Skip to content

Commit

Permalink
Add more classes with new save system support
Browse files Browse the repository at this point in the history
  • Loading branch information
mnelenpridumivat committed Dec 6, 2024
1 parent 02bc8f9 commit 35c5468
Show file tree
Hide file tree
Showing 15 changed files with 162 additions and 3 deletions.
20 changes: 20 additions & 0 deletions src/xrGame/ArtCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,26 @@ void CArtCombiner::load(IReader& input_packet)
CArtContainer::load(input_packet);
}

void CArtCombiner::Save(CSaveObjectSave* Object) const
{
Object->BeginChunk("CArtCombiner");
{
CArtefact::Save(Object);
CArtContainer::Save(Object);
}
Object->EndChunk();
}

void CArtCombiner::Load(CSaveObjectLoad* Object)
{
Object->FindChunk("CArtCombiner");
{
CArtefact::Load(Object);
CArtContainer::Load(Object);
}
Object->EndChunk();
}

u32 CArtCombiner::Cost() const
{
auto res = CArtefact::Cost();
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/ArtCombiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class CArtCombiner :
void save(NET_Packet& output_packet) override;
void load(IReader& input_packet) override;

virtual void Save(CSaveObjectSave* Object) const override;
virtual void Load(CSaveObjectLoad* Object) override;

u32 Cost() const override;
float Weight() const override;

Expand Down
40 changes: 40 additions & 0 deletions src/xrGame/ArtContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,46 @@ void CArtContainer::load(IReader& packet)
}
}

void CArtContainer::Save(CSaveObjectSave* Object) const
{
Object->BeginChunk("CArtContainer");
{
Object->GetCurrentChunk()->WriteArray(m_sArtefactsInside.size());
{
for (const auto& artefact : m_sArtefactsInside)
{
shared_str section = artefact->cNameSect();
Object->GetCurrentChunk()->w_stringZ(section);
artefact->Save(Object);
}
}
Object->GetCurrentChunk()->EndArray();
}
Object->EndChunk();
}

void CArtContainer::Load(CSaveObjectLoad* Object)
{
Object->FindChunk("CArtContainer");
{
u64 ArraySize;
Object->GetCurrentChunk()->ReadArray(ArraySize);
{
for (u64 i = 0; i < ArraySize; ++i)
{
shared_str section;
Object->GetCurrentChunk()->r_stringZ(section);
CArtefact* artefact = new CArtefact();
artefact->Load(section.c_str());
artefact->Load(Object);
m_sArtefactsInside.push_back(artefact);
}
}
Object->GetCurrentChunk()->EndArray();
}
Object->EndChunk();
}

bool CArtContainer::CanStoreArt(CArtefact* art)
{
return true;
Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/ArtContainer.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once
#include "Save/SaveObject.h"

class CArtefact;

Expand All @@ -19,6 +20,9 @@ class CArtContainer
void save(NET_Packet& output_packet);
void load(IReader& input_packet);

virtual void Save(CSaveObjectSave* Object) const;
virtual void Load(CSaveObjectLoad* Object);

u32 Cost() const;
float Weight() const;

Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/Artefact.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ class CArtefact : public CHudItemObject,
//processing_deactivate ();
}


virtual void Save(CSaveObjectSave* Object) const override { inherited::Save(Object); };
virtual void Load(CSaveObjectLoad* Object) override { inherited::Load(Object); };

DECLARE_SCRIPT_REGISTER_FUNCTION
};

Expand Down
20 changes: 20 additions & 0 deletions src/xrGame/ArtefactContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,26 @@ void CArtefactContainer::load(IReader& packet)
CArtContainer::load(packet);
}

void CArtefactContainer::Save(CSaveObjectSave* Object) const
{
Object->BeginChunk("CArtefactContainer");
{
inherited::Save(Object);
CArtContainer::Save(Object);
}
Object->EndChunk();
}

void CArtefactContainer::Load(CSaveObjectLoad* Object)
{
Object->FindChunk("CInventoryItemObject");
{
inherited::Load(Object);
CArtContainer::Load(Object);
}
Object->EndChunk();
}

u32 CArtefactContainer::Cost() const
{
u32 res = CInventoryItem::Cost();
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/ArtefactContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class CArtefactContainer : public CInventoryItemObject, public CArtContainer
void save (NET_Packet& output_packet) override;
void load (IReader& input_packet) override;

virtual void Save(CSaveObjectSave* Object) const override;
virtual void Load(CSaveObjectLoad* Object) override;

u32 Cost () const override;
float Weight () const override;
};
3 changes: 3 additions & 0 deletions src/xrGame/CustomRocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class CCustomRocket : public CPhysicItem,
virtual void PhDataUpdate (float step);
virtual void PhTune (float step);

virtual void Save(CSaveObjectSave* Object) const override { inherited::Save(Object); };
virtual void Load(CSaveObjectLoad* Object) override { inherited::Load(Object); };

//////////////////////////////////////////////////////////////////////////
// Rocket Properties
//////////////////////////////////////////////////////////////////////////
Expand Down
24 changes: 23 additions & 1 deletion src/xrGame/CustomZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1534,4 +1534,26 @@ void CCustomZone::load (IReader &input_packet)
m_eZoneState = eZoneStateDisabled;
else
m_eZoneState = eZoneStateIdle;
}
}

void CCustomZone::Save(CSaveObjectSave* Object) const
{
Object->BeginChunk("CCustomZone");
{
inherited::Save(Object);
Object->GetCurrentChunk()->w_u8((u8)m_eZoneState);
}
Object->EndChunk();
}

void CCustomZone::Load(CSaveObjectLoad* Object)
{
Object->FindChunk("CCustomZone");
{
inherited::Load(Object);
u8 Value;
Object->GetCurrentChunk()->r_u8(Value);
m_eZoneState = (EZoneState)Value;
}
Object->EndChunk();
}
3 changes: 3 additions & 0 deletions src/xrGame/CustomZone.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class CCustomZone : public CSpaceRestrictor,
virtual bool is_ai_obstacle () const {return true;};
virtual void save (NET_Packet &output_packet);
virtual void load (IReader &input_packet);

virtual void Save(CSaveObjectSave* Object) const override;
virtual void Load(CSaveObjectLoad* Object) override;

virtual void UpdateCL ();
virtual void UpdateWorkload (u32 dt);
Expand Down
2 changes: 2 additions & 0 deletions src/xrGame/ExplosiveRocket.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class CExplosiveRocket :

virtual void save (NET_Packet &output_packet) {inherited::save(output_packet);}
virtual void load (IReader &input_packet) {inherited::load(input_packet);}
virtual void Save(CSaveObjectSave* Object) const override { inherited::Save(Object); };
virtual void Load(CSaveObjectLoad* Object) override { inherited::Load(Object); };
virtual BOOL net_SaveRelevant () {return inherited::net_SaveRelevant();}

virtual void OnH_A_Chield () {inherited::OnH_A_Chield();}
Expand Down
12 changes: 10 additions & 2 deletions src/xrGame/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,20 @@ void CGameObject::load (IReader &input_packet)

void CGameObject::Save(CSaveObjectSave* Object) const
{
m_ScriptBinderComponent->Save(Object);
Object->BeginChunk("CGameObject");
{
m_ScriptBinderComponent->Save(Object);
}
Object->EndChunk();
}

void CGameObject::Load(CSaveObjectLoad* Object)
{
m_ScriptBinderComponent->Load(Object);
Object->FindChunk("CGameObject");
{
m_ScriptBinderComponent->Load(Object);
}
Object->EndChunk();
}

void CGameObject::spawn_supplies()
Expand Down
3 changes: 3 additions & 0 deletions src/xrGame/hud_item_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class CHudItemObject :
virtual void on_renderable_Render();
virtual void OnMoveToRuck (const SInvItemPlace& prev);

virtual void Save(CSaveObjectSave* Object) const override { CInventoryItemObject::Save(Object); }
virtual void Load(CSaveObjectLoad* Object) override { CInventoryItemObject::Load(Object); }

virtual bool use_parent_ai_locations () const
{
return CInventoryItemObject::use_parent_ai_locations () && (Device.dwFrame != dwXF_Frame);
Expand Down
20 changes: 20 additions & 0 deletions src/xrGame/inventory_item_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,26 @@ void CInventoryItemObject::load (IReader &packet)
CInventoryItem::load (packet);
}

void CInventoryItemObject::Save(CSaveObjectSave* Object) const
{
Object->BeginChunk("CInventoryItemObject");
{
CPhysicItem::Save(Object);
CInventoryItem::Save(Object);
}
Object->EndChunk();
}

void CInventoryItemObject::Load(CSaveObjectLoad* Object)
{
Object->FindChunk("CInventoryItemObject");
{
CPhysicItem::Load(Object);
CInventoryItem::Load(Object);
}
Object->EndChunk();
}

void CInventoryItemObject::renderable_Render()
{
CPhysicItem::renderable_Render ();
Expand Down
4 changes: 4 additions & 0 deletions src/xrGame/inventory_item_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class CInventoryItemObject :
virtual void net_Export (NET_Packet& P); // export to server
virtual void save (NET_Packet &output_packet);
virtual void load (IReader &input_packet);

virtual void Save(CSaveObjectSave* Object) const override;
virtual void Load(CSaveObjectLoad* Object) override;

virtual BOOL net_SaveRelevant () {return TRUE;}
virtual void renderable_Render ();
virtual void reload (LPCSTR section);
Expand Down

0 comments on commit 35c5468

Please sign in to comment.