mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-27 12:51:42 +00:00
api: ported BlueBlur headers and misc. research
This commit is contained in:
parent
416825872a
commit
1130064df2
56 changed files with 1948 additions and 3 deletions
8
UnleashedRecomp/api/CSD/Manager/csdmBase.h
Normal file
8
UnleashedRecomp/api/CSD/Manager/csdmBase.h
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class CBase
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
31
UnleashedRecomp/api/CSD/Manager/csdmNode.h
Normal file
31
UnleashedRecomp/api/CSD/Manager/csdmNode.h
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "CSD/Manager/csdmBase.h"
|
||||||
|
#include "CSD/Manager/csdmResourceBase.h"
|
||||||
|
#include "CSD/Manager/csdmNodeObserver.h"
|
||||||
|
#include "CSD/Manager/csdmSubjectBase.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
struct Node;
|
||||||
|
|
||||||
|
class CNode : public CResourceBase<Node>, SubjectBase<CNodeObserver, CNode>, CBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x4C);
|
||||||
|
|
||||||
|
~CNode() override = default;
|
||||||
|
|
||||||
|
void SetText(const char* in_pText);
|
||||||
|
void SetText(const wchar_t* in_pText);
|
||||||
|
Hedgehog::Math::CVector2 GetPosition() const;
|
||||||
|
void SetPosition(float in_X, float in_Y);
|
||||||
|
void SetHideFlag(uint32_t in_HideFlag);
|
||||||
|
void SetRotation(float in_Rotation);
|
||||||
|
void SetScale(float in_X, float in_Y);
|
||||||
|
void SetPatternIndex(uint32_t in_PatternIndex);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmNode.inl"
|
||||||
46
UnleashedRecomp/api/CSD/Manager/csdmNode.inl
Normal file
46
UnleashedRecomp/api/CSD/Manager/csdmNode.inl
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
inline void CNode::SetText(const char* in_pText)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF640, this, in_pText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CNode::SetText(const wchar_t* in_pText)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF640, this, in_pText);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline Hedgehog::Math::CVector2 CNode::GetPosition() const
|
||||||
|
{
|
||||||
|
Hedgehog::Math::CVector2 position;
|
||||||
|
GuestToHostFunction<void>(0x830BF008, this, &position);
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CNode::SetPosition(float in_X, float in_Y)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF078, this, in_X, in_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CNode::SetHideFlag(uint32_t in_HideFlag)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF080, this, in_HideFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CNode::SetRotation(float in_Rotation)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF088, this, in_Rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CNode::SetScale(float in_X, float in_Y)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF090, this, in_X, in_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CNode::SetPatternIndex(uint32_t in_PatternIndex)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<int>(0x830BF300, this, in_PatternIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
UnleashedRecomp/api/CSD/Manager/csdmNodeObserver.h
Normal file
12
UnleashedRecomp/api/CSD/Manager/csdmNodeObserver.h
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmObserverBase.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class CNode;
|
||||||
|
|
||||||
|
class CNodeObserver : public CObserverBase<CNode>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
15
UnleashedRecomp/api/CSD/Manager/csdmObserverBase.h
Normal file
15
UnleashedRecomp/api/CSD/Manager/csdmObserverBase.h
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename TObservee>
|
||||||
|
class CObserverBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x0C);
|
||||||
|
|
||||||
|
virtual ~CObserverBase() = default;
|
||||||
|
};
|
||||||
|
}
|
||||||
31
UnleashedRecomp/api/CSD/Manager/csdmProject.h
Normal file
31
UnleashedRecomp/api/CSD/Manager/csdmProject.h
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "CSD/Manager/csdmBase.h"
|
||||||
|
#include "CSD/Manager/csdmResourceBase.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
struct Project;
|
||||||
|
class CProject;
|
||||||
|
class CScene;
|
||||||
|
class CTexList;
|
||||||
|
|
||||||
|
class CProject : public CResourceBase<Project>, CBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x1C);
|
||||||
|
RCPtr<CTexList> m_rcTexList;
|
||||||
|
SWA_INSERT_PADDING(0x1C);
|
||||||
|
|
||||||
|
RCPtr<CScene> CreateScene(const char* in_pName) const;
|
||||||
|
RCPtr<CScene> CreateScene(const char* in_pName, const char* in_pMotionName) const;
|
||||||
|
|
||||||
|
void DestroyScene(CScene* in_pScene);
|
||||||
|
void DestroyScene(RCPtr<CScene>& inout_rcScene);
|
||||||
|
|
||||||
|
static void DestroyScene(CProject* in_pProject, RCPtr<CScene>& inout_rcScene);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmProject.inl"
|
||||||
40
UnleashedRecomp/api/CSD/Manager/csdmProject.inl
Normal file
40
UnleashedRecomp/api/CSD/Manager/csdmProject.inl
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
#include "kernel/function.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
inline RCPtr<CScene> CProject::CreateScene(const char* in_pName) const
|
||||||
|
{
|
||||||
|
RCPtr<CScene> rcScene;
|
||||||
|
GuestToHostFunction<void>(0x830BEE00, this, rcScene, in_pName, nullptr);
|
||||||
|
return rcScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtr<CScene> CProject::CreateScene(const char* in_pName, const char* in_pMotionName) const
|
||||||
|
{
|
||||||
|
RCPtr<CScene> rcScene;
|
||||||
|
GuestToHostFunction<void>(0x830BECE0, this, rcScene, in_pName, in_pMotionName, nullptr);
|
||||||
|
return rcScene;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CProject::DestroyScene(CScene* in_pScene)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BE298, this, in_pScene);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CProject::DestroyScene(RCPtr<CScene>& inout_rcScene)
|
||||||
|
{
|
||||||
|
if (!inout_rcScene)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DestroyScene(inout_rcScene.Get());
|
||||||
|
inout_rcScene = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CProject::DestroyScene(CProject* in_pProject, RCPtr<CScene>& inout_rcScene)
|
||||||
|
{
|
||||||
|
if (in_pProject)
|
||||||
|
in_pProject->DestroyScene(inout_rcScene);
|
||||||
|
else
|
||||||
|
inout_rcScene = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
UnleashedRecomp/api/CSD/Manager/csdmRCObject.h
Normal file
20
UnleashedRecomp/api/CSD/Manager/csdmRCObject.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmRCPtrAbs.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class RCPtrAbs::RCObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
xpointer<void> m_pMemory;
|
||||||
|
be<uint32_t> m_RefCount;
|
||||||
|
xpointer<void> m_pDealloctor;
|
||||||
|
be<uint32_t> m_eDealloctor;
|
||||||
|
|
||||||
|
virtual ~RCObject();
|
||||||
|
virtual void Deallocate(void* in_pMemory) = 0;
|
||||||
|
|
||||||
|
void Release();
|
||||||
|
};
|
||||||
|
}
|
||||||
24
UnleashedRecomp/api/CSD/Manager/csdmRCObject.inl
Normal file
24
UnleashedRecomp/api/CSD/Manager/csdmRCObject.inl
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
inline void RCPtrAbs::RCObject::Release()
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BA068, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtrAbs::~RCPtrAbs()
|
||||||
|
{
|
||||||
|
RCObject* pObj = m_pObject;
|
||||||
|
m_pObject = nullptr;
|
||||||
|
|
||||||
|
if (pObj)
|
||||||
|
pObj->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* RCPtrAbs::GetAbs() const
|
||||||
|
{
|
||||||
|
if (!m_pObject)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
return m_pObject->m_pMemory;
|
||||||
|
}
|
||||||
|
}
|
||||||
12
UnleashedRecomp/api/CSD/Manager/csdmRCObjectImp.h
Normal file
12
UnleashedRecomp/api/CSD/Manager/csdmRCObjectImp.h
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmRCPtr.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
class RCPtr<T>::RCObjectImp : public RCObject
|
||||||
|
{
|
||||||
|
void Deallocate(void* in_pMemory) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
14
UnleashedRecomp/api/CSD/Manager/csdmRCObjectImp.inl
Normal file
14
UnleashedRecomp/api/CSD/Manager/csdmRCObjectImp.inl
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void RCPtr<T>::RCObjectImp::Deallocate(void* in_pMemory)
|
||||||
|
{
|
||||||
|
// delete static_cast<T*>(in_pMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RCPtrAbs::RCObject* RCPtr<T>::CreateRCObject()
|
||||||
|
{
|
||||||
|
return new RCObjectImp();
|
||||||
|
}
|
||||||
|
}
|
||||||
32
UnleashedRecomp/api/CSD/Manager/csdmRCPtr.h
Normal file
32
UnleashedRecomp/api/CSD/Manager/csdmRCPtr.h
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmRCPtrAbs.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
class RCPtr : RCPtrAbs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class RCObjectImp;
|
||||||
|
|
||||||
|
RCPtr() : RCPtrAbs() {}
|
||||||
|
RCPtr(T* in_pMemory) : RCPtrAbs(in_pMemory) {}
|
||||||
|
RCPtr(const RCPtr& in_rOther) : RCPtrAbs(in_rOther) {}
|
||||||
|
RCPtr(RCPtr&& in_rOther) : RCPtrAbs(std::move(in_rOther)) {}
|
||||||
|
|
||||||
|
RCObject* CreateRCObject() override;
|
||||||
|
|
||||||
|
void Attach(T* in_pObject);
|
||||||
|
|
||||||
|
T* Get() const;
|
||||||
|
void Set(const RCPtr& in_rOther);
|
||||||
|
|
||||||
|
T* operator*() const;
|
||||||
|
T* operator->() const;
|
||||||
|
|
||||||
|
RCPtr& operator=(const RCPtr& in_rOther);
|
||||||
|
|
||||||
|
operator bool() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
45
UnleashedRecomp/api/CSD/Manager/csdmRCPtr.inl
Normal file
45
UnleashedRecomp/api/CSD/Manager/csdmRCPtr.inl
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void RCPtr<T>::Attach(T* in_pObject)
|
||||||
|
{
|
||||||
|
RCPtrAbs::AttachAbs(in_pObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* RCPtr<T>::Get() const
|
||||||
|
{
|
||||||
|
return static_cast<T*>(RCPtrAbs::GetAbs());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
void RCPtr<T>::Set(const RCPtr& in_rOther)
|
||||||
|
{
|
||||||
|
RCPtrAbs::SetAbs(in_rOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* RCPtr<T>::operator*() const
|
||||||
|
{
|
||||||
|
return Get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T* RCPtr<T>::operator->() const
|
||||||
|
{
|
||||||
|
return Get();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RCPtr<T>& RCPtr<T>::operator=(const RCPtr& in_rOther)
|
||||||
|
{
|
||||||
|
Set(in_rOther);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
RCPtr<T>::operator bool() const
|
||||||
|
{
|
||||||
|
return m_pObject != nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
33
UnleashedRecomp/api/CSD/Manager/csdmRCPtrAbs.h
Normal file
33
UnleashedRecomp/api/CSD/Manager/csdmRCPtrAbs.h
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class RCPtrAbs
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class RCObject;
|
||||||
|
|
||||||
|
xpointer<RCObject> m_pObject;
|
||||||
|
|
||||||
|
RCPtrAbs();
|
||||||
|
RCPtrAbs(void* in_pMemory);
|
||||||
|
RCPtrAbs(const RCPtrAbs& in_rOther);
|
||||||
|
RCPtrAbs(RCPtrAbs&& in_rPtr);
|
||||||
|
|
||||||
|
virtual ~RCPtrAbs();
|
||||||
|
virtual RCObject* CreateRCObject() = 0;
|
||||||
|
|
||||||
|
void AttachAbs(void* in_pMemory);
|
||||||
|
void* GetAbs() const;
|
||||||
|
void SetAbs(const RCPtrAbs& in_rPtr);
|
||||||
|
|
||||||
|
void* operator*() const;
|
||||||
|
void* operator->() const;
|
||||||
|
|
||||||
|
RCPtrAbs& operator=(const RCPtrAbs& in_rPtr);
|
||||||
|
|
||||||
|
operator bool() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
53
UnleashedRecomp/api/CSD/Manager/csdmRCPtrAbs.inl
Normal file
53
UnleashedRecomp/api/CSD/Manager/csdmRCPtrAbs.inl
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
inline RCPtrAbs::RCPtrAbs()
|
||||||
|
{
|
||||||
|
AttachAbs(nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtrAbs::RCPtrAbs(void* in_pMemory)
|
||||||
|
{
|
||||||
|
AttachAbs(in_pMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtrAbs::RCPtrAbs(const RCPtrAbs& in_rOther)
|
||||||
|
{
|
||||||
|
SetAbs(in_rOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtrAbs::RCPtrAbs(RCPtrAbs&& in_rPtr) : m_pObject(in_rPtr.m_pObject)
|
||||||
|
{
|
||||||
|
in_rPtr.m_pObject = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RCPtrAbs::AttachAbs(void* in_pMemory)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BA298, this, in_pMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void RCPtrAbs::SetAbs(const RCPtrAbs& in_rPtr)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BA328, this, in_rPtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* RCPtrAbs::operator*() const
|
||||||
|
{
|
||||||
|
return GetAbs();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void* RCPtrAbs::operator->() const
|
||||||
|
{
|
||||||
|
return GetAbs();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtrAbs& RCPtrAbs::operator=(const RCPtrAbs& in_rPtr)
|
||||||
|
{
|
||||||
|
SetAbs(in_rPtr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline RCPtrAbs::operator bool() const
|
||||||
|
{
|
||||||
|
return m_pObject != nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
UnleashedRecomp/api/CSD/Manager/csdmResourceBase.h
Normal file
18
UnleashedRecomp/api/CSD/Manager/csdmResourceBase.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmRCPtr.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
class CResourceBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RCPtr<uint8_t> m_rcResourceHolder;
|
||||||
|
xpointer<T> m_pResource;
|
||||||
|
|
||||||
|
virtual ~CResourceBase() = default;
|
||||||
|
|
||||||
|
virtual void CopyResource(const CResourceBase& in_rOther);
|
||||||
|
};
|
||||||
|
}
|
||||||
9
UnleashedRecomp/api/CSD/Manager/csdmResourceBase.inl
Normal file
9
UnleashedRecomp/api/CSD/Manager/csdmResourceBase.inl
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
void CResourceBase<T>::CopyResource(const CResourceBase& in_rOther)
|
||||||
|
{
|
||||||
|
m_rcResourceHolder = in_rOther.m_rcResourceHolder;
|
||||||
|
m_pResource = in_rOther.m_pResource;
|
||||||
|
}
|
||||||
|
}
|
||||||
64
UnleashedRecomp/api/CSD/Manager/csdmScene.h
Normal file
64
UnleashedRecomp/api/CSD/Manager/csdmScene.h
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "CSD/Manager/csdmBase.h"
|
||||||
|
#include "CSD/Manager/csdmResourceBase.h"
|
||||||
|
#include "CSD/Manager/csdmSceneObserver.h"
|
||||||
|
#include "CSD/Manager/csdmSubjectBase.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
struct Scene;
|
||||||
|
class CScene;
|
||||||
|
class CNode;
|
||||||
|
|
||||||
|
enum EMotionRepeatType : uint32_t
|
||||||
|
{
|
||||||
|
eMotionRepeatType_PlayOnce = 0,
|
||||||
|
eMotionRepeatType_Loop = 1,
|
||||||
|
eMotionRepeatType_PingPong = 2,
|
||||||
|
eMotionRepeatType_PlayThenDestroy = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
class CScene : public CResourceBase<Scene>, SubjectBase<CSceneObserver, CScene>, CBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x5C);
|
||||||
|
be<float> m_PrevMotionFrame;
|
||||||
|
be<float> m_MotionFrame;
|
||||||
|
be<float> m_MotionSpeed;
|
||||||
|
be<float> m_MotionStartFrame;
|
||||||
|
be<float> m_MotionEndFrame;
|
||||||
|
SWA_INSERT_PADDING(0x0C);
|
||||||
|
be<uint32_t> m_MotionDisableFlag;
|
||||||
|
SWA_INSERT_PADDING(0x10);
|
||||||
|
be<EMotionRepeatType> m_MotionRepeatType;
|
||||||
|
SWA_INSERT_PADDING(0x2C);
|
||||||
|
|
||||||
|
~CScene() override = default;
|
||||||
|
|
||||||
|
// Update should be called with a delta time of zero
|
||||||
|
// after making changes to a motion.
|
||||||
|
|
||||||
|
// Example:
|
||||||
|
// SetMotion("Intro_Anim");
|
||||||
|
// SetMotionFrame(0.0);
|
||||||
|
// m_MotionSpeed = 2.0f;
|
||||||
|
// Update(0.0f);
|
||||||
|
|
||||||
|
// Changes are not going to be recognized if
|
||||||
|
// update is not called.
|
||||||
|
|
||||||
|
virtual void Update(float in_DeltaTime = 0.0f);
|
||||||
|
virtual void Render(void*);
|
||||||
|
|
||||||
|
RCPtr<CNode> GetNode(const char* in_pName) const;
|
||||||
|
|
||||||
|
bool SetMotion(const char* in_pName);
|
||||||
|
void SetMotionFrame(float in_MotionFrame);
|
||||||
|
void SetPosition(float in_X, float in_Y);
|
||||||
|
void SetHideFlag(uint32_t in_HideFlag);
|
||||||
|
void SetRotation(float in_Angle);
|
||||||
|
void SetScale(float in_X, float in_Y);
|
||||||
|
};
|
||||||
|
}
|
||||||
40
UnleashedRecomp/api/CSD/Manager/csdmScene.inl
Normal file
40
UnleashedRecomp/api/CSD/Manager/csdmScene.inl
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
inline RCPtr<CNode> CScene::GetNode(const char* in_pName) const
|
||||||
|
{
|
||||||
|
RCPtr<CNode> rcNode;
|
||||||
|
GuestToHostFunction<void>(0x830BCCA8, this, rcNode, in_pName);
|
||||||
|
return rcNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CScene::SetMotion(const char* in_pName)
|
||||||
|
{
|
||||||
|
return GuestToHostFunction<bool>(0x830BA760, this, in_pName);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CScene::SetMotionFrame(float in_MotionFrame)
|
||||||
|
{
|
||||||
|
m_PrevMotionFrame = in_MotionFrame;
|
||||||
|
m_MotionFrame = in_MotionFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CScene::SetPosition(float in_X, float in_Y)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BB550, this, in_X, in_Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CScene::SetHideFlag(uint32_t in_HideFlag)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BB378, this, in_HideFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CScene::SetRotation(float in_Angle)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BB5F8, this, in_Angle);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CScene::SetScale(float in_X, float in_Y)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x830BB650, this, in_X, in_Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
12
UnleashedRecomp/api/CSD/Manager/csdmSceneObserver.h
Normal file
12
UnleashedRecomp/api/CSD/Manager/csdmSceneObserver.h
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmObserverBase.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class CScene;
|
||||||
|
|
||||||
|
class CSceneObserver : public CObserverBase<CScene>
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
16
UnleashedRecomp/api/CSD/Manager/csdmSubjectBase.h
Normal file
16
UnleashedRecomp/api/CSD/Manager/csdmSubjectBase.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
template<typename TObserver, typename TObservee>
|
||||||
|
class SubjectBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x0C);
|
||||||
|
|
||||||
|
virtual ~SubjectBase() = default;
|
||||||
|
virtual TObservee* GetObservee() const { return nullptr; }
|
||||||
|
};
|
||||||
|
}
|
||||||
15
UnleashedRecomp/api/CSD/Platform/csdTexList.h
Normal file
15
UnleashedRecomp/api/CSD/Platform/csdTexList.h
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmBase.h"
|
||||||
|
#include "CSD/Manager/csdmRCPtr.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class CTexList : public CBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
RCPtr<uint8_t> m_rcData;
|
||||||
|
|
||||||
|
virtual ~CTexList() = default;
|
||||||
|
};
|
||||||
|
}
|
||||||
36
UnleashedRecomp/api/Hedgehog/Base/System/hhAllocator.h
Normal file
36
UnleashedRecomp/api/Hedgehog/Base/System/hhAllocator.h
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
inline static void* __HH_ALLOC(const uint32_t in_Size)
|
||||||
|
{
|
||||||
|
return GuestToHostFunction<void*>(0x82DFA0B0, in_Size, nullptr, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void __HH_FREE(const void* in_pData)
|
||||||
|
{
|
||||||
|
GuestToHostFunction<void>(0x82DF9E50, in_pData);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
template<class T>
|
||||||
|
class TAllocator
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using value_type = T;
|
||||||
|
|
||||||
|
TAllocator() noexcept {}
|
||||||
|
template<class U> TAllocator(TAllocator<U> const&) noexcept {}
|
||||||
|
|
||||||
|
value_type* allocate(std::size_t n)
|
||||||
|
{
|
||||||
|
return reinterpret_cast<value_type*>(__HH_ALLOC(n * sizeof(value_type)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void deallocate(value_type* p, std::size_t) noexcept
|
||||||
|
{
|
||||||
|
__HH_FREE(p);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
20
UnleashedRecomp/api/Hedgehog/Base/Thread/hhHolder.h
Normal file
20
UnleashedRecomp/api/Hedgehog/Base/Thread/hhHolder.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Hedgehog/Base/Thread/hhHolderBase.h"
|
||||||
|
|
||||||
|
#define HH_BASE_HOLDER(x) \
|
||||||
|
Hedgehog::Base::THolder(x)
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
template<typename T, bool ForceSync = true>
|
||||||
|
class THolder : public CHolderBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
THolder(T* in_pObject) : CHolderBase(in_pObject, ForceSync) {}
|
||||||
|
|
||||||
|
T* get() const;
|
||||||
|
T* operator->() const;
|
||||||
|
T* operator*() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
28
UnleashedRecomp/api/Hedgehog/Base/Thread/hhHolderBase.h
Normal file
28
UnleashedRecomp/api/Hedgehog/Base/Thread/hhHolderBase.h
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
class CSynchronizedObject;
|
||||||
|
|
||||||
|
class CHolderBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
xpointer<CSynchronizedObject> m_pSynchronizedObject;
|
||||||
|
bool m_Locked;
|
||||||
|
|
||||||
|
public:
|
||||||
|
CHolderBase() : m_pSynchronizedObject(nullptr), m_Locked(false) {}
|
||||||
|
CHolderBase(CSynchronizedObject* in_pSynchronizedObject, bool in_ForceSync = false);
|
||||||
|
CHolderBase(CHolderBase&& io_rOther);
|
||||||
|
CHolderBase(const CHolderBase& in_rOther);
|
||||||
|
~CHolderBase();
|
||||||
|
|
||||||
|
CSynchronizedObject* get() const;
|
||||||
|
CSynchronizedObject* operator->() const;
|
||||||
|
CSynchronizedObject* operator*() const;
|
||||||
|
|
||||||
|
explicit operator bool() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
class CSynchronizedObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x04);
|
||||||
|
};
|
||||||
|
}
|
||||||
27
UnleashedRecomp/api/Hedgehog/Base/Thread/hhSynchronizedPtr.h
Normal file
27
UnleashedRecomp/api/Hedgehog/Base/Thread/hhSynchronizedPtr.h
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Base/Thread/hhHolder.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
template<typename T, bool ForceSync = false>
|
||||||
|
class TSynchronizedPtr
|
||||||
|
{
|
||||||
|
xpointer<T> m_pObject;
|
||||||
|
|
||||||
|
public:
|
||||||
|
TSynchronizedPtr(T* in_pObject);
|
||||||
|
TSynchronizedPtr();
|
||||||
|
TSynchronizedPtr(const TSynchronizedPtr& in_rOther);
|
||||||
|
TSynchronizedPtr(TSynchronizedPtr&& io_rOther);
|
||||||
|
|
||||||
|
TSynchronizedPtr<T, ForceSync>& operator=(T* const in_pObject);
|
||||||
|
|
||||||
|
THolder<T, ForceSync> get() const;
|
||||||
|
THolder<T, ForceSync> operator->() const;
|
||||||
|
THolder<T, ForceSync> operator*() const;
|
||||||
|
|
||||||
|
explicit operator bool() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
struct SStringHolder
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
be<uint16_t> Length;
|
||||||
|
be<uint16_t> RefCount;
|
||||||
|
};
|
||||||
|
|
||||||
|
be<uint32_t> RefCountAndLength;
|
||||||
|
};
|
||||||
|
|
||||||
|
char aStr[1u];
|
||||||
|
|
||||||
|
static SStringHolder* GetHolder(const char* in_pStr);
|
||||||
|
|
||||||
|
static size_t GetMemorySize(const size_t in_Length);
|
||||||
|
static size_t GetMemorySizeAligned(const size_t in_Length);
|
||||||
|
|
||||||
|
static SStringHolder* Make(const char* in_pStr, const size_t in_Length);
|
||||||
|
|
||||||
|
static SStringHolder* Concat(
|
||||||
|
const char* in_pStrA, const size_t in_LengthA,
|
||||||
|
const char* in_pStrB, const size_t in_LengthB);
|
||||||
|
|
||||||
|
void AddRef();
|
||||||
|
void Release();
|
||||||
|
|
||||||
|
bool IsUnique() const;
|
||||||
|
|
||||||
|
bool TryInplaceAssign(const char* in_pStr, const size_t in_Length);
|
||||||
|
bool TryInplaceAppend(const char* in_pStr, const size_t in_Length);
|
||||||
|
bool TryInplacePrepend(const char* in_pStr, const size_t in_Length);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "Hedgehog/Base/Type/detail/hhStringHolder.inl"
|
||||||
134
UnleashedRecomp/api/Hedgehog/Base/Type/detail/hhStringHolder.inl
Normal file
134
UnleashedRecomp/api/Hedgehog/Base/Type/detail/hhStringHolder.inl
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
inline SStringHolder* SStringHolder::GetHolder(const char* in_pStr)
|
||||||
|
{
|
||||||
|
return (SStringHolder*)((size_t)in_pStr - sizeof(RefCountAndLength));
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t SStringHolder::GetMemorySize(const size_t in_Length)
|
||||||
|
{
|
||||||
|
return sizeof(RefCountAndLength) + in_Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t SStringHolder::GetMemorySizeAligned(const size_t in_Length)
|
||||||
|
{
|
||||||
|
return (GetMemorySize(in_Length) + 0x10) & ~0x0F;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SStringHolder* SStringHolder::Make(const char* in_pStr, const size_t in_Length)
|
||||||
|
{
|
||||||
|
const size_t memSize = GetMemorySize(in_Length);
|
||||||
|
const size_t memSizeAligned = GetMemorySizeAligned(in_Length);
|
||||||
|
|
||||||
|
SStringHolder* pHolder = (SStringHolder*)__HH_ALLOC(memSizeAligned);
|
||||||
|
pHolder->RefCount = 1;
|
||||||
|
pHolder->Length = (uint16_t)in_Length;
|
||||||
|
|
||||||
|
if (in_pStr)
|
||||||
|
memcpy(pHolder->aStr, in_pStr, in_Length);
|
||||||
|
|
||||||
|
memset(&pHolder->aStr[in_Length], 0, memSizeAligned - memSize);
|
||||||
|
|
||||||
|
return pHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline SStringHolder* SStringHolder::Concat(const char* in_pStrA, const size_t in_LengthA, const char* in_pStrB, const size_t in_LengthB)
|
||||||
|
{
|
||||||
|
SStringHolder* pHolder = Make(nullptr, in_LengthA + in_LengthB);
|
||||||
|
|
||||||
|
memcpy(pHolder->aStr, in_pStrA, in_LengthA);
|
||||||
|
memcpy(&pHolder->aStr[in_LengthA], in_pStrB, in_LengthB);
|
||||||
|
|
||||||
|
return pHolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SStringHolder::AddRef()
|
||||||
|
{
|
||||||
|
uint32_t originalValue, incrementedValue;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
originalValue = RefCountAndLength.value;
|
||||||
|
incrementedValue = std::byteswap(std::byteswap(originalValue) + 1);
|
||||||
|
} while (InterlockedCompareExchange(reinterpret_cast<LONG*>(&RefCountAndLength), incrementedValue, originalValue) != originalValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void SStringHolder::Release()
|
||||||
|
{
|
||||||
|
uint32_t originalValue, decrementedValue;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
originalValue = RefCountAndLength.value;
|
||||||
|
decrementedValue = std::byteswap(std::byteswap(originalValue) - 1);
|
||||||
|
} while (InterlockedCompareExchange(reinterpret_cast<LONG*>(&RefCountAndLength), decrementedValue, originalValue) != originalValue);
|
||||||
|
|
||||||
|
if (RefCountAndLength == 0)
|
||||||
|
__HH_FREE(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SStringHolder::IsUnique() const
|
||||||
|
{
|
||||||
|
return RefCount == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SStringHolder::TryInplaceAssign(const char* in_pStr, const size_t in_Length)
|
||||||
|
{
|
||||||
|
if (!IsUnique())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const size_t memSizeAligned = GetMemorySizeAligned(in_Length);
|
||||||
|
|
||||||
|
if (memSizeAligned > GetMemorySizeAligned(Length))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (in_pStr)
|
||||||
|
memcpy(aStr, in_pStr, in_Length);
|
||||||
|
|
||||||
|
memset(&aStr[in_Length], 0, memSizeAligned - GetMemorySize(in_Length));
|
||||||
|
|
||||||
|
Length = (uint16_t)in_Length;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SStringHolder::TryInplaceAppend(const char* in_pStr, const size_t in_Length)
|
||||||
|
{
|
||||||
|
if (!IsUnique())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const size_t memSizeAligned = GetMemorySizeAligned(Length + in_Length);
|
||||||
|
|
||||||
|
if (memSizeAligned > GetMemorySizeAligned(Length))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (in_pStr)
|
||||||
|
memcpy(&aStr[Length], in_pStr, in_Length);
|
||||||
|
|
||||||
|
memset(&aStr[Length + in_Length], 0, memSizeAligned - GetMemorySize(Length + in_Length));
|
||||||
|
|
||||||
|
Length = (uint16_t)(Length + in_Length);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool SStringHolder::TryInplacePrepend(const char* in_pStr, const size_t in_Length)
|
||||||
|
{
|
||||||
|
if (!IsUnique())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const size_t memSizeAligned = GetMemorySizeAligned(in_Length + Length);
|
||||||
|
|
||||||
|
if (memSizeAligned > GetMemorySizeAligned(Length))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
memmove(&aStr[in_Length], aStr, Length);
|
||||||
|
|
||||||
|
if (in_pStr)
|
||||||
|
memcpy(aStr, in_pStr, in_Length);
|
||||||
|
|
||||||
|
memset(&aStr[in_Length + Length], 0, memSizeAligned - GetMemorySize(in_Length + Length));
|
||||||
|
|
||||||
|
Length = (uint16_t)(in_Length + Length);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
88
UnleashedRecomp/api/Hedgehog/Base/Type/hhSharedString.h
Normal file
88
UnleashedRecomp/api/Hedgehog/Base/Type/hhSharedString.h
Normal file
|
|
@ -0,0 +1,88 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Hedgehog/Base/Type/detail/hhStringHolder.h>
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
class CSharedString
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
xpointer<const char> m_pStr;
|
||||||
|
|
||||||
|
SStringHolder* GetHolder() const;
|
||||||
|
|
||||||
|
CSharedString(SStringHolder* in_pHolder);
|
||||||
|
|
||||||
|
public:
|
||||||
|
static constexpr size_t npos = ~0u;
|
||||||
|
|
||||||
|
CSharedString();
|
||||||
|
CSharedString(const char* in_pStr);
|
||||||
|
CSharedString(const CSharedString& in_rOther);
|
||||||
|
CSharedString(CSharedString&& io_rOther);
|
||||||
|
~CSharedString();
|
||||||
|
|
||||||
|
const char* get() const;
|
||||||
|
const char* c_str() const;
|
||||||
|
const char* data() const;
|
||||||
|
|
||||||
|
size_t size() const;
|
||||||
|
size_t length() const;
|
||||||
|
bool empty() const;
|
||||||
|
|
||||||
|
const char* begin() const;
|
||||||
|
const char* end() const;
|
||||||
|
|
||||||
|
CSharedString substr(size_t pos = 0, size_t len = npos) const;
|
||||||
|
|
||||||
|
size_t find(char c, size_t pos = 0) const;
|
||||||
|
size_t find(const char* s, size_t pos = 0) const;
|
||||||
|
size_t rfind(char c, size_t pos = npos) const;
|
||||||
|
|
||||||
|
size_t find_first_of(const char* s, size_t pos = 0) const;
|
||||||
|
size_t find_last_of(const char* s, size_t pos = npos) const;
|
||||||
|
size_t find_first_not_of(const char* s, size_t pos = 0) const;
|
||||||
|
size_t find_last_not_of(const char* s, size_t pos = npos) const;
|
||||||
|
|
||||||
|
size_t find(const CSharedString& str, size_t pos = 0) const;
|
||||||
|
size_t rfind(const CSharedString& str, size_t pos = npos) const;
|
||||||
|
|
||||||
|
size_t find_first_of(const CSharedString& str, size_t pos = 0) const;
|
||||||
|
size_t find_last_of(const CSharedString& str, size_t pos = npos) const;
|
||||||
|
size_t find_first_not_of(const CSharedString& str, size_t pos = 0) const;
|
||||||
|
size_t find_last_not_of(const CSharedString& str, size_t pos = npos) const;
|
||||||
|
|
||||||
|
void assign(const CSharedString& in_rOther);
|
||||||
|
void assign(const char* in_pStr);
|
||||||
|
void assign(CSharedString&& io_rOther);
|
||||||
|
|
||||||
|
void append(const CSharedString& in_rOther);
|
||||||
|
void append(const char* in_pStr);
|
||||||
|
|
||||||
|
void prepend(const CSharedString& in_rOther);
|
||||||
|
void prepend(const char* in_pStr);
|
||||||
|
|
||||||
|
int compare(const CSharedString& in_rOther) const;
|
||||||
|
|
||||||
|
CSharedString& operator=(const CSharedString& in_rOther);
|
||||||
|
CSharedString& operator=(const char* in_pStr);
|
||||||
|
CSharedString& operator=(CSharedString&& io_rOther);
|
||||||
|
CSharedString& operator+=(const CSharedString& in_rOther);
|
||||||
|
CSharedString& operator+=(const char* in_pStr);
|
||||||
|
|
||||||
|
friend CSharedString operator+(const CSharedString& in_rLeft, const CSharedString& in_rRight);
|
||||||
|
friend CSharedString operator+(const CSharedString& in_rLeft, const char* in_pRight);
|
||||||
|
friend CSharedString operator+(const char* in_pLeft, const CSharedString& in_pRight);
|
||||||
|
|
||||||
|
bool operator>(const CSharedString& in_rOther) const;
|
||||||
|
bool operator>=(const CSharedString& in_rOther) const;
|
||||||
|
bool operator<(const CSharedString& in_rOther) const;
|
||||||
|
bool operator<=(const CSharedString& in_rOther) const;
|
||||||
|
bool operator==(const CSharedString& in_rOther) const;
|
||||||
|
bool operator!=(const CSharedString& in_rOther) const;
|
||||||
|
bool operator==(const char* in_pOther) const;
|
||||||
|
bool operator!=(const char* in_pOther) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <Hedgehog/Base/Type/hhSharedString.inl>
|
||||||
444
UnleashedRecomp/api/Hedgehog/Base/Type/hhSharedString.inl
Normal file
444
UnleashedRecomp/api/Hedgehog/Base/Type/hhSharedString.inl
Normal file
|
|
@ -0,0 +1,444 @@
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
inline SStringHolder* CSharedString::GetHolder() const
|
||||||
|
{
|
||||||
|
return SStringHolder::GetHolder(m_pStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString::CSharedString(SStringHolder* in_pHolder) : m_pStr(in_pHolder->aStr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString::CSharedString() : m_pStr(nullptr)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString::CSharedString(const char* in_pStr) : m_pStr(nullptr)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
if (in_pStr && (length = strlen(in_pStr)) != 0)
|
||||||
|
m_pStr.ptr = g_memory.MapVirtual(SStringHolder::Make(in_pStr, length)->aStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString::CSharedString(const CSharedString& in_rOther) : m_pStr(in_rOther.m_pStr)
|
||||||
|
{
|
||||||
|
GetHolder()->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString::CSharedString(CSharedString&& io_rOther) : m_pStr(io_rOther.m_pStr)
|
||||||
|
{
|
||||||
|
io_rOther.m_pStr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString::~CSharedString()
|
||||||
|
{
|
||||||
|
GetHolder()->Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* CSharedString::get() const
|
||||||
|
{
|
||||||
|
return m_pStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* CSharedString::c_str() const
|
||||||
|
{
|
||||||
|
return get();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* CSharedString::data() const
|
||||||
|
{
|
||||||
|
return get();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::size() const
|
||||||
|
{
|
||||||
|
return GetHolder()->Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::length() const
|
||||||
|
{
|
||||||
|
return size();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::empty() const
|
||||||
|
{
|
||||||
|
return size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* CSharedString::begin() const
|
||||||
|
{
|
||||||
|
return get();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const char* CSharedString::end() const
|
||||||
|
{
|
||||||
|
return &m_pStr[GetHolder()->Length];
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString CSharedString::substr(size_t pos, size_t len) const
|
||||||
|
{
|
||||||
|
if (len == 0)
|
||||||
|
return CSharedString();
|
||||||
|
|
||||||
|
if (len > (GetHolder()->Length - pos))
|
||||||
|
len = GetHolder()->Length - pos;
|
||||||
|
|
||||||
|
if (pos == 0 && len == GetHolder()->Length)
|
||||||
|
return *this;
|
||||||
|
|
||||||
|
return SStringHolder::Make(&m_pStr[pos], len);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find(char c, size_t pos) const
|
||||||
|
{
|
||||||
|
for (size_t i = pos; i < GetHolder()->Length; i++)
|
||||||
|
{
|
||||||
|
if (m_pStr[i] == c)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find(const char* s, size_t pos) const
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for (size_t i = pos; i < GetHolder()->Length - len + 1; i++)
|
||||||
|
{
|
||||||
|
if (strncmp(m_pStr + i, s, len) == 0)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::rfind(char c, size_t pos) const
|
||||||
|
{
|
||||||
|
if (pos >= GetHolder()->Length)
|
||||||
|
pos = GetHolder()->Length - 1;
|
||||||
|
|
||||||
|
for (size_t i = pos; i != static_cast<size_t>(-1); i--)
|
||||||
|
{
|
||||||
|
if (m_pStr[i] == c)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_first_of(const char* s, size_t pos) const
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for (size_t i = pos; i < GetHolder()->Length; i++)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < len; j++)
|
||||||
|
{
|
||||||
|
if (m_pStr[i] == s[j])
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_last_of(const char* s, size_t pos) const
|
||||||
|
{
|
||||||
|
if (pos >= GetHolder()->Length)
|
||||||
|
pos = GetHolder()->Length - 1;
|
||||||
|
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for (size_t i = pos; i != static_cast<size_t>(-1); i--)
|
||||||
|
{
|
||||||
|
for (size_t j = 0; j < len; j++)
|
||||||
|
{
|
||||||
|
if (m_pStr[i] == s[j])
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_first_not_of(const char* s, size_t pos) const
|
||||||
|
{
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for (size_t i = pos; i < GetHolder()->Length; i++)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (size_t j = 0; j < len; j++)
|
||||||
|
{
|
||||||
|
if (m_pStr[i] == s[j])
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_last_not_of(const char* s, size_t pos) const
|
||||||
|
{
|
||||||
|
if (pos >= GetHolder()->Length)
|
||||||
|
pos = GetHolder()->Length - 1;
|
||||||
|
|
||||||
|
size_t len = strlen(s);
|
||||||
|
for (size_t i = pos; i != static_cast<size_t>(-1); i--)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
for (size_t j = 0; j < len; j++)
|
||||||
|
{
|
||||||
|
if (m_pStr[i] == s[j])
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find(const CSharedString& str, size_t pos) const
|
||||||
|
{
|
||||||
|
return find(str.c_str(), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::rfind(const CSharedString& str, size_t pos) const
|
||||||
|
{
|
||||||
|
return rfind(str.c_str(), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_first_of(const CSharedString& str, size_t pos) const
|
||||||
|
{
|
||||||
|
return find_first_of(str.c_str(), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_last_of(const CSharedString& str, size_t pos) const
|
||||||
|
{
|
||||||
|
return find_last_of(str.c_str(), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_first_not_of(const CSharedString& str, size_t pos) const
|
||||||
|
{
|
||||||
|
return find_first_not_of(str.c_str(), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline size_t CSharedString::find_last_not_of(const CSharedString& str, size_t pos) const
|
||||||
|
{
|
||||||
|
return find_last_not_of(str.c_str(), pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::assign(const CSharedString& in_rOther)
|
||||||
|
{
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = in_rOther.m_pStr;
|
||||||
|
GetHolder()->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::assign(const char* in_pStr)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
if (in_pStr && (length = strlen(in_pStr)) != 0)
|
||||||
|
{
|
||||||
|
if (!GetHolder()->TryInplaceAssign(in_pStr, length))
|
||||||
|
{
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = SStringHolder::Make(in_pStr, length)->aStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::assign(CSharedString&& io_rOther)
|
||||||
|
{
|
||||||
|
m_pStr = io_rOther.m_pStr;
|
||||||
|
io_rOther.m_pStr = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::append(const CSharedString& in_rOther)
|
||||||
|
{
|
||||||
|
if (!GetHolder()->TryInplaceAppend(in_rOther.GetHolder()->aStr, in_rOther.GetHolder()->Length))
|
||||||
|
{
|
||||||
|
SStringHolder* pHolder = SStringHolder::Concat(
|
||||||
|
GetHolder()->aStr, GetHolder()->Length,
|
||||||
|
in_rOther.GetHolder()->aStr, in_rOther.GetHolder()->Length);
|
||||||
|
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = pHolder->aStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::append(const char* in_pStr)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
if (in_pStr && (length = strlen(in_pStr)) != 0)
|
||||||
|
{
|
||||||
|
if (!GetHolder()->TryInplaceAppend(in_pStr, length))
|
||||||
|
{
|
||||||
|
SStringHolder* pHolder = SStringHolder::Concat(
|
||||||
|
GetHolder()->aStr, GetHolder()->Length, in_pStr, length);
|
||||||
|
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = pHolder->aStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::prepend(const CSharedString& in_rOther)
|
||||||
|
{
|
||||||
|
if (!GetHolder()->TryInplacePrepend(in_rOther.GetHolder()->aStr, in_rOther.GetHolder()->Length))
|
||||||
|
{
|
||||||
|
SStringHolder* pHolder = SStringHolder::Concat(
|
||||||
|
in_rOther.GetHolder()->aStr, in_rOther.GetHolder()->Length,
|
||||||
|
GetHolder()->aStr, GetHolder()->Length);
|
||||||
|
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = pHolder->aStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CSharedString::prepend(const char* in_pStr)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
if (in_pStr && (length = strlen(in_pStr)) != 0)
|
||||||
|
{
|
||||||
|
if (!GetHolder()->TryInplacePrepend(in_pStr, length))
|
||||||
|
{
|
||||||
|
SStringHolder* pHolder = SStringHolder::Concat(
|
||||||
|
in_pStr, length, GetHolder()->aStr, GetHolder()->Length);
|
||||||
|
|
||||||
|
GetHolder()->Release();
|
||||||
|
m_pStr = pHolder->aStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int CSharedString::compare(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
// TODO: DO NOT PASS BY REFERENCE.
|
||||||
|
GuestToHostFunction<int>(0x82DFB028, this, &in_rOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString& CSharedString::operator=(const CSharedString& in_rOther)
|
||||||
|
{
|
||||||
|
assign(in_rOther);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString& CSharedString::operator=(const char* in_pStr)
|
||||||
|
{
|
||||||
|
assign(in_pStr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString& CSharedString::operator=(CSharedString&& io_rOther)
|
||||||
|
{
|
||||||
|
assign(std::move(io_rOther));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString& CSharedString::operator+=(const CSharedString& in_rOther)
|
||||||
|
{
|
||||||
|
append(in_rOther);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString& CSharedString::operator+=(const char* in_pStr)
|
||||||
|
{
|
||||||
|
append(in_pStr);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString operator+(const CSharedString& in_rLeft, const CSharedString& in_rRight)
|
||||||
|
{
|
||||||
|
return SStringHolder::Concat(
|
||||||
|
in_rLeft.GetHolder()->aStr, in_rLeft.GetHolder()->Length,
|
||||||
|
in_rRight.GetHolder()->aStr, in_rRight.GetHolder()->Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString operator+(const CSharedString& in_rLeft, const char* in_pRight)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
if (in_pRight && (length = strlen(in_pRight)) != 0)
|
||||||
|
{
|
||||||
|
return SStringHolder::Concat(
|
||||||
|
in_rLeft.GetHolder()->aStr, in_rLeft.GetHolder()->Length, in_pRight, length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return in_rLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline CSharedString operator+(const char* in_pLeft, const CSharedString& in_pRight)
|
||||||
|
{
|
||||||
|
size_t length;
|
||||||
|
|
||||||
|
if (in_pLeft && (length = strlen(in_pLeft)) != 0)
|
||||||
|
{
|
||||||
|
return SStringHolder::Concat(
|
||||||
|
in_pLeft, length, in_pRight.GetHolder()->aStr, in_pRight.GetHolder()->Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return in_pRight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator>(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
return compare(in_rOther) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator>=(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
return compare(in_rOther) >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator<(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
return compare(in_rOther) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator<=(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
return compare(in_rOther) <= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator==(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
return compare(in_rOther) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator!=(const CSharedString& in_rOther) const
|
||||||
|
{
|
||||||
|
return !(*this == in_rOther);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator==(const char* in_pOther) const
|
||||||
|
{
|
||||||
|
return strcmp(c_str(), in_pOther) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CSharedString::operator!=(const char* in_pOther) const
|
||||||
|
{
|
||||||
|
return !(*this == in_pOther);
|
||||||
|
}
|
||||||
|
}
|
||||||
23
UnleashedRecomp/api/Hedgehog/Base/hhObject.h
Normal file
23
UnleashedRecomp/api/Hedgehog/Base/hhObject.h
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Hedgehog::Base
|
||||||
|
{
|
||||||
|
class CObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CObject();
|
||||||
|
CObject(const swa_null_ctor&);
|
||||||
|
|
||||||
|
void* operator new(const size_t in_Size);
|
||||||
|
void* operator new(const size_t in_Size, const size_t in_Align);
|
||||||
|
|
||||||
|
void operator delete(void* in_pMem);
|
||||||
|
|
||||||
|
void* operator new(const size_t in_Size, void* in_pObj);
|
||||||
|
void* operator new(const size_t in_Size, const size_t in_Align, void* in_pObj);
|
||||||
|
|
||||||
|
void operator delete(void* in_pMem, void* in_pObj);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Hedgehog/Base/hhObject.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Database
|
||||||
|
{
|
||||||
|
enum EDatabaseDataFlags : uint8_t
|
||||||
|
{
|
||||||
|
eDatabaseDataFlags_IsMadeOne = 0x1,
|
||||||
|
eDatabaseDataFlags_IsMadeAll = 0x2,
|
||||||
|
eDatabaseDataFlags_CreatedFromArchive = 0x4,
|
||||||
|
eDatabaseDataFlags_IsMadeMakingOne = 0x8
|
||||||
|
};
|
||||||
|
|
||||||
|
class CDatabaseData : public Base::CObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
uint8_t m_Flags; // see EDatabaseDataFlags
|
||||||
|
SWA_INSERT_PADDING(0x04); // TODO: Base::CSharedString m_TypeAndName;
|
||||||
|
|
||||||
|
virtual ~CDatabaseData() = default;
|
||||||
|
virtual bool CheckMadeAll();
|
||||||
|
|
||||||
|
bool IsMadeOne() const;
|
||||||
|
void SetMadeOne();
|
||||||
|
|
||||||
|
bool IsMadeAllInternal();
|
||||||
|
bool IsMadeAll();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "Hedgehog/Database/System/hhDatabaseData.inl"
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
namespace Hedgehog::Database
|
||||||
|
{
|
||||||
|
inline bool CDatabaseData::CheckMadeAll()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CDatabaseData::IsMadeOne() const
|
||||||
|
{
|
||||||
|
return (m_Flags & eDatabaseDataFlags_IsMadeOne) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void CDatabaseData::SetMadeOne()
|
||||||
|
{
|
||||||
|
m_Flags |= eDatabaseDataFlags_IsMadeOne;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CDatabaseData::IsMadeAllInternal()
|
||||||
|
{
|
||||||
|
if ((m_Flags & eDatabaseDataFlags_IsMadeOne) == 0 || !CheckMadeAll())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
m_Flags |= eDatabaseDataFlags_IsMadeAll;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool CDatabaseData::IsMadeAll()
|
||||||
|
{
|
||||||
|
return (m_Flags & eDatabaseDataFlags_IsMadeAll) != 0 || IsMadeAllInternal();
|
||||||
|
}
|
||||||
|
}
|
||||||
13
UnleashedRecomp/api/Hedgehog/Math/Vector2.h
Normal file
13
UnleashedRecomp/api/Hedgehog/Math/Vector2.h
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Hedgehog::Math
|
||||||
|
{
|
||||||
|
class CVector2
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
be<float> X;
|
||||||
|
be<float> Y;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Base/hhObject.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Mirage
|
||||||
|
{
|
||||||
|
class CRenderable : public Base::CObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool m_Enabled;
|
||||||
|
be<float> m_SortDepth;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhMessageProcess.h"
|
||||||
|
#include "Hedgehog/Universe/Thread/hhParallelJob.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Universe
|
||||||
|
{
|
||||||
|
class CMessageActor : public IMessageProcess, public IParallelJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x7C);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Base/hhObject.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Universe
|
||||||
|
{
|
||||||
|
class IMessageProcess : public Base::CObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IMessageProcess() {}
|
||||||
|
IMessageProcess(const swa_null_ctor& nil) : CObject(nil) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
13
UnleashedRecomp/api/Hedgehog/Universe/Engine/hhUpdateInfo.h
Normal file
13
UnleashedRecomp/api/Hedgehog/Universe/Engine/hhUpdateInfo.h
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
|
||||||
|
namespace Hedgehog::Universe
|
||||||
|
{
|
||||||
|
struct SUpdateInfo
|
||||||
|
{
|
||||||
|
be<float> DeltaTime;
|
||||||
|
be<uint32_t> Frame;
|
||||||
|
Base::CSharedString Category;
|
||||||
|
};
|
||||||
|
}
|
||||||
22
UnleashedRecomp/api/Hedgehog/Universe/Engine/hhUpdateUnit.h
Normal file
22
UnleashedRecomp/api/Hedgehog/Universe/Engine/hhUpdateUnit.h
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Universe/Thread/hhParallelJob.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Universe
|
||||||
|
{
|
||||||
|
class CUpdateUnit : public Base::CObject, public IParallelJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x24);
|
||||||
|
|
||||||
|
CUpdateUnit(const swa_null_ctor& nil) : CObject(nil), IParallelJob(nil) {}
|
||||||
|
CUpdateUnit();
|
||||||
|
virtual ~CUpdateUnit();
|
||||||
|
|
||||||
|
virtual void ExecuteParallelJob(const SUpdateInfo& in_rUpdateInfo) override;
|
||||||
|
|
||||||
|
virtual void UpdateParallel(const SUpdateInfo& in_rUpdateInfo) {}
|
||||||
|
virtual void UpdateSerial(const SUpdateInfo& in_rUpdateInfo) {}
|
||||||
|
};
|
||||||
|
}
|
||||||
18
UnleashedRecomp/api/Hedgehog/Universe/Thread/hhParallelJob.h
Normal file
18
UnleashedRecomp/api/Hedgehog/Universe/Thread/hhParallelJob.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhUpdateInfo.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Universe
|
||||||
|
{
|
||||||
|
class IParallelJob
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IParallelJob() {}
|
||||||
|
IParallelJob(const swa_null_ctor&) {}
|
||||||
|
|
||||||
|
virtual ~IParallelJob() = default;
|
||||||
|
|
||||||
|
virtual void ExecuteParallelJob(const SUpdateInfo& in_rUpdateInfo) = 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,41 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Hedgehog/Base/hhObject.h"
|
||||||
|
#include "Hedgehog/Base/System/hhAllocator.h"
|
||||||
|
#include "Hedgehog/Base/Thread/hhHolder.h"
|
||||||
|
#include "Hedgehog/Base/Thread/hhHolderBase.h"
|
||||||
|
#include "Hedgehog/Base/Thread/hhSynchronizedObject.h"
|
||||||
|
#include "Hedgehog/Base/Thread/hhSynchronizedPtr.h"
|
||||||
|
#include "Hedgehog/Base/Type/hhSharedString.h"
|
||||||
|
#include "Hedgehog/Database/System/hhDatabaseData.h"
|
||||||
|
#include "Hedgehog/Math/Vector2.h"
|
||||||
|
#include "Hedgehog/MirageCore/Renderable/hhRenderable.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhMessageActor.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhMessageProcess.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhUpdateInfo.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhUpdateUnit.h"
|
||||||
|
#include "Hedgehog/Universe/Thread/hhParallelJob.h"
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmBase.h"
|
||||||
|
#include "CSD/Manager/csdmNode.h"
|
||||||
|
#include "CSD/Manager/csdmNodeObserver.h"
|
||||||
|
#include "CSD/Manager/csdmObserverBase.h"
|
||||||
|
#include "CSD/Manager/csdmProject.h"
|
||||||
|
#include "CSD/Manager/csdmRCObject.h"
|
||||||
|
#include "CSD/Manager/csdmRCObjectImp.h"
|
||||||
|
#include "CSD/Manager/csdmRCPtr.h"
|
||||||
|
#include "CSD/Manager/csdmRCPtrAbs.h"
|
||||||
|
#include "CSD/Manager/csdmResourceBase.h"
|
||||||
|
#include "CSD/Manager/csdmScene.h"
|
||||||
|
#include "CSD/Manager/csdmSceneObserver.h"
|
||||||
|
#include "CSD/Manager/csdmSubjectBase.h"
|
||||||
|
#include "CSD/Platform/csdTexList.h"
|
||||||
|
|
||||||
#include "SWA/Camera/Camera.h"
|
#include "SWA/Camera/Camera.h"
|
||||||
|
#include "SWA/CSD/CsdDatabaseWrapper.h"
|
||||||
|
#include "SWA/CSD/CsdProject.h"
|
||||||
|
#include "SWA/CSD/CsdTexListMirage.h"
|
||||||
|
#include "SWA/CSD/GameObjectCSD.h"
|
||||||
#include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h"
|
#include "SWA/Player/Character/EvilSonic/Hud/EvilHudGuide.h"
|
||||||
#include "SWA/Player/Character/EvilSonic/EvilSonic.h"
|
#include "SWA/Player/Character/EvilSonic/EvilSonic.h"
|
||||||
#include "SWA/Player/Character/EvilSonic/EvilSonicContext.h"
|
#include "SWA/Player/Character/EvilSonic/EvilSonicContext.h"
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cpu/guest_code.h>
|
#include <cpu/guest_code.h>
|
||||||
|
#include <kernel/function.h>
|
||||||
|
|
||||||
#define SWA__CONCAT2(x, y) x##y
|
#define SWA__CONCAT2(x, y) x##y
|
||||||
#define SWA_CONCAT2(x, y) _CONCAT(x, y)
|
#define SWA_CONCAT2(x, y) _CONCAT(x, y)
|
||||||
|
|
||||||
#define SWA_INSERT_PADDING(length) \
|
#define SWA_INSERT_PADDING(length) \
|
||||||
uint8_t SWA_CONCAT2(pad, __LINE__)[length]
|
uint8_t SWA_CONCAT2(pad, __LINE__)[length]
|
||||||
|
|
||||||
|
struct swa_null_ctor {};
|
||||||
|
|
|
||||||
25
UnleashedRecomp/api/SWA/CSD/CsdDatabaseWrapper.h
Normal file
25
UnleashedRecomp/api/SWA/CSD/CsdDatabaseWrapper.h
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "boost/smart_ptr/shared_ptr.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Database
|
||||||
|
{
|
||||||
|
class CDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CCsdProject;
|
||||||
|
|
||||||
|
class CCsdDatabaseWrapper
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Hedgehog::Database::CDatabase* m_pDatabase;
|
||||||
|
|
||||||
|
CCsdDatabaseWrapper(Hedgehog::Database::CDatabase* in_pDatabase) : m_pDatabase(in_pDatabase) {}
|
||||||
|
|
||||||
|
boost::shared_ptr<CCsdProject> GetCsdProject(const Hedgehog::Base::CSharedString& in_rName);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "SWA/CSD/CsdDatabaseWrapper.inl"
|
||||||
9
UnleashedRecomp/api/SWA/CSD/CsdDatabaseWrapper.inl
Normal file
9
UnleashedRecomp/api/SWA/CSD/CsdDatabaseWrapper.inl
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
inline boost::shared_ptr<CCsdProject> CCsdDatabaseWrapper::GetCsdProject(const Hedgehog::Base::CSharedString& in_rName)
|
||||||
|
{
|
||||||
|
boost::shared_ptr<CCsdProject> spCsdProject;
|
||||||
|
GuestToHostFunction<void>(0x825E2B40, &in_rName, this, &spCsdProject, 0);
|
||||||
|
return spCsdProject;
|
||||||
|
}
|
||||||
|
}
|
||||||
18
UnleashedRecomp/api/SWA/CSD/CsdProject.h
Normal file
18
UnleashedRecomp/api/SWA/CSD/CsdProject.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Manager/csdmRCPtr.h"
|
||||||
|
#include "Hedgehog/Database/System/hhDatabaseData.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class CProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CCsdProject : public Hedgehog::Database::CDatabaseData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Chao::CSD::RCPtr<Chao::CSD::CProject> m_rcProject;
|
||||||
|
};
|
||||||
|
}
|
||||||
18
UnleashedRecomp/api/SWA/CSD/CsdTexListMirage.h
Normal file
18
UnleashedRecomp/api/SWA/CSD/CsdTexListMirage.h
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CSD/Platform/csdTexList.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Mirage
|
||||||
|
{
|
||||||
|
class CTexsetData;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CCsdTexListMirage : public Chao::CSD::CTexList
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
boost::shared_ptr<Hedgehog::Mirage::CTexsetData> m_spTexsetData;
|
||||||
|
SWA_INSERT_PADDING(0x04);
|
||||||
|
};
|
||||||
|
}
|
||||||
20
UnleashedRecomp/api/SWA/CSD/GameObjectCSD.h
Normal file
20
UnleashedRecomp/api/SWA/CSD/GameObjectCSD.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "CSD/Manager/csdmRCPtr.h"
|
||||||
|
#include "SWA/System/GameObject.h"
|
||||||
|
|
||||||
|
namespace Chao::CSD
|
||||||
|
{
|
||||||
|
class CProject;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CGameObjectCSD : public CGameObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Chao::CSD::RCPtr<Chao::CSD::CProject> m_rcProject;
|
||||||
|
SWA_INSERT_PADDING(0x38);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/MirageCore/Renderable/hhRenderable.h"
|
||||||
|
|
||||||
|
namespace SWA::Sequence::Utility
|
||||||
|
{
|
||||||
|
class CPlayMovieWrapper
|
||||||
|
{
|
||||||
|
class CRender : public Hedgehog::Mirage::CRenderable
|
||||||
|
{
|
||||||
|
SWA_INSERT_PADDING(0x08);
|
||||||
|
be<uint32_t> m_ScreenWidth;
|
||||||
|
be<uint32_t> m_ScreenHeight;
|
||||||
|
be<float> m_MovieWidth;
|
||||||
|
be<float> m_MovieHeight;
|
||||||
|
};
|
||||||
|
|
||||||
|
SWA_INSERT_PADDING(0x18);
|
||||||
|
CRender* m_pRender;
|
||||||
|
};
|
||||||
|
}
|
||||||
20
UnleashedRecomp/api/SWA/Sound/Sound.h
Normal file
20
UnleashedRecomp/api/SWA/Sound/Sound.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CSound // : public CGameObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
struct SSoundInfo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x04);
|
||||||
|
xpointer<void> m_pAdminSimplePlayer;
|
||||||
|
SWA_INSERT_PADDING(0x04);
|
||||||
|
xpointer<void> m_pAdminBgm;
|
||||||
|
};
|
||||||
|
|
||||||
|
SWA_INSERT_PADDING(0xC4);
|
||||||
|
xpointer<SSoundInfo> m_pSoundInfo;
|
||||||
|
};
|
||||||
|
}
|
||||||
8
UnleashedRecomp/api/SWA/Sound/SoundBGMActEvil.h
Normal file
8
UnleashedRecomp/api/SWA/Sound/SoundBGMActEvil.h
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CSoundBGMActEvil
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -1,21 +1,32 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA/Sound/Sound.h"
|
||||||
|
|
||||||
|
namespace Hedgehog::Database
|
||||||
|
{
|
||||||
|
class CDatabase;
|
||||||
|
}
|
||||||
|
|
||||||
namespace SWA
|
namespace SWA
|
||||||
{
|
{
|
||||||
class CGameDocument // : public Hedgehog::Base::CSynchronizedObject
|
class CGameDocument : public Hedgehog::Base::CSynchronizedObject
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class CMember
|
class CMember
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SWA_INSERT_PADDING(0x20C);
|
SWA_INSERT_PADDING(0x1C);
|
||||||
|
boost::shared_ptr<Hedgehog::Database::CDatabase> m_spDatabase;
|
||||||
|
SWA_INSERT_PADDING(0x90);
|
||||||
|
xpointer<CSound> m_pSound;
|
||||||
|
SWA_INSERT_PADDING(0x158);
|
||||||
be<uint32_t> m_Score;
|
be<uint32_t> m_Score;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>
|
// TODO: Hedgehog::Base::TSynchronizedPtr<CGameDocument>
|
||||||
static CGameDocument* GetInstance();
|
static CGameDocument* GetInstance();
|
||||||
|
|
||||||
SWA_INSERT_PADDING(0x08);
|
SWA_INSERT_PADDING(0x04);
|
||||||
xpointer<CMember> m_pMember;
|
xpointer<CMember> m_pMember;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
26
UnleashedRecomp/api/SWA/System/GameObject.h
Normal file
26
UnleashedRecomp/api/SWA/System/GameObject.h
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Base/Thread/hhSynchronizedPtr.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhMessageActor.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhUpdateUnit.h"
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CGameDocument;
|
||||||
|
class CWorld;
|
||||||
|
|
||||||
|
class CGameObject : public Hedgehog::Universe::CUpdateUnit, public Hedgehog::Universe::CMessageActor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class CMember
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Hedgehog::Base::TSynchronizedPtr<CGameDocument> m_pGameDocument;
|
||||||
|
Hedgehog::Base::TSynchronizedPtr<CWorld> m_pWorld;
|
||||||
|
SWA_INSERT_PADDING(0x78);
|
||||||
|
};
|
||||||
|
|
||||||
|
xpointer<CMember> m_pMember;
|
||||||
|
};
|
||||||
|
}
|
||||||
20
UnleashedRecomp/api/SWA/System/World.h
Normal file
20
UnleashedRecomp/api/SWA/System/World.h
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "SWA.inl"
|
||||||
|
#include "Hedgehog/Base/Thread/hhSynchronizedObject.h"
|
||||||
|
#include "Hedgehog/Universe/Engine/hhMessageActor.h"
|
||||||
|
|
||||||
|
namespace SWA
|
||||||
|
{
|
||||||
|
class CWorld : public Hedgehog::Base::CSynchronizedObject, public Hedgehog::Universe::CMessageActor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
class CMember
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SWA_INSERT_PADDING(0x80);
|
||||||
|
};
|
||||||
|
|
||||||
|
xpointer<CMember> m_pMember;
|
||||||
|
};
|
||||||
|
}
|
||||||
12
UnleashedRecomp/api/boost/smart_ptr/make_shared_object.h
Normal file
12
UnleashedRecomp/api/boost/smart_ptr/make_shared_object.h
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "boost/smart_ptr/shared_ptr.h"
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
template<typename T, typename... TArgs>
|
||||||
|
shared_ptr<T> make_shared(TArgs&&... args)
|
||||||
|
{
|
||||||
|
return shared_ptr<T>(new T(std::forward<TArgs>(args)...));
|
||||||
|
}
|
||||||
|
}
|
||||||
81
UnleashedRecomp/api/boost/smart_ptr/shared_ptr.h
Normal file
81
UnleashedRecomp/api/boost/smart_ptr/shared_ptr.h
Normal file
|
|
@ -0,0 +1,81 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstddef>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
template<typename T>
|
||||||
|
class shared_ptr
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
xpointer<T> m_pObject;
|
||||||
|
xpointer<size_t> m_pRefCount;
|
||||||
|
|
||||||
|
void release()
|
||||||
|
{
|
||||||
|
if (m_pRefCount && --(*m_pRefCount) == 0)
|
||||||
|
{
|
||||||
|
delete m_pObject;
|
||||||
|
delete m_pRefCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
|
shared_ptr() : m_pObject(nullptr), m_pRefCount(nullptr) {}
|
||||||
|
|
||||||
|
explicit shared_ptr(T* p) : m_pObject(p), m_pRefCount(new size_t(1)) {}
|
||||||
|
|
||||||
|
shared_ptr(const shared_ptr& other) : m_pObject(other.m_pObject), m_pRefCount(other.m_pRefCount)
|
||||||
|
{
|
||||||
|
if (m_pRefCount)
|
||||||
|
++(*m_pRefCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_ptr(shared_ptr&& other) noexcept : m_pObject(std::exchange(other.m_pObject, nullptr)),
|
||||||
|
m_pRefCount(std::exchange(other.m_pRefCount, nullptr)) {}
|
||||||
|
|
||||||
|
~shared_ptr()
|
||||||
|
{
|
||||||
|
release();
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_ptr& operator=(const shared_ptr& other)
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
release();
|
||||||
|
|
||||||
|
m_pObject = other.m_pObject;
|
||||||
|
m_pRefCount = other.m_pRefCount;
|
||||||
|
|
||||||
|
if (m_pRefCount)
|
||||||
|
++(*m_pRefCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
shared_ptr& operator=(shared_ptr&& other) noexcept
|
||||||
|
{
|
||||||
|
if (this != &other)
|
||||||
|
{
|
||||||
|
release();
|
||||||
|
|
||||||
|
m_pObject = std::exchange(other.m_pObject, nullptr);
|
||||||
|
m_pRefCount = std::exchange(other.m_pRefCount, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
T* get() const { return m_pObject; }
|
||||||
|
|
||||||
|
T& operator*() const { assert(m_pObject); return *m_pObject; }
|
||||||
|
T* operator->() const { assert(m_pObject); return m_pObject; }
|
||||||
|
|
||||||
|
explicit operator bool() const { return m_pObject != nullptr; }
|
||||||
|
|
||||||
|
size_t use_count() const { return m_pRefCount ? *m_pRefCount : 0; }
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue