2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-08 23:07:42 +00:00

Proper TUniqueId implementation, minor bug fixes in CSortedListManager

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