Merge pull request #965 from Azaezel/alpha41/moduleExec

callonmodules perf tweaks
This commit is contained in:
Brian Roberts 2023-02-18 00:51:41 -06:00 committed by GitHub
commit 2d946f693a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 12 deletions

View file

@ -20,7 +20,7 @@ function initClient()
if ( isFile( %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension ) )
exec( %prefPath @ "/clientPrefs." @ $TorqueScriptFileExtension );
callOnModules("initClient");
moduleExec("initClient");
// Copy saved script prefs into C++ code.
setDefaultFov( $pref::Player::defaultFov );

View file

@ -32,7 +32,7 @@ function GameConnection::onConnectionAccepted(%this)
// datablocks and objects are ghosted over.
physicsInitWorld( "client" );
callOnModules("onCreateClientConnection", "Game");
moduleExec("onCreateClientConnection", "Game");
}
function GameConnection::initialControlSet(%this)
@ -156,5 +156,5 @@ function disconnectedCleanup()
// We can now delete the client physics simulation.
physicsDestroyWorld( "client" );
callOnModules("onDestroyClientConnection", "Game");
moduleExec("onDestroyClientConnection", "Game");
}

View file

@ -53,7 +53,7 @@ function initServer()
// Specify where the mission files are.
$Server::MissionFileSpec = "data/levels/*.mis";
callOnModules("initServer");
moduleExec("initServer");
//Maybe this should be a pref for better per-project control
//But many physically based/gameplay things utilize materials being detected
@ -169,8 +169,8 @@ function createServer(%serverType, %levelAsset)
schedule(0,0,startHeartbeat);
}
callOnModules("onCreateGameServer", "Core");
callOnModules("onCreateGameServer", "Game");
moduleExec("onCreateGameServer", "Core");
moduleExec("onCreateGameServer", "Game");
// Let the game initialize some things now that the
// the server has been created
@ -204,8 +204,8 @@ function onServerCreated()
physicsStartSimulation("server");
loadDatablockFiles( DatablockFilesList, true );
callOnModules("onServerScriptExec", "Core");
callOnModules("onServerScriptExec", "Game");
moduleExec("onServerScriptExec", "Core");
moduleExec("onServerScriptExec", "Game");
// Keep track of when the game started
$Game::StartTime = $Sim::Time;
@ -244,8 +244,8 @@ function destroyServer()
deleteDataBlocks();
//Get our modules so we can exec any specific server-side loading/handling
callOnModules("onDestroyGameServer", "Game");
callOnModules("onDestroyGameServer", "Core");
moduleExec("onDestroyGameServer", "Game");
moduleExec("onDestroyGameServer", "Core");
// Save any server settings
%prefPath = getPrefpath();

View file

@ -3,8 +3,8 @@ $traceModuleCalls=false;
$reportModuleFileConflicts=true;
if (!isObject(ExecFilesList))
new ArrayObject(ExecFilesList);
function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
function moduleExec(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
{
//clear per module group file execution chain
%execArray = new ArrayObject("callOn" @ %functionName @ "_" @ %moduleGroup);
@ -46,6 +46,28 @@ function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3,
%execArray.delete();
}
function callOnModules(%functionName, %moduleGroup, %var0, %var1, %var2, %var3, %var4, %var5, %var6)
{
//Get our modules so we can exec any specific client-side loading/handling
%modulesList = ModuleDatabase.findModules();
%modlist = "modlist:";
for(%i=0; %i < getWordCount(%modulesList); %i++)
{
%module = getWord(%modulesList, %i);
%modlist = %modlist SPC %module.ModuleId;
if(%moduleGroup !$= "")
{
if(%module.group !$= %moduleGroup)
continue;
}
// match this to i/o signature
if(isObject(%module.scopeSet) && %module.scopeSet.isMethod(%functionName))
%module.scopeSet.call(%functionName, %var0, %var1, %var2, %var3, %var4, %var5, %var6);
}
if ($reportModuleOrder)
warn(%modlist);
}
function loadModuleMaterials(%moduleGroup)
{
//Get our modules so we can exec any specific client-side loading/handling