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 ➜ MUDs ➜ General ➜ [*****] BUG: Load_char_obj: # not found.

[*****] BUG: Load_char_obj: # not found.

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


Posted by RayneVII   (1 post)  Bio
Date Fri 24 Sep 2004 02:39 AM (UTC)
Message
As you can probably tell from the post, my problem is this.

[*****] BUG: Load_char_obj: # not found.

The little bit of script there that is found is this:

/*
* Load a char and inventory into a new ch structure.
*/
#pragma warning (disable: 4101)
bool load_char_obj( DESCRIPTOR_DATA *d, char *name )
{
char strsave[_MAX_PATH];
char buf[100];
CHAR_DATA *ch;
FILE *fp;
bool found;
int stat;

ch = new_char();
ch->pcdata = new_pcdata();

d->character = ch;
ch->desc = d;
ch->name = str_dup( name );
ch->id = get_pc_id();
ch->race = race_lookup("human");
ch->act = PLR_NOSUMMON;
ch->comm = COMM_COMBINE
| COMM_PROMPT;
ch->prompt = str_dup("<%hhp %mm %vmv> ");
ch->pcdata->confirm_delete = FALSE;
ch->pcdata->pwd = str_dup( "" );
ch->pcdata->bamfin = str_dup( "" );
ch->pcdata->bamfout = str_dup( "" );
ch->pcdata->title = str_dup( "" );
for (stat =0; stat < MAX_STATS; stat++)
ch->perm_stat[stat] = 13;
ch->pcdata->condition[COND_THIRST] = 48;
ch->pcdata->condition[COND_FULL] = 48;
ch->pcdata->condition[COND_HUNGER] = 48;
ch->pcdata->security = 0; /* OLC */

found = TRUE;
fclose( fpReserve );

#if defined(unix)
/* decompress if .gz file exists */
sprintf( strsave, "%s%s%s", PLAYER_DIR, capitalize(name),".gz");
if ( ( fp = fopen( strsave, "r" ) ) != NULL )
{
fclose(fp);
sprintf(buf,"gzip -dfq %s",strsave);
system(buf);
}
#endif

sprintf( strsave, "%s%s", PLAYER_DIR, capitalize( name ) );
if ( ( fp = fopen( strsave, "r" ) ) != NULL )
{
int iNest;

for ( iNest = 0; iNest < MAX_NEST; iNest++ )
rgObjNest[iNest] = NULL;

found = TRUE;
for ( ; ; )
{
char letter;
char *word;

letter = fread_letter( fp );
if ( letter == '*' )
{
fread_to_eol( fp );
continue;
}

if ( letter != '*' )
{
bug( "Load_char_obj: # not found.", 0 );
break;
}

word = fread_word( fp );
if ( !str_cmp( word, "PLAYER" ) ) ( ch, fp );
else if ( !str_cmp( word, "OBJECT" ) ) fread_obj ( ch, fp );
else if ( !str_cmp( word, "O" ) ) fread_obj ( ch, fp );
else if ( !str_cmp( word, "PET" ) ) fread_pet ( ch, fp );
else if ( !str_cmp( word, "END" ) ) break;
else
{
bug( "Load_char_obj: bad section.", 0 );
break;
}
}
fclose( fp );
}

fpReserve = fopen( NULL_FILE, "r" );


/* initialize race */
if (found)
{
int i;

if (ch->race == 0)
ch->race = race_lookup("human");

ch->size = pc_race_table[ch->race].size;
ch->dam_type = 17; /*punch */

for (i = 0; i < 5; i++)
{
if (pc_race_table[ch->race].skills[i] == NULL)
break;
group_add(ch,pc_race_table[ch->race].skills[i],FALSE);
}
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;
}


/* RT initialize skills */

if (found && ch->version < 2) /* need to add the new skills */
{
group_add(ch,"rom basics",FALSE);
group_add(ch,class_table[ch->ch_class].base_group,FALSE);
group_add(ch,class_table[ch->ch_class].default_group,TRUE);
ch->pcdata->learned[gsn_recall] = 50;
}

/* fix levels */
if (found && ch->version < 3 && (ch->level > 35 || ch->trust > 35))
{
switch (ch->level)
{
case(40) : ch->level = MAX_LEVEL; break; /* imp -> imp */
case(39) : ch->level = MAX_LEVEL-2; break; /* god -> supreme */
case(38) : ch->level = MAX_LEVEL-4; break; /* deity -> god */
case(37) : ch->level = MAX_LEVEL-6; break; /* angel -> demigod */
}

switch (ch->trust)
{
case(40) : ch->trust = MAX_LEVEL; break; /* imp -> imp */
case(39) : ch->trust = MAX_LEVEL-2; break; /* god -> supreme */
case(38) : ch->trust = MAX_LEVEL-4; break; /* deity -> god */
case(37) : ch->trust = MAX_LEVEL-6; break; /* angel -> demigod */
case(36) : ch->trust = MAX_LEVEL-8; break; /* hero -> hero */
}
}

/* ream gold */
if (found && ch->version < 4)
{
ch->gold /= 100;
}
return found;
}
#pragma warning (default: 4101)


Now, I don't quite know what im doing wrong, or what my eyes are not showing me, but I seem to keep missing the freakin error, hehe.

As you can tell, im really new to coding muds, and this is basicly my first shot at trying to do some coding by myself.

I'm am using the Win32 port of ROM from Micheal K. Weise.

Anyways, when I load a character, this is the screen while using the correct password:


By what name do you wish to be known? Rayne
Password: testpwd
Wrong password.
(this is inside the mud, not the cmd window)

Now, this is what happens if I don't enter a pword, and just hit enter instead.

Warning! Null password!
Please report old password with bug.
Type 'password null <new password>' to fix.
(This is inside the mud, not the cmd window)

I wanted to get this problem fixed before I get into the coding of this. Also, another thing that I noticed is that when i first create the character as a elf warrior, and when I enter the game again using that pfile (after I save), he's not set to human mage.

Please help out

Thanks,
Rayne Wallace
Top

Posted by Starflight   Australia  (12 posts)  Bio
Date Reply #1 on Fri 24 Sep 2004 03:59 PM (UTC)
Message
Ok, basically you've mentioned three problems. The first is the BUG error which is coming from:

if ( letter != '*' )
{
bug( "Load_char_obj: # not found.", 0 );
break;
}


Now without a few more functions from your code, it's a little difficult to analyse but I'll explain as best I can with what I can see. The code is attempting to load details from your individual pfiles (ie. your character names) and the beginning of the pfile starts with a * (which is what the code above is looking for).

To me, the section of code looks a little buggy. The code above the BUG error looks for a * and if it finds one, skips to the next line (getting ready to read in relevant details). If it doesn't find a *, then you get the error message - I believe it should be an else statement as follows:

letter = fread_letter( fp );
if ( letter == '*' )
{
fread_to_eol( fp );
continue;
} else {
bug( "Load_char_obj: # not found.", 0 );
break;
}


The second problem involves checking of your password and I'd need to see this section of code to help.

The third problem you mentioned is your chars always come out as human mages. By default, your code is setting the race to "human" - ch->race = race_lookup("human"); and at a guess, I'd say you aren't actually writing the character race to the pfile when the character is saved (so it defaults to "human"). The same thing is most likely happening with your class - the default will be a mage. You'd need to post the code that saves a character to disk to get any further with this one as well.
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.


10,823 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.