Skip to content

Commit fc52871

Browse files
authored
Refactoring (#540)
* Rename CMD mp_swapteams * Remove unused CVar mp_mirrordamage * Refactoring checks
1 parent 913bfc6 commit fc52871

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Archive's bin directory contains 2 subdirectories, 'bugfixed' and 'pure'
2727
| :---------------------------------- | :---------------------------------------------- |
2828
| game version | Will show GameDLL build version, date & URL. |
2929
| endround | Args:<br/>`T` force round end with Terrorists win. <br/>`CT` force round end with Counter-Terrorists win. <br/> or terminate round draw when called without arguments. |
30-
| mp_swapteams | Swap the teams and restart the game. |
30+
| swapteams | Swap the teams and restart the game. |
3131

3232
## Configuration (cvars)
3333
<details>

regamedll/dlls/game.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,11 @@ void EXT_FUNC GameDLLInit()
243243
CVAR_REGISTER(&autoteambalance);
244244
CVAR_REGISTER(&tkpunish);
245245
CVAR_REGISTER(&hostagepenalty);
246+
247+
#ifndef REGAMEDLL_FIXES
246248
CVAR_REGISTER(&mirrordamage);
249+
#endif
250+
247251
CVAR_REGISTER(&logmessages);
248252
CVAR_REGISTER(&forcecamera);
249253
CVAR_REGISTER(&forcechasecam);
@@ -320,7 +324,7 @@ void EXT_FUNC GameDLLInit()
320324

321325
ADD_SERVER_COMMAND("game", GameDLL_Version_f);
322326
ADD_SERVER_COMMAND("endround", GameDLL_EndRound_f);
323-
ADD_SERVER_COMMAND("mp_swapteams", GameDLL_SwapTeams_f);
327+
ADD_SERVER_COMMAND("swapteams", GameDLL_SwapTeams_f);
324328

325329
CVAR_REGISTER(&game_version);
326330
CVAR_REGISTER(&maxmoney);

regamedll/dlls/multiplay_gamerules.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3910,9 +3910,8 @@ void EXT_FUNC CHalfLifeMultiplay::__API_HOOK(PlayerKilled)(CBasePlayer *pVictim,
39103910
{
39113911
// if a player dies in a deathmatch game and the killer is a client, award the killer some points
39123912
CBasePlayer *killer = GetClassPtr<CCSPlayer>((CBasePlayer *)pKiller);
3913-
bool killedByFFA = IsFreeForAll();
39143913

3915-
if (killer->m_iTeam == pVictim->m_iTeam && !killedByFFA)
3914+
if (g_pGameRules->PlayerRelationship(pVictim, killer) == GR_TEAMMATE)
39163915
{
39173916
// if a player dies by from teammate
39183917
pKiller->frags -= IPointsForKill(peKiller, pVictim);

regamedll/dlls/player.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
835835
CBaseEntity *pAttacker = GET_PRIVATE<CBaseEntity>(ENT(pevAttacker));
836836

837837
// don't take damage if victim has protection
838-
if (((pAttacker && pAttacker->IsPlayer()) || (bitsDamageType & DMG_FALL)) && CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active)
838+
if (((pAttacker && pAttacker->IsPlayer()) || (bitsDamageType & DMG_FALL)) && CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active)
839839
return FALSE;
840840
}
841841
#endif
@@ -1034,7 +1034,7 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
10341034
pAttack = GetClassPtr<CCSPlayer>((CBasePlayer *)pevAttacker);
10351035

10361036
// warn about team attacks
1037-
if (!CSGameRules()->IsFreeForAll() && pAttack->m_iTeam == m_iTeam)
1037+
if (g_pGameRules->PlayerRelationship(this, pAttack) == GR_TEAMMATE)
10381038
{
10391039
if (pAttack != this)
10401040
{
@@ -7748,7 +7748,7 @@ void CBasePlayer::UpdateStatusBar()
77487748
{
77497749
CBasePlayer *pTarget = (CBasePlayer *)pEntity;
77507750

7751-
bool sameTeam = !CSGameRules()->IsFreeForAll() && pTarget->m_iTeam == m_iTeam;
7751+
bool sameTeam = g_pGameRules->PlayerRelationship(this, pTarget) == GR_TEAMMATE;
77527752

77537753
newSBarState[SBAR_ID_TARGETNAME] = ENTINDEX(pTarget->edict());
77547754
newSBarState[SBAR_ID_TARGETTYPE] = sameTeam ? SBAR_TARGETTYPE_TEAMMATE : SBAR_TARGETTYPE_ENEMY;

0 commit comments

Comments
 (0)