Register forum user name Search FAQ

Gammon Forum

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 ➜ Need help with bug.

Need help with bug.

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


Posted by Toy   (206 posts)  Bio
Date Wed 18 Feb 2004 02:50 PM (UTC)
Message
Attempted to do this command "setclass warrior mtitle 54 Admin" and got this bug message:

Log: Toy: setclass warrior mtitle 54 Admin
Log: [*****] BUG: Freeing null pointer act_wiz.c:7700

So I tracked down the part of the code in error..
	DISPOSE( title_table[cl][x][0] );
	title_table[cl][x-1][0] = str_dup( argument );


Anyone know what's up?
-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #1 on Wed 18 Feb 2004 05:49 PM (UTC)

Amended on Wed 18 Feb 2004 05:50 PM (UTC) by Greven

Message
Yeah, it means that it was not initialized and not read in(not nessecarily a bad thing) and was missing the proper check. It should have been this:
	if ( title_table[cl][x][0] )
		DISPOSE( title_table[cl][x][0] );
	title_table[cl][x-1][0] = str_dup( argument );


That error is to protect your from freeing memory that doesn't exist, and that check simply checks that it is pointing somewhere.

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
Top

Posted by Toy   (206 posts)  Bio
Date Reply #2 on Wed 18 Feb 2004 06:11 PM (UTC)
Message
    if ( !str_cmp( arg2, "mtitle" ) )
    {
	char arg3[MAX_INPUT_LENGTH];
	int x;

	argument = one_argument( argument, arg3 );
	if ( arg3[0] == '\0' || argument[0] == '\0' )
	{
	    send_to_char( "Syntax: setclass <class> mtitle <level> <title>\n\r", ch );
	    return;
	}
	if ( (x=atoi(arg3)) < 0 || x > MAX_LEVEL )
	{
	    send_to_char( "Invalid level.\n\r", ch );
	    return;
	}
	if ( title_table[cl][x][0] )
		DISPOSE( title_table[cl][x][0] );
	title_table[cl][x-1][0] = str_dup( argument );
    }
    if ( !str_cmp( arg2, "ftitle" ) )
    {
	char arg3[MAX_INPUT_LENGTH];
	char arg4[MAX_INPUT_LENGTH];
	int x,sex;

	argument = one_argument( argument, arg3 );
	argument = one_argument( argument, arg4 );
	if ( arg3[0] == '\0' || argument[0] == '\0' )
	{
	    send_to_char( "Syntax: setclass <class> ftitle <level> <male/female> <title>\n\r", ch );
	    return;
	}
	if ( (x=atoi(arg4)) < 0 || x > MAX_LEVEL )
	{
	    send_to_char( "Invalid level.\n\r", ch );
	    return;
	}
	if ( !str_cmp( arg4, "Male") )
		sex = 0;
        else
		sex = 1;
	if ( title_table[cl][x][sex] )
	DISPOSE( title_table[cl][x][sex] );
	/* Bug fix below -Shaddai*/
	title_table[cl][x][sex] = str_dup( argument );
    }
    do_setclass( ch, "" );
}


It's strange. That cleared up the that bug, but now this happens:

Log: Toy: setclass 3 mtitle 54 admin
Syntax: setclass <class> <field> <value>
Syntax: setclass <class> create

Field being one of:
name prime weapon guild thac0 thac32
hpmin hpmax mana expbase mtitle ftitle
second, deficient affected resist suscept

No matter what I type in for mtitle and level, it just keeps show the Syntax message.

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Toy   (206 posts)  Bio
Date Reply #3 on Wed 18 Feb 2004 07:06 PM (UTC)
Message
Solved it. Since "ftitle" changed both male and female titles, I removed mtitle, changed ftitle into just title,
removed this at the bottom of the code:

do_setclass( ch, "" );

And finally, I adjusted this part:

	if ( (x=atoi(arg4)) < 0 || x > MAX_LEVEL )
	{
	    send_to_char( "Invalid level.\n\r", ch );
	    return;
	}


I just changed arg4 to arg3, because because arg4 was calling to sex, not level. Didn't need to arg4's. :)

-Toy

It's always good to know how far you are willing to go to be the best...

Karl Mancine
aka
Toy the Dark Puppet
Top

Posted by Greven   Canada  (835 posts)  Bio
Date Reply #4 on Wed 18 Feb 2004 09:47 PM (UTC)
Message
It looks like the original worked, the reason you were getting the error was because there was no return after the indivudual sections, so it would fall down to the the do_setclass

Nobody ever expects the spanish inquisition!

darkwarriors.net:4848
http://darkwarriors.net
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.


18,491 views.

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

Go to topic:           Search the forum


[Go to top] top

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