diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 78a8b7d3f..ca1c0f7df 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ on: jobs: windows: name: 'Windows' - runs-on: windows-latest + runs-on: windows-2019 env: solution: 'msvc/ReGameDLL.sln' diff --git a/regamedll/dlls/API/CAPI_Impl.cpp b/regamedll/dlls/API/CAPI_Impl.cpp index 0fe10a490..47532642b 100644 --- a/regamedll/dlls/API/CAPI_Impl.cpp +++ b/regamedll/dlls/API/CAPI_Impl.cpp @@ -30,12 +30,15 @@ CReGameHookchains g_ReGameHookchains; -int EXT_FUNC Cmd_Argc_api() { - return CMD_ARGC_(); -} +void Regamedll_ChangeString_api(char *&dest, const char *source) +{ + size_t len = Q_strlen(source); + if (dest == nullptr || Q_strlen(dest) != len) { + delete [] dest; + dest = new char [len + 1]; + } -const char *EXT_FUNC Cmd_Argv_api(int i) { - return CMD_ARGV_(i); + Q_strcpy(dest, source); } CGrenade *PlantBomb_api(entvars_t *pevOwner, Vector &vecStart, Vector &vecVelocity) { @@ -51,22 +54,22 @@ void SpawnRandomGibs_api(entvars_t *pevVictim, int cGibs, int human) { } ReGameFuncs_t g_ReGameApiFuncs = { - &CREATE_NAMED_ENTITY, + CREATE_NAMED_ENTITY, - &Regamedll_ChangeString_api, + Regamedll_ChangeString_api, - &RadiusDamage_api, - &ClearMultiDamage_api, - &ApplyMultiDamage_api, - &AddMultiDamage_api, + RadiusDamage, + ClearMultiDamage, + ApplyMultiDamage, + AddMultiDamage, - &UTIL_FindEntityByString, + UTIL_FindEntityByString, - &AddEntityHashValue, - &RemoveEntityHashValue, + AddEntityHashValue, + RemoveEntityHashValue, - Cmd_Argc_api, - Cmd_Argv_api, + CMD_ARGC_, + CMD_ARGV_, PlantBomb_api, @@ -265,35 +268,4 @@ bool CReGameApi::BGetIGameRules(const char *pchVersion) const return false; } -EXT_FUNC void Regamedll_ChangeString_api(char *&dest, const char *source) -{ - size_t len = Q_strlen(source); - if (dest == nullptr || Q_strlen(dest) != len) { - delete [] dest; - dest = new char [len + 1]; - } - - Q_strcpy(dest, source); -} - -EXT_FUNC void RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType) -{ - RadiusDamage(vecSrc, pevInflictor, pevAttacker, flDamage, flRadius, iClassIgnore, bitsDamageType); -} - -EXT_FUNC void ClearMultiDamage_api() -{ - ClearMultiDamage(); -} - -EXT_FUNC void ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker) -{ - ApplyMultiDamage(pevInflictor, pevAttacker); -} - -EXT_FUNC void AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType) -{ - AddMultiDamage(pevInflictor, pEntity, flDamage, bitsDamageType); -} - EXPOSE_SINGLE_INTERFACE(CReGameApi, IReGameApi, VRE_GAMEDLL_API_VERSION); diff --git a/regamedll/dlls/API/CAPI_Impl.h b/regamedll/dlls/API/CAPI_Impl.h index 1be3dd232..311f612ed 100644 --- a/regamedll/dlls/API/CAPI_Impl.h +++ b/regamedll/dlls/API/CAPI_Impl.h @@ -906,8 +906,8 @@ class CReGameHookchains: public IReGameHookchains { virtual IReGameHookRegistry_CBasePlayer_JoiningThink *CBasePlayer_JoiningThink(); }; -extern CReGameHookchains g_ReGameHookchains; -extern ReGameFuncs_t g_ReGameApiFuncs; +C_DLLEXPORT CReGameHookchains g_ReGameHookchains; +C_DLLEXPORT ReGameFuncs_t g_ReGameApiFuncs; class CReGameApi: public IReGameApi { public: @@ -930,10 +930,3 @@ class CReGameApi: public IReGameApi { EXT_FUNC virtual bool BGetICSEntity(const char *pchVersion) const; EXT_FUNC virtual bool BGetIGameRules(const char *pchVersion) const; }; - -void Regamedll_ChangeString_api(char *&dest, const char *source); -void RadiusDamage_api(Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType); - -void ClearMultiDamage_api(); -void ApplyMultiDamage_api(entvars_t *pevInflictor, entvars_t *pevAttacker); -void AddMultiDamage_api(entvars_t *pevInflictor, CBaseEntity *pEntity, float flDamage, int bitsDamageType); diff --git a/regamedll/dlls/API/CSPlayer.cpp b/regamedll/dlls/API/CSPlayer.cpp index 6b11725fe..dd5dda750 100644 --- a/regamedll/dlls/API/CSPlayer.cpp +++ b/regamedll/dlls/API/CSPlayer.cpp @@ -43,6 +43,11 @@ EXT_FUNC bool CCSPlayer::JoinTeam(TeamName team) pPlayer->pev->deadflag = DEAD_DEAD; pPlayer->pev->health = 0; + // Drop the C4 when we move toward spectator! + if(pPlayer->m_bHasC4) + { + pPlayer->DropPlayerItem("weapon_c4"); + } pPlayer->RemoveAllItems(TRUE); pPlayer->m_bHasC4 = false; @@ -200,7 +205,6 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov return true; } - else if (FStrEq(pszItemName, "weapon_shield")) { return RemoveShield(); @@ -209,33 +213,35 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov auto pItem = GetItemByName(pszItemName); if (pItem) { - if (FClassnameIs(pItem->pev, "weapon_c4")) { - pPlayer->m_bHasC4 = false; - pPlayer->pev->body = 0; - pPlayer->SetBombIcon(FALSE); - pPlayer->SetProgressBarTime(0); - } - - if (pItem->IsWeapon()) - { - if (pItem == pPlayer->m_pActiveItem) { - ((CBasePlayerWeapon *)pItem)->RetireWeapon(); - } - - if (bRemoveAmmo) { - pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; - } - } + CBasePlayerItem *pActiveItem = pPlayer->m_pActiveItem; if (pPlayer->RemovePlayerItem(pItem)) { pPlayer->pev->weapons &= ~(1 << pItem->m_iId); - // No more weapon + // No more weapon. if ((pPlayer->pev->weapons & ~(1 << WEAPON_SUIT)) == 0) { pPlayer->m_iHideHUD |= HIDEHUD_WEAPONS; } pItem->Kill(); + if (pItem->IsWeapon()) { + if (pItem == pActiveItem) { + g_pGameRules->GetNextBestWeapon(pPlayer, pActiveItem); + } + + // Critical if we share BP ammo with others, a mode like <0|1|2> where "1" check if no other weapon use such ammo type would have been better. + if (bRemoveAmmo || (pItem->iFlags() & ITEM_FLAG_EXHAUSTIBLE)) { + pPlayer->m_rgAmmo[ pItem->PrimaryAmmoIndex() ] = 0; + } + } + + if (FClassnameIs(pItem->pev, "weapon_c4")) { + pPlayer->m_bHasC4 = false; + pPlayer->pev->body = 0; + pPlayer->SetBombIcon(FALSE); + pPlayer->SetProgressBarTime(0); + } + if (!pPlayer->m_rgpPlayerItems[PRIMARY_WEAPON_SLOT]) { pPlayer->m_bHasPrimary = false; } @@ -303,14 +309,14 @@ EXT_FUNC void CCSPlayer::GiveShield(bool bDeploy) BasePlayer()->GiveShield(bDeploy); } -EXT_FUNC void CCSPlayer::DropShield(bool bDeploy) +EXT_FUNC CBaseEntity *CCSPlayer::DropShield(bool bDeploy) { - BasePlayer()->DropShield(bDeploy); + return BasePlayer()->DropShield(bDeploy); } -EXT_FUNC void CCSPlayer::DropPlayerItem(const char *pszItemName) +EXT_FUNC CBaseEntity *CCSPlayer::DropPlayerItem(const char *pszItemName) { - BasePlayer()->DropPlayerItem(pszItemName); + return BasePlayer()->DropPlayerItem(pszItemName); } EXT_FUNC bool CCSPlayer::RemoveShield() @@ -531,8 +537,8 @@ void CCSPlayer::Reset() m_szModel[0] = '\0'; m_bForceShowMenu = false; - m_flRespawnPending = - m_flSpawnProtectionEndTime = 0.0f; + m_flRespawnPending = 0.0f; + m_flSpawnProtectionEndTime = 0.0f; m_vecOldvAngle = g_vecZero; m_iWeaponInfiniteAmmo = 0; @@ -541,6 +547,7 @@ void CCSPlayer::Reset() m_bGameForcingRespawn = false; m_bAutoBunnyHopping = false; m_bMegaBunnyJumping = false; + m_bPlantC4Anywhere = false; } void CCSPlayer::OnSpawn() diff --git a/regamedll/public/regamedll/API/CSPlayer.h b/regamedll/public/regamedll/API/CSPlayer.h index 8410d95f7..4e7d1e93e 100644 --- a/regamedll/public/regamedll/API/CSPlayer.h +++ b/regamedll/public/regamedll/API/CSPlayer.h @@ -61,8 +61,8 @@ class CCSPlayer: public CCSMonster { virtual CBaseEntity *GiveNamedItemEx(const char *pszName); virtual void GiveDefaultItems(); virtual void GiveShield(bool bDeploy = true); - virtual void DropShield(bool bDeploy = true); - virtual void DropPlayerItem(const char *pszItemName); + virtual CBaseEntity *DropShield(bool bDeploy = true); + virtual CBaseEntity *DropPlayerItem(const char *pszItemName); virtual bool RemoveShield(); virtual void RemoveAllItems(bool bRemoveSuit); virtual bool RemovePlayerItem(const char* pszItemName); diff --git a/regamedll/public/regamedll/regamedll_api.h b/regamedll/public/regamedll/regamedll_api.h index ba7a8517c..79aec7c5c 100644 --- a/regamedll/public/regamedll/regamedll_api.h +++ b/regamedll/public/regamedll/regamedll_api.h @@ -38,7 +38,7 @@ #include #define REGAMEDLL_API_VERSION_MAJOR 5 -#define REGAMEDLL_API_VERSION_MINOR 21 +#define REGAMEDLL_API_VERSION_MINOR 22 // CBasePlayer::Spawn hook typedef IHookChainClass IReGameHook_CBasePlayer_Spawn; diff --git a/regamedll/version/version.h b/regamedll/version/version.h index ba22bb751..b65ba1ab2 100644 --- a/regamedll/version/version.h +++ b/regamedll/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 5 -#define VERSION_MINOR 21 +#define VERSION_MINOR 22 #define VERSION_MAINTENANCE 0