09 Aug, 2015, dbna2 wrote in the 1st comment:
Votes: 0
So I recently changed the ways commands are loaded/saved/stored on my codebase but I am getting an error message on start up…. It compiles clean and I feel like its something simple that I am just over looking. So hopefully an extra set of eyes will help.

Error Message:
Sun Aug 9 7:44:02AM 2015 :: [*****] BUG: fread_command: no match: Flags
Sun Aug 9 7:44:02AM 2015 :: [*****] BUG: fread_command: no match: Flags
Sun Aug 9 7:44:02AM 2015 :: [*****] BUG: fread_command: no match: Flags
Sun Aug 9 7:44:02AM 2015 :: [*****] BUG: fread_command: no match: Flags
Sun Aug 9 7:44:02AM 2015 :: [*****] BUG: fread_command: no match: Flags


But flags seem to be working correctly. I just disabled a command it stayed disabled and saved the flag correctly.

Example of how the saved/stored commands look:
#COMMAND
Name tell~
Code do_tell
Position 106
Level 0
Log 0
Flags possessed~
Type 0
HText Syntax: gtell <message>
Syntax: say <message>
Syntax: tell <character> <message>

All of these commands send messages to other players.
GTELL sends a message to all of the characters in
your group, wherever they are, even if they are sleeping
or stunned or dying. ';' is a synonym for GTELL.

SAY sends a message to all awake players in your room.
The single quote '' ' is a synonym for SAY.
TELL sends a message to one awake player anywhere in
the world.

REPLY sends a message to the last player who sent
you a TELL. REPLY will work even if you can't
see the player, and without revealing their identity.
This is handy for talking to invisible or switched
immortal players.
~
HUpdatedby Lieos~
Hupdated 1319224931
End

Fread Command code:

void fread_command( FILE *fp )
{
CMDTYPE *command;
const char *word;
char *infoflags, flag[MSL];
int value;
bool fMatch;

CREATE( command, CMDTYPE, 1 );
command->lag_count = 0; /* can't have caused lag yet… FB */
xCLEAR_BITS( command->flags );
command->htext = NULL;
command->updated = 0;

for( ;; )
{
word = feof( fp ) ? "End" : fread_word( fp );
fMatch = FALSE;

switch( UPPER( word[0] ) )
{
case '*':
fMatch = TRUE;
fread_to_eol( fp );
break;

case 'C':
KEY( "Code", command->fun_name, STRALLOC( fread_word( fp ) ) );
break;

case 'E':
if( !str_cmp( word, "End" ) )
{
if( !command->name )
{
bug( "%s: Name not found", __FUNCTION__ );
free_command( command );
return;
}

if( !command->fun_name )
{
bug( "%s: No function name supplied for %s", __FUNCTION__, command->name );
free_command( command );
return;
}

if( command->htext && command->htext[0] == '.' && command->htext[1] == ' ' )
{
char *tmptext = un_fix_help( command->htext );
STRSET( command->htext, tmptext );
}

/*
* Mods by Trax
* Fread in code into char* and try linkage here then
* deal in the "usual" way I suppose..
*/
command->do_fun = skill_function( command->fun_name );
if( command->do_fun == skill_notfound )
{
bug( "%s: Function %s not found for %s", __FUNCTION__, command->fun_name, command->name );
free_command( command );
return;
}

add_command( command, FALSE );
add_command_help( command, FALSE );
return;
}
break;

case 'F':
WEXTKEY( "Flags", command->flags, fp, cmd_flags, CMD_MAX );
break;


case 'H':
KEY( "HText", command->htext, fread_string( fp ) );
KEY( "Hupdated", command->updated, fread_time( fp ) );
KEY( "Hupdatedby", command->updated_by, fread_string( fp ) );
break;

case 'L':
KEY( "Level", command->level, fread_number(fp) );
KEY( "Log", command->log, fread_number( fp ) );
break;

case 'N':
KEY( "Name", command->name, fread_string( fp ) );
break;

case 'P':
if ( !str_cmp(word, "Position") )
{
fMatch = TRUE;
command->position = fread_number(fp);
if( command->position<100 )
{
switch(command->position)
{
default:
case 0:
case 1:
case 2:
case 3:
case 4: break;
case 5: command->position=6; break;
case 6: command->position=8; break;
case 7: command->position=9; break;
case 8: command->position=12; break;
case 9: command->position=13; break;
case 10: command->position=14; break;
case 11: command->position=15; break;
}
}
else
command->position-=100;
break;
}
break;

case 'T':
KEY( "Type", command->type, fread_number(fp) );
break;

}

if( !fMatch )
{
bug( "%s: no match: %s", __FUNCTION__, word );
fread_to_eol( fp );
}
}
}


Its saved like this:

void save_commands( bool autosave )
{
FILE *fp;

CMDTYPE *command;
int x;
bool found = FALSE;

if( autosave && !sysdata.autosavecommands )
return;

if( !( fp = fopen( COMMAND_FILE, "w" ) ) )
{
bug( "%s: Can't open %s for writing", __FUNCTION__, COMMAND_FILE );
perror( COMMAND_FILE );
return;
}

for( x = 0; x < 126; x++ )
{
for( command = command_hash[x]; command; command = command->next )
{
if( !command->name || command->name[0] == '\0' )
{
bug( "%s: blank command in hash bucket %d", __FUNCTION__, x );
continue;
}
found = TRUE;
fprintf( fp, "#COMMAND\n" );
fprintf( fp, "Name %s~\n", command->name );
fprintf( fp, "Code %s\n", command->fun_name ? command->fun_name : "" );
if ( command->position < 100 )
fprintf( fp, "Position %d\n", command->position+100);
else
fprintf( fp, "Position %d\n", command->position);
fprintf( fp, "Level %d\n", command->level );
fprintf( fp, "Log %d\n", command->log );
if( !xIS_EMPTY( command->flags ) )
fprintf( fp, "Flags %s~\n", ext_flag_string( &command->flags, cmd_flags ) );

fprintf( fp, "Type %d\n", command->type );
if( command->htext )
fprintf( fp, "HText %s~\n", help_fix( command->htext ) );
if( command->updated_by )
fprintf( fp, "HUpdatedby %s~\n", command->updated_by );
if( command->updated )
fprintf( fp, "Hupdated %ld\n", command->updated );
fprintf( fp, "End\n\n" );
}
}
fprintf( fp, "#END\n" );
fclose( fp );
fp = NULL;
if( !found )
remove_file( COMMAND_FILE );
}
09 Aug, 2015, dbna2 wrote in the 2nd comment:
Votes: 0
Fixed :)
0.0/2