Changeset View
Changeset View
Standalone View
Standalone View
source/simulation2/system/Entity.h
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2022 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 0 A.D. is free software: you can redistribute it and/or modify | ||||
* it under the terms of the GNU General Public License as published by | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | public: | ||||
CEntityHandle() : m_Id(INVALID_ENTITY), m_ComponentCache(NULL) { } | CEntityHandle() : m_Id(INVALID_ENTITY), m_ComponentCache(NULL) { } | ||||
CEntityHandle(entity_id_t id, SEntityComponentCache* componentCache) | CEntityHandle(entity_id_t id, SEntityComponentCache* componentCache) | ||||
: m_Id(id), m_ComponentCache(componentCache) | : m_Id(id), m_ComponentCache(componentCache) | ||||
{ | { | ||||
} | } | ||||
entity_id_t GetId() const { return m_Id; } | entity_id_t GetId() const { return m_Id; } | ||||
SEntityComponentCache* GetComponentCache() const { return m_ComponentCache; } | SEntityComponentCache* GetComponentCache() const { return m_ComponentCache; } | ||||
void SetInvalid() { m_Id = INVALID_ENTITY; } | |||||
jprahman: Per earlier comment, we can elide an invalid marking if the pool allocator keeps free/allocated… | |||||
private: | private: | ||||
entity_id_t m_Id; | entity_id_t m_Id; | ||||
SEntityComponentCache* m_ComponentCache; | SEntityComponentCache* m_ComponentCache; | ||||
}; | }; | ||||
#endif // INCLUDED_ENTITY | #endif // INCLUDED_ENTITY |
Wildfire Games · Phabricator
Per earlier comment, we can elide an invalid marking if the pool allocator keeps free/allocated lists for iteration over free vs. allocated entries. Though that's a more involved change of course, but helps in the sparse case.