diff --git a/Makefile b/Makefile index d3262ab..e13ca5b 100644 --- a/Makefile +++ b/Makefile @@ -4,8 +4,8 @@ SOURCEDIR=src SMINCLUDES=env/include BUILDDIR=build -SPCOMP_LINUX=env/linux/bin/spcomp-1.4.1 -SPCOMP_DARWIN=env/darwin/bin/spcomp-1.4.1 +SPCOMP_LINUX=env/linux/bin/spcomp-1.6.0 +SPCOMP_DARWIN=env/darwin/bin/spcomp-1.6.0 DOS2UNIX_LINUX=dos2unix -p DOS2UNIX_DARWIN=env/darwin/bin/dos2unix -p VERSIONDUMP=./updateversion.sh diff --git a/compile.bat b/compile.bat index 769c6ee..fecb379 100644 --- a/compile.bat +++ b/compile.bat @@ -1,25 +1,25 @@ -@echo off - -set SOURCEDIR=src -set SMINCLUDES=env\include -set BUILDDIR=build -set SPCOMP=env\win32\bin\spcomp-1.4.1.exe -set VERSIONDUMP=updateversion.bat - -:: Dump version and revision information first. -echo Updating version and revision info... -start /wait %VERSIONDUMP% - -:: Make build directory. -if not exist "%BUILDDIR%" ( - mkdir %BUILDDIR% -) - -:: Compile. -echo Starting compiler: -%SPCOMP% -i%SOURCEDIR% -i%SOURCEDIR%/include -i%SMINCLUDES% -o%BUILDDIR%/zombiereloaded.smx %SOURCEDIR%\zombiereloaded.sp - -echo Compiling done. This script is looped, close if you're done. -pause - -compile.bat +@echo off + +set SOURCEDIR=src +set SMINCLUDES=env\include +set BUILDDIR=build +set SPCOMP=env\win32\bin\spcomp-1.6.0.exe +set VERSIONDUMP=updateversion.bat + +:: Dump version and revision information first. +echo Updating version and revision info... +start /wait %VERSIONDUMP% + +:: Make build directory. +if not exist "%BUILDDIR%" ( + mkdir %BUILDDIR% +) + +:: Compile. +echo Starting compiler: +%SPCOMP% -i%SOURCEDIR% -i%SOURCEDIR%/include -i%SMINCLUDES% -o%BUILDDIR%/zombiereloaded.smx %SOURCEDIR%\zombiereloaded.sp + +echo Compiling done. This script is looped, close if you're done. +pause + +compile.bat diff --git a/env/darwin/bin/spcomp-1.6.0 b/env/darwin/bin/spcomp-1.6.0 new file mode 100755 index 0000000..02df00e Binary files /dev/null and b/env/darwin/bin/spcomp-1.6.0 differ diff --git a/env/include/admin.inc b/env/include/admin.inc index 0278156..40c5907 100644 --- a/env/include/admin.inc +++ b/env/include/admin.inc @@ -138,7 +138,7 @@ enum ImmunityType */ enum GroupId { - INVALID_GROUP_ID = -1, /**< An invalid/nonexistant group */ + INVALID_GROUP_ID = -1, /**< An invalid/non-existent group */ }; /** @@ -146,7 +146,7 @@ enum GroupId */ enum AdminId { - INVALID_ADMIN_ID = -1, /**< An invalid/nonexistant admin */ + INVALID_ADMIN_ID = -1, /**< An invalid/non-existent admin */ }; /** @@ -169,7 +169,7 @@ enum AdminCachePart }; /** - * Called when part of the cache which needs to be rebuilt. + * Called when part of the cache needs to be rebuilt. * * @param part Part of the admin cache to rebuild. */ @@ -324,7 +324,7 @@ native bool:GetAdmGroupCmdOverride(GroupId:id, const String:name[], OverrideType * Registers an authentication identity type. You normally never need to call this except for * very specific systems. * - * @param codename Codename to use for your authentication type. + * @param name Codename to use for your authentication type. * @noreturn */ native RegisterAuthIdentType(const String:name[]); @@ -347,7 +347,7 @@ native AdminId:CreateAdmin(const String:name[]=""); * @param maxlength Maximum size of string buffer. * @return Number of bytes written. */ -native GetAdminUsername(AdminId:id, const String:name[], maxlength); +native GetAdminUsername(AdminId:id, String:name[], maxlength); /** * Binds an admin to an identity for fast lookup later on. The bind must be unique. @@ -425,7 +425,7 @@ native GroupId:GetAdminGroup(AdminId:id, index, const String:name[], maxlength); * Sets a password on an admin. * * @param id AdminId index of the admin. - * @param passwd String containing the password. + * @param password String containing the password. * @noreturn */ native SetAdminPassword(AdminId:id, const String:password[]); @@ -434,12 +434,12 @@ native SetAdminPassword(AdminId:id, const String:password[]); * Gets an admin's password. * * @param id AdminId index of the admin. - * @param name Optional buffer to store the admin's password. + * @param buffer Optional buffer to store the admin's password. * @param maxlength Maximum size of the output name buffer. * Note: This will safely chop UTF-8 strings. * @return True if there was a password set, false otherwise. */ -native bool:GetAdminPassword(AdminId:id, const String:buffer[]="", maxlength=0); +native bool:GetAdminPassword(AdminId:id, String:buffer[]="", maxlength=0); /** * Attempts to find an admin by an auth method and an identity. @@ -537,7 +537,7 @@ native ReadFlagString(const String:flags[], &numchars=0); /** * Tests whether one admin can target another. * - * The hueristics for this check are as follows: + * The heuristics for this check are as follows: * 0. If the targeting AdminId is INVALID_ADMIN_ID, targeting fails. * 1. If the targeted AdminId is INVALID_ADMIN_ID, targeting succeeds. * 2. If the targeted AdminId is the same as the targeting AdminId, diff --git a/env/include/adt_array.inc b/env/include/adt_array.inc index e8b81f6..798ae55 100644 --- a/env/include/adt_array.inc +++ b/env/include/adt_array.inc @@ -210,14 +210,14 @@ native SetArrayCell(Handle:array, index, any:value, block=0, bool:asChar=false); * @return Number of characters copied. * @error Invalid Handle or invalid index. */ -native SetArrayString(Handle:array, index, const String:buffer[]); +native SetArrayString(Handle:array, index, const String:value[]); /** * Sets an array of cells in an array. * * @param array Array Handle. * @param index Index in the array. - * @param buffer Array to copy. + * @param values Array to copy. * @param size If not set, assumes the buffer size is equal to the * blocksize. Otherwise, the size passed is used. * @return Number of cells copied. diff --git a/env/include/adt_trie.inc b/env/include/adt_trie.inc index 4de66fa..4e9f120 100644 --- a/env/include/adt_trie.inc +++ b/env/include/adt_trie.inc @@ -1,5 +1,5 @@ /** - * vim: set ts=4 : + * vim: set ts=4 sw=4 tw=99 noet : * ============================================================================= * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved. * ============================================================================= @@ -36,35 +36,37 @@ #define _adt_trie_included /** - * Creates a Trie structure. A trie is a data storage object that maps any value to a - * string of text. It features very fast lookup and deletion, but grows very slow for - * insertion once tens of thousands of items are added. + * Creates a hash map. A hash map is a container that can map strings (called + * "keys") to arbitrary values (cells, arrays, or strings). Keys in a hash map + * are unique. That is, there is at most one entry in the map for a given key. * - * Keys in Tries are unique. That is, each key may only have one value. Unlike arrays, - * Tries cannot be iterated right now. Since the contents are known to be unique, to - * work around this, you can use ADT Arrays to store a list of keys known to be in a - * Trie. + * Insertion, deletion, and lookup in a hash map are all considered to be fast + * operations, amortized to O(1), or constant time. * - * @return New Trie Handle, which must be freed via CloseHandle(). + * The word "Trie" in this API is historical. As of SourceMod 1.6, tries have + * been internally replaced with hash tables, which have O(1) insertion time + * instead of O(n). + * + * @return New Map Handle, which must be freed via CloseHandle(). */ native Handle:CreateTrie(); /** - * Sets a value in a Trie, either inserting a new entry or replacing an old one. + * Sets a value in a hash map, either inserting a new entry or replacing an old one. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. * @param value Value to store at this key. * @param replace If false, operation will fail if the key is already set. * @return True on success, false on failure. * @error Invalid Handle. */ -native bool:SetTrieValue(Handle:trie, const String:key[], any:value, bool:replace=true); +native bool:SetTrieValue(Handle:map, const String:key[], any:value, bool:replace=true); /** - * Sets an array value in a Trie, either inserting a new entry or replacing an old one. + * Sets an array value in a Map, either inserting a new entry or replacing an old one. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. * @param array Array to store. * @param num_items Number of items in the array. @@ -72,36 +74,36 @@ native bool:SetTrieValue(Handle:trie, const String:key[], any:value, bool:replac * @return True on success, false on failure. * @error Invalid Handle. */ -native bool:SetTrieArray(Handle:trie, const String:key[], const any:array[], num_items, bool:replace=true); +native bool:SetTrieArray(Handle:map, const String:key[], const any:array[], num_items, bool:replace=true); /** - * Sets a string value in a Trie, either inserting a new entry or replacing an old one. + * Sets a string value in a Map, either inserting a new entry or replacing an old one. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. * @param value String to store. * @param replace If false, operation will fail if the key is already set. * @return True on success, false on failure. * @error Invalid Handle. */ -native bool:SetTrieString(Handle:trie, const String:key[], const String:value[], bool:replace=true); +native bool:SetTrieString(Handle:map, const String:key[], const String:value[], bool:replace=true); /** - * Retrieves a value in a Trie. + * Retrieves a value in a Map. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. - * @param val Variable to store value. + * @param value Variable to store value. * @return True on success. False if the key is not set, or the key is set * as an array or string (not a value). * @error Invalid Handle. */ -native bool:GetTrieValue(Handle:trie, const String:key[], &any:value); +native bool:GetTrieValue(Handle:map, const String:key[], &any:value); /** - * Retrieves an array in a Trie. + * Retrieves an array in a Map. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. * @param array Buffer to store array. * @param max_size Maximum size of array buffer. @@ -110,12 +112,12 @@ native bool:GetTrieValue(Handle:trie, const String:key[], &any:value); * as a value or string (not an array). * @error Invalid Handle. */ -native bool:GetTrieArray(Handle:trie, const String:key[], any:array[], max_size, &size=0); +native bool:GetTrieArray(Handle:map, const String:key[], any:array[], max_size, &size=0); /** - * Retrieves a string in a Trie. + * Retrieves a string in a Map. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. * @param value Buffer to store value. * @param max_size Maximum size of string buffer. @@ -124,34 +126,31 @@ native bool:GetTrieArray(Handle:trie, const String:key[], any:array[], max_size, * as a value or array (not a string). * @error Invalid Handle. */ -native bool:GetTrieString(Handle:trie, const String:key[], String:value[], max_size, &size=0); +native bool:GetTrieString(Handle:map, const String:key[], String:value[], max_size, &size=0); /** - * Removes a key entry from a Trie. + * Removes a key entry from a Map. * - * @param trie Trie Handle. + * @param map Map Handle. * @param key Key string. * @return True on success, false if the value was never set. * @error Invalid Handle. */ -native RemoveFromTrie(Handle:trie, const String:key[]); +native RemoveFromTrie(Handle:map, const String:key[]); /** - * Clears all entries from a Trie. + * Clears all entries from a Map. * - * @param trie Trie Handle. + * @param map Map Handle. * @error Invalid Handle. */ -native ClearTrie(Handle:trie); +native ClearTrie(Handle:map); /** - * Retrieves the number of elements in a trie. + * Retrieves the number of elements in a map. * - * Note that trie items are not enumerable/iteratable. If you need to - * retrieve the elements in a trie, store its keys in an ADT Array. - * - * @param trie Trie Handle. + * @param map Map Handle. * @return Number of elements in the trie. * @error Invalid Handle. */ -native GetTrieSize(Handle:trie); +native GetTrieSize(Handle:map); diff --git a/env/include/basecomm.inc b/env/include/basecomm.inc index 8cfd319..832afbc 100644 --- a/env/include/basecomm.inc +++ b/env/include/basecomm.inc @@ -35,6 +35,22 @@ #endif #define _basecomm_included +/** + * Called when a client is muted or unmuted + * + * @param client Client index + * @param muteState True if client was muted, false otherwise + */ + forward BaseComm_OnClientMute(client, bool:muteState); + + /** + * Called when a client is gagged or ungagged + * + * @param client Client index + * @param gagState True if client was gaged, false otherwise + */ + forward BaseComm_OnClientGag(client, bool:gagState); + /** * Returns whether or not a client is gagged * diff --git a/env/include/clientprefs.inc b/env/include/clientprefs.inc index 2a78a11..c6ac023 100644 --- a/env/include/clientprefs.inc +++ b/env/include/clientprefs.inc @@ -162,8 +162,8 @@ forward OnClientCookiesCached(client); * Cookie Menu Callback prototype * * @param client Client index. - * @param action CookeMenuAction being performed. - * @param data Info data passed. + * @param action CookieMenuAction being performed. + * @param info Info data passed. * @param buffer Outbut buffer. * @param maxlen Max length of the output buffer. */ @@ -221,7 +221,6 @@ native Handle:GetCookieIterator(); * @param access Access level of the cookie. * @param desc Cookie description buffer. * @param descLen Cookie description buffer size. - * @param * @return True on success, false if there are no more commands. */ native bool:ReadCookieIterator(Handle:iter, diff --git a/env/include/clients.inc b/env/include/clients.inc index be1d5f0..13381c3 100644 --- a/env/include/clients.inc +++ b/env/include/clients.inc @@ -209,6 +209,21 @@ forward OnClientPostAdminCheck(client); */ native GetMaxClients(); +/** + * Returns the maximum number of human players allowed on the server. This is + * a game-specific function used on newer games to limit the number of humans + * that can join a game and can be lower than MaxClients. It is the number often + * reflected in the server browser or when viewing the output of the status command. + * On unsupported games or modes without overrides, it will return the same value + * as MaxClients. + * + * You should not globally cache the value to GetMaxHumanPlayers() because it can change across + * game modes. You may still cache it locally. + * + * @return Maximum number of humans allowed. + */ +native GetMaxHumanPlayers(); + /** * Returns the client count put in the server. * @@ -232,7 +247,7 @@ native bool:GetClientName(client, String:name[], maxlen); * Retrieves a client's IP address. * * @param client Player index. - * @param name Buffer to store the client's ip address. + * @param ip Buffer to store the client's ip address. * @param maxlen Maximum length of string buffer (includes NULL terminator). * @param remport Remove client's port from the ip string (true by default). * @return True on success, false otherwise. @@ -246,10 +261,25 @@ native bool:GetClientIP(client, String:ip[], maxlen, bool:remport=true); * @param client Player index. * @param auth Buffer to store the client's auth string. * @param maxlen Maximum length of string buffer (includes NULL terminator). + * @param validate Check backend validation status. + * DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES, + * You WILL KNOW if you need to use this, MOST WILL NOT. * @return True on success, false otherwise. * @error If the client is not connected or the index is invalid. */ -native bool:GetClientAuthString(client, String:auth[], maxlen); +native bool:GetClientAuthString(client, String:auth[], maxlen, bool:validate=true); + +/** + * Returns the client's Steam account ID. + * + * @param client Client Index. + * @param validate Check backend validation status. + * DO NOT PASS FALSE UNLESS YOU UNDERSTAND THE CONSEQUENCES, + * You WILL KNOW if you need to use this, MOST WILL NOT. + * @return Steam account ID or 0 if not available. + * @error If the client is not connected or the index is invalid. + */ +native GetSteamAccountID(client, bool:validate=true); /** * Retrieves a client's user id, which is an index incremented for every client @@ -590,7 +620,7 @@ native GetClientFrags(client); * * @param client Player's index. * @return Data rate. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native GetClientDataRate(client); @@ -599,7 +629,7 @@ native GetClientDataRate(client); * * @param client Player's index. * @return True if client is timing out, false otherwise. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native bool:IsClientTimingOut(client); @@ -608,7 +638,7 @@ native bool:IsClientTimingOut(client); * * @param client Player's index. * @return Connection time. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientTime(client); @@ -618,7 +648,7 @@ native Float:GetClientTime(client); * @param client Player's index. * @param flow Traffic flowing direction. * @return Latency, or -1 if network info is not available. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientLatency(client, NetFlow:flow); @@ -628,7 +658,7 @@ native Float:GetClientLatency(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Latency, or -1 if network info is not available. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgLatency(client, NetFlow:flow); @@ -638,7 +668,7 @@ native Float:GetClientAvgLatency(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Average packet loss, or -1 if network info is not available. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgLoss(client, NetFlow:flow); @@ -648,7 +678,7 @@ native Float:GetClientAvgLoss(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Average packet loss, or -1 if network info is not available. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgChoke(client, NetFlow:flow); @@ -658,7 +688,7 @@ native Float:GetClientAvgChoke(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Data flow. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgData(client, NetFlow:flow); @@ -668,7 +698,7 @@ native Float:GetClientAvgData(client, NetFlow:flow); * @param client Player's index. * @param flow Traffic flowing direction. * @return Packet frequency. - * @error Invalid client index, client not in game, or fake client. + * @error Invalid client index, client not connected, or fake client. */ native Float:GetClientAvgPackets(client, NetFlow:flow); @@ -733,6 +763,7 @@ native ChangeClientTeam(client, team); /** * Returns the clients unique serial identifier. * + * @param client Client index. * @return Serial number. */ native GetClientSerial(client); @@ -740,6 +771,7 @@ native GetClientSerial(client); /** * Returns the client index by its serial number. * + * @param serial Serial number. * @return Client index, or 0 for invalid serial. */ native GetClientFromSerial(serial); diff --git a/env/include/console.inc b/env/include/console.inc index 140a059..d89bcbc 100644 --- a/env/include/console.inc +++ b/env/include/console.inc @@ -160,7 +160,7 @@ native ServerExecute(); * * @param client Index of the client. * @param fmt Format of the client command. - * @param ... Format parameters/ + * @param ... Format parameters * @noreturn * @error Invalid client index, or client not connected. */ @@ -324,7 +324,7 @@ native FormatActivitySource(client, target, const String:namebuf[], maxlength); /** * Called when a server-only command is invoked. * - * @params args Number of arguments that were in the argument string. + * @param args Number of arguments that were in the argument string. * @return An Action value. Not handling the command * means that Source will report it as "not found." */ @@ -358,7 +358,7 @@ functag public Action:ConCmd(client, args); * Creates a console command, or hooks an already existing one. * * Console commands are case sensitive. However, if the command already exists in the game, - * the a client may enter the command in any case. SourceMod corrects for this automatically, + * a client may enter the command in any case. SourceMod corrects for this automatically, * and you should only hook the "real" version of the command. * * @param cmd Name of the command to hook or create. @@ -703,7 +703,7 @@ funcenum ConVarQueryFinished * Starts a query to retrieve the value of a client's console variable. * * @param client Player index. - * @param name Name of client convar to query. + * @param cvarName Name of client convar to query. * @param callback A function to use as a callback when the query has finished. * @param value Optional value to pass to the callback function. * @return A cookie that uniquely identifies the query. @@ -938,3 +938,34 @@ native bool:AddCommandListener(CommandListener:callback, const String:command[]= */ native RemoveCommandListener(CommandListener:callback, const String:command[]=""); +/** + * Returns true if the supplied command exists. + * + * @param command Command to find. + * @return True if command is found, false otherwise. + */ +stock bool:CommandExists(const String:command[]) +{ + return (GetCommandFlags(command) != INVALID_FCVAR_FLAGS); +} +/** + * Global listener for the chat commands. + * + * @param client Client index. + * @param command Command name. + * @param sArgs Chat argument string. + * + * @return An Action value. Returning Plugin_Handled bypasses the game function call. + Returning Plugin_Stop bypasses the post hook as well as the game function. + */ +forward Action:OnClientSayCommand(client, const String:command[], const String:sArgs[]); + +/** + * Global post listener for the chat commands. + * + * @param client Client index. + * @param command Command name. + * @param sArgs Chat argument string. + * + */ +forward OnClientSayCommand_Post(client, const String:command[], const String:sArgs[]); diff --git a/env/include/core.inc b/env/include/core.inc index 13ae42a..262e186 100644 --- a/env/include/core.inc +++ b/env/include/core.inc @@ -167,6 +167,67 @@ public __ext_core_SetNTVOptional() MarkNativeAsOptional("RequireFeature"); MarkNativeAsOptional("AddCommandListener"); MarkNativeAsOptional("RemoveCommandListener"); + + MarkNativeAsOptional("BfWriteBool"); + MarkNativeAsOptional("BfWriteByte"); + MarkNativeAsOptional("BfWriteChar"); + MarkNativeAsOptional("BfWriteShort"); + MarkNativeAsOptional("BfWriteWord"); + MarkNativeAsOptional("BfWriteNum"); + MarkNativeAsOptional("BfWriteFloat"); + MarkNativeAsOptional("BfWriteString"); + MarkNativeAsOptional("BfWriteEntity"); + MarkNativeAsOptional("BfWriteAngle"); + MarkNativeAsOptional("BfWriteCoord"); + MarkNativeAsOptional("BfWriteVecCoord"); + MarkNativeAsOptional("BfWriteVecNormal"); + MarkNativeAsOptional("BfWriteAngles"); + MarkNativeAsOptional("BfReadBool"); + MarkNativeAsOptional("BfReadByte"); + MarkNativeAsOptional("BfReadChar"); + MarkNativeAsOptional("BfReadShort"); + MarkNativeAsOptional("BfReadWord"); + MarkNativeAsOptional("BfReadNum"); + MarkNativeAsOptional("BfReadFloat"); + MarkNativeAsOptional("BfReadString"); + MarkNativeAsOptional("BfReadEntity"); + MarkNativeAsOptional("BfReadAngle"); + MarkNativeAsOptional("BfReadCoord"); + MarkNativeAsOptional("BfReadVecCoord"); + MarkNativeAsOptional("BfReadVecNormal"); + MarkNativeAsOptional("BfReadAngles"); + MarkNativeAsOptional("BfGetNumBytesLeft"); + + MarkNativeAsOptional("PbReadInt"); + MarkNativeAsOptional("PbReadFloat"); + MarkNativeAsOptional("PbReadBool"); + MarkNativeAsOptional("PbReadString"); + MarkNativeAsOptional("PbReadColor"); + MarkNativeAsOptional("PbReadAngle"); + MarkNativeAsOptional("PbReadVector"); + MarkNativeAsOptional("PbReadVector2D"); + MarkNativeAsOptional("PbGetRepeatedFieldCount"); + MarkNativeAsOptional("PbSetInt"); + MarkNativeAsOptional("PbSetFloat"); + MarkNativeAsOptional("PbSetBool"); + MarkNativeAsOptional("PbSetString"); + MarkNativeAsOptional("PbSetColor"); + MarkNativeAsOptional("PbSetAngle"); + MarkNativeAsOptional("PbSetVector"); + MarkNativeAsOptional("PbSetVector2D"); + MarkNativeAsOptional("PbAddInt"); + MarkNativeAsOptional("PbAddFloat"); + MarkNativeAsOptional("PbAddBool"); + MarkNativeAsOptional("PbAddString"); + MarkNativeAsOptional("PbAddColor"); + MarkNativeAsOptional("PbAddAngle"); + MarkNativeAsOptional("PbAddVector"); + MarkNativeAsOptional("PbAddVector2D"); + MarkNativeAsOptional("PbRemoveRepeatedFieldValue"); + MarkNativeAsOptional("PbReadMessage"); + MarkNativeAsOptional("PbReadRepeatedMessage"); + MarkNativeAsOptional("PbAddMessage"); + VerifyCoreVersion(); } diff --git a/env/include/cstrike.inc b/env/include/cstrike.inc index 2d82a14..45ccac0 100644 --- a/env/include/cstrike.inc +++ b/env/include/cstrike.inc @@ -42,66 +42,95 @@ #define CS_SLOT_PRIMARY 0 /**< Primary weapon slot. */ #define CS_SLOT_SECONDARY 1 /**< Secondary weapon slot. */ +#define CS_SLOT_KNIFE 2 /**< Knife slot. */ #define CS_SLOT_GRENADE 3 /**< Grenade slot (will only return one grenade). */ #define CS_SLOT_C4 4 /**< C4 slot. */ +#define CS_DMG_HEADSHOT (1 << 30) /**< Headshot */ + enum CSRoundEndReason { - CSRoundEnd_TargetBombed = 0, // Target Successfully Bombed! - CSRoundEnd_VIPEscaped, // The VIP has escaped! - CSRoundEnd_VIPKilled, // VIP has been assassinated! - CSRoundEnd_TerroristsEscaped, // The terrorists have escaped! - CSRoundEnd_CTStoppedEscape, // The CTs have prevented most of the terrorists from escaping! - CSRoundEnd_TerroristsStopped, // Escaping terrorists have all been neutralized! - CSRoundEnd_BombDefused, // The bomb has been defused! - CSRoundEnd_CTWin, // Counter-Terrorists Win! - CSRoundEnd_TerroristWin, // Terrorists Win! - CSRoundEnd_Draw, // Round Draw! - CSRoundEnd_HostagesRescued, // All Hostages have been rescued! - CSRoundEnd_TargetSaved, // Target has been saved! - CSRoundEnd_HostagesNotRescued, // Hostages have not been rescued! - CSRoundEnd_TerroristsNotEscaped, // Terrorists have not escaped! - CSRoundEnd_VIPNotEscaped, // VIP has not escaped! - CSRoundEnd_GameStart // Game Commencing! + CSRoundEnd_TargetBombed = 0, /**< Target Successfully Bombed! */ + CSRoundEnd_VIPEscaped, /**< The VIP has escaped! */ + CSRoundEnd_VIPKilled, /**< VIP has been assassinated! */ + CSRoundEnd_TerroristsEscaped, /**< The terrorists have escaped! */ + CSRoundEnd_CTStoppedEscape, /**< The CTs have prevented most of the terrorists from escaping! */ + CSRoundEnd_TerroristsStopped, /**< Escaping terrorists have all been neutralized! */ + CSRoundEnd_BombDefused, /**< The bomb has been defused! */ + CSRoundEnd_CTWin, /**< Counter-Terrorists Win! */ + CSRoundEnd_TerroristWin, /**< Terrorists Win! */ + CSRoundEnd_Draw, /**< Round Draw! */ + CSRoundEnd_HostagesRescued, /**< All Hostages have been rescued! */ + CSRoundEnd_TargetSaved, /**< Target has been saved! */ + CSRoundEnd_HostagesNotRescued, /**< Hostages have not been rescued! */ + CSRoundEnd_TerroristsNotEscaped, /**< Terrorists have not escaped! */ + CSRoundEnd_VIPNotEscaped, /**< VIP has not escaped! */ + CSRoundEnd_GameStart, /**< Game Commencing! */ + + // The below only exist on CS:GO + CSRoundEnd_TerroristsSurrender, /**< Terrorists Surrender */ + CSRoundEnd_CTSurrender, /**< CTs Surrender */ }; enum CSWeaponID { - CSWeapon_NONE, - CSWeapon_P228, - CSWeapon_GLOCK, - CSWeapon_SCOUT, - CSWeapon_HEGRENADE, - CSWeapon_XM1014, - CSWeapon_C4, - CSWeapon_MAC10, - CSWeapon_AUG, - CSWeapon_SMOKEGRENADE, - CSWeapon_ELITE, - CSWeapon_FIVESEVEN, - CSWeapon_UMP45, - CSWeapon_SG550, - CSWeapon_GALIL, - CSWeapon_FAMAS, - CSWeapon_USP, - CSWeapon_AWP, - CSWeapon_MP5NAVY, - CSWeapon_M249, - CSWeapon_M3, - CSWeapon_M4A1, - CSWeapon_TMP, - CSWeapon_G3SG1, - CSWeapon_FLASHBANG, - CSWeapon_DEAGLE, - CSWeapon_SG552, - CSWeapon_AK47, - CSWeapon_KNIFE, - CSWeapon_P90, - CSWeapon_SHIELD, - CSWeapon_KEVLAR, - CSWeapon_ASSAULTSUIT, - CSWeapon_NIGHTVISION + CSWeapon_NONE = 0, + CSWeapon_P228, + CSWeapon_GLOCK, + CSWeapon_SCOUT, + CSWeapon_HEGRENADE, + CSWeapon_XM1014, + CSWeapon_C4, + CSWeapon_MAC10, + CSWeapon_AUG, + CSWeapon_SMOKEGRENADE, + CSWeapon_ELITE, + CSWeapon_FIVESEVEN, + CSWeapon_UMP45, + CSWeapon_SG550, + CSWeapon_GALIL, + CSWeapon_FAMAS, + CSWeapon_USP, + CSWeapon_AWP, + CSWeapon_MP5NAVY, + CSWeapon_M249, + CSWeapon_M3, + CSWeapon_M4A1, + CSWeapon_TMP, + CSWeapon_G3SG1, + CSWeapon_FLASHBANG, + CSWeapon_DEAGLE, + CSWeapon_SG552, + CSWeapon_AK47, + CSWeapon_KNIFE, + CSWeapon_P90, + CSWeapon_SHIELD, + CSWeapon_KEVLAR, + CSWeapon_ASSAULTSUIT, + CSWeapon_NIGHTVISION, + CSWeapon_GALILAR, + CSWeapon_BIZON, + CSWeapon_MAG7, + CSWeapon_NEGEV, + CSWeapon_SAWEDOFF, + CSWeapon_TEC9, + CSWeapon_TASER, + CSWeapon_HKP2000, + CSWeapon_MP7, + CSWeapon_MP9, + CSWeapon_NOVA, + CSWeapon_P250, + CSWeapon_SCAR17, + CSWeapon_SCAR20, + CSWeapon_SG556, + CSWeapon_SSG08, + CSWeapon_KNIFE_GG, + CSWeapon_MOLOTOV, + CSWeapon_DECOY, + CSWeapon_INCGRENADE, + CSWeapon_DEFUSER }; + /** * Called when a player attempts to purchase an item. * Return Plugin_Continue to allow the purchase or return a @@ -118,7 +147,7 @@ forward Action:CS_OnBuyCommand(client, const String:weapon[]); * higher action to deny. * * @param client Client index - * @param weapon Weapon index + * @param weaponIndex Weapon index */ forward Action:CS_OnCSWeaponDrop(client, weaponIndex); @@ -236,7 +265,120 @@ native CS_GetClientClanTag(client, String:buffer[], size); * @error Invalid client. */ native CS_SetClientClanTag(client, const String:tag[]); - + +/** + * Gets a team's score + * @param team Team index to get score for. + * @return Returns the internal team score. + * + * @error Invalid team index. + */ +native CS_GetTeamScore(team); + +/** + * Sets a team's score + * @param team Team index to set score for. + * @param value Value to set teams score as. + * @noreturn + * + * @error Invalid team index. + * @note This will update the scoreboard only after the scoreboard update function is called. Use SetTeamScore plus this to update the scoreboard instantly and save values correctly. + */ +native CS_SetTeamScore(team, value); + +/** + * Gets a client's mvp count + * @param client Client index to get mvp count of. + * @return Returns the client's internal MVP count. + * + * @error Invalid client. + */ +native CS_GetMVPCount(client); + +/** + * Sets a client's mvp count + * @param client Client index to set mvp count for. + * @param value Value to set client's mvp count as. + * @noreturn + * + * @error Invalid client. + */ +native CS_SetMVPCount(client, value); + +/** + * Gets a client's contribution score (CS:GO only) + * @param client Client index to get score of. + * @return Returns the client's score. + * + * @error Invalid client. + */ +native CS_GetClientContributionScore(client); + +/** + * Sets a client's contribution score (CS:GO only) + * @param client Client index to set score for. + * @param value Value to set client's score as. + * @noreturn + * + * @error Invalid client. + */ +native CS_SetClientContributionScore(client, value); + +/** + * Gets a client's assists (CS:GO only) + * @param client Client index to get assists of. + * @return Returns the client's assists. + * + * @error Invalid client. + */ +native CS_GetClientAssists(client); + +/** + * Sets a client's assists (CS:GO only) + * @param client Client index to set assists for. + * @param value Value to set client's assists as. + * @noreturn + * + * @error Invalid client. + */ +native CS_SetClientAssists(client, value); + +/** + * Gets a weaponID from a alias + * @param alias Weapon alias to attempt to get an id for. + * @return Returns a weapon id or 0 if failed to find a match. + * + * @note For best results use CS_GetTranslatedWeaponAlias on the weapon name before passing it. + */ +native CSWeaponID:CS_AliasToWeaponID(const String:alias[]); + +/** + * Gets a alias from a weaponID + * @param weaponID WeaponID to get alias for. + * @param destination Destination string to hold the weapon alias. + * @param len Length of the destination array. + * @return Returns number of cells written. + */ +native CS_WeaponIDToAlias(CSWeaponID:weaponID, String:destination[], len); + +/** + * Returns weather a WeaponID is valid on the current mod (css or csgo) + * @param weaponID WeaponID to check + * @return Returns true if its a valid WeaponID false otherwise. + * + * @note This will return false always for CSWeapon_NONE + */ +native bool:CS_IsValidWeaponID(CSWeaponID:id); + +/** + * Sets a player's model based on their current class + * + * @param client Player's index. + * @noreturn + * @error Invalid client index, client not in game. + */ +native CS_UpdateClientModel(client); + /** * Do not edit below this line! */ @@ -263,6 +405,18 @@ public __ext_cstrike_SetNTVOptional() MarkNativeAsOptional("CS_GetWeaponPrice"); MarkNativeAsOptional("CS_GetClientClanTag"); MarkNativeAsOptional("CS_SetClientClanTag"); + MarkNativeAsOptional("CS_GetTeamScore"); + MarkNativeAsOptional("CS_SetTeamScore"); + MarkNativeAsOptional("CS_GetMVPCount"); + MarkNativeAsOptional("CS_SetMVPCount"); + MarkNativeAsOptional("CS_GetClientContributionScore"); + MarkNativeAsOptional("CS_SetClientContributionScore"); + MarkNativeAsOptional("CS_GetClientAssists"); + MarkNativeAsOptional("CS_SetClientAssists"); + MarkNativeAsOptional("CS_AliasToWeaponID"); + MarkNativeAsOptional("CS_WeaponIDToAlias"); + MarkNativeAsOptional("CS_IsValidWeaponID"); + MarkNativeAsOptional("CS_UpdateClientModel"); } #endif diff --git a/env/include/datapack.inc b/env/include/datapack.inc index 4ad8eb4..ce3d8b7 100644 --- a/env/include/datapack.inc +++ b/env/include/datapack.inc @@ -50,7 +50,7 @@ native Handle:CreateDataPack(); * @noreturn * @error Invalid handle. */ -native WritePackCell(Handle:pack, cell); +native WritePackCell(Handle:pack, any:cell); /** * Packs a float into a data pack. @@ -79,7 +79,7 @@ native WritePackString(Handle:pack, const String:str[]); * @return Cell value. * @error Invalid handle, or bounds error. */ -native ReadPackCell(Handle:pack); +native any:ReadPackCell(Handle:pack); /** * Reads a float from a data pack. diff --git a/env/include/dbi.inc b/env/include/dbi.inc index 175d1c6..bbb1d6e 100644 --- a/env/include/dbi.inc +++ b/env/include/dbi.inc @@ -137,6 +137,8 @@ stock Handle:SQL_DefConnect(String:error[], maxlength, bool:persistent=true) * @param keyvalues Key/value pairs from a KeyValues handle, describing the connection. * @param error Error buffer. * @param maxlength Maximum length of the error buffer. + * @param persistent True to re-use a previous persistent connection if + * possible, false otherwise. * @return A database connection Handle, or INVALID_HANDLE on failure. * On failure the error buffer will be filled with a message. * @error Invalid KeyValues handle. @@ -249,6 +251,18 @@ native SQL_GetDriverIdent(Handle:driver, String:ident[], maxlength); */ native SQL_GetDriverProduct(Handle:driver, String:product[], maxlength); +/** + * Sets the character set of the current connection. + * Like SET NAMES .. in mysql, but stays after connection problems. + * + * Example: "utf8", "latin1" + * + * @param database Database Handle. + * @param characterset The character set string to change to. + * @return True, if character set was changed, false otherwise. + */ +native bool:SQL_SetCharset(Handle:database, const String:charset[]); + /** * Returns the number of affected rows from the last query. * @@ -292,7 +306,7 @@ native bool:SQL_GetError(Handle:hndl, String:error[], maxlength); * encloses the string in ''. While drivers tend to allow " instead, the string * may be not be escaped (for example, on SQLite)! * - * @param hndl A database Handle. + * @param database A database Handle. * @param string String to quote. * @param buffer Buffer to store quoted string in. * @param maxlength Maximum length of the buffer. @@ -557,7 +571,7 @@ native SQL_BindParamInt(Handle:statement, param, number, bool:signed=true); * * @param statement A statement (prepared query) Handle. * @param param The parameter index (starting from 0). - * @param float The float number to bind. + * @param value The float number to bind. * @noreturn * @error Invalid statement Handle or parameter index, or * SQL error. @@ -621,7 +635,7 @@ native SQL_UnlockDatabase(Handle:database); /** * General callback for threaded SQL stuff. * - * @param db Parent object of the Handle (or INVALID_HANDLE if none). + * @param owner Parent object of the Handle (or INVALID_HANDLE if none). * @param hndl Handle to the child object (or INVALID_HANDLE if none). * @param error Error string if there was an error. The error could be * empty even if an error condition exists, so it is important @@ -654,6 +668,7 @@ native bool:SQL_IsSameConnection(Handle:hndl1, Handle:hndl2); * @param callback Callback; new Handle will be in hndl, owner is the driver. * If no driver was found, the owner is INVALID_HANDLE. * @param name Database name. + * @param data Extra data value to pass to the callback. * @noreturn */ native SQL_TConnect(SQLTCallback:callback, const String:name[]="default", any:data=0); @@ -679,3 +694,69 @@ native SQL_TConnect(SQLTCallback:callback, const String:name[]="default", any:da * @error Invalid database Handle. */ native SQL_TQuery(Handle:database, SQLTCallback:callback, const String:query[], any:data=0, DBPriority:prio=DBPrio_Normal); + +/** + * Creates a new transaction object. A transaction object is a list of queries + * that can be sent to the database thread and executed as a single transaction. + * + * @return A transaction handle. + */ +native Handle:SQL_CreateTransaction(); + +/** + * Adds a query to a transaction object. + * + * @param txn A transaction handle. + * @param query Query string. + * @param data Extra data value to pass to the final callback. + * @return The index of the query in the transaction's query list. + * @error Invalid transaction handle. + */ +native SQL_AddQuery(Handle:txn, const String:query[], any:data=0); + +/** + * Callback for a successful transaction. + * + * @param db Database handle. + * @param data Data value passed to SQL_ExecuteTransaction(). + * @param numQueries Number of queries executed in the transaction. + * @param results An array of Query handle results, one for each of numQueries. They are closed automatically. + * @param queryData An array of each data value passed to SQL_AddQuery(). + * @noreturn + */ +functag public SQLTxnSuccess(Handle:db, any:data, numQueries, Handle:results[], any:queryData[]); + +/** + * Callback for a failed transaction. + * + * @param db Database handle. + * @param data Data value passed to SQL_ExecuteTransaction(). + * @param numQueries Number of queries executed in the transaction. + * @param error Error message. + * @param failIndex Index of the query that failed, or -1 if something else. + * @param queryData An array of each data value passed to SQL_AddQuery(). + * @noreturn + */ +functag public SQLTxnFailure(Handle:db, any:data, numQueries, const String:error[], failIndex, any:queryData[]); + +/** + * Sends a transaction to the database thread. The transaction handle is + * automatically closed. When the transaction completes, the optional + * callback is invoked. + * + * @param db A database handle. + * @param txn A transaction handle. + * @param onSuccess An optional callback to receive a successful transaction. + * @param onError An optional callback to receive an error message. + * @param data An optional value to pass to callbacks. + * @param prio Priority queue to use. + * @noreturn + * @error An invalid handle. + */ +native SQL_ExecuteTransaction( + Handle:db, + Handle:txn, + SQLTxnSuccess:onSuccess=SQLTxnSuccess:-1, + SQLTxnFailure:onError=SQLTxnFailure:-1, + any:data=0, + DBPriority:priority=DBPrio_Normal); diff --git a/env/include/entity.inc b/env/include/entity.inc index 6fb8d7c..d33a3b8 100644 --- a/env/include/entity.inc +++ b/env/include/entity.inc @@ -226,6 +226,7 @@ native GetEntData(entity, offset, size=4); * * @param entity Edict index. * @param offset Offset to use. + * @param value Value to set. * @param size Number of bytes to write (valid values are 1, 2, or 4). * @param changeState If true, change will be sent over the network. * @return Value at the given memory location. @@ -251,6 +252,7 @@ native Float:GetEntDataFloat(entity, offset); * * @param entity Edict index. * @param offset Offset to use. + * @param value Value to set. * @param changeState If true, change will be sent over the network. * @return Value at the given memory location. * @error Invalid entity or offset out of reasonable bounds. @@ -281,7 +283,7 @@ native GetEntDataEnt(entity, offset); * reasons explained in the notes. * * Note: This function uses 0 as an indicator to unset data, but - * 0 is also the world entity index. Thus, the a property cannot + * 0 is also the world entity index. Thus, a property cannot * be set to the world entity using this native. * * @param entity Edict index. @@ -447,6 +449,26 @@ native FindDataMapOffs(entity, const String:prop[], &PropFieldType:type=PropFieldType:0, &num_bits=0); + +/** + * Given an entity, finds a nested datamap property offset. + * This information is cached for future calls. + * + * @param entity Entity index. + * @param prop Property name. + * @param type Optional parameter to store the type. + * @param num_bits Optional parameter to store the number of bits the field + * uses. The bit count will either be 1 (for boolean) or + * divisible by 8 (including 0 if unknown). + * @param local_offset Optional parameter to store the local offset, as + * FindDataMapOffs() would return. + * @return An offset, or -1 on failure. + */ +native FindDataMapInfo(entity, + const String:prop[], + &PropFieldType:type=PropFieldType:0, + &num_bits=0, + &local_offset=0); /** * Wrapper function for finding a send property for a particular entity. @@ -691,12 +713,21 @@ stock SetEntDataArray(entity, offset, const array[], arraySize, dataSize=4, bool } } +/** + * Gets the memory address of an entity. + * + * @param entity Entity index. + * @return Address of the entity. + * @error Invalid entity. + */ +native Address:GetEntityAddress(entity); + /** * Retrieves the classname of an entity. * This is like GetEdictClassname(), except it works for ALL * entities, not just edicts. * - * @param edict Index of the entity. + * @param entity Index of the entity. * @param clsname Buffer to store the classname. * @param maxlength Maximum length of the buffer. * @return True on success, false if there is no classname set. diff --git a/env/include/entity_prop_stocks.inc b/env/include/entity_prop_stocks.inc index 91d7951..7f22b50 100644 --- a/env/include/entity_prop_stocks.inc +++ b/env/include/entity_prop_stocks.inc @@ -113,55 +113,56 @@ enum RenderFx #define IN_RELOAD (1 << 13) #define IN_ALT1 (1 << 14) #define IN_ALT2 (1 << 15) -#define IN_SCORE (1 << 16) // Used by client.dll for when scoreboard is held down -#define IN_SPEED (1 << 17) // Player is holding the speed key -#define IN_WALK (1 << 18) // Player holding walk key -#define IN_ZOOM (1 << 19) // Zoom key for HUD zoom -#define IN_WEAPON1 (1 << 20) // weapon defines these bits -#define IN_WEAPON2 (1 << 21) // weapon defines these bits +#define IN_SCORE (1 << 16) /**< Used by client.dll for when scoreboard is held down */ +#define IN_SPEED (1 << 17) /**< Player is holding the speed key */ +#define IN_WALK (1 << 18) /**< Player holding walk key */ +#define IN_ZOOM (1 << 19) /**< Zoom key for HUD zoom */ +#define IN_WEAPON1 (1 << 20) /**< weapon defines these bits */ +#define IN_WEAPON2 (1 << 21) /**< weapon defines these bits */ #define IN_BULLRUSH (1 << 22) -#define IN_GRENADE1 (1 << 23) // grenade 1 -#define IN_GRENADE2 (1 << 24) // grenade 2 +#define IN_GRENADE1 (1 << 23) /**< grenade 1 */ +#define IN_GRENADE2 (1 << 24) /**< grenade 2 */ +#define IN_ATTACK3 (1 << 25) // Note: these are only for use with GetEntityFlags and SetEntityFlags // and may not match the game's actual, internal m_fFlags values. // PLAYER SPECIFIC FLAGS FIRST BECAUSE WE USE ONLY A FEW BITS OF NETWORK PRECISION -#define FL_ONGROUND (1 << 0) // At rest / on the ground -#define FL_DUCKING (1 << 1) // Player flag -- Player is fully crouched -#define FL_WATERJUMP (1 << 2) // player jumping out of water -#define FL_ONTRAIN (1 << 3) // Player is _controlling_ a train, so movement commands should be ignored on client during prediction. -#define FL_INRAIN (1 << 4) // Indicates the entity is standing in rain -#define FL_FROZEN (1 << 5) // Player is frozen for 3rd person camera -#define FL_ATCONTROLS (1 << 6) // Player can't move, but keeps key inputs for controlling another entity -#define FL_CLIENT (1 << 7) // Is a player -#define FL_FAKECLIENT (1 << 8) // Fake client, simulated server side; don't send network messages to them +#define FL_ONGROUND (1 << 0) /**< At rest / on the ground */ +#define FL_DUCKING (1 << 1) /**< Player flag -- Player is fully crouched */ +#define FL_WATERJUMP (1 << 2) /**< player jumping out of water */ +#define FL_ONTRAIN (1 << 3) /**< Player is _controlling_ a train, so movement commands should be ignored on client during prediction. */ +#define FL_INRAIN (1 << 4) /**< Indicates the entity is standing in rain */ +#define FL_FROZEN (1 << 5) /**< Player is frozen for 3rd person camera */ +#define FL_ATCONTROLS (1 << 6) /**< Player can't move, but keeps key inputs for controlling another entity */ +#define FL_CLIENT (1 << 7) /**< Is a player */ +#define FL_FAKECLIENT (1 << 8) /**< Fake client, simulated server side; don't send network messages to them */ // NOTE if you move things up, make sure to change this value #define PLAYER_FLAG_BITS 9 // NON-PLAYER SPECIFIC (i.e., not used by GameMovement or the client .dll ) -- Can still be applied to players, though -#define FL_INWATER (1 << 9) // In water -#define FL_FLY (1 << 10) // Changes the SV_Movestep() behavior to not need to be on ground -#define FL_SWIM (1 << 11) // Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) +#define FL_INWATER (1 << 9) /**< In water */ +#define FL_FLY (1 << 10) /**< Changes the SV_Movestep() behavior to not need to be on ground */ +#define FL_SWIM (1 << 11) /**< Changes the SV_Movestep() behavior to not need to be on ground (but stay in water) */ #define FL_CONVEYOR (1 << 12) #define FL_NPC (1 << 13) #define FL_GODMODE (1 << 14) #define FL_NOTARGET (1 << 15) -#define FL_AIMTARGET (1 << 16) // set if the crosshair needs to aim onto the entity -#define FL_PARTIALGROUND (1 << 17) // not all corners are valid -#define FL_STATICPROP (1 << 18) // Eetsa static prop! -#define FL_GRAPHED (1 << 19) // worldgraph has this ent listed as something that blocks a connection +#define FL_AIMTARGET (1 << 16) /**< set if the crosshair needs to aim onto the entity */ +#define FL_PARTIALGROUND (1 << 17) /**< not all corners are valid */ +#define FL_STATICPROP (1 << 18) /**< Eetsa static prop! */ +#define FL_GRAPHED (1 << 19) /**< worldgraph has this ent listed as something that blocks a connection */ #define FL_GRENADE (1 << 20) -#define FL_STEPMOVEMENT (1 << 21) // Changes the SV_Movestep() behavior to not do any processing -#define FL_DONTTOUCH (1 << 22) // Doesn't generate touch functions, generates Untouch() for anything it was touching when this flag was set -#define FL_BASEVELOCITY (1 << 23) // Base velocity has been applied this frame (used to convert base velocity into momentum) -#define FL_WORLDBRUSH (1 << 24) // Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) -#define FL_OBJECT (1 << 25) // Terrible name. This is an object that NPCs should see. Missiles, for example. -#define FL_KILLME (1 << 26) // This entity is marked for death -- will be freed by game DLL -#define FL_ONFIRE (1 << 27) // You know... -#define FL_DISSOLVING (1 << 28) // We're dissolving! -#define FL_TRANSRAGDOLL (1 << 29) // In the process of turning into a client side ragdoll. -#define FL_UNBLOCKABLE_BY_PLAYER (1 << 30) // pusher that can't be blocked by the player -#define FL_FREEZING (1 << 31) // We're becoming frozen! -#define FL_EP2V_UNKNOWN1 (1 << 31) // Unknown +#define FL_STEPMOVEMENT (1 << 21) /**< Changes the SV_Movestep() behavior to not do any processing */ +#define FL_DONTTOUCH (1 << 22) /**< Doesn't generate touch functions, generates Untouch() for anything it was touching when this flag was set */ +#define FL_BASEVELOCITY (1 << 23) /**< Base velocity has been applied this frame (used to convert base velocity into momentum) */ +#define FL_WORLDBRUSH (1 << 24) /**< Not moveable/removeable brush entity (really part of the world, but represented as an entity for transparency or something) */ +#define FL_OBJECT (1 << 25) /**< Terrible name. This is an object that NPCs should see. Missiles, for example. */ +#define FL_KILLME (1 << 26) /**< This entity is marked for death -- will be freed by game DLL */ +#define FL_ONFIRE (1 << 27) /**< You know... */ +#define FL_DISSOLVING (1 << 28) /**< We're dissolving! */ +#define FL_TRANSRAGDOLL (1 << 29) /**< In the process of turning into a client side ragdoll. */ +#define FL_UNBLOCKABLE_BY_PLAYER (1 << 30) /**< pusher that can't be blocked by the player */ +#define FL_FREEZING (1 << 31) /**< We're becoming frozen! */ +#define FL_EP2V_UNKNOWN1 (1 << 31) /**< Unknown */ // END entity flag #defines /** diff --git a/env/include/events.inc b/env/include/events.inc index 3308fe7..d7e8f4c 100644 --- a/env/include/events.inc +++ b/env/include/events.inc @@ -235,7 +235,7 @@ native SetEventString(Handle:event, const String:key[], const String:value[]); * Retrieves the name of a game event. * * @param event Handle to the event. - * @param value Buffer to store the name of the event. + * @param name Buffer to store the name of the event. * @param maxlength Maximum length of string buffer. * @noreturn * @error Invalid or corrupt Handle. diff --git a/env/include/files.inc b/env/include/files.inc index 8a4d2d2..f353deb 100644 --- a/env/include/files.inc +++ b/env/include/files.inc @@ -303,9 +303,9 @@ native FilePosition(Handle:file); * * @param path Path to the file. * @param use_valve_fs If true, the Valve file system will be used instead. - * This can be used to check for the existance of files - * inside GCFs or the game cache, rather than solely files - * that are on disk. + * This can be used to find files existing in any of + * the GAME search paths, rather than solely files + * existing directly in the gamedir. * @return True if the file exists, false otherwise. */ native bool:FileExists(const String:path[], bool:use_valve_fs=false); @@ -331,9 +331,13 @@ native bool:DirExists(const String:path[]); * Get the file size in bytes. * * @param path Path to the file. + * @param use_valve_fs If true, the Valve file system will be used instead. + * This can be used to find files existing in any of + * the GAME search paths, rather than solely files + * existing directly in the gamedir. * @return File size in bytes, -1 if file not found. */ -native FileSize(const String:path[]); +native FileSize(const String:path[], bool:use_valve_fs=false); /** * Flushes a file's buffered output; any buffered output diff --git a/env/include/float.inc b/env/include/float.inc index 73a5c3e..1282158 100644 --- a/env/include/float.inc +++ b/env/include/float.inc @@ -246,10 +246,25 @@ stock RoundFloat(Float:value) */ #pragma rational Float +native bool:__FLOAT_GT__(Float:a, Float:b); +native bool:__FLOAT_GE__(Float:a, Float:b); +native bool:__FLOAT_LT__(Float:a, Float:b); +native bool:__FLOAT_LE__(Float:a, Float:b); +native bool:__FLOAT_EQ__(Float:a, Float:b); +native bool:__FLOAT_NE__(Float:a, Float:b); +native bool:__FLOAT_NOT__(Float:a); + native Float:operator*(Float:oper1, Float:oper2) = FloatMul; native Float:operator/(Float:oper1, Float:oper2) = FloatDiv; native Float:operator+(Float:oper1, Float:oper2) = FloatAdd; native Float:operator-(Float:oper1, Float:oper2) = FloatSub; +native bool:operator!(Float:oper1) = __FLOAT_NOT__; +native bool:operator>(Float:oper1, Float:oper2) = __FLOAT_GT__; +native bool:operator>=(Float:oper1, Float:oper2) = __FLOAT_GE__; +native bool:operator<(Float:oper1, Float:oper2) = __FLOAT_LT__; +native bool:operator<=(Float:oper1, Float:oper2) = __FLOAT_LE__; +native bool:operator!=(Float:oper1, Float:oper2) = __FLOAT_NE__; +native bool:operator==(Float:oper1, Float:oper2) = __FLOAT_EQ__; stock Float:operator++(Float:oper) { @@ -263,7 +278,7 @@ stock Float:operator--(Float:oper) stock Float:operator-(Float:oper) { - return oper^Float:((-1)^((-1)/2)); /* IEEE values are sign/magnitude */ + return oper^Float:cellmin; /* IEEE values are sign/magnitude */ } stock Float:operator*(Float:oper1, oper2) @@ -296,90 +311,54 @@ stock Float:operator-(oper1, Float:oper2) return FloatSub(float(oper1), oper2); } -stock bool:operator==(Float:oper1, Float:oper2) -{ - return FloatCompare(oper1, oper2) == 0; -} - stock bool:operator==(Float:oper1, oper2) { - return FloatCompare(oper1, float(oper2)) == 0; /* "==" is commutative */ -} - -stock bool:operator!=(Float:oper1, Float:oper2) -{ - return FloatCompare(oper1, oper2) != 0; + return __FLOAT_EQ__(oper1, float(oper2)); } stock bool:operator!=(Float:oper1, oper2) { - return FloatCompare(oper1, float(oper2)) != 0; /* "==" is commutative */ -} - -stock bool:operator>(Float:oper1, Float:oper2) -{ - return FloatCompare(oper1, oper2) > 0; + return __FLOAT_NE__(oper1, float(oper2)); } stock bool:operator>(Float:oper1, oper2) { - return FloatCompare(oper1, float(oper2)) > 0; + return __FLOAT_GT__(oper1, float(oper2)); } stock bool:operator>(oper1, Float:oper2) { - return FloatCompare(float(oper1), oper2) > 0; -} - -stock bool:operator>=(Float:oper1, Float:oper2) -{ - return FloatCompare(oper1, oper2) >= 0; + return __FLOAT_GT__(float(oper1), oper2); } stock bool:operator>=(Float:oper1, oper2) { - return FloatCompare(oper1, float(oper2)) >= 0; + return __FLOAT_GE__(oper1, float(oper2)); } stock bool:operator>=(oper1, Float:oper2) { - return FloatCompare(float(oper1), oper2) >= 0; -} - -stock bool:operator<(Float:oper1, Float:oper2) -{ - return FloatCompare(oper1, oper2) < 0; + return __FLOAT_GE__(float(oper1), oper2); } stock bool:operator<(Float:oper1, oper2) { - return FloatCompare(oper1, float(oper2)) < 0; + return __FLOAT_LT__(oper1, float(oper2)); } stock bool:operator<(oper1, Float:oper2) { - return FloatCompare(float(oper1), oper2) < 0; -} - -stock bool:operator<=(Float:oper1, Float:oper2) -{ - return FloatCompare(oper1, oper2) <= 0; + return __FLOAT_LT__(float(oper1), oper2); } stock bool:operator<=(Float:oper1, oper2) { - return FloatCompare(oper1, float(oper2)) <= 0; + return __FLOAT_LE__(oper1, float(oper2)); } stock bool:operator<=(oper1, Float:oper2) { - return FloatCompare(float(oper1), oper2) <= 0; -} - -stock bool:operator!(Float:oper) -{ - return (_:oper & ((-1)/2)) == 0; /* -1 = all bits to 1; /2 = remove most significant bit (sign) - works on both 32bit and 64bit systems; no constant required */ + return __FLOAT_LE__(float(oper1), oper2); } /** diff --git a/env/include/functions.inc b/env/include/functions.inc index 1a6ddcb..105f1d2 100644 --- a/env/include/functions.inc +++ b/env/include/functions.inc @@ -492,3 +492,20 @@ native FormatNativeString(out_param, &written=0, String:out_string[]="", const String:fmt_string[]=""); + +/** + * Defines a RequestFrame Callback. + * + * @param data Data passed to the RequestFrame native. + * @noreturn + */ +functag public RequestFrameCallback(any:data); + +/** + * Creates a single use Next Frame hook. + * + * @param Function Function to call on the next frame. + * @param data Value to be passed on the invocation of the Function. + * @noreturn + */ +native RequestFrame(RequestFrameCallback:Function, any:data=0); diff --git a/env/include/geoip.inc b/env/include/geoip.inc index 725126e..3df697e 100644 --- a/env/include/geoip.inc +++ b/env/include/geoip.inc @@ -63,8 +63,8 @@ native bool:GeoipCode3(const String:ip[], String:ccode[4]); * Gets the full country name. (max length of output string is 45) * * @param ip Ip to determine the country code. - * @param ccode Destination string buffer to store the country name. - * @param len Maximum length of output string buffer. + * @param name Destination string buffer to store the country name. + * @param maxlength Maximum length of output string buffer. * @return True on success, false if no country found. */ native bool:GeoipCountry(const String:ip[], String:name[], maxlength); diff --git a/env/include/halflife.inc b/env/include/halflife.inc index 18294d9..c734e90 100644 --- a/env/include/halflife.inc +++ b/env/include/halflife.inc @@ -42,10 +42,13 @@ #define SOURCE_SDK_EPISODE2 30 /**< SDK+Engine released after Episode 2/Orange Box */ #define SOURCE_SDK_BLOODYGOODTIME 32 /**< Modified version of ep2 engine used by Bloody Good Time (no SDK) */ #define SOURCE_SDK_EYE 33 /**< Modified version of ep2 engine used by E.Y.E Divine Cybermancy (no SDK) */ -#define SOURCE_SDK_EPISODE2VALVE 35 /**< SDK+Engine released after Episode 2/Orange Box */ +#define SOURCE_SDK_CSS 34 /**< Sometime-older version of Source 2009 SDK+Engine, used for Counter-Strike: Source */ +#define SOURCE_SDK_EPISODE2VALVE 35 /**< SDK+Engine released after Episode 2/Orange Box, "Source 2009" or "Source MP" */ #define SOURCE_SDK_LEFT4DEAD 40 /**< Engine released after Left 4 Dead (no SDK yet) */ #define SOURCE_SDK_LEFT4DEAD2 50 /**< Engine released after Left 4 Dead 2 (no SDK yet) */ #define SOURCE_SDK_ALIENSWARM 60 /**< SDK+Engine released after Alien Swarm */ +#define SOURCE_SDK_CSGO 80 /**< Engine released after CS:GO (no SDK yet) */ +#define SOURCE_SDK_DOTA 90 /**< Engine released after Dota 2 (no SDK) */ #define MOTDPANEL_TYPE_TEXT 0 /**< Treat msg as plain text */ #define MOTDPANEL_TYPE_INDEX 1 /**< Msg is auto determined by the engine */ @@ -61,6 +64,32 @@ enum DialogType DialogType_AskConnect /**< ask the client to connect to a specified IP */ }; +enum EngineVersion +{ + Engine_Unknown, /**< Could not determine the engine version */ + Engine_Original, /**< Original Source Engine (used by The Ship) */ + Engine_SourceSDK2006, /**< Episode 1 Source Engine (second major SDK) */ + Engine_SourceSDK2007, /**< Orange Box Source Engine (third major SDK) */ + Engine_Left4Dead, /**< Left 4 Dead */ + Engine_DarkMessiah, /**< Dark Messiah Multiplayer (based on original engine) */ + Engine_Left4Dead2 = 7, /**< Left 4 Dead 2 */ + Engine_AlienSwarm, /**< Alien Swarm (and Alien Swarm SDK) */ + Engine_BloodyGoodTime, /**< Bloody Good Time */ + Engine_EYE, /**< E.Y.E Divine Cybermancy */ + Engine_Portal2, /**< Portal 2 */ + Engine_CSGO, /**< Counter-Strike: Global Offensive */ + Engine_CSS, /**< Counter-Strike: Source */ + Engine_DOTA, /**< Dota 2 */ + Engine_HL2DM, /**< Half-Life 2 Deathmatch */ + Engine_DODS, /**< Day of Defeat: Source */ + Engine_TF2, /**< Team Fortress 2 */ + Engine_NuclearDawn, /**< Nuclear Dawn */ + Engine_SDK2013, /**< Source SDK 2013 */ + Engine_Blade, /**< Blade Symphony */ + Engine_Insurgency, /**< Insurgency (2013 Retail version)*/ + Engine_Contagion, /**< Contagion */ +}; + #define INVALID_ENT_REFERENCE 0xFFFFFFFF /** @@ -101,7 +130,7 @@ native GetRandomInt(nmin, nmax); /** * Returns whether a map is valid or not. * - * @param Map name, excluding .bsp extension. + * @param map Map name, excluding .bsp extension. * @return True if valid, false otherwise. */ native bool:IsMapValid(const String:map[]); @@ -127,6 +156,13 @@ native Float:GetEngineTime(); */ native Float:GetGameTime(); +/** + * Returns the game's internal tick count. + * + * @return Game tick count. + */ +native GetGameTickCount(); + /** * Returns the game description from the mod. * @@ -212,7 +248,7 @@ native bool:IsDecalPrecached(const String:decal[]); /** * Returns if a given generic file is precached. * - * @param decal Name of the generic file to check. + * @param generic Name of the generic file to check. * @return True if precached, false otherwise. */ native bool:IsGenericPrecached(const String:generic[]); @@ -254,8 +290,19 @@ native CreateDialog(client, Handle:kv, DialogType:type); * * @return SOURCE_SDK version code. */ +#pragma deprecated See GetEngineVersion() native GuessSDKVersion(); +/** + * Gets the engine version that the currently-loaded SM core was compiled against. + * + * The engine version values are not guaranteed to be in any particular order, + * and should only be compared by (in)equality. + * + * @return An EngineVersion value. + */ +native EngineVersion:GetEngineVersion(); + /** * Prints a message to a specific client in the chat area. * @@ -537,14 +584,17 @@ stock ShowMOTDPanel(client, const String:title[], const String:msg[], type=MOTDP * * @param client Client index. * @param time Duration to hold the panel on the client's screen. - * @param ip Destionation IP. + * @param ip Destination IP. + * @param password Password to connect to the destination IP. The client will be able to see this. * @noreturn */ -stock DisplayAskConnectBox(client, Float:time, const String:ip[]) +stock DisplayAskConnectBox(client, Float:time, const String:ip[], const String:password[] = "") { + decl String:destination[288]; + FormatEx(destination, sizeof(destination), "%s/%s", ip, password); new Handle:Kv = CreateKeyValues("data"); KvSetFloat(Kv, "time", time); - KvSetString(Kv, "title", ip); + KvSetString(Kv, "title", destination); CreateDialog(client, Kv, DialogType_AskConnect); CloseHandle(Kv); } diff --git a/env/include/keyvalues.inc b/env/include/keyvalues.inc index a026b4f..51f6580 100644 --- a/env/include/keyvalues.inc +++ b/env/include/keyvalues.inc @@ -60,7 +60,7 @@ enum KvDataTypes * @param firstValue If firstKey is non-empty, specifies the first key's value. * @return A Handle to a new KeyValues structure. */ -native Handle:CreateKeyValues(const String:name[], const String:firstkey[]="", const String:firstValue[]=""); +native Handle:CreateKeyValues(const String:name[], const String:firstKey[]="", const String:firstValue[]=""); /** * Sets a string value of a KeyValues key. diff --git a/env/include/lang.inc b/env/include/lang.inc index 8d57f16..6ff4464 100644 --- a/env/include/lang.inc +++ b/env/include/lang.inc @@ -41,7 +41,7 @@ * Loads a translation file for the plugin calling this native. * If no extension is specified, .txt is assumed. * - * @param path Translation file. + * @param file Translation file. * @noreturn */ native LoadTranslations(const String:file[]); diff --git a/env/include/logging.inc b/env/include/logging.inc index 39028c6..4269b22 100644 --- a/env/include/logging.inc +++ b/env/include/logging.inc @@ -45,17 +45,6 @@ */ native LogMessage(const String:format[], any:...); -/** - * Logs a message to the SourceMod logs without any plugin logtag. This is - * useful for re-routing messages from other plugins, for example, messages - * from LogAction(). - * - * @param format String format. - * @param ... Format arguments. - * @noreturn - */ -native LogMessageEx(const String:format[], any:...); - /** * Logs a message to any file. The log message will be in the normal * SourceMod format, with the plugin logtag prepended. diff --git a/env/include/menus.inc b/env/include/menus.inc index 3d44aa8..fa6cbac 100644 --- a/env/include/menus.inc +++ b/env/include/menus.inc @@ -345,6 +345,7 @@ native GetMenuTitle(Handle:menu, String:buffer[], maxlength); * Creates a raw MenuPanel based off the menu's style. * The Handle must be freed with CloseHandle(). * + * @param menu Menu Handle. * @return A new MenuPanel Handle. * @error Invalid Handle. */ @@ -404,6 +405,16 @@ native bool:GetMenuExitBackButton(Handle:menu); */ native SetMenuExitBackButton(Handle:menu, bool:button); +/** + * Sets whether or not the menu has a "no vote" button in slot 1. + * By default, menus do not have a no vote button. + * + * @param menu Menu Handle. + * @param button True to enable the button, false to remove it. + * @return True if allowed; false on failure. + * @error Invalid Handle. + */ +native bool:SetMenuNoVoteButton(Handle:menu, bool:button); /** * Cancels a menu from displaying on all clients. While the @@ -489,14 +500,14 @@ native bool:VoteMenu(Handle:menu, clients[], numClients, time, flags=0); * in progress. * @error Invalid Handle. */ -stock VoteMenuToAll(Handle:menu, time, flags=0) +stock bool:VoteMenuToAll(Handle:menu, time, flags=0) { new total; decl players[MaxClients]; for (new i=1; i<=MaxClients; i++) { - if (!IsClientInGame(i)) + if (!IsClientInGame(i) || IsFakeClient(i)) { continue; } @@ -590,7 +601,7 @@ native Handle:CreatePanel(Handle:hStyle=INVALID_HANDLE); * Creates a Menu from a MenuStyle. The Handle must be closed with * CloseHandle(). * - * @parma hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. + * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param handler Function which will receive menu actions. * @param actions Optionally set which actions to receive. Select, * Cancel, and End will always be received regardless @@ -614,7 +625,7 @@ native MenuSource:GetClientMenu(client, Handle:hStyle=INVALID_HANDLE); /** * Cancels a menu on a client. This will only affect non-external menus. * - * @param hstyle MenuStyle Handle, or INVALID_HANDLE to use the default style. + * @param hStyle MenuStyle Handle, or INVALID_HANDLE to use the default style. * @param client Client index. * @param autoIgnore If true, no menus can be re-drawn on the client during * the cancellation process. @@ -644,7 +655,7 @@ native Handle:GetPanelStyle(Handle:panel); * Sets the panel's title. * * @param panel A MenuPanel Handle. - * @param title Text to set as the title. + * @param text Text to set as the title. * @param onlyIfEmpty If true, the title will only be set if no title is set. * @noreturn * @error Invalid Handle. @@ -691,6 +702,7 @@ native CanPanelDrawFlags(Handle:panel, style); * Sets the selectable key map of a panel. This is not supported by * all styles (only by Radio, as of this writing). * + * @param panel A MenuPanel Handle. * @param keys An integer where each bit N allows key * N+1 to be selected. If no keys are selectable, * then key 0 (bit 9) is automatically set. diff --git a/env/include/protobuf.inc b/env/include/protobuf.inc new file mode 100644 index 0000000..56f0bd9 --- /dev/null +++ b/env/include/protobuf.inc @@ -0,0 +1,368 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod (C)2013 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This file is part of the SourceMod/SourcePawn SDK. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#if defined _protobuf_included +#endinput +#endif +#define _protobuf_included + +#define PB_FIELD_NOT_REPEATED -1 + +/** + * Reads an int32, uint32, sint32, fixed32, sfixed32, or enum value from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param index Index into repeated field. + * @return Integer value read. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbReadInt(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED); + +/** + * Reads a float or downcasted double from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param index Index into repeated field. + * @return Float value read. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native Float:PbReadFloat(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED); + +/** + * Reads a bool from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param index Index into repeated field. + * @return Boolean value read. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native bool:PbReadBool(Handle:pb, const String:field[], index=PB_FIELD_NOT_REPEATED); + +/** + * Reads a string from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param buffer Destination string buffer. + * @param maxlength Maximum length of output string buffer. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbReadString(Handle:pb, const String:field[], String:buffer[], maxlength, index=PB_FIELD_NOT_REPEATED); + +/** + * Reads an RGBA color value from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param buffer Destination color buffer. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbReadColor(Handle:pb, const String:field[], buffer[4], index=PB_FIELD_NOT_REPEATED); + +/** + * Reads an XYZ angle value from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param buffer Destination angle buffer. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbReadAngle(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED); + +/** + * Reads an XYZ vector value from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param buffer Destination vector buffer. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbReadVector(Handle:pb, const String:field[], Float:buffer[3], index=PB_FIELD_NOT_REPEATED); + +/** + * Reads an XY vector value from a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param buffer Destination vector buffer. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbReadVector2D(Handle:pb, const String:field[], Float:buffer[2], index=PB_FIELD_NOT_REPEATED); + +/** + * Gets the number of elements in a repeated field of a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @return Number of elements in the field. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbGetRepeatedFieldCount(Handle:pb, const String:field[]); + +/** + * Sets an int32, uint32, sint32, fixed32, sfixed32, or enum value on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value Integer value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetInt(Handle:pb, const String:field[], value, index=PB_FIELD_NOT_REPEATED); + +/** + * Sets a float or double on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value Float value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetFloat(Handle:pb, const String:field[], Float:value, index=PB_FIELD_NOT_REPEATED); + +/** + * Sets a bool on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value Boolean value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetBool(Handle:pb, const String:field[], bool:value, index=PB_FIELD_NOT_REPEATED); + +/** + * Sets a string on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value String value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetString(Handle:pb, const String:field[], const String:value[], index=PB_FIELD_NOT_REPEATED); + +/** + * Sets an RGBA color on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param color Color value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetColor(Handle:pb, const String:field[], const color[4], index=PB_FIELD_NOT_REPEATED); + +/** + * Sets an XYZ angle on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param angle Angle value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetAngle(Handle:pb, const String:field[], const Float:angle[3], index=PB_FIELD_NOT_REPEATED); + +/** + * Sets an XYZ vector on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param vec Vector value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetVector(Handle:pb, const String:field[], const Float:vec[3], index=PB_FIELD_NOT_REPEATED); + +/** + * Sets an XY vector on a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @param vec Vector value to set. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbSetVector2D(Handle:pb, const String:field[], const Float:vec[2], index=PB_FIELD_NOT_REPEATED); + +/** + * Add an int32, uint32, sint32, fixed32, sfixed32, or enum value to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value Integer value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddInt(Handle:pb, const String:field[], value); + +/** + * Add a float or double to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value Float value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddFloat(Handle:pb, const String:field[], Float:value); + +/** + * Add a bool to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value Boolean value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddBool(Handle:pb, const String:field[], bool:value); + +/** + * Add a string to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param value String value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddString(Handle:pb, const String:field[], const String:value[]); + +/** + * Add an RGBA color to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param color Color value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddColor(Handle:pb, const String:field[], const color[4]); + +/** + * Add an XYZ angle to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param angle Angle value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddAngle(Handle:pb, const String:field[], const Float:angle[3]); + +/** + * Add an XYZ vector to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param vec Vector value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddVector(Handle:pb, const String:field[], const Float:vec[3]); + +/** + * Add an XY vector to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param vec Vector value to add. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbAddVector2D(Handle:pb, const String:field[], const Float:vec[2]); + +/** + * Removes a value by index from a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param index Index into repeated field. + * @noreturn + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native PbRemoveRepeatedFieldValue(Handle:pb, const String:field[], index); + +/** + * Retrieve a handle to an embedded protobuf message in a protobuf message. + * + * @param pb protobuf handle. + * @param field Field name. + * @return protobuf handle to embedded message. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native Handle:PbReadMessage(Handle:pb, const String:field[]); + +/** + * Retrieve a handle to an embedded protobuf message in a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @param index Index in the repeated field. + * @return protobuf handle to embedded message. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native Handle:PbReadRepeatedMessage(Handle:pb, const String:field[], index); + +/** + * Adds an embedded protobuf message to a protobuf message repeated field. + * + * @param pb protobuf handle. + * @param field Field name. + * @return protobuf handle to added, embedded message. + * @error Invalid or incorrect Handle, non-existent field, or incorrect field type. + */ +native Handle:PbAddMessage(Handle:pb, const String:field[]); diff --git a/env/include/regex.inc b/env/include/regex.inc index bfdd22c..555c4a3 100644 --- a/env/include/regex.inc +++ b/env/include/regex.inc @@ -43,9 +43,13 @@ #define PCRE_MULTILINE 0x00000002 /* Multilines (affects ^ and $ so that they match the start/end of a line rather than matching the start/end of the string). */ #define PCRE_DOTALL 0x00000004 /* Single line (affects . so that it matches any character, even new line characters). */ #define PCRE_EXTENDED 0x00000008 /* Pattern extension (ignore whitespace and # comments). */ +#define PCRE_ANCHORED 0x00000010 /* Force pattern anchoring. */ +#define PCRE_DOLLAR_ENDONLY 0x00000020 /* $ not to match newline at end. */ #define PCRE_UNGREEDY 0x00000200 /* Invert greediness of quantifiers */ +#define PCRE_NOTEMPTY 0x00000400 /* An empty string is not a valid match. */ #define PCRE_UTF8 0x00000800 /* Use UTF-8 Chars */ #define PCRE_NO_UTF8_CHECK 0x00002000 /* Do not check the pattern for UTF-8 validity (only relevant if PCRE_UTF8 is set) */ +#define PCRE_UCP 0x20000000 /* Use Unicode properties for \ed, \ew, etc. */ /** @@ -76,7 +80,16 @@ enum RegexError REGEX_ERROR_DFA_RECURSE = -20, REGEX_ERROR_RECURSIONLIMIT = -21, REGEX_ERROR_NULLWSLIMIT = -22, /* No longer actually used */ - REGEX_ERROR_BADNEWLINE = -23 + REGEX_ERROR_BADNEWLINE = -23, + REGEX_ERROR_BADOFFSET = -24, + REGEX_ERROR_SHORTUTF8 = -25, + REGEX_ERROR_RECURSELOOP = -26, + REGEX_ERROR_JIT_STACKLIMIT = -27, + REGEX_ERROR_BADMODE = -28, + REGEX_ERROR_BADENDIANNESS = -29, + REGEX_ERROR_DFA_BADRESTART = -30, + REGEX_ERROR_JIT_BADOPTION = -31, + REGEX_ERROR_BADLENGTH = -32, }; /** @@ -114,7 +127,7 @@ native MatchRegex(Handle:regex, const String:str[], &RegexError:ret = REGEX_ERRO * @param regex The regex handle to extract data from. * @param str_id The index of the expression to get - starts at 0, and ends at substrings - 1. * @param buffer The buffer to set to the matching substring. - * @param maxLen The maximum string length of the buffer. + * @param maxlen The maximum string length of the buffer. * @return True if a substring was found, False on fail/error */ native bool:GetRegexSubString(Handle:regex, str_id, String:buffer[], maxlen); diff --git a/env/include/sdkhooks.inc b/env/include/sdkhooks.inc index bba7237..2b25504 100644 --- a/env/include/sdkhooks.inc +++ b/env/include/sdkhooks.inc @@ -1,43 +1,80 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod (C)2009-2013 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This file is part of the SourceMod/SourcePawn SDK. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + */ + #if defined _sdkhooks_included #endinput #endif #define _sdkhooks_included -#define DMG_GENERIC 0 // generic damage was done -#define DMG_CRUSH (1 << 0) // crushed by falling or moving object. - // NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage. - // DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead. -#define DMG_BULLET (1 << 1) // shot -#define DMG_SLASH (1 << 2) // cut, clawed, stabbed -#define DMG_BURN (1 << 3) // heat burned -#define DMG_VEHICLE (1 << 4) // hit by a vehicle -#define DMG_FALL (1 << 5) // fell too far -#define DMG_BLAST (1 << 6) // explosive blast damage -#define DMG_CLUB (1 << 7) // crowbar, punch, headbutt -#define DMG_SHOCK (1 << 8) // electric shock -#define DMG_SONIC (1 << 9) // sound pulse shockwave -#define DMG_ENERGYBEAM (1 << 10) // laser or other high energy beam -#define DMG_PREVENT_PHYSICS_FORCE (1 << 11) // Prevent a physics force -#define DMG_NEVERGIB (1 << 12) // with this bit OR'd in, no damage type will be able to gib victims upon death -#define DMG_ALWAYSGIB (1 << 13) // with this bit OR'd in, any damage type can be made to gib victims upon death. -#define DMG_DROWN (1 << 14) // Drowning -#define DMG_PARALYZE (1 << 15) // slows affected creature down -#define DMG_NERVEGAS (1 << 16) // nerve toxins, very bad -#define DMG_POISON (1 << 17) // blood poisoning - heals over time like drowning damage -#define DMG_RADIATION (1 << 18) // radiation exposure -#define DMG_DROWNRECOVER (1 << 19) // drowning recovery -#define DMG_ACID (1 << 20) // toxic chemicals or acid burns -#define DMG_SLOWBURN (1 << 21) // in an oven -#define DMG_REMOVENORAGDOLL (1 << 22) // with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed. - // use this to kill an entity that you've already got a server-side ragdoll for -#define DMG_PHYSGUN (1 << 23) // Hit by manipulator. Usually doesn't do any damage. -#define DMG_PLASMA (1 << 24) // Shot by Cremator -#define DMG_AIRBOAT (1 << 25) // Hit by the airboat's gun -#define DMG_DISSOLVE (1 << 26) // Dissolving! -#define DMG_BLAST_SURFACE (1 << 27) // A blast on the surface of water that cannot harm things underwater +// this is obviously _not_ a robust check, but it will solve most conflict and is clean +#if !defined DMG_GENERIC +#define DMG_GENERIC 0 /**< generic damage was done */ +#define DMG_CRUSH (1 << 0) /**< crushed by falling or moving object. + NOTE: It's assumed crush damage is occurring as a result of physics collision, so no extra physics force is generated by crush damage. + DON'T use DMG_CRUSH when damaging entities unless it's the result of a physics collision. You probably want DMG_CLUB instead. */ +#define DMG_BULLET (1 << 1) /**< shot */ +#define DMG_SLASH (1 << 2) /**< cut, clawed, stabbed */ +#define DMG_BURN (1 << 3) /**< heat burned */ +#define DMG_VEHICLE (1 << 4) /**< hit by a vehicle */ +#define DMG_FALL (1 << 5) /**< fell too far */ +#define DMG_BLAST (1 << 6) /**< explosive blast damage */ +#define DMG_CLUB (1 << 7) /**< crowbar, punch, headbutt */ +#define DMG_SHOCK (1 << 8) /**< electric shock */ +#define DMG_SONIC (1 << 9) /**< sound pulse shockwave */ +#define DMG_ENERGYBEAM (1 << 10) /**< laser or other high energy beam */ +#define DMG_PREVENT_PHYSICS_FORCE (1 << 11) /**< Prevent a physics force */ +#define DMG_NEVERGIB (1 << 12) /**< with this bit OR'd in, no damage type will be able to gib victims upon death */ +#define DMG_ALWAYSGIB (1 << 13) /**< with this bit OR'd in, any damage type can be made to gib victims upon death. */ +#define DMG_DROWN (1 << 14) /**< Drowning */ +#define DMG_PARALYZE (1 << 15) /**< slows affected creature down */ +#define DMG_NERVEGAS (1 << 16) /**< nerve toxins, very bad */ +#define DMG_POISON (1 << 17) /**< blood poisoning - heals over time like drowning damage */ +#define DMG_RADIATION (1 << 18) /**< radiation exposure */ +#define DMG_DROWNRECOVER (1 << 19) /**< drowning recovery */ +#define DMG_ACID (1 << 20) /**< toxic chemicals or acid burns */ +#define DMG_SLOWBURN (1 << 21) /**< in an oven */ +#define DMG_REMOVENORAGDOLL (1 << 22) /**< with this bit OR'd in, no ragdoll will be created, and the target will be quietly removed. + use this to kill an entity that you've already got a server-side ragdoll for */ +#define DMG_PHYSGUN (1 << 23) /**< Hit by manipulator. Usually doesn't do any damage. */ +#define DMG_PLASMA (1 << 24) /**< Shot by Cremator */ +#define DMG_AIRBOAT (1 << 25) /**< Hit by the airboat's gun */ +#define DMG_DISSOLVE (1 << 26) /**< Dissolving! */ +#define DMG_BLAST_SURFACE (1 << 27) /**< A blast on the surface of water that cannot harm things underwater */ #define DMG_DIRECT (1 << 28) -#define DMG_BUCKSHOT (1 << 29) // not quite a bullet. Little, rounder, different. +#define DMG_BUCKSHOT (1 << 29) /**< not quite a bullet. Little, rounder, different. */ +#endif +#if !defined DMG_CRIT + // TF2 crits and minicrits + #define DMG_CRIT DMG_ACID +#endif enum SDKHookType { @@ -62,68 +99,183 @@ enum SDKHookType SDKHook_ShouldCollide, SDKHook_PreThinkPost, SDKHook_PostThinkPost, - SDKHook_ThinkPost + SDKHook_ThinkPost, + SDKHook_EndTouchPost, + SDKHook_GroundEntChangedPost, + SDKHook_SpawnPost, + SDKHook_StartTouchPost, + SDKHook_TouchPost, + SDKHook_VPhysicsUpdate, + SDKHook_VPhysicsUpdatePost, + SDKHook_WeaponCanSwitchToPost, + SDKHook_WeaponCanUsePost, + SDKHook_WeaponDropPost, + SDKHook_WeaponEquipPost, + SDKHook_WeaponSwitchPost, + SDKHook_Use, + SDKHook_UsePost, + SDKHook_Reload, + SDKHook_ReloadPost, + SDKHook_GetMaxHealth, /**< ep2v and later */ }; /* Alphabetized for easy readability - SDKHook_EndTouch - SDKHook_FireBulletsPost - SDKHook_OnTakeDamage - SDKHook_OnTakeDamagePost - SDKHook_PreThink - SDKHook_PreThinkPost - SDKHook_PostThink - SDKHook_PostThinkPost - SDKHook_SetTransmit - SDKHook_ShouldCollide - SDKHook_Spawn - SDKHook_StartTouch - SDKHook_Think - SDKHook_ThinkPost - SDKHook_Touch - SDKHook_TraceAttack - SDKHook_TraceAttackPost - SDKHook_WeaponCanSwitchTo - SDKHook_WeaponCanUse - SDKHook_WeaponDrop - SDKHook_WeaponEquip - SDKHook_WeaponSwitch + SDKHook_EndTouch, + SDKHook_EndTouchPost, + + SDKHook_FireBulletsPost, + + SDKHook_GetMaxHealth, (ep2v and later) + + SDKHook_GroundEntChangedPost, + + SDKHook_OnTakeDamage, + SDKHook_OnTakeDamagePost, + + SDKHook_PreThink, + SDKHook_PreThinkPost, + + SDKHook_PostThink, + SDKHook_PostThinkPost, + + SDKHook_Reload, + SDKHook_ReloadPost, + + SDKHook_SetTransmit, + + SDKHook_ShouldCollide, + + SDKHook_Spawn, + SDKHook_SpawnPost, + + SDKHook_StartTouch, + SDKHook_StartTouchPost, + + SDKHook_Think, + SDKHook_ThinkPost, + + SDKHook_Touch, + SDKHook_TouchPost, + + SDKHook_TraceAttack, + SDKHook_TraceAttackPost, + + SDKHook_Use, + SDKHook_UsePost, + + SDKHook_VPhysicsUpdate, + SDKHook_VPhysicsUpdatePost, + + SDKHook_WeaponCanSwitchTo, + SDKHook_WeaponCanSwitchToPost, + + SDKHook_WeaponCanUse, + SDKHook_WeaponCanUsePost, + + SDKHook_WeaponDrop, + SDKHook_WeaponDropPost, + + SDKHook_WeaponEquip, + SDKHook_WeaponEquipPost, + + SDKHook_WeaponSwitch, + SDKHook_WeaponSwitchPost */ +enum UseType +{ + Use_Off, + Use_On, + Use_Set, + Use_Toggle +}; + funcenum SDKHookCB { // PreThink/Post // PostThink/Post public(client), + // Spawn + Action:public(entity), + + // GroundEntChanged + // SpawnPost // Think/Post + // VPhysicsUpdate/Post public(entity), + // EndTouch // StartTouch // Touch + Action:public(entity, other), + + // EndTouchPost + // StartTouchPost + // TouchPost public(entity, other), + // SetTransmit Action:public(entity, client), + // WeaponCanSwitchTo // WeaponCanUse // WeaponDrop // WeaponEquip // WeaponSwitch Action:public(client, weapon), + + // WeaponCanSwitchToPost + // WeaponCanUsePost + // WeaponDropPost + // WeaponEquipPost + // WeaponSwitchPost + public(client, weapon), + + // GetMaxHealth (ep2v and later) + Action:public(entity, &maxhealth), + // OnTakeDamage + // Note: The weapon parameter is not used by all games and damage sources. + // Note: Force application is dependent on game and damage type(s) + // SDKHooks 1.0+ Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype), + // SDKHooks 2.0+ + Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]), + // SDKHooks 2.1+ (can check for support at runtime using GetFeatureStatus on SDKHook_DmgCustomInOTD capability. + // DON'T attempt to access 'damagecustom' var if feature status != available + Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, + Float:damageForce[3], Float:damagePosition[3], damagecustom), + // OnTakeDamagePost public(victim, attacker, inflictor, Float:damage, damagetype), - // FireBullets + public(victim, attacker, inflictor, Float:damage, damagetype, weapon, const Float:damageForce[3], const Float:damagePosition[3]), + + // FireBulletsPost public(client, shots, const String:weaponname[]), + // TraceAttack Action:public(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup), + // TraceAttackPost public(victim, attacker, inflictor, Float:damage, damagetype, ammotype, hitbox, hitgroup), + // ShouldCollide - Action:public(entity, &collisiongroup, &contentsmask, &bool:result) + bool:public(entity, collisiongroup, contentsmask, bool:originalResult), + + // Use + Action:public(entity, activator, caller, UseType:type, Float:value), + + // UsePost + public(entity, activator, caller, UseType:type, Float:value), + + // Reload + Action:public(weapon), + + // Reload post + public(weapon, bool:bSuccessful) }; @@ -147,6 +299,8 @@ forward OnEntityDestroyed(entity); /** * @brief When the game description is retrieved * + * @note Not supported on ep2v. + * * @param gameDesc Game description * @noreturn */ @@ -191,11 +345,41 @@ native bool:SDKHookEx(entity, SDKHookType:type, SDKHookCB:callback); */ native SDKUnhook(entity, SDKHookType:type, SDKHookCB:callback); -/** Do Not Edit Below This Line **/ +/** + * @brief Applies damage to an entity + * + * @note Force application is dependent on game and damage type(s) + * + * @param entity Entity index taking damage + * @param inflictor Inflictor entity index + * @param attacker Attacker entity index + * @param damage Amount of damage + * @param damageType Bitfield of damage types + * @param weapon Weapon index (orangebox and later) or -1 for unspecified + * @param damageForce Velocity of damage force + * @param damagePosition Origin of damage + * @noreturn + */ +native SDKHooks_TakeDamage(entity, inflictor, attacker, Float:damage, damageType=DMG_GENERIC, weapon=-1, const Float:damageForce[3]=NULL_VECTOR, const Float:damagePosition[3]=NULL_VECTOR); -public Extension:__ext_sdkhooks = +/** + * @brief Forces a client to drop the specified weapon + * + * @param client Client index. + * @param weapon Weapon entity index. + * @param vecTarget Location to toss weapon to, or NULL_VECTOR for default. + * @param vecVelocity Velocity at which to toss weapon, or NULL_VECTOR for default. + * @noreturn + * @error Invalid client or weapon entity, weapon not owned by client. + */ +native SDKHooks_DropWeapon(client, weapon, const Float:vecTarget[3]=NULL_VECTOR, const Float:vecVelocity[3]=NULL_VECTOR); + +/** + * Do not edit below this line! + */ +public Extension:__ext_sdkhooks = { - name = "sdkhooks", + name = "SDKHooks", file = "sdkhooks.ext", #if defined AUTOLOAD_EXTENSIONS autoload = 1, @@ -207,4 +391,4 @@ public Extension:__ext_sdkhooks = #else required = 0, #endif -}; \ No newline at end of file +}; diff --git a/env/include/sdktools.inc b/env/include/sdktools.inc index db96337..3351bcf 100644 --- a/env/include/sdktools.inc +++ b/env/include/sdktools.inc @@ -72,6 +72,7 @@ enum SDKFuncConfSource { SDKConf_Virtual = 0, /**< Read a virtual index from the Offsets section */ SDKConf_Signature = 1, /**< Read a signature from the Signatures section */ + SDKConf_Address = 2, /**< Read an address from the Addresses section */ }; enum SDKType @@ -130,6 +131,14 @@ native PrepSDKCall_SetVirtual(vtblidx); */ native bool:PrepSDKCall_SetSignature(SDKLibrary:lib, const String:signature[], bytes); +/** + * Uses the given function address for the SDK call. + * + * @param addr Address of function to use. + * @return True on success, false on failure. + */ +native bool:PrepSDKCall_SetAddress(Address:addr); + /** * Finds an address or virtual function index in a GameConfig file and sets it as * the calling information for the SDK call. @@ -194,6 +203,13 @@ native Handle:EndPrepSDKCall(); */ native any:SDKCall(Handle:call, any:...); +/** + * Returns the entity index of the player resource/manager entity. + * + * @return Index of resource entity or -1 if not found. + */ +native GetPlayerResourceEntity(); + #include /** diff --git a/env/include/sdktools_entinput.inc b/env/include/sdktools_entinput.inc index 1eb5f6b..88d90cc 100644 --- a/env/include/sdktools_entinput.inc +++ b/env/include/sdktools_entinput.inc @@ -109,7 +109,7 @@ native SetVariantColor(const color[4]); /** * Sets an entity in the global variant object. * - * @param Entity index. + * @param entity Entity index. * @noreturn * @error Invalid entity index. */ diff --git a/env/include/sdktools_functions.inc b/env/include/sdktools_functions.inc index c8e3705..16b3e47 100644 --- a/env/include/sdktools_functions.inc +++ b/env/include/sdktools_functions.inc @@ -81,13 +81,13 @@ native GetPlayerWeaponSlot(client, slot); native IgniteEntity(entity, Float:time, bool:npc=false, Float:size=0.0, bool:level=false); /** - * Extinguishes a player that is on fire. + * Extinguishes an entity that is on fire. * * @param entity Entity index. * @noreturn * @error Invalid entity or client not in game, or lack of mod support. */ -native ExtinguishEntity(client); +native ExtinguishEntity(entity); /** * Teleports an entity. @@ -194,7 +194,7 @@ native bool:DispatchKeyValueFloat(entity, const String:keyName[], Float:value); * @return True on success, false otherwise. * @error Invalid entity index, or no mod support. */ -native bool:DispatchKeyValueVector(entity, const String:keyName[], const Float:vector[3]); +native bool:DispatchKeyValueVector(entity, const String:keyName[], const Float:vec[3]); /** * Returns the entity a client is aiming at. @@ -270,7 +270,7 @@ native GetTeamClientCount(index); native SetEntityModel(entity, const String:model[]); /** - * Retrieves the decal file name associated to a given client. + * Retrieves the decal file name associated with a given client. * * @param client Player's index. * @param hex Buffer to store the logo filename. @@ -280,6 +280,17 @@ native SetEntityModel(entity, const String:model[]); */ native bool:GetPlayerDecalFile(client, String:hex[], maxlength); +/** + * Retrieves the jingle file name associated with a given client. + * + * @param client Player's index. + * @param hex Buffer to store the jingle filename. + * @param maxlength Maximum length of string buffer. + * @return True on success, otherwise false. + * @error Invalid client or client not in game. + */ +native bool:GetPlayerJingleFile(client, String:hex[], maxlength); + /** * Returns the average server network traffic in bytes/sec. * @@ -293,7 +304,7 @@ native GetServerNetStats(&Float:in, &Float:out); * Equip's a player's weapon. * * @param client Client index. - * @param item CBaseCombatWeapon entity index. + * @param weapon CBaseCombatWeapon entity index. * @noreturn * @error Invalid client or entity, lack of mod support, or client not in * game. @@ -320,3 +331,16 @@ native ActivateEntity(entity); * @error Invalid client index, or client not connected. */ native SetClientInfo(client, const String:key[], const String:value[]); + +/** + * Gives ammo of a certain type to a player. + * This natives obeys the maximum amount of ammo a player can carry per ammo type. + * + * @param client The client index. + * @param amount Amount of ammo to give. Is capped at ammotype's limit. + * @param ammotype Type of ammo to give to player. + * @param suppressSound If true, don't play the ammo pickup sound. + * + * @return Amount of ammo actually given. + */ +native GivePlayerAmmo(client, amount, ammotype, bool:suppressSound=false); \ No newline at end of file diff --git a/env/include/sdktools_gamerules.inc b/env/include/sdktools_gamerules.inc index 967963d..6a5f7ba 100644 --- a/env/include/sdktools_gamerules.inc +++ b/env/include/sdktools_gamerules.inc @@ -66,6 +66,9 @@ enum RoundState { //Game is over, doing bonus round stuff RoundState_Bonus, + + //Between rounds + RoundState_BetweenRounds, }; /** @@ -90,6 +93,7 @@ native GameRules_GetProp(const String:prop[], size=4, element=0); * This value is auto-detected, and the size parameter is * only used as a fallback in case detection fails. * @param element Element # (starting from 0) if property is an array. + * @param changeState If true, change will be sent over the network. * @error Not supported. * @noreturn */ @@ -111,6 +115,7 @@ native Float:GameRules_GetPropFloat(const String:prop[], element=0); * @param prop Property name. * @param value Value to set. * @param element Element # (starting from 0) if property is an array. + * @param changeState If true, change will be sent over the network. * @noreturn * @error Not supported. */ @@ -134,6 +139,7 @@ native GameRules_GetPropEnt(const String:prop[], element=0); * @param prop Property name. * @param other Entity index to set, or -1 to unset. * @param element Element # (starting from 0) if property is an array. + * @param changeState If true, change will be sent over the network. * @noreturn * @error Not supported. */ @@ -156,6 +162,7 @@ native GameRules_GetPropVector(const String:prop[], Float:vec[3], element=0); * @param prop Property name. * @param vec Vector to set. * @param element Element # (starting from 0) if property is an array. + * @param changeState If true, change will be sent over the network. * @noreturn * @error Not supported. */ @@ -177,6 +184,7 @@ native GameRules_GetPropString(const String:prop[], String:buffer[], maxlen); * * @param prop Property to use. * @param buffer String to set. + * @param changeState If true, change will be sent over the network. * @return Number of non-null bytes written. * @error Not supported. */ diff --git a/env/include/sdktools_hooks.inc b/env/include/sdktools_hooks.inc index 0f8d20e..bae8d52 100644 --- a/env/include/sdktools_hooks.inc +++ b/env/include/sdktools_hooks.inc @@ -35,6 +35,8 @@ #endif #define _sdktools_hooks_included +#define FEATURECAP_PLAYERRUNCMD_11PARAMS "SDKTools PlayerRunCmd 11Params" + /** * @brief Called when a clients movement buttons are being processed * @@ -44,6 +46,14 @@ * @param vel Players desired velocity. * @param angles Players desired view angles. * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise. + * @param subtype Weapon subtype when selected from a menu. + * @param cmdnum Command number. Increments from the first command sent. + * @param tickcount Tick count. A client's prediction based on the server's GetGameTickCount value. + * @param seed Random seed. Used to determine weapon recoil, spread, and other predicted elements. + * @param mouse Mouse direction (x, y). * @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise. + * + * @note To see if all 11 params are avaliable, use FeatureType_Capability and + * FEATURECAP_PLAYERRUNCMD_11PARAMS. */ -forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon); \ No newline at end of file +forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon, &subtype, &cmdnum, &tickcount, &seed, mouse[2]); \ No newline at end of file diff --git a/env/include/sdktools_sound.inc b/env/include/sdktools_sound.inc index a978dbd..bfb4e3f 100644 --- a/env/include/sdktools_sound.inc +++ b/env/include/sdktools_sound.inc @@ -127,7 +127,7 @@ enum * @param name Sound file name relative to the "sounds" folder. * @noreturn */ -native PrefetchSound(const String:nane[]); +native PrefetchSound(const String:name[]); /** * This function is not known to work, and may crash. You should diff --git a/env/include/sdktools_stringtables.inc b/env/include/sdktools_stringtables.inc index b54583b..8c4ee08 100644 --- a/env/include/sdktools_stringtables.inc +++ b/env/include/sdktools_stringtables.inc @@ -86,7 +86,7 @@ native GetStringTableName(tableidx, String:name[], maxlength); * Searches for the index of a given string in a string table. * * @param tableidx A string table index. - * @param string String to find. + * @param str String to find. * @return String index if found, INVALID_STRING_INDEX otherwise. * @error Invalid string table index. */ @@ -97,12 +97,12 @@ native FindStringIndex(tableidx, const String:str[]); * * @param tableidx A string table index. * @param stringidx A string index. - * @param name Buffer to store the string value. + * @param str Buffer to store the string value. * @param maxlength Maximum length of string buffer. * @return Number of bytes written to the buffer (UTF-8 safe). * @error Invalid string table index or string index. */ -native ReadStringTable(tableidx, stringIdx, String:str[], maxlength); +native ReadStringTable(tableidx, stringidx, String:str[], maxlength); /** * Returns the length of the user data associated with a given string index. @@ -124,7 +124,7 @@ native GetStringTableDataLength(tableidx, stringidx); * @return Number of bytes written to the buffer (UTF-8 safe). * @error Invalid string table index or string index. */ -native GetStringTableData(tableidx, stringIdx, String:userdata[], maxlength); +native GetStringTableData(tableidx, stringidx, String:userdata[], maxlength); /** * Sets the user data associated with a given string index. @@ -136,13 +136,13 @@ native GetStringTableData(tableidx, stringIdx, String:userdata[], maxlength); * @return Number of bytes written to the buffer (UTF-8 safe). * @error Invalid string table index or string index. */ -native SetStringTableData(tableidx, stringIdx, const String:userdata[], length); +native SetStringTableData(tableidx, stringidx, const String:userdata[], length); /** * Adds a string to a given string table. * * @param tableidx A string table index. - * @param string String to add. + * @param str String to add. * @param userdata An optional user data string. * @param length Length of user data string. This should include the null terminator. * If set to -1, then user data will be not be altered if the specified string diff --git a/env/include/sdktools_tempents_stocks.inc b/env/include/sdktools_tempents_stocks.inc index 2a52bf1..6a632c0 100644 --- a/env/include/sdktools_tempents_stocks.inc +++ b/env/include/sdktools_tempents_stocks.inc @@ -100,7 +100,7 @@ stock TE_SetupSparks(const Float:pos[3], const Float:dir[3], Magnitude, TrailLen * @param pos Position of the smoke. * @param Model Precached model index. * @param Scale Scale of the smoke. - * @param Framerate Frame rate of the smoke. + * @param FrameRate Frame rate of the smoke. * @noreturn */ stock TE_SetupSmoke(const Float:pos[3], Model, Float:Scale, FrameRate) @@ -278,7 +278,7 @@ stock TE_SetupBloodSprite(const Float:pos[3], const Float:dir[3], const color[4] * @param Life Time duration of the ring. * @param Width Beam width. * @param Amplitude Beam amplitude. - * @param color Color array (r, g, b, a). + * @param Color Color array (r, g, b, a). * @param Speed Speed of the beam. * @param Flags Beam flags. * @noreturn @@ -321,7 +321,7 @@ stock TE_SetupBeamRingPoint(const Float:center[3], Float:Start_Radius, Float:End * @param EndWidth Final beam width. * @param FadeLength Beam fade time duration. * @param Amplitude Beam amplitude. - * @param color Color array (r, g, b, a). + * @param Color Color array (r, g, b, a). * @param Speed Speed of the beam. * @noreturn */ @@ -361,7 +361,7 @@ stock TE_SetupBeamPoints(const Float:start[3], const Float:end[3], ModelIndex, H * @param EndWidth Final beam width. * @param FadeLength Beam fade time duration. * @param Amplitude Beam amplitude. - * @param color Color array (r, g, b, a). + * @param Color Color array (r, g, b, a). * @param Speed Speed of the beam. * @noreturn */ @@ -399,7 +399,7 @@ stock TE_SetupBeamLaser(StartEntity, EndEntity, ModelIndex, HaloIndex, StartFram * @param Life Time duration of the ring. * @param Width Beam width. * @param Amplitude Beam amplitude. - * @param color Color array (r, g, b, a). + * @param Color Color array (r, g, b, a). * @param Speed Speed of the beam. * @param Flags Beam flags. * @noreturn @@ -436,7 +436,7 @@ stock TE_SetupBeamRing(StartEntity, EndEntity, ModelIndex, HaloIndex, StartFrame * @param Width Initial beam width. * @param EndWidth Final beam width. * @param FadeLength Beam fade time duration. - * @param color Color array (r, g, b, a). + * @param Color Color array (r, g, b, a). * @noreturn */ stock TE_SetupBeamFollow(EntIndex, ModelIndex, HaloIndex, Float:Life, Float:Width, Float:EndWidth, FadeLength, const Color[4]) diff --git a/env/include/sdktools_voice.inc b/env/include/sdktools_voice.inc index ef27180..132898b 100644 --- a/env/include/sdktools_voice.inc +++ b/env/include/sdktools_voice.inc @@ -78,6 +78,7 @@ native GetClientListeningFlags(client); * * @param iReceiver The listener index. * @param iSender The sender index. + * @param bListen True if the receiver can listen to the sender, false otherwise. * @return True if successful otherwise false. */ #pragma deprecated Use SetListenOverride() instead @@ -98,7 +99,7 @@ native bool:GetClientListening(iReceiver, iSender); * * @param iReceiver The listener index. * @param iSender The sender index. - * @param override + * @param override The override of the receiver's ability to listen to the sender. * @return True if successful otherwise false. */ native bool:SetListenOverride(iReceiver, iSender, ListenOverride:override); diff --git a/env/include/sorting.inc b/env/include/sorting.inc index 2b1bfec..50ac310 100644 --- a/env/include/sorting.inc +++ b/env/include/sorting.inc @@ -84,7 +84,7 @@ native SortFloats(Float:array[], array_size, SortOrder:order = Sort_Ascending); * @param order Sorting order to use. * @noreturn */ -native SortStrings(String:array[][], num_strings, SortOrder:order = Sort_Ascending); +native SortStrings(String:array[][], array_size, SortOrder:order = Sort_Ascending); /** * Sort comparison function for 1D array elements. @@ -125,8 +125,8 @@ native SortCustom1D(array[], array_size, SortFunc1D:sortfunc, Handle:hndl=INVALI */ funcenum SortFunc2D { - public(array[], array[], const array[][], Handle:hndl), - public(String:array[], String:array[], const String:array[][], Handle:hndl), + public(elem1[], elem2[], const array[][], Handle:hndl), + public(String:elem1[], String:elem2[], const String:array[][], Handle:hndl), }; /** diff --git a/env/include/sourcemod.inc b/env/include/sourcemod.inc index 8d165f7..dec146d 100644 --- a/env/include/sourcemod.inc +++ b/env/include/sourcemod.inc @@ -66,6 +66,7 @@ struct Plugin #include #include #include +#include #include #include #include @@ -277,7 +278,7 @@ native GetPluginFilename(Handle:plugin, String:buffer[], maxlength); * @return True if being debugged, false otherwise. * @error Invalid Handle. */ -native bool:IsPluginDebugging(Handle:hndl); +native bool:IsPluginDebugging(Handle:plugin); /** * Retrieves a plugin's public info. @@ -327,7 +328,7 @@ native SetFailState(const String:string[], any:...); * Aborts the current callback and throws an error. This function * does not return in that no code is executed following it. * - * @param format String format. + * @param fmt String format. * @param ... Format arguments. * @noreturn * @error Always! @@ -386,7 +387,7 @@ native GameConfGetOffset(Handle:gc, const String:key[]); */ native bool:GameConfGetKeyValue(Handle:gc, const String:key[], String:buffer[], maxlen); -/* +/** * Finds an address calculation in a GameConfig file, * performs LoadFromAddress on it as appropriate, then returns the final address. * diff --git a/env/include/string.inc b/env/include/string.inc index 957ad68..a06b924 100644 --- a/env/include/string.inc +++ b/env/include/string.inc @@ -119,7 +119,7 @@ stock bool:StrEqual(const String:str1[], const String:str2[], bool:caseSensitive * destination will be truncated. * * @param dest Destination string buffer to copy to. - * @param destlen Destination buffer length (includes null terminator). + * @param destLen Destination buffer length (includes null terminator). * @param source Source string buffer to copy from. * @return Number of cells written. */ @@ -323,7 +323,7 @@ native GetCharBytes(const String:source[]); * * @note Multi-byte characters will always return false. * - * @param char Character to test. + * @param chr Character to test. * @return True if character is alphabetical, otherwise false. */ native bool:IsCharAlpha(chr); @@ -333,7 +333,7 @@ native bool:IsCharAlpha(chr); * * @note Multi-byte characters will always return false. * - * @param char Character to test. + * @param chr Character to test. * @return True if character is numeric, otherwise false. */ native bool:IsCharNumeric(chr); @@ -343,7 +343,7 @@ native bool:IsCharNumeric(chr); * * @note Multi-byte characters will always return false. * - * @param char Character to test. + * @param chr Character to test. * @return True if character is whitespace, otherwise false. */ native bool:IsCharSpace(chr); @@ -351,7 +351,7 @@ native bool:IsCharSpace(chr); /** * Returns if a character is multi-byte or not. * - * @param char Character to test. + * @param chr Character to test. * @return 0 for a normal 7-bit ASCII character, * otherwise number of bytes in multi-byte character. */ @@ -362,7 +362,7 @@ native IsCharMB(chr); * * @note Multi-byte characters will always return false. * - * @param char Character to test. + * @param chr Character to test. * @return True if character is uppercase, otherwise false. */ native bool:IsCharUpper(chr); @@ -372,7 +372,7 @@ native bool:IsCharUpper(chr); * * @note Multi-byte characters will always return false. * - * @param char Character to test. + * @param chr Character to test. * @return True if character is lowercase, otherwise false. */ native bool:IsCharLower(chr); diff --git a/env/include/testing.inc b/env/include/testing.inc new file mode 100644 index 0000000..28b50e8 --- /dev/null +++ b/env/include/testing.inc @@ -0,0 +1,72 @@ +/** + * vim: set ts=4 sw=4 tw=99 noet : + * ============================================================================= + * SourceMod (C)2004-2014 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This file is part of the SourceMod/SourcePawn SDK. + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +static TestNumber = 0; +static String:TestContext[255]; + +SetTestContext(const String:context[]) +{ + strcopy(TestContext, sizeof(TestContext), context); +} + +AssertEq(const String:text[], cell1, cell2) +{ + TestNumber++; + if (cell1 == cell2) { + PrintToServer("[%d] %s: %s == %d OK", TestNumber, TestContext, text, cell2); + } else { + PrintToServer("[%d] %s FAIL: %s should be %d, got %d", TestNumber, TestContext, text, cell2, cell1); + ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext); + } +} + +AssertFalse(const String:text[], bool:value) +{ + TestNumber++; + if (!value) { + PrintToServer("[%d] %s: %s == false OK", TestNumber, TestContext, text, value); + } else { + PrintToServer("[%d] %s FAIL: %s should be false, got true", TestNumber, TestContext, text); + ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext); + } +} + +AssertTrue(const String:text[], bool:value) +{ + TestNumber++; + if (value) { + PrintToServer("[%d] %s: %s == true OK", TestNumber, TestContext, text, value); + } else { + PrintToServer("[%d] %s FAIL: %s should be true, got false", TestNumber, TestContext, text); + ThrowError("test %d (%s in %s) failed", TestNumber, text, TestContext); + } +} diff --git a/env/include/tf2.inc b/env/include/tf2.inc index bba1efd..789463d 100644 --- a/env/include/tf2.inc +++ b/env/include/tf2.inc @@ -35,13 +35,13 @@ #endif #define _tf2_included -#define TF_STUNFLAG_SLOWDOWN (1 << 0) // activates slowdown modifier -#define TF_STUNFLAG_BONKSTUCK (1 << 1) // bonk sound, stuck -#define TF_STUNFLAG_LIMITMOVEMENT (1 << 2) // disable forward/backward movement -#define TF_STUNFLAG_CHEERSOUND (1 << 3) // cheering sound -#define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5) // no sound or particle -#define TF_STUNFLAG_THIRDPERSON (1 << 6) // panic animation -#define TF_STUNFLAG_GHOSTEFFECT (1 << 7) // ghost particles +#define TF_STUNFLAG_SLOWDOWN (1 << 0) /**< activates slowdown modifier */ +#define TF_STUNFLAG_BONKSTUCK (1 << 1) /**< bonk sound, stuck */ +#define TF_STUNFLAG_LIMITMOVEMENT (1 << 2) /**< disable forward/backward movement */ +#define TF_STUNFLAG_CHEERSOUND (1 << 3) /**< cheering sound */ +#define TF_STUNFLAG_NOSOUNDOREFFECT (1 << 5) /**< no sound or particle */ +#define TF_STUNFLAG_THIRDPERSON (1 << 6) /**< panic animation */ +#define TF_STUNFLAG_GHOSTEFFECT (1 << 7) /**< ghost particles */ #define TF_STUNFLAGS_LOSERSTATE TF_STUNFLAG_SLOWDOWN|TF_STUNFLAG_NOSOUNDOREFFECT|TF_STUNFLAG_THIRDPERSON #define TF_STUNFLAGS_GHOSTSCARE TF_STUNFLAG_GHOSTEFFECT|TF_STUNFLAG_THIRDPERSON @@ -107,23 +107,67 @@ enum TFCond TFCond_RegenBuffed, TFCond_MarkedForDeath, TFCond_NoHealingDamageBuff, - TFCond_SpeedBuffAlly, + TFCond_SpeedBuffAlly, //32 TFCond_HalloweenCritCandy, - - TFCond_CritHype = 36, + TFCond_CritCanteen, + TFCond_CritDemoCharge, + TFCond_CritHype, TFCond_CritOnFirstBlood, TFCond_CritOnWin, TFCond_CritOnFlagCapture, TFCond_CritOnKill, - TFCond_RestrictToMelee + TFCond_RestrictToMelee, + TFCond_DefenseBuffNoCritBlock, + TFCond_Reprogrammed, + TFCond_CritMmmph, + TFCond_DefenseBuffMmmph, + TFCond_FocusBuff, + TFCond_DisguiseRemoved, + TFCond_MarkedForDeathSilent, + TFCond_DisguisedAsDispenser, + TFCond_Sapped, + TFCond_UberchargedHidden, + TFCond_UberchargedCanteen, + TFCond_HalloweenBombHead, + TFCond_HalloweenThriller, + TFCond_RadiusHealOnDamage, + TFCond_CritOnDamage, + TFCond_UberchargedOnTakeDamage, + TFCond_UberBulletResist, + TFCond_UberBlastResist, + TFCond_UberFireResist, + TFCond_SmallBulletResist, + TFCond_SmallBlastResist, + TFCond_SmallFireResist, + TFCond_Stealthed, // 64 + TFCond_MedigunDebuff, + TFCond_StealthedUserBuffFade, + TFCond_BulletImmune, + TFCond_BlastImmune, + TFCond_FireImmune, + TFCond_PreventDeath, + TFCond_MVMBotRadiowave, + TFCond_HalloweenSpeedBoost, + TFCond_HalloweenQuickHeal, + TFCond_HalloweenGiant, + TFCond_HalloweenTiny, + TFCond_HalloweenInHell, + TFCond_HalloweenGhostMode, }; +const Float:TFCondDuration_Infinite = -1.0; + enum TFHoliday { TFHoliday_Birthday = 1, TFHoliday_Halloween, + TFHoliday_Christmas, + TFHoliday_ValentinesDay, + TFHoliday_MeetThePyro, TFHoliday_FullMoon, TFHoliday_HalloweenOrFullMoon, + TFHoliday_HalloweenOrFullMoonOrValentines, + TFHoliday_AprilFools, }; enum TFObjectType @@ -146,10 +190,11 @@ enum TFObjectMode * Sets a client on fire for 10 seconds. * * @param client Player's index. + * @param attacker Attacker's index. * @noreturn * @error Invalid client index, client not in game, or no mod support. */ -native TF2_IgnitePlayer(client, target); +native TF2_IgnitePlayer(client, attacker); /** * Respawns a client @@ -175,10 +220,12 @@ native TF2_RegeneratePlayer(client); * @param client Player's index. * @param condition Integer identifier of condition to apply. * @param duration Duration of condition (does not apply to all conditions). + * Pass TFCondDuration_Infinite to apply until manually removed. + * @param inflictor Condition inflictor's index (0 for no inflictor). * @noreturn * @error Invalid client index, client not in game, or no mod support. */ -native TF2_AddCondition(client, TFCond:condition, Float:duration); +native TF2_AddCondition(client, TFCond:condition, Float:duration=TFCondDuration_Infinite, inflictor=0); /** * Removes a condition from a player @@ -227,10 +274,10 @@ native TF2_RemovePlayerDisguise(client); * Stuns a client * * @param client Player's index. - * @param float Duration of stun. - * @param float Slowdown percent (as decimal, 0.00-1.00) - * (ignored if TF_STUNFLAG_SLOWDOWN is not set. - * @param int Stun flags. + * @param duration Duration of stun. + * @param slowdown Slowdown percent (as decimal, 0.00-1.00) + * Ignored if TF_STUNFLAG_SLOWDOWN is not set. + * @param stunflags Stun flags. * @param attacker Attacker's index (0 is allowed for world). * @noreturn */ @@ -241,7 +288,7 @@ native TF2_StunPlayer(client, Float:duration, Float:slowdown=0.0, stunflags, att * * @param client Player's index. * @param attacker Attacker's index. - * @param float Duration of bleeding (in seconds). + * @param duration Duration of bleeding (in seconds). * @noreturn */ native TF2_MakeBleed(client, attacker, Float:duration); @@ -251,6 +298,7 @@ native TF2_MakeBleed(client, attacker, Float:duration); * * @return The current resource entity index. */ +#pragma deprecated Use GetPlayerResourceEntity instead native TF2_GetResourceEntity(); /** @@ -295,6 +343,14 @@ forward Action:TF2_OnGetHoliday(&TFHoliday:holiday); */ forward Action:TF2_OnIsHolidayActive(TFHoliday:holiday, &bool:result); +/** + * Returns whether or not a holiday is active + * + * @param holiday Holiday being checked. + * @return Boolean of whether or not the holiday is active. + */ +native bool:TF2_IsHolidayActive(TFHoliday:holiday); + /** * Returns whether or not a client (Player) is in a duel. * @@ -335,6 +391,19 @@ forward TF2_OnWaitingForPlayersStart(); */ forward TF2_OnWaitingForPlayersEnd(); +/** + * Called when a player attempts to use a teleporter to decide if the player should be allowed to teleport. + * Return Plugin_Continue to let the original calculation or return a higher + * action to override the decision with the value of 'result' + * + * @param client Client index. + * @param teleporter Teleporter entity index. + * @param result Buffer param for the result of the decision. + * This is prepopulated with the game's original decision to let a player teleport. + * @return Plugin_Continue for original calculation, higher value to use 'result'. + */ +forward Action:TF2_OnPlayerTeleport(client, teleporter, &bool:result); + /** * Do not edit below this line! */ @@ -366,5 +435,6 @@ public __ext_tf2_SetNTVOptional() MarkNativeAsOptional("TF2_GetResourceEntity"); MarkNativeAsOptional("TF2_GetClass"); MarkNativeAsOptional("TF2_IsPlayerInDuel"); + MarkNativeAsOptional("TF2_IsHolidayActive"); } #endif diff --git a/env/include/tf2_stocks.inc b/env/include/tf2_stocks.inc index dff35b6..10fff4b 100644 --- a/env/include/tf2_stocks.inc +++ b/env/include/tf2_stocks.inc @@ -132,6 +132,18 @@ enum { TF_CUSTOM_PLASMA_GIB, TF_CUSTOM_PRACTICE_STICKY, TF_CUSTOM_EYEBALL_ROCKET, + TF_CUSTOM_HEADSHOT_DECAPITATION, + TF_CUSTOM_TAUNT_ARMAGEDDON, + TF_CUSTOM_FLARE_PELLET, + TF_CUSTOM_CLEAVER, + TF_CUSTOM_CLEAVER_CRIT, + TF_CUSTOM_SAPPER_RECORDER_DEATH, + TF_CUSTOM_MERASMUS_PLAYER_BOMB, + TF_CUSTOM_MERASMUS_GRENADE, + TF_CUSTOM_MERASMUS_ZAP, + TF_CUSTOM_MERASMUS_DECAPITATION, + TF_CUSTOM_CANNONBALL_PUSH, + TF_CUSTOM_TAUNT_ALLCLASS_GUITAR_RIFF, }; // Weapon codes as used in some events, such as player_death @@ -218,9 +230,28 @@ enum { TF_WEAPON_RAYGUN, TF_WEAPON_PARTICLE_CANNON, TF_WEAPON_MECHANICAL_ARM, + TF_WEAPON_DRG_POMSON, + TF_WEAPON_BAT_GIFTWRAP, + TF_WEAPON_GRENADE_ORNAMENT, + TF_WEAPON_RAYGUN_REVENGE, + TF_WEAPON_PEP_BRAWLER_BLASTER, + TF_WEAPON_CLEAVER, + TF_WEAPON_GRENADE_CLEAVER, + TF_WEAPON_STICKY_BALL_LAUNCHER, + TF_WEAPON_GRENADE_STICKY_BALL, + TF_WEAPON_SHOTGUN_BUILDING_RESCUE, + TF_WEAPON_CANNON, + TF_WEAPON_THROWABLE, + TF_WEAPON_GRENADE_THROWABLE, + TF_WEAPON_PDA_SPY_BUILD, + TF_WEAPON_GRENADE_WATERBALLOON, + TF_WEAPON_HARVESTER_SAW, + TF_WEAPON_SPELLBOOK, + TF_WEAPON_SPELLBOOK_PROJECTILE, + TF_WEAPON_SNIPERRIFLE_CLASSIC, }; -// TF2 Weapon Slots for GetPlayerWeaponSlot +// TF2 Weapon Loadout Slots enum { TFWeaponSlot_Primary, @@ -328,6 +359,7 @@ stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:pers * @return Value or -1 on failure. * @error Invalid client index, client not in game or failed to find resource entity. */ +#pragma deprecated Use GetPlayerResourceEntity and GetEntProp instead stock TF2_GetPlayerResourceData(client, TFResourceType:type) { if (!IsClientConnected(client)) @@ -363,6 +395,7 @@ stock TF2_GetPlayerResourceData(client, TFResourceType:type) * @return Value or -1 on failure. * @error Invalid client index, client not in game or failed to find resource entity. */ +#pragma deprecated Use GetPlayerResourceEntity and SetEntProp instead stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value) { if (!IsClientConnected(client)) @@ -403,7 +436,7 @@ stock TF2_RemoveWeaponSlot(client, slot) while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1) { RemovePlayerItem(client, weaponIndex); - RemoveEdict(weaponIndex); + AcceptEntityInput(weaponIndex, "Kill"); } } @@ -437,6 +470,7 @@ stock TF2_GetPlayerConditionFlags(client) * Check whether or not a condition is set on a player * * @param client Player's index. + * @param cond TFCond constant * @return True if set, false otherwise */ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond) @@ -455,7 +489,7 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond) return true; } } - else + else if (_:cond < 64) { new bit = (1 << (_:cond - 32)); if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx") & bit) == bit) @@ -463,6 +497,14 @@ stock bool:TF2_IsPlayerInCondition(client, TFCond:cond) return true; } } + else + { + new bit = (1 << (_:cond - 64)); + if ((GetEntProp(client, Prop_Send, "m_nPlayerCondEx2") & bit) == bit) + { + return true; + } + } return false; } diff --git a/env/include/timers.inc b/env/include/timers.inc index 07e801e..dbaeb14 100644 --- a/env/include/timers.inc +++ b/env/include/timers.inc @@ -92,6 +92,7 @@ native Handle:CreateTimer(Float:interval, Timer:func, any:data=INVALID_HANDLE, f /** * Kills a timer. Use this instead of CloseHandle() if you need more options. * + * @param timer Timer Handle to kill. * @param autoClose If autoClose is true, the data that was passed to CreateTimer() will * be closed as a handle if TIMER_DATA_HNDL_CLOSE was not specified. * @noreturn diff --git a/env/include/topmenus.inc b/env/include/topmenus.inc index b6fcca2..9bc4d7f 100644 --- a/env/include/topmenus.inc +++ b/env/include/topmenus.inc @@ -178,11 +178,11 @@ native bool:LoadTopMenuConfig(Handle:topmenu, const String:file[], String:error[ * @param name Object name (MUST be unique). * @param type Object type. * @param handler Handler for object. - * @param cmdname Command name (for access overrides). - * @param flags Default access flags. * @param parent Parent object ID, or INVALID_TOPMENUOBJECT for none. * Items must have a category parent. * Categories must not have a parent. + * @param cmdname Command name (for access overrides). + * @param flags Default access flags. * @param info_string Arbitrary storage (max 255 bytes). * @return A new TopMenuObject ID, or INVALID_TOPMENUOBJECT on * failure. @@ -201,7 +201,7 @@ native TopMenuObject:AddToTopMenu(Handle:topmenu, * Retrieves the info string of a top menu item. * * @param topmenu TopMenu Handle. - * @param object TopMenuObject ID. + * @param parent TopMenuObject ID. * @param buffer Buffer to store info string. * @param maxlength Maximum size of info string. * @return Number of bytes written, not including the @@ -247,6 +247,17 @@ native RemoveFromTopMenu(Handle:topmenu, TopMenuObject:object); */ native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position); +/** + * Displays a TopMenu category to a client. + * + * @param topmenu TopMenu Handle. + * @param category Category object id. + * @param client Client index. + * @return True on success, false on failure. + * @error Invalid TopMenu Handle or client not in game. + */ +native bool:DisplayTopMenuCategory(Handle:topmenu, TopMenuObject:category, client); + /** * Finds a category's object ID in a TopMenu. * @@ -258,6 +269,17 @@ native bool:DisplayTopMenu(Handle:topmenu, client, TopMenuPosition:position); */ native TopMenuObject:FindTopMenuCategory(Handle:topmenu, const String:name[]); +/** + * Change the menu title caching behaviour of the TopMenu. By default the titles are cached to reduce overhead. + * If you need dynamic menu titles, which can change everytime the menu is displayed to a user, set this to false. + * + * @param topmenu TopMenu Handle. + * @param cache_titles Cache the menu titles and don't call the handler with TopMenuAction_DisplayTitle everytime the menu is drawn? + * @noreturn + * @error Invalid TopMenu Handle + */ +native SetTopMenuTitleCaching(Handle:topmenu, bool:cache_titles); + /** * Do not edit below this line! */ @@ -285,6 +307,8 @@ public __ext_topmenus_SetNTVOptional() MarkNativeAsOptional("AddToTopMenu"); MarkNativeAsOptional("RemoveFromTopMenu"); MarkNativeAsOptional("DisplayTopMenu"); + MarkNativeAsOptional("DisplayTopMenuCategory"); MarkNativeAsOptional("FindTopMenuCategory"); + MarkNativeAsOptional("SetTopMenuTitleCaching"); } #endif diff --git a/env/include/usermessages.inc b/env/include/usermessages.inc index b960de3..5a9538d 100644 --- a/env/include/usermessages.inc +++ b/env/include/usermessages.inc @@ -43,6 +43,15 @@ enum UserMsg INVALID_MESSAGE_ID = -1, }; +/** + * UserMsg message serialization formats + */ +enum UserMessageType +{ + UM_BitBuf = 0, + UM_Protobuf, +}; + /** * @section Message Flags. */ @@ -54,6 +63,13 @@ enum UserMsg * @endsection */ +/** + * Returns usermessage serialization type used for the current engine + * + * @return The supported usermessage type. + */ +native UserMessageType:GetUserMessageType(); + /** * Returns the ID of a given message, or -1 on failure. * @@ -115,7 +131,7 @@ native EndMessage(); * Called when a message is hooked * * @param msg_id Message index. - * @param bf Handle to the input bit buffer of the message. + * @param msg Handle to the input bit buffer or protobuf. * @param players Array containing player indexes. * @param playersNum Number of players in the array. * @param reliable True if message is reliable, false otherwise. @@ -124,7 +140,7 @@ native EndMessage(); * blocks the message from being sent, and Plugin_Continue * resumes normal functionality. */ -functag public Action:MsgHook(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init); +functag public Action:MsgHook(UserMsg:msg_id, Handle:msg, const players[], playersNum, bool:reliable, bool:init); /** * Called when a message hook has completed. @@ -142,7 +158,7 @@ functag public MsgPostHook(UserMsg:msg_id, bool:sent); * @param intercept If intercept is true, message will be fully intercepted, * allowing the user to block the message. Otherwise, * the hook is normal and ignores the return value. - * @param notify Notification function. + * @param post Notification function. * @noreturn * @error Invalid message index. */ diff --git a/env/include/version.inc b/env/include/version.inc index 50accf5..b69d5c7 100644 --- a/env/include/version.inc +++ b/env/include/version.inc @@ -35,8 +35,15 @@ #endif #define _version_included -#define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */ -#define SOURCEMOD_V_MINOR 4 /**< SourceMod Minor version */ -#define SOURCEMOD_V_RELEASE 1 /**< SourceMod Release version */ +#tryinclude -#define SOURCEMOD_VERSION "1.4.1" /**< SourceMod version string (major.minor.release.build) */ +#if !defined _auto_version_included +#define SOURCEMOD_V_TAG "manual" +#define SOURCEMOD_V_REV 0 +#define SOURCEMOD_V_CSET "0" +#define SOURCEMOD_V_MAJOR 1 /**< SourceMod Major version */ +#define SOURCEMOD_V_MINOR 6 /**< SourceMod Minor version */ +#define SOURCEMOD_V_RELEASE 0 /**< SourceMod Release version */ + +#define SOURCEMOD_VERSION "1.6.0-manual" /**< SourceMod version string (major.minor.release-tag) */ +#endif diff --git a/env/include/version_auto.inc b/env/include/version_auto.inc new file mode 100644 index 0000000..16dd8d2 --- /dev/null +++ b/env/include/version_auto.inc @@ -0,0 +1,15 @@ + +#if defined _auto_version_included + #endinput +#endif +#define _auto_version_included + +#define SOURCEMOD_V_TAG "" +#define SOURCEMOD_V_CSET "95ab81f" +#define SOURCEMOD_V_MAJOR 1 +#define SOURCEMOD_V_MINOR 6 +#define SOURCEMOD_V_RELEASE 0 +#define SOURCEMOD_V_REV 4525 + +#define SOURCEMOD_VERSION "1.6.0" + \ No newline at end of file diff --git a/env/linux/bin/spcomp-1.6.0 b/env/linux/bin/spcomp-1.6.0 new file mode 100755 index 0000000..c609e7f Binary files /dev/null and b/env/linux/bin/spcomp-1.6.0 differ diff --git a/env/win32/bin/spcomp-1.6.0.exe b/env/win32/bin/spcomp-1.6.0.exe new file mode 100644 index 0000000..9539647 Binary files /dev/null and b/env/win32/bin/spcomp-1.6.0.exe differ