Proper TUniqueId implementation, minor bug fixes in CSortedListManager

This commit is contained in:
Phillip Stephens 2017-08-10 06:40:07 -07:00
parent 9d85e7dbfe
commit 8409cf7868
12 changed files with 123 additions and 101 deletions

View File

@ -12,9 +12,9 @@ void CObjectList::AddObject(CEntity& entity)
if (IsQualified(entity)) if (IsQualified(entity))
{ {
if (x2008_firstId != -1) if (x2008_firstId != -1)
x0_list[x2008_firstId].prev = entity.GetUniqueId() & 0x3ff; x0_list[x2008_firstId].prev = entity.GetUniqueId().Value();
TUniqueId prevFirst = x2008_firstId; s16 prevFirst = x2008_firstId;
x2008_firstId = entity.GetUniqueId() & 0x3ff; x2008_firstId = entity.GetUniqueId().Value();
SObjectListEntry& newEnt = x0_list[x2008_firstId]; SObjectListEntry& newEnt = x0_list[x2008_firstId];
newEnt.entity = &entity; newEnt.entity = &entity;
newEnt.next = prevFirst; newEnt.next = prevFirst;
@ -25,11 +25,10 @@ void CObjectList::AddObject(CEntity& entity)
void CObjectList::RemoveObject(TUniqueId uid) void CObjectList::RemoveObject(TUniqueId uid)
{ {
uid = uid & 0x3ff; SObjectListEntry& ent = x0_list[uid.Value()];
SObjectListEntry& ent = x0_list[uid];
if (!ent.entity || ent.entity->GetUniqueId() != uid) if (!ent.entity || ent.entity->GetUniqueId() != uid)
return; return;
if (uid == x2008_firstId) if (uid.Value() == x2008_firstId)
{ {
x2008_firstId = ent.next; x2008_firstId = ent.next;
if (ent.next != -1) if (ent.next != -1)
@ -67,7 +66,7 @@ const CEntity* CObjectList::GetObjectById(TUniqueId uid) const
{ {
if (uid == kInvalidUniqueId) if (uid == kInvalidUniqueId)
return nullptr; return nullptr;
const SObjectListEntry& ent = x0_list[uid & 0x3ff]; const SObjectListEntry& ent = x0_list[uid.Value()];
if (ent.entity->x30_26_scriptingBlocked) if (ent.entity->x30_26_scriptingBlocked)
return nullptr; return nullptr;
return ent.entity; return ent.entity;
@ -77,7 +76,7 @@ CEntity* CObjectList::GetObjectById(TUniqueId uid)
{ {
if (uid == kInvalidUniqueId) if (uid == kInvalidUniqueId)
return nullptr; return nullptr;
SObjectListEntry& ent = x0_list[uid & 0x3ff]; SObjectListEntry& ent = x0_list[uid.Value()];
if (ent.entity->x30_26_scriptingBlocked) if (ent.entity->x30_26_scriptingBlocked)
return nullptr; return nullptr;
return ent.entity; return ent.entity;
@ -87,7 +86,7 @@ const CEntity* CObjectList::GetValidObjectById(TUniqueId uid) const
{ {
if (uid == kInvalidUniqueId) if (uid == kInvalidUniqueId)
return nullptr; return nullptr;
const SObjectListEntry& ent = x0_list[uid & 0x3ff]; const SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity) if (!ent.entity)
return nullptr; return nullptr;
if (ent.entity->GetUniqueId() != uid) if (ent.entity->GetUniqueId() != uid)
@ -99,7 +98,7 @@ CEntity* CObjectList::GetValidObjectById(TUniqueId uid)
{ {
if (uid == kInvalidUniqueId) if (uid == kInvalidUniqueId)
return nullptr; return nullptr;
SObjectListEntry& ent = x0_list[uid & 0x3ff]; SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity) if (!ent.entity)
return nullptr; return nullptr;
if (ent.entity->GetUniqueId() != uid) if (ent.entity->GetUniqueId() != uid)

View File

@ -27,41 +27,41 @@ class CObjectList
struct SObjectListEntry struct SObjectListEntry
{ {
CEntity* entity = nullptr; CEntity* entity = nullptr;
TUniqueId next = kInvalidUniqueId; s16 next = -1;
TUniqueId prev = kInvalidUniqueId; s16 prev = -1;
}; };
SObjectListEntry x0_list[1024]; // was an rstl::prereserved_vector SObjectListEntry x0_list[1024]; // was an rstl::prereserved_vector
EGameObjectList x2004_listEnum; EGameObjectList x2004_listEnum;
TUniqueId x2008_firstId = kInvalidUniqueId; s16 x2008_firstId = -1;
u16 x200a_count = 0; u16 x200a_count = 0;
public: public:
class iterator class iterator
{ {
friend class CObjectList; friend class CObjectList;
CObjectList& m_list; CObjectList& m_list;
TUniqueId m_id; s16 m_id;
iterator(CObjectList& list, TUniqueId id) : m_list(list), m_id(id) {} iterator(CObjectList& list, s16 id) : m_list(list), m_id(id) {}
public: public:
iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; } iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; }
bool operator!=(const iterator& other) const { return m_id != other.m_id; } bool operator!=(const iterator& other) const { return m_id != other.m_id; }
CEntity* operator*() const { return m_list.GetObjectById(m_id); } CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
}; };
iterator begin() { return iterator(*this, x2008_firstId); } iterator begin() { return iterator(*this, x2008_firstId); }
iterator end() { return iterator(*this, kInvalidUniqueId); } iterator end() { return iterator(*this, -1); }
class const_iterator class const_iterator
{ {
friend class CObjectList; friend class CObjectList;
const CObjectList& m_list; const CObjectList& m_list;
TUniqueId m_id; s16 m_id;
const_iterator(const CObjectList& list, TUniqueId id) : m_list(list), m_id(id) {} const_iterator(const CObjectList& list, s16 id) : m_list(list), m_id(id) {}
public: public:
const_iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; } const_iterator& operator++() { m_id = m_list.GetNextObjectIndex(m_id); return *this; }
bool operator!=(const iterator& other) const { return m_id != other.m_id; } bool operator!=(const iterator& other) const { return m_id != other.m_id; }
const CEntity* operator*() const { return m_list.GetObjectById(m_id); } const CEntity* operator*() const { return m_list.GetObjectByIndex(m_id); }
}; };
const_iterator cbegin() const { return const_iterator(*this, x2008_firstId); } const_iterator cbegin() const { return const_iterator(*this, x2008_firstId); }
const_iterator cend() const { return const_iterator(*this, kInvalidUniqueId); } const_iterator cend() const { return const_iterator(*this, -1); }
CObjectList(EGameObjectList listEnum); CObjectList(EGameObjectList listEnum);
@ -70,12 +70,13 @@ public:
const CEntity* operator[](size_t i) const; const CEntity* operator[](size_t i) const;
CEntity* operator[](size_t i); CEntity* operator[](size_t i);
const CEntity* GetObjectById(TUniqueId uid) const; const CEntity* GetObjectById(TUniqueId uid) const;
const CEntity* GetObjectByIndex(s32 index) const { return x0_list[index].entity; } const CEntity* GetObjectByIndex(s16 index) const { return x0_list[index].entity; }
CEntity* GetObjectByIndex(s16 index) { return x0_list[index].entity; }
CEntity* GetObjectById(TUniqueId uid); CEntity* GetObjectById(TUniqueId uid);
const CEntity* GetValidObjectById(TUniqueId uid) const; const CEntity* GetValidObjectById(TUniqueId uid) const;
CEntity* GetValidObjectById(TUniqueId uid); CEntity* GetValidObjectById(TUniqueId uid);
TUniqueId GetFirstObjectIndex() const { return x2008_firstId; } s16 GetFirstObjectIndex() const { return x2008_firstId; }
TUniqueId GetNextObjectIndex(TUniqueId prev) const { return x0_list[prev & 0x3ff].next; } s16 GetNextObjectIndex(s16 prev) const { return x0_list[prev].next; }
virtual bool IsQualified(const CEntity&); virtual bool IsQualified(const CEntity&);
u16 size() const { return x200a_count; } u16 size() const { return x200a_count; }
}; };

View File

@ -16,7 +16,7 @@ void CSortedListManager::Reset()
xb000_sortedLists[i].Reset(); xb000_sortedLists[i].Reset();
} }
void CSortedListManager::AddToLinkedList(TUniqueId nodeId, TUniqueId& headId, TUniqueId& tailId) const void CSortedListManager::AddToLinkedList(s16 nodeId, s16& headId, s16& tailId) const
{ {
if (headId == -1) if (headId == -1)
{ {
@ -100,7 +100,7 @@ void CSortedListManager::InsertInList(ESortedList list, SNode& node)
} }
/* Do insert */ /* Do insert */
sl.x0_ids[insIdx] = node.x0_actor->GetUniqueId(); sl.x0_ids[insIdx] = node.x0_actor->GetUniqueId().Value();
node.x1c_selfIdxs[int(list)] = insIdx; node.x1c_selfIdxs[int(list)] = insIdx;
++sl.x800_size; ++sl.x800_size;
} }
@ -149,7 +149,7 @@ s16 CSortedListManager::FindInListLower(ESortedList list, float val) const
return idx; return idx;
} }
TUniqueId CSortedListManager::ConstructIntersectionArray(const zeus::CAABox& aabb) s16 CSortedListManager::ConstructIntersectionArray(const zeus::CAABox& aabb)
{ {
int minXa = FindInListLower(ESortedList::MinX, aabb.min.x); int minXa = FindInListLower(ESortedList::MinX, aabb.min.x);
int maxXa = FindInListUpper(ESortedList::MinX, aabb.max.x); int maxXa = FindInListUpper(ESortedList::MinX, aabb.max.x);
@ -186,12 +186,12 @@ TUniqueId CSortedListManager::ConstructIntersectionArray(const zeus::CAABox& aab
} }
} }
TUniqueId CSortedListManager::CalculateIntersections(ESortedList la, ESortedList lb, s16 a, s16 b, s16 c, s16 d, s16 CSortedListManager::CalculateIntersections(ESortedList la, ESortedList lb, s16 a, s16 b, s16 c, s16 d,
ESortedList slA, ESortedList slB, ESortedList slC, ESortedList slD, ESortedList slA, ESortedList slB, ESortedList slC, ESortedList slD,
const zeus::CAABox& aabb) const zeus::CAABox& aabb)
{ {
TUniqueId headId = kInvalidUniqueId; s16 headId = -1;
TUniqueId tailId = kInvalidUniqueId; s16 tailId = -1;
for (int i=a ; i<b ; ++i) for (int i=a ; i<b ; ++i)
AddToLinkedList(xb000_sortedLists[int(la)].x0_ids[i], headId, tailId); AddToLinkedList(xb000_sortedLists[int(la)].x0_ids[i], headId, tailId);
for (int i=c ; i<d ; ++i) for (int i=c ; i<d ; ++i)
@ -201,7 +201,7 @@ TUniqueId CSortedListManager::CalculateIntersections(ESortedList la, ESortedList
{ {
for (int i=0 ; i<a ; ++i) for (int i=0 ; i<a ; ++i)
{ {
TUniqueId id = xb000_sortedLists[int(la)].x0_ids[i]; s16 id = xb000_sortedLists[int(la)].x0_ids[i];
if (x0_nodes[id].x1c_selfIdxs[lb] > aabb[int(lb)]) if (x0_nodes[id].x1c_selfIdxs[lb] > aabb[int(lb)])
AddToLinkedList(id, headId, tailId); AddToLinkedList(id, headId, tailId);
} }
@ -210,13 +210,13 @@ TUniqueId CSortedListManager::CalculateIntersections(ESortedList la, ESortedList
{ {
for (int i=d ; i<xb000_sortedLists[int(lb)].x800_size ; ++i) for (int i=d ; i<xb000_sortedLists[int(lb)].x800_size ; ++i)
{ {
TUniqueId id = xb000_sortedLists[int(lb)].x0_ids[i]; s16 id = xb000_sortedLists[int(lb)].x0_ids[i];
if (x0_nodes[id].x1c_selfIdxs[la] < aabb[int(la)]) if (x0_nodes[id].x1c_selfIdxs[la] < aabb[int(la)])
AddToLinkedList(id, headId, tailId); AddToLinkedList(id, headId, tailId);
} }
} }
for (TUniqueId* id = &headId ; *id != kInvalidUniqueId ;) for (s16* id = &headId ; *id != -1 ;)
{ {
SNode& node = x0_nodes[*id]; SNode& node = x0_nodes[*id];
if (node.x4_box[int(slA)] > aabb[int(slB)] || if (node.x4_box[int(slA)] > aabb[int(slB)] ||
@ -226,7 +226,7 @@ TUniqueId CSortedListManager::CalculateIntersections(ESortedList la, ESortedList
{ {
/* Not intersecting; remove from chain */ /* Not intersecting; remove from chain */
*id = node.x28_next; *id = node.x28_next;
node.x28_next = kInvalidUniqueId; node.x28_next = -1;
continue; continue;
} }
id = &node.x28_next; id = &node.x28_next;
@ -252,8 +252,8 @@ void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& o
const zeus::CAABox& aabb) const const zeus::CAABox& aabb) const
{ {
const CMaterialFilter& filter = actor.GetMaterialFilter(); const CMaterialFilter& filter = actor.GetMaterialFilter();
TUniqueId id = const_cast<CSortedListManager&>(*this).ConstructIntersectionArray(aabb); s16 id = const_cast<CSortedListManager&>(*this).ConstructIntersectionArray(aabb);
while (id != kInvalidUniqueId) while (id != -1)
{ {
const SNode& node = x0_nodes[id]; const SNode& node = x0_nodes[id];
if (&actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList()) && if (&actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList()) &&
@ -261,29 +261,29 @@ void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& o
out.push_back(node.x0_actor->GetUniqueId()); out.push_back(node.x0_actor->GetUniqueId());
id = node.x28_next; id = node.x28_next;
const_cast<SNode&>(node).x28_next = kInvalidUniqueId; const_cast<SNode&>(node).x28_next = -1;
} }
} }
void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const zeus::CAABox& aabb, void CSortedListManager::BuildNearList(rstl::reserved_vector<TUniqueId, 1024>& out, const zeus::CAABox& aabb,
const CMaterialFilter& filter, const CActor* actor) const const CMaterialFilter& filter, const CActor* actor) const
{ {
TUniqueId id = const_cast<CSortedListManager&>(*this).ConstructIntersectionArray(aabb); s16 id = const_cast<CSortedListManager&>(*this).ConstructIntersectionArray(aabb);
while (id != kInvalidUniqueId) while (id != -1)
{ {
const SNode& node = x0_nodes[id]; const SNode& node = x0_nodes[id];
if (actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList())) if (actor != node.x0_actor && filter.Passes(node.x0_actor->GetMaterialList()))
out.push_back(node.x0_actor->GetUniqueId()); out.push_back(node.x0_actor->GetUniqueId());
id = node.x28_next; id = node.x28_next;
const_cast<SNode&>(node).x28_next = kInvalidUniqueId; const_cast<SNode&>(node).x28_next = -1;
} }
} }
void CSortedListManager::Remove(const CActor* act) void CSortedListManager::Remove(const CActor* act)
{ {
SNode& node = x0_nodes[act->GetUniqueId() & 0x3ff]; SNode& node = x0_nodes[act->GetUniqueId().Value()];
if (node.x2a_populated == false) if (!node.x2a_populated)
return; return;
RemoveFromList(ESortedList::MinX, node.x1c_selfIdxs[0]); RemoveFromList(ESortedList::MinX, node.x1c_selfIdxs[0]);
@ -297,7 +297,7 @@ void CSortedListManager::Remove(const CActor* act)
void CSortedListManager::Move(const CActor* act, const zeus::CAABox& aabb) void CSortedListManager::Move(const CActor* act, const zeus::CAABox& aabb)
{ {
SNode& node = x0_nodes[act->GetUniqueId() & 0x3ff]; SNode& node = x0_nodes[act->GetUniqueId().Value()];
node.x4_box = aabb; node.x4_box = aabb;
MoveInList(ESortedList::MinX, node.x1c_selfIdxs[0]); MoveInList(ESortedList::MinX, node.x1c_selfIdxs[0]);
@ -310,7 +310,7 @@ void CSortedListManager::Move(const CActor* act, const zeus::CAABox& aabb)
void CSortedListManager::Insert(const CActor* act, const zeus::CAABox& aabb) void CSortedListManager::Insert(const CActor* act, const zeus::CAABox& aabb)
{ {
SNode& node = x0_nodes[act->GetUniqueId() & 0x3ff]; SNode& node = x0_nodes[act->GetUniqueId().Value()];
if (node.x2a_populated) if (node.x2a_populated)
{ {
Move(act, aabb); Move(act, aabb);
@ -331,7 +331,7 @@ bool CSortedListManager::ActorInLists(const CActor* act) const
{ {
if (!act) if (!act)
return false; return false;
const SNode& node = x0_nodes[act->GetUniqueId() & 0x3ff]; const SNode& node = x0_nodes[act->GetUniqueId().Value()];
return node.x2a_populated; return node.x2a_populated;
} }

View File

@ -19,9 +19,9 @@ enum ESortedList
struct SSortedList struct SSortedList
{ {
TUniqueId x0_ids[1024]; s16 x0_ids[1024];
u32 x800_size; u32 x800_size;
void Reset() {std::fill(std::begin(x0_ids), std::end(x0_ids), kInvalidUniqueId);} void Reset() {std::fill(std::begin(x0_ids), std::end(x0_ids), -1);}
SSortedList() {Reset();} SSortedList() {Reset();}
}; };
@ -33,7 +33,7 @@ class CSortedListManager
const CActor* x0_actor = nullptr; const CActor* x0_actor = nullptr;
zeus::CAABox x4_box = zeus::CAABox::skNullBox; zeus::CAABox x4_box = zeus::CAABox::skNullBox;
s16 x1c_selfIdxs[6] = {-1, -1, -1, -1, -1, -1}; s16 x1c_selfIdxs[6] = {-1, -1, -1, -1, -1, -1};
TUniqueId x28_next = kInvalidUniqueId; s16 x28_next = -1;
bool x2a_populated = false; bool x2a_populated = false;
SNode() = default; SNode() = default;
SNode(const CActor* act, const zeus::CAABox& aabb) SNode(const CActor* act, const zeus::CAABox& aabb)
@ -42,14 +42,14 @@ class CSortedListManager
SNode x0_nodes[1024]; SNode x0_nodes[1024];
SSortedList xb000_sortedLists[6]; SSortedList xb000_sortedLists[6];
void Reset(); void Reset();
void AddToLinkedList(TUniqueId a, TUniqueId& b, TUniqueId& c) const; void AddToLinkedList(s16 a, s16& b, s16& c) const;
void RemoveFromList(ESortedList, s16); void RemoveFromList(ESortedList, s16);
void MoveInList(ESortedList, s16); void MoveInList(ESortedList, s16);
void InsertInList(ESortedList, SNode& node); void InsertInList(ESortedList, SNode& node);
s16 FindInListUpper(ESortedList, float) const; s16 FindInListUpper(ESortedList, float) const;
s16 FindInListLower(ESortedList, float) const; s16 FindInListLower(ESortedList, float) const;
TUniqueId ConstructIntersectionArray(const zeus::CAABox&); s16 ConstructIntersectionArray(const zeus::CAABox&);
TUniqueId CalculateIntersections(ESortedList, ESortedList, s16, s16, s16, s16, s16 CalculateIntersections(ESortedList, ESortedList, s16, s16, s16, s16,
ESortedList, ESortedList, ESortedList, ESortedList, const zeus::CAABox&); ESortedList, ESortedList, ESortedList, ESortedList, const zeus::CAABox&);
public: public:
CSortedListManager(); CSortedListManager();

View File

@ -924,7 +924,7 @@ void CStateManager::PreRender()
xf7c_projectedShadow = nullptr; xf7c_projectedShadow = nullptr;
x850_world->PreRender(); x850_world->PreRender();
BuildDynamicLightListForWorld(); BuildDynamicLightListForWorld();
CGameCamera* cam = static_cast<CGameCamera*>(x870_cameraManager->GetCurrentCamera(*this)); CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this);
zeus::CFrustum frustum; zeus::CFrustum frustum;
zeus::CProjection proj; zeus::CProjection proj;
proj.setPersp(zeus::SProjPersp{zeus::degToRad(cam->GetFov()), proj.setPersp(zeus::SProjPersp{zeus::degToRad(cam->GetFov()),
@ -2059,7 +2059,7 @@ void CStateManager::CrossTouchActors()
if (!ent2->GetActive() || touchAABB2) if (!ent2->GetActive() || touchAABB2)
continue; continue;
if (visits[ent2->GetUniqueId() & 0x3ff]) if (visits[ent2->GetUniqueId().Value()])
continue; continue;
if (touchAABB->intersects(*touchAABB2)) if (touchAABB->intersects(*touchAABB2))
@ -2068,7 +2068,7 @@ void CStateManager::CrossTouchActors()
ent2->Touch(actor, *this); ent2->Touch(actor, *this);
} }
visits[ent2->GetUniqueId() & 0x3ff] = true; visits[ent2->GetUniqueId().Value()] = true;
} }
} }
} }
@ -2501,10 +2501,10 @@ TUniqueId CStateManager::AllocateUniqueId()
while (GetAllObjectList().GetObjectByIndex(ourIndex) != nullptr); while (GetAllObjectList().GetObjectByIndex(ourIndex) != nullptr);
x8_idArr[ourIndex] = (x8_idArr[ourIndex] + 1) & 0x3f; x8_idArr[ourIndex] = (x8_idArr[ourIndex] + 1) & 0x3f;
if (((ourIndex | ((x8_idArr[ourIndex]) << 10)) & 0xFFFF) == kInvalidUniqueId) if (TUniqueId(ourIndex, x8_idArr[ourIndex]) == kInvalidUniqueId)
x8_idArr[0] = 0; x8_idArr[ourIndex] = 0;
return ((ourIndex | ((x8_idArr[ourIndex]) << 10)) & 0xFFFF); return TUniqueId(ourIndex, x8_idArr[ourIndex]);
} }
void CStateManager::DeferStateTransition(EStateManagerTransition t) void CStateManager::DeferStateTransition(EStateManagerTransition t)

View File

@ -90,7 +90,7 @@ public:
private: private:
s16 x0_nextFreeIndex = 0; s16 x0_nextFreeIndex = 0;
TUniqueId x8_idArr[1024] = {}; u16 x8_idArr[1024] = {};
/* /*
std::unique_ptr<CObjectList> x80c_allObjs; std::unique_ptr<CObjectList> x80c_allObjs;

View File

@ -52,11 +52,23 @@ struct TEditorId
bool operator==(const TEditorId& other) const { return (id & 0x3ffffff) == (other.id & 0x3ffffff); } bool operator==(const TEditorId& other) const { return (id & 0x3ffffff) == (other.id & 0x3ffffff); }
}; };
using TUniqueId = s16; struct TUniqueId
{
TUniqueId() = default;
TUniqueId(u16 value, u16 version) : id(value | (version << 10)) {}
u16 id = u16(-1);
s16 Version() const { return s16((id >> 10) & 0x3f);}
s16 Value() const { return s16(id & 0x3ff);}
bool operator<(const TUniqueId& other) const { return (id < other.id); }
bool operator!=(const TUniqueId& other) const { return (id != other.id); }
bool operator==(const TUniqueId& other) const { return (id == other.id); }
};
using TAreaId = s32; using TAreaId = s32;
#define kInvalidEditorId TEditorId() #define kInvalidEditorId TEditorId()
#define kInvalidUniqueId TUniqueId(-1) #define kInvalidUniqueId TUniqueId()
#define kInvalidAreaId TAreaId(-1) #define kInvalidAreaId TAreaId(-1)
} }

View File

@ -779,7 +779,7 @@ void CGameArea::Validate(CStateManager& mgr)
TUniqueId id = mgr.GetIdForScript(entId); TUniqueId id = mgr.GetIdForScript(entId);
if (id != kInvalidUniqueId) if (id != kInvalidUniqueId)
{ {
CPostConstructed::MapEntry& ent = x12c_postConstructed->xa8_pvsEntityMap[id & 0x3ff]; CPostConstructed::MapEntry& ent = x12c_postConstructed->xa8_pvsEntityMap[id.Value()];
ent.x0_id = i + (pvs->GetNumFeatures() - pvs->GetNumActors()); ent.x0_id = i + (pvs->GetNumFeatures() - pvs->GetNumActors());
ent.x4_uid = id; ent.x4_uid = id;
} }
@ -1097,12 +1097,12 @@ CGameArea::MREAHeader CGameArea::VerifyHeader() const
TUniqueId CGameArea::LookupPVSUniqueID(TUniqueId id) const TUniqueId CGameArea::LookupPVSUniqueID(TUniqueId id) const
{ {
return x12c_postConstructed->xa8_pvsEntityMap[id & 0x3ff].x4_uid; return x12c_postConstructed->xa8_pvsEntityMap[id.Value()].x4_uid;
} }
s16 CGameArea::LookupPVSID(TUniqueId id) const s16 CGameArea::LookupPVSID(TUniqueId id) const
{ {
return x12c_postConstructed->xa8_pvsEntityMap[id & 0x3ff].x0_id; return x12c_postConstructed->xa8_pvsEntityMap[id.Value()].x0_id;
} }
void CGameArea::SetAreaAttributes(const CScriptAreaAttributes* areaAttributes) void CGameArea::SetAreaAttributes(const CScriptAreaAttributes* areaAttributes)

View File

@ -4,8 +4,14 @@
namespace urde namespace urde
{ {
CScriptActorRotate::CScriptActorRotate(TUniqueId uid, const std::string& name, const CEntityInfo& info, CScriptActorRotate::CScriptActorRotate(TUniqueId uid, const std::string& name, const CEntityInfo& info,
const zeus::CVector3f& rotation, float scale, bool, bool, bool active) const zeus::CVector3f& rotation, float f1, bool b1, bool b2, bool active)
: CEntity(uid, info, active, name) : CEntity(uid, info, active, name)
, x34_rotation(rotation)
, x40_(f1)
, x58_24_(false)
, x58_25_(false)
, x58_26_(b1)
, x58_27_(b2)
{ {
} }
@ -14,4 +20,9 @@ void CScriptActorRotate::Accept(IVisitor& visitor)
visitor.Visit(this); visitor.Visit(this);
} }
void CScriptActorRotate::AcceptScriptMsg(EScriptObjectMessage msg, TUniqueId uid, CStateManager& mgr)
{
CEntity::AcceptScriptMsg(msg, uid, mgr);
}
} }

View File

@ -13,7 +13,8 @@ class CScriptActorRotate : public CEntity
float x44_; float x44_;
std::map<TUniqueId, zeus::CTransform> x48_actors; std::map<TUniqueId, zeus::CTransform> x48_actors;
union { union
{
struct struct
{ {
bool x58_24_ : 1; bool x58_24_ : 1;
@ -29,6 +30,7 @@ public:
bool); bool);
void Accept(IVisitor& visitor); void Accept(IVisitor& visitor);
void AcceptScriptMsg(EScriptObjectMessage, TUniqueId, CStateManager&);
}; };
} }

View File

@ -13,39 +13,39 @@ class CScriptSpecialFunction : public CActor
public: public:
enum class ESpecialFunction enum class ESpecialFunction
{ {
What, What = 0,
PlayerFollowLocator, PlayerFollowLocator = 1,
SpinnerController, SpinnerController = 2,
ObjectFollowLocator, ObjectFollowLocator = 3,
Four, Four = 4,
InventoryActivator, InventoryActivator = 5,
MapStation, MapStation = 6,
SaveStation, SaveStation = 7,
IntroBossRingController, IntroBossRingController = 8,
ViewFrustumTester, ViewFrustumTester = 9,
ShotSpinnerController, ShotSpinnerController = 10,
EscapeSequence, EscapeSequence = 11,
BossEnergyBar, BossEnergyBar = 12,
EndGame, EndGame = 13,
HUDFadeIn, HUDFadeIn = 14,
CinematicSkip, CinematicSkip = 15,
ScriptLayerController, ScriptLayerController = 16,
RainSimulator, RainSimulator = 17,
AreaDamage, AreaDamage = 18,
ObjectFollowObject, ObjectFollowObject = 19,
RedundantHintSystem, RedundantHintSystem = 20,
DropBomb, DropBomb = 21,
TwentyTwo, TwentyTwo = 22,
MissileStation, MissileStation = 23,
Billboard, Billboard = 24,
PlayerInAreaRelay, PlayerInAreaRelay = 25,
HUDTarget, HUDTarget = 26,
FogFader, FogFader = 27,
EnterLogbook, EnterLogbook = 28,
PowerBombStation, PowerBombStation = 29,
Ending, Ending = 30,
FusionRelay, FusionRelay = 31,
WeaponSwitch, WeaponSwitch = 32,
FogVolume = 47, FogVolume = 47,
RadialDamage = 48, RadialDamage = 48,
EnvFxDensityController = 49, EnvFxDensityController = 49,

View File

@ -1,11 +1,8 @@
#include "CWorld.hpp" #include "CWorld.hpp"
#include "CGameArea.hpp"
#include "GameGlobalObjects.hpp"
#include "CSimplePool.hpp" #include "CSimplePool.hpp"
#include "CStateManager.hpp" #include "CStateManager.hpp"
#include "CInGameTweakManagerBase.hpp" #include "CInGameTweakManagerBase.hpp"
#include "Audio/CAudioGroupSet.hpp" #include "Audio/CAudioGroupSet.hpp"
#include "Editor/ProjectResourceFactoryBase.hpp"
#include "CGameState.hpp" #include "CGameState.hpp"
#include "Graphics/CBooRenderer.hpp" #include "Graphics/CBooRenderer.hpp"