Skip to content

Commit 26a4500

Browse files
Lucyyohjimane
Lucy
authored andcommitted
*ADD: [Engine] Save and load condition for all items instead of just weapons and outfits
1 parent 8ff7b67 commit 26a4500

7 files changed

+9
-44
lines changed

src/xrGame/ActorHelmet.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,6 @@ bool CHelmet::net_Spawn(CSE_Abstract* DC)
7474
return (res);
7575
}
7676

77-
void CHelmet::net_Export(NET_Packet& P)
78-
{
79-
inherited::net_Export(P);
80-
P.w_float_q8(GetCondition(), 0.0f, 1.0f);
81-
}
82-
83-
void CHelmet::net_Import(NET_Packet& P)
84-
{
85-
inherited::net_Import(P);
86-
float _cond;
87-
P.r_float_q8(_cond, 0.0f, 1.0f);
88-
SetCondition(_cond);
89-
}
90-
9177
void CHelmet::OnH_A_Chield()
9278
{
9379
inherited::OnH_A_Chield();

src/xrGame/ActorHelmet.h

-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ class CHelmet : public CInventoryItemObject
2323
virtual void OnMoveToSlot(const SInvItemPlace& previous_place);
2424
virtual void OnMoveToRuck(const SInvItemPlace& previous_place);
2525
virtual bool net_Spawn(CSE_Abstract* DC);
26-
virtual void net_Export(NET_Packet& P);
27-
virtual void net_Import(NET_Packet& P);
2826
virtual void OnH_A_Chield();
2927

3028
float GetDefHitTypeProtection(ALife::EHitType hit_type);

src/xrGame/CustomOutfit.cpp

-14
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ bool CCustomOutfit::net_Spawn(CSE_Abstract* DC)
3535
return (res);
3636
}
3737

38-
void CCustomOutfit::net_Export(NET_Packet& P)
39-
{
40-
inherited::net_Export(P);
41-
P.w_float_q8(GetCondition(), 0.0f, 1.0f);
42-
}
43-
44-
void CCustomOutfit::net_Import(NET_Packet& P)
45-
{
46-
inherited::net_Import(P);
47-
float _cond;
48-
P.r_float_q8(_cond, 0.0f, 1.0f);
49-
SetCondition(_cond);
50-
}
51-
5238
void CCustomOutfit::OnH_A_Chield()
5339
{
5440
inherited::OnH_A_Chield();

src/xrGame/CustomOutfit.h

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ class CCustomOutfit : public CInventoryItemObject
6363
const shared_str& GetFullIconName() const { return m_full_icon_name; }
6464
u32 get_artefact_count() const { return m_artefact_count; }
6565
virtual bool net_Spawn(CSE_Abstract* DC);
66-
virtual void net_Export(NET_Packet& P);
67-
virtual void net_Import(NET_Packet& P);
6866
void ApplySkinModel(CActor* pActor, bool bDress, bool bHUDOnly);
6967
void ReloadBonesProtection();
7068
void AddBonesProtection(LPCSTR bones_section);

src/xrGame/Weapon.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,6 @@ void CWeapon::net_Export(NET_Packet& P)
609609
{
610610
inherited::net_Export(P);
611611

612-
P.w_float_q8(GetCondition(), 0.0f, 1.0f);
613-
614612
u8 need_upd = IsUpdating() ? 1 : 0;
615613
P.w_u8(need_upd);
616614
P.w_u16(u16(iAmmoElapsed));
@@ -624,10 +622,6 @@ void CWeapon::net_Import(NET_Packet& P)
624622
{
625623
inherited::net_Import(P);
626624

627-
float _cond;
628-
P.r_float_q8(_cond, 0.0f, 1.0f);
629-
SetCondition(_cond);
630-
631625
u8 flags = 0;
632626
P.r_u8(flags);
633627

src/xrGame/inventory_item.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ void CInventoryItem::net_Import(NET_Packet& P)
400400
////////////////////////////////////////////
401401
P.r_u8(); // active (not freezed ot not)
402402

403+
float _cond;
404+
P.r_float_q8(_cond, 0.0f, 1.0f);
405+
SetCondition(_cond);
406+
403407
if (this->cast_game_object()->Local())
404408
{
405409
return;
@@ -663,6 +667,8 @@ void CInventoryItem::net_Export(NET_Packet& P)
663667
P.w_u8(0); // freezed
664668
}
665669

670+
P.w_float_q8(GetCondition(), 0.0f, 1.0f);
671+
666672
/*if (object().H_Parent() || IsGameTypeSingle())
667673
{
668674
P.w_u8 (0);

src/xrServerEntities/xrServer_Objects_ALife_Items.cpp

+3-6
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ void CSE_ALifeInventoryItem::UPDATE_Write(NET_Packet& tNetPacket)
181181
}
182182
}
183183
tNetPacket.w_u8(1); // not freezed - doesn't mean anything...
184+
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
184185
};
185186

186187
void CSE_ALifeInventoryItem::UPDATE_Read(NET_Packet& tNetPacket)
@@ -302,6 +303,8 @@ void CSE_ALifeInventoryItem::UPDATE_Read(NET_Packet& tNetPacket)
302303
#endif
303304
freezed = true;
304305
}
306+
307+
tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
305308
};
306309

307310
#ifndef MASTER_GOLD
@@ -526,7 +529,6 @@ void CSE_ALifeItemWeapon::UPDATE_Read(NET_Packet& tNetPacket)
526529
{
527530
inherited::UPDATE_Read(tNetPacket);
528531

529-
tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
530532
tNetPacket.r_u8(wpn_flags);
531533
tNetPacket.r_u16(a_elapsed);
532534
tNetPacket.r_u8(m_addon_flags.flags);
@@ -540,7 +542,6 @@ void CSE_ALifeItemWeapon::UPDATE_Write(NET_Packet& tNetPacket)
540542
{
541543
inherited::UPDATE_Write(tNetPacket);
542544

543-
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
544545
tNetPacket.w_u8(wpn_flags);
545546
tNetPacket.w_u16(a_elapsed);
546547
tNetPacket.w_u8(m_addon_flags.get());
@@ -1012,13 +1013,11 @@ void CSE_ALifeItemCustomOutfit::STATE_Write(NET_Packet& tNetPacket) { inherited:
10121013
void CSE_ALifeItemCustomOutfit::UPDATE_Read(NET_Packet& tNetPacket)
10131014
{
10141015
inherited::UPDATE_Read(tNetPacket);
1015-
tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
10161016
}
10171017

10181018
void CSE_ALifeItemCustomOutfit::UPDATE_Write(NET_Packet& tNetPacket)
10191019
{
10201020
inherited::UPDATE_Write(tNetPacket);
1021-
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
10221021
}
10231022

10241023
#ifndef MASTER_GOLD
@@ -1036,13 +1035,11 @@ void CSE_ALifeItemHelmet::STATE_Write(NET_Packet& tNetPacket) { inherited::STATE
10361035
void CSE_ALifeItemHelmet::UPDATE_Read(NET_Packet& tNetPacket)
10371036
{
10381037
inherited::UPDATE_Read(tNetPacket);
1039-
tNetPacket.r_float_q8(m_fCondition, 0.0f, 1.0f);
10401038
}
10411039

10421040
void CSE_ALifeItemHelmet::UPDATE_Write(NET_Packet& tNetPacket)
10431041
{
10441042
inherited::UPDATE_Write(tNetPacket);
1045-
tNetPacket.w_float_q8(m_fCondition, 0.0f, 1.0f);
10461043
}
10471044

10481045
#ifndef MASTER_GOLD

0 commit comments

Comments
 (0)