Welcome to the Builder Academy

Question Item Durability

More
22 Mar 2014 19:44 - 22 Mar 2014 19:45 #4770 by bakarus
Replied by bakarus on topic Item Durability
I added everything from the snippet, and am getting an error on compile,
Code:
gcc -g -O2 -Wall -c -o act.comm.o act.comm.c gcc -g -O2 -Wall -c -o act.informative.o act.informative.c act.informative.c: In function ‘show_obj_to_char’: act.informative.c:122: error: called object ‘obj->obj_flags.durability’ is not a function act.informative.c:123: error: called object ‘obj->obj_flags.durability’ is not a function act.informative.c:145: error: called object ‘obj->obj_flags.durability’ is not a function act.informative.c:146: error: called object ‘obj->obj_flags.durability’ is not a function make[1]: *** [act.informative.o] Error 1

checked structs.h and the line is there for int durability;

not sure what else could be wrong, here are the lines, line 122 is the first line,
Code:
if ((GET_OBJ_MAX_DURAB(obj) != 0) && (GET_OBJ_MAX_DURAB(obj) > GET_OBJ_DURABILITY(obj))) percent = (100 * GET_OBJ_DURABILITY(obj)) / GET_OBJ_MAX_DURAB(obj); else percent = 100;
Last edit: 22 Mar 2014 19:45 by bakarus.

Please Log in or Create an account to join the conversation.

More
22 Mar 2014 22:18 #4771 by thomas
Replied by thomas on topic Item Durability
how does the GET_OBJ_MAX_DURAB macro look like?

Please Log in or Create an account to join the conversation.

More
23 Mar 2014 01:45 #4772 by bakarus
Replied by bakarus on topic Item Durability
I believe it is
Code:
#define GET_OBJ_MAX_DURAB(obj) ((obj)->obj_flags.max_durab)

Please Log in or Create an account to join the conversation.

More
23 Mar 2014 09:02 #4773 by thomas
Replied by thomas on topic Item Durability
sorry - meant GET_OBJ_DURABILITY - apparently it's not got the (obj) suffix in the definition.
This means the preprocessor will substitute it as

obj->obj_flags.durability(obj)
The following user(s) said Thank You: bakarus

Please Log in or Create an account to join the conversation.

More
24 Mar 2014 03:08 #4774 by bakarus
Replied by bakarus on topic Item Durability
You were exactly right, I was missing the (obj) on the macro
Code:
GET_OBJECT_DURABILITY (obj->obj_flags.durability)

missing the (obj) after, shoulda been
Code:
GET_OBJECT_DURABILITY(obj) (obj->obj_flags.durability)

Please Log in or Create an account to join the conversation.

Time to create page: 0.230 seconds