Update spcomp and includes to latest 1.10-fork

disable warning 241: Array-based enum structs will be removed in 1.11
This commit is contained in:
BotoX
2024-06-21 06:55:55 +02:00
committed by zaCade
parent 689c4e89cf
commit 917ec936f8
72 changed files with 7755 additions and 6440 deletions
+109 -105
View File
@@ -36,38 +36,26 @@
#define _helpers_included
/**
* Formats a user's info as log text. This is usually not needed because
* %L can be used to auto-format client information into a string.
* This function is deprecated. Use the %L format specifier instead.
*
* Formats a user's info as log text.
*
* @param client Client index.
* @param buffer Buffer for text.
* @param maxlength Maximum length of text.
* @param client Client index.
* @param buffer Buffer for text.
* @param maxlength Maximum length of text.
* @deprecated Use the %L format specifier instead.
*/
#pragma deprecated Use the %L format specifier instead.
stock void FormatUserLogText(int client, char[] buffer, int maxlength)
{
char auth[32];
char name[MAX_NAME_LENGTH];
int userid = GetClientUserId(client);
if (!GetClientAuthString(client, auth, sizeof(auth)))
{
strcopy(auth, sizeof(auth), "UNKNOWN");
}
if (!GetClientName(client, name, sizeof(name)))
{
strcopy(name, sizeof(name), "UNKNOWN");
}
/** Currently, no team stuff ... */
Format(buffer, maxlength, "\"%s<%d><%s><>\"", name, userid, auth);
FormatEx(buffer, maxlength, "\"%L\"", client);
}
/**
* Returns plugin handle from plugin filename.
*
* @param filename Filename of the plugin to search for.
* @return Handle to plugin if found, INVALID_HANDLE otherwise.
* @param filename Filename of the plugin to search for.
* @return Handle to plugin if found, INVALID_HANDLE otherwise.
*/
stock Handle FindPluginByFile(const char[] filename)
{
@@ -94,7 +82,7 @@ stock Handle FindPluginByFile(const char[] filename)
}
/**
* @deprecated Use FindTarget() or ProcessTargetString().
* @deprecated Use FindTarget() or ProcessTargetString().
*/
#pragma deprecated Use FindTarget() or ProcessTargetString()
stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
@@ -102,24 +90,34 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
int total = 0;
if (maxClients == 0)
{
return 0;
}
if (pattern[0] == '#') {
if (pattern[0] == '#')
{
int input = StringToInt(pattern[1]);
if (!input) {
char name[MAX_NAME_LENGTH];
for (int i=1; i<=MaxClients; i++) {
for (int i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i))
{
continue;
}
GetClientName(i, name, sizeof(name));
if (strcmp(name, pattern, false) == 0) {
if (strcmp(name, pattern, false) == 0)
{
clients[0] = i;
return 1;
}
}
} else {
}
else
{
int client = GetClientOfUserId(input);
if (client) {
if (client)
{
clients[0] = client;
return 1;
}
@@ -130,12 +128,18 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
for (int i=1; i<=MaxClients; i++)
{
if (!IsClientInGame(i))
{
continue;
}
GetClientName(i, name, sizeof(name));
if (StrContains(name, pattern, false) != -1) {
if (StrContains(name, pattern, false) != -1)
{
clients[total++] = i;
if (total >= maxClients)
{
break;
}
}
}
@@ -146,11 +150,11 @@ stock int SearchForClients(const char[] pattern, int[] clients, int maxClients)
* Wraps ProcessTargetString() and handles producing error messages for
* bad targets.
*
* @param client Client who issued command
* @param target Client's target argument
* @param nobots Optional. Set to true if bots should NOT be targetted
* @param immunity Optional. Set to false to ignore target immunity.
* @return Index of target client, or -1 on error.
* @param client Client who issued command
* @param target Client's target argument
* @param nobots Optional. Set to true if bots should NOT be targetted
* @param immunity Optional. Set to false to ignore target immunity.
* @return Index of target client, or -1 on error.
*/
stock int FindTarget(int client, const char[] target, bool nobots = false, bool immunity = true)
{
@@ -163,6 +167,7 @@ stock int FindTarget(int client, const char[] target, bool nobots = false, bool
{
flags |= COMMAND_FILTER_NO_BOTS;
}
if (!immunity)
{
flags |= COMMAND_FILTER_NO_IMMUNITY;
@@ -180,11 +185,9 @@ stock int FindTarget(int client, const char[] target, bool nobots = false, bool
{
return target_list[0];
}
else
{
ReplyToTargetError(client, target_count);
return -1;
}
ReplyToTargetError(client, target_count);
return -1;
}
/**
@@ -197,83 +200,84 @@ stock int FindTarget(int client, const char[] target, bool nobots = false, bool
* parameter is used to store a timestamp of the file. If specified, the file will only be reloaded if it
* has changed.
*
* @param array Valid array handle, should be created with CreateArray(33) or larger.
* @param fileTime Variable containing the "last changed" time of the file. Used to avoid needless reloading.
* @param fileCvar CVAR set to the file to be loaded. Optional.
* @return Number of maps loaded or 0 if in error.
* @param array Valid array handle, should be created with CreateArray(33) or larger.
* @param fileTime Variable containing the "last changed" time of the file. Used to avoid needless reloading.
* @param fileCvar CVAR set to the file to be loaded. Optional.
* @return Number of maps loaded or 0 if in error.
* @deprecated Use ReadMapList() instead.
*/
#pragma deprecated Use ReadMapList() instead.
stock int LoadMaps(Handle array, int &fileTime = 0, Handle fileCvar = INVALID_HANDLE)
{
char mapPath[256], mapFile[64];
bool fileFound = false;
if (fileCvar != INVALID_HANDLE)
{
GetConVarString(fileCvar, mapFile, 64);
BuildPath(Path_SM, mapPath, sizeof(mapPath), mapFile);
fileFound = FileExists(mapPath);
}
stock int LoadMaps(Handle array, int &fileTime = 0, Handle fileCvar = INVALID_HANDLE)
{
char mapPath[256], mapFile[64];
bool fileFound = false;
if (fileCvar != INVALID_HANDLE)
{
GetConVarString(fileCvar, mapFile, 64);
BuildPath(Path_SM, mapPath, sizeof(mapPath), mapFile);
fileFound = FileExists(mapPath);
}
if (!fileFound)
{
Handle mapCycleFile = FindConVar("mapcyclefile");
GetConVarString(mapCycleFile, mapPath, sizeof(mapPath));
fileFound = FileExists(mapPath);
}
if (!fileFound)
{
LogError("Failed to find a file to load maps from. No maps loaded.");
ClearArray(array);
return 0;
}
if (!fileFound)
{
Handle mapCycleFile = FindConVar("mapcyclefile");
GetConVarString(mapCycleFile, mapPath, sizeof(mapPath));
fileFound = FileExists(mapPath);
}
if (!fileFound)
{
LogError("Failed to find a file to load maps from. No maps loaded.");
ClearArray(array);
return 0;
}
// If the file hasn't changed, there's no reason to reload
// all of the maps.
int newTime = GetFileTime(mapPath, FileTime_LastChange);
if (fileTime == newTime)
{
return GetArraySize(array);
}
fileTime = newTime;
ClearArray(array);
// If the file hasn't changed, there's no reason to reload
// all of the maps.
int newTime = GetFileTime(mapPath, FileTime_LastChange);
if (fileTime == newTime)
{
return GetArraySize(array);
}
fileTime = newTime;
ClearArray(array);
File file = OpenFile(mapPath, "rt");
if (!file) {
LogError("Could not open file: %s", mapPath);
return 0;
}
File file = OpenFile(mapPath, "rt");
if (!file) {
LogError("Could not open file: %s", mapPath);
return 0;
}
LogMessage("Loading maps from file: %s", mapPath);
int len;
char buffer[64];
while (!file.EndOfFile() && file.ReadLine(buffer, sizeof(buffer)))
{
TrimString(buffer);
char buffer[64];
while (!file.EndOfFile() && file.ReadLine(buffer, sizeof(buffer)))
{
TrimString(buffer);
if ((len = StrContains(buffer, ".bsp", false)) != -1)
{
buffer[len] = '\0';
}
if ((len = StrContains(buffer, ".bsp", false)) != -1)
{
buffer[len] = '\0';
}
if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer))
{
continue;
}
if (FindStringInArray(array, buffer) != -1)
{
continue;
}
if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer))
{
continue;
}
if (FindStringInArray(array, buffer) != -1)
{
continue;
}
PushArrayString(array, buffer);
}
PushArrayString(array, buffer);
}
file.Close();
return GetArraySize(array);
return GetArraySize(array);
}