Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
windows:
name: 'Windows'
runs-on: windows-latest
runs-on: windows-2019

env:
solution: 'msvc/ReGameDLL.sln'
Expand Down
8 changes: 5 additions & 3 deletions regamedll/dlls/API/CSPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ EXT_FUNC CBaseEntity *CCSPlayer::GiveNamedItemEx(const char *pszName)

if (FStrEq(pszName, "weapon_c4")) {
pPlayer->m_bHasC4 = true;
pPlayer->SetBombIcon();
pPlayer->SetBombIcon(((pPlayer->m_signals.GetState() & SIGNAL_BOMB) && (CSGameRules()->CanPlantBomb(pPlayer) & GR_CANPLANTBOMB_DELAY_OVER)));

if (pPlayer->m_iTeam == TERRORIST) {
pPlayer->pev->body = 1;
Expand Down Expand Up @@ -531,8 +531,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;
Expand All @@ -541,6 +541,8 @@ void CCSPlayer::Reset()
m_bGameForcingRespawn = false;
m_bAutoBunnyHopping = false;
m_bMegaBunnyJumping = false;
m_iCanPlantC4Anywhere = -1;
m_flPlantC4Delay = -1.0;
}

void CCSPlayer::OnSpawn()
Expand Down
2 changes: 2 additions & 0 deletions regamedll/dlls/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 plant_c4_delay = { "mp_plant_c4_delay", "0", 0, 0.0f, nullptr };

void GameDLL_Version_f()
{
Expand Down Expand Up @@ -393,6 +394,7 @@ void EXT_FUNC GameDLLInit()
CVAR_REGISTER(&sv_autobunnyhopping);
CVAR_REGISTER(&sv_enablebunnyhopping);
CVAR_REGISTER(&plant_c4_anywhere);
CVAR_REGISTER(&plant_c4_delay);

// print version
CONSOLE_ECHO("ReGameDLL version: " APP_VERSION "\n");
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 plant_c4_delay;

#endif

Expand Down
12 changes: 10 additions & 2 deletions regamedll/dlls/gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ enum
SCENARIO_BLOCK_PRISON_ESCAPE_TIME = BIT(8), // flag "i"
SCENARIO_BLOCK_BOMB_TIME = BIT(9), // flag "j"
SCENARIO_BLOCK_HOSTAGE_RESCUE_TIME = BIT(10), // flag "k"

};

// Player relationship return codes
Expand All @@ -215,6 +214,14 @@ enum
GR_NEUTRAL,
};

// Custom enum (used with custom function "CHalfLifeMultiplay::CanPlantBomb").
enum
{
GR_CANPLANTBOMB_NO = 0,
GR_CANPLANTBOMB_ANYWHERE = BIT(0),
GR_CANPLANTBOMB_DELAY_OVER = BIT(1),
};

class CItem;

class CGameRules
Expand Down Expand Up @@ -683,7 +690,8 @@ class CHalfLifeMultiplay: public CGameRules

// has a style of gameplay when aren't any teams
bool IsFreeForAll() const;
bool CanPlayerBuy(CBasePlayer *pPlayer) const;
EXPORT bool CanPlayerBuy(CBasePlayer *pPlayer);
EXPORT int CanPlantBomb(CBasePlayer *pPlayer, float *pflPlantC4Delay = nullptr);

VFUNC bool HasRoundTimeExpired();
VFUNC bool IsBombPlanted();
Expand Down
66 changes: 58 additions & 8 deletions regamedll/dlls/multiplay_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5141,20 +5141,70 @@ void CHalfLifeMultiplay::ChangePlayerTeam(CBasePlayer *pPlayer, const char *pTea
}
}

bool CHalfLifeMultiplay::CanPlayerBuy(CBasePlayer *pPlayer) const
bool CHalfLifeMultiplay::CanPlayerBuy(CBasePlayer *pPlayer)
{
if (pPlayer->m_iTeam == CT && m_bCTCantBuy)
{
if((m_bCTCantBuy && m_bTCantBuy)
|| (pPlayer->m_iTeam == CT && m_bCTCantBuy)
|| (pPlayer->m_iTeam == TERRORIST && m_bTCantBuy))
return false;

return true;
}

// Check if the C4 can be planted (only by rules).
// Note: Implement team check here when a player is passed in order to easily allow tricking, if needed (but facultative).
int CHalfLifeMultiplay::CanPlantBomb(CBasePlayer *pPlayer, float *pflPlantC4Delay)
{
if(pflPlantC4Delay)
{
*pflPlantC4Delay = 0.0f;
}
else if (pPlayer->m_iTeam == TERRORIST && m_bTCantBuy)

if(pPlayer && pPlayer->IsPlayer() && !(pPlayer->m_iTeam == TERRORIST || pPlayer->m_iTeam == CT))
return GR_CANPLANTBOMB_NO;

#ifdef REGAMEDLL_ADD
int iResultFlags = GR_CANPLANTBOMB_NO;
int iCanPlantC4Anywhere = -1;
float flPlantC4Delay = -1.0;

#ifdef REGAMEDLL_API
if(pPlayer && pPlayer->IsPlayer())
{
return false;
iCanPlantC4Anywhere = pPlayer->CSPlayer()->m_iCanPlantC4Anywhere;
flPlantC4Delay = pPlayer->CSPlayer()->m_flPlantC4Delay;
}
else if (m_bCTCantBuy && m_bTCantBuy)
#endif

if(iCanPlantC4Anywhere <= -1)
{
return false;
iCanPlantC4Anywhere = plant_c4_anywhere.value;
}

return true;
if(flPlantC4Delay <= -1.0)
{
flPlantC4Delay = plant_c4_delay.value;
}
flPlantC4Delay = Q_max(flPlantC4Delay, 0.0f);

if(pflPlantC4Delay)
{
*pflPlantC4Delay = flPlantC4Delay;
}

if(iCanPlantC4Anywhere >= 1)
{
iResultFlags |= GR_CANPLANTBOMB_ANYWHERE;
}

if(flPlantC4Delay <= (gpGlobals->time - CSGameRules()->m_fRoundStartTime))
{
iResultFlags |= GR_CANPLANTBOMB_DELAY_OVER;
}

return iResultFlags;
#else
return GR_CANPLANTBOMB_DELAY_OVER;
#endif
}

4 changes: 4 additions & 0 deletions regamedll/dlls/observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,11 @@ void CBasePlayer::Observer_CheckProperties()

if (target->m_bHasC4)
{
#ifdef REGAMEDLL_ADD
if ((target->m_signals.GetState() & SIGNAL_BOMB) && (CSGameRules()->CanPlantBomb(target) & GR_CANPLANTBOMB_DELAY_OVER))
#else
if (target->m_signals.GetState() & SIGNAL_BOMB)
#endif
targetBombState = STATUSICON_FLASH;
else
targetBombState = STATUSICON_SHOW;
Expand Down
52 changes: 37 additions & 15 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6622,25 +6622,22 @@ void CBasePlayer::HandleSignals()
{
if (CSGameRules()->IsMultiplayer())
{

#ifdef REGAMEDLL_ADD
if (buytime.value != 0.0f)
#endif
{
#ifdef REGAMEDLL_ADD
if (buy_anywhere.value)
if (buy_anywhere.value >= 1)
{
if (pev->deadflag == DEAD_NO && (m_iTeam == TERRORIST || m_iTeam == CT)
&& !(m_signals.GetSignal() & SIGNAL_BUY)
// Restricted by map rules
&& CSGameRules()->CanPlayerBuy(this)
)
if (IsAlive() && (m_iTeam == TERRORIST || m_iTeam == CT)
&& !(m_signals.GetSignal() & SIGNAL_BUY)
// Restricted by map rules
&& CSGameRules()->CanPlayerBuy(this))
{
// 0 = default. 1 = both teams. 2 = Terrorists. 3 = Counter-Terrorists.
if (buy_anywhere.value == 1
|| (buy_anywhere.value == 2 && m_iTeam == TERRORIST)
|| (buy_anywhere.value == 3 && m_iTeam == CT)
)
|| (buy_anywhere.value == 2 && m_iTeam == TERRORIST)
|| (buy_anywhere.value >= 3 && m_iTeam == CT))
{
m_signals.Signal(SIGNAL_BUY);
}
Expand All @@ -6654,24 +6651,32 @@ void CBasePlayer::HandleSignals()
}

#ifdef REGAMEDLL_ADD
if (m_bHasC4 && (plant_c4_anywhere.value || CSPlayer()->m_bPlantC4Anywhere))
if (IsAlive() && m_bHasC4)
{
if (IsAlive() && (m_iTeam == TERRORIST || m_iTeam == CT)
&& !(m_signals.GetSignal() & SIGNAL_BOMB))
int iCanPlantBomb = CSGameRules()->CanPlantBomb(this);

if (iCanPlantBomb & GR_CANPLANTBOMB_ANYWHERE)
{
m_signals.Signal(SIGNAL_BOMB);
}

if (iCanPlantBomb & GR_CANPLANTBOMB_DELAY_OVER)
{
m_signals.Signal(SIGNAL_BOMB_DELAY_OVER);
}
}
#endif

if (!(m_signals.GetSignal() & SIGNAL_BOMB) && !CSGameRules()->m_bMapHasBombZone)
#else
if (!CSGameRules()->m_bMapHasBombZone)
#endif
OLD_CheckBombTarget(this);

if (!CSGameRules()->m_bMapHasRescueZone)
OLD_CheckRescueZone(this);
}

int state = m_signals.GetSignal();
int state = m_signals.GetSignal();
int changed = m_signals.GetState() ^ state;

m_signals.Update();
Expand All @@ -6685,11 +6690,24 @@ void CBasePlayer::HandleSignals()
}
if (changed & SIGNAL_BOMB)
{
#ifdef REGAMEDLL_ADD
if ((state & SIGNAL_BOMB) && (m_signals.GetState() & SIGNAL_BOMB_DELAY_OVER))
#else
if (state & SIGNAL_BOMB)
#endif
BombTargetFlash_Set(this);
else
BombTargetFlash_Clear(this);
}
#ifdef REGAMEDLL_ADD
else if ((changed & SIGNAL_BOMB_DELAY_OVER) && (m_signals.GetState() & SIGNAL_BOMB))
{
if (state & SIGNAL_BOMB_DELAY_OVER)
BombTargetFlash_Set(this);
else
BombTargetFlash_Clear(this);
}
#endif
if (changed & SIGNAL_RESCUE)
{
if (state & SIGNAL_RESCUE)
Expand Down Expand Up @@ -10053,7 +10071,11 @@ bool EXT_FUNC CBasePlayer::__API_HOOK(MakeBomber)()
}

m_bHasC4 = true;
#ifdef REGAMEDLL_FIXES
SetBombIcon(((m_signals.GetState() & SIGNAL_BOMB) && (CSGameRules()->CanPlantBomb(this) & GR_CANPLANTBOMB_DELAY_OVER)));
#else
SetBombIcon();
#endif
pev->body = 1;

m_flDisplayHistory |= DHF_BOMB_RETRIEVED;
Expand Down
4 changes: 4 additions & 0 deletions regamedll/dlls/unisignals.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,15 @@

#pragma once

// Default CS's signals.
#define SIGNAL_BUY BIT(0)
#define SIGNAL_BOMB BIT(1)
#define SIGNAL_RESCUE BIT(2)
#define SIGNAL_ESCAPE BIT(3)
#define SIGNAL_VIPSAFETY BIT(4)
// ReGameDLL_CS's specific signals.
// Note: Jump to +5 in order to predict possible new flags that could be added by a legit update of the game (by VALVe).
#define SIGNAL_BOMB_DELAY_OVER BIT(10) // Note: Used to specify the player has his plant C4 delay over or not (to blink/unblink the C4 icon when value changed and if player is on site).

class CUnifiedSignals
{
Expand Down
Loading