[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Crash caused by new config/get_eq_char code

Crash caused by new config/get_eq_char code

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Mon 20 Jun 2005 02:23 PM (UTC)

Amended on Mon 20 Jun 2005 02:30 PM (UTC) by Dralnu

Message
I'm not sure what the problem here is, so I'll post the code and let you see for yourself


OBJ_DATA *
get_eq_char (CHAR_DATA * ch, int iWear)
{
	OBJ_DATA *obj, *maxobj = NULL;
	OBJ_DATA *cloak = NULL;
	for (obj = ch->first_carrying; obj; obj = obj->next_content)
		{
			if (obj->wear_loc == WEAR_ABOUT)   checks for cloak in wear_loc WEAR_ABOUT
			cloak = obj;
		}
	for (obj = ch->first_carrying; obj; obj = obj->next_content)
		{
			if (ch->pcdata && IS_SET (ch->pcdata->flags, PLR_CLOAK) && cloak)
			{
				if (obj->wear_loc != WEAR_FEET && obj->wear_loc != WEAR_HEAD && obj->wear_loc != WEAR_HANDS &&obj->wear_loc != WEAR_ABOUT && obj->wear_loc != WEAR_FACE && obj->wear_loc != WEAR_FLOAT && obj->wear_loc != WEAR_SHOULDER)
				continue;
			}
			else if (obj->wear_loc == iWear)
			{
				if (!obj->pIndexData->layers)
				return obj;
				else if (!maxobj || obj->pIndexData->layers > maxobj->pIndexData->layers)
				maxobj = obj;
			}
		}
	return maxobj;
}


I know it is caused by that somehow, or something related to it because it only crashes when you remove an obj, and when I changed to the stock code it worked perfectly fine



Edit #1
Forgot to subscribe, lol
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #1 on Mon 20 Jun 2005 03:27 PM (UTC)
Message
Can you show us the gdb results?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Reply #2 on Mon 20 Jun 2005 03:32 PM (UTC)
Message
Had a hard time with gdb, so I didn't get into it since I was fairly sure it was that code. I've changed the code some since then, the only problem I have now is the code working to only show certaint wearlocs.


OBJ_DATA *
get_eq_char (CHAR_DATA * ch, int iWear)
{
	OBJ_DATA *obj, *maxobj = NULL;
	for (obj = ch->first_carrying; obj; obj = obj->next_content)
		{
			if (ch->pcdata && IS_SET (ch->pcdata->flags, PLR_CLOAK) && obj->wear_loc == WEAR_ABOUT)
			{
				if (obj->wear_loc != WEAR_FEET && obj->wear_loc != WEAR_HEAD && obj->wear_loc != WEAR_HANDS && obj->wear_loc != WEAR_ABOUT && obj->wear_loc != WEAR_FACE && obj->wear_loc != WEAR_FLOAT && obj->wear_loc != WEAR_SHOULDER)
					{
						return obj;
						maxobj = obj;
					}
			}
			else if (obj->wear_loc == iWear)
			{
				if (!obj->pIndexData->layers)
					{
						return obj;
					}
				else if (!maxobj || obj->pIndexData->layers > maxobj->pIndexData->layers)
					{
						maxobj = obj;
					}
			}
		}
	return maxobj;
}


That doesn't cause crashes (for some odd reason), but the first if doesn't seem to work entirly right. It should only return feet, hands, about, ect., w/o shoing body and some other wearlocs. If I can get that to work I think I'll be good
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #3 on Mon 20 Jun 2005 03:35 PM (UTC)
Message
It's really hard to find out why it crashed without gdb. For all I know, an obj could be null.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Reply #4 on Mon 20 Jun 2005 03:39 PM (UTC)
Message
I'll see if I cann't get gdb to work for me, but at least I got it past the crashing point.
[Go to top] top

Posted by Zeno   USA  (2,871 posts)  [Biography] bio
Date Reply #5 on Mon 20 Jun 2005 03:39 PM (UTC)
Message
What were you having a hard time with? You should just be able to attach gdb to the process, continue, and cause the crash.

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Reply #6 on Mon 20 Jun 2005 03:44 PM (UTC)
Message
Some reason it just doesn't seem to like me, but like I said it doesn't crash anymore when you remove equipment like it did with the first posted code. Right now I just need to get the ifcheck to return the right wearlocs instead of showing everything, and I'll be done for the most part, cept maybe for cosmetic changes for send_to_char at times.
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #7 on Mon 20 Jun 2005 07:10 PM (UTC)
Message
Like Zeno said, you really should get gdb to work, that'll make debugging a lot simpler; random stabs are never a good idea. :)

As to your specific problem, it's hard to see what is wrong without knowing exactly what you had in mind. You're doing some odd stuff, for instance, after the inner-most if statement, you return maxobj but then assign obj to maxobj. But by returning maxobj, you've already left the function...

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Reply #8 on Mon 20 Jun 2005 08:21 PM (UTC)
Message
The return bit was trying to get something to work. As for random stabs, I knew it was that since it only crashed after the change in code and when the code worked. As for what I'm trying to do, is a cloak config to allow players to hide certain wearlocs, such as body, to help them keep their equip somewhat secret as for pk. I hope that helps explain what my goal is...
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #9 on Mon 20 Jun 2005 08:27 PM (UTC)
Message
Not really. :-) What is this 'maxobj' business?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Reply #10 on Mon 20 Jun 2005 08:32 PM (UTC)
Message
Rash attempt to get it to work. As is, with PLR_CLOAK on, when you look at someone, it doesn't show any equip on them, which is the problem as of right now

If I set it to return maxobj, think that would work? Or do I need to do something else to get it to work right?
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #11 on Tue 21 Jun 2005 03:18 AM (UTC)
Message
You know, there's a bigger problem with this approach. get_eq_char is used for lots of stuff, not just looking at people. If you start messing with it, you might find that your whole game is affected. Namely, that the game will not know if somebody is wearing something if they have a cloak on.

What is the difference between the player flag 'cloak' and having something about you?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Dralnu   USA  (277 posts)  [Biography] bio
Date Reply #12 on Tue 21 Jun 2005 03:40 AM (UTC)
Message
restricting what people see. Its kind of like pulling your cloak around you to hide what you are wearing...
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio
Date Reply #13 on Tue 21 Jun 2005 03:53 AM (UTC)
Message
That's not what I meant. :) Your if statement checks for those two things:
if (ch->pcdata && IS_SET (ch->pcdata->flags, PLR_CLOAK) && obj->wear_loc == WEAR_ABOUT)
Is that what you want to do?

Furthermore, if you've established that obj is a wear_about item, how could it possibly be any of the other wearlocs you're checking for?

Looking over your first solution again, it actually looks like it's much closer to what you want to do. The second solution is simply wrong.

As to why your code is crashing, I'm almost certain that it's because you messed with the wrong function. As I said, get_eq_char is a function that the game uses to determine a player's equipment. What you're trying to do is prevent a player from seeing somebody else's equipment. Those are two very different things; by changing get_eq_char you probably are breaking a huge number of things.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] 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.


19,417 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]