mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-23 05:53:34 +00:00
d2aeebcd46
* Move CDClientManager to be a namespace Tested that worlds still load data as expected. Had no use being a singleton anyways. * Move cdclient data storage to tu local containers Allows some data from these containers to be saved on object by reference instead of always needing to copy. iteration 2 - move all unnamed namespace containers to a singular spot - use macro for template specialization and variable declaration - use templates to allow for as little copy paste of types and functions as possible * remember to use typename! compiler believes T::StorageType is accessing a member, not a type. * Update CDClientManager.cpp * move to cpp?
38 lines
1.6 KiB
C++
38 lines
1.6 KiB
C++
#include "CDPhysicsComponentTable.h"
|
|
|
|
void CDPhysicsComponentTable::LoadValuesFromDatabase() {
|
|
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PhysicsComponent");
|
|
auto& entries = GetEntriesMutable();
|
|
while (!tableData.eof()) {
|
|
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);
|
|
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");
|
|
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"));
|
|
|
|
entries.insert(std::make_pair(entry.id, entry));
|
|
tableData.nextRow();
|
|
}
|
|
|
|
tableData.finalize();
|
|
}
|
|
|
|
CDPhysicsComponent* CDPhysicsComponentTable::GetByID(uint32_t componentID) {
|
|
auto& entries = GetEntriesMutable();
|
|
auto itr = entries.find(componentID);
|
|
return itr != entries.end() ? &itr->second : nullptr;
|
|
}
|
|
|