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
➜ get_obj_weight: NULL obj crash
get_obj_weight: NULL obj crash
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Mon 30 Aug 2004 04:06 AM (UTC) Amended on Mon 30 Aug 2004 04:08 AM (UTC) by Zeno
|
Message
| After months of tracking this rare bug, I finally found what was causing it.
wear hunter
You wield a hunter's longbow.
wear demonic
Log: [*****] BUG: get_obj_weight: NULL obj!
You dual-wield a demonic sword.
The sword surges with a demonic power as Zeno wields it in his hand!
So a bow and sword.
ostat hunter
Name: hunter longbow
Vnum: 2860 Type: missileweapon Count: 38 Gcount: 1
Serial#: 426 TopIdxSerial#: 426 TopSerial#: 552
Short description: a hunter's longbow
Long description : A hunter's longbow lies here.
Wear flags : take missile
Extra flags:
Magic flags: none
Number: 1/1 Weight: 1/1 Layers: 0 Wear_loc: 21
Cost: 0 Rent: 0 Timer: 0 Level: 115
In room: 0 In object: (none) Carried by: Zeno
Index Values : 12 0 100 14 10 0.
Object Values: 12 30 91 14 10 0.
Attached shards: 0
ostat demonic
Name: demonic sword
Vnum: 2851 Type: weapon Count: 6 Gcount: 1
Serial#: 427 TopIdxSerial#: 427 TopSerial#: 564
Short description: a demonic sword
Long description : A demonic sword lies here crackling with energy.
Wear flags : take wield
Extra flags: glow hum antihuman antihanyou
Magic flags: none
Number: 1/1 Weight: 1/1 Layers: 0 Wear_loc: 18
Cost: 0 Rent: 0 Timer: 0 Level: 115
In room: 0 In object: (none) Carried by: Zeno
Index Values : 12 8 10 3 0 0.
Object Values: 12 8 80 3 0 0.
Attached shards: 0
int get_obj_weight( OBJ_DATA *obj )
{
int weight;
if ( !obj )
{
bug( "get_obj_weight: NULL obj!\n\r" );
return 0;
}
weight = obj->count * obj->weight;
/* magic containers */
if ( obj->item_type != ITEM_CONTAINER || !IS_OBJ_STAT(obj, ITEM_MAGIC) )
for ( obj = obj->first_content; obj; obj = obj->next_content )
weight += get_obj_weight(obj);
return weight;
}
Called from wear_obj:
OBJ_DATA *mw, *dw, *hd;
tmpobj = get_eq_char(ch, WEAR_WIELD);
mw = get_eq_char(ch, WEAR_MISSILE_WIELD);
dw = get_eq_char(ch, WEAR_DUAL_WIELD);
hd = get_eq_char(ch, WEAR_HOLD);
if ( tmpobj || mw )
{
if ( !can_dual( ch ) )
return;
if ( get_obj_weight(obj) + get_obj_weight(tmpobj) > (get_curr_str(ch)) )
{
send_to_char( "It is too heavy for you to wield.\n\r", ch );
return;
}
Okay, so I need to do some sort of check here for getting the weight of the worn eq.
This appears to be a bug, and I'm using SmaugFUSS. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Robert Powell
Australia (367 posts) Bio
|
Date
| Reply #1 on Mon 13 Sep 2004 10:05 AM (UTC) Amended on Mon 13 Sep 2004 10:08 AM (UTC) by Robert Powell
|
Message
| I dont know why it happens but i fixed it by removing the if checks to see if you can wield by weight, the problem with that section of code is that it doesnt matter what weight you make the obj's in question it always crashes and its only on missile_wields, not normal dual wields, there are much nicer ways to stop certain classes or races from using a peice of eq, and in this case it limiting the class/race combinations that receive those skills is a much simpler solution, i say scrap all tha code and forget the weight check all together. |
Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated. | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #2 on Tue 14 Sep 2004 05:28 PM (UTC) Amended on Tue 14 Sep 2004 05:29 PM (UTC) by Zeno
|
Message
| The way to solve this is simple, but it requires about 5 different ifchecks and calls to get_obj_weight, which I do not intend to do. Something of the sort of this would be done:
if ( tmpobj )
{
if get_obj_weight(obj) + get_obj_weight(tmpobj) > (get_curr_str(ch) )
(send to char etc)
}
if ( mw )
{
get_obj_weight(obj) + get_obj_weight(mw) > (get_curr_str(ch) )
(send to char etc)
}
if ( dw )
{
get_obj_weight(obj) + get_obj_weight(dw) > (get_curr_str(ch) )
(send to char etc)
}
if ( hd )
{
get_obj_weight(obj) + get_obj_weight(hd) > (get_curr_str(ch) )
(send to char etc)
}
What could be done is this:
tempvar = get_obj_weight(hd) + get_obj_weight(dw) + get_obj_weight(mw) + get_obj_weight(tmpobj)
Then check on tempvar.
I'm in my Cisco Course right now, so I can't think that over if it'll work. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Mon 20 Sep 2004 03:47 AM (UTC) Amended on Mon 20 Sep 2004 03:48 AM (UTC) by David Haley
|
Message
| Well for my part I find your fix code hard to read, and without it being obvious what has changed to what I can't judge the quality of the fix. :)
(EDIT) More specifically, it's hard to read because of the bad indenting. (/EDIT)
Besides, I've never once had this bug in my codebase, so I don't know much about it in the first place. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #4 on Mon 20 Sep 2004 04:04 PM (UTC) |
Message
| You asked why people hadn't commented on it. I told you that for my part it's because I don't like reading code that isn't indented properly - especially if the code isn't really relevant to me (since I've [i]never[/i] had this bug.) It wasn't meant to embarass, but to tell you frankly why I hadn't commented on it. I can't help but think that if you didn't want to know you shouldn't have asked. :) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #5 on Mon 20 Sep 2004 08:07 PM (UTC) |
Message
| Like I said before, I do not see a way to fix this without creating 5 different ifchecks, which by the way I see it, isn't worth it. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #6 on Tue 05 Oct 2004 07:10 PM (UTC) |
Message
| The bug has been fixed by Gatewaysysop and Samson, on the MudPlanet forums.
http://forums.mudplanet.org/index.php?act=ST&f=54&t=9&st=25#entry3320 |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #7 on Wed 06 Oct 2004 01:13 AM (UTC) |
Message
| Looks like somebody decided to delete their posts from this thread...? |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #8 on Wed 06 Oct 2004 01:19 AM (UTC) |
Message
| I noticed that too. I think his user was deleted or username was changed. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #9 on Wed 06 Oct 2004 07:12 AM (UTC) Amended on Wed 06 Oct 2004 07:13 AM (UTC) by Nick Gammon
|
Message
| Yes, Gatewaysysop2 has deleted a number of messages in this thread. I suppose he took exception at being told his code was hard to read.
I have them on my audit trail, and would appreciate it if people don't delete messages in threads unnecessarily, as it makes the threads hard to read.
It might also help if comments about code being hard to read was done in a constructive way, eg. "it would help to read the code if you indented it like this [give example]".
|
- Nick Gammon
www.gammon.com.au, www.mushclient.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.
22,811 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top