mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-10-22 15:28:07 +00:00
refactor: Move CDClient Database away from constructor queries (#1164)
* Move away from constructor queries Fix up other large tables to have proper backup lookups Revert "idk im just dumb ig" This reverts commit 5d5be5df53b8959b42b291613d7db749a65a3585. idk im just dumb ig * Fix slow components registry lookup * add define for cdclient cache all * Update CDBehaviorParameterTable.cpp
This commit is contained in:
@@ -1,46 +1,35 @@
|
||||
#include "CDPhysicsComponentTable.h"
|
||||
|
||||
CDPhysicsComponentTable::CDPhysicsComponentTable(void) {
|
||||
void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
||||
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
||||
while (!tableData.eof()) {
|
||||
CDPhysicsComponent* entry = new CDPhysicsComponent();
|
||||
entry->id = tableData.getIntField("id", -1);
|
||||
entry->bStatic = tableData.getIntField("static", -1) != 0;
|
||||
entry->physicsAsset = tableData.getStringField("physics_asset", "");
|
||||
CDPhysicsComponent entry;
|
||||
entry.id = tableData.getIntField("id", -1);
|
||||
entry.bStatic = tableData.getIntField("static", -1) != 0;
|
||||
entry.physicsAsset = tableData.getStringField("physics_asset", "");
|
||||
UNUSED(entry->jump = tableData.getIntField("jump", -1) != 0);
|
||||
UNUSED(entry->doublejump = tableData.getIntField("doublejump", -1) != 0);
|
||||
entry->speed = tableData.getFloatField("speed", -1);
|
||||
entry.speed = tableData.getFloatField("speed", -1);
|
||||
UNUSED(entry->rotSpeed = tableData.getFloatField("rotSpeed", -1));
|
||||
entry->playerHeight = tableData.getFloatField("playerHeight");
|
||||
entry->playerRadius = tableData.getFloatField("playerRadius");
|
||||
entry->pcShapeType = tableData.getIntField("pcShapeType");
|
||||
entry->collisionGroup = tableData.getIntField("collisionGroup");
|
||||
entry.playerHeight = tableData.getFloatField("playerHeight");
|
||||
entry.playerRadius = tableData.getFloatField("playerRadius");
|
||||
entry.pcShapeType = tableData.getIntField("pcShapeType");
|
||||
entry.collisionGroup = tableData.getIntField("collisionGroup");
|
||||
UNUSED(entry->airSpeed = tableData.getFloatField("airSpeed"));
|
||||
UNUSED(entry->boundaryAsset = tableData.getStringField("boundaryAsset"));
|
||||
UNUSED(entry->jumpAirSpeed = tableData.getFloatField("jumpAirSpeed"));
|
||||
UNUSED(entry->friction = tableData.getFloatField("friction"));
|
||||
UNUSED(entry->gravityVolumeAsset = tableData.getStringField("gravityVolumeAsset"));
|
||||
|
||||
m_entries.insert(std::make_pair(entry->id, entry));
|
||||
m_entries.insert(std::make_pair(entry.id, entry));
|
||||
tableData.nextRow();
|
||||
}
|
||||
|
||||
tableData.finalize();
|
||||
}
|
||||
|
||||
CDPhysicsComponentTable::~CDPhysicsComponentTable() {
|
||||
for (auto e : m_entries) {
|
||||
if (e.second) delete e.second;
|
||||
}
|
||||
|
||||
m_entries.clear();
|
||||
}
|
||||
|
||||
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(unsigned int componentID) {
|
||||
for (auto e : m_entries) {
|
||||
if (e.first == componentID) return e.second;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
auto itr = m_entries.find(componentID);
|
||||
return itr != m_entries.end() ? &itr->second : nullptr;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user