Skip to content

Commit c67be59

Browse files
Simplify the declaration of commands and cvars and remove unregistered function stuff
1 parent 2a902e4 commit c67be59

File tree

4 files changed

+123
-233
lines changed

4 files changed

+123
-233
lines changed

Code/CryGame/Game.h

-26
Original file line numberDiff line numberDiff line change
@@ -214,33 +214,7 @@ class CGame :
214214

215215
virtual void RegisterGameObjectEvents();
216216

217-
// marcok: this is bad and evil ... should be removed soon
218-
static void CmdRestartGame(IConsoleCmdArgs *pArgs);
219-
220-
static void CmdDumpSS(IConsoleCmdArgs *pArgs);
221-
222-
static void CmdLastInv(IConsoleCmdArgs *pArgs);
223-
static void CmdName(IConsoleCmdArgs *pArgs);
224-
static void CmdTeam(IConsoleCmdArgs *pArgs);
225-
static void CmdLoadLastSave(IConsoleCmdArgs *pArgs);
226-
static void CmdSpectator(IConsoleCmdArgs *pArgs);
227-
static void CmdJoinGame(IConsoleCmdArgs *pArgs);
228-
static void CmdKill(IConsoleCmdArgs *pArgs);
229-
static void CmdVehicleKill(IConsoleCmdArgs *pArgs);
230-
static void CmdRestart(IConsoleCmdArgs *pArgs);
231-
static void CmdSay(IConsoleCmdArgs *pArgs);
232-
static void CmdReloadItems(IConsoleCmdArgs *pArgs);
233217
static void CmdLoadActionmap(IConsoleCmdArgs *pArgs);
234-
static void CmdReloadGameRules(IConsoleCmdArgs *pArgs);
235-
static void CmdNextLevel(IConsoleCmdArgs* pArgs);
236-
static void CmdStartKickVoting(IConsoleCmdArgs* pArgs);
237-
static void CmdStartNextMapVoting(IConsoleCmdArgs* pArgs);
238-
static void CmdVote(IConsoleCmdArgs* pArgs);
239-
static void CmdListPlayers(IConsoleCmdArgs* pArgs);
240-
241-
static void CmdQuickGame(IConsoleCmdArgs* pArgs);
242-
static void CmdQuickGameStop(IConsoleCmdArgs* pArgs);
243-
static void CmdBattleDustReload(IConsoleCmdArgs* pArgs);
244218

245219
IGameFramework *m_pFramework;
246220
IConsole *m_pConsole;

Code/CryGame/GameCVars.cpp

+79-90
Original file line numberDiff line numberDiff line change
@@ -101,82 +101,81 @@ static void CmdGOCMode(IConsoleCmdArgs* cmdArgs)
101101
}
102102
}
103103

104-
SCVars::SCVars()
105-
{
106-
std::memset(this, 0, sizeof(SCVars));
107-
}
108-
109-
SCVars::~SCVars()
110-
{
111-
this->ReleaseCVars();
112-
}
113104

114105
// game related cvars must start with an g_
115106
// game server related cvars must start with sv_
116107
// game client related cvars must start with cl_
117108
// no other types of cvars are allowed to be defined here!
118-
void SCVars::InitCVars(IConsole* pConsole)
109+
SCVars::SCVars()
119110
{
120111
const int OPTIONAL_SYNC = 0;
121112

122-
#define GAMECVAR_REGISTERLIST
123-
#include "GameCVarsLib.h"
124-
#undef GAMECVAR_REGISTERLIST
125-
126-
ca_GameControlledStrafingPtr = pConsole->GetCVar("ca_GameControlledStrafing");
127-
pl_debug_filter = pConsole->RegisterString("pl_debug_filter", "", VF_CHEAT);
128-
129-
aln_debug_filter = pConsole->RegisterString("aln_debug_filter", "", VF_CHEAT);
113+
std::memset(this, 0, sizeof(SCVars));
114+
// marcok TODO: seem to be only used on script side ...
130115

131-
pAltitudeLimitCVar = pConsole->Register("v_altitudeLimit", &v_altitudeLimit, v_altitudeLimitDefault(), VF_CHEAT, "Used to restrict the helicopter and VTOL movement from going higher than a set altitude. If set to zero, the altitude limit is disabled.");
132-
pAltitudeLimitLowerOffsetCVar = pConsole->Register("v_altitudeLimitLowerOffset", &v_altitudeLimitLowerOffset, 0.1f, VF_CHEAT, "Used in conjunction with v_altitudeLimit to set the zone when gaining altitude start to be more difficult.");
133-
134-
// weapon system
135-
i_debuggun_1 = pConsole->RegisterString("i_debuggun_1", "ai_statsTarget", VF_DUMPTODISK, "Command to execute on primary DebugGun fire");
136-
i_debuggun_2 = pConsole->RegisterString("i_debuggun_2", "ag_debug", VF_DUMPTODISK, "Command to execute on secondary DebugGun fire");
116+
ICVar* p_cl_motionBlur = pConsole->RegisterFloat("cl_motionBlur", 2, 0, "motion blur type (0=off, 1=accumulation-based, 2=velocity-based)");
117+
ICVar* p_cl_sprintBlur = pConsole->RegisterFloat("cl_sprintBlur", 0.6f, 0, "sprint blur");
118+
ICVar* p_cl_hitShake = pConsole->RegisterFloat("cl_hitShake", 1.25f, 0, "hit shake");
119+
ICVar* p_cl_hitBlur = pConsole->RegisterFloat("cl_hitBlur", 0.25f, 0, "blur on hit");
137120

138-
// quick game
121+
ICVar* p_cl_righthand = pConsole->RegisterInt("cl_righthand", 1, 0, "Select right-handed weapon!");
122+
ICVar* p_cl_screeneffects = pConsole->RegisterInt("cl_screeneffects", 1, 0, "Enable player screen effects (depth-of-field, motion blur, ...).");
139123

140-
g_quickGame_map = pConsole->RegisterString("g_quickGame_map", "", VF_DUMPTODISK, "QuickGame option");
141-
g_quickGame_mode = pConsole->RegisterString("g_quickGame_mode", "PowerStruggle", VF_DUMPTODISK, "QuickGame option");
142-
143-
// battledust
144-
g_battleDust_effect = pConsole->RegisterString("g_battleDust_effect", "misc.battledust.light", 0, "Sets the effect to use for battledust");
124+
ICVar* p_g_grabLog = pConsole->RegisterInt("g_grabLog", 0, 0, "verbosity for grab logging (0-2)");
125+
ICVar* p_cl_actorsafemode = pConsole->RegisterInt("cl_actorsafemode", 0, VF_CHEAT, "Enable/disable actor safe mode", BroadcastChangeSafeMode);
126+
ICVar* p_aa_maxDist = pConsole->RegisterFloat("aa_maxDist", 10.0f, VF_CHEAT, "max lock distance");
127+
ICVar* p_g_showIdleStats = pConsole->RegisterInt("g_showIdleStats", 0, 0, "");
145128

146-
pVehicleQuality = pConsole->GetCVar("v_vehicle_quality"); assert(pVehicleQuality);
129+
#define GAMECVAR_REGISTERLIST
130+
#include "GameCvarsLib.h"
131+
#undef GAMECVAR_REGISTERLIST
147132

148133
NetInputChainInitCVars();
149-
}
150134

151-
//------------------------------------------------------------------------
152-
void SCVars::ReleaseCVars()
153-
{
154-
IConsole* pConsole = gEnv->pConsole;
155-
156-
pConsole->UnregisterVariable("pl_debug_filter", true);
157-
pConsole->UnregisterVariable("v_altitudeLimit", true);
158-
pConsole->UnregisterVariable("v_altitudeLimitLowerOffset", true);
159-
160-
// weapon system
161-
pConsole->UnregisterVariable("i_debuggun_1", true);
162-
pConsole->UnregisterVariable("i_debuggun_2", true);
163-
164-
pConsole->UnregisterVariable("g_quickGame_map", true);
165-
pConsole->UnregisterVariable("g_quickGame_mode", true);
166-
167-
pConsole->UnregisterVariable("g_battleDust_effect", true);
168-
169-
// alien debugging
170-
pConsole->UnregisterVariable("aln_debug_movement", true);
171-
pConsole->UnregisterVariable("aln_debug_filter", true);
172-
173-
#define UNREGISTER_GAMECVAR
174-
#include "GameCvarsLib.h"
175-
#undef UNREGISTER_GAMECVAR
176-
}
135+
pConsole->AddCommand("quit", "System.Quit()", VF_RESTRICTEDMODE, "Quits the game");
136+
pConsole->AddCommand("goto", "g_localActor:SetWorldPos({x=%1, y=%2, z=%3})", VF_CHEAT, "Sets current player position.");
137+
pConsole->AddCommand("freeze", "g_gameRules:SetFrozenAmount(g_localActor,1)", 0, "Freezes player");
138+
139+
pConsole->AddCommand("loadactionmap", g_pGame->CmdLoadActionmap, 0, "Loads a key configuration file");
140+
pConsole->AddCommand("restartgame", CmdRestartGame, 0, "Restarts Crysis completely.");
141+
142+
pConsole->AddCommand("name", CmdName, VF_RESTRICTEDMODE, "Sets player name.");
143+
pConsole->AddCommand("team", CmdTeam, VF_RESTRICTEDMODE, "Sets player team.");
144+
pConsole->AddCommand("kill", CmdKill, VF_RESTRICTEDMODE, "Kills the player.");
145+
pConsole->AddCommand("v_kill", CmdVehicleKill, VF_CHEAT, "Kills the players vehicle.");
146+
pConsole->AddCommand("sv_restart", CmdRestart, 0, "Restarts the round.");
147+
pConsole->AddCommand("sv_say", CmdSay, 0, "Broadcasts a message to all clients.");
148+
pConsole->AddCommand("i_reload", CmdReloadItems, 0, "Reloads item scripts.");
149+
pConsole->AddCommand("dumpss", CmdDumpSS, 0, "test synched storage.");
150+
151+
pConsole->AddCommand("g_reloadGameRules", CmdReloadGameRules, 0, "Reload GameRules script");
152+
pConsole->AddCommand("g_quickGame", CmdQuickGame, 0, "Quick connect to good server.");
153+
pConsole->AddCommand("g_quickGameStop", CmdQuickGameStop, 0, "Cancel quick game search.");
154+
pConsole->AddCommand("g_nextlevel", CmdNextLevel, 0, "Switch to next level in rotation or restart current one.");
155+
156+
pConsole->AddCommand("vote", CmdVote, VF_RESTRICTEDMODE, "Vote on current topic.");
157+
pConsole->AddCommand("startKickVoting", CmdStartKickVoting, VF_RESTRICTEDMODE, "Initiate voting.");
158+
pConsole->AddCommand("listplayers", CmdListPlayers, VF_RESTRICTEDMODE, "Initiate voting.");
159+
pConsole->AddCommand("startNextMapVoting", CmdStartNextMapVoting, VF_RESTRICTEDMODE, "Initiate voting.");
160+
161+
pConsole->AddCommand("g_battleDust_reload", CmdBattleDustReload, 0, "Reload the battle dust parameters xml");
162+
163+
pConsole->AddCommand("lastinv", CmdLastInv, 0, "Selects last inventory item used.");
164+
pConsole->AddCommand("gotoe", "local e=System.GetEntityByName(%1); if (e) then g_localActor:SetWorldPos(e:GetWorldPos()); end", VF_CHEAT, "Sets current player position.");
165+
166+
pConsole->AddCommand("loadLastSave", CmdLoadLastSave, 0, "Loads the last savegame if available.");
167+
pConsole->AddCommand("spectator", CmdSpectator, 0, "Sets the player as a spectator.");
168+
pConsole->AddCommand("join_game", CmdJoinGame, VF_RESTRICTEDMODE, "Enter the current ongoing game.");
169+
170+
pConsole->AddCommand("dumpnt", CmdDumpItemNameTable, 0, "Dump ItemString table.");
171+
pConsole->AddCommand("preloadforstats", "PreloadForStats()", VF_CHEAT, "Preload multiplayer assets for memory statistics.");
172+
}
173+
#undef GAMECVAR
174+
175+
SCVars::~SCVars() {}
177176

178177
//------------------------------------------------------------------------
179-
void CGame::CmdDumpSS(IConsoleCmdArgs* pArgs)
178+
void CmdDumpSS(IConsoleCmdArgs* pArgs)
180179
{
181180
if (g_pGame->GetSynchedStorage())
182181
g_pGame->GetSynchedStorage()->Dump();
@@ -200,17 +199,7 @@ void CmdDumpItemNameTable(IConsoleCmdArgs* pArgs)
200199
}
201200

202201
//------------------------------------------------------------------------
203-
void CGame::RegisterConsoleCommands()
204-
{
205-
assert(m_pConsole);
206-
207-
#define COMMAND_REGISTERLIST
208-
#include "GameCvarsLib.h"
209-
#undef COMMAND_REGISTERLIST
210-
}
211-
212-
//------------------------------------------------------------------------
213-
void CGame::CmdLastInv(IConsoleCmdArgs* pArgs)
202+
void CmdLastInv(IConsoleCmdArgs* pArgs)
214203
{
215204
if (!gEnv->bClient)
216205
return;
@@ -220,7 +209,7 @@ void CGame::CmdLastInv(IConsoleCmdArgs* pArgs)
220209
}
221210

222211
//------------------------------------------------------------------------
223-
void CGame::CmdName(IConsoleCmdArgs* pArgs)
212+
void CmdName(IConsoleCmdArgs* pArgs)
224213
{
225214
if (!gEnv->bClient)
226215
return;
@@ -235,7 +224,7 @@ void CGame::CmdName(IConsoleCmdArgs* pArgs)
235224
}
236225

237226
//------------------------------------------------------------------------
238-
void CGame::CmdTeam(IConsoleCmdArgs* pArgs)
227+
void CmdTeam(IConsoleCmdArgs* pArgs)
239228
{
240229
if (!gEnv->bClient)
241230
return;
@@ -250,7 +239,7 @@ void CGame::CmdTeam(IConsoleCmdArgs* pArgs)
250239
}
251240

252241
//------------------------------------------------------------------------
253-
void CGame::CmdLoadLastSave(IConsoleCmdArgs* pArgs)
242+
void CmdLoadLastSave(IConsoleCmdArgs* pArgs)
254243
{
255244
if (!gEnv->bClient || gEnv->bMultiplayer)
256245
return;
@@ -275,7 +264,7 @@ void CGame::CmdLoadLastSave(IConsoleCmdArgs* pArgs)
275264
}
276265

277266
//------------------------------------------------------------------------
278-
void CGame::CmdSpectator(IConsoleCmdArgs* pArgs)
267+
void CmdSpectator(IConsoleCmdArgs* pArgs)
279268
{
280269
if (!gEnv->bClient)
281270
return;
@@ -295,7 +284,7 @@ void CGame::CmdSpectator(IConsoleCmdArgs* pArgs)
295284
}
296285

297286
//------------------------------------------------------------------------
298-
void CGame::CmdJoinGame(IConsoleCmdArgs* pArgs)
287+
void CmdJoinGame(IConsoleCmdArgs* pArgs)
299288
{
300289
if (!gEnv->bClient)
301290
return;
@@ -313,7 +302,7 @@ void CGame::CmdJoinGame(IConsoleCmdArgs* pArgs)
313302
}
314303

315304
//------------------------------------------------------------------------
316-
void CGame::CmdKill(IConsoleCmdArgs* pArgs)
305+
void CmdKill(IConsoleCmdArgs* pArgs)
317306
{
318307
if (!gEnv->bClient)
319308
return;
@@ -334,7 +323,7 @@ void CGame::CmdKill(IConsoleCmdArgs* pArgs)
334323
}
335324

336325
//------------------------------------------------------------------------
337-
void CGame::CmdVehicleKill(IConsoleCmdArgs* pArgs)
326+
void CmdVehicleKill(IConsoleCmdArgs* pArgs)
338327
{
339328
if (!gEnv->bClient)
340329
return;
@@ -359,14 +348,14 @@ void CGame::CmdVehicleKill(IConsoleCmdArgs* pArgs)
359348
}
360349

361350
//------------------------------------------------------------------------
362-
void CGame::CmdRestart(IConsoleCmdArgs* pArgs)
351+
void CmdRestart(IConsoleCmdArgs* pArgs)
363352
{
364353
if (g_pGame && g_pGame->GetGameRules())
365354
g_pGame->GetGameRules()->Restart();
366355
}
367356

368357
//------------------------------------------------------------------------
369-
void CGame::CmdSay(IConsoleCmdArgs* pArgs)
358+
void CmdSay(IConsoleCmdArgs* pArgs)
370359
{
371360
if (pArgs->GetArgCount() > 1 && gEnv->bServer)
372361
{
@@ -386,22 +375,22 @@ void CGame::CmdLoadActionmap(IConsoleCmdArgs* pArgs)
386375
}
387376

388377
//------------------------------------------------------------------------
389-
void CGame::CmdRestartGame(IConsoleCmdArgs* pArgs)
378+
void CmdRestartGame(IConsoleCmdArgs* pArgs)
390379
{
391380
GetISystem()->Relaunch(true);
392381
GetISystem()->Quit();
393382
}
394383

395384
//------------------------------------------------------------------------
396-
void CGame::CmdReloadItems(IConsoleCmdArgs* pArgs)
385+
void CmdReloadItems(IConsoleCmdArgs* pArgs)
397386
{
398387
g_pGame->GetItemSharedParamsList()->Reset();
399388
g_pGame->GetIGameFramework()->GetIItemSystem()->Reload();
400389
g_pGame->GetWeaponSystem()->Reload();
401390
}
402391

403392
//------------------------------------------------------------------------
404-
void CGame::CmdReloadGameRules(IConsoleCmdArgs* pArgs)
393+
void CmdReloadGameRules(IConsoleCmdArgs* pArgs)
405394
{
406395
if (gEnv->bMultiplayer)
407396
return;
@@ -431,14 +420,14 @@ void CGame::CmdReloadGameRules(IConsoleCmdArgs* pArgs)
431420
}
432421
}
433422

434-
void CGame::CmdNextLevel(IConsoleCmdArgs* pArgs)
423+
void CmdNextLevel(IConsoleCmdArgs* pArgs)
435424
{
436425
ILevelRotation* pLevelRotation = g_pGame->GetIGameFramework()->GetILevelSystem()->GetLevelRotation();
437426
if (pLevelRotation->GetLength())
438427
pLevelRotation->ChangeLevel(pArgs);
439428
}
440429

441-
void CGame::CmdStartKickVoting(IConsoleCmdArgs* pArgs)
430+
void CmdStartKickVoting(IConsoleCmdArgs* pArgs)
442431
{
443432
if (!gEnv->bClient)
444433
return;
@@ -462,7 +451,7 @@ void CGame::CmdStartKickVoting(IConsoleCmdArgs* pArgs)
462451
}
463452
}
464453

465-
void CGame::CmdStartNextMapVoting(IConsoleCmdArgs* pArgs)
454+
void CmdStartNextMapVoting(IConsoleCmdArgs* pArgs)
466455
{
467456
if (!gEnv->bClient)
468457
return;
@@ -476,7 +465,7 @@ void CGame::CmdStartNextMapVoting(IConsoleCmdArgs* pArgs)
476465
}
477466

478467

479-
void CGame::CmdVote(IConsoleCmdArgs* pArgs)
468+
void CmdVote(IConsoleCmdArgs* pArgs)
480469
{
481470
if (!gEnv->bClient)
482471
return;
@@ -489,7 +478,7 @@ void CGame::CmdVote(IConsoleCmdArgs* pArgs)
489478
pGameRules->Vote(pGameRules->GetActorByEntityId(pClientActor->GetEntityId()), true);
490479
}
491480

492-
void CGame::CmdListPlayers(IConsoleCmdArgs* pArgs)
481+
void CmdListPlayers(IConsoleCmdArgs* pArgs)
493482
{
494483
IActor* pClientActor = g_pGame->GetIGameFramework()->GetClientActor();
495484
if (!pClientActor)
@@ -570,17 +559,17 @@ void CGame::CmdListPlayers(IConsoleCmdArgs* pArgs)
570559
}
571560
}
572561

573-
void CGame::CmdQuickGame(IConsoleCmdArgs* pArgs)
562+
void CmdQuickGame(IConsoleCmdArgs* pArgs)
574563
{
575564
g_pGame->GetMenu()->GetMPHub()->OnQuickGame();
576565
}
577566

578-
void CGame::CmdQuickGameStop(IConsoleCmdArgs* pArgs)
567+
void CmdQuickGameStop(IConsoleCmdArgs* pArgs)
579568
{
580569

581570
}
582571

583-
void CGame::CmdBattleDustReload(IConsoleCmdArgs* pArgs)
572+
void CmdBattleDustReload(IConsoleCmdArgs* pArgs)
584573
{
585574
if (CBattleDust* pBD = g_pGame->GetGameRules()->GetBattleDust())
586575
{

0 commit comments

Comments
 (0)