Formatting

This commit is contained in:
Sezz 2025-02-12 17:36:12 +11:00
parent 62ce2f043d
commit d37ac17a39
2 changed files with 15 additions and 14 deletions

View file

@ -78,38 +78,38 @@ ObjectInfo& ObjectHandler::GetFirstAvailableObject()
void StaticHandler::Initialize() void StaticHandler::Initialize()
{ {
_lookupTable.resize(0); _lut.resize(0);
_lookupTable.reserve(_defaultLUTSize); _lut.reserve(LUT_SIZE);
_statics.resize(0); _statics.resize(0);
} }
int StaticHandler::GetIndex(int staticID) int StaticHandler::GetIndex(int staticID)
{ {
if (staticID < 0 || staticID >= _lookupTable.size()) if (staticID < 0 || staticID >= _lut.size())
{ {
TENLog("Attempt to get nonexistent static mesh ID slot index (" + std::to_string(staticID) + ")", LogLevel::Warning); TENLog("Attempted to get index of missing static object " + std::to_string(staticID) + ".", LogLevel::Warning);
return _lookupTable.front(); return _lut.front();
} }
return _lookupTable[staticID]; return _lut[staticID];
} }
StaticInfo& StaticHandler::operator [](int staticID) StaticInfo& StaticHandler::operator [](int staticID)
{ {
if (staticID < 0) if (staticID < 0)
{ {
TENLog("Attempt to access illegal static mesh ID slot info", LogLevel::Warning); TENLog("Attempted to access missing static object " + std::to_string(staticID) + ".", LogLevel::Warning);
return _statics.front(); return _statics.front();
} }
if (staticID >= _lookupTable.size()) if (staticID >= _lut.size())
_lookupTable.resize(staticID + 1, NO_VALUE); _lut.resize(staticID + 1, NO_VALUE);
if (_lookupTable[staticID] != NO_VALUE) if (_lut[staticID] != NO_VALUE)
return _statics[_lookupTable[staticID]]; return _statics[_lut[staticID]];
_statics.emplace_back(); _statics.emplace_back();
_lookupTable[staticID] = (int)_statics.size() - 1; _lut[staticID] = (int)_statics.size() - 1;
return _statics.back(); return _statics.back();
} }

View file

@ -135,10 +135,10 @@ struct StaticInfo
class StaticHandler class StaticHandler
{ {
private: private:
static const int _defaultLUTSize = 256; static constexpr auto LUT_SIZE = 256;
std::vector<StaticInfo> _statics = {}; std::vector<StaticInfo> _statics = {};
std::vector<int> _lookupTable = {}; std::vector<int> _lut = {};
public: public:
void Initialize(); void Initialize();
@ -147,6 +147,7 @@ public:
StaticInfo& operator [](int staticID); StaticInfo& operator [](int staticID);
// Iterators // Iterators
auto begin() { return _statics.begin(); } // Non-const begin auto begin() { return _statics.begin(); } // Non-const begin
auto end() { return _statics.end(); } // Non-const end auto end() { return _statics.end(); } // Non-const end
auto begin() const { return _statics.cbegin(); } // Const begin auto begin() const { return _statics.cbegin(); } // Const begin