The CGame constructor is spread throughout the codebase.
One problem with that is that it had received multiple arguments throughout it's timeline and they were made optional.
This meant that new code was shorter, but this also meant that it was easy to not check the other CGame constructor calls when the new arguments were introduced, since they were not part of the patch anymore but still affectected by the patch.
This has already caused some bugs where replays were written in atlas and other situations, for example in rP17689.
The responsibility of the decision whether or not to enable visual mode and write a replay is the one of the caller, so the caller should explicitly be forced to decide whether or not to do that rather than possibly not noticing the default value and copy pasting a constructor call.
Here all constructor calls with the values moved to the caller:
Declaration and Definition:
source/ps/Game.cpp:CGame::CGame(bool disableGraphics, bool replayLog): source/ps/Game.h: CGame(bool disableGraphics, bool replayLog);
Start a visual match from the UI:
source/ps/scripting/JSInterface_Game.cpp: g_Game = new CGame(false, true); source/ps/scripting/JSInterface_SavedGame.cpp: g_Game = new CGame(false, true); source/network/scripting/JSInterface_Network.cpp: g_Game = new CGame(false, true); source/network/scripting/JSInterface_Network.cpp: g_Game = new CGame(false, true);
Start atlas:
source/tools/atlas/GameInterface/Handlers/MapHandlers.cpp: g_Game = new CGame(false, false);
Autostart a visual or non-visual match:
source/ps/GameSetup/GameSetup.cpp: g_Game = new CGame(nonVisual, !args.Has("autostart-disable-replay"));
Autostart a visual replay:
source/ps/GameSetup/GameSetup.cpp: g_Game = new CGame(false, false);
Autostart a non-visual replay:
source/ps/Replay.cpp: g_Game = new CGame(true, false);
Tests:
source/network/tests/test_Net.h: CGame client1Game(true, false); source/network/tests/test_Net.h: CGame client2Game(true, false); source/network/tests/test_Net.h: CGame client3Game(true, false); source/network/tests/test_Net.h: CGame client1Game(true, false); source/network/tests/test_Net.h: CGame client2Game(true, false); source/network/tests/test_Net.h: CGame client3Game(true, false); source/network/tests/test_Net.h: CGame client2BGame(true, false);
But now where I see that, it would also be more consistent to speak of Visual mode (positively), always, rather than functions with "Visual" in their name having to pass nonvisual=false.
"true" represents a feature (renderer, sound) being enabled.
This patch is a preparation to make D2197 a bit cleaner.