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

@ -91,38 +91,14 @@ void CheckDirectories()
public void RestartTimers()
{
delete g_hDrawFullZone;
delete g_hDrawZone;
delete g_hHudLoop;
delete g_hSideHudLoop;
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);
}

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

@ -177,7 +177,7 @@ public ClearExistingData()
continue;
}
CloseHandle(hHandle);
delete hHandle;
}
ClearArray(g_hIndexArray);
@ -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)
@ -284,7 +284,7 @@ public SMCResult:SMCReadKeyValues(Handle:smc, const String:key[], const String:v
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))
{
@ -421,7 +421,7 @@ public DisplayMOTDWithOptions(iClient, const String:sTitle[], const String:sUrl[
}
ShowVGUIPanel(iClient, "info", hKv, bNotSilent);
CloseHandle(hKv);
delete hKv;
}
static stock bool:IsValidClient(iClient)

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

@ -252,7 +252,7 @@ stock void MC_ReplaceColorCodes(char[] buffer, int author = 0, bool removeTags =
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;
}

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()