Guest User

Untitled

a guest
Aug 19th, 2016
59
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ===================
  3. idGameLocal::NextMap
  4. ===================
  5. */
  6. bool idGameLocal::NextMap( void ) {
  7. const function_t *func;
  8. idThread *thread;
  9. idDict newInfo;
  10. const idKeyValue *keyval, *keyval2;
  11. int i;
  12. const char *mapCycleList, *currentMap;
  13.  
  14. // RAVEN BEGIN
  15. // rjohnson: traditional map cycle
  16. // si_mapCycle "mp/q4dm4;mp/q4dm5;mp/q4dm6"
  17. mapCycleList = si_mapCycle.GetString();
  18. if ( mapCycleList && strlen( mapCycleList ) ) {
  19. idLexer src;
  20. idToken token, firstFound;
  21. int numMaps = 0;
  22. bool foundMap = false;
  23.  
  24. src.FreeSource();
  25. src.SetFlags( LEXFL_NOFATALERRORS | LEXFL_ALLOWPATHNAMES | LEXFL_ALLOWMULTICHARLITERALS | LEXFL_ALLOWBACKSLASHSTRINGCONCAT );
  26. src.LoadMemory( mapCycleList, strlen( mapCycleList ), "idGameLocal::NextMap" );
  27. if ( src.IsLoaded() ) {
  28.  
  29. currentMap = si_map.GetString();
  30. while( src.ReadToken( &token ) ) {
  31. if ( token == ";" ) {
  32. continue;
  33. }
  34. numMaps++;
  35.  
  36. if ( numMaps == 1 ) {
  37. // guarantee that we use a map no matter what ( or when we wrap )
  38. firstFound = token;
  39. }
  40. if ( foundMap ) {
  41. firstFound = token;
  42. break;
  43. }
  44.  
  45. if ( idStr::Icmp( token, currentMap ) == 0 ) {
  46. foundMap = true;
  47. }
  48. }
  49.  
  50. if ( firstFound != "" ) {
  51. si_map.SetString( firstFound );
  52. return true;
  53. }
  54. }
  55.  
  56. return false;
  57. }
  58. // RAVEN END
  59.  
  60. if ( !g_mapCycle.GetString()[0] ) {
  61. Printf( common->GetLocalizedString( "#str_104294" ) );
  62. return false;
  63. }
  64. if ( fileSystem->ReadFile( g_mapCycle.GetString(), NULL, NULL ) < 0 ) {
  65. if ( fileSystem->ReadFile( va( "%s.scriptcfg", g_mapCycle.GetString() ), NULL, NULL ) < 0 ) {
  66. Printf( "map cycle script '%s': not found\n", g_mapCycle.GetString() );
  67. return false;
  68. } else {
  69. g_mapCycle.SetString( va( "%s.scriptcfg", g_mapCycle.GetString() ) );
  70. }
  71. }
  72.  
  73. Printf( "map cycle script: '%s'\n", g_mapCycle.GetString() );
  74. func = program.FindFunction( "mapcycle::cycle" );
  75. if ( !func ) {
  76. program.CompileFile( g_mapCycle.GetString() );
  77. func = program.FindFunction( "mapcycle::cycle" );
  78. }
  79. if ( !func ) {
  80. Printf( "Couldn't find mapcycle::cycle\n" );
  81. return false;
  82. }
  83. thread = new idThread( func );
  84. thread->Start();
  85. delete thread;
  86.  
  87. newInfo = *cvarSystem->MoveCVarsToDict( CVAR_SERVERINFO );
  88. for ( i = 0; i < newInfo.GetNumKeyVals(); i++ ) {
  89. keyval = newInfo.GetKeyVal( i );
  90. keyval2 = serverInfo.FindKey( keyval->GetKey() );
  91. if ( !keyval2 || keyval->GetValue().Icmp( keyval2->GetValue() ) ) {
  92. break;
  93. }
  94. }
  95. return ( i != newInfo.GetNumKeyVals() );
  96. }
RAW Paste Data