Skip to content

Commit

Permalink
Implementing more accurate way for weapon hiding fix
Browse files Browse the repository at this point in the history
See previous commit for details
  • Loading branch information
gunslingermod authored and Xottab-DUTY committed Aug 14, 2017
1 parent d243af2 commit 42ac33e
Show file tree
Hide file tree
Showing 32 changed files with 69 additions and 67 deletions.
5 changes: 2 additions & 3 deletions src/xrGame/Artefact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,10 +410,9 @@ bool CArtefact::Action(u16 cmd, u32 flags)
return inherited::Action(cmd, flags);
}

void CArtefact::OnStateSwitch(u32 S)
void CArtefact::OnStateSwitch(u32 S, u32 oldState)
{
u32 oldState = GetState();
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
switch (S)
{
case eShowing: { PlayHUDMotion("anm_show", FALSE, this, S);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Artefact.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class CArtefact : public CHudItemObject, public CPHUpdateObject
virtual void Show();
virtual void UpdateXForm();
virtual bool Action(u16 cmd, u32 flags);
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual void OnAnimationEnd(u32 state);
virtual bool IsHidden() const { return GetState() == eHidden; }
// optimization FAST/SLOW mode
Expand Down
5 changes: 2 additions & 3 deletions src/xrGame/CustomDetector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ void CCustomDetector::ToggleDetector(bool bFastMode)
SwitchState(eHiding);
}

void CCustomDetector::OnStateSwitch(u32 S)
void CCustomDetector::OnStateSwitch(u32 S, u32 oldState)
{
u32 oldState = GetState();
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);

switch (S)
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/CustomDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class CCustomDetector : public CHudItemObject

virtual void OnActiveItem();
virtual void OnHiddenItem();
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual void OnAnimationEnd(u32 state);
virtual void UpdateXForm();

Expand Down
8 changes: 6 additions & 2 deletions src/xrGame/Grenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,12 @@ bool CGrenade::DropGrenade()

void CGrenade::DiscardState()
{
if (IsGameTypeSingle() && (GetState() == eReady || GetState() == eThrow))
OnStateSwitch(eIdle);
if (IsGameTypeSingle())
{
u32 state = GetState();
if (state == eReady || state == eThrow)
OnStateSwitch(eIdle, state);
}
}

void CGrenade::SendHiddenItem()
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ void CHudItem::OnEvent(NET_Packet& P, u16 type)
{
u8 S;
P.r_u8(S);
OnStateSwitch(u32(S));
OnStateSwitch(u32(S), GetState());
}
break;
}
}

void CHudItem::OnStateSwitch(u32 S)
void CHudItem::OnStateSwitch(u32 S, u32 oldState)
{
SetState(S);

Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class CHUDState
IC u32 CurrStateTime() const { return Device.dwTimeGlobal - m_dw_curr_state_time; }
IC void ResetSubStateTime() { m_dw_curr_substate_time = Device.dwTimeGlobal; }
virtual void SwitchState(u32 S) = 0;
virtual void OnStateSwitch(u32 S) = 0;
virtual void OnStateSwitch(u32 S, u32 oldState) = 0;
};

class CHudItem : public CHUDState
Expand Down Expand Up @@ -110,7 +110,7 @@ class CHudItem : public CHUDState
bool IsHiding() const { return GetState() == eHiding; }
bool IsShowing() const { return GetState() == eShowing; }
virtual void SwitchState(u32 S);
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);

virtual void OnAnimationEnd(u32 state);
virtual void OnMotionMark(u32 state, const motion_marks&){};
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Level_input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ void CLevel::IR_OnKeyboardPress(int key)
CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem());
if (pHudItem)
{
pHudItem->OnStateSwitch(pHudItem->GetState());
pHudItem->OnStateSwitch(pHudItem->GetState(), pHudItem->GetState());
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions src/xrGame/Missile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ void CMissile::shedule_Update(u32 dt)
}
}

void CMissile::State(u32 state, u32 old_state)
void CMissile::State(u32 state, u32 oldState)
{
switch (state)
{
Expand All @@ -259,7 +259,7 @@ void CMissile::State(u32 state, u32 old_state)
{
if (H_Parent())
{
if (old_state != eHiding)
if (oldState != eHiding)
{
SetPending(TRUE);
PlayHUDMotion("anm_hide", TRUE, this, GetState());
Expand Down Expand Up @@ -311,11 +311,10 @@ void CMissile::State(u32 state, u32 old_state)
}
}

void CMissile::OnStateSwitch(u32 S)
void CMissile::OnStateSwitch(u32 S, u32 oldState)
{
m_dwStateTime = 0;
u32 oldState = GetState();
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
State(S, oldState);
}

Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/Missile.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class CMissile : public CHudItemObject

virtual bool Action(u16 cmd, u32 flags);

virtual void State(u32 state, u32 old_state);
virtual void OnStateSwitch(u32 S);
virtual void State(u32 state, u32 oldState);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual bool GetBriefInfo(II_BriefInfo& info);

protected:
Expand Down
10 changes: 5 additions & 5 deletions src/xrGame/Spectator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,11 @@ void CSpectator::FirstEye_ToPlayer(IGameObject* pObject)
{
pActor->inventory().Items_SetCurrentEntityHud(true);

/* CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem());
if (pHudItem)
{
pHudItem->OnStateSwitch(pHudItem->GetState());
}*/
/*CHudItem* pHudItem = smart_cast<CHudItem*>(pActor->inventory().ActiveItem());
if (pHudItem)
{
pHudItem->OnStateSwitch(pHudItem->GetState(), pHudItem->GetState());
}*/
}
};
if (Device.Paused() && pOldActor)
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ void CWeapon::OnEvent(NET_Packet& P, u16 type)

if (OnClient())
SetAmmoElapsed(int(AmmoElapsed));
OnStateSwitch(u32(state));
OnStateSwitch(u32(state), GetState());
}
break;
default: { inherited::OnEvent(P, type);
Expand Down Expand Up @@ -1817,9 +1817,9 @@ const float& CWeapon::hit_probability() const
return (m_hit_probability[egdNovice]);
}

void CWeapon::OnStateSwitch(u32 S)
void CWeapon::OnStateSwitch(u32 S, u32 oldState)
{
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
m_BriefInfo_CalcFrame = 0;

// if(GetState()==eReload)
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Weapon.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ class CWeapon : public CHudItemObject, public CShootingObject
virtual void SetDefaults();

virtual bool MovingAnimAllowedNow();
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual void OnAnimationEnd(u32 state);

//трассирование полета пули
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/WeaponAutomaticShotgun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ void CWeaponAutomaticShotgun::TriStateReload()
SwitchState(eReload);
}

void CWeaponAutomaticShotgun::OnStateSwitch(u32 S)
void CWeaponAutomaticShotgun::OnStateSwitch(u32 S, u32 oldState)
{
if (!m_bTriStateReload || S != eReload)
{
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
return;
}

CWeapon::OnStateSwitch(S);
CWeapon::OnStateSwitch(S, oldState);

if (m_magazine.size() == (u32)iMagazineSize || !HaveCartridgeInInventory(1))
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/WeaponAutomaticShotgun.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class CWeaponAutomaticShotgun : public CWeaponMagazined
protected:
virtual void OnAnimationEnd(u32 state);
void TriStateReload();
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);

bool HaveCartridgeInInventory(u8 cnt);
virtual u8 AddCartridge(u8 cnt);
Expand Down
7 changes: 3 additions & 4 deletions src/xrGame/WeaponKnife.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,16 @@ void CWeaponKnife::Load(LPCSTR section)
knife_material_idx = GMLib.GetMaterialIdx(KNIFE_MATERIAL_NAME);
}

void CWeaponKnife::OnStateSwitch(u32 S)
void CWeaponKnife::OnStateSwitch(u32 S, u32 oldState)
{
u32 old_state = GetState();
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
switch (S)
{
case eIdle: switch2_Idle(); break;
case eShowing: switch2_Showing(); break;
case eHiding:
{
if (old_state != eHiding)
if (oldState != eHiding)
switch2_Hiding();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/WeaponKnife.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CWeaponKnife : public CWeapon

virtual void OnAnimationEnd(u32 state);
virtual void OnMotionMark(u32 state, const motion_marks&);
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);

void state_Attacking(float dt);

Expand Down
7 changes: 3 additions & 4 deletions src/xrGame/WeaponMagazined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -380,10 +380,9 @@ void CWeaponMagazined::ReloadMagazine()
VERIFY((u32)iAmmoElapsed == m_magazine.size());
}

void CWeaponMagazined::OnStateSwitch(u32 S)
void CWeaponMagazined::OnStateSwitch(u32 S, u32 oldState)
{
u32 old_state = GetState();
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
CInventoryOwner* owner = smart_cast<CInventoryOwner*>(this->H_Parent());
switch (S)
{
Expand All @@ -407,7 +406,7 @@ void CWeaponMagazined::OnStateSwitch(u32 S)
case eHiding:
if (owner)
m_sounds_enabled = owner->CanPlayShHdRldSounds();
if (old_state != eHiding)
if (oldState != eHiding)
switch2_Hiding();
break;
case eHidden: switch2_Hidden(); break;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/WeaponMagazined.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class CWeaponMagazined : public CWeapon
virtual void OnEmptyClick();

virtual void OnAnimationEnd(u32 state);
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);

virtual void UpdateSounds();

Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/WeaponMagazinedWGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ void CWeaponMagazinedWGrenade::ReloadMagazine()
}
}

void CWeaponMagazinedWGrenade::OnStateSwitch(u32 S)
void CWeaponMagazinedWGrenade::OnStateSwitch(u32 S, u32 oldState)
{
switch (S)
{
Expand All @@ -420,7 +420,7 @@ void CWeaponMagazinedWGrenade::OnStateSwitch(u32 S)
break;
}

inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
UpdateGrenadeVisibility(!!iAmmoElapsed || S == eReload);
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/WeaponMagazinedWGrenade.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CWeaponMagazinedWGrenade : public CWeaponMagazined, public CRocketLauncher
virtual void FireEnd();
void LaunchGrenade();

virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);

virtual void switch2_Reload();
virtual void state_Fire(float dt);
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/WeaponRPG7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ BOOL CWeaponRPG7::net_Spawn(CSE_Abstract* DC)
return l_res;
}

void CWeaponRPG7::OnStateSwitch(u32 S)
void CWeaponRPG7::OnStateSwitch(u32 S, u32 oldState)
{
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
UpdateMissileVisibility();
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/WeaponRPG7.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class CWeaponRPG7 : public CWeaponCustomPistol, public CRocketLauncher
virtual ~CWeaponRPG7();

virtual BOOL net_Spawn(CSE_Abstract* DC);
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual void OnEvent(NET_Packet& P, u16 type);
virtual void ReloadMagazine();
virtual void Load(LPCSTR section);
Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/WeaponShotgun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ void CWeaponShotgun::TriStateReload()
SwitchState(eReload);
}

void CWeaponShotgun::OnStateSwitch(u32 S)
void CWeaponShotgun::OnStateSwitch(u32 S, u32 oldState)
{
if (!m_bTriStateReload || S != eReload)
{
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
return;
}

CWeapon::OnStateSwitch(S);
CWeapon::OnStateSwitch(S, oldState);

if (m_magazine.size() == (u32)iMagazineSize || !HaveCartridgeInInventory(1))
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/WeaponShotgun.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CWeaponShotgun : public CWeaponCustomPistol
protected:
virtual void OnAnimationEnd(u32 state);
void TriStateReload();
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);

bool HaveCartridgeInInventory(u8 cnt);
virtual u8 AddCartridge(u8 cnt);
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ai/stalker/ai_stalker_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void restore_actor()
CHudItem* pHudItem = smart_cast<CHudItem*>(g_debug_actor->inventory().ActiveItem());
if (pHudItem)
{
pHudItem->OnStateSwitch(pHudItem->GetState());
pHudItem->OnStateSwitch(pHudItem->GetState(), pHudItem->GetState());
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/xrGame/cta_game_artefact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ bool CtaGameArtefact::Action(s32 cmd, u32 flags)
return inherited::Action((u16)cmd, flags);
}

void CtaGameArtefact::OnStateSwitch(u32 S)
void CtaGameArtefact::OnStateSwitch(u32 S, u32 oldState)
{
inherited::OnStateSwitch(S);
inherited::OnStateSwitch(S, oldState);
/*// just temporary (before we get huds for artefact activation)
if (S == eActivating)
{
Expand All @@ -68,7 +68,7 @@ void CtaGameArtefact::OnStateSwitch(u32 S)
return;
} else
{
//inherited::OnStateSwitch(S);
//inherited::OnStateSwitch(S, oldState);
}*/
}

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/cta_game_artefact.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CtaGameArtefact : public CArtefact
virtual ~CtaGameArtefact();

virtual bool Action(s32 cmd, u32 flags);
virtual void OnStateSwitch(u32 S);
virtual void OnStateSwitch(u32 S, u32 oldState);
virtual void OnAnimationEnd(u32 state);
virtual void UpdateCLChild();
virtual bool CanTake() const;
Expand Down
Loading

0 comments on commit 42ac33e

Please sign in to comment.