Stop multiple instances from running
by Aaron K Murray · in Torque Game Builder · 01/31/2008 (3:11 pm) · 8 replies
Is there a way to stop multiple instances of the game from running at the same time?
It really causes problems in my game...
Thanks,
Aaron
It really causes problems in my game...
Thanks,
Aaron
#2
02/01/2008 (8:11 am)
Thanks Joe. I don't have the source so the game is going to ship Monday with this problem.
#3
02/01/2008 (10:22 am)
Does the problem arise when they launch another version of the same game immediately, or when they actually get into your game scripting. You could dump out a file when you launch storing the value of a game currently running and then just check against that when you fire up an instance.
#4
Your workaround is easy to implement and potentially effective. My only concern would be that the game is shut down via abnormal methods (Task Manager) - the game wouldn't be able to cleanup that check file. Even if I put a timestamp in there, I would need some sort of window for allowing a second instance to run again.
Hrmm...it is a good suggestion but the worst case scenario is very bad (game crashes/shut down abnormally - can't be launched again). I guess I would rather have the game freak out when a second instance is launched.
If you think of a way to do this without the potentially bad side effect - I would to hear it so I can get it in the game this weekend.
Thanks,
Aaron
02/01/2008 (11:05 am)
The problem arises when they launch a second instance at any time after launching the game initially.Your workaround is easy to implement and potentially effective. My only concern would be that the game is shut down via abnormal methods (Task Manager) - the game wouldn't be able to cleanup that check file. Even if I put a timestamp in there, I would need some sort of window for allowing a second instance to run again.
Hrmm...it is a good suggestion but the worst case scenario is very bad (game crashes/shut down abnormally - can't be launched again). I guess I would rather have the game freak out when a second instance is launched.
If you think of a way to do this without the potentially bad side effect - I would to hear it so I can get it in the game this weekend.
Thanks,
Aaron
#5
08/13/2009 (9:06 am)
Any updates on this? I'm surprised this isn't a feature of the engine. I'm running into this problem again trying to get the game passed Oberon's checklist.
#6
08/13/2009 (6:05 pm)
I don't know what issue the code I posted is causing you, or could cause you. My game has crashed abnormally plenty of times. Only one copy of the game will run at any given time, and it works on both XP and Vista.
#7
Thanks,
Aaron
08/15/2009 (2:18 pm)
Hi Joe - I'm using the code above, but it still isn't stopping multiple instances. Perhaps I need to configure "TheTool" and/or "ThePlayer" to something? If so - where so I set those values? I searched through the c++ and the torquescript and haven't found anything yet.Thanks,
Aaron
#8
08/15/2009 (3:12 pm)
Make sure you #define ONE_INSTANCE somewhere to make that code compile...
Torque Owner Joe Rossi
Indri Games
Open your game/main.cc source file.
Find the function initLibraries and add this to the top of that function.
#ifdef ONE_INSTANCE //Use different mutexes for the tool and the "player". //This allows us to run the editor and game at the same time, but not multiple copies of either. #ifdef TORQUE_PLAYER if (!Platform::excludeOtherInstances("ThePlayer")) return false; #else if (!Platform::excludeOtherInstances("TheTool")) return false; #endif #endif