Welcome to the Builder Academy

Question help with a identify change

More
12 Aug 2012 21:18 #657 by bakarus
In spells.c inside of ASPELL(spell_identify) beneath this case
Code:
case ITEM_ARMOR: send_to_char(ch, "AC-apply is %d\r\n", GET_OBJ_VAL(obj, 0)); break;
i added some code to hopefully show players how much their containers can hold
Code:
case ITEM_CONTAINER: sprintbit(GET_OBJ_VAL(obj, 1), container_bits, buf, sizeof(buf)); send_to_char(ch, "\tBWeight capacity:\tG %d\tn\r\n", GET_OBJ_VAL(j, 0)); break;

at the top of the function i added:
Code:
struct obj_data *j; char buf[MAX_STRING_LENGTH];

But whenever you c 'identify' on a container it disconnects you from the mud, it doesn't kick any gdb errors or anything, it just disconnects you.

I realize you guys probably get tired of newbie mud coders but thanks for any help. :)

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

More
12 Aug 2012 22:13 #658 by Vatiken
  1. You don't need to declare a "char buf" since "char bitbuf" is already assigned for the exact same purpose.
  2. I'm not sure why you declared an obj_data *j, since it's not used for anything.
  3. You used sprintbit() on your "char buf" but never end up using "buf".
  4. You attempt to send_to_char() some data associated with obj_data *j, but the object data is already assigned, and ONLY assigned to *obj.
  5. If you have a compiler that successfully compiled this, bury it in your front yard.

All you should need is something like this:
Code:
case ITEM_CONTAINER: sprintbit(GET_OBJ_VAL(obj, 1), container_bits, bitbuf, sizeof(bitbuf)); send_to_char(ch, "\tBWeight capacity:\tG %d\r\n" "\tBBits:\tG %s\r\n", GET_OBJ_VAL(obj, 0), bitbuf); break;

tbaMUD developer/programmer

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

More
12 Aug 2012 22:47 #659 by Halenbane

If you have a compiler that successfully compiled this, bury it in your front yard.


LMAO

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

More
12 Aug 2012 23:06 #660 by bakarus
Ouch, and thanks.

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

More
12 Aug 2012 23:51 #661 by Vatiken

Halenbane wrote:

If you have a compiler that successfully compiled this, bury it in your front yard.


LMAO

bakarus wrote: it doesn't kick any gdb errors or anything

Wasn't meant as a slap in the face, but anything less than the following is unacceptable.
Code:
spells.c: In function ‘spell_identify’: spells.c:357: error: ‘j’ undeclared (first use in this function) spells.c:357: error: (Each undeclared identifier is reported only once spells.c:357: error: for each function it appears in.) make[1]: *** [spells.o] Error 1
We all make goofy and/or stupid mistakes sometimes and I'd much prefer the compiler puke on me then my player base when everyone keeps getting randomly disconnected from the MUD.

tbaMUD developer/programmer

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

Time to create page: 0.199 seconds