Optimized G_Command_ProcessFile a little bit

This commit is contained in:
smallmodel 2023-08-01 19:31:08 +02:00
parent c115796137
commit 84ecf838d4
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -2353,7 +2353,8 @@ 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)
{ {
@ -2367,39 +2368,39 @@ qboolean G_Command_ProcessFile( const char * filename, qboolean quiet )
while (1) while (1)
{ {
Event *ev;
// grab each line as we go // grab each line as we go
strcpy( com_token, COM_ParseExt( &buffer, qtrue ) ); token = COM_ParseExt(&buffer, qtrue);
if( !com_token[ 0 ] ) if (!token[0]) {
break; break;
}
if ( if (
!Q_stricmp( com_token, "end" ) || !Q_stricmp(token, "end") ||
!Q_stricmp( com_token, "server" ) !Q_stricmp(token, "server")
) )
{ {
// skip the line // skip the line
while (1) while (1)
{ {
strcpy( com_token, COM_ParseExt( &buffer, qfalse ) ); token = COM_ParseExt(&buffer, qfalse);
if( !com_token[ 0 ] ) if (!token[0]) {
break; break;
} }
}
continue; continue;
} }
// Create the event // Create the event
ev = new Event( com_token ); Event ev(token);
// get the rest of the line // get the rest of the line
while( 1 ) while (1) {
{ token = COM_ParseExt(&buffer, qfalse);
strcpy( com_token, COM_ParseExt( &buffer, qfalse ) ); if (!token[0]) {
if( !com_token[ 0 ] )
break; break;
}
ev->AddToken( com_token ); ev.AddToken(token);
} }
Director.ProcessEvent(ev); Director.ProcessEvent(ev);