Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ===================
- idGameLocal::NextMap
- ===================
- */
- bool idGameLocal::NextMap( void ) {
- const function_t *func;
- idThread *thread;
- idDict newInfo;
- const idKeyValue *keyval, *keyval2;
- int i;
- const char *mapCycleList, *currentMap;
- // RAVEN BEGIN
- // rjohnson: traditional map cycle
- // si_mapCycle "mp/q4dm4;mp/q4dm5;mp/q4dm6"
- mapCycleList = si_mapCycle.GetString();
- if ( mapCycleList && strlen( mapCycleList ) ) {
- idLexer src;
- idToken token, firstFound;
- int numMaps = 0;
- bool foundMap = false;
- src.FreeSource();
- src.SetFlags( LEXFL_NOFATALERRORS | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
- src.LoadMemory( mapCycleList, strlen( mapCycleList ), "idGameLocal::NextMap" );
- if ( src.IsLoaded() ) {
- currentMap = si_map.GetString();
- while( src.ReadToken( &token ) ) {
- if ( token == ";" ) {
- continue;
- }
- numMaps++;
- if ( numMaps == 1 ) {
- // guarantee that we use a map no matter what ( or when we wrap )
- firstFound = token;
- }
- if ( foundMap ) {
- firstFound = token;
- break;
- }
- if ( idStr::Icmp( token, currentMap ) == 0 ) {
- foundMap = true;
- }
- }
- if ( firstFound != "" ) {
- si_map.SetString( firstFound );
- return true;
- }
- }
- return false;
- }
- // RAVEN END
- if ( !g_mapCycle.GetString()[0] ) {
- Printf( common->GetLocalizedString( "#str_104294" ) );
- return false;
- }
- if ( fileSystem->ReadFile( g_mapCycle.GetString(), NULL, NULL ) < 0 ) {
- if ( fileSystem->ReadFile( va( "%s.scriptcfg", g_mapCycle.GetString() ), NULL, NULL ) < 0 ) {
- Printf( "map cycle script '%s': not found\n", g_mapCycle.GetString() );
- return false;
- } else {
- g_mapCycle.SetString( va( "%s.scriptcfg", g_mapCycle.GetString() ) );
- }
- }
- Printf( "map cycle script: '%s'\n", g_mapCycle.GetString() );
- func = program.FindFunction( "mapcycle::cycle" );
- if ( !func ) {
- program.CompileFile( g_mapCycle.GetString() );
- func = program.FindFunction( "mapcycle::cycle" );
- }
- if ( !func ) {
- Printf( "Couldn't find mapcycle::cycle\n" );
- return false;
- }
- thread = new idThread( func );
- thread->Start();
- delete thread;
- newInfo = *cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO );
- for ( i = 0; i < newInfo.GetNumKeyVals(); i++ ) {
- keyval = newInfo.GetKeyVal( i );
- keyval2 = serverInfo.FindKey( keyval->GetKey() );
- if ( !keyval2 || keyval->GetValue().Icmp( keyval2->GetValue() ) ) {
- break;
- }
- }
- return ( i != newInfo.GetNumKeyVals() );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement