I didn't fix your problem because you didn't identify it. If the game
"crashes", a line number will show you exactly where in gdb with a bt.
I have (shown with comments) pointed out a few potential problems with
your code. Unlike your C or C++ class where you've learned that
multiple return points is bad, in ROM it is relatively essential. Use
them when you need to.
void save_char_creation( CHAR_DATA *ch )
{
DESCRIPTOR_DATA *d;
//USE BETTER VARIABLE NAMES. Also, refactor your code so that you don't
double
//use loop variables, such as how you use 'i' in your for-hell below.
int rb,i,j,sn;
//First, you had better make sure ch isn't a mob because you access
pcdata later.
if( IS_NPC(ch))
return;
//What if ch isn't in the descriptor list? And why the hell are you
doing this?
//Just do ch->desc if you need it.
for ( d = descriptor_list; d != NULL; d = d->next )
if(!strcmp(d->character->name,ch->name))
break;
//What if ch isn't doing whatever to create_table? Then rb will be
"pc_creating".
//you need to check if rb is valid before using it.
for(rb=0;rb<pc_creating;rb++)
if(!strcmp(create_table[rb].name,ch->name))
break;
//You're missing so many opening braces for the below for and if statements
//that the code isn't even readable. gcc should be screaming at you. If it
//isn't, compile with -Wall. If you aren't compiling with -Wall, then you
//have a death wish.
for(sn=0;sn<maxSkill;sn++)
if(create_table[rb].skill[sn])
{
ch->pcdata->has_skill[sn] = TRUE;
ch->pcdata->skill_level[sn] = skill_table[sn].rating[ch->class];
if(ch->pcdata->skill_level[sn] == 1 )
ch->pcdata->learned[sn] = 1;
}
for(sn=0;sn<maxGroup;sn++)
if(create_table[rb].group[sn])
for(i=0;i<maxInGroup;i++)
if(group_table[sn].spells[i] != NULL)
{
j = skill_lookup(group_table[sn].spells[i]);
ch->pcdata->has_skill[j] = TRUE;
ch->pcdata->skill_level[j] =
skill_table[j].rating[ch->class];
if(ch->pcdata->skill_level[j] == 1 )
ch->pcdata->learned[j] = 1;
}
logf("clothes:)");
act( "$n has entered the game.", ch, NULL, NULL, TO_ROOM );
logf("bank:)");
ch->class = create_table[rb].newclass;
ch->race = create_table[rb].race;
ch->alignment= create_table[rb].align;
ch->sex = create_table[rb].gender;
ch->gold = 0;
ch->primary_weap = create_table[rb].weapon;
for (i = 0; i < MAX_STATS; i++)
ch->perm_stat[i] = pc_race_table[ch->race].stats[i];
ch->affected_by = ch->affected_by|race_table[ch->race].aff;
ch->imm_flags = ch->imm_flags|race_table[ch->race].imm;
ch->res_flags = ch->res_flags|race_table[ch->race].res;
ch->vuln_flags = ch->vuln_flags|race_table[ch->race].vuln;
ch->form = race_table[ch->race].form;
ch->parts = race_table[ch->race].parts;
ch->size = pc_race_table[ch->race].size;
ch->pcdata->points = create_table[rb].cp;
SET_BIT(ch->act,PLR_AUTOASSIST);
SET_BIT(ch->act,PLR_AUTOEXIT);
SET_BIT(ch->act,PLR_AUTOGOLD);
SET_BIT(ch->act,PLR_AUTOSAC);
SET_BIT(ch->act,PLR_AUTOLOOT);
SET_BIT(ch->act,PLR_COLOUR);
do_function (ch, &do_outfit,"");
obj_to_char(create_object(get_obj_index(OBJ_VNUM_MAP),0),ch);
char_to_room( ch, get_room_index( ROOM_VNUM_SCHOOL ) );
send_to_char("\n\r",ch);
logf("1");
logf("2");
logf("3");
do_function(ch, &do_look, "auto" );
logf("4");
wiznet("$N has left real life behind.",ch,NULL,
WIZ_LOGINS,WIZ_SITES,get_trust(ch));
if (ch->pet != NULL)
{
char_to_room(ch->pet,ch->in_room);
act("$n has entered the game.",ch->pet,NULL,NULL,TO_ROOM);
}
do_function(ch, &do_unread, "");
if (ch->pcdata->host == NULL
|| sizeof(ch->pcdata->host) == 0
|| !str_cmp(ch->pcdata->host, "none"))
ptc(ch, "{cUpdating site login info: {y%s{x\n\r", d->host);
else if (!str_cmp(ch->pcdata->host, d->host))
ptc(ch, "{cUsual login: {y%s{x\n\r", ch->pcdata->host);
else
ptc(ch,"{cLast login: {y%s{x\n\r"
"{cCurrent login: {y%s{x\n\r",
ch->pcdata->host,d->host);
//Memory leak below. Add this line.
// free_string(ch->pcdata->host);
ch->pcdata->host = str_dup(d->host);
ch->pcdata->confirm_delete = FALSE;
ch->pcdata->confirm_rebirth = FALSE;
ch->pcdata->creation = FALSE;
pc_creating--;
return;
}
_________________________________________________________________
Take advantage of powerful junk e-mail filters built on patented
Microsoft® SmartScreen Technology.
http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines
Start enjoying all the benefits of MSN® Premium right now and get the
first two months FREE*.
--
ROM mailing list
[email protected]
http://www.rom.org/cgi-bin/mailman/listinfo/rom
omar miisa wrote:
>crap