Code cleanup in class overlays.

This commit is contained in:
richard 2009-11-30 16:49:11 +01:00
parent 109a923ae3
commit 37c9929bd4
2 changed files with 8 additions and 13 deletions

View File

@ -45,29 +45,24 @@
new Handle:g_hOverlayEnabledCookie = INVALID_HANDLE; new Handle:g_hOverlayEnabledCookie = INVALID_HANDLE;
/** /**
* Hook commands related to overlay here. * Creates command clallbacks for listed overlay commands.
*/ */
ClassOverlayOnCommandsHook() ClassOverlayOnCommandsHook()
{ {
// Create command callbacks (intercepts) for listed suicide commands.
decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH]; decl String:togglecmds[CLASSOVERLAY_TOGGLE_MAX_CMDS * CLASSOVERLAY_TOGGLE_MAX_LENGTH];
GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds)); GetConVarString(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLECMDS], togglecmds, sizeof(togglecmds));
// Create array to store cmds // Array to store commands.
new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH]; new String:arrayCmds[CLASSOVERLAY_TOGGLE_MAX_CMDS][CLASSOVERLAY_TOGGLE_MAX_LENGTH];
// Explode string into array indexes. // Put the commands into an array.
new cmdcount = ExplodeString(togglecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[])); new cmdcount = ExplodeString(togglecmds, ",", arrayCmds, sizeof(arrayCmds), sizeof(arrayCmds[]));
// x = Array index. // Register all overlay commands.
// arrayCmds[x] = suicide command. for (new i = 0; i < cmdcount; i++)
for (new x = 0; x <= cmdcount - 1; x++)
{ {
// Trim whitespace. TrimString(arrayCmds[i]);
TrimString(arrayCmds[x]); RegConsoleCmd(arrayCmds[i], ClassOverlayEnableCommand);
// Prepare intercept for this command.
RegConsoleCmd(arrayCmds[x], ClassOverlayEnableCommand);
} }
} }