2
0
mirror of https://github.com/AxioDL/metaforce.git synced 2025-12-09 04:27:42 +00:00

New code style refactor

This commit is contained in:
Jack Andersen
2018-12-07 19:30:43 -10:00
parent 41ae32be31
commit 636c82a568
1451 changed files with 171430 additions and 203303 deletions

View File

@@ -1,111 +1,96 @@
#include "CObjectList.hpp"
namespace urde
{
namespace urde {
CObjectList::CObjectList(EGameObjectList listEnum)
: x2004_listEnum(listEnum)
{}
CObjectList::CObjectList(EGameObjectList listEnum) : x2004_listEnum(listEnum) {}
void CObjectList::AddObject(CEntity& entity)
{
if (IsQualified(entity))
{
if (x2008_firstId != -1)
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;
newEnt.prev = -1;
++x200a_count;
}
void CObjectList::AddObject(CEntity& entity) {
if (IsQualified(entity)) {
if (x2008_firstId != -1)
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;
newEnt.prev = -1;
++x200a_count;
}
}
void CObjectList::RemoveObject(TUniqueId uid)
{
SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity || ent.entity->GetUniqueId() != uid)
return;
if (uid.Value() == x2008_firstId)
{
x2008_firstId = ent.next;
if (ent.next != -1)
x0_list[ent.next].prev = -1;
}
else
{
x0_list[ent.prev].next = ent.next;
if (ent.next != -1)
x0_list[ent.next].prev = ent.prev;
}
ent.entity = nullptr;
ent.next = -1;
ent.prev = -1;
--x200a_count;
void CObjectList::RemoveObject(TUniqueId uid) {
SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity || ent.entity->GetUniqueId() != uid)
return;
if (uid.Value() == x2008_firstId) {
x2008_firstId = ent.next;
if (ent.next != -1)
x0_list[ent.next].prev = -1;
} else {
x0_list[ent.prev].next = ent.next;
if (ent.next != -1)
x0_list[ent.next].prev = ent.prev;
}
ent.entity = nullptr;
ent.next = -1;
ent.prev = -1;
--x200a_count;
}
const CEntity* CObjectList::operator[](size_t i) const
{
const SObjectListEntry& ent = x0_list[i];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
const CEntity* CObjectList::operator[](size_t i) const {
const SObjectListEntry& ent = x0_list[i];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
}
CEntity* CObjectList::operator[](size_t i)
{
SObjectListEntry& ent = x0_list[i];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
CEntity* CObjectList::operator[](size_t i) {
SObjectListEntry& ent = x0_list[i];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
}
const CEntity* CObjectList::GetObjectById(TUniqueId uid) const
{
if (uid == kInvalidUniqueId)
return nullptr;
const SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
const CEntity* CObjectList::GetObjectById(TUniqueId uid) const {
if (uid == kInvalidUniqueId)
return nullptr;
const SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
}
CEntity* CObjectList::GetObjectById(TUniqueId uid)
{
if (uid == kInvalidUniqueId)
return nullptr;
SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
CEntity* CObjectList::GetObjectById(TUniqueId uid) {
if (uid == kInvalidUniqueId)
return nullptr;
SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity || ent.entity->x30_26_scriptingBlocked)
return nullptr;
return ent.entity;
}
const CEntity* CObjectList::GetValidObjectById(TUniqueId uid) const
{
if (uid == kInvalidUniqueId)
return nullptr;
const SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity)
return nullptr;
if (ent.entity->GetUniqueId() != uid)
return nullptr;
return ent.entity;
const CEntity* CObjectList::GetValidObjectById(TUniqueId uid) const {
if (uid == kInvalidUniqueId)
return nullptr;
const SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity)
return nullptr;
if (ent.entity->GetUniqueId() != uid)
return nullptr;
return ent.entity;
}
CEntity* CObjectList::GetValidObjectById(TUniqueId uid)
{
if (uid == kInvalidUniqueId)
return nullptr;
SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity)
return nullptr;
if (ent.entity->GetUniqueId() != uid)
return nullptr;
return ent.entity;
CEntity* CObjectList::GetValidObjectById(TUniqueId uid) {
if (uid == kInvalidUniqueId)
return nullptr;
SObjectListEntry& ent = x0_list[uid.Value()];
if (!ent.entity)
return nullptr;
if (ent.entity->GetUniqueId() != uid)
return nullptr;
return ent.entity;
}
bool CObjectList::IsQualified(const CEntity&) {return true;}
bool CObjectList::IsQualified(const CEntity&) { return true; }
}
} // namespace urde