diff --git a/reapi/build.gradle b/reapi/build.gradle index 0d8a81a..67852cc 100644 --- a/reapi/build.gradle +++ b/reapi/build.gradle @@ -37,7 +37,7 @@ void postEvaluate(NativeBinarySpec b) { void setupToolchain(NativeBinarySpec b) { ToolchainConfig cfg = rootProject.createToolchainConfig(b) - cfg.projectInclude(project, '', '/src', '/include', '/include/metamod', '/include/cssdk/common', '/include/cssdk/dlls', '/include/cssdk/engine', '/include/cssdk/game_shared', '/include/cssdk/pm_shared', '/include/cssdk/public') + cfg.projectInclude(project, '', '/src', '/src/mods', '/src/natives', '/include', '/include/metamod', '/include/cssdk/common', '/include/cssdk/dlls', '/include/cssdk/engine', '/include/cssdk/game_shared', '/include/cssdk/pm_shared', '/include/cssdk/public') if (cfg instanceof MsvcToolchainConfig) { cfg.compilerOptions.pchConfig = new MsvcToolchainConfig.PrecompiledHeadersConfig( diff --git a/reapi/extra/amxmodx/scripting/include/reapi.inc b/reapi/extra/amxmodx/scripting/include/reapi.inc index 50bb268..2770ef3 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi.inc @@ -16,6 +16,7 @@ #include #include // NOTE: only for ReHLDS #include // NOTE: only for gamedll Counter-Strike (ReGameDLL_CS) +#include // NOTE: Common set of natives and forwards. // hookchain return type enum diff --git a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc index 21f10c3..dd855c0 100644 --- a/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc +++ b/reapi/extra/amxmodx/scripting/include/reapi_gamedll.inc @@ -33,7 +33,7 @@ native any:get_member_game(CSGameRules_Members:member, any:...); * * @return 1 on success. */ -native set_member(index, any:member, any:...); +native set_member(const index, any:member, any:...); /* * Returns a value from an entity's member @@ -42,29 +42,161 @@ native set_member(index, any:member, any:...); * @param member The specified member, look at the enum's with name *_Members * * @return If an integer or boolean or one byte, array or everything else is passed via 3rd argument and more, look at argument list for specified member -* -* An integer: new iTeam = get_member(id, m_iTeam); -* -* String array: new szName[32]; -* get_member(id, m_szNewName, charsmax(m_szNewName)); -* -* An int array: new iAmmoIndex = get_member(id, m_rgAmmo, 5); // number of the element -* */ -native any:get_member(index, any:member, any:...); +native any:get_member(const index, any:member, any:...); -native rg_set_animation(index, PLAYER_ANIM:playerAnim); -native rg_add_account(index, amount, bool:bTrackChange = true); -native rg_give_item(index, const pszName[]); -native rg_give_default_items(index); -native rg_give_shield(index, bool:bDeploy = true); -native rg_dmg_radius(Float:vecSrc[3], inflictor, attacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType); +/* +* Assign the number of the player animations. +* +* @param index Client index +* @param playerAnim Specific the number animation +* +* @noreturn +*/ +native rg_set_animation(const index, PLAYER_ANIM:playerAnim); + +/* +* Adds money to player's account. +* +* @param index Client index +* @param amount The amount of money +* @param bTrackChange If the bTrackChange is 1, the amount of money added will also be displayed. +* +* @noreturn +*/ +native rg_add_account(const index, amount, bool:bTrackChange = true); + +/* +* Gives item to player +* +* @param index Client index +* @param pszName Classname item +* +* @noreturn +*/ +native rg_give_item(const index, const pszName[]); + +/* +* Give the player default items +* +* @param index Client index +* +* @noreturn +*/ +native rg_give_default_items(const index); + +/* +* Give the player shield +* +* @param index Client index +* @param bDeploy to get shield from holster +* +* @noreturn +*/ +native rg_give_shield(const index, bool:bDeploy = true); + +/* +* Inflicts in a radius from the source position. +* +* @param vecSrc The source position +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* @param flDamage The amount of damage +* @param flRadius Radius damage +* @param iClassIgnore To specify classes that are immune to damage. +* @param bitsDamageType Damage type DMG_* +* +* @noreturn +*/ +native rg_dmg_radius(Float:vecSrc[3], const inflictor, const attacker, const Float:flDamage, const Float:flRadius, const iClassIgnore, const bitsDamageType); + +/* +* Resets the global multi damage accumulator +* +* @noreturn +*/ native rg_multidmg_clear(); -native rg_multidmg_apply(inflictor, attacker); -native rg_multidmg_add(inflictor, victim, Float:flDamage, bitsDamageType); -native rg_fire_bullets(inflictor, attacker, shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage); -native Float:[3] rg_fire_bullets3(inflictor, attacker, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, bool:bPistol, shared_rand); +/* +* inflicts contents of global multi damage register on victim +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* +* @noreturn +*/ +native rg_multidmg_apply(const inflictor, const attacker); -native rg_round_end(Float:tmDelay, WinStatus:st, ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default"); -native rg_update_teamscores(iCtsWins = 0, iTsWins = 0, bool:bAdd = true); +/* +* Adds damage the accumulator +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param victim A victim that takes damage +* @param flDamage The amount of damage +* @param bitsDamageType Damage type DMG_* +* +* @noreturn +*/ +native rg_multidmg_add(const inflictor, const victim, const Float:flDamage, const bitsDamageType); + +/* +* Fire bullets from entity +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* @param shots The number of shots +* @param vecSrc The source position of the barrel +* @param vecDirShooting Direction shooting +* @param vecSpread Spread +* @param flDistance Max shot distance +* @param iBulletType Bullet type +* @param iTracerFreq Tracer frequancy +* @param iDamage Damage amount +* +* @noreturn +*/ +native rg_fire_bullets(const inflictor, const attacker, const shots, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread[3], const Float:flDistance, const iBulletType, const iTracerFreq, const iDamage); + +/* +* Fire bullets from player's weapon +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* @param vecSrc The source position of the barrel +* @param vecDirShooting Direction shooting +* @param vecSpread Spread +* @param flDistance Max shot distance +* @param iPenetration The number of penetration +* @param iBulletType Bullet type +* @param iDamage Damage amount +* @param flRangeModifier Damage range modifier +* @param bPistol Pistol shot +* @param shared_rand Use player's random seed, get circular gaussian spread +* +* @return Float:[3] The result spread +*/ +native Float:[3] rg_fire_bullets3(const inflictor, const attacker, Float:vecSrc[3], Float:vecDirShooting[3], const Float:vecSpread, const Float:flDistance, const iPenetration, const iBulletType, const iDamage, const Float:flRangeModifier, const bool:bPistol, const shared_rand); + +/* +* Complete the round +* +* @param tmDelay Delay before the onset of a new round. +* @param st Which team won +* @param event The event is the end of the round +* @param message The message on round end +* @param sentence The sound at the end of the round +* +* @noreturn +*/ +native rg_round_end(const Float:tmDelay, const WinStatus:st, const ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default"); + +/* +* Update current scores +* +* @param iCtsWins The amount of wins to won +* @param iTsWins The amount of wins to won +* @param bAdd Adds the score to the current amount wins. +* +* @noreturn +*/ +native rg_update_teamscores(const iCtsWins = 0, const iTsWins = 0, const bool:bAdd = true); diff --git a/reapi/extra/amxmodx/scripting/include/reapi_misc.inc b/reapi/extra/amxmodx/scripting/include/reapi_misc.inc new file mode 100644 index 0000000..91886f0 --- /dev/null +++ b/reapi/extra/amxmodx/scripting/include/reapi_misc.inc @@ -0,0 +1,45 @@ +#if defined _reapi_misc_included + #endinput +#endif +#define _reapi_misc_included + +/* +* Checks whether the player is talking at this moment +* +* @param index Client index +* @return 1 if client is speaking, 0 otherwise +* +*/ +native VTC_IsClientSpeaking(index); + +/* +* Mutes this player +* +* @param index Client index +* @noreturn +*/ +native VTC_MuteClient(index); + +/* +* Unmutes this player +* +* @param index Client index +* @noreturn +*/ +native VTC_UnmuteClient(index); + +/* +* Called when player started talking +* +* @param index Client index +* @noreturn +*/ +forward VTC_OnClientStartSpeak(index); + +/* +* Called when player stopped talking +* +* @param index Client index +* @noreturn +*/ +forward VTC_OnClientStopSpeak(index); diff --git a/reapi/include/cssdk/dlls/osconfig.h b/reapi/include/cssdk/dlls/osconfig.h index 1d956a6..4190bb5 100644 --- a/reapi/include/cssdk/dlls/osconfig.h +++ b/reapi/include/cssdk/dlls/osconfig.h @@ -199,4 +199,4 @@ // DLLEXPORT is defined, for convenience. #define C_DLLEXPORT extern "C" DLLEXPORT -#define EXT_FUNC /*FORCE_STACK_ALIGN*/ +#define EXT_FUNC FORCE_STACK_ALIGN diff --git a/reapi/include/vtc_api.h b/reapi/include/vtc_api.h new file mode 100644 index 0000000..7ed3916 --- /dev/null +++ b/reapi/include/vtc_api.h @@ -0,0 +1,34 @@ +#pragma once + +#define VOICETRANSCODER_API_VERSION_MAJOR 1 +#define VOICETRANSCODER_API_VERSION_MINOR 0 + +template +class IVoidCallbackRegistry { +public: + virtual ~IVoidCallbackRegistry() {} + + typedef void (*callback_t)(t_args...); + + virtual void registerCallback(callback_t func) = 0; + virtual void unregisterCallback(callback_t func) = 0; +}; + +typedef IVoidCallbackRegistry ICallbackRegistry_ClientStartSpeak; +typedef IVoidCallbackRegistry ICallbackRegistry_ClientStopSpeak; + +class IVoiceTranscoderAPI { +public: + virtual ~IVoiceTranscoderAPI() {} + + virtual size_t GetMajorVersion() = 0; + virtual size_t GetMinorVersion() = 0; + + virtual bool IsClientSpeaking(size_t clientIndex) = 0; + + virtual ICallbackRegistry_ClientStartSpeak *ClientStartSpeak() = 0; + virtual ICallbackRegistry_ClientStopSpeak *ClientStopSpeak() = 0; + + virtual void MuteClient(size_t clientIndex) = 0; + virtual void UnmuteClient(size_t clientIndex) = 0; +}; diff --git a/reapi/msvc/reapi.vcxproj b/reapi/msvc/reapi.vcxproj index 7b9a12e..b36141a 100644 --- a/reapi/msvc/reapi.vcxproj +++ b/reapi/msvc/reapi.vcxproj @@ -194,17 +194,20 @@ + - - - - - + + + + + + + @@ -234,13 +237,15 @@ - - - - - + + + + + + + Create Create @@ -257,6 +262,7 @@ + @@ -307,7 +313,7 @@ true MultiThreadedDebug precompiled.h - $(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\src;$(ProjectDir)\..\src\mods;$(ProjectDir)\..\src\natives;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories) ProgramDatabase true false @@ -356,7 +362,7 @@ WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - $(ProjectDir)\..\src;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories) + $(ProjectDir)\..\src;$(ProjectDir)\..\src\mods;$(ProjectDir)\..\src\natives;$(ProjectDir)\..\version;$(ProjectDir)\..\include;$(ProjectDir)\..\include\metamod;$(ProjectDir)\..\include\cssdk\common;$(ProjectDir)\..\include\cssdk\dlls;$(ProjectDir)\..\include\cssdk\engine;$(ProjectDir)\..\include\cssdk\game_shared;$(ProjectDir)\..\include\cssdk\pm_shared;$(ProjectDir)\..\include\cssdk\public;%(AdditionalIncludeDirectories) MultiThreaded precompiled.h AnySuitable diff --git a/reapi/msvc/reapi.vcxproj.filters b/reapi/msvc/reapi.vcxproj.filters index f00d7b0..a361ede 100644 --- a/reapi/msvc/reapi.vcxproj.filters +++ b/reapi/msvc/reapi.vcxproj.filters @@ -52,6 +52,9 @@ {1e41b4f5-768c-437f-af6d-51432194e332} + + {669b4426-091f-4cac-9281-f5585a2922fb} + @@ -597,12 +600,6 @@ src - - src - - - src - src @@ -621,15 +618,30 @@ src - + + src\mods + + + src\mods + + + src\mods + + src\natives - + src\natives - + src\natives + + src\natives + + + include + @@ -659,12 +671,6 @@ src - - src - - - src - src @@ -689,18 +695,30 @@ src - - src\natives - - - src\natives - - - src\natives - src + + src\mods + + + src\mods + + + src\mods + + + src\natives + + + src\natives + + + src\natives + + + src\natives + @@ -725,6 +743,9 @@ amxmodx\scripting\include + + amxmodx\scripting\include + diff --git a/reapi/src/amxxmodule.cpp b/reapi/src/amxxmodule.cpp index 1a998ef..a5e15cf 100644 --- a/reapi/src/amxxmodule.cpp +++ b/reapi/src/amxxmodule.cpp @@ -162,6 +162,7 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc) RegisterNatives_HookChains(); RegisterNatives_Members(); RegisterNatives_Misc(); + RegisterNatives_Vtc(); return AMXX_OK; } @@ -176,6 +177,12 @@ C_DLLEXPORT int AMXX_PluginsLoaded() int iFwd = g_amxxapi.RegisterForward("__reapi_version_check", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE); g_amxxapi.ExecuteForward(iFwd, REAPI_VERISON_MAJOR, REAPI_VERISON_MINOR); + if (api_cfg.hasVTC()) { + + g_iClientStartSpeak = g_amxxapi.RegisterForward("VTC_OnClientStartSpeak", ET_IGNORE, FP_CELL, FP_DONE); + g_iClientStopSpeak = g_amxxapi.RegisterForward("VTC_OnClientStopSpeak", ET_IGNORE, FP_CELL, FP_DONE); + } + return AMXX_OK; } diff --git a/reapi/src/amxxmodule.h b/reapi/src/amxxmodule.h index 11cadba..fe2e6c6 100644 --- a/reapi/src/amxxmodule.h +++ b/reapi/src/amxxmodule.h @@ -55,7 +55,7 @@ struct amxx_module_info_s /* calling convention for native functions */ #if !defined AMX_NATIVE_CALL -#define AMX_NATIVE_CALL FORCE_STACK_ALIGN +#define AMX_NATIVE_CALL EXT_FUNC #endif /* calling convention for all interface functions and callback functions */ #if !defined AMXAPI diff --git a/reapi/src/api_config.cpp b/reapi/src/api_config.cpp index 6e978ee..38ae618 100644 --- a/reapi/src/api_config.cpp +++ b/reapi/src/api_config.cpp @@ -2,7 +2,7 @@ CAPI_Config api_cfg; -CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false) +CAPI_Config::CAPI_Config() : m_api_rehlds(false), m_api_regame(false), m_api_vtc(false) { } @@ -11,6 +11,7 @@ bool CAPI_Config::Init() { m_api_rehlds = RehldsApi_Init(); m_api_regame = RegamedllApi_Init(); + m_api_vtc = VTC_Api_Init(); return true; } diff --git a/reapi/src/api_config.h b/reapi/src/api_config.h index a1f9891..87cb35b 100644 --- a/reapi/src/api_config.h +++ b/reapi/src/api_config.h @@ -10,6 +10,7 @@ public: bool hasReHLDS() const { return m_api_rehlds; } bool hasReGameDLL() const { return m_api_regame; } + bool hasVTC() const { return m_api_vtc; } void ServerActivate() const; void ServerDeactivate() const; @@ -20,7 +21,7 @@ private: bool m_api_regame; // some useful functions #2 // future plans? - //bool m_api_vtc; // for gag + bool m_api_vtc; // for gag //bool m_api_revoice; // for gag #2 //bool m_api_reunion; // for information about authorization client //bool m_api_rechecker; // for detection when checking and adding few files diff --git a/reapi/src/hook_callback.cpp b/reapi/src/hook_callback.cpp index 2d330a4..b05e9ce 100644 --- a/reapi/src/hook_callback.cpp +++ b/reapi/src/hook_callback.cpp @@ -383,3 +383,15 @@ bool RoundEnd(IReGameHook_RoundEnd *chain, int winStatus, ScenarionEventEndRound return callForward(RG_RoundEnd, original, winStatus, event, tmDelay); } + +int g_iClientStartSpeak, g_iClientStopSpeak; + +void ClientStartSpeak(size_t clientIndex) +{ + g_amxxapi.ExecuteForward(g_iClientStartSpeak, clientIndex); +} + +void ClientStopSpeak(size_t clientIndex) +{ + g_amxxapi.ExecuteForward(g_iClientStopSpeak, clientIndex); +} diff --git a/reapi/src/hook_callback.h b/reapi/src/hook_callback.h index 215eeb7..aef4072 100644 --- a/reapi/src/hook_callback.h +++ b/reapi/src/hook_callback.h @@ -234,3 +234,9 @@ void CBasePlayer_AddAccount(IReGameHook_CBasePlayer_AddAccount *chain, CBasePlay void CBasePlayer_GiveShield(IReGameHook_CBasePlayer_GiveShield *chain, CBasePlayer *pthis, bool bDeploy); void CBaseAnimating_ResetSequenceInfo(IReGameHook_CBaseAnimating_ResetSequenceInfo *chain, CBaseAnimating *pthis); + +extern int g_iClientStartSpeak; +extern int g_iClientStopSpeak; + +void ClientStartSpeak(size_t clientIndex); +void ClientStopSpeak(size_t clientIndex); diff --git a/reapi/src/main.cpp b/reapi/src/main.cpp index f82b5d1..d17552a 100644 --- a/reapi/src/main.cpp +++ b/reapi/src/main.cpp @@ -15,6 +15,11 @@ void OnMetaDetach() { // clear all hooks? g_hookManager.clearHandlers(); + + if (api_cfg.hasVTC()) { + g_pVoiceTranscoderApi->ClientStartSpeak()->unregisterCallback(&ClientStartSpeak); + g_pVoiceTranscoderApi->ClientStopSpeak()->unregisterCallback(&ClientStopSpeak); + } } void ServerActivate(edict_t *pEdictList, int edictCount, int clientMax) diff --git a/reapi/src/mod_regamedll_api.cpp b/reapi/src/mods/mod_regamedll_api.cpp similarity index 100% rename from reapi/src/mod_regamedll_api.cpp rename to reapi/src/mods/mod_regamedll_api.cpp diff --git a/reapi/src/mod_regamedll_api.h b/reapi/src/mods/mod_regamedll_api.h similarity index 100% rename from reapi/src/mod_regamedll_api.h rename to reapi/src/mods/mod_regamedll_api.h diff --git a/reapi/src/mod_rehlds_api.cpp b/reapi/src/mods/mod_rehlds_api.cpp similarity index 100% rename from reapi/src/mod_rehlds_api.cpp rename to reapi/src/mods/mod_rehlds_api.cpp diff --git a/reapi/src/mod_rehlds_api.h b/reapi/src/mods/mod_rehlds_api.h similarity index 100% rename from reapi/src/mod_rehlds_api.h rename to reapi/src/mods/mod_rehlds_api.h diff --git a/reapi/src/mods/mod_vtc_api.cpp b/reapi/src/mods/mod_vtc_api.cpp new file mode 100644 index 0000000..e91cfe2 --- /dev/null +++ b/reapi/src/mods/mod_vtc_api.cpp @@ -0,0 +1,33 @@ +#include "precompiled.h" + +IVoiceTranscoderAPI *g_pVoiceTranscoderApi; + +bool VTC_Api_Init() +{ + if (g_RehldsApi == nullptr) + return false; + + g_pVoiceTranscoderApi = (IVoiceTranscoderAPI *)g_RehldsApi->GetFuncs()->GetPluginApi("VoiceTranscoder"); + + if (g_pVoiceTranscoderApi == nullptr) { + return false; + } + + int majorVersion = g_pVoiceTranscoderApi->GetMajorVersion(); + int minorVersion = g_pVoiceTranscoderApi->GetMinorVersion(); + + if (majorVersion != VOICETRANSCODER_API_VERSION_MAJOR) { + UTIL_LogPrintf("[%s]: VTC Api major version mismatch; expected %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MAJOR, majorVersion); + return false; + } + + if (minorVersion < VOICETRANSCODER_API_VERSION_MINOR) { + UTIL_LogPrintf("[%s]: VTC Api minor version mismatch; expected at least %d, real %d\n", Plugin_info.logtag, VOICETRANSCODER_API_VERSION_MINOR, minorVersion); + return false; + } + + g_pVoiceTranscoderApi->ClientStartSpeak()->registerCallback(&ClientStartSpeak); + g_pVoiceTranscoderApi->ClientStopSpeak()->registerCallback(&ClientStopSpeak); + + return true; +} diff --git a/reapi/src/mods/mod_vtc_api.h b/reapi/src/mods/mod_vtc_api.h new file mode 100644 index 0000000..323288a --- /dev/null +++ b/reapi/src/mods/mod_vtc_api.h @@ -0,0 +1,5 @@ +#pragma once + +extern IVoiceTranscoderAPI *g_pVoiceTranscoderApi; + +extern bool VTC_Api_Init(); diff --git a/reapi/src/natives_hookchains.cpp b/reapi/src/natives/natives_hookchains.cpp similarity index 100% rename from reapi/src/natives_hookchains.cpp rename to reapi/src/natives/natives_hookchains.cpp diff --git a/reapi/src/natives_hookchains.h b/reapi/src/natives/natives_hookchains.h similarity index 100% rename from reapi/src/natives_hookchains.h rename to reapi/src/natives/natives_hookchains.h diff --git a/reapi/src/natives_members.cpp b/reapi/src/natives/natives_members.cpp similarity index 100% rename from reapi/src/natives_members.cpp rename to reapi/src/natives/natives_members.cpp diff --git a/reapi/src/natives_members.h b/reapi/src/natives/natives_members.h similarity index 100% rename from reapi/src/natives_members.h rename to reapi/src/natives/natives_members.h diff --git a/reapi/src/natives_misc.cpp b/reapi/src/natives/natives_misc.cpp similarity index 66% rename from reapi/src/natives_misc.cpp rename to reapi/src/natives/natives_misc.cpp index 0523d23..524a6e9 100644 --- a/reapi/src/natives_misc.cpp +++ b/reapi/src/natives/natives_misc.cpp @@ -1,6 +1,15 @@ #include "precompiled.h" -// native rg_set_animation(index, PLAYER_ANIM:playerAnim); +/* +* Assign the number of the player animations. +* +* @param index Client index +* @param playerAnim Specific the number animation +* +* @noreturn +* +* native rg_set_animation(index, PLAYER_ANIM:playerAnim); +*/ static cell AMX_NATIVE_CALL rg_set_animation(AMX *amx, cell *params) { enum args_e { arg_count, arg_index, arg_anim }; @@ -14,7 +23,17 @@ static cell AMX_NATIVE_CALL rg_set_animation(AMX *amx, cell *params) return TRUE; } -// native rg_add_account(index, amount, bool:bTrackChange = true); +/* +* Adds money to player's account. +* +* @param index Client index +* @param amount The amount of money +* @param bTrackChange If the bTrackChange is 1, the amount of money added will also be displayed. +* +* @noreturn +* +* native rg_add_account(index, amount, bool:bTrackChange = true); +*/ static cell AMX_NATIVE_CALL rg_add_account(AMX *amx, cell *params) { enum args_e { arg_count, arg_index, arg_amount, arg_track_change }; @@ -28,7 +47,16 @@ static cell AMX_NATIVE_CALL rg_add_account(AMX *amx, cell *params) return TRUE; } -// native rg_give_item(index, const pszName[]); +/* +* Gives item to player +* +* @param index Client index +* @param pszName Classname item +* +* @noreturn +* +* native rg_give_item(index, const pszName[]); +*/ static cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params) { enum args_e { arg_count, arg_index, arg_item }; @@ -44,7 +72,15 @@ static cell AMX_NATIVE_CALL rg_give_item(AMX *amx, cell *params) return TRUE; } -// native rg_give_default_items(index); +/* +* Give the player default items +* +* @param index Client index +* +* @noreturn +* +* native rg_give_default_items(index); +*/ static cell AMX_NATIVE_CALL rg_give_default_items(AMX *amx, cell *params) { enum args_e { arg_count, arg_index }; @@ -58,7 +94,16 @@ static cell AMX_NATIVE_CALL rg_give_default_items(AMX *amx, cell *params) return TRUE; } -// native rg_give_shield(index, bool:bDeploy = true); +/* +* Give the player shield +* +* @param index Client index +* @param bDeploy to get shield from holster +* +* @noreturn +* +* native rg_give_shield(index, bool:bDeploy = true); +*/ static cell AMX_NATIVE_CALL rg_give_shield(AMX *amx, cell *params) { enum args_e { arg_count, arg_index, arg_deploy }; @@ -72,7 +117,21 @@ static cell AMX_NATIVE_CALL rg_give_shield(AMX *amx, cell *params) return TRUE; } -// native rg_dmg_radius(Float:vecSrc[3], inflictor, attacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType); +/* +* Inflicts in a radius from the source position. +* +* @param vecSrc The source position +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* @param flDamage The amount of damage +* @param flRadius Radius damage +* @param iClassIgnore To specify classes that are immune to damage. +* @param bitsDamageType Damage type DMG_* +* +* @noreturn +* +* native rg_dmg_radius(Float:vecSrc[3], inflictor, attacker, Float:flDamage, Float:flRadius, iClassIgnore, bitsDamageType); +*/ static cell AMX_NATIVE_CALL rg_dmg_radius(AMX *amx, cell *params) { enum args_e { arg_count, arg_vec, arg_inflictor, arg_attacker, arg_damage, arg_radius, arg_ignore_class, arg_dmg_type }; @@ -87,14 +146,29 @@ static cell AMX_NATIVE_CALL rg_dmg_radius(AMX *amx, cell *params) return TRUE; } -// native rg_multidmg_clear(); +/* +* Resets the global multi damage accumulator +* +* @noreturn +* +* native rg_multidmg_clear(); +*/ static cell AMX_NATIVE_CALL rg_multidmg_clear(AMX *amx, cell *params) { g_ReGameFuncs->ClearMultiDamage(); return TRUE; } -// native rg_multidmg_apply(inflictor, attacker); +/* +* inflicts contents of global multi damage register on victim +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* +* @noreturn +* +* native rg_multidmg_apply(inflictor, attacker); +*/ static cell AMX_NATIVE_CALL rg_multidmg_apply(AMX *amx, cell *params) { enum args_e { arg_count, arg_inflictor, arg_attacker }; @@ -106,7 +180,18 @@ static cell AMX_NATIVE_CALL rg_multidmg_apply(AMX *amx, cell *params) return TRUE; } -// native rg_multidmg_add(inflictor, victim, Float:flDamage, bitsDamageType); +/* +* Adds damage the accumulator +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param victim A victim that takes damage +* @param flDamage The amount of damage +* @param bitsDamageType Damage type DMG_* +* +* @noreturn +* +* native rg_multidmg_add(inflictor, victim, Float:flDamage, bitsDamageType); +*/ static cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params) { enum args_e { arg_count, arg_inflictor, arg_victim, arg_damage, arg_dmg_type }; @@ -122,7 +207,24 @@ static cell AMX_NATIVE_CALL rg_multidmg_add(AMX *amx, cell *params) return TRUE; } -// native rg_fire_bullets(inflictor, attacker, shots, Float:vecSrc[3], Float:vecDirShooting[3], Float::vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage); +/* +* Fire bullets from entity +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* @param shots The number of shots +* @param vecSrc The source position of the barrel +* @param vecDirShooting Direction shooting +* @param vecSpread Spread +* @param flDistance Max shot distance +* @param iBulletType Bullet type +* @param iTracerFreq Tracer frequancy +* @param iDamage Damage amount +* +* @noreturn +* +* native rg_fire_bullets(inflictor, attacker, shots, Float:vecSrc[3], Float:vecDirShooting[3], Float::vecSpread[3], Float:flDistance, iBulletType, iTracerFreq, iDamage); +*/ static cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params) { enum args_e { arg_count, arg_inflictor, arg_attacker, arg_shots, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_bullet_type, arg_tracefrq, arg_dmg }; @@ -143,7 +245,26 @@ static cell AMX_NATIVE_CALL rg_fire_bullets(AMX *amx, cell *params) return TRUE; } -// native Float:[3] rg_fire_bullets3(inflictor, attacker, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, bool:bPistol, shared_rand); +/* +* Fire bullets from player's weapon +* +* @param inflictor Inflictor is the entity that caused the damage (such as a gun) +* @param attacker Attacker is the entity that tirggered the damage (such as the gun's owner). +* @param vecSrc The source position of the barrel +* @param vecDirShooting Direction shooting +* @param vecSpread Spread +* @param flDistance Max shot distance +* @param iPenetration The number of penetration +* @param iBulletType Bullet type +* @param iDamage Damage amount +* @param flRangeModifier Damage range modifier +* @param bPistol Pistol shot +* @param shared_rand Use player's random seed, get circular gaussian spread +* +* @return Float:[3] The result spread +* +* native Float:[3] rg_fire_bullets3(inflictor, attacker, Float:vecSrc[3], Float:vecDirShooting[3], Float:vecSpread, Float:flDistance, iPenetration, iBulletType, iDamage, Float:flRangeModifier, bool:bPistol, shared_rand); +*/ static cell AMX_NATIVE_CALL rg_fire_bullets3(AMX *amx, cell *params) { enum args_e { arg_count, arg_inflictor, arg_attacker, arg_vecSrc, arg_dir, arg_spread, arg_dist, arg_penetration, arg_bullet_type, arg_dmg, arg_range_mod, arg_pistol, arg_rand, arg_out }; @@ -188,7 +309,19 @@ struct { { "#Game_Commencing", "", WINSTATUS_DRAW }, // ROUND_GAME_COMMENCE }; -// native rg_round_end(Float:tmDelay, WinStatus:st, ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default"); +/* +* Complete the round +* +* @param tmDelay Delay before the onset of a new round. +* @param st Which team won +* @param event The event is the end of the round +* @param message The message on round end +* @param sentence The sound at the end of the round +* +* @noreturn +* +* native rg_round_end(Float:tmDelay, WinStatus:st, ScenarionEventEndRound:event = ROUND_NONE, const message[] = "default", const sentence[] = "default"); +*/ static cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params) { enum args_e { arg_count, arg_delay, arg_win, arg_event, arg_message, arg_sentence, arg_silent }; @@ -223,7 +356,17 @@ static cell AMX_NATIVE_CALL rg_round_end(AMX *amx, cell *params) return TRUE; } -// native rg_update_teamscores(iCtsWins = 0, iTsWins = 0, bool:bAdd = true); +/* +* Update current scores +* +* @param iCtsWins The amount of wins to won +* @param iTsWins The amount of wins to won +* @param bAdd Adds the score to the current amount wins. +* +* @noreturn +* +* native rg_update_teamscores(iCtsWins = 0, iTsWins = 0, bool:bAdd = true); +*/ static cell AMX_NATIVE_CALL rg_update_teamscores(AMX *amx, cell *params) { enum args_e { arg_count, arg_cts, arg_ts, arg_add }; diff --git a/reapi/src/natives_misc.h b/reapi/src/natives/natives_misc.h similarity index 100% rename from reapi/src/natives_misc.h rename to reapi/src/natives/natives_misc.h diff --git a/reapi/src/natives/natives_vtc.cpp b/reapi/src/natives/natives_vtc.cpp new file mode 100644 index 0000000..5e02a12 --- /dev/null +++ b/reapi/src/natives/natives_vtc.cpp @@ -0,0 +1,61 @@ +#include "precompiled.h" + +/* +* Checks whether the player is talking at this moment +* +* @param index Client index +* @return 1 if client is speaking, 0 otherwise +* +* native VTC_IsClientSpeaking(index); +*/ +static cell AMX_NATIVE_CALL VTC_IsClientSpeaking(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index }; + return g_pVoiceTranscoderApi->IsClientSpeaking((size_t)params[arg_index]); +} + +/* +* Mutes this player +* +* @param index Client index +* @noreturn +* +* native VTC_MuteClient(index); +*/ +static cell AMX_NATIVE_CALL VTC_MuteClient(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index }; + g_pVoiceTranscoderApi->MuteClient((size_t)params[arg_index]); + + return FALSE; +} + +/* +* Unmutes this player +* +* @param index Client index +* @noreturn +* +* native VTC_UnmuteClient(index); +*/ +static cell AMX_NATIVE_CALL VTC_UnmuteClient(AMX *amx, cell *params) +{ + enum args_e { arg_count, arg_index }; + g_pVoiceTranscoderApi->UnmuteClient((size_t)params[arg_index]); + + return FALSE; +} + +AMX_NATIVE_INFO Vtc_Natives[] = +{ + { "VTC_IsClientSpeaking", VTC_IsClientSpeaking }, + { "VTC_MuteClient", VTC_MuteClient }, + { "VTC_UnmuteClient", VTC_UnmuteClient }, + + { nullptr, nullptr } +}; + +void RegisterNatives_Vtc() +{ + g_amxxapi.AddNatives(Vtc_Natives); +} diff --git a/reapi/src/natives/natives_vtc.h b/reapi/src/natives/natives_vtc.h new file mode 100644 index 0000000..d77db48 --- /dev/null +++ b/reapi/src/natives/natives_vtc.h @@ -0,0 +1,3 @@ +#pragma once + +void RegisterNatives_Vtc(); diff --git a/reapi/src/precompiled.h b/reapi/src/precompiled.h index f25eb68..3987e23 100644 --- a/reapi/src/precompiled.h +++ b/reapi/src/precompiled.h @@ -21,10 +21,8 @@ #include "amxxmodule.h" #include "osconfig.h" -// gamedll -#include "gamerules.h" - // regamedll API +#include "gamerules.h" #include "regamedll_api.h" #include "mod_regamedll_api.h" @@ -32,13 +30,19 @@ #include "rehlds_api.h" #include "mod_rehlds_api.h" +// VTC API +#include "vtc_api.h" +#include "mod_vtc_api.h" + #include "api_config.h" #include "hook_manager.h" #include "hook_callback.h" #include "member_list.h" + #include "natives_hookchains.h" #include "natives_members.h" #include "natives_misc.h" +#include "natives_vtc.h" #undef DLLEXPORT #ifdef _WIN32