CloseHandle -> delete

This commit is contained in:
neon 2019-07-07 22:44:43 +02:00
parent 4dd4ff521b
commit eeba405984
18 changed files with 258 additions and 292 deletions

View File

@ -90,7 +90,7 @@ public void OnPluginStart()
HookConVarChange((cvar = CreateConVar("sm_afk_immunity", "1", "AFK admins immunity: 0 = DISABLED, 1 = COMPLETE, 2 = KICK, 3 = MOVE")), Cvar_Immunity);
g_iImmunity = GetConVarInt(cvar);
CloseHandle(cvar);
delete cvar;
AddCommandListener(Command_Say, "say");
AddCommandListener(Command_Say, "say_team");

View File

@ -36,14 +36,14 @@ public void OnPluginStart()
int iMaxClipOffset;
if ((iMaxClipOffset = GameConfGetOffset(hGameConf, "GetMaxClip")) == -1)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("GameConfGetOffset(hGameConf, \"GetMaxClip\") failed!");
return;
}
if ((g_hGetMaxClip = DHookCreate(iMaxClipOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxClip)) == INVALID_HANDLE)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("DHookCreate(iMaxClipOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxClip) failed!");
return;
}
@ -54,14 +54,14 @@ public void OnPluginStart()
int iMaxReserveOffset;
if ((iMaxReserveOffset = GameConfGetOffset(hGameConf, "GetMaxReserve")) == -1)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("GameConfGetOffset(hGameConf, \"GetMaxReserve\") failed!");
return;
}
if ((g_hGetMaxReserve = DHookCreate(iMaxReserveOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxReserve)) == INVALID_HANDLE)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("DHookCreate(iMaxReserveOffset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnGetMaxReserve) failed!");
return;
}
@ -74,7 +74,7 @@ public void OnPluginStart()
OnEntityCreated(entity, "weapon_*");
}
CloseHandle(hGameConf);
delete hGameConf;
}
//----------------------------------------------------------------------------------------------------

View File

@ -5,22 +5,22 @@ public void OnMapStart()
AddFileToDownloadsTable("sound/unl1/disco.wav");
PrecacheSound("unl1/disco.wav");
AddFileToDownloadsTable("sound/unl1/steamedyes.mp3");
PrecacheSound("unl1/steamedyes.mp3");
GetCurrentMap(g_sMapName, sizeof(g_sMapName));
LowerString(g_sMapName, sizeof(g_sMapName));
RestartTimers();
ClearMapInfo();
CheckDirectories();
if (g_hDatabase != null)
{
LoadMapInfo();
}
}
public void OnConfigsExecuted()
@ -57,7 +57,7 @@ public void Event_RoundStart(Handle event, char[] name, bool dontBroadcast)
{
CreateTrigger(i);
}
for (int i = 0; i <= MAXPLAYERS; i++)
for (int i = 0; i <= MAXPLAYERS; i++)
{
g_iActivity[i] = -1;
}
@ -65,7 +65,7 @@ public void Event_RoundStart(Handle event, char[] name, bool dontBroadcast)
/*public Action CS_OnTerminateRound(float& delay, CSRoundEndReason& reason)
{
}*/
public void Event_PlayerDeath(Handle event, char[] name, bool dontBroadcast)
@ -78,12 +78,12 @@ void CheckDirectories()
{
char path[PLATFORM_MAX_PATH];
BuildPath(Path_SM, path, sizeof(path), REPLAYS_PATH);
if (!DirExists(path))
CreateDirectory(path, 711);
BuildPath(Path_SM, path, sizeof(path), "%s/%s", REPLAYS_PATH, g_sMapName);
if (!DirExists(path))
CreateDirectory(path, 711);
@ -91,39 +91,15 @@ void CheckDirectories()
public void RestartTimers()
{
if (g_hDrawFullZone != INVALID_HANDLE)
{
CloseHandle(g_hDrawFullZone);
g_hDrawFullZone = INVALID_HANDLE;
}
if (g_hDrawZone != INVALID_HANDLE)
{
CloseHandle(g_hDrawZone);
g_hDrawZone = INVALID_HANDLE;
}
if (g_hHudLoop != INVALID_HANDLE)
{
CloseHandle(g_hHudLoop);
g_hHudLoop = INVALID_HANDLE;
}
if (g_hSideHudLoop != INVALID_HANDLE)
{
CloseHandle(g_hSideHudLoop);
g_hSideHudLoop = INVALID_HANDLE;
}
if (g_hDrawFullZone == INVALID_HANDLE)
g_hDrawFullZone = CreateTimer(0.2, DrawFullZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
if (g_hDrawZone == INVALID_HANDLE)
g_hDrawZone = CreateTimer(1.0, DrawZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
if (g_hHudLoop == INVALID_HANDLE)
g_hHudLoop = CreateTimer(0.2, HudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
if (g_hSideHudLoop == INVALID_HANDLE)
g_hSideHudLoop = CreateTimer(1.0, SideHudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
delete g_hDrawFullZone;
delete g_hDrawZone;
delete g_hHudLoop;
delete g_hSideHudLoop;
g_hDrawFullZone = CreateTimer(0.2, DrawFullZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
g_hDrawZone = CreateTimer(1.0, DrawZoneTimer, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
g_hHudLoop = CreateTimer(0.2, HudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
g_hSideHudLoop = CreateTimer(1.0, SideHudLoop, INVALID_HANDLE, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
public void ClearMapInfo()
@ -144,7 +120,7 @@ public void ClearMapInfo()
g_bEditorComesFromMenu = false;
g_iSnapToClient = -1;
g_fWrTime = -1.0;
Format(g_sWrHolder, sizeof(g_sWrHolder), "\0");
}
@ -160,39 +136,39 @@ public void ProcessFinish(int client)
if (fTimeToWR == fTime)
Format(cTimeToWR, sizeof(cTimeToWR), "WR");
else
TimerFormat(fTimeToWR, cTimeToWR, sizeof(cTimeToWR), true, true);
if (g_fMapTime[client] > fTime)
{
float fTimeDif;
char cTimeDif[16];
fTimeDif = g_fMapTime[client] - fTime;
g_fMapTime[client] = fTime;
TimerFormat(fTimeDif, cTimeDif, sizeof(cTimeDif), true, false);
TimerPrintToChat(client, true, "%T", "FinishedImproved", LANG_SERVER, name, cTime, cTimeToWR, cTimeDif);
UpdateTime(client);
if (fTimeToWR < 0.0)
UpdateWR(client, fTime, name);
}
else
{
TimerPrintToChat(client, true, "%T", "Finished", LANG_SERVER, name, cTime, cTimeToWR);
if (g_fMapTime[client] == 0.0)
{
g_fMapTime[client] = fTime;
UpdateTime(client);
if (fTimeToWR < 0.0 || g_fWrTime == 0.0)
{
UpdateWR(client, fTime, name);
}
}
else
{
@ -208,17 +184,17 @@ public void UpdateWR(int client, float time, char[] name)
LogError("WR never loaded, reload map");
return;
}
if (g_fWrTime < time && g_fWrTime != 0.0)
{
LogError("Time submitted is not faster");
return;
}
SaveRecord(client);
g_fWrTime = time;
strcopy(g_sWrHolder, sizeof(g_sWrHolder), name);
}
@ -228,13 +204,13 @@ public void ProcessRankMessage(int client, int rank, int total)
GetClientName(client, name, sizeof(name));
if (rank > 10)
TimerPrintToChat(client, false, "%T", "Rank", LANG_SERVER, name, rank, total);
else if (rank <= 10 && rank != 1)
{
TimerPrintToChat(client, true, "%T", "RankTop10", LANG_SERVER, name, rank, total);
EmitSoundToAll("unl1/steamedyes.mp3");
}
else if (rank == 1)
{
TimerPrintToChat(client, true, "%T", "RankWR", LANG_SERVER, name, rank, total);

View File

@ -196,8 +196,7 @@ public Action Command_JoinMsg(int client, int args)
char sAuth[32];
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
if (g_hCustomMessageFile != null)
CloseHandle(g_hCustomMessageFile);
delete g_hCustomMessageFile;
g_hCustomMessageFile = CreateKeyValues("custom_messages");
@ -270,8 +269,7 @@ public Action Command_ResetJoinMsg(int client, int args)
char sAuth[32];
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
if (g_hCustomMessageFile != null)
CloseHandle(g_hCustomMessageFile);
delete g_hCustomMessageFile;
g_hCustomMessageFile = CreateKeyValues("custom_messages");
@ -323,7 +321,7 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data)
{
ReadFileLine(hFile, sRawMsg, sizeof(sRawMsg));
TrimString(sRawMsg);
CloseHandle(hFile);
delete hFile;
}
else
{
@ -411,8 +409,7 @@ public void TQueryCB(Handle owner, Handle rs, const char[] error, any data)
return;
}
if (g_hCustomMessageFile2 != null)
CloseHandle(g_hCustomMessageFile2);
delete g_hCustomMessageFile2;
g_hCustomMessageFile2 = CreateKeyValues("custom_messages");

View File

@ -54,7 +54,7 @@ public void OnPluginStart()
HookConVarChange((cvar = CreateConVar("sm_happyhour_message_interval", "60.0", "interval for repetetive message of happy hour in chat")), g_cvMessageTimer);
g_fMessageTimer = cvar.FloatValue;
CloseHandle(cvar);
delete cvar;
RegConsoleCmd("sm_hh", Command_DisplayHappyHour, "Shows if happy hour is currently enabled or not");
@ -87,8 +87,7 @@ public void g_cvMessageTimer(ConVar convar, const char[] oldValue, const char[]
{
g_fMessageTimer = convar.FloatValue;
if (g_h_MessageTimer != INVALID_HANDLE && CloseHandle(g_h_MessageTimer))
g_h_MessageTimer = INVALID_HANDLE;
delete g_h_MessageTimer;
g_h_MessageTimer = CreateTimer(g_fMessageTimer, MessageHappyHour, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}

View File

@ -61,19 +61,19 @@ public void OnPluginStart()
}
if(GameConfGetOffset(hGameConf, "GetSlot") == -1)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("Couldn't get GetSlot offset from game config!");
return;
}
if(GameConfGetOffset(hGameConf, "BumpWeapon") == -1)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("Couldn't get BumpWeapon offset from game config!");
return;
}
if(GameConfGetOffset(hGameConf, "OnPickedUp") == -1)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("Couldn't get OnPickedUp offset from game config!");
return;
}
@ -82,7 +82,7 @@ public void OnPluginStart()
StartPrepSDKCall(SDKCall_Entity);
if(!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "GetSlot"))
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"GetSlot\" failed!");
return;
}
@ -93,7 +93,7 @@ public void OnPluginStart()
StartPrepSDKCall(SDKCall_Player);
if(!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "BumpWeapon"))
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"BumpWeapon\" failed!");
return;
}
@ -105,7 +105,7 @@ public void OnPluginStart()
StartPrepSDKCall(SDKCall_Entity);
if(!PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, "OnPickedUp"))
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("PrepSDKCall_SetFromConf(hGameConf, SDKConf_Virtual, \"OnPickedUp\" failed!");
return;
}

View File

@ -307,7 +307,7 @@ public int Handler_MakoVoteMenu(Handle menu, MenuAction action, int param1, int
{
case MenuAction_End:
{
CloseHandle(menu);
delete menu;
if (param1 != -1)
{

View File

@ -44,7 +44,7 @@ public void OnPluginStart()
g_fSelfExtendsRatio = cvar.FloatValue;
HookConVarChange((cvar = CreateConVar("sm_selfextend_delay", "60.0", "Time to pass until sm_selfextend can be used")), Cvar_SelfExtendsDelay);
g_fSelfExtendsDelay = cvar.FloatValue;
CloseHandle(cvar);
delete cvar;
g_cvarTimeLimit = FindConVar("mp_timelimit");

View File

@ -33,14 +33,14 @@ public void OnPluginStart()
int iOffset;
if ((iOffset = GameConfGetOffset(hGameConf, "SelectSpawnPoint")) == -1)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("GameConfGetOffset(hGameConf, \"SelectSpawnPoint\") failed!");
return;
}
if ((hSelectSpawnPoint = DHookCreate(iOffset, HookType_Entity, ReturnType_CBaseEntity, ThisPointer_CBaseEntity, OnPlayerSelectSpawnPoint)) == INVALID_HANDLE)
{
CloseHandle(hGameConf);
delete hGameConf;
SetFailState("DHookCreate(iOffset, HookType_Entity, ReturnType_CBaseEntity, ThisPointer_CBaseEntity, OnPlayerSelectSpawnPoint) failed!");
return;
}
@ -54,7 +54,7 @@ public void OnPluginStart()
}
}
CloseHandle(hGameConf);
delete hGameConf;
}
//----------------------------------------------------------------------------------------------------

View File

@ -740,7 +740,7 @@ public void OnReloadEffect(DataPack pack)
}
}
CloseHandle(pack);
delete pack;
Handle ReloadEffect = StartMessage("ReloadEffect", players, playersNum, USERMSG_RELIABLE | USERMSG_BLOCKHOOKS);
if(GetFeatureStatus(FeatureType_Native, "GetUserMessageType") == FeatureStatus_Available && GetUserMessageType() == UM_Protobuf)

View File

@ -48,7 +48,7 @@ enum _:FieldCheckFlags
#else
Flag_MaxPlayers = (1<<16)
#endif /* _steamtools_included */
};
};
#define IsTeamFortress2() (g_iGameMode & Game_TF2)
#define IsLeftForDead() (g_iGameMode & Game_L4D)
@ -67,15 +67,15 @@ public OnPluginStart()
g_hIndexArray = CreateArray(); /* We'll only use this for cleanup to prevent handle leaks and what not.
Our friend below doesn't have iteration, so we have to do this... */
g_hFastLookupTrie = CreateTrie();
AddCommandListener(Client_Say, "say");
AddCommandListener(Client_Say, "say_team");
/* From Psychonic */
Duck_OnPluginStart();
new Handle:cvarVersion = CreateConVar("webshortcutsredux_version", PLUGIN_VERSION, PLUGIN_DESCRIPTION, FCVAR_PLUGIN|FCVAR_NOTIFY);
/* On a reload, this will be set to the old version. Let's update it. */
SetConVarString(cvarVersion, PLUGIN_VERSION);
}
@ -86,22 +86,22 @@ public Action:Client_Say(iClient, const String:sCommand[], argc)
{
return Plugin_Continue; /* Well. While we can probably have blank hooks, I doubt anyone wants this. Lets not waste cycles. Let the game deal with this. */
}
decl String:sFirstArg[64]; /* If this is too small, let someone know. */
GetCmdArg(1, sFirstArg, sizeof(sFirstArg));
TrimString(sFirstArg);
new Handle:hStoredTrie = INVALID_HANDLE;
if (!GetTrieValue(g_hFastLookupTrie, sFirstArg, hStoredTrie) || hStoredTrie == INVALID_HANDLE) /* L -> R. Strings are R -> L, but that can change. */
{
return Plugin_Continue; /* Didn't find anything. Bug out! */
}
if (DealWithOurTrie(iClient, sFirstArg, hStoredTrie))
{
return Plugin_Handled; /* We want other hooks to be called, I guess. We just don't want it to go to the game. */
}
return Plugin_Continue; /* Well this is embarasing. We didn't actually hook this. Or atleast didn't intend to. */
}
@ -113,14 +113,14 @@ public bool:DealWithOurTrie(iClient, const String:sHookedString[], Handle:hStore
LogError("Unable to find a Url for: \"%s\".", sHookedString);
return false;
}
new iUrlBits;
if (!GetTrieValue(hStoredTrie, "UrlBits", iUrlBits))
{
iUrlBits = 0; /* That's fine, there are no replacements! Less work for us. */
}
decl String:sTitle[256];
new iTitleBits;
if (!GetTrieString(hStoredTrie, "Title", sTitle, sizeof(sTitle)))
@ -135,12 +135,12 @@ public bool:DealWithOurTrie(iClient, const String:sHookedString[], Handle:hStore
iTitleBits = 0; /* That's fine, there are no replacements! Less work for us. */
}
}
Duck_DoReplacements(iClient, sUrl, iUrlBits, sTitle, iTitleBits); /* Arrays are passed by reference. Variables are copied. */
new bool:bBig;
new bool:bNotSilent = true;
GetTrieValue(hStoredTrie, "Silent", bNotSilent);
if (GoLargeOrGoHome())
{
@ -152,15 +152,15 @@ public bool:DealWithOurTrie(iClient, const String:sHookedString[], Handle:hStore
{
new iMsgBits;
GetTrieValue(hStoredTrie, "MsgBits", iMsgBits);
if (iMsgBits != 0)
{
Duck_DoReplacements(iClient, sMessage, iMsgBits, sMessage, 0); /* Lame Hack for now */
}
PrintToChatAll("%s", sMessage);
}
DisplayMOTDWithOptions(iClient, sTitle, sUrl, bBig, bNotSilent, MOTDPANEL_TYPE_URL);
return true;
}
@ -171,15 +171,15 @@ public ClearExistingData()
for (new i = (GetArraySize(g_hIndexArray) - 1); i >= 0; i--)
{
hHandle = GetArrayCell(g_hIndexArray, i);
if (hHandle == INVALID_HANDLE)
{
continue;
}
CloseHandle(hHandle);
delete hHandle;
}
ClearArray(g_hIndexArray);
ClearTrie(g_hFastLookupTrie);
}
@ -187,14 +187,14 @@ public ClearExistingData()
public OnConfigsExecuted()
{
ClearExistingData();
decl String:sPath[256];
BuildPath(Path_SM, sPath, sizeof(sPath), "configs/Webshortcuts.txt");
if (!FileExists(sPath))
{
return;
}
ProcessFile(sPath);
}
@ -202,10 +202,10 @@ public ProcessFile(const String:sPathToFile[])
{
new Handle:hSMC = SMC_CreateParser();
SMC_SetReaders(hSMC, SMCNewSection, SMCReadKeyValues, SMCEndSection);
new iLine;
new SMCError:ReturnedError = SMC_ParseFile(hSMC, sPathToFile, iLine); /* Calls the below functions, then execution continues. */
if (ReturnedError != SMCError_Okay)
{
decl String:sError[256];
@ -213,14 +213,14 @@ public ProcessFile(const String:sPathToFile[])
if (iLine > 0)
{
LogError("Could not parse file (Line: %d, File \"%s\"): %s.", iLine, sPathToFile, sError);
CloseHandle(hSMC); /* Sneaky Handles. */
delete hSMC; /* Sneaky Handles. */
return;
}
LogError("Parser encountered error (File: \"%s\"): %s.", sPathToFile, sError);
}
CloseHandle(hSMC);
delete hSMC;
}
public SMCResult:SMCNewSection(Handle:smc, const String:name[], bool:opt_quotes)
@ -229,9 +229,9 @@ public SMCResult:SMCNewSection(Handle:smc, const String:name[], bool:opt_quotes)
{
LogError("Invalid Quoting used with Section: %s.", name);
}
strcopy(g_sCurrentSection, sizeof(g_sCurrentSection), name);
if (GetTrieValue(g_hFastLookupTrie, name, g_hCurrentTrie))
{
return SMCParse_Continue;
@ -243,7 +243,7 @@ public SMCResult:SMCNewSection(Handle:smc, const String:name[], bool:opt_quotes)
SetTrieValue(g_hFastLookupTrie, name, g_hCurrentTrie);
SetTrieString(g_hCurrentTrie, "Name", name);
}
return SMCParse_Continue;
}
@ -261,7 +261,7 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v
{
return SMCParse_Continue;
}
switch (key[0])
{
case 'p','P':
@ -270,21 +270,21 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v
{
return SMCParse_Continue;
}
new iFindValue;
iFindValue = FindValueInArray(g_hIndexArray, g_hCurrentTrie);
if (iFindValue > -1)
{
RemoveFromArray(g_hIndexArray, iFindValue);
}
if (g_sCurrentSection[0] != '\0')
{
RemoveFromTrie(g_hFastLookupTrie, g_sCurrentSection);
}
CloseHandle(g_hCurrentTrie); /* We're about to invalidate below */
delete g_hCurrentTrie; /* We're about to invalidate below */
if (GetTrieValue(g_hFastLookupTrie, value, g_hCurrentTrie))
{
@ -297,81 +297,81 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v
SetTrieValue(g_hFastLookupTrie, g_sCurrentSection, g_hCurrentTrie, true);
SetTrieString(g_hCurrentTrie, "Name", g_sCurrentSection, true);
}
case 'u','U':
{
if (!StrEqual(key, "Url", false))
{
return SMCParse_Continue;
}
SetTrieString(g_hCurrentTrie, "Url", value, true);
new iBits;
Duck_CalcBits(value, iBits); /* Passed by Ref */
SetTrieValue(g_hCurrentTrie, "UrlBits", iBits, true);
}
case 'T','t':
{
if (!StrEqual(key, "Title", false))
{
return SMCParse_Continue;
}
SetTrieString(g_hCurrentTrie, "Title", value, true);
new iBits;
Duck_CalcBits(value, iBits); /* Passed by Ref */
SetTrieValue(g_hCurrentTrie, "TitleBits", iBits, true);
}
case 'b','B':
{
if (!GoLargeOrGoHome() || !StrEqual(key, "Big", false)) /* Maybe they don't know they can't use it? Oh well. Protect the silly. */
{
return SMCParse_Continue;
}
SetTrieValue(g_hCurrentTrie, "Big", TranslateToBool(value), true);
}
case 'h','H':
{
if (!StrEqual(key, "Hook", false))
{
return SMCParse_Continue;
}
SetTrieValue(g_hFastLookupTrie, value, g_hCurrentTrie, true);
}
case 's', 'S':
{
if (!StrEqual(key, "Silent", false))
{
return SMCParse_Continue;
}
SetTrieValue(g_hCurrentTrie, "Silent", !TranslateToBool(value), true);
}
case 'M', 'm':
{
if (!StrEqual(key, "Msg", false))
{
return SMCParse_Continue;
}
SetTrieString(g_hCurrentTrie, "Msg", value, true);
new iBits;
Duck_CalcBits(value, iBits); /* Passed by Ref */
SetTrieValue(g_hCurrentTrie, "MsgBits", iBits, true);
}
}
return SMCParse_Continue;
}
@ -389,13 +389,13 @@ public bool:TranslateToBool(const String:sSource[])
{
return false;
}
case '1', 'y', 'Y', 't', 'T', 's', 'S':
{
return true;
}
}
return false; /* Assume False */
}
@ -407,21 +407,21 @@ public DisplayMOTDWithOptions(iClient, const String:sTitle[], const String:sUrl[
{
KvSetNum(hKv, "customsvr", 1);
}
KvSetNum(hKv, "type", iType);
if (sTitle[0] != '\0')
{
KvSetString(hKv, "title", sTitle);
}
if (sUrl[0] != '\0')
{
KvSetString(hKv, "msg", sUrl);
}
ShowVGUIPanel(iClient, "info", hKv, bNotSilent);
CloseHandle(hKv);
delete hKv;
}
static stock bool:IsValidClient(iClient)
@ -455,7 +455,7 @@ if (StrContains(source, %1) != -1) { field |= %2; }
#if defined _steamtools_included
#define TOKEN_VACSTATUS "{VAC_STATUS}"
#define TOKEN_SERVER_PUB_IP "{SERVER_PUB_IP}"
#define TOKEN_STEAM_CONNSTATUS "{STEAM_CONNSTATUS}"
#define TOKEN_STEAM_CONNSTATUS "{STEAM_CONNSTATUS}"
new g_bSteamTools;
#endif /* _steamtools_included */
@ -485,7 +485,7 @@ public OnLibraryRemoved(const String:sLibrary[])
{
return;
}
g_bSteamTools = false;
}
@ -500,29 +500,29 @@ public Duck_OnPluginStart()
g_iGameMode |= Game_TF2;
g_iGameMode |= Big_MOTD;
}
/* On a reload, these will already be registered and could be set to non-default */
if (IsTeamFortress2())
{
/* AddCommandListener(Duck_TF2OnClose, "closed_htmlpage"); */
}
LongIPToString(GetConVarInt(FindConVar("hostip")), g_szServerIp);
}
LongIPToString(GetConVarInt(FindConVar("hostip")), g_szServerIp);
GetConVarString(FindConVar("hostport"), g_szServerPort, sizeof(g_szServerPort));
new Handle:hostname = FindConVar("hostname");
decl String:szHostname[256];
GetConVarString(hostname, szHostname, sizeof(szHostname));
Duck_UrlEncodeString(g_szServerName, sizeof(g_szServerName), szHostname);
HookConVarChange(hostname, OnCvarHostnameChange);
decl String:szCustom[256];
new Handle:hCVARCustom = CreateConVar("WebShortcuts_Custom", "", "Custom String for this server.");
GetConVarString(hCVARCustom, szCustom, sizeof(szCustom));
Duck_UrlEncodeString(g_szServerCustom, sizeof(g_szServerCustom), szCustom);
HookConVarChange(hCVARCustom, OnCvarCustomChange);
new iSDKVersion = GuessSDKVersion();
if (iSDKVersion == SOURCE_SDK_LEFT4DEAD || iSDKVersion == SOURCE_SDK_LEFT4DEAD2)
{
@ -533,7 +533,7 @@ public Duck_OnPluginStart()
Duck_UrlEncodeString(g_szL4DGameMode, sizeof(g_szL4DGameMode), szGamemode);
HookConVarChange(hGameMode, OnCvarGamemodeChange);
}
Duck_UrlEncodeString(g_szGameDir, sizeof(g_szGameDir), sGameDir);
}
@ -541,7 +541,7 @@ public OnMapStart()
{
decl String:sTempMap[sizeof(g_szCurrentMap)];
GetCurrentMap(sTempMap, sizeof(sTempMap));
Duck_UrlEncodeString(g_szCurrentMap, sizeof(g_szCurrentMap), sTempMap);
}
@ -566,7 +566,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_STEAM_ID, "");
}
}
if (iUrlBits & Flag_User_ID || iTitleBits & Flag_User_ID)
{
decl String:sUserId[16];
@ -576,7 +576,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
if (iUrlBits & Flag_User_ID)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_USER_ID, sUserId);
}
if (iUrlBits & Flag_Friend_ID || iTitleBits & Flag_Friend_ID)
{
decl String:sFriendId[64];
@ -595,7 +595,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_FRIEND_ID, "");
}
}
if (iUrlBits & Flag_Name || iTitleBits & Flag_Name)
{
decl String:sName[MAX_NAME_LENGTH];
@ -616,7 +616,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_NAME, "");
}
}
if (iUrlBits & Flag_IP || iTitleBits & Flag_IP)
{
decl String:sClientIp[32];
@ -635,7 +635,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_IP, "");
}
}
if (iUrlBits & Flag_Language || iTitleBits & Flag_Language)
{
decl String:sLanguage[32];
@ -656,7 +656,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_LANGUAGE, "");
}
}
if (iUrlBits & Flag_Rate || iTitleBits & Flag_Rate)
{
decl String:sRate[16];
@ -678,27 +678,27 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_RATE, "");
}
}
if (iTitleBits & Flag_Server_IP)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_IP, g_szServerIp);
if (iUrlBits & Flag_Server_IP)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_IP, g_szServerIp);
if (iTitleBits & Flag_Server_Port)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_PORT, g_szServerPort);
if (iUrlBits & Flag_Server_Port)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_PORT, g_szServerPort);
if (iTitleBits & Flag_Server_Name)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_NAME, g_szServerName);
if (iUrlBits & Flag_Server_Name)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_NAME, g_szServerName);
ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_NAME, g_szServerName);
if (iTitleBits & Flag_Server_Custom)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_CUSTOM, g_szServerCustom);
if (iUrlBits & Flag_Server_Custom)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_CUSTOM, g_szServerCustom);
if (IsLeftForDead() && ((iUrlBits & Flag_L4D_GameMode) || (iTitleBits & Flag_L4D_GameMode)))
{
if (iTitleBits & Flag_L4D_GameMode)
@ -706,12 +706,12 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
if (iUrlBits & Flag_L4D_GameMode)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_L4D_GAMEMODE, g_szL4DGameMode);
}
if (iTitleBits & Flag_Current_Map)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_CURRENT_MAP, g_szCurrentMap);
if (iUrlBits & Flag_Current_Map)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_CURRENT_MAP, g_szCurrentMap);
if (iUrlBits & Flag_Next_Map || iTitleBits & Flag_Next_Map)
{
decl String:szNextMap[PLATFORM_MAX_PATH];
@ -730,12 +730,12 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_NEXT_MAP, "");
}
}
if (iTitleBits & Flag_GameDir)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_GAMEDIR, g_szGameDir);
if (iUrlBits & Flag_GameDir)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_GAMEDIR, g_szGameDir);
if (iUrlBits & Flag_CurPlayers || iTitleBits & Flag_CurPlayers)
{
decl String:sCurPlayers[10];
@ -745,7 +745,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
if (iUrlBits & Flag_CurPlayers)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_CURPLAYERS, sCurPlayers);
}
if (iUrlBits & Flag_MaxPlayers || iTitleBits & Flag_MaxPlayers)
{
decl String:maxplayers[10];
@ -755,8 +755,8 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
if (iUrlBits & Flag_MaxPlayers)
ReplaceString(sUrl, sizeof(sUrl), TOKEN_MAXPLAYERS, maxplayers);
}
#if defined _steamtools_included
#if defined _steamtools_included
if (iUrlBits & Flag_VACStatus || iTitleBits & Flag_VACStatus)
{
if (g_bSteamTools && Steam_IsVACEnabled())
@ -774,7 +774,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_VACSTATUS, "0");
}
}
if (iUrlBits & Flag_Server_Pub_IP || iTitleBits & Flag_Server_Pub_IP)
{
if (g_bSteamTools)
@ -783,7 +783,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
decl String:sIPString[16];
Steam_GetPublicIP(ip);
FormatEx(sIPString, sizeof(sIPString), "%d.%d.%d.%d", ip[0], ip[1], ip[2], ip[3]);
if (iTitleBits & Flag_Server_Pub_IP)
ReplaceString(sTitle, sizeof(sTitle), TOKEN_SERVER_PUB_IP, sIPString);
if (iUrlBits & Flag_Server_Pub_IP)
@ -797,7 +797,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
ReplaceString(sUrl, sizeof(sUrl), TOKEN_SERVER_PUB_IP, "");
}
}
if (iUrlBits & Flag_Steam_ConnStatus || iTitleBits & Flag_Steam_ConnStatus)
{
if (g_bSteamTools && Steam_IsConnected())
@ -818,7 +818,7 @@ stock Duck_DoReplacements(iClient, String:sUrl[256], iUrlBits, String:sTitle[256
#endif /* _steamtools_included */
}
stock bool:GetClientFriendID(client, String:sFriendID[], size)
stock bool:GetClientFriendID(client, String:sFriendID[], size)
{
#if defined _steamtools_included
Steam_GetCSteamIDForClient(client, sFriendID, size);
@ -829,22 +829,22 @@ stock bool:GetClientFriendID(client, String:sFriendID[], size)
sFriendID[0] = '\0'; /* Sanitize incase the return isn't checked. */
return false;
}
TrimString(sSteamID); /* Just incase... */
if (StrEqual(sSteamID, "STEAM_ID_LAN", false))
{
sFriendID[0] = '\0';
return false;
}
decl String:toks[3][16];
ExplodeString(sSteamID, ":", toks, sizeof(toks), sizeof(toks[]));
new iServer = StringToInt(toks[1]);
new iAuthID = StringToInt(toks[2]);
new iFriendID = (iAuthID*2) + 60265728 + iServer;
if (iFriendID >= 100000000)
{
decl String:temp[12], String:carry[12];
@ -852,7 +852,7 @@ stock bool:GetClientFriendID(client, String:sFriendID[], size)
FormatEx(carry, 2, "%s", temp);
new icarry = StringToInt(carry[0]);
new upper = 765611979 + icarry;
FormatEx(temp, sizeof(temp), "%d", iFriendID);
FormatEx(sFriendID, size, "%d%s", upper, temp[1]);
}
@ -867,7 +867,7 @@ stock bool:GetClientFriendID(client, String:sFriendID[], size)
Duck_CalcBits(const String:source[], &field)
{
field = 0;
FIELD_CHECK(TOKEN_STEAM_ID, Flag_Steam_ID);
FIELD_CHECK(TOKEN_USER_ID, Flag_User_ID);
FIELD_CHECK(TOKEN_FRIEND_ID, Flag_Friend_ID);
@ -879,12 +879,12 @@ Duck_CalcBits(const String:source[], &field)
FIELD_CHECK(TOKEN_SERVER_PORT, Flag_Server_Port);
FIELD_CHECK(TOKEN_SERVER_NAME, Flag_Server_Name);
FIELD_CHECK(TOKEN_SERVER_CUSTOM, Flag_Server_Custom);
if (IsLeftForDead())
{
FIELD_CHECK(TOKEN_L4D_GAMEMODE, Flag_L4D_GameMode);
}
FIELD_CHECK(TOKEN_CURRENT_MAP, Flag_Current_Map);
FIELD_CHECK(TOKEN_NEXT_MAP, Flag_Next_Map);
FIELD_CHECK(TOKEN_GAMEDIR, Flag_GameDir);
@ -909,7 +909,7 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[])
{
new icnt = 0;
new ocnt = 0;
for(;;)
{
if (ocnt == size)
@ -917,14 +917,14 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[])
output[ocnt-1] = '\0';
return;
}
new c = input[icnt];
if (c == '\0')
{
output[ocnt] = '\0';
return;
}
// Use '+' instead of '%20'.
// Still follows spec and takes up less of our limited buffer.
if (c == ' ')
@ -934,7 +934,7 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[])
else if ((c < '0' && c != '-' && c != '.') ||
(c < 'A' && c > '9') ||
(c > 'Z' && c < 'a' && c != '_') ||
(c > 'z' && c != '~'))
(c > 'z' && c != '~'))
{
output[ocnt++] = '%';
Format(output[ocnt], size-strlen(output[ocnt]), "%x", c);
@ -944,7 +944,7 @@ stock Duck_UrlEncodeString(String:output[], size, const String:input[])
{
output[ocnt++] = c;
}
icnt++;
}
}

View File

@ -270,7 +270,7 @@ stock CAddVariable(String:sName[], String:sValue[], bool:bOnlySaveToConfig = fal
new Handle:hKV = CreateKeyValues("colorvariables");
if (!FileToKeyValues(hKV, g_sConfig)) {
CloseHandle(hKV);
delete hKV;
LogError("Cannot open file (for adding color variable) '%s' !", g_sConfig);
return;
}
@ -284,13 +284,13 @@ stock CAddVariable(String:sName[], String:sValue[], bool:bOnlySaveToConfig = fal
PushArrayString(hRedirect, sName);
SetTrieString(g_hColors, sName, sValue);
SolveRedirects(g_hColors, hRedirect);
CloseHandle(hRedirect);
delete hRedirect;
}
}
KvRewind(hKV);
KeyValuesToFile(hKV, g_sConfig);
CloseHandle(hKV);
delete hKV;
}
}
@ -310,7 +310,7 @@ stock CLoadPluginConfig(const String:sPluginName[], bool:bAllowPrefix = true)
new Handle:hRedirect = CreateArray(64);
LoadConfigFile(g_hColors, sConfig, hRedirect, bAllowPrefix);
SolveRedirects(g_hColors, hRedirect);
CloseHandle(hRedirect);
delete hRedirect;
}
}
@ -346,8 +346,8 @@ stock CLoadPluginVariables(const String:sPluginName[], const String:sVariables[]
}
SolveRedirects(g_hColors, hRedirect);
CloseHandle(hRedirect);
CloseHandle(hVariables);
delete hRedirect;
delete hVariables;
}
}
@ -571,8 +571,7 @@ stock bool:Init()
}
WriteFileLine(hConfig, "}");
CloseHandle(hConfig);
hConfig = INVALID_HANDLE;
delete hConfig;
} else {
hConfig = OpenFile(g_sConfigGlobal, "r");
if (hConfig == INVALID_HANDLE) {
@ -582,7 +581,7 @@ stock bool:Init()
new String:sVersionLine[64];
ReadFileLine(hConfig, sVersionLine, sizeof(sVersionLine));
CloseHandle(hConfig);
delete hConfig;
TrimString(sVersionLine);
strcopy(sVersionLine, sizeof(sVersionLine), sVersionLine[FindCharInString(sVersionLine, ':') + 2]);
@ -591,7 +590,7 @@ stock bool:Init()
new Handle:hKV = CreateKeyValues("colorvariables");
if (!FileToKeyValues(hKV, g_sConfigGlobal) || !KvGotoFirstSubKey(hKV, false)) {
CloseHandle(hKV);
delete hKV;
LogError("Cannot read variables from file '%s' !", g_sConfigGlobal);
return false;
}
@ -629,8 +628,8 @@ stock bool:Init()
WriteFileLine(hConfig, "}");
CloseHandle(hConfig);
CloseHandle(hKV);
delete hConfig;
delete hKV;
}
}
@ -643,8 +642,7 @@ stock bool:Init()
}
WriteFileLine(hConfig, "\"colorvariables\"\n{\n}");
CloseHandle(hConfig);
hConfig = INVALID_HANDLE;
delete hConfig;
}
for (new iClient = 1; iClient <= MaxClients; iClient++) {
@ -683,13 +681,13 @@ stock static LoadConfigFile(Handle:hTrie, String:sPath[], Handle:hRedirect, bool
new Handle:hKV = CreateKeyValues("colorvariables");
if (!FileToKeyValues(hKV, sPath)) {
CloseHandle(hKV);
delete hKV;
LogError("Cannot load color variables from file '%s' !", sPath);
return;
}
if (!KvGotoFirstSubKey(hKV, false)) {
CloseHandle(hKV);
delete hKV;
return;
}
@ -723,7 +721,7 @@ stock static LoadConfigFile(Handle:hTrie, String:sPath[], Handle:hRedirect, bool
SetTrieString(hTrie, sCode, sColor);
} while (KvGotoNextKey(hKV, false));
CloseHandle(hKV);
delete hKV;
}
stock static SolveRedirects(Handle:hTrie, Handle:hRedirect)

View File

@ -29,11 +29,11 @@ static Handle sm_show_activity = INVALID_HANDLE;
/**
* Prints a message to a specific client in the chat area.
* Supports color tags.
*
*
* @param client Client index.
* @param message Message (formatting rules).
* @noreturn
*
*
* On error/Errors: If the client is not connected an error will be thrown.
*/
stock void MC_PrintToChat(int client, const char[] message, any ...) {
@ -55,7 +55,7 @@ stock void MC_PrintToChat(int client, const char[] message, any ...) {
/**
* Prints a message to all clients in the chat area.
* Supports color tags.
*
*
* @param client Client index.
* @param message Message (formatting rules).
* @noreturn
@ -79,12 +79,12 @@ stock void MC_PrintToChatAll(const char[] message, any ...) {
/**
* Prints a message to a specific client in the chat area.
* Supports color tags and teamcolor tag.
*
*
* @param client Client index.
* @param author Author index whose color will be used for teamcolor tag.
* @param message Message (formatting rules).
* @noreturn
*
*
* On error/Errors: If the client or author are not connected an error will be thrown
*/
stock void MC_PrintToChatEx(int client, int author, const char[] message, any ...) {
@ -116,7 +116,7 @@ stock void MC_PrintToChatEx(int client, int author, const char[] message, any ..
* @param author Author index whose color will be used for teamcolor tag.
* @param message Message (formatting rules).
* @noreturn
*
*
* On error/Errors: If the author is not connected an error will be thrown.
*/
stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) {
@ -143,7 +143,7 @@ stock void MC_PrintToChatAllEx(int author, const char[] message, any ...) {
/**
* Sends a SayText2 usermessage
*
*
* @param client Client to send usermessage to
* @param message Message to send
* @noreturn
@ -191,7 +191,7 @@ stock void MC_SendMessage(int client, const char[] message, int author = 0) {
* MC_PrintToChatAll or MC_PrintToChatAllEx. It causes those functions
* to skip the specified client when printing the message.
* After printing the message, the client will no longer be skipped.
*
*
* @param client Client index
* @noreturn
*/
@ -204,7 +204,7 @@ stock void MC_SkipNextClient(int client) {
/**
* Checks if the colors trie is initialized and initializes it if it's not (used internally)
*
*
* @return No return
*/
stock void MC_CheckTrie() {
@ -221,7 +221,7 @@ stock void MC_CheckTrie() {
* @param removeTags Optional boolean value to determine whether we're replacing tags with colors, or just removing tags, used by MC_RemoveTags
* @param maxlen Optional value for max buffer length, used by MC_RemoveTags
* @noreturn
*
*
* On error/Errors: If the client index passed for author is invalid or not in game.
*/
stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags = false, int maxlen = MAX_BUFFER_LENGTH) {
@ -243,16 +243,16 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
}
int cursor = 0;
int value;
char tag[32], buff[32];
char tag[32], buff[32];
char[] output = new char[maxlen];
strcopy(output, maxlen, buffer);
// Since the string's size is going to be changing, output will hold the replaced string and we'll search buffer
Handle regex = CompileRegex("{[a-zA-Z0-9]+}");
for(int i = 0; i < 1000; i++) { // The RegEx extension is quite flaky, so we have to loop here :/. This loop is supposed to be infinite and broken by return, but conditions have been added to be safe.
if(MatchRegex(regex, buffer[cursor]) < 1) {
CloseHandle(regex);
delete regex;
strcopy(buffer, maxlen, output);
return;
}
@ -262,11 +262,11 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
strcopy(buff, sizeof(buff), tag);
ReplaceString(buff, sizeof(buff), "{", "");
ReplaceString(buff, sizeof(buff), "}", "");
if(!GetTrieValue(MC_Trie, buff, value)) {
continue;
}
if(removeTags) {
ReplaceString(output, maxlen, tag, "", false);
} else {
@ -279,7 +279,7 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
/**
* Gets a part of a string
*
*
* @param input String to get the part from
* @param output Buffer to write to
* @param maxlen Max length of output buffer
@ -301,7 +301,7 @@ stock void CSubString(const char[] input, char[] output, int maxlen, int start,
/**
* Converts a string to lowercase
*
*
* @param buffer String to convert
* @noreturn
*/
@ -334,7 +334,7 @@ stock bool MC_AddColor(const char[] name, int color) {
/**
* Removes color tags from a message
*
*
* @param message Message to remove tags from
* @param maxlen Maximum buffer length
* @noreturn
@ -345,7 +345,7 @@ stock void MC_RemoveTags(char[] message, int maxlen) {
/**
* Replies to a command with colors
*
*
* @param client Client to reply to
* @param message Message (formatting rules)
* @noreturn
@ -364,7 +364,7 @@ stock void MC_ReplyToCommand(int client, const char[] message, any ...) {
/**
* Replies to a command with colors
*
*
* @param client Client to reply to
* @param author Client to use for {teamcolor}
* @param message Message (formatting rules)
@ -383,12 +383,12 @@ stock void MC_ReplyToCommandEx(int client, int author, const char[] message, any
}
/**
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
* Displays usage of an admin command to users depending on the
* setting of the sm_show_activity cvar.
*
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* This version does not display a message to the originating client
* if used from chat triggers or menus. If manual replies are used
* for these cases, then this function will suffice. Otherwise,
* MC_ShowActivity2() is slightly more useful.
* Supports color tags.
*
@ -402,14 +402,14 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
if (sm_show_activity == INVALID_HANDLE)
sm_show_activity = FindConVar("sm_show_activity");
char tag[] = "[SM] ";
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
@ -417,7 +417,7 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@ -425,13 +425,13 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE)
{
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
@ -441,16 +441,16 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@ -475,7 +475,7 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@ -494,12 +494,12 @@ stock int MC_ShowActivity(int client, const char[] format, any ...)
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 3);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
@ -518,12 +518,12 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
if (sm_show_activity == INVALID_HANDLE)
sm_show_activity = FindConVar("sm_show_activity");
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
bool display_in_chat = false;
@ -531,7 +531,7 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@ -539,13 +539,13 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
sign = "PLAYER";
}
/* Display the message to the client? */
if (replyto == SM_REPLY_TO_CONSOLE)
{
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToConsole(client, "%s%s\n", tag, szBuffer);
display_in_chat = true;
@ -555,16 +555,16 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@ -589,7 +589,7 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@ -608,18 +608,18 @@ stock int MC_ShowActivityEx(int client, const char[] tag, const char[] format, a
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
}
/**
* Displays usage of an admin command to users depending on the setting of the sm_show_activity cvar.
* All users receive a message in their chat text, except for the originating client,
* All users receive a message in their chat text, except for the originating client,
* who receives the message based on the current ReplySource.
* Supports color tags.
*
@ -634,19 +634,19 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
{
if (sm_show_activity == INVALID_HANDLE)
sm_show_activity = FindConVar("sm_show_activity");
char szBuffer[MC_MAX_MESSAGE_LENGTH];
//char szCMessage[MC_MAX_MESSAGE_LENGTH];
int value = GetConVarInt(sm_show_activity);
// ReplySource replyto = GetCmdReplySource();
char name[MAX_NAME_LENGTH] = "Console";
char sign[MAX_NAME_LENGTH] = "ADMIN";
if (client != 0)
{
if (client < 0 || client > MaxClients || !IsClientConnected(client))
ThrowError("Client index %d is invalid", client);
GetClientName(client, name, sizeof(name));
AdminId id = GetUserAdmin(client);
if (id == INVALID_ADMIN_ID
@ -654,12 +654,12 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
{
sign = "PLAYER";
}
SetGlobalTransTarget(client);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
/* We don't display directly to the console because the chat text
* simply gets added to the console, so we don't want it to print
* twice.
*/
MC_PrintToChatEx(client, client, "%s%s", tag, szBuffer);
@ -668,16 +668,16 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
{
SetGlobalTransTarget(LANG_SERVER);
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_RemoveTags(szBuffer, sizeof(szBuffer));
PrintToServer("%s%s\n", tag, szBuffer);
}
if (!value)
{
return 1;
}
MuCo_LoopClients(i)
{
if (i == 0
@ -702,7 +702,7 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
@ -721,18 +721,18 @@ stock int MC_ShowActivity2(int client, const char[] tag, const char[] format, an
newsign = name;
}
VFormat(szBuffer, sizeof(szBuffer), format, 4);
MC_PrintToChatEx(i, client, "%s%s: %s", tag, newsign, szBuffer);
}
}
}
return 1;
return 1;
}
/**
* Determines whether a color name exists
*
*
* @param color The color name to check
* @return True if the color exists, false otherwise
*/

View File

@ -290,7 +290,7 @@ native bool json_object_update_missing(JSONObject hObj, JSONObject hOther);
*
* // Do something with sKey and hValue
*
* CloseHandle(hValue);
* delete hValue;
*
* hIterator = json_object_iter_next(hObj, hIterator);
* }
@ -1575,7 +1575,7 @@ public JSONObject json_pack_object_(const char[] sFormat, int &iPos, Handle hPar
if(this_char != 115) {
LogError("Object keys must be strings at %d.", iPos);
CloseHandle(hObj);
delete hObj;
return view_as<JSONObject>(INVALID_HANDLE);
}

View File

@ -816,7 +816,7 @@ public int LeaderMenu_Handler(Handle menu, MenuAction action, int client, int po
}
else if(action == MenuAction_End)
{
CloseHandle(menu);
delete menu;
}
}
@ -912,7 +912,7 @@ public int SpriteMenu_Handler(Handle menu, MenuAction action, int client, int po
}
else if(action == MenuAction_End)
{
CloseHandle(menu);
delete menu;
}
else if (action == MenuAction_Cancel && position == MenuCancel_ExitBack)
{
@ -989,7 +989,7 @@ public int MarkerMenu_Handler(Handle menu, MenuAction action, int client, int po
}
else if(action == MenuAction_End)
{
CloseHandle(menu);
delete menu;
}
else if (action == MenuAction_Cancel && position == MenuCancel_ExitBack)
{

View File

@ -1192,7 +1192,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
AddMapItem(map);
}
CloseHandle(randomizeList);
delete randomizeList;
randomizeList = INVALID_HANDLE;
}
@ -1233,7 +1233,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
}
}
CloseHandle(inputlist);
delete inputlist;
}
int voteDuration = GetConVarInt(g_Cvar_VoteDuration);
@ -1482,7 +1482,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
if(g_NativeVotes)
NativeVotes_Close(menu);
else
CloseHandle(menu);
delete menu;
}
case MenuAction_Display:
@ -1748,7 +1748,7 @@ void CreateNextVote()
}
delete groupmap;
CloseHandle(tempMaps);
delete tempMaps;
}
bool CanVoteStart()

View File

@ -179,7 +179,7 @@ public OnListBans(Handle:owner, Handle:hndl, const String:error[], any:pack)
new client = GetClientOfUserId(clientuid);
decl String:targetName[MAX_NAME_LENGTH];
ReadPackString(pack, targetName, sizeof(targetName));
CloseHandle(pack);
delete pack;
if (clientuid > 0 && client == 0)
return;

View File

@ -781,11 +781,7 @@ public Action Sparks(Handle timer)
stock ClearTimer(&Handle:timer)
{
if (timer != INVALID_HANDLE)
{
CloseHandle(timer);
timer = INVALID_HANDLE;
}
delete timer;
}
public Action SpawnSeagullRelay()