argument = one_argument( argument, arg1 );
argument = one_argument( argument, arg2 );
argument = one_argument( argument, arg3 );
argument = one_argument( argument, arg1 );
argument = one_argument( argument, target_name );
argument = one_argument( argument, arg3 );
/*
* The kludgy global is for spells who want more stuff from command line.
*/
char *target_name;
print target_name
$1 = 0x836319e ""
target_name = one_argument( argument, arg1 );
one_argument( target_name, arg2 );
percentage = 100;
argument = one_argument(argument, arg1);
if (*arg1 != '\0' && is_number(arg1))
{
percentage = atol(arg1);
argument = one_argument(argument, arg1);
percentage = URANGE(1, percentage, 100);
}
target_name = argument;
argument = one_argument( argument, arg2 );
argument = one_argument( argument, arg3 );
….
level = level * percentage / 100 ;
if (level < 1)
{
level = 1;
}
target_name = one_argument( argument, arg1 );
one_argument( target_name, arg2 );
We've redone a good bit of our magic system, and so we have our stock do_cast function copied over as do_cast2 and it is able to be used under the cast2 command by immortals and such. Everything was working fine, until I decided to add in an optional value on the end of the function for spell level. This crash doesn't happen very often, but enough to be annoying and a problem. When it reaches a certain part where I have it copying over "arg2" (the spot where the victim's name is usually input) over to the target_name value, strcpy likes to crash on occasion.
Here is the gdb back trace, with some frame and print values:
Frame 1 list:
The associated printing of various things in the frame:
The entire top of the cast2 function:
I can tell something is going wrong with arg1, arg2, and arg3, and that the function is likely crashing because I'm trying to copy garbage over into the blank target_name value.
The input on the command I used was:
cast2 rej diabolo
rej being short for 'rejuvenate', a valid spell, and diabolo being short for 'diablolos' a mob I was fighting. Also, the garbage from the prints were echoes and program information on the mob I was fighting, but this has happened when cast on players, mobs with no programs, myself w/o any arguments… so I'm kind of at a loss.
Any help would be greatly appreciated.