From d6d78ddbe1903aebfabbfb75135d30da290d653e Mon Sep 17 00:00:00 2001 From: Alejo Date: Tue, 16 Nov 2021 18:02:27 -0300 Subject: [PATCH 01/32] CVar `mp_max_alive_name_changes` --- README.md | 1 + dist/game.cfg | 8 ++++++++ regamedll/dlls/API/CSPlayer.cpp | 2 ++ regamedll/dlls/game.cpp | 2 ++ regamedll/dlls/game.h | 1 + regamedll/dlls/player.cpp | 9 +++++++++ regamedll/public/regamedll/API/CSPlayer.h | 15 ++++++++++++++- 7 files changed, 37 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b25aab8a9..1adb7c1c5 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | sv_autobunnyhopping | 0 | 0 | 1 | Players automatically re-jump while holding jump button.
`0` disabled
`1` enabled | | sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.
`0` disabled
`1` enabled | | mp_plant_c4_anywhere | 0 | 0 | 1 | When set, players can plant anywhere, not only in bombsites.
`0` disabled
`1` enabled | +| mp_max_alive_name_changes | -1 | -1 | - | Maximum amount of nickname changes when alive
`-1` unlimited
`0` Blocks name changes
`>0` Allow to change arbitrary amount of nicks | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 09766cd04..61a7d84ae 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -483,3 +483,11 @@ sv_enablebunnyhopping 0 // // Default value: "0" mp_plant_c4_anywhere 0 + +// Maximum amount of nickname changes before next respawn. +// -1 - unlimited (default behaviour) +// 0 - Blocks name changes +// >0 - Allow to change arbitrary amount of nicks +// +// Default value: "-1" +mp_max_alive_name_changes -1 diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index 6b11725fe..96fab9054 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -541,12 +541,14 @@ void CCSPlayer::Reset() m_bGameForcingRespawn = false; m_bAutoBunnyHopping = false; m_bMegaBunnyJumping = false; + m_iAliveNameChanges = 0; } void CCSPlayer::OnSpawn() { m_bGameForcingRespawn = false; m_flRespawnPending = 0.0f; + m_iAliveNameChanges = 0; } void CCSPlayer::OnKilled() diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 14dc2d11e..e6741356a 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -162,6 +162,7 @@ cvar_t allchat = { "sv_allchat", "0", 0, 0.0f, nullptr cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr }; +cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; void GameDLL_Version_f() { @@ -393,6 +394,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&sv_autobunnyhopping); CVAR_REGISTER(&sv_enablebunnyhopping); CVAR_REGISTER(&plant_c4_anywhere); + CVAR_REGISTER(&max_alive_name_changes); // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 5c75387b7..344b4f6db 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -188,6 +188,7 @@ extern cvar_t allchat; extern cvar_t sv_autobunnyhopping; extern cvar_t sv_enablebunnyhopping; extern cvar_t plant_c4_anywhere; +extern cvar_t max_alive_name_changes; #endif diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index c48545051..1aed0bdf7 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -173,6 +173,11 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c } #endif +#ifdef REGAMEDLL_API + if (!CSPlayer()->CanChangeName()) + return false; +#endif + if (pev->deadflag != DEAD_NO) { m_bHasChangedName = true; @@ -191,6 +196,10 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c WRITE_STRING(szNewName); MESSAGE_END(); +#ifdef REGAMEDLL_API + CSPlayer()->m_iAliveNameChanges++; +#endif + UTIL_LogPrintf("\"%s<%i><%s><%s>\" changed name to \"%s\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam), szNewName); return true; } diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 8410d95f7..5619397af 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -49,7 +49,8 @@ class CCSPlayer: public CCSMonster { m_bGameForcingRespawn(false), m_bAutoBunnyHopping(false), m_bMegaBunnyJumping(false), - m_bPlantC4Anywhere(false) + m_bPlantC4Anywhere(false), + m_iAliveNameChanges(0) { m_szModel[0] = '\0'; } @@ -106,6 +107,7 @@ class CCSPlayer: public CCSMonster { void OnKilled(); CBasePlayer *BasePlayer() const; + bool CanChangeName() const; public: enum EProtectionState @@ -131,8 +133,19 @@ class CCSPlayer: public CCSMonster { bool m_bAutoBunnyHopping; bool m_bMegaBunnyJumping; bool m_bPlantC4Anywhere; + int m_iAliveNameChanges; }; +inline bool CCSPlayer::CanChangeName() const +{ +#ifdef REGAMEDLL_ADD + if (max_alive_name_changes.value >= 0 && m_iAliveNameChanges >= max_alive_name_changes.value) + return false; +#endif + + return true; +} + // Inlines inline CBasePlayer *CCSPlayer::BasePlayer() const { From 2617399572d73cca5734cc0361fc6f652b9a63ca Mon Sep 17 00:00:00 2001 From: Alejo Date: Fri, 19 Nov 2021 21:07:08 -0300 Subject: [PATCH 02/32] CVar `sv_legacy_restart_entities` --- regamedll/dlls/game.cpp | 2 + regamedll/dlls/game.h | 1 + regamedll/dlls/multiplay_gamerules.cpp | 51 +++++++++++++++++--------- 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index e6741356a..106b96fb8 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -163,6 +163,7 @@ cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr }; cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; +cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr }; void GameDLL_Version_f() { @@ -395,6 +396,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&sv_enablebunnyhopping); CVAR_REGISTER(&plant_c4_anywhere); CVAR_REGISTER(&max_alive_name_changes); + CVAR_REGISTER(&legacy_restart_entities); // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 344b4f6db..b593fd84a 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -189,6 +189,7 @@ extern cvar_t sv_autobunnyhopping; extern cvar_t sv_enablebunnyhopping; extern cvar_t plant_c4_anywhere; extern cvar_t max_alive_name_changes; +extern cvar_t legacy_restart_entities; #endif diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 7824ef516..eb7e6a66f 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -607,11 +607,16 @@ LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CleanUpMap) void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() { #ifdef REGAMEDLL_FIXES - UTIL_RestartOther("multi_manager"); +#ifdef REGAMEDLL_ADD + if (legacy_restart_entities.value > 0) +#endif + { + UTIL_RestartOther("multi_manager"); - // Release or reset everything entities in depending of flags ObjectCaps - // (FCAP_MUST_RESET / FCAP_MUST_RELEASE) - UTIL_ResetEntities(); + // Release or reset everything entities in depending of flags ObjectCaps + // (FCAP_MUST_RESET / FCAP_MUST_RELEASE) + UTIL_ResetEntities(); + } #endif // Recreate all the map entities from the map data (preserving their indices), @@ -622,11 +627,16 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() UTIL_RestartOther("func_door"); #ifdef REGAMEDLL_FIXES - UTIL_RestartOther("func_button"); - UTIL_RestartOther("func_rot_button"); - UTIL_RestartOther("env_render"); - UTIL_RestartOther("env_spark"); - UTIL_RestartOther("trigger_push"); +#ifdef REGAMEDLL_ADD + if (legacy_restart_entities.value > 0) +#endif + { + UTIL_RestartOther("func_button"); + UTIL_RestartOther("func_rot_button"); + UTIL_RestartOther("env_render"); + UTIL_RestartOther("env_spark"); + UTIL_RestartOther("trigger_push"); + } #endif UTIL_RestartOther("func_water"); @@ -639,15 +649,20 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() UTIL_RestartOther("env_sprite"); #ifdef REGAMEDLL_FIXES - UTIL_RestartOther("trigger_once"); - UTIL_RestartOther("func_wall_toggle"); - UTIL_RestartOther("func_healthcharger"); - UTIL_RestartOther("func_recharge"); - UTIL_RestartOther("trigger_hurt"); - UTIL_RestartOther("multisource"); - UTIL_RestartOther("env_beam"); - UTIL_RestartOther("env_laser"); - UTIL_RestartOther("trigger_auto"); +#ifdef REGAMEDLL_ADD + if (legacy_restart_entities.value > 0) +#endif + { + UTIL_RestartOther("trigger_once"); + UTIL_RestartOther("func_wall_toggle"); + UTIL_RestartOther("func_healthcharger"); + UTIL_RestartOther("func_recharge"); + UTIL_RestartOther("trigger_hurt"); + UTIL_RestartOther("multisource"); + UTIL_RestartOther("env_beam"); + UTIL_RestartOther("env_laser"); + UTIL_RestartOther("trigger_auto"); + } #endif // Remove grenades and C4 From c08796f67e0e6d448d34f8b1da521d3a19759aa7 Mon Sep 17 00:00:00 2001 From: Alejo Date: Sat, 20 Nov 2021 11:49:05 -0300 Subject: [PATCH 03/32] Fix "if" condition --- README.md | 1 + dist/game.cfg | 7 +++++++ regamedll/dlls/multiplay_gamerules.cpp | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1adb7c1c5..e248f986c 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.
`0` disabled
`1` enabled | | mp_plant_c4_anywhere | 0 | 0 | 1 | When set, players can plant anywhere, not only in bombsites.
`0` disabled
`1` enabled | | mp_max_alive_name_changes | -1 | -1 | - | Maximum amount of nickname changes when alive
`-1` unlimited
`0` Blocks name changes
`>0` Allow to change arbitrary amount of nicks | +| sv_legacy_restart_entities | 0 | 0 | 1 | Legacy restart of entities on new round
`0` disabled
`1` enabled | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 61a7d84ae..e9d395f57 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -491,3 +491,10 @@ mp_plant_c4_anywhere 0 // // Default value: "-1" mp_max_alive_name_changes -1 + +// Legacy restart of entities on new round. +// 0 - disabled (default behaviour) +// 1 - enabled +// +// Default value: "0" +sv_legacy_restart_entities 0 diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index eb7e6a66f..69077f37f 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -608,7 +608,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() { #ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_ADD - if (legacy_restart_entities.value > 0) + if (!(bool)legacy_restart_entities.value) #endif { UTIL_RestartOther("multi_manager"); @@ -628,7 +628,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() #ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_ADD - if (legacy_restart_entities.value > 0) + if (!(bool)legacy_restart_entities.value) #endif { UTIL_RestartOther("func_button"); @@ -650,7 +650,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() #ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_ADD - if (legacy_restart_entities.value > 0) + if (!(bool)legacy_restart_entities.value) #endif { UTIL_RestartOther("trigger_once"); From 52f79cfdad594cdd20f27ad694908a361e0690b4 Mon Sep 17 00:00:00 2001 From: Giovani Ferraro Trivelli Date: Sun, 28 Nov 2021 10:39:13 -0300 Subject: [PATCH 04/32] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78a8b7d3f..b8164163e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: C/C++ CI on: push: - branches: [master] + branches: [master, nostalgia] paths-ignore: - '**.md' From 7fc388d6cd9267617b85f04fd19c6d3ed9e1cf9b Mon Sep 17 00:00:00 2001 From: Alejo Date: Sun, 28 Nov 2021 15:59:33 -0300 Subject: [PATCH 05/32] Cambio funcionamiento cvar --- regamedll/dlls/player.cpp | 13 ++++++++++--- regamedll/public/regamedll/API/CSPlayer.h | 11 ----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 1aed0bdf7..3f18b6517 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -173,12 +173,19 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c } #endif -#ifdef REGAMEDLL_API - if (!CSPlayer()->CanChangeName()) +#ifdef REGAMEDLL_ADD + if (max_alive_name_changes.value <= 0) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Command_Not_Available"); return false; + } #endif - if (pev->deadflag != DEAD_NO) + if (pev->deadflag != DEAD_NO +#if defined REGAMEDLL_API && REGAMEDLL_ADD + || CSPlayer()->m_iAliveNameChanges >= max_alive_name_changes.value +#endif + ) { m_bHasChangedName = true; Q_snprintf(m_szNewName, sizeof(m_szNewName), "%s", szNewName); diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 5619397af..9ce4c15d0 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -107,7 +107,6 @@ class CCSPlayer: public CCSMonster { void OnKilled(); CBasePlayer *BasePlayer() const; - bool CanChangeName() const; public: enum EProtectionState @@ -136,16 +135,6 @@ class CCSPlayer: public CCSMonster { int m_iAliveNameChanges; }; -inline bool CCSPlayer::CanChangeName() const -{ -#ifdef REGAMEDLL_ADD - if (max_alive_name_changes.value >= 0 && m_iAliveNameChanges >= max_alive_name_changes.value) - return false; -#endif - - return true; -} - // Inlines inline CBasePlayer *CCSPlayer::BasePlayer() const { From 1d9a6b903bff5fe3807709d7e8a8f86cfb270e3d Mon Sep 17 00:00:00 2001 From: Alejo Date: Mon, 10 Jan 2022 13:37:57 -0300 Subject: [PATCH 06/32] `sv_block_vote_commands` --- README.md | 1 + dist/game.cfg | 7 +++++++ regamedll/dlls/client.cpp | 12 ++++++++++-- regamedll/dlls/client.h | 7 +++++++ regamedll/dlls/game.cpp | 1 + regamedll/dlls/game.h | 1 + 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b25aab8a9..67d999e96 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | sv_autobunnyhopping | 0 | 0 | 1 | Players automatically re-jump while holding jump button.
`0` disabled
`1` enabled | | sv_enablebunnyhopping | 0 | 0 | 1 | Allow player speed to exceed maximum running speed.
`0` disabled
`1` enabled | | mp_plant_c4_anywhere | 0 | 0 | 1 | When set, players can plant anywhere, not only in bombsites.
`0` disabled
`1` enabled | +| sv_block_vote_commands | 0 | 0 | 1 | When set, blocks `vote` and `votemap` commands.
`0` disabled
`1` enabled | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 09766cd04..974837afd 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -483,3 +483,10 @@ sv_enablebunnyhopping 0 // // Default value: "0" mp_plant_c4_anywhere 0 + +// When set, blocks "vote" and "votemap" commands +// 0 - disabled (default behaviour) +// 1 - enabled +// +// Default value: "0" +sv_block_vote_commands 0 diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 5ddf63adb..0440308d5 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -2602,7 +2602,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa pPlayer->ForceClientDllUpdate(); } } - else if (FStrEq(pcmd, "vote")) + else if (FStrEq(pcmd, "vote") +#ifdef REGAMEDLL_ADD + && sv_block_vote_commands.value <= 0 +#endif + ) { if (gpGlobals->time >= pPlayer->m_flLastCommandTime[CMD_VOTE]) { @@ -2683,7 +2687,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa CSGameRules()->DisplayMaps(pPlayer, 0); } } - else if (FStrEq(pcmd, "votemap")) + else if (FStrEq(pcmd, "votemap") +#ifdef REGAMEDLL_ADD + && sv_block_vote_commands.value <= 0 +#endif + ) { if (gpGlobals->time >= pPlayer->m_flLastCommandTime[CMD_VOTEMAP]) { diff --git a/regamedll/dlls/client.h b/regamedll/dlls/client.h index 28f06e41b..ee98ddbca 100644 --- a/regamedll/dlls/client.h +++ b/regamedll/dlls/client.h @@ -54,6 +54,13 @@ enum BuyItemMenuSlot MENU_SLOT_ITEM_SHIELD, }; +// custom enum +enum +{ + BLOCK_VOTE = BIT(0), + BLOCK_VOTEMAP = BIT(1), +}; + #define CS_NUM_SKIN 4 #define CZ_NUM_SKIN 5 diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 14dc2d11e..0d78e7094 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -162,6 +162,7 @@ cvar_t allchat = { "sv_allchat", "0", 0, 0.0f, nullptr cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr }; +cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0.0f, nullptr }; void GameDLL_Version_f() { diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 5c75387b7..dd89ad5bd 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -188,6 +188,7 @@ extern cvar_t allchat; extern cvar_t sv_autobunnyhopping; extern cvar_t sv_enablebunnyhopping; extern cvar_t plant_c4_anywhere; +extern cvar_t sv_block_vote_commands; #endif From 1cc56037ae3d062e9a2d5ebc375bbdf5ca8d5d53 Mon Sep 17 00:00:00 2001 From: Alejo Date: Tue, 11 Jan 2022 13:40:10 -0300 Subject: [PATCH 07/32] =?UTF-8?q?Fix=20=C3=BAltima=20cvar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- regamedll/dlls/game.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index d3761ab1b..769752c27 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -399,6 +399,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&plant_c4_anywhere); CVAR_REGISTER(&max_alive_name_changes); CVAR_REGISTER(&legacy_restart_entities); + CVAR_REGISTER(&sv_block_vote_commands); // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); From 6f80affbb07e882a871954279d80357b0f908475 Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 15 Jun 2022 21:41:49 -0300 Subject: [PATCH 08/32] Update client.cpp --- regamedll/dlls/client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 0440308d5..4eec4630e 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4817,7 +4817,8 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) Q_memset(&II, 0, sizeof(II)); #ifdef REGAMEDLL_API - pPlayerItem->CSPlayerItem()->GetItemInfo(&II); + weapon->CSPlayerItem()->GetItemInfo(&II); + //pPlayerItem->CSPlayerItem()->GetItemInfo(&II); #else weapon->GetItemInfo(&II); #endif From 15b03e662544be16eaacf9d17b5f6f337b1ca0a2 Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 15 Jun 2022 22:04:16 -0300 Subject: [PATCH 09/32] Revert "Update client.cpp" This reverts commit 6f80affbb07e882a871954279d80357b0f908475. --- regamedll/dlls/client.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 4eec4630e..0440308d5 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4817,8 +4817,7 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) Q_memset(&II, 0, sizeof(II)); #ifdef REGAMEDLL_API - weapon->CSPlayerItem()->GetItemInfo(&II); - //pPlayerItem->CSPlayerItem()->GetItemInfo(&II); + pPlayerItem->CSPlayerItem()->GetItemInfo(&II); #else weapon->GetItemInfo(&II); #endif From 86a9f2d6bfbc60dd02933c86d82e6956718745c5 Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 22 Jun 2022 17:31:08 -0300 Subject: [PATCH 10/32] Fix secondary attack api --- regamedll/dlls/weapons.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 22d61fc9f..b727d38eb 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -814,13 +814,6 @@ bool CBasePlayerWeapon::HasSecondaryAttack() return true; } -#ifdef REGAMEDLL_API - if (CSPlayerWeapon()->m_bHasSecondaryAttack) - { - return true; - } -#endif - switch (m_iId) { case WEAPON_AK47: @@ -887,7 +880,11 @@ void CBasePlayerWeapon::ItemPostFrame() { int usableButtons = m_pPlayer->pev->button; - if (!HasSecondaryAttack()) +#ifdef REGAMEDLL_API + if (!CSPlayerWeapon()->m_bHasSecondaryAttack) +#else + if (!HasSecondaryWeapon()) +#endif { usableButtons &= ~IN_ATTACK2; } From c1798ed776075caf2ce8f428c69c8f8c028811f7 Mon Sep 17 00:00:00 2001 From: Alejo Date: Tue, 16 Nov 2021 18:02:27 -0300 Subject: [PATCH 11/32] CVar `mp_max_alive_name_changes` --- README.md | 2 ++ dist/game.cfg | 8 ++++++++ regamedll/dlls/API/CSPlayer.cpp | 2 ++ regamedll/dlls/game.cpp | 11 +++++++---- regamedll/dlls/game.h | 1 + regamedll/dlls/player.cpp | 9 +++++++++ regamedll/public/regamedll/API/CSPlayer.h | 15 ++++++++++++++- 7 files changed, 43 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bf7408dac..6d070ad0a 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,8 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_give_c4_frags | 3 | - | - | How many bonuses (frags) will get the player who defused or exploded the bomb. | | mp_hostages_rescued_ratio | 1.0 | 0.0 | 1.0 | Ratio of hostages rescued to win the round. | | mp_legacy_vehicle_block | 1 | 0 | 1 | Legacy func_vehicle behavior when blocked by another entity.
`0` New behavior
`1` Legacy behavior | +| mp_max_alive_name_changes | -1 | -1 | - | Maximum amount of nickname changes when alive
`-1` unlimited
`0` Blocks name changes
`>0` Allow to change arbitrary amount of nicks | + ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index efebcba89..d6444d2f1 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -503,3 +503,11 @@ mp_hostages_rescued_ratio "1.0" // // Default value: "1" mp_legacy_vehicle_block "1" + +// Maximum amount of nickname changes before next respawn. +// -1 - unlimited (default behaviour) +// 0 - Blocks name changes +// >0 - Allow to change arbitrary amount of nicks +// +// Default value: "-1" +mp_max_alive_name_changes -1 diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index 6b11725fe..96fab9054 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -541,12 +541,14 @@ void CCSPlayer::Reset() m_bGameForcingRespawn = false; m_bAutoBunnyHopping = false; m_bMegaBunnyJumping = false; + m_iAliveNameChanges = 0; } void CCSPlayer::OnSpawn() { m_bGameForcingRespawn = false; m_flRespawnPending = 0.0f; + m_iAliveNameChanges = 0; } void CCSPlayer::OnKilled() diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 11e35513b..fbf0e464a 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -163,10 +163,9 @@ cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr }; cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr }; - -cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr }; - -cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr }; +cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr }; +cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr }; +cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; void GameDLL_Version_f() { @@ -408,11 +407,15 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&sv_autobunnyhopping); CVAR_REGISTER(&sv_enablebunnyhopping); CVAR_REGISTER(&plant_c4_anywhere); +<<<<<<< HEAD CVAR_REGISTER(&give_c4_frags); CVAR_REGISTER(&hostages_rescued_ratio); CVAR_REGISTER(&legacy_vehicle_block); +======= + CVAR_REGISTER(&max_alive_name_changes); +>>>>>>> d6d78dd (CVar `mp_max_alive_name_changes`) // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index a9b9158b0..97fade838 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -190,6 +190,7 @@ extern cvar_t sv_enablebunnyhopping; extern cvar_t plant_c4_anywhere; extern cvar_t give_c4_frags; extern cvar_t hostages_rescued_ratio; +extern cvar_t max_alive_name_changes; extern cvar_t legacy_vehicle_block; #endif diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 7c0b62e19..2548ff845 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -173,6 +173,11 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c } #endif +#ifdef REGAMEDLL_API + if (!CSPlayer()->CanChangeName()) + return false; +#endif + if (pev->deadflag != DEAD_NO) { m_bHasChangedName = true; @@ -191,6 +196,10 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c WRITE_STRING(szNewName); MESSAGE_END(); +#ifdef REGAMEDLL_API + CSPlayer()->m_iAliveNameChanges++; +#endif + UTIL_LogPrintf("\"%s<%i><%s><%s>\" changed name to \"%s\"\n", STRING(pev->netname), GETPLAYERUSERID(edict()), GETPLAYERAUTHID(edict()), GetTeam(m_iTeam), szNewName); return true; } diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 8410d95f7..5619397af 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -49,7 +49,8 @@ class CCSPlayer: public CCSMonster { m_bGameForcingRespawn(false), m_bAutoBunnyHopping(false), m_bMegaBunnyJumping(false), - m_bPlantC4Anywhere(false) + m_bPlantC4Anywhere(false), + m_iAliveNameChanges(0) { m_szModel[0] = '\0'; } @@ -106,6 +107,7 @@ class CCSPlayer: public CCSMonster { void OnKilled(); CBasePlayer *BasePlayer() const; + bool CanChangeName() const; public: enum EProtectionState @@ -131,8 +133,19 @@ class CCSPlayer: public CCSMonster { bool m_bAutoBunnyHopping; bool m_bMegaBunnyJumping; bool m_bPlantC4Anywhere; + int m_iAliveNameChanges; }; +inline bool CCSPlayer::CanChangeName() const +{ +#ifdef REGAMEDLL_ADD + if (max_alive_name_changes.value >= 0 && m_iAliveNameChanges >= max_alive_name_changes.value) + return false; +#endif + + return true; +} + // Inlines inline CBasePlayer *CCSPlayer::BasePlayer() const { From f149045f243fb928ac4467c483c4b8725076ca50 Mon Sep 17 00:00:00 2001 From: Giovani Ferraro Trivelli Date: Sun, 28 Nov 2021 10:39:13 -0300 Subject: [PATCH 12/32] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f08eab89e..35d851a0c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,7 @@ name: C/C++ CI on: push: - branches: [master] + branches: [master, nostalgia] paths-ignore: - '**.md' From 2058d0f4816b7a99c23c0dd08965477087610654 Mon Sep 17 00:00:00 2001 From: Alejo Date: Fri, 19 Nov 2021 21:07:08 -0300 Subject: [PATCH 13/32] CVar `sv_legacy_restart_entities` --- regamedll/dlls/game.cpp | 9 ++--- regamedll/dlls/game.h | 5 ++- regamedll/dlls/multiplay_gamerules.cpp | 51 +++++++++++++++++--------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index fbf0e464a..d29119a57 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -165,7 +165,9 @@ cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0 cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr }; cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr }; cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr }; + cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; +cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr }; void GameDLL_Version_f() { @@ -407,15 +409,12 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&sv_autobunnyhopping); CVAR_REGISTER(&sv_enablebunnyhopping); CVAR_REGISTER(&plant_c4_anywhere); -<<<<<<< HEAD CVAR_REGISTER(&give_c4_frags); - CVAR_REGISTER(&hostages_rescued_ratio); - CVAR_REGISTER(&legacy_vehicle_block); -======= + CVAR_REGISTER(&max_alive_name_changes); ->>>>>>> d6d78dd (CVar `mp_max_alive_name_changes`) + CVAR_REGISTER(&legacy_restart_entities); // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 97fade838..b2ccf0017 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -190,9 +190,10 @@ extern cvar_t sv_enablebunnyhopping; extern cvar_t plant_c4_anywhere; extern cvar_t give_c4_frags; extern cvar_t hostages_rescued_ratio; -extern cvar_t max_alive_name_changes; - extern cvar_t legacy_vehicle_block; + +extern cvar_t max_alive_name_changes; +extern cvar_t legacy_restart_entities; #endif extern cvar_t scoreboard_showmoney; diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 2a8821d9f..815136438 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -607,11 +607,16 @@ LINK_HOOK_CLASS_VOID_CUSTOM_CHAIN2(CHalfLifeMultiplay, CSGameRules, CleanUpMap) void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() { #ifdef REGAMEDLL_FIXES - UTIL_RestartOther("multi_manager"); +#ifdef REGAMEDLL_ADD + if (legacy_restart_entities.value > 0) +#endif + { + UTIL_RestartOther("multi_manager"); - // Release or reset everything entities in depending of flags ObjectCaps - // (FCAP_MUST_RESET / FCAP_MUST_RELEASE) - UTIL_ResetEntities(); + // Release or reset everything entities in depending of flags ObjectCaps + // (FCAP_MUST_RESET / FCAP_MUST_RELEASE) + UTIL_ResetEntities(); + } #endif // Recreate all the map entities from the map data (preserving their indices), @@ -622,11 +627,16 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() UTIL_RestartOther("func_door"); #ifdef REGAMEDLL_FIXES - UTIL_RestartOther("func_button"); - UTIL_RestartOther("func_rot_button"); - UTIL_RestartOther("env_render"); - UTIL_RestartOther("env_spark"); - UTIL_RestartOther("trigger_push"); +#ifdef REGAMEDLL_ADD + if (legacy_restart_entities.value > 0) +#endif + { + UTIL_RestartOther("func_button"); + UTIL_RestartOther("func_rot_button"); + UTIL_RestartOther("env_render"); + UTIL_RestartOther("env_spark"); + UTIL_RestartOther("trigger_push"); + } #endif UTIL_RestartOther("func_water"); @@ -639,15 +649,20 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() UTIL_RestartOther("env_sprite"); #ifdef REGAMEDLL_FIXES - UTIL_RestartOther("trigger_once"); - UTIL_RestartOther("func_wall_toggle"); - UTIL_RestartOther("func_healthcharger"); - UTIL_RestartOther("func_recharge"); - UTIL_RestartOther("trigger_hurt"); - UTIL_RestartOther("multisource"); - UTIL_RestartOther("env_beam"); - UTIL_RestartOther("env_laser"); - UTIL_RestartOther("trigger_auto"); +#ifdef REGAMEDLL_ADD + if (legacy_restart_entities.value > 0) +#endif + { + UTIL_RestartOther("trigger_once"); + UTIL_RestartOther("func_wall_toggle"); + UTIL_RestartOther("func_healthcharger"); + UTIL_RestartOther("func_recharge"); + UTIL_RestartOther("trigger_hurt"); + UTIL_RestartOther("multisource"); + UTIL_RestartOther("env_beam"); + UTIL_RestartOther("env_laser"); + UTIL_RestartOther("trigger_auto"); + } #endif // Remove grenades and C4 From cf6aa05f916a2d1e9a57387b08536c75019dcfc8 Mon Sep 17 00:00:00 2001 From: Alejo Date: Sat, 20 Nov 2021 11:49:05 -0300 Subject: [PATCH 14/32] Fix "if" condition --- README.md | 2 +- dist/game.cfg | 7 +++++++ regamedll/dlls/multiplay_gamerules.cpp | 6 +++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 6d070ad0a..e68a9e9c5 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_hostages_rescued_ratio | 1.0 | 0.0 | 1.0 | Ratio of hostages rescued to win the round. | | mp_legacy_vehicle_block | 1 | 0 | 1 | Legacy func_vehicle behavior when blocked by another entity.
`0` New behavior
`1` Legacy behavior | | mp_max_alive_name_changes | -1 | -1 | - | Maximum amount of nickname changes when alive
`-1` unlimited
`0` Blocks name changes
`>0` Allow to change arbitrary amount of nicks | - +| sv_legacy_restart_entities | 0 | 0 | 1 | Legacy restart of entities on new round
`0` disabled
`1` enabled | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index d6444d2f1..cabd24450 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -511,3 +511,10 @@ mp_legacy_vehicle_block "1" // // Default value: "-1" mp_max_alive_name_changes -1 + +// Legacy restart of entities on new round. +// 0 - disabled (default behaviour) +// 1 - enabled +// +// Default value: "0" +sv_legacy_restart_entities 0 diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index 815136438..19650e257 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -608,7 +608,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() { #ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_ADD - if (legacy_restart_entities.value > 0) + if (!(bool)legacy_restart_entities.value) #endif { UTIL_RestartOther("multi_manager"); @@ -628,7 +628,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() #ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_ADD - if (legacy_restart_entities.value > 0) + if (!(bool)legacy_restart_entities.value) #endif { UTIL_RestartOther("func_button"); @@ -650,7 +650,7 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(CleanUpMap)() #ifdef REGAMEDLL_FIXES #ifdef REGAMEDLL_ADD - if (legacy_restart_entities.value > 0) + if (!(bool)legacy_restart_entities.value) #endif { UTIL_RestartOther("trigger_once"); From 4d7a915a61851fb65c8b2f35cd2d95b09040f4b2 Mon Sep 17 00:00:00 2001 From: Alejo Date: Sun, 28 Nov 2021 15:59:33 -0300 Subject: [PATCH 15/32] Cambio funcionamiento cvar --- regamedll/dlls/player.cpp | 13 ++++++++++--- regamedll/public/regamedll/API/CSPlayer.h | 11 ----------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 2548ff845..d86b320ef 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -173,12 +173,19 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(SetClientUserInfoName)(char *infobuffer, c } #endif -#ifdef REGAMEDLL_API - if (!CSPlayer()->CanChangeName()) +#ifdef REGAMEDLL_ADD + if (max_alive_name_changes.value <= 0) + { + ClientPrint(pev, HUD_PRINTCENTER, "#Command_Not_Available"); return false; + } #endif - if (pev->deadflag != DEAD_NO) + if (pev->deadflag != DEAD_NO +#if defined REGAMEDLL_API && REGAMEDLL_ADD + || CSPlayer()->m_iAliveNameChanges >= max_alive_name_changes.value +#endif + ) { m_bHasChangedName = true; Q_snprintf(m_szNewName, sizeof(m_szNewName), "%s", szNewName); diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 5619397af..9ce4c15d0 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -107,7 +107,6 @@ class CCSPlayer: public CCSMonster { void OnKilled(); CBasePlayer *BasePlayer() const; - bool CanChangeName() const; public: enum EProtectionState @@ -136,16 +135,6 @@ class CCSPlayer: public CCSMonster { int m_iAliveNameChanges; }; -inline bool CCSPlayer::CanChangeName() const -{ -#ifdef REGAMEDLL_ADD - if (max_alive_name_changes.value >= 0 && m_iAliveNameChanges >= max_alive_name_changes.value) - return false; -#endif - - return true; -} - // Inlines inline CBasePlayer *CCSPlayer::BasePlayer() const { From 1261e313e0039ab86fa92308ed72417c6e0443a8 Mon Sep 17 00:00:00 2001 From: Alejo Date: Mon, 10 Jan 2022 13:37:57 -0300 Subject: [PATCH 16/32] `sv_block_vote_commands` --- README.md | 1 + dist/game.cfg | 8 ++++++++ regamedll/dlls/client.cpp | 12 ++++++++++-- regamedll/dlls/client.h | 7 +++++++ regamedll/dlls/game.cpp | 1 + regamedll/dlls/game.h | 2 ++ 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e68a9e9c5..85a5f2246 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_legacy_vehicle_block | 1 | 0 | 1 | Legacy func_vehicle behavior when blocked by another entity.
`0` New behavior
`1` Legacy behavior | | mp_max_alive_name_changes | -1 | -1 | - | Maximum amount of nickname changes when alive
`-1` unlimited
`0` Blocks name changes
`>0` Allow to change arbitrary amount of nicks | | sv_legacy_restart_entities | 0 | 0 | 1 | Legacy restart of entities on new round
`0` disabled
`1` enabled | +| sv_block_vote_commands | 0 | 0 | 1 | When set, blocks `vote` and `votemap` commands.
`0` disabled
`1` enabled | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index cabd24450..dfbcb8aef 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -518,3 +518,11 @@ mp_max_alive_name_changes -1 // // Default value: "0" sv_legacy_restart_entities 0 + +// When set, blocks "vote" and "votemap" commands +// 0 - disabled (default behaviour) +// 1 - enabled +// +// Default value: "0" +sv_block_vote_commands 0 + diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 5ddf63adb..0440308d5 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -2602,7 +2602,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa pPlayer->ForceClientDllUpdate(); } } - else if (FStrEq(pcmd, "vote")) + else if (FStrEq(pcmd, "vote") +#ifdef REGAMEDLL_ADD + && sv_block_vote_commands.value <= 0 +#endif + ) { if (gpGlobals->time >= pPlayer->m_flLastCommandTime[CMD_VOTE]) { @@ -2683,7 +2687,11 @@ void EXT_FUNC InternalCommand(edict_t *pEntity, const char *pcmd, const char *pa CSGameRules()->DisplayMaps(pPlayer, 0); } } - else if (FStrEq(pcmd, "votemap")) + else if (FStrEq(pcmd, "votemap") +#ifdef REGAMEDLL_ADD + && sv_block_vote_commands.value <= 0 +#endif + ) { if (gpGlobals->time >= pPlayer->m_flLastCommandTime[CMD_VOTEMAP]) { diff --git a/regamedll/dlls/client.h b/regamedll/dlls/client.h index 28f06e41b..ee98ddbca 100644 --- a/regamedll/dlls/client.h +++ b/regamedll/dlls/client.h @@ -54,6 +54,13 @@ enum BuyItemMenuSlot MENU_SLOT_ITEM_SHIELD, }; +// custom enum +enum +{ + BLOCK_VOTE = BIT(0), + BLOCK_VOTEMAP = BIT(1), +}; + #define CS_NUM_SKIN 4 #define CZ_NUM_SKIN 5 diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index d29119a57..7d18900ec 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -168,6 +168,7 @@ cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr }; +cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0.0f, nullptr }; void GameDLL_Version_f() { diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index b2ccf0017..d1894aa2a 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -194,6 +194,8 @@ extern cvar_t legacy_vehicle_block; extern cvar_t max_alive_name_changes; extern cvar_t legacy_restart_entities; +extern cvar_t sv_block_vote_commands; + #endif extern cvar_t scoreboard_showmoney; From f8dd7e0e7a9497fa723d6cc684e2b56569b10050 Mon Sep 17 00:00:00 2001 From: Alejo Date: Tue, 11 Jan 2022 13:40:10 -0300 Subject: [PATCH 17/32] =?UTF-8?q?Fix=20=C3=BAltima=20cvar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- regamedll/dlls/game.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 7d18900ec..fdfd26184 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -416,6 +416,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&max_alive_name_changes); CVAR_REGISTER(&legacy_restart_entities); + CVAR_REGISTER(&sv_block_vote_commands); // print version CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n"); From 4d7799a22c540d6d625e4615d3939df689a557ef Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 15 Jun 2022 21:41:49 -0300 Subject: [PATCH 18/32] Update client.cpp --- regamedll/dlls/client.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 0440308d5..4eec4630e 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4817,7 +4817,8 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) Q_memset(&II, 0, sizeof(II)); #ifdef REGAMEDLL_API - pPlayerItem->CSPlayerItem()->GetItemInfo(&II); + weapon->CSPlayerItem()->GetItemInfo(&II); + //pPlayerItem->CSPlayerItem()->GetItemInfo(&II); #else weapon->GetItemInfo(&II); #endif From bccc6889824f77254828dbb50268ce931f9127fe Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 15 Jun 2022 22:04:16 -0300 Subject: [PATCH 19/32] Revert "Update client.cpp" This reverts commit 6f80affbb07e882a871954279d80357b0f908475. --- regamedll/dlls/client.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 4eec4630e..0440308d5 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -4817,8 +4817,7 @@ int EXT_FUNC GetWeaponData(edict_t *pEdict, struct weapon_data_s *info) Q_memset(&II, 0, sizeof(II)); #ifdef REGAMEDLL_API - weapon->CSPlayerItem()->GetItemInfo(&II); - //pPlayerItem->CSPlayerItem()->GetItemInfo(&II); + pPlayerItem->CSPlayerItem()->GetItemInfo(&II); #else weapon->GetItemInfo(&II); #endif From 09ca850b0d3acd89e8b627adbfaa7c631090f46a Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 22 Jun 2022 17:31:08 -0300 Subject: [PATCH 20/32] Fix secondary attack api --- regamedll/dlls/weapons.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 22d61fc9f..b727d38eb 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -814,13 +814,6 @@ bool CBasePlayerWeapon::HasSecondaryAttack() return true; } -#ifdef REGAMEDLL_API - if (CSPlayerWeapon()->m_bHasSecondaryAttack) - { - return true; - } -#endif - switch (m_iId) { case WEAPON_AK47: @@ -887,7 +880,11 @@ void CBasePlayerWeapon::ItemPostFrame() { int usableButtons = m_pPlayer->pev->button; - if (!HasSecondaryAttack()) +#ifdef REGAMEDLL_API + if (!CSPlayerWeapon()->m_bHasSecondaryAttack) +#else + if (!HasSecondaryWeapon()) +#endif { usableButtons &= ~IN_ATTACK2; } From 15fc2a069234f4d52ce73f107598b26676bef69e Mon Sep 17 00:00:00 2001 From: Alejo Date: Sun, 11 Dec 2022 22:03:23 -0300 Subject: [PATCH 21/32] Fix --- regamedll/dlls/game.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 4f3f74228..fdfd26184 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -162,7 +162,6 @@ cvar_t allchat = { "sv_allchat", "0", 0, 0.0f, nullptr cvar_t sv_autobunnyhopping = { "sv_autobunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t sv_enablebunnyhopping = { "sv_enablebunnyhopping", "0", 0, 0.0f, nullptr }; cvar_t plant_c4_anywhere = { "mp_plant_c4_anywhere", "0", 0, 0.0f, nullptr }; -<<<<<<< HEAD cvar_t give_c4_frags = { "mp_give_c4_frags", "3", 0, 3.0f, nullptr }; cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr }; cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr }; @@ -170,12 +169,6 @@ cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr }; cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0.0f, nullptr }; -======= -cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; -cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr }; -cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0.0f, nullptr }; - ->>>>>>> 86a9f2d6bfbc60dd02933c86d82e6956718745c5 void GameDLL_Version_f() { From fc2ac49732f181b1a5550296b40b278b802075bc Mon Sep 17 00:00:00 2001 From: Alejo Date: Sun, 24 Dec 2023 13:28:34 -0300 Subject: [PATCH 22/32] Fix --- regamedll/dlls/game.cpp | 1 - regamedll/dlls/weapons.cpp | 16 ++++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 9b3e2f7b2..37b6db4f0 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -172,7 +172,6 @@ cvar_t assist_damage_threshold = { "mp_assist_damage_threshold", "40", cvar_t freezetime_duck = { "mp_freezetime_duck", "1", 0, 1.0f, nullptr }; cvar_t freezetime_jump = { "mp_freezetime_jump", "1", 0, 1.0f, nullptr }; cvar_t hostages_rescued_ratio = { "mp_hostages_rescued_ratio", "1.0", 0, 1.0f, nullptr }; -cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr }; cvar_t max_alive_name_changes = { "mp_max_alive_name_changes", "-1", 0, -1.0f, nullptr }; cvar_t legacy_restart_entities = { "sv_legacy_restart_entities", "0", 0, 0.0f, nullptr }; diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index d3877fbba..ad8de9d25 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -911,11 +911,7 @@ void EXT_FUNC CBasePlayerWeapon::__API_HOOK(ItemPostFrame)() { int usableButtons = m_pPlayer->pev->button; -#ifdef REGAMEDLL_API - if (!CSPlayerWeapon()->m_bHasSecondaryAttack) -#else - if (!HasSecondaryWeapon()) -#endif + if (!HasSecondaryAttack()) { usableButtons &= ~IN_ATTACK2; } @@ -1860,11 +1856,11 @@ void CWeaponBox::Touch(CBaseEntity *pOther) bool bRemove = true; -#ifdef REGAMEDLL_FIXES +#ifdef REGAMEDLL_FIXES CBasePlayerItem *givenItem = nullptr; #else bool givenItem = false; -#endif +#endif // go through my weapons and try to give the usable ones to the player. // it's important the the player be given ammo first, so the weapons code doesn't refuse @@ -2059,7 +2055,7 @@ void CWeaponBox::Touch(CBaseEntity *pOther) pItem->AttachToPlayer(pPlayer); #ifdef REGAMEDLL_FIXES givenItem = pItem; -#else +#else givenItem = true; #endif } @@ -2099,13 +2095,13 @@ void CWeaponBox::Touch(CBaseEntity *pOther) { EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/gunpickup2.wav", VOL_NORM, ATTN_NORM); -#ifdef REGAMEDLL_FIXES +#ifdef REGAMEDLL_FIXES // BUGBUG: weaponbox links gun to player, then ammo is given // so FShouldSwitchWeapon's CanHolster (which checks ammo) check inside AddPlayerItem // return FALSE, causing an unarmed player to not deploy any weaponbox grenade if (pPlayer->m_pActiveItem != givenItem && CSGameRules()->FShouldSwitchWeapon(pPlayer, givenItem)) { - // This re-check is done after ammo is given + // This re-check is done after ammo is given // so it ensures player properly deploys grenade from floor pPlayer->SwitchWeapon(givenItem); } From 699ab580c8f31523d8c8bee8e3f41f6e59b46fbc Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 20:21:28 -0300 Subject: [PATCH 23/32] Cambio CBasePlayerWeapon::Spawn --- regamedll/dlls/weapons.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index ad8de9d25..30a61ae2e 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -1223,10 +1223,9 @@ void CBasePlayerItem::AttachToPlayer(CBasePlayer *pPlayer) void CBasePlayerWeapon::Spawn() { #ifdef REGAMEDLL_API - ItemInfo info; - Q_memset(&info, 0, sizeof(info)); + ItemInfo &info = m_ItemInfoArray[m_iId]; - if (GetItemInfo(&info)) { + if (info.iId) { CSPlayerItem()->SetItemInfo(&info); } #endif From 06621e03030013be78058282340e7a487d4c1af7 Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 20:52:48 -0300 Subject: [PATCH 24/32] Fix Reload en armas --- regamedll/dlls/wpn_shared/wpn_ak47.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_aug.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_awp.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_deagle.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_elite.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_famas.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_fiveseven.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_g3sg1.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_galil.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_glock18.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_m249.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_m4a1.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_mac10.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_mp5navy.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_p228.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_p90.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_scout.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_sg550.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_sg552.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_tmp.cpp | 2 +- regamedll/dlls/wpn_shared/wpn_ump45.cpp | 2 ++ regamedll/dlls/wpn_shared/wpn_usp.cpp | 2 ++ 22 files changed, 39 insertions(+), 5 deletions(-) diff --git a/regamedll/dlls/wpn_shared/wpn_ak47.cpp b/regamedll/dlls/wpn_shared/wpn_ak47.cpp index 1a27a3f92..1cc9efcaa 100644 --- a/regamedll/dlls/wpn_shared/wpn_ak47.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ak47.cpp @@ -173,7 +173,7 @@ void CAK47::AK47Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CAK47::Reload() { -#ifdef REGAMEDLL_FIXES +#ifndef REGAMEDLL_FIXES // to prevent reload if not enough ammo if (m_pPlayer->ammo_762nato <= 0) return; diff --git a/regamedll/dlls/wpn_shared/wpn_aug.cpp b/regamedll/dlls/wpn_shared/wpn_aug.cpp index 988c74808..6150ff4a4 100644 --- a/regamedll/dlls/wpn_shared/wpn_aug.cpp +++ b/regamedll/dlls/wpn_shared/wpn_aug.cpp @@ -181,8 +181,10 @@ void CAUG::AUGFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CAUG::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_556nato <= 0) return; +#endif if (DefaultReload(iMaxClip(), AUG_RELOAD, AUG_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_awp.cpp b/regamedll/dlls/wpn_shared/wpn_awp.cpp index 0e31bd548..e86eebb13 100644 --- a/regamedll/dlls/wpn_shared/wpn_awp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_awp.cpp @@ -194,8 +194,10 @@ void CAWP::AWPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CAWP::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_338mag <= 0) return; +#endif if (DefaultReload(iMaxClip(), AWP_RELOAD, AWP_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_deagle.cpp b/regamedll/dlls/wpn_shared/wpn_deagle.cpp index 7dbed0c6b..001039e97 100644 --- a/regamedll/dlls/wpn_shared/wpn_deagle.cpp +++ b/regamedll/dlls/wpn_shared/wpn_deagle.cpp @@ -183,8 +183,10 @@ void CDEAGLE::DEAGLEFire(float flSpread, float flCycleTime, BOOL fUseSemi) void CDEAGLE::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_50ae <= 0) return; +#endif if (DefaultReload(iMaxClip(), DEAGLE_RELOAD, DEAGLE_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_elite.cpp b/regamedll/dlls/wpn_shared/wpn_elite.cpp index 05428d8ed..1a0f8a9d5 100644 --- a/regamedll/dlls/wpn_shared/wpn_elite.cpp +++ b/regamedll/dlls/wpn_shared/wpn_elite.cpp @@ -205,8 +205,10 @@ void CELITE::ELITEFire(float flSpread, float flCycleTime, BOOL fUseSemi) void CELITE::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_9mm <= 0) return; +#endif if (DefaultReload(iMaxClip(), ELITE_RELOAD, ELITE_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_famas.cpp b/regamedll/dlls/wpn_shared/wpn_famas.cpp index eb7bcc892..0c0355165 100644 --- a/regamedll/dlls/wpn_shared/wpn_famas.cpp +++ b/regamedll/dlls/wpn_shared/wpn_famas.cpp @@ -216,8 +216,10 @@ void CFamas::FamasFire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL void CFamas::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_556nato <= 0) return; +#endif if (DefaultReload(iMaxClip(), FAMAS_RELOAD, FAMAS_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp index 31f211f08..c57bd003a 100644 --- a/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp +++ b/regamedll/dlls/wpn_shared/wpn_fiveseven.cpp @@ -182,8 +182,10 @@ void CFiveSeven::FiveSevenFire(float flSpread, float flCycleTime, BOOL fUseSemi) void CFiveSeven::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_57mm <= 0) return; +#endif if (DefaultReload(iMaxClip(), FIVESEVEN_RELOAD, FIVESEVEN_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp index 5351d0f78..d15b3b20c 100644 --- a/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_g3sg1.cpp @@ -191,8 +191,10 @@ void CG3SG1::G3SG1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CG3SG1::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_762nato <= 0) return; +#endif if (DefaultReload(iMaxClip(), G3SG1_RELOAD, G3SG1_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_galil.cpp b/regamedll/dlls/wpn_shared/wpn_galil.cpp index 69326075e..e6f5a96cf 100644 --- a/regamedll/dlls/wpn_shared/wpn_galil.cpp +++ b/regamedll/dlls/wpn_shared/wpn_galil.cpp @@ -176,7 +176,7 @@ void CGalil::GalilFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CGalil::Reload() { -#ifdef REGAMEDLL_FIXES +#ifndef REGAMEDLL_FIXES // to prevent reload if not enough ammo if (m_pPlayer->ammo_556nato <= 0) return; diff --git a/regamedll/dlls/wpn_shared/wpn_glock18.cpp b/regamedll/dlls/wpn_shared/wpn_glock18.cpp index c2f5399d5..f505b6fa6 100644 --- a/regamedll/dlls/wpn_shared/wpn_glock18.cpp +++ b/regamedll/dlls/wpn_shared/wpn_glock18.cpp @@ -259,8 +259,10 @@ void CGLOCK18::GLOCK18Fire(float flSpread, float flCycleTime, BOOL bFireBurst) void CGLOCK18::Reload() { int iResult; +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_9mm <= 0) return; +#endif if (m_pPlayer->HasShield()) iResult = GLOCK18_SHIELD_RELOAD; diff --git a/regamedll/dlls/wpn_shared/wpn_m249.cpp b/regamedll/dlls/wpn_shared/wpn_m249.cpp index 45d7290be..e08435cdd 100644 --- a/regamedll/dlls/wpn_shared/wpn_m249.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m249.cpp @@ -170,7 +170,7 @@ void CM249::M249Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CM249::Reload() { -#ifdef REGAMEDLL_FIXES +#ifndef REGAMEDLL_FIXES // to prevent reload if not enough ammo if (m_pPlayer->ammo_556natobox <= 0) return; diff --git a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp index 89ea81b5b..e8a686878 100644 --- a/regamedll/dlls/wpn_shared/wpn_m4a1.cpp +++ b/regamedll/dlls/wpn_shared/wpn_m4a1.cpp @@ -229,8 +229,10 @@ void CM4A1::M4A1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CM4A1::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_556nato <= 0) return; +#endif if (DefaultReload(iMaxClip(), ((m_iWeaponState & WPNSTATE_M4A1_SILENCED) == WPNSTATE_M4A1_SILENCED) ? M4A1_RELOAD : M4A1_UNSIL_RELOAD, M4A1_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_mac10.cpp b/regamedll/dlls/wpn_shared/wpn_mac10.cpp index b05170882..4304931eb 100644 --- a/regamedll/dlls/wpn_shared/wpn_mac10.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mac10.cpp @@ -163,8 +163,10 @@ void CMAC10::MAC10Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CMAC10::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_45acp <= 0) return; +#endif if (DefaultReload(iMaxClip(), MAC10_RELOAD, MAC10_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp index 3a1b679a6..cefed60bb 100644 --- a/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp +++ b/regamedll/dlls/wpn_shared/wpn_mp5navy.cpp @@ -164,8 +164,10 @@ void CMP5N::MP5NFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CMP5N::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_9mm <= 0) return; +#endif if (DefaultReload(iMaxClip(), MP5N_RELOAD, MP5N_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_p228.cpp b/regamedll/dlls/wpn_shared/wpn_p228.cpp index b64f5fcf3..108d76d72 100644 --- a/regamedll/dlls/wpn_shared/wpn_p228.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p228.cpp @@ -182,8 +182,10 @@ void CP228::P228Fire(float flSpread, float flCycleTime, BOOL fUseSemi) void CP228::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_357sig <= 0) return; +#endif if (DefaultReload(iMaxClip(), m_pPlayer->HasShield() ? P228_SHIELD_RELOAD : P228_RELOAD, P228_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_p90.cpp b/regamedll/dlls/wpn_shared/wpn_p90.cpp index 7f3cc606f..c4c0fa656 100644 --- a/regamedll/dlls/wpn_shared/wpn_p90.cpp +++ b/regamedll/dlls/wpn_shared/wpn_p90.cpp @@ -170,8 +170,10 @@ void CP90::P90Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CP90::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_57mm <= 0) return; +#endif if (DefaultReload(iMaxClip(), P90_RELOAD, P90_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_scout.cpp b/regamedll/dlls/wpn_shared/wpn_scout.cpp index fd9456624..8d07bfcdc 100644 --- a/regamedll/dlls/wpn_shared/wpn_scout.cpp +++ b/regamedll/dlls/wpn_shared/wpn_scout.cpp @@ -186,7 +186,7 @@ void CSCOUT::SCOUTFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CSCOUT::Reload() { -#ifdef REGAMEDLL_FIXES +#ifndef REGAMEDLL_FIXES // to prevent reload if not enough ammo if (m_pPlayer->ammo_762nato <= 0) return; diff --git a/regamedll/dlls/wpn_shared/wpn_sg550.cpp b/regamedll/dlls/wpn_shared/wpn_sg550.cpp index 8263e98a8..0ae73b607 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg550.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg550.cpp @@ -194,8 +194,10 @@ void CSG550::SG550Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CSG550::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_556nato <= 0) return; +#endif if (DefaultReload(iMaxClip(), SG550_RELOAD, SG550_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_sg552.cpp b/regamedll/dlls/wpn_shared/wpn_sg552.cpp index e86eec412..fe9b31dcc 100644 --- a/regamedll/dlls/wpn_shared/wpn_sg552.cpp +++ b/regamedll/dlls/wpn_shared/wpn_sg552.cpp @@ -180,8 +180,10 @@ void CSG552::SG552Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CSG552::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_556nato <= 0) return; +#endif if (DefaultReload(iMaxClip(), SG552_RELOAD, SG552_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_tmp.cpp b/regamedll/dlls/wpn_shared/wpn_tmp.cpp index 10378abc2..eca575413 100644 --- a/regamedll/dlls/wpn_shared/wpn_tmp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_tmp.cpp @@ -161,7 +161,7 @@ void CTMP::TMPFire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CTMP::Reload() { -#ifdef REGAMEDLL_FIXES +#ifndef REGAMEDLL_FIXES // to prevent reload if not enough ammo if (m_pPlayer->ammo_9mm <= 0) return; diff --git a/regamedll/dlls/wpn_shared/wpn_ump45.cpp b/regamedll/dlls/wpn_shared/wpn_ump45.cpp index 73ada761e..5d9deff18 100644 --- a/regamedll/dlls/wpn_shared/wpn_ump45.cpp +++ b/regamedll/dlls/wpn_shared/wpn_ump45.cpp @@ -167,8 +167,10 @@ void CUMP45::UMP45Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim) void CUMP45::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_45acp <= 0) return; +#endif if (DefaultReload(iMaxClip(), UMP45_RELOAD, UMP45_RELOAD_TIME)) { diff --git a/regamedll/dlls/wpn_shared/wpn_usp.cpp b/regamedll/dlls/wpn_shared/wpn_usp.cpp index 0d830d690..43ec605dd 100644 --- a/regamedll/dlls/wpn_shared/wpn_usp.cpp +++ b/regamedll/dlls/wpn_shared/wpn_usp.cpp @@ -245,8 +245,10 @@ void CUSP::USPFire(float flSpread, float flCycleTime, BOOL fUseSemi) void CUSP::Reload() { +#ifndef REGAMEDLL_FIXES if (m_pPlayer->ammo_45acp <= 0) return; +#endif int iAnim; if (m_pPlayer->HasShield()) From 9f5e80d9c23ae40e3ff50a20af736568930da8ef Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 23:15:10 -0300 Subject: [PATCH 25/32] Nueva native y cambios en ammo registry --- regamedll/dlls/API/CAPI_Impl.cpp | 1 + regamedll/dlls/weapons.cpp | 44 +++++++++++++++++++++- regamedll/dlls/weapons.h | 1 + regamedll/public/regamedll/regamedll_api.h | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 5bb6b3940..e3edbafcc 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -173,6 +173,7 @@ ReGameFuncs_t g_ReGameApiFuncs = { UTIL_Remove_api, AddAmmoNameToAmmoRegistry_api, + RemoveAmmoNameFromAmmoRegistry, TextureTypePlaySound_api, CreateWeaponBox_api, SpawnGrenade_api, diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 30a61ae2e..4d5a15742 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -212,6 +212,26 @@ struct { { AMMO_C4, "C4" }, }; #endif +#ifdef REGAMEDLL_API +BOOL EXT_FUNC RemoveAmmoNameFromAmmoRegistry(const char *szAmmoname) +{ + if (!szAmmoname || !szAmmoname[0]) + { + return FALSE; + } + + for (int i = 1; i < MAX_AMMO_SLOTS; i++) + { + if (!Q_stricmp(CBasePlayerItem::m_AmmoInfoArray[i].pszName, szAmmoname)) + { + Q_memset(&CBasePlayerItem::m_AmmoInfoArray[i], 0, sizeof(CBasePlayerItem::m_AmmoInfoArray[i])); + return TRUE; + } + } + + return FALSE; +} +#endif // Precaches the ammo and queues the ammo info for sending to clients int AddAmmoNameToAmmoRegistry(const char *szAmmoname) @@ -222,6 +242,27 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) return -1; } +#ifdef REGAMEDLL_ADD + int newIndex = -1; + for (int i = 1; i < MAX_AMMO_SLOTS; i++) + { + if (!Q_stricmp(CBasePlayerItem::m_AmmoInfoArray[i].pszName, szAmmoname)) + { + return i; + } + + // New slot for the ammo it's the first one clear. + if (newIndex == -1) + { + newIndex = i; + } + } + + CBasePlayerItem::m_AmmoInfoArray[newIndex].pszName = szAmmoname; + CBasePlayerItem::m_AmmoInfoArray[newIndex].iId = newIndex; + + return newIndex; +#else // make sure it's not already in the registry for (int i = 1; i < MAX_AMMO_SLOTS; i++) { @@ -241,7 +282,6 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) if (giAmmoIndex >= MAX_AMMO_SLOTS) giAmmoIndex = 1; -#ifdef REGAMEDLL_ADD for (auto& ammo : ammoIndex) { if (Q_stricmp(ammo.name, szAmmoname)) @@ -252,7 +292,6 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) } break; } -#endif CBasePlayerItem::m_AmmoInfoArray[giAmmoIndex].pszName = szAmmoname; @@ -260,6 +299,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) CBasePlayerItem::m_AmmoInfoArray[giAmmoIndex].iId = giAmmoIndex; return giAmmoIndex; +#endif } // Precaches the weapon and queues the weapon info for sending to clients diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 431284fb9..0e865fa70 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -2174,4 +2174,5 @@ float GetBaseAccuracy(WeaponIdType id); void ClearMultiDamage_OrigFunc(); void ApplyMultiDamage_OrigFunc(entvars_t *pevInflictor, entvars_t *pevAttacker); void AddMultiDamage_OrigFunc(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType); +BOOL RemoveAmmoNameFromAmmoRegistry(const char* szAmmoname); #endif diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index 4aeb12545..453f973a7 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -808,6 +808,7 @@ struct ReGameFuncs_t { void (*UTIL_DecalTrace)(TraceResult *pTrace, int decalNumber); void (*UTIL_Remove)(CBaseEntity *pEntity); int (*AddAmmoNameToAmmoRegistry)(const char *szAmmoname); + BOOL(*RemoveAmmoNameFromAmmoRegistry)(const char* szAmmoname); void (*TextureTypePlaySound)(TraceResult *ptr, Vector vecSrc, Vector vecEnd, int iBulletType); class CWeaponBox *(*CreateWeaponBox)(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo); class CGrenade *(*SpawnGrenade)(WeaponIdType weaponId, entvars_t *pevOwner, Vector &vecSrc, Vector &vecThrow, float time, int iTeam, unsigned short usEvent); From f8a87c08641ed1446c1a6c6ccc37e30490c63a1b Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 23:26:04 -0300 Subject: [PATCH 26/32] fix index --- regamedll/dlls/weapons.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 4d5a15742..050d2144d 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -244,22 +244,24 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) #ifdef REGAMEDLL_ADD int newIndex = -1; - for (int i = 1; i < MAX_AMMO_SLOTS; i++) + for (int i = 0; i < MAX_AMMO_SLOTS; i++) { if (!Q_stricmp(CBasePlayerItem::m_AmmoInfoArray[i].pszName, szAmmoname)) { return i; } - // New slot for the ammo it's the first one clear. - if (newIndex == -1) + if (!CBasePlayerItem::m_AmmoInfoArray[i].iId && newIndex == -1) { newIndex = i; } } - CBasePlayerItem::m_AmmoInfoArray[newIndex].pszName = szAmmoname; - CBasePlayerItem::m_AmmoInfoArray[newIndex].iId = newIndex; + if (newIndex != -1) + { + CBasePlayerItem::m_AmmoInfoArray[newIndex].pszName = szAmmoname; + CBasePlayerItem::m_AmmoInfoArray[newIndex].iId = newIndex; + } return newIndex; #else From 518bbc1e21195895aa5e19a0b0d93613ec801bef Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 23:32:48 -0300 Subject: [PATCH 27/32] ammoindex remove --- regamedll/dlls/weapons.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 050d2144d..2eb05eb2e 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -190,7 +190,7 @@ NOXREF void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, floa MESSAGE_END(); } -#ifdef REGAMEDLL_ADD +/*#ifdef REGAMEDLL_ADD struct { AmmoType type; const char *name; @@ -211,7 +211,7 @@ struct { { AMMO_SMOKEGRENADE, "SmokeGrenade" }, { AMMO_C4, "C4" }, }; -#endif +#endif*/ #ifdef REGAMEDLL_API BOOL EXT_FUNC RemoveAmmoNameFromAmmoRegistry(const char *szAmmoname) { From 163cc62fc40fd566cfe4d81d30ae11289395f387 Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 23:36:51 -0300 Subject: [PATCH 28/32] fix --- regamedll/dlls/weapons.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 2eb05eb2e..68e8a7422 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -190,7 +190,7 @@ NOXREF void EjectBrass2(const Vector &vecOrigin, const Vector &vecVelocity, floa MESSAGE_END(); } -/*#ifdef REGAMEDLL_ADD +#ifdef REGAMEDLL_ADD struct { AmmoType type; const char *name; @@ -211,7 +211,7 @@ struct { { AMMO_SMOKEGRENADE, "SmokeGrenade" }, { AMMO_C4, "C4" }, }; -#endif*/ +#endif #ifdef REGAMEDLL_API BOOL EXT_FUNC RemoveAmmoNameFromAmmoRegistry(const char *szAmmoname) { @@ -251,6 +251,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) return i; } + // New slot for the ammo it's the first one clear. if (!CBasePlayerItem::m_AmmoInfoArray[i].iId && newIndex == -1) { newIndex = i; @@ -284,6 +285,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) if (giAmmoIndex >= MAX_AMMO_SLOTS) giAmmoIndex = 1; +#ifdef REGAMEDLL_ADD for (auto& ammo : ammoIndex) { if (Q_stricmp(ammo.name, szAmmoname)) @@ -294,6 +296,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) } break; } +#endif CBasePlayerItem::m_AmmoInfoArray[giAmmoIndex].pszName = szAmmoname; From ec11031dca6817100e8361bc5f6cb7bd5af295ef Mon Sep 17 00:00:00 2001 From: Alejo Date: Thu, 4 Jan 2024 23:55:45 -0300 Subject: [PATCH 29/32] testing --- regamedll/dlls/weapons.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index 68e8a7422..e0f017f1e 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -244,7 +244,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) #ifdef REGAMEDLL_ADD int newIndex = -1; - for (int i = 0; i < MAX_AMMO_SLOTS; i++) + for (int i = 1; i < MAX_AMMO_SLOTS; i++) { if (!Q_stricmp(CBasePlayerItem::m_AmmoInfoArray[i].pszName, szAmmoname)) { @@ -254,6 +254,7 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) // New slot for the ammo it's the first one clear. if (!CBasePlayerItem::m_AmmoInfoArray[i].iId && newIndex == -1) { + CONSOLE_ECHO("Añadiendo ammo al indice %d", i); newIndex = i; } } From ec63dcfc755793e27806ee13b1943d577374eb21 Mon Sep 17 00:00:00 2001 From: Alejo Date: Fri, 5 Jan 2024 00:07:08 -0300 Subject: [PATCH 30/32] Fix strcmp nullptr --- regamedll/dlls/weapons.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index e0f017f1e..a053dedad 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -246,15 +246,16 @@ int AddAmmoNameToAmmoRegistry(const char *szAmmoname) int newIndex = -1; for (int i = 1; i < MAX_AMMO_SLOTS; i++) { - if (!Q_stricmp(CBasePlayerItem::m_AmmoInfoArray[i].pszName, szAmmoname)) + AmmoInfo& ammoinfo = CBasePlayerItem::m_AmmoInfoArray[i]; + + if (ammoinfo.iId && !Q_stricmp(ammoinfo.pszName, szAmmoname)) { return i; } // New slot for the ammo it's the first one clear. - if (!CBasePlayerItem::m_AmmoInfoArray[i].iId && newIndex == -1) + if (!ammoinfo.iId && newIndex == -1) { - CONSOLE_ECHO("Añadiendo ammo al indice %d", i); newIndex = i; } } From f677567df4c5fe4e8f7e2a002938e40a93077283 Mon Sep 17 00:00:00 2001 From: Alejo Date: Fri, 5 Jan 2024 00:15:37 -0300 Subject: [PATCH 31/32] Mismo fix pero para RemoveAmmo --- regamedll/dlls/weapons.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index a053dedad..b43b05473 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -222,7 +222,9 @@ BOOL EXT_FUNC RemoveAmmoNameFromAmmoRegistry(const char *szAmmoname) for (int i = 1; i < MAX_AMMO_SLOTS; i++) { - if (!Q_stricmp(CBasePlayerItem::m_AmmoInfoArray[i].pszName, szAmmoname)) + AmmoInfo& ammoinfo = CBasePlayerItem::m_AmmoInfoArray[i]; + + if (ammoinfo.iId && !Q_stricmp(ammoinfo.pszName, szAmmoname)) { Q_memset(&CBasePlayerItem::m_AmmoInfoArray[i], 0, sizeof(CBasePlayerItem::m_AmmoInfoArray[i])); return TRUE; From 4cc9a092fb9e09e4c06a0478052ad512e2aea47b Mon Sep 17 00:00:00 2001 From: Alejo Date: Wed, 14 Feb 2024 19:22:43 -0300 Subject: [PATCH 32/32] Squashed commit of the following: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit commit d48fd3e551bc88d5271197c21c1c627316b4ce45 Merge: 5268e6b 5d2174f Author: Alejo Date: Wed Feb 14 19:17:25 2024 -0300 Merge remote-tracking branch 'upstream/master' commit 5d2174fbbf546f033118bc6d65d55d2166f66980 Author: s1lentq Date: Mon Feb 5 02:21:49 2024 +0700 CWeaponBox::Touch: Reworked dropped grenade pickup commit 4d90a5f4faabd1d220f7bbd0bfc7c246c3896717 Author: s1lentq Date: Thu Feb 1 18:20:11 2024 +0700 CWeaponBox::Touch: Fix grenade pickup (Resolves #923, Closes #931) commit f4c4e891ac094937cc56c26a17d0b2416d92b0c2 Author: s1lentq Date: Thu Feb 1 16:38:16 2024 +0700 CBasePlayerWeapon::ExtractAmmo: Fixed reverse-engineering mistake commit 2489213127db3b73cb2946ce8fe076053dbb9880 Author: s1lentq Date: Thu Feb 1 12:21:23 2024 +0700 Resetable g_weaponSlotInfo commit fb9eb0db55f6c24a333569eda1640360bdc8b0b3 Author: Francisco Muñoz Date: Wed Jan 31 09:38:35 2024 -0300 Fix excessive punchangle when getting shield shot (#919) commit 0bc4ff1d405000d8bebb5141bbc1f748f69c0d1e Author: Rafflesian <56321479+Rafflesian@users.noreply.github.com> Date: Wed Jan 31 09:35:26 2024 -0300 Support for secondary ammo and extra EF_ flags (#934) Support for secondary ammo and extra EF_ flags commit 5287f2a4150ed128e7951fc02ba32a184ed6684b Author: s1lentq Date: Wed Jan 31 19:16:37 2024 +0700 Do not reduce points for bot suicide due bot_kill command commit 0bbc4bd55d437a7097ba969b0922b1bd14a4380c Author: s1lentq Date: Wed Jan 31 18:38:47 2024 +0700 Do not reduce points for suicide due to a fatal fall commit aec3ba2579b0ef50157b9f4a2bf6643b3f8a80b0 Author: s1lentq Date: Wed Jan 31 18:33:34 2024 +0700 Fixed m_looseBombArea assertion commit b34d564e3cd9a4283de6c59ea36783714f2f18e3 Author: s1lentq Date: Wed Jan 31 17:52:38 2024 +0700 PM_CheckWater: Fix for uninitialized waterlevel value for dead players (incorrect waterlevel values from another player movements persisting) commit a1af7ca4260f6f6f5a8d795d654efe91d7603ff5 Author: s1lentq Date: Wed Jan 31 17:40:47 2024 +0700 CBasePlayer::WaterMove: No water sound playback occurs when clients emerge from network lag or was using noclip commit bde6aa07bcd1c359e38eaf5e908886d4d8762b20 Author: s1lentq Date: Wed Jan 31 15:51:44 2024 +0700 Disable door asserts (Resolves #926) commit 2d957a79152eda0ed85ee7f5e725d093ac2f8836 Author: s1lentq Date: Wed Jan 31 15:10:08 2024 +0700 utlvector.h fix assert commit 4b49f630da970cc62bb3cd7ecd65710dd7d87122 Author: s1lentq Date: Fri Jan 19 20:33:01 2024 +0700 Fix mismatched damage glock18 in burst mode 18 against 25 (GLOCK18_DAMAGE) commit 051dc0751afdf86d79660bc85c6d7ecbe1e25587 Author: Sergey Shorokhov Date: Fri Jan 12 11:55:00 2024 +0300 New ConVar: `mp_defuser_allocation` (#908) commit 89dda43b216bb771a6a1dd6960dbfa0aea603e25 Author: s1lentq Date: Fri Jan 12 13:30:01 2024 +0700 fix test demo commit 02a0516c2f257fc3e1b1bcd6408e37143944cc14 Author: s1lentq Date: Fri Jan 12 13:19:01 2024 +0700 Reset damage stats on Putin Server commit c0f47949ec8893f0f41c7d647fcdbde4d6279c99 Author: s1lentq Date: Fri Jan 12 09:27:40 2024 +0700 PM_CategorizePosition: Do not stick to the ground of an OBSERVER or NOCLIP mode commit e636cbc8f582508c0233b23de616e96998560b77 Author: s1lentq Date: Fri Jan 12 09:16:20 2024 +0700 PlayerRelationship: GR_TEAMMATE on checking itself commit 5268e6b8826317d5a4e1d3ddd2543bba3dc1e514 Merge: 9f54246 15df1a9 Author: Alejo <53284952+aleeperezz16@users.noreply.github.com> Date: Tue Jan 2 12:55:47 2024 -0300 Merge branch 's1lentq:master' into master --- README.md | 1 + dist/game.cfg | 8 ++ regamedll/common/const.h | 5 + regamedll/dlls/API/CSPlayer.cpp | 3 + regamedll/dlls/bot/cs_bot.cpp | 14 ++ regamedll/dlls/bot/cs_bot.h | 4 + regamedll/dlls/bot/cs_bot_manager.cpp | 7 +- regamedll/dlls/buttons.cpp | 7 + regamedll/dlls/cbase.cpp | 4 + regamedll/dlls/client.cpp | 28 +++- regamedll/dlls/doors.cpp | 10 +- regamedll/dlls/game.cpp | 2 + regamedll/dlls/game.h | 1 + regamedll/dlls/gamerules.h | 9 ++ regamedll/dlls/multiplay_gamerules.cpp | 72 ++++++++++ regamedll/dlls/player.cpp | 104 +++++++++++--- regamedll/dlls/player.h | 1 + regamedll/dlls/weapons.cpp | 191 ++++++++++++++++++++----- regamedll/dlls/weapons.h | 21 ++- regamedll/dlls/weapontype.cpp | 5 +- regamedll/game_shared/bot/nav_area.cpp | 5 + regamedll/game_shared/bot/nav_area.h | 1 + regamedll/pm_shared/pm_shared.cpp | 31 ++-- regamedll/public/utlvector.h | 20 +-- 24 files changed, 461 insertions(+), 93 deletions(-) diff --git a/README.md b/README.md index a2419da2f..fb9088f09 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,7 @@ This means that plugins that do binary code analysis (Orpheu for example) probab | mp_assist_damage_threshold | 40 | 0 | 100 | Sets the percentage of damage needed to score an assist. | | mp_freezetime_duck | 1 | 0 | 1 | Allow players to duck during freezetime.
`0` disabled
`1` enabled | | mp_freezetime_jump | 1 | 0 | 1 | Allow players to jump during freezetime.
`0` disabled
`1` enabled | +| mp_defuser_allocation | 0 | 0 | 2 | Give defuser on player spawn.
`0` disabled
`1` Random players.
`2` All players. | ## How to install zBot for CS 1.6? diff --git a/dist/game.cfg b/dist/game.cfg index 97fdb1fc4..d41e685b2 100644 --- a/dist/game.cfg +++ b/dist/game.cfg @@ -588,3 +588,11 @@ mp_freezetime_duck "1" // // Default value: "1" mp_freezetime_jump "1" + +// Give defuser on player spawn +// 0 - No free defusers (default behavior) +// 1 - Random players +// 2 - All players +// +// Default value: "0" +mp_defuser_allocation "0" diff --git a/regamedll/common/const.h b/regamedll/common/const.h index 024a2a3d5..f6ec01c48 100644 --- a/regamedll/common/const.h +++ b/regamedll/common/const.h @@ -158,6 +158,11 @@ #define EF_FORCEVISIBILITY BIT(11) // force visibility #define EF_OWNER_VISIBILITY BIT(12) // visibility for owner #define EF_OWNER_NO_VISIBILITY BIT(13) // no visibility for owner +#define EF_NOSLERP BIT(14) // no slerp flag for this entity (addtofullpack) +#define EF_FOLLOWKEEPRENDER BIT(15) // the entity following will not copy the render (like it follows nothing) + +// Custom flags that aren't handled by the client +#define EF_CUSTOM_BITS (EF_FORCEVISIBILITY | EF_OWNER_VISIBILITY | EF_OWNER_NO_VISIBILITY | EF_NOSLERP | EF_FOLLOWKEEPRENDER) // state->eflags values #define EFLAG_SLERP 1 // do studio interpolation of this entity diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index ad368bbb9..23c94ec21 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -557,6 +557,8 @@ void CCSPlayer::ResetAllStats() m_iNumKilledByUnanswered[i] = 0; m_bPlayerDominated[i] = false; } + + m_DamageList.Clear(); } void CCSPlayer::OnSpawn() @@ -586,6 +588,7 @@ void CCSPlayer::OnKilled() void CCSPlayer::OnConnect() { ResetVars(); + ResetAllStats(); m_iUserID = GETPLAYERUSERID(BasePlayer()->edict()); } diff --git a/regamedll/dlls/bot/cs_bot.cpp b/regamedll/dlls/bot/cs_bot.cpp index b0a484724..838387a95 100644 --- a/regamedll/dlls/bot/cs_bot.cpp +++ b/regamedll/dlls/bot/cs_bot.cpp @@ -429,6 +429,20 @@ bool CCSBot::StayOnNavMesh() return false; } +#ifdef REGAMEDLL_FIXES +void CCSBot::Kill() +{ + m_LastHitGroup = HITGROUP_GENERIC; + + // have the player kill himself + pev->health = 0.0f; + Killed(VARS(eoNullEntity), GIB_NEVER); + + if (CSGameRules()->m_pVIP == this) + CSGameRules()->m_iConsecutiveVIP = 10; +} +#endif + void CCSBot::Panic(CBasePlayer *pEnemy) { if (IsSurprised()) diff --git a/regamedll/dlls/bot/cs_bot.h b/regamedll/dlls/bot/cs_bot.h index 345e11fbd..9670744f9 100644 --- a/regamedll/dlls/bot/cs_bot.h +++ b/regamedll/dlls/bot/cs_bot.h @@ -375,6 +375,10 @@ class CCSBot: public CBot bool IsBuying() const; +#ifdef REGAMEDLL_FIXES + void Kill(); +#endif + void Panic(CBasePlayer *pEnemy); // look around in panic void Follow(CBasePlayer *pPlayer); // begin following given Player void ContinueFollowing(); // continue following our leader after finishing what we were doing diff --git a/regamedll/dlls/bot/cs_bot_manager.cpp b/regamedll/dlls/bot/cs_bot_manager.cpp index 6324ceeb7..78ce0cf5d 100644 --- a/regamedll/dlls/bot/cs_bot_manager.cpp +++ b/regamedll/dlls/bot/cs_bot_manager.cpp @@ -408,10 +408,9 @@ void CCSBotManager::ServerCommand(const char *pcmd) if (pPlayer->IsBot()) { + CCSBot *pBot = static_cast(pPlayer); if (killThemAll || FStrEq(name, msg)) - { - pPlayer->Kill(); - } + pBot->Kill(); } } } @@ -1452,7 +1451,7 @@ void CCSBotManager::SetLooseBomb(CBaseEntity *bomb) if (bomb) { m_looseBombArea = TheNavAreaGrid.GetNearestNavArea(&bomb->pev->origin); - DbgAssert(m_looseBombArea); // TODO: Need investigation and find out why it cannot find nearest area for a lost bomb, just catch it + DbgAssert(!TheNavAreaGrid.IsValid() || m_looseBombArea); // TODO: Need investigation and find out why it cannot find nearest area for a lost bomb, just catch it } else { diff --git a/regamedll/dlls/buttons.cpp b/regamedll/dlls/buttons.cpp index 8e38b369f..8ad08fe71 100644 --- a/regamedll/dlls/buttons.cpp +++ b/regamedll/dlls/buttons.cpp @@ -1,5 +1,12 @@ #include "precompiled.h" +#if !defined(DOOR_ASSERT) +#undef DbgAssert +#undef DbgAssertMsg +#define DbgAssert(_exp) ((void)0) +#define DbgAssertMsg(_exp, _msg) ((void)0) +#endif + TYPEDESCRIPTION CEnvGlobal::m_SaveData[] = { DEFINE_FIELD(CEnvGlobal, m_globalstate, FIELD_STRING), diff --git a/regamedll/dlls/cbase.cpp b/regamedll/dlls/cbase.cpp index 1d706299b..ebfd2fdc2 100644 --- a/regamedll/dlls/cbase.cpp +++ b/regamedll/dlls/cbase.cpp @@ -1449,7 +1449,11 @@ VectorRef CBaseEntity::__API_HOOK(FireBullets3)(VectorRef vecSrc, VectorRef vecD pEntity->pev->punchangle.x = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); pEntity->pev->punchangle.z = iCurrentDamage * RANDOM_FLOAT(-0.15, 0.15); +#ifndef REGAMEDLL_FIXES if (pEntity->pev->punchangle.x < 4) +#else + if (pEntity->pev->punchangle.x < -4) +#endif { pEntity->pev->punchangle.x = -4; } diff --git a/regamedll/dlls/client.cpp b/regamedll/dlls/client.cpp index 2cf9dbd63..7aa20ebee 100644 --- a/regamedll/dlls/client.cpp +++ b/regamedll/dlls/client.cpp @@ -249,7 +249,7 @@ void WriteSigonMessages() #ifdef PLAY_GAMEDLL // TODO: fix test demo - iFlags &= ~ITEM_FLAG_NOFIREUNDERWATER; + iFlags &= ~ITEM_FLAG_CUSTOM; #endif MESSAGE_BEGIN(MSG_INIT, gmsgWeaponList); @@ -4494,7 +4494,7 @@ BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, e #ifdef REGAMEDLL_ADD // don't send unhandled custom bits to client - state->effects &= ~(EF_FORCEVISIBILITY | EF_OWNER_VISIBILITY | EF_OWNER_NO_VISIBILITY); + state->effects &= ~EF_CUSTOM_BITS; if (ent->v.skin == CONTENTS_LADDER && (host->v.iuser3 & PLAYER_PREVENT_CLIMB) == PLAYER_PREVENT_CLIMB) { @@ -4502,7 +4502,13 @@ BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, e } #endif - if (!player && ent->v.animtime && !ent->v.velocity.x && !ent->v.velocity.y && !ent->v.velocity.z) + // add studio interpolation if non-player entity is moving (why?) + if (!player && +#ifdef REGAMEDLL_ADD + // adds slerp (studio interpolation) if not set + !(ent->v.effects & EF_NOSLERP) && +#endif + ent->v.animtime && !ent->v.velocity.x && !ent->v.velocity.y && !ent->v.velocity.z) state->eflags |= EFLAG_SLERP; state->scale = ent->v.scale; @@ -4528,8 +4534,22 @@ BOOL EXT_FUNC AddToFullPack(struct entity_state_s *state, int e, edict_t *ent, e state->aiment = 0; + // following something if (ent->v.aiment) - state->aiment = ENTINDEX(ent->v.aiment); + { +#ifdef REGAMEDLL_ADD + // if set, it will still follow the player with a bit of "delay", still looks fine (experimental) + if (ent->v.effects & EF_FOLLOWKEEPRENDER) + { + // will keep the current render entity values if it's set + state->movetype = MOVETYPE_NONE; + } + else +#endif + { + state->aiment = ENTINDEX(ent->v.aiment); + } + } state->owner = 0; if (ent->v.owner) diff --git a/regamedll/dlls/doors.cpp b/regamedll/dlls/doors.cpp index ada7e6a82..a6b252bc0 100644 --- a/regamedll/dlls/doors.cpp +++ b/regamedll/dlls/doors.cpp @@ -1,5 +1,12 @@ #include "precompiled.h" +#if !defined(DOOR_ASSERT) +#undef DbgAssert +#undef DbgAssertMsg +#define DbgAssert(_exp) ((void)0) +#define DbgAssertMsg(_exp, _msg) ((void)0) +#endif + TYPEDESCRIPTION CBaseDoor::m_SaveData[] = { DEFINE_FIELD(CBaseDoor, m_bHealthValue, FIELD_CHARACTER), @@ -695,10 +702,7 @@ void CBaseDoor::DoorGoDown() } } -#ifdef DOOR_ASSERT DbgAssert(m_toggle_state == TS_AT_TOP); -#endif - m_toggle_state = TS_GOING_DOWN; SetMoveDone(&CBaseDoor::DoorHitBottom); diff --git a/regamedll/dlls/game.cpp b/regamedll/dlls/game.cpp index 37b6db4f0..22dbfb715 100644 --- a/regamedll/dlls/game.cpp +++ b/regamedll/dlls/game.cpp @@ -180,6 +180,7 @@ cvar_t sv_block_vote_commands = { "sv_block_vote_commands", "0", 0, 0 cvar_t legacy_vehicle_block = { "mp_legacy_vehicle_block", "1", 0, 0.0f, nullptr }; cvar_t dying_time = { "mp_dying_time", "3.0", 0, 3.0f, nullptr }; +cvar_t defuser_allocation = { "mp_defuser_allocation", "0", 0, 0.0f, nullptr }; void GameDLL_Version_f() { @@ -440,6 +441,7 @@ void EXT_FUNC GameDLLInit() CVAR_REGISTER(&freezetime_duck); CVAR_REGISTER(&freezetime_jump); + CVAR_REGISTER(&defuser_allocation); CVAR_REGISTER(&max_alive_name_changes); CVAR_REGISTER(&legacy_restart_entities); diff --git a/regamedll/dlls/game.h b/regamedll/dlls/game.h index 270ee8019..d48850108 100644 --- a/regamedll/dlls/game.h +++ b/regamedll/dlls/game.h @@ -200,6 +200,7 @@ extern cvar_t deathmsg_flags; extern cvar_t assist_damage_threshold; extern cvar_t freezetime_duck; extern cvar_t freezetime_jump; +extern cvar_t defuser_allocation; extern cvar_t max_alive_name_changes; extern cvar_t legacy_restart_entities; diff --git a/regamedll/dlls/gamerules.h b/regamedll/dlls/gamerules.h index e29aaba88..e7dc35085 100644 --- a/regamedll/dlls/gamerules.h +++ b/regamedll/dlls/gamerules.h @@ -255,6 +255,13 @@ enum KillRarity KILLRARITY_REVENGE = 0x100 // Revenge by the killer }; +enum +{ + DEFUSERALLOCATION_NONE = 0, + DEFUSERALLOCATION_RANDOM = 1, + DEFUSERALLOCATION_ALL = 2, +}; + class CItem; class CGameRules @@ -738,6 +745,8 @@ class CHalfLifeMultiplay: public CGameRules int GetRarityOfKill(CBaseEntity *pKiller, CBasePlayer *pVictim, CBasePlayer *pAssister, const char *killerWeaponName, bool bFlashAssist); CBasePlayer *CheckAssistsToKill(CBaseEntity *pKiller, CBasePlayer *pVictim, bool &bFlashAssist); + void GiveDefuserToRandomPlayer(); + private: void MarkLivingPlayersOnTeamAsNotReceivingMoneyNextRound(int iTeam); diff --git a/regamedll/dlls/multiplay_gamerules.cpp b/regamedll/dlls/multiplay_gamerules.cpp index d16a53970..398b4b1b0 100644 --- a/regamedll/dlls/multiplay_gamerules.cpp +++ b/regamedll/dlls/multiplay_gamerules.cpp @@ -2078,6 +2078,11 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(RestartRound)() GiveC4(); } +#ifdef REGAMEDLL_ADD + if (m_bMapHasBombTarget && (int)defuser_allocation.value == DEFUSERALLOCATION_RANDOM) + GiveDefuserToRandomPlayer(); +#endif + if (TheBots) { TheBots->OnEvent(EVENT_BUY_TIME_START); @@ -3852,6 +3857,10 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerSpawn)(CBasePlayer *pPlayer) #ifdef REGAMEDLL_ADD if (respawn_immunitytime.value > 0) pPlayer->SetSpawnProtection(respawn_immunitytime.value); + + // remove any defusers left over from previous random if there is just one random one + if (m_bMapHasBombTarget && (int)defuser_allocation.value == DEFUSERALLOCATION_RANDOM) + pPlayer->RemoveDefuser(); #endif } @@ -3970,6 +3979,15 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerKilled)(CBasePlayer *pVictim, } FireTargets("game_playerdie", pVictim, pVictim, USE_TOGGLE, 0); + +#ifdef REGAMEDLL_FIXES + // Did the player die from a fall? + if (pVictim->m_bitsDamageType & DMG_FALL) + { + // do nothing + } + else +#endif // Did the player kill himself? if (pVictim->pev == pKiller) { @@ -4378,6 +4396,9 @@ edict_t *EXT_FUNC CHalfLifeMultiplay::__API_HOOK(GetPlayerSpawnSpot)(CBasePlayer int CHalfLifeMultiplay::PlayerRelationship(CBasePlayer *pPlayer, CBaseEntity *pTarget) { + if (pPlayer == pTarget) + return GR_TEAMMATE; + #ifdef REGAMEDLL_ADD if (IsFreeForAll()) { @@ -5414,3 +5435,54 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(SendDeathMessage)(CBaseEntity *pKil MESSAGE_END(); } + +void CHalfLifeMultiplay::GiveDefuserToRandomPlayer() +{ + int iDefusersToGive = 2; + CUtlVector candidates; + candidates.EnsureCapacity(MAX_CLIENTS); + + // add all CT candidates to a list + for (int i = 1; i <= gpGlobals->maxClients; i++) + { + CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); + if (!pPlayer || FNullEnt(pPlayer->edict())) + continue; + + if (!pPlayer->IsAlive() || pPlayer->m_iTeam != CT) + continue; + + candidates.AddToTail(pPlayer); + } + + // randomly shuffle the list; this will keep the selection random in case of ties + for (int i = 0; i < candidates.Count(); i++) { + SWAP(candidates[i], candidates[RANDOM_LONG(0, candidates.Count() - 1)]); + } + + // now sort the shuffled list into subgroups + candidates.Sort([](CBasePlayer *const *left, CBasePlayer *const *right) -> int { + // should we prioritize humans over bots? + if (cv_bot_defer_to_human.value != 0.0f) + { + if ((*left)->IsBot() && !(*right)->IsBot()) + return 1; + + if (!(*left)->IsBot() && (*right)->IsBot()) + return -1; + } + + return 0; + } + ); + + // give defusers to the first N candidates + for (int i = 0; i < iDefusersToGive && i < candidates.Count(); ++i) + { + CBasePlayer *pPlayer = candidates[i]; + assert(pPlayer && pPlayer->m_iTeam == CT && pPlayer->IsAlive()); + + pPlayer->GiveDefuser(); + ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Got_defuser"); + } +} diff --git a/regamedll/dlls/player.cpp b/regamedll/dlls/player.cpp index 3b6671e6e..5df67f700 100644 --- a/regamedll/dlls/player.cpp +++ b/regamedll/dlls/player.cpp @@ -1319,26 +1319,52 @@ CWeaponBox *EXT_FUNC __API_HOOK(CreateWeaponBox)(CBasePlayerItem *pItem, CBasePl pWeaponBox->pev->nextthink = gpGlobals->time + lifeTime; pWeaponBox->PackWeapon(pItem); // now pack all of the items in the lists - // pack the ammo - bool exhaustibleAmmo = (pItem->iFlags() & ITEM_FLAG_EXHAUSTIBLE) == ITEM_FLAG_EXHAUSTIBLE; - if ((exhaustibleAmmo || packAmmo) && pPlayerOwner) + // player is the ammo source + if (pPlayerOwner) { -#ifndef REGAMEDLL_ADD - pWeaponBox->PackAmmo(MAKE_STRING(pItem->pszAmmo1()), pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()]); -#else - pWeaponBox->GiveAmmo(pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()], (char *)pItem->pszAmmo1(), pItem->iMaxAmmo1()); -#endif -#ifndef REGAMEDLL_FIXES // by removing ammo ONLY on exhaustible weapons (slot 4 and 5) // you are allowing to duplicate ammo whenever: // (1) you have 2 weapons sharing the same ammo type (e.g. mp5navy and glock) // (2) you are dropping a weapon alive and pickup another (with same ammo type) without ammo // and, logically, you throw your ammo with your gun with packing enabled - if (exhaustibleAmmo) + bool exhaustibleAmmo = (pItem->iFlags() & ITEM_FLAG_EXHAUSTIBLE) == ITEM_FLAG_EXHAUSTIBLE; + + // pack the primary ammo + if (exhaustibleAmmo || packAmmo) + { +#ifndef REGAMEDLL_ADD + pWeaponBox->PackAmmo(MAKE_STRING(pItem->pszAmmo1()), pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()]); +#else + pWeaponBox->GiveAmmo(pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()], (char *)pItem->pszAmmo1(), pItem->iMaxAmmo1()); +#endif + +#ifndef REGAMEDLL_FIXES + if (exhaustibleAmmo) #endif + { + pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()] = 0; + } + } + + // (3rd party support) now that reapi can register custom ammo +#ifdef REGAMEDLL_ADD + // use this flag if you don't want the player harvesting this kind of ammo from dropped weapons + bool exhaustSecondaryAmmo = (pItem->iFlags() & ITEM_FLAG_EXHAUST_SECONDARYAMMO) == ITEM_FLAG_EXHAUST_SECONDARYAMMO; + int iSecondaryAmmoIndex = pItem->SecondaryAmmoIndex(); + + // pack secondary ammo now (must be valid too) + if ((exhaustibleAmmo || exhaustSecondaryAmmo || packAmmo) && iSecondaryAmmoIndex != -1) { - pPlayerOwner->m_rgAmmo[pItem->PrimaryAmmoIndex()] = 0; + pWeaponBox->GiveAmmo(pPlayerOwner->m_rgAmmo[iSecondaryAmmoIndex], (char *)pItem->pszAmmo2(), pItem->iMaxAmmo2()); + +#ifndef REGAMEDLL_FIXES + if (exhaustibleAmmo) +#endif + { + pPlayerOwner->m_rgAmmo[iSecondaryAmmoIndex] = 0; + } } +#endif } pWeaponBox->SetModel(modelName); @@ -3098,11 +3124,16 @@ void CBasePlayer::WaterMove() // not underwater // play 'up for air' sound - if (pev->air_finished < gpGlobals->time) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM); +#ifdef REGAMEDLL_FIXES + if (pev->flags & FL_INWATER) +#endif + { + if (pev->air_finished < gpGlobals->time) + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade1.wav", VOL_NORM, ATTN_NORM); - else if (pev->air_finished < gpGlobals->time + 9) - EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade2.wav", VOL_NORM, ATTN_NORM); + else if (pev->air_finished < gpGlobals->time + 9) + EMIT_SOUND(ENT(pev), CHAN_VOICE, "player/pl_wade2.wav", VOL_NORM, ATTN_NORM); + } pev->air_finished = gpGlobals->time + AIRTIME; pev->dmg = 2; @@ -3679,7 +3710,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(JoiningThink)() } if (m_pIntroCamera && gpGlobals->time >= m_fIntroCamTime -#ifdef REGAMEDLL_FIXES +#ifdef REGAMEDLL_FIXES && m_fIntroCamTime > 0.0 // update only if cameras are available #endif ) @@ -6336,6 +6367,44 @@ CBaseEntity *CBasePlayer::GiveNamedItemEx(const char *pszName) return pEntity; } +// Creates a copy of the specified entity (pEntitySource) and gives it to the player +// The cloned entity inherits base properties (entvars) of the original entity +// Returns Pointer to the cloned entity, or NULL if the entity cannot be created +CBaseEntity *CBasePlayer::GiveCopyItem(CBaseEntity *pEntitySource) +{ + edict_t *pEdict = CREATE_NAMED_ENTITY(pEntitySource->pev->classname); + if (FNullEnt(pEdict)) + { + ALERT(at_console, "NULL Ent in GiveCloneItem classname `%s`!\n", STRING(pEntitySource->pev->classname)); + return nullptr; + } + + // copy entity properties + Q_memcpy(&pEdict->v, pEntitySource->pev, sizeof(pEdict->v)); + + pEdict->v.pContainingEntity = pEdict; + pEdict->v.origin = pev->origin; + pEdict->v.spawnflags |= SF_NORESPAWN; + pEdict->v.owner = NULL; // will re-link owner after touching + pEdict->v.chain = ENT(pEntitySource->pev); // refer to source copy entity + + DispatchSpawn(pEdict); + DispatchTouch(pEdict, ENT(pev)); + pEdict->v.chain = NULL; + + CBaseEntity *pEntity = GET_PRIVATE(pEdict); + + // not allow the item to fall to the ground. + if (FNullEnt(pEdict->v.owner) || pEdict->v.owner != edict()) + { + pEdict->v.flags |= FL_KILLME; + UTIL_Remove(pEntity); + return nullptr; + } + + return pEntity; +} + CBaseEntity *FindEntityForward(CBaseEntity *pEntity) { TraceResult tr; @@ -10330,6 +10399,9 @@ void EXT_FUNC CBasePlayer::__API_HOOK(OnSpawnEquip)(bool addDefault, bool equipG case ARMOR_VESTHELM: GiveNamedItemEx("item_assaultsuit"); break; } } + + if (NeedsDefuseKit() && (int)defuser_allocation.value == DEFUSERALLOCATION_ALL) + GiveNamedItemEx("item_thighpack"); #endif } diff --git a/regamedll/dlls/player.h b/regamedll/dlls/player.h index 4595bf226..8908e44c9 100644 --- a/regamedll/dlls/player.h +++ b/regamedll/dlls/player.h @@ -536,6 +536,7 @@ class CBasePlayer: public CBaseMonster { void ItemPostFrame(); CBaseEntity *GiveNamedItem(const char *pszName); CBaseEntity *GiveNamedItemEx(const char *pszName); + CBaseEntity *GiveCopyItem(CBaseEntity *pEntityBase); void EnableControl(BOOL fControl); bool HintMessage(const char *pMessage, BOOL bDisplayIfPlayerDead = FALSE, BOOL bOverride = FALSE); bool HintMessageEx(const char *pMessage, float duration = 6.0f, bool bDisplayIfPlayerDead = false, bool bOverride = false); diff --git a/regamedll/dlls/weapons.cpp b/regamedll/dlls/weapons.cpp index b43b05473..3f441975e 100644 --- a/regamedll/dlls/weapons.cpp +++ b/regamedll/dlls/weapons.cpp @@ -816,9 +816,15 @@ void CBasePlayerWeapon::FireRemaining(int &shotsFired, float &shootTime, BOOL bI flag = 0; #endif +#ifdef REGAMEDLL_API + float flBaseDamage = CSPlayerWeapon()->m_flBaseDamage; +#else + float flBaseDamage = bIsGlock ? GLOCK18_DAMAGE : FAMAS_DAMAGE; +#endif + if (bIsGlock) { - vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, 0.05, 8192, 1, BULLET_PLAYER_9MM, 18, 0.9, m_pPlayer->pev, true, m_pPlayer->random_seed); + vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, 0.05, 8192, 1, BULLET_PLAYER_9MM, flBaseDamage, 0.9, m_pPlayer->pev, true, m_pPlayer->random_seed); #ifndef REGAMEDLL_FIXES --m_pPlayer->ammo_9mm; #endif @@ -827,8 +833,7 @@ void CBasePlayerWeapon::FireRemaining(int &shotsFired, float &shootTime, BOOL bI } else { - - vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, m_fBurstSpread, 8192, 2, BULLET_PLAYER_556MM, 30, 0.96, m_pPlayer->pev, false, m_pPlayer->random_seed); + vecDir = m_pPlayer->FireBullets3(vecSrc, gpGlobals->v_forward, m_fBurstSpread, 8192, 2, BULLET_PLAYER_556MM, flBaseDamage, 0.96, m_pPlayer->pev, false, m_pPlayer->random_seed); #ifndef REGAMEDLL_FIXES --m_pPlayer->ammo_556nato; #endif @@ -1302,9 +1307,19 @@ int CBasePlayerWeapon::AddToPlayer(CBasePlayer *pPlayer) if (!m_iPrimaryAmmoType) { m_iPrimaryAmmoType = pPlayer->GetAmmoIndex(pszAmmo1()); +#ifndef REGAMEDLL_FIXES m_iSecondaryAmmoType = pPlayer->GetAmmoIndex(pszAmmo2()); +#endif } +#ifdef REGAMEDLL_FIXES + // (3rd party support) if someone updates (or screws) the secondary ammo type later + if (!m_iSecondaryAmmoType) + { + m_iSecondaryAmmoType = pPlayer->GetAmmoIndex(pszAmmo2()); + } +#endif + if (AddWeapon()) { return CBasePlayerItem::AddToPlayer(pPlayer); @@ -1630,7 +1645,11 @@ int CBasePlayerWeapon::PrimaryAmmoIndex() int CBasePlayerWeapon::SecondaryAmmoIndex() { +#ifdef REGAMEDLL_ADD + return m_iSecondaryAmmoType; +#else return -1; +#endif } void CBasePlayerWeapon::Holster(int skiplocal) @@ -1660,7 +1679,7 @@ int CBasePlayerWeapon::ExtractAmmo(CBasePlayerWeapon *pWeapon) if (pszAmmo2()) { - res = AddSecondaryAmmo(0, (char *)pszAmmo2(), iMaxAmmo2()); + res = pWeapon->AddSecondaryAmmo(0, (char *)pszAmmo2(), iMaxAmmo2()); } return res; @@ -1875,6 +1894,91 @@ void CWeaponBox::Kill() UTIL_Remove(this); } +bool CWeaponBox::GiveAmmoToPlayer(CBasePlayer *pPlayer, CBasePlayerWeapon *pWeapon, int iCurrentAmmo, const char *pszAmmo, int iMaxAmmo, CBasePlayerItem **pGivenItem) +{ + if (iCurrentAmmo >= iMaxAmmo) + return false; // can't pickup more, these ammo are full in backpack + + // If already have a weapon in backpack, just refill ammo for it + int iAmmoIndex = GetAmmoIndex(pszAmmo); + if (iAmmoIndex > 0) + { + // How many weapon ammo can pick up? + int iAmmoPickup = min(m_rgAmmo[iAmmoIndex], iMaxAmmo - iCurrentAmmo); + if (iAmmoPickup > 0) + { + if (iCurrentAmmo == 0 && !(pPlayer->pev->weapons & (1<m_iId)) && (pWeapon->iFlags() & ITEM_FLAG_EXHAUSTIBLE)) + { + if (m_rgAmmo[iAmmoIndex] > iMaxAmmo) + { + // If ammo capacity of the dropped weapon exceeds the player's backpack capacity, + // make a copy of dropped weapon and give it to the player + CBasePlayerItem *copyItem = (CBasePlayerItem *)pPlayer->GiveCopyItem(pWeapon); + if (copyItem) + { + // The cloned weapon must inherit properties from a dropped weapon, such as Item Info +#ifdef REGAMEDLL_API + ItemInfo info; + if (pWeapon->CSPlayerItem()->GetItemInfo(&info)) + copyItem->CSPlayerItem()->SetItemInfo(&info); +#endif + m_rgAmmo[iAmmoIndex]--; + iAmmoPickup--; + } + } + else + { + // If no weapon in backpack, then issue weapon + if (pPlayer->AddPlayerItem(pWeapon)) + { + pWeapon->AttachToPlayer(pPlayer); + if (pGivenItem) *pGivenItem = pWeapon; + } + + // unlink this weapon from the box + return true; + } + } + + Assert(iAmmoPickup != 0); + Assert(m_rgAmmo[iAmmoIndex] != 0); + + if (!FStringNull(m_rgiszAmmo[iAmmoIndex]) && + pPlayer->GiveAmmo(iAmmoPickup, STRING(m_rgiszAmmo[iAmmoIndex]), iMaxAmmo) != -1) + { + m_rgAmmo[iAmmoIndex] -= iAmmoPickup; + + if (m_rgAmmo[iAmmoIndex] < 0) + m_rgAmmo[iAmmoIndex] = 0; + + EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); + } + } + + // ammo exhausted, remove this weapon + if (m_rgAmmo[iAmmoIndex] <= 0) + { + pWeapon->Kill(); + + // unlink this weapon from the box + return true; + } + + // ammo has not been exhausted yet, keep this weapon in weaponbox + return false; + } + + // If no weapon in backpack, then issue weapon + if (pPlayer->AddPlayerItem(pWeapon)) + { + pWeapon->AttachToPlayer(pPlayer); + if (pGivenItem) *pGivenItem = pWeapon; + } + + // unlink this weapon from the box + return true; +} + // Try to add my contents to the toucher if the toucher is a player. void CWeaponBox::Touch(CBaseEntity *pOther) { @@ -2020,38 +2124,28 @@ void CWeaponBox::Touch(CBaseEntity *pOther) int playerGrenades = pPlayer->m_rgAmmo[pGrenade->m_iPrimaryAmmoType]; #ifdef REGAMEDLL_FIXES - // sorry for hardcode :( - const int boxAmmoSlot = 1; - - if (playerGrenades < pGrenade->iMaxAmmo1()) + CBasePlayerItem *pNext = m_rgpPlayerItems[i]->m_pNext; + + // Determine the max ammo capacity for the picked-up grenade + int iMaxPickupAmmo = pGrenade->iMaxAmmo1(); + + // If the player already has the same weapon in inventory, + // prioritize the max ammo capacity value over the one from the dropped weapon + // When the pickup occurs, ammo will be granted up to + // the max ammo capacity of the weapon currently held by the player + CBasePlayerItem *pInventoryItem = (CBasePlayerItem *)pPlayer->GetItemById((WeaponIdType)pGrenade->m_iId); + if (pInventoryItem && !Q_stricmp(pInventoryItem->pszAmmo1(), pGrenade->pszAmmo1())) + iMaxPickupAmmo = pInventoryItem->iMaxAmmo1(); + + // Pickup grenade item or refill ammo + if (GiveAmmoToPlayer(pPlayer, pGrenade, + playerGrenades, pGrenade->pszAmmo1(), iMaxPickupAmmo, &givenItem)) { - if (m_rgAmmo[boxAmmoSlot] > 1 && playerGrenades > 0) - { - if (!FStringNull(m_rgiszAmmo[boxAmmoSlot]) - && pPlayer->GiveAmmo(1, STRING(m_rgiszAmmo[boxAmmoSlot]), pGrenade->iMaxAmmo1()) != -1) - { - m_rgAmmo[boxAmmoSlot]--; - - EMIT_SOUND(pPlayer->edict(), CHAN_ITEM, "items/9mmclip1.wav", VOL_NORM, ATTN_NORM); - } - } - else - { - auto pNext = m_rgpPlayerItems[i]->m_pNext; - - if (pPlayer->AddPlayerItem(pItem)) - { - pItem->AttachToPlayer(pPlayer); - givenItem = pItem; - } - - // unlink this weapon from the box - m_rgpPlayerItems[i] = pItem = pNext; - continue; - } + // unlink this weapon from the box + m_rgpPlayerItems[i] = pItem = pNext; + continue; } #else - int maxGrenades = 0; const char *grenadeName = nullptr; @@ -2125,13 +2219,18 @@ void CWeaponBox::Touch(CBaseEntity *pOther) { if (!FStringNull(m_rgiszAmmo[n])) { - // there's some ammo of this type. -#ifndef REGAMEDLL_ADD - pPlayer->GiveAmmo(m_rgAmmo[n], (char *)STRING(m_rgiszAmmo[n]), MaxAmmoCarry(m_rgiszAmmo[n])); + // there's some ammo of this type + if (m_rgAmmo[n] > 0) + { +#ifdef REGAMEDLL_ADD + int iMaxAmmo = m_rgAmmo[n]; #else - pPlayer->GiveAmmo(m_rgAmmo[n], STRING(m_rgiszAmmo[n]), m_rgAmmo[n]); + int iMaxAmmo = MaxAmmoCarry(m_rgiszAmmo[n]); #endif + pPlayer->GiveAmmo(m_rgAmmo[n], STRING(m_rgiszAmmo[n]), iMaxAmmo); + } + // now empty the ammo from the weaponbox since we just gave it to the player m_rgiszAmmo[n] = iStringNull; m_rgAmmo[n] = 0; @@ -2271,6 +2370,24 @@ int CWeaponBox::GiveAmmo(int iCount, char *szName, int iMax, int *pIndex) return i; } +int CWeaponBox::GetAmmoIndex(const char *psz) const +{ + if (!psz) + return -1; + + int i; + for (i = 1; i < MAX_AMMO_SLOTS; i++) + { + if (FStringNull(m_rgiszAmmo[i])) + continue; + + if (!Q_stricmp(STRING(m_rgiszAmmo[i]), psz)) + return i; + } + + return -1; +} + // Is a weapon of this type already packed in this box? BOOL CWeaponBox::HasWeapon(CBasePlayerItem *pCheckItem) { diff --git a/regamedll/dlls/weapons.h b/regamedll/dlls/weapons.h index 0e865fa70..a52a1c1b7 100644 --- a/regamedll/dlls/weapons.h +++ b/regamedll/dlls/weapons.h @@ -35,12 +35,16 @@ const float MAX_DIST_RELOAD_SOUND = 512.0f; #define MAX_WEAPONS 32 -#define ITEM_FLAG_SELECTONEMPTY BIT(0) -#define ITEM_FLAG_NOAUTORELOAD BIT(1) -#define ITEM_FLAG_NOAUTOSWITCHEMPTY BIT(2) -#define ITEM_FLAG_LIMITINWORLD BIT(3) -#define ITEM_FLAG_EXHAUSTIBLE BIT(4) // A player can totally exhaust their ammo supply and lose this weapon -#define ITEM_FLAG_NOFIREUNDERWATER BIT(5) +#define ITEM_FLAG_SELECTONEMPTY BIT(0) +#define ITEM_FLAG_NOAUTORELOAD BIT(1) +#define ITEM_FLAG_NOAUTOSWITCHEMPTY BIT(2) +#define ITEM_FLAG_LIMITINWORLD BIT(3) +#define ITEM_FLAG_EXHAUSTIBLE BIT(4) // A player can totally exhaust their ammo supply and lose this weapon +#define ITEM_FLAG_NOFIREUNDERWATER BIT(5) +#define ITEM_FLAG_EXHAUST_SECONDARYAMMO BIT(6) // A player will exhaust weapon's secondary ammo supply if dropped (ITEM_FLAG_EXHAUSTIBLE does both) + +// if someone has an idea for another flag pack it here, so client prediction will not be screwed (or something) if PLAY_GAMEDLL is defined +#define ITEM_FLAG_CUSTOM (ITEM_FLAG_NOFIREUNDERWATER | ITEM_FLAG_EXHAUST_SECONDARYAMMO) #define WEAPON_IS_ONTARGET 0x40 @@ -473,6 +477,9 @@ class CWeaponBox: public CBaseEntity public: BOOL IsEmpty(); int GiveAmmo(int iCount, char *szName, int iMax, int *pIndex = nullptr); + int GetAmmoIndex(const char *psz) const; + bool GiveAmmoToPlayer(CBasePlayer *pPlayer, CBasePlayerWeapon *pWeapon, + int iCurrentAmmo, const char *pszAmmo, int iMaxAmmo, CBasePlayerItem **pGivenItem = NULL); void EXPORT Kill(); void EXPORT BombThink(); @@ -1265,7 +1272,7 @@ inline float CKnife::KnifeSwingDamage(bool fast) const { return fast ? m_flSwing inline float CKnife::KnifeStabDistance() const { return m_flStabDistance; } inline float CKnife::KnifeSwingDistance() const { return m_flSwingDistance; } inline float CKnife::KnifeBackStabMultiplier() const { return m_flBackStabMultiplier; } -#else +#else inline float CKnife::KnifeStabDamage() const { return KNIFE_STAB_DAMAGE; } inline float CKnife::KnifeSwingDamage(bool fast) const { return fast ? KNIFE_SWING_DAMAGE_FAST : KNIFE_SWING_DAMAGE; } inline float CKnife::KnifeStabDistance() const { return KNIFE_STAB_DISTANCE; } diff --git a/regamedll/dlls/weapontype.cpp b/regamedll/dlls/weapontype.cpp index 2b8ae4458..dd7dc0f82 100644 --- a/regamedll/dlls/weapontype.cpp +++ b/regamedll/dlls/weapontype.cpp @@ -290,7 +290,7 @@ AmmoInfoStruct g_ammoInfo_default[] = AmmoInfoStruct g_ammoInfo[ARRAYSIZE(g_ammoInfo_default)]; -WeaponSlotInfo g_weaponSlotInfo[] = { +WeaponSlotInfo g_weaponSlotInfo_default[] = { { WEAPON_C4, C4_SLOT, "weapon_c4" }, { WEAPON_KNIFE, KNIFE_SLOT, "weapon_knife" }, { WEAPON_P228, PISTOL_SLOT, "weapon_p228" }, @@ -324,6 +324,8 @@ WeaponSlotInfo g_weaponSlotInfo[] = { { WEAPON_SHIELDGUN, NONE_SLOT, "weapon_shield" }, }; +WeaponSlotInfo g_weaponSlotInfo[ARRAYSIZE(g_weaponSlotInfo_default)]; + // Given an alias, return the associated weapon ID WeaponIdType AliasToWeaponID(const char *alias) { @@ -566,6 +568,7 @@ void WeaponInfoReset() { Q_memcpy(g_weaponInfo, g_weaponInfo_default, sizeof(g_weaponInfo)); Q_memcpy(g_ammoInfo, g_ammoInfo_default, sizeof(g_ammoInfo)); + Q_memcpy(g_weaponSlotInfo, g_weaponSlotInfo_default, sizeof(g_weaponSlotInfo)); } WeaponSlotInfo *GetWeaponSlot(WeaponIdType weaponID) diff --git a/regamedll/game_shared/bot/nav_area.cpp b/regamedll/game_shared/bot/nav_area.cpp index 4e4bb309d..1ff3ef8c5 100644 --- a/regamedll/game_shared/bot/nav_area.cpp +++ b/regamedll/game_shared/bot/nav_area.cpp @@ -4674,6 +4674,11 @@ void CNavAreaGrid::RemoveNavArea(CNavArea *area) m_areaCount--; } +bool CNavAreaGrid::IsValid() const +{ + return m_grid && m_areaCount > 0; +} + // Given a position, return the nav area that IsOverlapping and is *immediately* beneath it CNavArea *CNavAreaGrid::GetNavArea(const Vector *pos, float beneathLimit) const { diff --git a/regamedll/game_shared/bot/nav_area.h b/regamedll/game_shared/bot/nav_area.h index 434424a1c..d1ed024ec 100644 --- a/regamedll/game_shared/bot/nav_area.h +++ b/regamedll/game_shared/bot/nav_area.h @@ -503,6 +503,7 @@ class CNavAreaGrid CNavArea *GetNavAreaByID(unsigned int id) const; CNavArea *GetNearestNavArea(const Vector *pos, bool anyZ = false) const; + bool IsValid() const; Place GetPlace(const Vector *pos) const; // return radio chatter place for given coordinate private: diff --git a/regamedll/pm_shared/pm_shared.cpp b/regamedll/pm_shared/pm_shared.cpp index b41a23927..ed6819769 100644 --- a/regamedll/pm_shared/pm_shared.cpp +++ b/regamedll/pm_shared/pm_shared.cpp @@ -1345,27 +1345,27 @@ qboolean PM_InWater() // Sets pmove->waterlevel and pmove->watertype values. qboolean PM_CheckWater() { -#ifdef REGAMEDLL_FIXES - // do not check for dead - if (pmove->dead || pmove->deadflag != DEAD_NO) - return FALSE; -#endif - vec3_t point; int cont; int truecont; float height; float heightover2; + // Assume that we are not in water at all. + pmove->waterlevel = 0; + pmove->watertype = CONTENTS_EMPTY; + +#ifdef REGAMEDLL_FIXES + // do not check for dead + if (pmove->dead || pmove->deadflag != DEAD_NO) + return FALSE; +#endif + // Pick a spot just above the players feet. point[0] = pmove->origin[0] + (pmove->player_mins[pmove->usehull][0] + pmove->player_maxs[pmove->usehull][0]) * 0.5f; point[1] = pmove->origin[1] + (pmove->player_mins[pmove->usehull][1] + pmove->player_maxs[pmove->usehull][1]) * 0.5f; point[2] = pmove->origin[2] + pmove->player_mins[pmove->usehull][2] + 1; - // Assume that we are not in water at all. - pmove->waterlevel = 0; - pmove->watertype = CONTENTS_EMPTY; - // Grab point contents. cont = pmove->PM_PointContents(point, &truecont); @@ -1436,6 +1436,15 @@ void PM_CategorizePosition() // water on each call, and the converse case will correct itself if called twice. PM_CheckWater(); + // Do not stick to the ground of an OBSERVER or NOCLIP mode +#ifdef REGAMEDLL_FIXES + if (pmove->movetype == MOVETYPE_NOCLIP || pmove->movetype == MOVETYPE_NONE) + { + pmove->onground = -1; + return; + } +#endif + point[0] = pmove->origin[0]; point[1] = pmove->origin[1]; point[2] = pmove->origin[2] - 2; @@ -3275,7 +3284,7 @@ void EXT_FUNC __API_HOOK(PM_Move)(struct playermove_s *ppmove, int server) DbgAssert(pm_shared_initialized); pmove = ppmove; - + #ifdef REGAMEDLL_API pmoveplayer = UTIL_PlayerByIndex(pmove->player_index + 1)->CSPlayer(); #endif diff --git a/regamedll/public/utlvector.h b/regamedll/public/utlvector.h index e3f34e585..8c0b20d3e 100644 --- a/regamedll/public/utlvector.h +++ b/regamedll/public/utlvector.h @@ -43,13 +43,6 @@ class CUtlVector CUtlVector(T *pMemory, int numElements); ~CUtlVector(); - // features C++11 ranged based for - T *begin() { return &m_Memory[0]; } - T *end() { return &m_Memory[m_Size]; } - - T const *begin() const { return &m_Memory[0]; } - T const *end() const { return &m_Memory[m_Size]; } - // Copy the array. CUtlVector &operator=(const CUtlVector &other); @@ -59,6 +52,13 @@ class CUtlVector T &Element(int i); T const &Element(int i) const; + // STL compatible member functions. These allow easier use of std::sort + // and they are forward compatible with the C++ 11 range-based for loops + T *begin() { return Base(); } + const T *begin() const { return Base(); } + T *end() { return Base() + Count(); } + const T *end() const { return Base() + Count(); } + // Gets the base address (can change when adding elements!) T *Base(); T const *Base() const; @@ -583,13 +583,13 @@ void CUtlVector::SetGrowSize(int size) template void CUtlVector::Sort() { - std::sort(Base(), Base() + Count()); + std::sort(begin(), end()); } template void CUtlVector::Sort(bool (*pfnLessFunc)(const T &src1, const T &src2)) { - std::sort(Base(), Base() + Count(), + std::sort(begin(), end(), [pfnLessFunc](const T &a, const T &b) -> bool { if (&a == &b) @@ -628,5 +628,5 @@ template template void CUtlVector::SortPredicate(F &&predicate) { - std::sort(Base(), Base() + Count(), predicate); + std::sort(begin(), end(), predicate); }