diff --git a/include/PrimeAPI.h b/include/PrimeAPI.h index 378dc5a..f0cc3ad 100644 --- a/include/PrimeAPI.h +++ b/include/PrimeAPI.h @@ -21,9 +21,17 @@ typedef unsigned long uint32; typedef unsigned long long uint64; // Other common types -struct TAreaId { +class TAreaId { +public: int32 Id; - inline operator int32() const { return Id; } + + TAreaId() {} + TAreaId(const TAreaId& rhs) { Id = rhs.Id; } + ~TAreaId() {} + TAreaId& operator=(const TAreaId& rhs) { Id = rhs.Id; return *this; } + TAreaId& operator=(int32 i) { Id = i; return *this; } + + operator int32() const { return Id; } }; // Common defines diff --git a/include/Runtime/CGameArea.hpp b/include/Runtime/CGameArea.hpp new file mode 100644 index 0000000..81e4c27 --- /dev/null +++ b/include/Runtime/CGameArea.hpp @@ -0,0 +1,14 @@ +#ifndef CGAMEAREA_HPP +#define CGAMEAREA_HPP + +class CStateManager; + +class CGameArea +{ +public: + void StartStreamIn(CStateManager&); + void Validate(CStateManager&); + void LoadScriptObjects(CStateManager&); +}; + +#endif // CGAMEAREA_HPP \ No newline at end of file diff --git a/include/Runtime/CStateManager.hpp b/include/Runtime/CStateManager.hpp index d717e05..f07b043 100644 --- a/include/Runtime/CStateManager.hpp +++ b/include/Runtime/CStateManager.hpp @@ -9,6 +9,7 @@ class CPlayer; class CPlayerState; +class CWorld; class CStateManager { @@ -23,6 +24,7 @@ public: void InitializeState(uint WorldAssetId, TAreaId AreaId, uint AreaAssetId); inline CPlayer* GetPlayer() const { return *GetField(this, 0x84C); } + inline CWorld* GetWorld() const { return *GetField(this, 0x850); } inline CPlayerState* GetPlayerState() const { return **GetField(this, 0x8b8); } inline EInitPhase GetInitPhase() const { return *GetField(this, 0xB3C); } }; diff --git a/include/Runtime/CWorldState.hpp b/include/Runtime/CWorldState.hpp index 91783b8..29a2d6f 100644 --- a/include/Runtime/CWorldState.hpp +++ b/include/Runtime/CWorldState.hpp @@ -2,10 +2,32 @@ #define CWORLDSTATE_HPP #include +#include + +class CWorldLayers +{ +public: + struct Area + { + uint32 mStartNameIdx; + uint32 mLayerCount; + uint64 mLayerBits; + }; +}; + +class CWorldLayerState +{ +public: + rstl::vector areaLayers; +}; class CWorldState { public: + uint32 x0_worldAssetId; + TAreaId x4_areaId; + + inline CWorldLayerState* GetWorldLayerState() const { return **GetField(this, 0x14); } void SetDesiredAreaAssetId(uint assetId); }; diff --git a/include/Runtime/World/CWorld.hpp b/include/Runtime/World/CWorld.hpp new file mode 100644 index 0000000..a9dfacb --- /dev/null +++ b/include/Runtime/World/CWorld.hpp @@ -0,0 +1,13 @@ +#ifndef CWORLD_HPP +#define CWORLD_HPP + +#include + +class CWorld +{ +public: + TAreaId IGetAreaId(uint areaAssetId) const; + TAreaId GetAreaId(uint areaAssetId) const; +}; + +#endif // CWORLD_HPP \ No newline at end of file diff --git a/include/rstl/string.h b/include/rstl/string.h new file mode 100644 index 0000000..8f99b92 --- /dev/null +++ b/include/rstl/string.h @@ -0,0 +1,110 @@ +#ifndef RSTL_STRING_H +#define RSTL_STRING_H + +#include + +RSTL_BEGIN + +class rmemory_allocator; +template +class char_traits; + +template +class basic_string { + struct COWData { + u32 x0_capacity; + u32 x4_refCount; + _CharTp *x8_data; + }; + + const _CharTp *x0_ptr; + COWData *x4_cow; + u32 x8_size; + + void internal_allocate(int size) { + x4_cow = reinterpret_cast(new u8[size * sizeof(_CharTp) + 8]); + x0_ptr = x4_cow->x8_data; + x4_cow->x0_capacity = u32(size); + x4_cow->x4_refCount = 1; + } + + static const _CharTp _EmptyString; + +public: + struct literal_t { + }; + + basic_string(literal_t, const _CharTp *data) { + x0_ptr = data; + x4_cow = nullptr; + + const _CharTp *it = data; + while (*it) { + ++it; + } + + x8_size = u32((it - data) / sizeof(_CharTp)); + } + + basic_string(const basic_string &str) { + x0_ptr = str.x0_ptr; + x4_cow = str.x4_cow; + x8_size = str.x8_size; + if (x4_cow) { + ++x4_cow->x4_refCount; + } + } + + basic_string(const _CharTp *data, int size) { + if (size <= 0 && !data) { + x0_ptr = &_EmptyString; + x4_cow = nullptr; + x8_size = 0; + return; + } + + const _CharTp *it = data; + u32 len = 0; + while (*it) { + if (size != -1 && len >= size) { + break; + } + ++it; + ++len; + } + + internal_allocate(len + 1); + x8_size = len; + for (int i = 0; i < len; ++i) { + x4_cow->x8_data[i] = data[i]; + } + x4_cow->x8_data[len] = 0; + } + + ~basic_string() { + if (x4_cow && --x4_cow->x4_refCount == 0) { + delete[] x4_cow; + } + } +}; + +template<> +const char basic_string, rmemory_allocator>::_EmptyString = 0; +template<> +const wchar_t basic_string, rmemory_allocator>::_EmptyString = 0; + +typedef basic_string, rmemory_allocator> wstring; +typedef basic_string, rmemory_allocator> string; + + +inline wstring wstring_l(const wchar_t *data) { + return wstring(wstring::literal_t(), data); +} + +inline string string_l(const char *data) { + return string(string::literal_t(), data); +} + +RSTL_END + +#endif // RSTL_STRING_H \ No newline at end of file diff --git a/include/rstl/vector.h b/include/rstl/vector.h new file mode 100644 index 0000000..8df69f2 --- /dev/null +++ b/include/rstl/vector.h @@ -0,0 +1,36 @@ +#ifndef RSTL_VECTOR_H +#define RSTL_VECTOR_H + +#include "rstl/rstl.h" + +RSTL_BEGIN + +template +class vector +{ + uint32 mFirst; + uint32 mSize; + uint32 mMax; + T* mPtr; + +public: + inline uint32 size() const { return mSize; } + inline uint32 capacity() const { return mMax; } + inline T& operator[](int i) const { return mPtr[i]; } + inline T* data() const { return mPtr; } +}; + +template +class reserved_vector +{ +public: + int32 len; + T* first; + T* end; + T* last; +}; + +RSTL_END + + +#endif // RSTL_VECTOR_H \ No newline at end of file diff --git a/symbols/v1.088.lst b/symbols/v1.088.lst index 32da4ab..013d7f5 100644 --- a/symbols/v1.088.lst +++ b/symbols/v1.088.lst @@ -825,6 +825,8 @@ 0x800556F0 __dt__6CActorFv 0x80055820 __ct__6CActorF9TUniqueIdbRCQ24rstl66basic_string,Q24rstl17rmemory_allocator>RC11CEntityInfoRC12CTransform4fRC10CModelDataRC13CMaterialListRC16CActorParameters9TUniqueId 0x80055D28 MakeActorMaterialList__FRC13CMaterialListRC16CActorParameters +0x800560CC IGetAreaId__6CWorldCFUi +0x800560F8 GetAreaId__6CWorldCFUi 0x80056164 AreSkyNeedsMet__6CWorldCFv 0x800561D0 DrawSky__6CWorldCFRC12CTransform4f 0x800562F0 PreRender__6CWorldFv @@ -969,6 +971,7 @@ 0x800609B8 Invalidate__9CGameAreaFP13CStateManager 0x80060D80 CullDeadAreaRequests__9CGameAreaFv 0x80060DE4 StartStreamIn__9CGameAreaFR13CStateManager +0x80060F60 LoadScriptObjects__9CGameAreaFR13CStateManager 0x800610A4 Validate__9CGameAreaFR13CStateManager 0x800612F0 PostConstructArea__9CGameAreaFv 0x80062548 FillInStaticGeometry__9CGameAreaFv