Skip to content

Commit

Permalink
ADD: refactor 2
Browse files Browse the repository at this point in the history
  • Loading branch information
wh1t3lord committed Sep 28, 2024
1 parent 985a6f9 commit 3fc64e2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
20 changes: 11 additions & 9 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ void CHudItem::Load(LPCSTR section)
m_fLookOutAmplK = READ_IF_EXISTS(pSettings, r_float, HudSection(), "lookout_ampl_k", 1.0f);
m_bDisableBore = READ_IF_EXISTS(pSettings, r_bool, hud_sect, "disable_bore", isGuns);

m_jitter_params.pos_amplitude = READ_IF_EXISTS(pSettings, r_float, "gunslinger_base", "base_jitter_pos_amplitude", 0.001f);
m_jitter_params.rot_amplitude = READ_IF_EXISTS(pSettings, r_float, "gunslinger_base", "base_jitter_rot_amplitude", 0.1f);

if (hud_sect.size())
{
m_jitter_params.pos_amplitude = READ_IF_EXISTS(pSettings, r_float, hud_sect, "jitter_pos_amplitude", m_jitter_params.pos_amplitude);
m_jitter_params.rot_amplitude = READ_IF_EXISTS(pSettings, r_float, hud_sect, "jitter_rot_amplitude", m_jitter_params.rot_amplitude);
}

if (!m_bDisableBore)
m_sounds.LoadSound(section, "snd_bore", "sndBore", true);

Expand Down Expand Up @@ -1079,16 +1088,9 @@ bool CHudItem::WpnCanShoot() const
return !!(smart_cast<CWeaponMagazined*>(this) != nullptr && smart_cast<CWeaponBinoculars*>(this) == nullptr);
}

CHudItem::jitter_params CHudItem::GetCurJitterParams(const char* hud_sect)
const CHudItem::jitter_params& CHudItem::GetCurJitterParams() const
{
jitter_params result;

result.pos_amplitude = READ_IF_EXISTS(pSettings, r_float, "gunslinger_base", "base_jitter_pos_amplitude", 0.001f);
result.rot_amplitude = READ_IF_EXISTS(pSettings, r_float, "gunslinger_base", "base_jitter_rot_amplitude", 0.1f);

result.pos_amplitude = READ_IF_EXISTS(pSettings, r_float, hud_sect, "jitter_pos_amplitude", result.pos_amplitude);
result.rot_amplitude = READ_IF_EXISTS(pSettings, r_float, hud_sect, "jitter_rot_amplitude", result.rot_amplitude);
return result;
return m_jitter_params;
}

float CHudItem::getLookOutSpeedKoef(void) const
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class CHudItem :public CHUDState
bool WpnCanShoot() const;
bool StartCompanionAnimIfNeeded(const xr_string anim_name);
void AssignDetectorAnim(const xr_string anm_alias, bool bMixIn = true, bool use_companion_section = false);
jitter_params GetCurJitterParams(const char* hud_sect);
const jitter_params& GetCurJitterParams() const;
using TAnimationEffector = fastdelegate::FastDelegate<void()>;

enum EDeviceFlags
Expand Down Expand Up @@ -210,7 +210,7 @@ class CHudItem :public CHUDState
TAnimationEffector lock_time_callback;
u32 mark;
int _action_ppe;

jitter_params m_jitter_params;
private:
CPhysicItem *m_object;
CInventoryItem *m_item;
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/player_hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1861,7 +1861,7 @@ void player_hud::UpdateWeaponOffset(u32 delta)

if (Actor()->IsHandJitter(itm))
{
jitter = itm->GetCurJitterParams(section.c_str());
jitter = itm->GetCurJitterParams();

pos.x = ::Random.randF(0.f, 1000.f) - 500.f;
pos.y = ::Random.randF(0.f, 500.f) - 250.f;
Expand Down Expand Up @@ -1890,7 +1890,7 @@ void player_hud::UpdateWeaponOffset(u32 delta)

if (Actor()->IsActorSuicideNow() && Actor()->CheckActorVisibilityForController() && !(READ_IF_EXISTS(pSettings, r_bool, section, "prohibit_suicide", false) || READ_IF_EXISTS(pSettings, r_bool, section, "suicide_by_animation", false)))
{
jitter = itm->GetCurJitterParams(section.c_str());
jitter = itm->GetCurJitterParams();
pos = HID->hands_attach_pos();
rot = HID->hands_attach_rot();

Expand Down

0 comments on commit 3fc64e2

Please sign in to comment.