Whether to delete g_rankedGame
or to use it for cheat-prevention:
The g_rankedGame
could be deleted and the only consumer CGameView::HandleEvent
could obtain it from CSimulation2::GetInitAttributes
, but it seems cleaner to have the JS side disable or enable the hotkey on session
init
. That the variable is stored (copied) to C++ doesn't add any cheat-prevention because the JS side can still enable and disable that variable arbitrarily (i.e. some hacker JS mod can do that without the need to recompile).
The wireframe option seems better implemented as a DeveloperOverlay dropdown that is also triggered by the hotkey (if rated games are disabled in g_GameAttributes in JS session GUI context).
Those 3 calls
g_Renderer.SetTerrainRenderMode(...);
g_Renderer.SetWaterRenderMode(...);
g_Renderer.SetModelRenderMode(...);
are also incorrectly located, CGameViewCGameView
instead of JSI_Renderer
, the hotkey should not be present in C++ (no need to).
Compare this with the other developer overlay options which entirely disregard the C++ g_isRankedGame
variable. (Why the overlays use GuiInterfaceCall+ICmp instead of JSInterface GUI entrance is also dubious. If that's the preferred means then JSInterface_Simulation.cpp functions such as JSI_Simulation::SetBoundingBoxDebugOverlay
are wrong.)
If one actually was to intend to harden it against JS hacker mods for rated games, then the g_rankedGame
variable could be kept but should not be set from JS but from C++.
That would be from the data in CNetClient::OnGameStart
which passes it to client->m_Game->StartGame(&client->m_GameAttributes, "");
.
The disadvantage of doing so would be that its parsing of simulation data (that isnt really simulation data since the RatingEnabled boolean doesn't influence simulation state) in the NetClient
(that doesn't really operate with the simulation) for the purpose of XmppClient logic setting (which doesn't really have to do anything with simulation nor netclient).
As the code stands every commit did something unique for no reason.
So if g_XmppClient
was not deleted but hardened against cheating by setting it in CNetClient::OnGameStart
or whereever, then one could perhaps also make it impossible to change the perspective to "Observer", "Gaia" or the opponent and whatever else could be used for cheating. That would be JSI_Game::SetViewedPlayer
having an early return for g_rankedGame
.
As we have so many hundred thousands of rated games where people cheated exploited or otherwise broke the concept and fair sportsmanship of rated games, I suppose I can't delete this g_rankedGame
variable but have to rewrire and harden that in anticipation of people just jumping on the next best exploit after fixing the current most popular. (Where I is a variable like X)
So I can fix "Rated game variable not set correctly" easily but "Use rated game variable correctly" is also missing and needs more code, so perhaps the ticket needs to be backlogged again.