forked from UNLOZE/sm-plugins
CloseHandle -> delete
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user