Skip to content

Commit

Permalink
Refactoring the refactory
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm committed Jul 15, 2023
1 parent d1111e7 commit 7dd2690
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 69 deletions.
3 changes: 3 additions & 0 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,9 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
return;
}

#ifdef REGAMEDLL_FIXES
pPlayer->m_bHasDefuser = false;
#endif
pPlayer->m_bNotKilled = true;
pPlayer->m_iIgnoreGlobalChat = IGNOREMSG_NONE;
pPlayer->m_iTeamKills = 0;
Expand Down
88 changes: 19 additions & 69 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1690,18 +1690,6 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit)
if (m_bHasDefuser)
{
RemoveDefuser();

#ifndef REGAMEDLL_FIXES
// NOTE: moved into RemoveDefuser
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser");
MESSAGE_END();

SendItemStatus();
#endif

bKillProgBar = true;
}

if (m_bHasC4)
Expand Down Expand Up @@ -2435,30 +2423,16 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
else if (m_bHasDefuser)
{
RemoveDefuser();

#ifdef REGAMEDLL_FIXES
SpawnDefuser(pev->origin, ENT(pev));

if (m_bIsDefusing)
SetProgressBarTime(0);

m_bIsDefusing = false;
#else
GiveNamedItem("item_thighpack");

// NOTE: moved into RemoveDefuser
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser");
MESSAGE_END();

SendItemStatus();
SetProgressBarTime(0);
#endif
}

#ifndef REGAMEDLL_FIXES
m_bIsDefusing = false; // NOTE: moved above
// NOTE: moved to RemoveDefuser
m_bIsDefusing = false;
#endif

BuyZoneIcon_Clear(this);
Expand Down Expand Up @@ -3651,22 +3625,20 @@ void EXT_FUNC CBasePlayer::__API_HOOK(JoiningThink)()
ResetMenu();
m_iJoiningState = SHOWTEAMSELECT;

#ifdef REGAMEDLL_FIXES
RemoveDefuser();
#else
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
#ifndef REGAMEDLL_FIXES
// client already clears StatusIcon on join
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser");
MESSAGE_END();

m_bHasDefuser = false;
m_bHasDefuser = false; // unneded
#endif
m_fLastMovement = gpGlobals->time;
m_bMissionBriefing = false;

#ifndef REGAMEDLL_FIXES
SendItemStatus();
#endif
SendItemStatus();

break;
}
case READINGLTEXT:
Expand Down Expand Up @@ -3785,25 +3757,10 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)()
else if (m_bHasDefuser)
{
RemoveDefuser();

#ifdef REGAMEDLL_FIXES
SpawnDefuser(pev->origin, ENT(pev));

if (m_bIsDefusing)
SetProgressBarTime(0);

m_bIsDefusing = false;
#else
GiveNamedItem("item_thighpack");

// NOTE: moved into RemoveDefuser
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser");
MESSAGE_END();

SendItemStatus();
SetProgressBarTime(0);
#endif
}

Expand Down Expand Up @@ -5707,10 +5664,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Spawn)()
ReloadWeapons();
#endif

if (m_bHasDefuser)
pev->body = 1;
else
pev->body = 0;
pev->body = m_bHasDefuser ? 1 : 0;

if (m_bMissionBriefing)
{
Expand Down Expand Up @@ -8305,18 +8259,6 @@ void CBasePlayer::__API_HOOK(SwitchTeam)()
{
RemoveDefuser();

#ifndef REGAMEDLL_FIXES
// NOTE: moved into RemoveDefuser
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser");
MESSAGE_END();

SendItemStatus();
#endif

SetProgressBarTime(0);

#ifndef REGAMEDLL_FIXES
// NOTE: unreachable code - Vaqtincha
for (int i = 0; i < MAX_ITEM_TYPES; i++)
Expand Down Expand Up @@ -10159,14 +10101,22 @@ void CBasePlayer::RemoveDefuser()
m_bHasDefuser = false;
pev->body = 0;

#ifdef REGAMEDLL_FIXES
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_HIDE);
WRITE_STRING("defuser");
MESSAGE_END();

SendItemStatus();
#endif

#ifdef REGAMEDLL_FIXES
if (m_bIsDefusing)
{
SetProgressBarTime(0);
m_bIsDefusing = false;
}
#else
SetProgressBarTime(0);
#endif
}

CItemThighPack *SpawnDefuser(const Vector &vecOrigin, edict_t *pentOwner)
Expand Down

0 comments on commit 7dd2690

Please sign in to comment.