mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-09 20:18:17 +03:00
Optimized G_Command_ProcessFile a little bit
This commit is contained in:
parent
c115796137
commit
84ecf838d4
1 changed files with 48 additions and 47 deletions
|
@ -2351,63 +2351,64 @@ char *CanonicalTikiName( const char *szInName )
|
||||||
|
|
||||||
qboolean G_Command_ProcessFile( const char * filename, qboolean quiet )
|
qboolean G_Command_ProcessFile( const char * filename, qboolean quiet )
|
||||||
{
|
{
|
||||||
char *buffer;
|
char* buffer;
|
||||||
const char *bufstart;
|
const char* bufstart;
|
||||||
char com_token[ MAX_STRING_CHARS ];
|
const char* token;
|
||||||
|
int numTokens = 0;
|
||||||
|
|
||||||
if( gi.FS_ReadFile( filename, ( void ** )&buffer, quiet ) == -1 )
|
if (gi.FS_ReadFile(filename, (void**)&buffer, quiet) == -1)
|
||||||
{
|
{
|
||||||
return qfalse;
|
return qfalse;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !quiet )
|
if (!quiet)
|
||||||
gi.DPrintf( "G_Command_ProcessFile: %s\n", filename );
|
gi.DPrintf("G_Command_ProcessFile: %s\n", filename);
|
||||||
|
|
||||||
bufstart = buffer;
|
bufstart = buffer;
|
||||||
|
|
||||||
while( 1 )
|
while (1)
|
||||||
{
|
{
|
||||||
Event *ev;
|
// grab each line as we go
|
||||||
|
token = COM_ParseExt(&buffer, qtrue);
|
||||||
|
if (!token[0]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// grab each line as we go
|
if (
|
||||||
strcpy( com_token, COM_ParseExt( &buffer, qtrue ) );
|
!Q_stricmp(token, "end") ||
|
||||||
if( !com_token[ 0 ] )
|
!Q_stricmp(token, "server")
|
||||||
break;
|
)
|
||||||
|
{
|
||||||
|
// skip the line
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
token = COM_ParseExt(&buffer, qfalse);
|
||||||
|
if (!token[0]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if(
|
// Create the event
|
||||||
!Q_stricmp( com_token, "end" ) ||
|
Event ev(token);
|
||||||
!Q_stricmp( com_token, "server" )
|
|
||||||
)
|
|
||||||
{
|
|
||||||
// skip the line
|
|
||||||
while( 1 )
|
|
||||||
{
|
|
||||||
strcpy( com_token, COM_ParseExt( &buffer, qfalse ) );
|
|
||||||
if( !com_token[ 0 ] )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create the event
|
// get the rest of the line
|
||||||
ev = new Event( com_token );
|
while (1) {
|
||||||
|
token = COM_ParseExt(&buffer, qfalse);
|
||||||
|
if (!token[0]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ev.AddToken(token);
|
||||||
|
}
|
||||||
|
|
||||||
// get the rest of the line
|
Director.ProcessEvent(ev);
|
||||||
while( 1 )
|
}
|
||||||
{
|
|
||||||
strcpy( com_token, COM_ParseExt( &buffer, qfalse ) );
|
|
||||||
if( !com_token[ 0 ] )
|
|
||||||
break;
|
|
||||||
|
|
||||||
ev->AddToken( com_token );
|
gi.FS_FreeFile((void*)bufstart);
|
||||||
}
|
|
||||||
|
|
||||||
Director.ProcessEvent( ev );
|
return qtrue;
|
||||||
}
|
|
||||||
|
|
||||||
gi.FS_FreeFile( ( void * )bufstart );
|
|
||||||
|
|
||||||
return qtrue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue