Skip to content

Commit

Permalink
minor code clean up and add operator== to Client and NetState
Browse files Browse the repository at this point in the history
  • Loading branch information
raydienull committed Nov 29, 2023
1 parent ce9367e commit 602e3ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/game/chars/CCharFight.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys
if ( pSpellDef && pSpellDef->GetPrimarySkill(&iSpellSkill) )
iDisturbChance = pSpellDef->m_Interrupt.GetLinear(Skill_GetBase((SKILL_TYPE)iSpellSkill));

if ( iDisturbChance && fElemental && !pSpellDef->IsSpellType(SPELLFLAG_SCRIPTED) ) //If Protection spell has SPELLFLAG_SCRIPTED don't make this check.
//If COMBAT_ELEMENTAL is enabled, protection spell has SPELLFLAG_SCRIPTED don't make this check.
if ( iDisturbChance && fElemental && !pSpellDef->IsSpellType(SPELLFLAG_SCRIPTED) )
{
// Protection spell can cancel the disturb
CItem *pProtectionSpell = LayerFind(LAYER_SPELL_Protection);
Expand Down Expand Up @@ -924,15 +925,10 @@ int CChar::OnTakeDamage( int iDmg, CChar * pSrc, DAMAGE_TYPE uType, int iDmgPhys
{
if ( GetTopDist3D(pSrc) < 2 )
{
CItem* pReactive = LayerFind(LAYER_SPELL_Reactive);

CItem* pReactive = LayerFind(LAYER_SPELL_Reactive);
if (pReactive)
{
int iReactiveDamage = (iDmg * pReactive->m_itSpell.m_PolyStr) / 100;
if (iReactiveDamage < 1)
{
iReactiveDamage = 1;
}
int iReactiveDamage = maximum(1, (iDmg * pReactive->m_itSpell.m_PolyStr) / 100);

iDmg -= iReactiveDamage;
pSrc->OnTakeDamage(iReactiveDamage, this, (DAMAGE_TYPE)(DAMAGE_FIXED | DAMAGE_REACTIVE), iDmgPhysical, iDmgFire, iDmgCold, iDmgPoison, iDmgEnergy,(SPELL_TYPE)pReactive->m_itSpell.m_spell);
Expand Down
5 changes: 5 additions & 0 deletions src/game/clients/CClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,11 @@ class CClient : public CSObjListRec, public CScriptObj, public CChatChanMember,
return m_net;
}

inline bool operator==(const CClient& other) const
{
return (m_net == other.m_net);
}

public:
char m_zLastMessage[SCRIPT_MAX_LINE_LEN]; // last sysmessage
char m_zLastObjMessage[SCRIPT_MAX_LINE_LEN]; // last message
Expand Down
5 changes: 5 additions & 0 deletions src/network/CNetState.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ class CNetState
void beginTransaction(int priority); // begin a transaction for grouping packets
void endTransaction(void); // end transaction

inline bool operator==(const CNetState& other) const
{
return m_id == other.m_id;
}

friend class CNetworkManager;
friend class CNetworkThread;
friend class CNetworkInput;
Expand Down

0 comments on commit 602e3ad

Please sign in to comment.