Multiple Instances Of Scumm VM

All the inane chatter goes in here. If you're curious about whether we will support a game, post HERE not in General Discussion :)

Moderator: ScummVM Team

Post Reply
Manannan
Posts: 8
Joined: Wed Sep 25, 2019 11:17 am

Multiple Instances Of Scumm VM

Post by Manannan »

If this is not the right place for a question like this please let me know.

I am using the Scumm VM codebase as part of a personal code project.

I am trying to make multiple instances of Scumm VM so that multiple games can be managed at once by a website.

Here is a condensed version of how I have gone about it. I have cut a lot of stuff out . . .

CLIScumm::Wrapper::Wrapper(System::String^ gameFolderLocation, CopyRectToScreen^ screenUpdated)
{
g_system = . . .

PluginManager::instance().init(); //TO DO FIX this hack, so that the plugin manager is not inited twice
PluginManager::instance().loadAllPlugins(); // load plugins for cached plugin manager

DetectedGames detectionResults = EngineMan.detectGames(files).listDetectedGames();
Common::String domain = EngineMan.createTargetForGame(detectionResults.front());

//Common::String domain = "kq3";
ConfMan.addGameDomain(domain);
ConfMan.setActiveDomain(domain);
}


void CLIScumm::Wrapper::init()
{
scummvm_main(0, {});
}

There is a new instance of this 'Wrapper' for every instance, and init is called once per instance as well.

This system works for a single instance, but as 'g_system' is a global variable (forgive me if I haven't used the right terminology), it is shared between instances of the wrapper, rendering multiple instances impossible :(.

Has anyone else had any previous experience in trying to make multiple instances and could they guide me in the right direction?
Post Reply