Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Crash on closing..
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Sun 08 Jun 2003 10:36 AM (UTC) Amended on Sun 08 Jun 2003 10:38 AM (UTC) by Nick Cash
|
Message
| Alright, I've tried to install a locker code into my mud, and it has worked perfectly except for one thing. They cannont close the locker, and I know how unspecific that can be so I'll post the closing code here. Then if I must I will post additional code such as the fwrite_locker and such. It only crashes on closing the locker by the way.
From the do_locker function:
else if( !str_cmp( arg, "close" ) )
{
if( !ch->pcdata->locker )
{
send_to_char( "You are not currently in the locker room.\r\n", ch );
return;
}
locker = ch->pcdata->locker;
/* Total the weight of the contents */
locker->holding = 0;
for( obj = ch->in_room->first_content; obj; obj = obj->next_content )
{
locker->holding = locker->holding + obj->weight;
if( obj->item_type == ITEM_CONTAINER )
{
send_to_char( "You may not leave containers in the locker room.\r\n", ch );
return;
}
}
if( locker->holding > locker->capacity )
{
sprintf( buf, "The weight limit of your locker has beed exceeded. "
"You must carry\r\nsome items out when you leave.\r\n" );
send_to_char( buf, ch );
return;
}
/* Save the locker */
fwrite_locker( ch );
/* Return the player to the real world. */
char_from_room( ch );
char_to_room( ch, get_room_index( ch->pcdata->locker_vnum ) );
delete_locker( ch );
do_look( ch, "auto" );
send_to_char( "Your locker has been closed and saved.\r\n", ch );
}
else
{
send_to_char( "Syntax: locker <open | close>\r\n", ch );
return;
}
return;
}
Trying to find where the error really is I added in send_to_char statements before delete_locker and fwrite_locker, assuming that they would show up before it crashed. Assuming that would work right, and it always has before, then those functions are clean because it crashes before either come up. Perhaps a problem with the for loop? I'm not sure, please help :) |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Boborak
USA (228 posts) Bio
|
Date
| Reply #1 on Mon 09 Jun 2003 10:49 AM (UTC) |
Message
| Hmm, this is one of those bugs that doesn't jump out at you very clearly. It could be a number of problems not directly rlated to this bit of code as well. You really should run GDB on this error. Since it's reproduceable you should be able to find the problem easy enough. Also, have you tried "triggering" any of the returns? i.e. dropping a container or 'exceeding the weight limit' ? That's always a good place to start. It'll give you an idea of where the crash is occuring.
If I had to guess.
I'd say these lines are your prime targets:
/* Save the locker */
fwrite_locker( ch );
/* Return the player to the real world. */
char_from_room( ch );
char_to_room( ch, get_room_index( ch->pcdata->locker_vnum ) );
delete_locker( ch );
GDB is your friend ;-) | Top |
|
Posted by
| Samson
USA (683 posts) Bio
|
Date
| Reply #2 on Tue 10 Jun 2003 08:09 AM (UTC) |
Message
| Strange memories of having seen locker problems before when I was helping with Resortmud.... hmmm. I forget how they fixed it but it looks like you have the same code. Might want to ask them :) | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #3 on Thu 12 Jun 2003 02:24 PM (UTC) |
Message
| Now, I got it fixed, and I'm sure your all wondering how! Or not, doesn't matter. Anyways, thanks Samson. I just downloaded they beta version and stuck their locker.c where mine used to be and with my modifications I needed it worked like a charm. Anyways, thanks! |
~Nick Cash
http://www.nick-cash.com | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
14,056 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top