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
+167 -156
View File
@@ -45,53 +45,53 @@
/**
* Calculates the length of a string.
*
* @param str String to check.
* @return Number of valid character bytes in the string.
* @param str String to check.
* @return Number of valid character bytes in the string.
*/
native int strlen(const char[] str);
/**
* Tests whether a string is found inside another string.
*
* @param str String to search in.
* @param substr Substring to find inside the original string.
* @param caseSensitive If true (default), search is case sensitive.
* If false, search is case insensitive.
* @return -1 on failure (no match found). Any other value
* indicates a position in the string where the match starts.
* @param str String to search in.
* @param substr Substring to find inside the original string.
* @param caseSensitive If true (default), search is case sensitive.
* If false, search is case insensitive.
* @return -1 on failure (no match found). Any other value
* indicates a position in the string where the match starts.
*/
native int StrContains(const char[] str, const char[] substr, bool caseSensitive=true);
/**
* Compares two strings lexographically.
*
* @param str1 First string (left).
* @param str2 Second string (right).
* @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive.
* @return -1 if str1 < str2
* 0 if str1 == str2
* 1 if str1 > str2
* @param str1 First string (left).
* @param str2 Second string (right).
* @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive.
* @return -1 if str1 < str2
* 0 if str1 == str2
* 1 if str1 > str2
*/
native int strcmp(const char[] str1, const char[] str2, bool caseSensitive=true);
/**
* Compares two strings parts lexographically.
*
* @param str1 First string (left).
* @param str2 Second string (right).
* @param num Number of characters to compare.
* @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive.
* @return -1 if str1 < str2
* 0 if str1 == str2
* 1 if str1 > str2
* @param str1 First string (left).
* @param str2 Second string (right).
* @param num Number of characters to compare.
* @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive.
* @return -1 if str1 < str2
* 0 if str1 == str2
* 1 if str1 > str2
*/
native int strncmp(const char[] str1, const char[] str2, int num, bool caseSensitive=true);
/**
* Backwards compatible stock - StrCompare is now strcmp
* @deprecated Renamed to strcmp
* @deprecated Renamed to strcmp
*/
#pragma deprecated Use strcmp() instead
stock int StrCompare(const char[] str1, const char[] str2, bool caseSensitive=true)
@@ -102,11 +102,11 @@ stock int StrCompare(const char[] str1, const char[] str2, bool caseSensitive=tr
/**
* Returns whether two strings are equal.
*
* @param str1 First string (left).
* @param str2 Second string (right).
* @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive.
* @return True if equal, false otherwise.
* @param str1 First string (left).
* @param str2 Second string (right).
* @param caseSensitive If true (default), comparison is case sensitive.
* If false, comparison is case insensitive.
* @return True if equal, false otherwise.
*/
stock bool StrEqual(const char[] str1, const char[] str2, bool caseSensitive=true)
{
@@ -118,16 +118,16 @@ stock bool StrEqual(const char[] str1, const char[] str2, bool caseSensitive=tru
* @note If the destination buffer is too small to hold the source string, the
* destination will be truncated.
*
* @param dest Destination string buffer to copy to.
* @param destLen Destination buffer length (includes null terminator).
* @param source Source string buffer to copy from.
* @return Number of cells written.
* @param dest Destination string buffer to copy to.
* @param destLen Destination buffer length (includes null terminator).
* @param source Source string buffer to copy from.
* @return Number of cells written.
*/
native int strcopy(char[] dest, int destLen, const char[] source);
/**
* Backwards compatibility stock - use strcopy
* @deprecated Renamed to strcopy
* @deprecated Renamed to strcopy
*/
#pragma deprecated Use strcopy() instead
stock int StrCopy(char[] dest, int destLen, const char[] source)
@@ -138,11 +138,11 @@ stock int StrCopy(char[] dest, int destLen, const char[] source)
/**
* Formats a string according to the SourceMod format rules (see documentation).
*
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @return Number of cells written.
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @return Number of cells written.
*/
native int Format(char[] buffer, int maxlength, const char[] format, any ...);
@@ -152,11 +152,11 @@ native int Format(char[] buffer, int maxlength, const char[] format, any ...);
* overlap the same memory as the output buffer. Since this security
* check is removed, it is slightly faster.
*
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @return Number of cells written.
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @param ... Variable number of format parameters.
* @return Number of cells written.
*/
native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...);
@@ -166,68 +166,68 @@ native int FormatEx(char[] buffer, int maxlength, const char[] format, any ...);
* parent parameter stack, rather than a local. This is useful for
* implementing your own variable argument functions.
*
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @param varpos Argument number which contains the '...' symbol.
* Note: Arguments start at 1.
* @return Number of bytes written.
* @param buffer Destination string buffer.
* @param maxlength Maximum length of output string buffer.
* @param format Formatting rules.
* @param varpos Argument number which contains the '...' symbol.
* Note: Arguments start at 1.
* @return Number of bytes written.
*/
native int VFormat(char[] buffer, int maxlength, const char[] format, int varpos);
/**
* Converts a string to an integer.
*
* @param str String to convert.
* @param nBase Numerical base to use. 10 is default.
* @return Integer conversion of string, or 0 on failure.
* @param str String to convert.
* @param nBase Numerical base to use. 10 is default.
* @return Integer conversion of string, or 0 on failure.
*/
native int StringToInt(const char[] str, int nBase=10);
/**
* Converts a string to an integer with some more options.
*
* @param str String to convert.
* @param result Variable to store the result in.
* @param nBase Numerical base to use. 10 is default.
* @return Number of characters consumed.
* @param str String to convert.
* @param result Variable to store the result in.
* @param nBase Numerical base to use. 10 is default.
* @return Number of characters consumed.
*/
native int StringToIntEx(const char[] str, int &result, int nBase=10);
/**
* Converts an integer to a string.
*
* @param num Integer to convert.
* @param str Buffer to store string in.
* @param maxlength Maximum length of string buffer.
* @return Number of cells written to buffer.
* @param num Integer to convert.
* @param str Buffer to store string in.
* @param maxlength Maximum length of string buffer.
* @return Number of cells written to buffer.
*/
native int IntToString(int num, char[] str, int maxlength);
/**
* Converts a string to a floating point number.
*
* @param str String to convert to a float.
* @return Floating point result, or 0.0 on error.
* @param str String to convert to a float.
* @return Floating point result, or 0.0 on error.
*/
native float StringToFloat(const char[] str);
/**
* Converts a string to a floating point number with some more options.
*
* @param str String to convert to a float.
* @param result Variable to store result in.
* @return Number of characters consumed.
* @param str String to convert to a float.
* @param result Variable to store result in.
* @return Number of characters consumed.
*/
native int StringToFloatEx(const char[] str, float &result);
/**
* Converts a floating point number to a string.
*
* @param num Floating point number to convert.
* @param str Buffer to store string in.
* @param maxlength Maximum length of string buffer.
* @return Number of cells written to buffer.
* @param num Floating point number to convert.
* @param str Buffer to store string in.
* @param maxlength Maximum length of string buffer.
* @return Number of cells written to buffer.
*/
native int FloatToString(float num, char[] str, int maxlength);
@@ -238,16 +238,16 @@ native int FloatToString(float num, char[] str, int maxlength);
* of the string is reached. If nothing remains, -1 is returned.
* Otherwise, the index to the first character is returned.
*
* @param source Source input string.
* @param arg Stores argument read from string.
* @param argLen Maximum length of argument buffer.
* @return Index to next piece of string, or -1 if none.
* @param source Source input string.
* @param arg Stores argument read from string.
* @param argLen Maximum length of argument buffer.
* @return Index to next piece of string, or -1 if none.
*/
native int BreakString(const char[] source, char[] arg, int argLen);
/**
* Backwards compatibility stock - use BreakString
* @deprecated Renamed to BreakString.
* @deprecated Renamed to BreakString.
*/
#pragma deprecated Use BreakString() instead
stock int StrBreak(const char[] source, char[] arg, int argLen)
@@ -258,21 +258,21 @@ stock int StrBreak(const char[] source, char[] arg, int argLen)
/**
* Removes whitespace characters from the beginning and end of a string.
*
* @param str The string to trim.
* @return Number of bytes written (UTF-8 safe).
* @param str The string to trim.
* @return Number of bytes written (UTF-8 safe).
*/
native int TrimString(char[] str);
/**
* Returns text in a string up until a certain character sequence is reached.
*
* @param source Source input string.
* @param split A string which specifies a search point to break at.
* @param part Buffer to store string part.
* @param partLen Maximum length of the string part buffer.
* @return -1 if no match was found; otherwise, an index into source
* marking the first index after the searched text. The
* index is always relative to the start of the input string.
* @param source Source input string.
* @param split A string which specifies a search point to break at.
* @param part Buffer to store string part.
* @param partLen Maximum length of the string part buffer.
* @return -1 if no match was found; otherwise, an index into source
* marking the first index after the searched text. The
* index is always relative to the start of the input string.
*/
native int SplitString(const char[] source, const char[] split, char[] part, int partLen);
@@ -280,12 +280,12 @@ native int SplitString(const char[] source, const char[] split, char[] part, int
* Given a string, replaces all occurrences of a search string with a
* replacement string.
*
* @param text String to perform search and replacements on.
* @param maxlength Maximum length of the string buffer.
* @param search String to search for.
* @param replace String to replace the search string with.
* @param caseSensitive If true (default), search is case sensitive.
* @return Number of replacements that were performed.
* @param text String to perform search and replacements on.
* @param maxlength Maximum length of the string buffer.
* @param search String to search for.
* @param replace String to replace the search string with.
* @param caseSensitive If true (default), search is case sensitive.
* @return Number of replacements that were performed.
*/
native int ReplaceString(char[] text, int maxlength, const char[] search, const char[] replace, bool caseSensitive=true);
@@ -293,18 +293,18 @@ native int ReplaceString(char[] text, int maxlength, const char[] search, const
* Given a string, replaces the first occurrence of a search string with a
* replacement string.
*
* @param text String to perform search and replacements on.
* @param maxlength Maximum length of the string buffer.
* @param search String to search for.
* @param replace String to replace the search string with.
* @param searchLen If higher than -1, its value will be used instead of
* a strlen() call on the search parameter.
* @param replaceLen If higher than -1, its value will be used instead of
* a strlen() call on the replace parameter.
* @param caseSensitive If true (default), search is case sensitive.
* @return Index into the buffer (relative to the start) from where
* the last replacement ended, or -1 if no replacements were
* made.
* @param text String to perform search and replacements on.
* @param maxlength Maximum length of the string buffer.
* @param search String to search for.
* @param replace String to replace the search string with.
* @param searchLen If higher than -1, its value will be used instead of
* a strlen() call on the search parameter.
* @param replaceLen If higher than -1, its value will be used instead of
* a strlen() call on the replace parameter.
* @param caseSensitive If true (default), search is case sensitive.
* @return Index into the buffer (relative to the start) from where
* the last replacement ended, or -1 if no replacements were
* made.
*/
native int ReplaceStringEx(char[] text, int maxlength, const char[] search, const char[] replace, int searchLen=-1, int replaceLen=-1, bool caseSensitive=true);
@@ -313,8 +313,8 @@ native int ReplaceStringEx(char[] text, int maxlength, const char[] search, cons
* for multi-byte characters (UTF-8). For normal ASCII characters,
* this will return 1.
*
* @param source Source input string.
* @return Number of bytes the current character uses.
* @param source Source input string.
* @return Number of bytes the current character uses.
*/
native int GetCharBytes(const char[] source);
@@ -323,8 +323,8 @@ native int GetCharBytes(const char[] source);
*
* @note Multi-byte characters will always return false.
*
* @param chr Character to test.
* @return True if character is alphabetical, otherwise false.
* @param chr Character to test.
* @return True if character is alphabetical, otherwise false.
*/
native bool IsCharAlpha(int chr);
@@ -333,8 +333,8 @@ native bool IsCharAlpha(int chr);
*
* @note Multi-byte characters will always return false.
*
* @param chr Character to test.
* @return True if character is numeric, otherwise false.
* @param chr Character to test.
* @return True if character is numeric, otherwise false.
*/
native bool IsCharNumeric(int chr);
@@ -343,17 +343,17 @@ native bool IsCharNumeric(int chr);
*
* @note Multi-byte characters will always return false.
*
* @param chr Character to test.
* @return True if character is whitespace, otherwise false.
* @param chr Character to test.
* @return True if character is whitespace, otherwise false.
*/
native bool IsCharSpace(int chr);
/**
* Returns if a character is multi-byte or not.
*
* @param chr Character to test.
* @return 0 for a normal 7-bit ASCII character,
* otherwise number of bytes in multi-byte character.
* @param chr Character to test.
* @return 0 for a normal 7-bit ASCII character,
* otherwise number of bytes in multi-byte character.
*/
native int IsCharMB(int chr);
@@ -362,8 +362,8 @@ native int IsCharMB(int chr);
*
* @note Multi-byte characters will always return false.
*
* @param chr Character to test.
* @return True if character is uppercase, otherwise false.
* @param chr Character to test.
* @return True if character is uppercase, otherwise false.
*/
native bool IsCharUpper(int chr);
@@ -372,8 +372,8 @@ native bool IsCharUpper(int chr);
*
* @note Multi-byte characters will always return false.
*
* @param chr Character to test.
* @return True if character is lowercase, otherwise false.
* @param chr Character to test.
* @return True if character is lowercase, otherwise false.
*/
native bool IsCharLower(int chr);
@@ -385,18 +385,18 @@ native bool IsCharLower(int chr);
* exist. Otherwise, the string is left unmodified. This function should
* be considered O(k) (all characters get shifted down).
*
* @param text String to modify (in place).
* @return True if string was modified, false if there was no
* set of quotes.
* @param text String to modify (in place).
* @return True if string was modified, false if there was no
* set of quotes.
*/
native bool StripQuotes(char[] text);
/**
* Returns an uppercase character to a lowercase character.
* Converts a lowercase character to its uppercase counterpart.
*
* @param chr Character to convert.
* @return Lowercase character on success,
* no change on failure.
* @param chr Character to convert.
* @return Uppercase character on success,
* no change on failure.
*/
stock int CharToUpper(int chr)
{
@@ -404,15 +404,16 @@ stock int CharToUpper(int chr)
{
return (chr & ~(1<<5));
}
return chr;
}
/**
* Returns a lowercase character to an uppercase character.
* Converts an uppercase character to its lowercase counterpart.
*
* @param chr Character to convert.
* @return Uppercase character on success,
* no change on failure.
* @param chr Character to convert.
* @return Lowercase character on success,
* no change on failure.
*/
stock int CharToLower(int chr)
{
@@ -420,32 +421,42 @@ stock int CharToLower(int chr)
{
return (chr | (1<<5));
}
return chr;
}
/**
* Finds the first occurrence of a character in a string.
*
* @param str String.
* @param c Character to search for.
* @param reverse False (default) to search forward, true to search
* backward.
* @return The index of the first occurrence of the character
* in the string, or -1 if the character was not found.
* @param str String.
* @param c Character to search for.
* @param reverse False (default) to search forward, true to search
* backward.
* @return The index of the first occurrence of the character
* in the string, or -1 if the character was not found.
*/
stock int FindCharInString(const char[] str, char c, bool reverse = false)
{
int len = strlen(str);
if (!reverse) {
for (int i = 0; i < len; i++) {
if (!reverse)
{
for (int i = 0; i < len; i++)
{
if (str[i] == c)
{
return i;
}
}
} else {
for (int i = len - 1; i >= 0; i--) {
}
else
{
for (int i = len - 1; i >= 0; i--)
{
if (str[i] == c)
{
return i;
}
}
}
@@ -455,10 +466,10 @@ stock int FindCharInString(const char[] str, char c, bool reverse = false)
/**
* Concatenates one string onto another.
*
* @param buffer String to append to.
* @param maxlength Maximum length of entire buffer.
* @param source Source string to concatenate.
* @return Number of bytes written.
* @param buffer String to append to.
* @param maxlength Maximum length of entire buffer.
* @param source Source string to concatenate.
* @return Number of bytes written.
*/
stock int StrCat(char[] buffer, int maxlength, const char[] source)
{
@@ -474,14 +485,14 @@ stock int StrCat(char[] buffer, int maxlength, const char[] source)
/**
* Breaks a string into pieces and stores each piece into an array of buffers.
*
* @param text The string to split.
* @param split The string to use as a split delimiter.
* @param buffers An array of string buffers (2D array).
* @param maxStrings Number of string buffers (first dimension size).
* @param maxStringLength Maximum length of each string buffer.
* @param copyRemainder False (default) discard excess pieces, true to ignore
* delimiters after last piece.
* @return Number of strings retrieved.
* @param text The string to split.
* @param split The string to use as a split delimiter.
* @param buffers An array of string buffers (2D array).
* @param maxStrings Number of string buffers (first dimension size).
* @param maxStringLength Maximum length of each string buffer.
* @param copyRemainder False (default) discard excess pieces, true to ignore
* delimiters after last piece.
* @return Number of strings retrieved.
*/
stock int ExplodeString(const char[] text, const char[] split, char[][] buffers, int maxStrings,
int maxStringLength, bool copyRemainder = false)
@@ -515,12 +526,12 @@ stock int ExplodeString(const char[] text, const char[] split, char[][] buffers,
* Joins an array of strings into one string, with a "join" string inserted in
* between each given string. This function complements ExplodeString.
*
* @param strings An array of strings.
* @param numStrings Number of strings in the array.
* @param join The join string to insert between each string.
* @param buffer Output buffer to write the joined string to.
* @param maxLength Maximum length of the output buffer.
* @return Number of bytes written to the output buffer.
* @param strings An array of strings.
* @param numStrings Number of strings in the array.
* @param join The join string to insert between each string.
* @param buffer Output buffer to write the joined string to.
* @param maxLength Maximum length of the output buffer.
* @return Number of bytes written to the output buffer.
*/
stock int ImplodeStrings(const char[][] strings, int numStrings, const char[] join, char[] buffer, int maxLength)
{