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;
- mapCycleList = si_mapCycle.GetString();
- #ifdef _XENON
- //Live()->PickMap();
- return true;
- #endif
- nextMap = false;
- if ( si_rmapCycle.GetBool() ) {
- idStrList fileList;
- idStr mapName;
- int numMaps = fileSystem->GetNumMaps();
- const idDict *dict;
- int index = 0;
- const char* gameType = si_gameType.GetString();
- fileList.Clear();
- for ( i = 0; i < numMaps; i++ ) {
- dict = fileSystem->GetMapDecl( i );
- if ( dict && idStr::FindText( dict->GetString( "path" ), "mp/") ) {
- continue;
- }
- // any MP gametype supported
- bool gameTypeMap = false;
- if ( dict && dict->GetBool( gameType ) && (strcmp( dict->GetString( "path" ), si_map.GetString() )) ) {
- gameTypeMap = true;
- }
- if ( gameTypeMap ) {
- fileList.AddUnique( va( "%s", dict->GetString( "path" ) ) );
- }
- }
- if ( fileList.Num() > 0 ) {
- index = gameLocal.random.RandomInt( fileList.Num() );
- mapName = fileList[index].c_str();
- if ( mapName[0] != '\0' ) {
- si_map.SetString( mapName );
- 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() );
- }
- }
- return false;
- } else 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;
- }
- }
- 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() );
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement