Initial CSaveWorld imps

This commit is contained in:
Phillip Stephens 2016-07-24 00:39:58 -07:00
parent efe4a62e5d
commit 75a7e35f8c
2 changed files with 121 additions and 0 deletions

View File

@ -4,6 +4,96 @@ namespace urde
{
CSaveWorld::CSaveWorld(CInputStream &in)
{
in.readUint32Big();
u32 version = in.readUint32Big();
if (version > 1)
x0_areaCount = in.readUint32Big();
if (version > 2)
{
u32 cinematicCount = in.readUint32Big();
x4_cinematics.reserve(cinematicCount);
for (u32 i=0 ; i<cinematicCount ; ++i)
x4_cinematics.push_back(in.readUint32Big());
u32 relayCount = in.readUint32Big();
x14_relays.reserve(relayCount);
for (u32 i=0 ; i<relayCount ; ++i)
x14_relays.push_back(in.readUint32Big());
}
u32 layerCount = in.readUint32Big();
x24_layers.reserve(layerCount);
for (u32 i=0 ; i<layerCount ; ++i)
{
x24_layers.emplace_back();
SLayerState& st = x24_layers.back();
st.x0_area = in.readUint32Big();
st.x4_layer = in.readUint32Big();
}
u32 doorCount = in.readUint32Big();
x34_doors.reserve(doorCount);
for (u32 i=0 ; i<doorCount ; ++i)
x34_doors.push_back(in.readUint32Big());
if (version > 0)
{
u32 scanCount = in.readUint32Big();
x44_scans.reserve(scanCount);
for (u32 i=0 ; i<scanCount ; ++i)
{
x44_scans.emplace_back();
SScanState& st = x44_scans.back();
st.x0_id = in.readUint32Big();
st.x4_category = EScanCategory(in.readUint32Big());
}
}
}
u32 CSaveWorld::GetAreaCount() const
{
return x0_areaCount;
}
u32 CSaveWorld::GetCinematicCount() const
{
return x4_cinematics.size();
}
s32 CSaveWorld::GetCinematicIndex(const TEditorId &id) const
{
for (u32 i=0 ; i<x4_cinematics.size() ; ++i)
if (x4_cinematics.at(i) == id)
return i;
return -1;
}
u32 CSaveWorld::GetRelayCount() const
{
return x14_relays.size();
}
s32 CSaveWorld::GetRelayIndex(const TEditorId &id) const
{
for (u32 i=0 ; i<x14_relays.size() ; ++i)
if (x14_relays.at(i) == id)
return i;
return -1;
}
u32 CSaveWorld::GetDoorCount() const
{
return x34_doors.size();
}
s32 CSaveWorld::GetDoorIndex(const TEditorId &id) const
{
for (u32 i=0 ; i<x34_doors.size() ; ++i)
if (x34_doors.at(i) == id)
return i;
return -1;
}
}

View File

@ -2,12 +2,43 @@
#define __URDE_CSAVEWORLD_HPP__
#include "RetroTypes.hpp"
#include "DNACommon/SAVWCommon.hpp"
namespace urde
{
class CSaveWorld
{
public:
using EScanCategory = DataSpec::SAVWCommon::EScanCategory;
struct SScanState
{
ResId x0_id;
EScanCategory x4_category;
};
struct SLayerState
{
TAreaId x0_area;
u32 x4_layer;
};
private:
u32 x0_areaCount;
std::vector<TEditorId> x4_cinematics;
std::vector<TEditorId> x14_relays;
std::vector<SLayerState> x24_layers;
std::vector<TEditorId> x34_doors;
std::vector<SScanState> x44_scans;
public:
CSaveWorld(CInputStream& in);
u32 GetAreaCount() const;
u32 GetCinematicCount() const;
s32 GetCinematicIndex(const TEditorId& id) const;
u32 GetRelayCount() const;
s32 GetRelayIndex(const TEditorId& id) const;
u32 GetDoorCount() const;
s32 GetDoorIndex(const TEditorId &id) const;
};
}