git » fp-git.git » commit 3adf724

better NULL pointer documentation and testing

author ecalot
2004-10-24 00:39:32 UTC
committer ecalot
2004-10-24 00:39:32 UTC
parent a0975229157beb388058d86b8fc21fa33869de32

better NULL pointer documentation and testing

FP/src/include/states.h +16 -1
FP/src/ker/states.c +2 -2

diff --git a/FP/src/include/states.h b/FP/src/include/states.h
index a452b8f..b344ad1 100644
--- a/FP/src/include/states.h
+++ b/FP/src/include/states.h
@@ -31,7 +31,22 @@ typedef struct {
 /* public functions interface */
 
 /* This function should return the frame flags
- * and actions to be performed by this call */
+ * and actions to be performed by this call
+ *
+ * Usage:
+ *  stateUpdate(tKey* key, tKid* kid,tRoom* room);
+ *  where key is a tKey* with the current key state (read from a file,
+ *  keyboard or joystick) or NULL in case there is no need to interpretate
+ *  key events to manipulate states
+ *
+ *  kid is a pointer to a person or object that uses states, with states
+ *  initialized properly by createState fucntion.
+ *
+ *  room is a pointer to a room where the events will be interpreted, the NULL
+ *  pointer is allowed. In that case actions that needs map conditions won't
+ *  be performed.
+ */
+
 short stateUpdate(tKey* key, tKid* kid,tRoom* room);
 
 /* Create a State depending on the level */
diff --git a/FP/src/ker/states.c b/FP/src/ker/states.c
index 7f99201..723c1c3 100644
--- a/FP/src/ker/states.c
+++ b/FP/src/ker/states.c
@@ -50,8 +50,8 @@ tState createState(int level) {
 /* private functions */
 
 /* Evaluates a condition indexed in the condition table */
-#define DefaultTrue(pointer) if (pointer) return STATES_CONDRESULT_TRUE
-#define DefaultFalse(pointer) if (pointer) return STATES_CONDRESULT_TRUE
+#define DefaultTrue(pointer) if (!pointer) return STATES_CONDRESULT_TRUE
+#define DefaultFalse(pointer) if (!pointer) return STATES_CONDRESULT_TRUE
 int evaluateCondition(int condition,tKey* key, tKid* kid, tRoom* room) {
 	tsCondition c=statesConditionList[condition];
 #define thisTile (kid->location/STATES_STEPS_PER_TILE+1+12*kid->floor)