Просмотр исходного кода

refactor, with the following wrappers to keep in mind:
Core_ClientServer.clearLoadStatus();
Core_ClientServer.inishMapLoad();
Core_ClientServer.FailMapLoad( %moduleName, %isFine);
Of special note: the postevent method must only take one entry, so we store off Core_ClientServer.failedModuleName = %moduleName; priorto triggering the event so that the failing module can be reported.

AzaezelX 2 лет назад
Родитель
Сommit
29e06fc327

+ 18 - 7
Templates/BaseGame/game/core/clientServer/Core_ClientServer.tscript

@@ -12,19 +12,30 @@
 // When a local game is started - a listen server - via calling StartGame() a server is created and then the client is
 // When a local game is started - a listen server - via calling StartGame() a server is created and then the client is
 // connected to it via createAndConnectToLocalServer().
 // connected to it via createAndConnectToLocalServer().
 
 
+function Core_ClientServer::clearLoadStatus()
+{
+   Core_ClientServer.moduleLoadedDone = 0;
+   Core_ClientServer.moduleLoadedFailed = 0;
+}
 function Core_ClientServer::onLoadMap(%this)
 function Core_ClientServer::onLoadMap(%this)
 {
 {
     %this.finishMapLoad();
     %this.finishMapLoad();
 }
 }
 
 
-function Core_ClientServer::finishMapLoad()
+function Core_ClientServer::finishMapLoad(%this)
 {
 {
     Core_ClientServer.GetEventManager().postEvent( "mapLoadComplete" );
     Core_ClientServer.GetEventManager().postEvent( "mapLoadComplete" );
 }
 }
 
 
+function Core_ClientServer::FailMapLoad(%this, %moduleName, %isFine)
+{    
+    Core_ClientServer.failedModuleName = %moduleName;
+    Core_ClientServer.GetEventManager().postEvent( "mapLoadFail", %isFine );
+}
+
 function Core_ClientServerListener::onMapLoadComplete(%this)
 function Core_ClientServerListener::onMapLoadComplete(%this)
 {
 {
-    $moduleLoadedDone++;
+    Core_ClientServer.moduleLoadedDone++;
     %numModsNeedingLoaded = 0;
     %numModsNeedingLoaded = 0;
     %modulesList = ModuleDatabase.findModules();
     %modulesList = ModuleDatabase.findModules();
     for(%i=0; %i < getWordCount(%modulesList); %i++)
     for(%i=0; %i < getWordCount(%modulesList); %i++)
@@ -33,7 +44,7 @@ function Core_ClientServerListener::onMapLoadComplete(%this)
         if (%module.ModuleId.isMethod("finishMapLoad"))
         if (%module.ModuleId.isMethod("finishMapLoad"))
             %numModsNeedingLoaded++;
             %numModsNeedingLoaded++;
     }
     }
-    if ($moduleLoadedDone == %numModsNeedingLoaded)
+    if (Core_ClientServer.moduleLoadedDone == %numModsNeedingLoaded)
     {
     {
         loadMissionStage3();  
         loadMissionStage3();  
     }
     }
@@ -47,11 +58,11 @@ function Core_ClientServerListener::onmapLoadFail(%this, %isFine)
         return;
         return;
     }
     }
     
     
-    $moduleLoadedFailed++;
-    echo("onmapLoadFail!");
-    if ($moduleLoadedFailed>1) return; // yeah, we know
+    Core_ClientServer.moduleLoadedFailed++;
+    if (Core_ClientServer.moduleLoadedFailed>1) return; // yeah, we know
         
         
-    $Server::LoadFailMsg = "Failed to load map!";
+    $Server::LoadFailMsg = Core_ClientServer.failedModuleName @" failed to load mission specific data!";
+    error($Server::LoadFailMsg);
     // Inform clients that are already connected
     // Inform clients that are already connected
     
     
     for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
     for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)

+ 1 - 2
Templates/BaseGame/game/core/clientServer/scripts/server/levelLoad.tscript

@@ -126,8 +126,7 @@ function loadMissionStage2()
    // Set mission name.
    // Set mission name.
    if( isObject( theLevelInfo ) )
    if( isObject( theLevelInfo ) )
       $Server::MissionName = theLevelInfo.levelName;
       $Server::MissionName = theLevelInfo.levelName;
-   $moduleLoadedDone = 0;
-   $moduleLoadedFailed = 0;
+   Core_ClientServer.clearLoadStatus();
    callOnModules("onLoadMap");
    callOnModules("onLoadMap");
 
 
 }
 }