Skip to content

Commit

Permalink
*ADD: [Engine] Save and load condition for all items instead of just …
Browse files Browse the repository at this point in the history
…weapons and outfits
  • Loading branch information
Lucy authored and yohjimane committed Nov 14, 2023
1 parent 8ff7b67 commit 26a4500
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 44 deletions.
14 changes: 0 additions & 14 deletions src/xrGame/ActorHelmet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,6 @@ bool CHelmet::net_Spawn(CSE_Abstract* DC)
return (res);
}

void CHelmet::net_Export(NET_Packet& P)
{
inherited::net_Export(P);
P.w_float_q8(GetCondition(), 0.0f, 1.0f);
}

void CHelmet::net_Import(NET_Packet& P)
{
inherited::net_Import(P);
float _cond;
P.r_float_q8(_cond, 0.0f, 1.0f);
SetCondition(_cond);
}

void CHelmet::OnH_A_Chield()
{
inherited::OnH_A_Chield();
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/ActorHelmet.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ class CHelmet : public CInventoryItemObject
virtual void OnMoveToSlot(const SInvItemPlace& previous_place);
virtual void OnMoveToRuck(const SInvItemPlace& previous_place);
virtual bool net_Spawn(CSE_Abstract* DC);
virtual void net_Export(NET_Packet& P);
virtual void net_Import(NET_Packet& P);
virtual void OnH_A_Chield();

float GetDefHitTypeProtection(ALife::EHitType hit_type);
Expand Down
14 changes: 0 additions & 14 deletions src/xrGame/CustomOutfit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@ bool CCustomOutfit::net_Spawn(CSE_Abstract* DC)
return (res);
}

void CCustomOutfit::net_Export(NET_Packet& P)
{
inherited::net_Export(P);
P.w_float_q8(GetCondition(), 0.0f, 1.0f);
}

void CCustomOutfit::net_Import(NET_Packet& P)
{
inherited::net_Import(P);
float _cond;
P.r_float_q8(_cond, 0.0f, 1.0f);
SetCondition(_cond);
}

void CCustomOutfit::OnH_A_Chield()
{
inherited::OnH_A_Chield();
Expand Down
2 changes: 0 additions & 2 deletions src/xrGame/CustomOutfit.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ class CCustomOutfit : public CInventoryItemObject
const shared_str& GetFullIconName() const { return m_full_icon_name; }
u32 get_artefact_count() const { return m_artefact_count; }
virtual bool net_Spawn(CSE_Abstract* DC);
virtual void net_Export(NET_Packet& P);
virtual void net_Import(NET_Packet& P);
void ApplySkinModel(CActor* pActor, bool bDress, bool bHUDOnly);
void ReloadBonesProtection();
void AddBonesProtection(LPCSTR bones_section);
Expand Down
6 changes: 0 additions & 6 deletions src/xrGame/Weapon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,8 +609,6 @@ void CWeapon::net_Export(NET_Packet& P)
{
inherited::net_Export(P);

P.w_float_q8(GetCondition(), 0.0f, 1.0f);

u8 need_upd = IsUpdating() ? 1 : 0;
P.w_u8(need_upd);
P.w_u16(u16(iAmmoElapsed));
Expand All @@ -624,10 +622,6 @@ void CWeapon::net_Import(NET_Packet& P)
{
inherited::net_Import(P);

float _cond;
P.r_float_q8(_cond, 0.0f, 1.0f);
SetCondition(_cond);

u8 flags = 0;
P.r_u8(flags);

Expand Down
6 changes: 6 additions & 0 deletions src/xrGame/inventory_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ void CInventoryItem::net_Import(NET_Packet& P)
////////////////////////////////////////////
P.r_u8(); // active (not freezed ot not)

float _cond;
P.r_float_q8(_cond, 0.0f, 1.0f);
SetCondition(_cond);

if (this->cast_game_object()->Local())
{
return;
Expand Down Expand Up @@ -663,6 +667,8 @@ void CInventoryItem::net_Export(NET_Packet& P)
P.w_u8(0); // freezed
}

P.w_float_q8(GetCondition(), 0.0f, 1.0f);

/*if (object().H_Parent() || IsGameTypeSingle())
{
P.w_u8 (0);
Expand Down
9 changes: 3 additions & 6 deletions src/xrServerEntities/xrServer_Objects_ALife_Items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void CSE_ALifeInventoryItem::UPDATE_Write(NET_Packet& tNetPacket)
}
}
tNetPacket.w_u8(1); // not freezed - doesn't mean anything...
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
};

void CSE_ALifeInventoryItem::UPDATE_Read(NET_Packet& tNetPacket)
Expand Down Expand Up @@ -302,6 +303,8 @@ void CSE_ALifeInventoryItem::UPDATE_Read(NET_Packet& tNetPacket)
#endif
freezed = true;
}

tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
};

#ifndef MASTER_GOLD
Expand Down Expand Up @@ -526,7 +529,6 @@ void CSE_ALifeItemWeapon::UPDATE_Read(NET_Packet& tNetPacket)
{
inherited::UPDATE_Read(tNetPacket);

tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
tNetPacket.r_u8(wpn_flags);
tNetPacket.r_u16(a_elapsed);
tNetPacket.r_u8(m_addon_flags.flags);
Expand All @@ -540,7 +542,6 @@ void CSE_ALifeItemWeapon::UPDATE_Write(NET_Packet& tNetPacket)
{
inherited::UPDATE_Write(tNetPacket);

tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
tNetPacket.w_u8(wpn_flags);
tNetPacket.w_u16(a_elapsed);
tNetPacket.w_u8(m_addon_flags.get());
Expand Down Expand Up @@ -1012,13 +1013,11 @@ void CSE_ALifeItemCustomOutfit::STATE_Write(NET_Packet& tNetPacket) { inherited:
void CSE_ALifeItemCustomOutfit::UPDATE_Read(NET_Packet& tNetPacket)
{
inherited::UPDATE_Read(tNetPacket);
tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
}

void CSE_ALifeItemCustomOutfit::UPDATE_Write(NET_Packet& tNetPacket)
{
inherited::UPDATE_Write(tNetPacket);
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
}

#ifndef MASTER_GOLD
Expand All @@ -1036,13 +1035,11 @@ void CSE_ALifeItemHelmet::STATE_Write(NET_Packet& tNetPacket) { inherited::STATE
void CSE_ALifeItemHelmet::UPDATE_Read(NET_Packet& tNetPacket)
{
inherited::UPDATE_Read(tNetPacket);
tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
}

void CSE_ALifeItemHelmet::UPDATE_Write(NET_Packet& tNetPacket)
{
inherited::UPDATE_Write(tNetPacket);
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
}

#ifndef MASTER_GOLD
Expand Down

0 comments on commit 26a4500

Please sign in to comment.