mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-15 00:24:40 +00:00
adds a fail state method+event to the load chain
at time of writing:
Core_ClientServer.GetEventManager().postEvent( "mapLoadFail", false );
kicks players and closes the server
Core_ClientServer.GetEventManager().postEvent( "mapLoadFail", false );
proceeds to continue loading reguardless
This commit is contained in:
parent
2e47e7d823
commit
78cb2e1d80
2 changed files with 29 additions and 0 deletions
|
|
@ -39,6 +39,32 @@ function Core_ClientServerListener::onMapLoadComplete(%this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Core_ClientServerListener::onmapLoadFail(%this, %isFine)
|
||||||
|
{
|
||||||
|
if (%isFine)
|
||||||
|
{
|
||||||
|
%this.onMapLoadComplete();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$moduleLoadedFailed++;
|
||||||
|
echo("onmapLoadFail!");
|
||||||
|
if ($moduleLoadedFailed>1) return; // yeah, we know
|
||||||
|
|
||||||
|
$Server::LoadFailMsg = "Failed to load map!";
|
||||||
|
// Inform clients that are already connected
|
||||||
|
|
||||||
|
for (%clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++)
|
||||||
|
{
|
||||||
|
%cl = ClientGroup.getObject( %clientIndex );
|
||||||
|
%cl.onConnectionDropped($Server::LoadFailMsg);
|
||||||
|
%cl.endMission();
|
||||||
|
%cl.resetGhosting();
|
||||||
|
%cl.clearPaths();
|
||||||
|
}
|
||||||
|
destroyServer();
|
||||||
|
}
|
||||||
|
|
||||||
function Core_ClientServer::onCreate( %this )
|
function Core_ClientServer::onCreate( %this )
|
||||||
{
|
{
|
||||||
echo("\n--------- Initializing Directory: scripts ---------");
|
echo("\n--------- Initializing Directory: scripts ---------");
|
||||||
|
|
@ -61,8 +87,10 @@ function Core_ClientServer::onCreate( %this )
|
||||||
initClient();
|
initClient();
|
||||||
}
|
}
|
||||||
%this.GetEventManager().registerEvent("mapLoadComplete");
|
%this.GetEventManager().registerEvent("mapLoadComplete");
|
||||||
|
%this.GetEventManager().registerEvent("mapLoadFail");
|
||||||
%this.listener = new ScriptMsgListener() {class = Core_ClientServerListener;};
|
%this.listener = new ScriptMsgListener() {class = Core_ClientServerListener;};
|
||||||
%this.GetEventManager().subscribe( %this.listener, "mapLoadComplete" );
|
%this.GetEventManager().subscribe( %this.listener, "mapLoadComplete" );
|
||||||
|
%this.GetEventManager().subscribe( %this.listener, "mapLoadFail" );
|
||||||
}
|
}
|
||||||
|
|
||||||
function Core_ClientServer::onDestroy( %this )
|
function Core_ClientServer::onDestroy( %this )
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ function loadMissionStage2()
|
||||||
if( isObject( theLevelInfo ) )
|
if( isObject( theLevelInfo ) )
|
||||||
$Server::MissionName = theLevelInfo.levelName;
|
$Server::MissionName = theLevelInfo.levelName;
|
||||||
$moduleLoadedDone = 0;
|
$moduleLoadedDone = 0;
|
||||||
|
$moduleLoadedFailed = 0;
|
||||||
callOnModules("onLoadMap");
|
callOnModules("onLoadMap");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue