From 2be21425dfff9912d39193c008412e988e231630 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 9 Aug 2025 12:54:29 -0500 Subject: [PATCH 1/4] clean up spawn chain ensure among other things that we're only subscribed to the completion or failed events for a given loading stage once all of them have checked in also for callonobjectlist, see what module::callback method in particular is being itterated through for that stages batch when debugging --- .../scripts/server/connectionToClient.tscript | 23 +++++++++++-------- .../utility/scripts/helperFunctions.tscript | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript index 0e2a11e28..7f6bb8885 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript @@ -81,8 +81,8 @@ function GameConnection::onConnect( %this, %clientData ) %this.connectData = %clientData; - //Signal and listener logic for the spawn config/processing here - %this.GetEventManager().registerEvent("setSpawnObjectTypeComplete"); + //Signal and listener logic for the spawn config/processing here + %this.GetEventManager().registerEvent("setSpawnObjectTypeComplete"); %this.GetEventManager().registerEvent("setSpawnObjectTypeFailed"); %this.GetEventManager().registerEvent("setSpawnPointComplete"); %this.GetEventManager().registerEvent("setSpawnPointFailed"); @@ -91,11 +91,6 @@ function GameConnection::onConnect( %this, %clientData ) %this.listener = new ScriptMsgListener() { class = GameConnectionListener; }; - %this.GetEventManager().subscribe( %this.listener, "setSpawnObjectTypeComplete" ); - %this.GetEventManager().subscribe( %this.listener, "setSpawnObjectTypeFailed" ); - %this.GetEventManager().subscribe( %this.listener, "setSpawnPointComplete" ); - %this.GetEventManager().subscribe( %this.listener, "setSpawnPointFailed" ); - %this.GetEventManager().subscribe( %this.listener, "postSpawnComplete" ); callGamemodeFunction("onClientConnect", %this); @@ -124,9 +119,12 @@ function GameConnection::spawnControlObject( %this ) %modulesIDList = getModulesAndGameModesList(true, "Game"); %this.numModsNeedingLoaded = getNumCanCallOnObjectList("setSpawnObjectType", %modulesIDList); - if (%this.numModsNeedingLoaded) + { + %this.GetEventManager().subscribe( %this.listener, "setSpawnObjectTypeComplete" ); + %this.GetEventManager().subscribe( %this.listener, "setSpawnObjectTypeFailed" ); callOnObjectList("setSpawnObjectType", %modulesIdList, %this); + } else %this.listener.onSetSpawnObjectTypeComplete(%this); //just jump to progress } @@ -134,9 +132,12 @@ function GameConnection::spawnControlObject( %this ) function GameConnectionListener::onSetSpawnObjectTypeComplete( %this, %client ) { %client.moduleLoadedDone++; - if (%client.moduleLoadedDone < %client.numModsNeedingLoaded) return; //continue to wait + %client.GetEventManager().remove( %client.listener, "setSpawnObjectTypeComplete" ); + %client.GetEventManager().remove( %client.listener, "setSpawnObjectTypeFailed" ); + %client.GetEventManager().subscribe( %client.listener, "setSpawnPointComplete" ); + %client.GetEventManager().subscribe( %client.listener, "setSpawnPointFailed" ); if (isObject(%client.player)) { @@ -187,6 +188,10 @@ function GameConnectionListener::onSetSpawnPointComplete( %this, %client ) if (%client.moduleLoadedDone < %client.numModsNeedingLoaded) return; //continue to wait + %client.GetEventManager().remove( %client.listener, "setSpawnPointComplete" ); + %client.GetEventManager().remove( %client.listener, "setSpawnPointFailed" ); + %client.GetEventManager().subscribe( %client.listener, "postSpawnComplete" ); + // Spawn with the engine's Sim::spawnObject() function %client.player = spawnObject(%client.spawnClass, %client.spawnDataBlock, %client.spawnProperties, %client.spawnScript); diff --git a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript index b852bb45b..8057fb148 100644 --- a/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript +++ b/Templates/BaseGame/game/core/utility/scripts/helperFunctions.tscript @@ -734,7 +734,7 @@ function getModulesAndGameModesList(%usePriority, %group) function callOnObjectList(%functionName, %objectsList, %var0, %var1, %var2, %var3, %var4, %var5, %var6) { //Get our modules so we can exec any specific client-side loading/handling - %echoList = "Called List:"; + %echoList = "Called List for "@ %functionName @":"; for(%i=0; %i < getWordCount(%objectsList); %i++) { %obj = getWord(%objectsList, %i); From 229cc9709e533b17101647dd5c9c37c7f207d6a8 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 9 Aug 2025 19:35:06 -0500 Subject: [PATCH 2/4] postSpawnComplete listener cleanup --- .../core/clientServer/scripts/server/connectionToClient.tscript | 1 + 1 file changed, 1 insertion(+) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript index 7f6bb8885..e2661492d 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript @@ -291,6 +291,7 @@ function GameConnectionListener::onPostSpawnComplete(%this, %client) if (%client.moduleLoadedDone < %client.numModsNeedingLoaded) return; //continue to wait + %client.GetEventManager().remove( %client.listener, "postSpawnComplete" ); //Continue on. Room for special handling here if needbe but not expressly required } From 26ea1b60fc740f79d840b323d98373390daa3955 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 9 Aug 2025 19:54:51 -0500 Subject: [PATCH 3/4] ensure controlling client object is removed post onClienLeaveGame so each controllable object module doesn't have to remmber to do so --- .../clientServer/scripts/server/connectionToClient.tscript | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript index e2661492d..ac475f3c8 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript @@ -363,6 +363,9 @@ function GameConnection::onDrop(%this, %reason) if($missionRunning) { %hasGameMode = callGamemodeFunction("onClientLeaveGame", %this); + // Cleanup the player + if (isObject(%client.player)) + %client.player.delete(); } removeFromServerGuidList( %this.guid ); From 73abc69a82173ed718fd12e0e93409ed92d309e0 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Sat, 9 Aug 2025 22:22:34 -0500 Subject: [PATCH 4/4] typofix --- .../clientServer/scripts/server/connectionToClient.tscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript index ac475f3c8..25f874d76 100644 --- a/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript +++ b/Templates/BaseGame/game/core/clientServer/scripts/server/connectionToClient.tscript @@ -364,8 +364,8 @@ function GameConnection::onDrop(%this, %reason) { %hasGameMode = callGamemodeFunction("onClientLeaveGame", %this); // Cleanup the player - if (isObject(%client.player)) - %client.player.delete(); + if (isObject(%this.player)) + %this.player.delete(); } removeFromServerGuidList( %this.guid );