Skip to content

Commit a4d85ba

Browse files
committed
xrGame/CustomOutfit.h|cpp: make Get* functions as const and nodiscard
Same change for ActorHelmet.h|cpp
1 parent aa9cfd2 commit a4d85ba

File tree

4 files changed

+30
-18
lines changed

4 files changed

+30
-18
lines changed

src/xrGame/ActorHelmet.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,23 @@ void CHelmet::Hit(float hit_power, ALife::EHitType hit_type)
130130
ChangeCondition(-hit_power);
131131
}
132132

133-
float CHelmet::GetDefHitTypeProtection(ALife::EHitType hit_type)
133+
float CHelmet::GetDefHitTypeProtection(ALife::EHitType hit_type) const
134134
{
135135
return m_HitTypeProtection[hit_type] * GetCondition();
136136
}
137137

138-
float CHelmet::GetHitTypeProtection(ALife::EHitType hit_type, s16 element)
138+
float CHelmet::GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const
139139
{
140-
float fBase = m_HitTypeProtection[hit_type] * GetCondition();
141-
float bone = m_boneProtection->getBoneProtection(element);
142-
return fBase * bone;
140+
const float base = m_HitTypeProtection[hit_type] * GetCondition();
141+
const float bone = m_boneProtection->getBoneProtection(element);
142+
return base * bone;
143+
}
144+
145+
float CHelmet::GetBoneArmor(s16 element) const
146+
{
147+
return m_boneProtection->getBoneArmor(element);
143148
}
144149

145-
float CHelmet::GetBoneArmor(s16 element) { return m_boneProtection->getBoneArmor(element); }
146150
bool CHelmet::install_upgrade_impl(LPCSTR section, bool test)
147151
{
148152
bool result = inherited::install_upgrade_impl(section, test);

src/xrGame/ActorHelmet.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class CHelmet : public CInventoryItemObject
2727
virtual void net_Import(NET_Packet& P);
2828
virtual void OnH_A_Chield();
2929

30-
float GetDefHitTypeProtection(ALife::EHitType hit_type);
31-
float GetHitTypeProtection(ALife::EHitType hit_type, s16 element);
32-
float GetBoneArmor(s16 element);
30+
[[nodiscard]] float GetDefHitTypeProtection(ALife::EHitType hit_type) const;
31+
[[nodiscard]] float GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const;
32+
[[nodiscard]] float GetBoneArmor(s16 element) const;
3333

3434
float HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type);
3535

@@ -46,7 +46,7 @@ class CHelmet : public CInventoryItemObject
4646
void AddBonesProtection(LPCSTR bones_section);
4747

4848
protected:
49-
HitImmunity::HitTypeSVec m_HitTypeProtection;
49+
mutable HitImmunity::HitTypeSVec m_HitTypeProtection;
5050
SBoneProtections* m_boneProtection;
5151

5252
protected:

src/xrGame/CustomOutfit.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,19 +122,23 @@ void CCustomOutfit::Hit(float hit_power, ALife::EHitType hit_type)
122122
ChangeCondition(-hit_power);
123123
}
124124

125-
float CCustomOutfit::GetDefHitTypeProtection(ALife::EHitType hit_type)
125+
float CCustomOutfit::GetDefHitTypeProtection(ALife::EHitType hit_type) const
126126
{
127127
return m_HitTypeProtection[hit_type] * GetCondition();
128128
}
129129

130-
float CCustomOutfit::GetHitTypeProtection(ALife::EHitType hit_type, s16 element)
130+
float CCustomOutfit::GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const
131131
{
132132
float fBase = m_HitTypeProtection[hit_type] * GetCondition();
133133
float bone = m_boneProtection->getBoneProtection(element);
134134
return fBase * bone;
135135
}
136136

137-
float CCustomOutfit::GetBoneArmor(s16 element) { return m_boneProtection->getBoneArmor(element); }
137+
float CCustomOutfit::GetBoneArmor(s16 element) const
138+
{
139+
return m_boneProtection->getBoneArmor(element);
140+
}
141+
138142
float CCustomOutfit::HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type)
139143
{
140144
float NewHitPower = hit_power;
@@ -276,7 +280,11 @@ void CCustomOutfit::OnMoveToRuck(const SInvItemPlace& prev)
276280
}
277281
};
278282

279-
u32 CCustomOutfit::ef_equipment_type() const { return (m_ef_equipment_type); }
283+
u32 CCustomOutfit::ef_equipment_type() const
284+
{
285+
return m_ef_equipment_type;
286+
}
287+
280288
bool CCustomOutfit::install_upgrade_impl(LPCSTR section, bool test)
281289
{
282290
bool result = inherited::install_upgrade_impl(section, test);

src/xrGame/CustomOutfit.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class CCustomOutfit : public CInventoryItemObject
2121
//коэффициенты на которые домножается хит
2222
//при соответствующем типе воздействия
2323
//если на персонаже надет костюм
24-
float GetHitTypeProtection(ALife::EHitType hit_type, s16 element);
25-
float GetDefHitTypeProtection(ALife::EHitType hit_type);
26-
float GetBoneArmor(s16 element);
24+
[[nodiscard]] float GetHitTypeProtection(ALife::EHitType hit_type, s16 element) const;
25+
[[nodiscard]] float GetDefHitTypeProtection(ALife::EHitType hit_type) const;
26+
[[nodiscard]] float GetBoneArmor(s16 element) const;
2727

2828
float HitThroughArmor(float hit_power, s16 element, float ap, bool& add_wound, ALife::EHitType hit_type);
2929

@@ -32,7 +32,7 @@ class CCustomOutfit : public CInventoryItemObject
3232
virtual void OnH_A_Chield();
3333

3434
protected:
35-
HitImmunity::HitTypeSVec m_HitTypeProtection;
35+
mutable HitImmunity::HitTypeSVec m_HitTypeProtection;
3636

3737
shared_str m_ActorVisual;
3838
shared_str m_full_icon_name;

0 commit comments

Comments
 (0)