|
From: <lor...@us...> - 2008-11-22 00:53:45
|
Revision: 41
http://deraciel.svn.sourceforge.net/deraciel/?rev=41&view=rev
Author: lordhoto
Date: 2008-11-22 00:53:40 +0000 (Sat, 22 Nov 2008)
Log Message:
-----------
Added identified flag to obj descriptors.
Modified Paths:
--------------
trunk/obj_types.c
trunk/obj_types.h
trunk/object.h
trunk/util.h
Modified: trunk/obj_types.c
===================================================================
--- trunk/obj_types.c 2008-11-22 00:39:38 UTC (rev 40)
+++ trunk/obj_types.c 2008-11-22 00:53:40 UTC (rev 41)
@@ -3,9 +3,11 @@
// Gold piles always contain 0 coins by default
static const uint32_t coins_default_value = 0;
-static const struct obj_desc_struct obj_descs[] = {
- { OBJ_DESC_COINS, &coins_default_value, sizeof(coins_default_value) },
- { OBJ_DESC_INVALID, NULL, 0 }
+#define DEFINE_OBJ(ID, d, s) { ID, false, d, s }
+
+static struct obj_desc_struct obj_descs[] = {
+ DEFINE_OBJ(OBJ_DESC_COINS, &coins_default_value, sizeof(coins_default_value)),
+ DEFINE_OBJ(OBJ_DESC_INVALID, NULL, 0)
};
const struct obj_desc_struct *obj_desc_find(obj_descriptor_id id) {
@@ -20,3 +22,16 @@
return NULL;
}
+bool obj_desc_is_identified(obj_descriptor_id id) {
+ const struct obj_desc_struct *desc = obj_desc_find(id);
+ if (desc)
+ return desc->is_identified;
+ return false;
+}
+
+void obj_desc_mark_identified(obj_descriptor_id id) {
+ struct obj_desc_struct *desc = (struct obj_desc_struct *)obj_desc_find(id);
+ if (desc)
+ desc->is_identified = true;
+}
+
Modified: trunk/obj_types.h
===================================================================
--- trunk/obj_types.h 2008-11-22 00:39:38 UTC (rev 40)
+++ trunk/obj_types.h 2008-11-22 00:53:40 UTC (rev 41)
@@ -1,6 +1,8 @@
#ifndef DERACIEL_OBJ_TYPES_H
#define DERACIEL_OBJ_TYPES_H
+#include "util.h"
+
#include <stdint.h>
#include <string.h>
@@ -8,14 +10,14 @@
#define OBJ_DESC_INVALID ((obj_descriptor_id)-1)
-/*
+/**
* Different object types we have
*/
enum {
- /*
+ /**
* Object type for coins.
*
- * [default_data] = uint32_t
+ * [default_data] = uint32_t => indicating how many gold coins there are
*/
OBJ_DESC_COINS
};
@@ -23,11 +25,17 @@
struct obj_desc_struct {
obj_descriptor_id id;
+ bool is_identified;
+
const void *default_data;
size_t default_data_size;
};
const struct obj_desc_struct *obj_desc_find(obj_descriptor_id id);
+bool obj_desc_is_identified(obj_descriptor_id id);
+
+void obj_desc_mark_identified(obj_descriptor_id id);
+
#endif
Modified: trunk/object.h
===================================================================
--- trunk/object.h 2008-11-22 00:39:38 UTC (rev 40)
+++ trunk/object.h 2008-11-22 00:53:40 UTC (rev 41)
@@ -19,3 +19,4 @@
void obj_uninit(struct obj_struct *obj);
#endif
+
Modified: trunk/util.h
===================================================================
--- trunk/util.h 2008-11-22 00:39:38 UTC (rev 40)
+++ trunk/util.h 2008-11-22 00:53:40 UTC (rev 41)
@@ -24,5 +24,17 @@
#define mem_dealloc(var) free(var)
+#ifndef bool
+#define bool unsigned char
+#endif // !bool
+
+#ifndef true
+#define true 1
+#endif // !true
+
+#ifndef false
+#define false 0
+#endif // !false
+
#endif // !DERACIEL_UTIL_H
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|