updated CDClient pet data handling

This commit is contained in:
jadebenn
2023-12-15 18:38:52 -06:00
parent 9add2c944e
commit 1c7ce6eac3
6 changed files with 116 additions and 55 deletions

View File

@@ -0,0 +1,34 @@
#include "CDPetComponentTable.h"
void CDPetComponentTable::LoadValuesFromDatabase() {
auto tableData = CDClientDatabase::ExecuteQuery("SELECT * FROM PetComponent");
while (!tableData.eof()) {
CDPetComponent entry;
entry.id = tableData.getIntField("id", -1);
UNUSED_COLUMN(entry.minTameUpdateTime = tableData.getFloatField("minTameUpdateTime", 60.0f);)
UNUSED_COLUMN(entry.maxTameUpdateTime = tableData.getFloatField("maxTameUpdateTime", 300.0f);)
UNUSED_COLUMN(entry.percentTameChance = tableData.getFloatField("percentTameChance", 101.0f);)
UNUSED_COLUMN(entry.tameability = tableData.getFloatField("tamability", 100.0f);) // Mispelled as "tamability" in CDClient
UNUSED_COLUMN(entry.elementType = tableData.getIntField("elementType", 1);)
entry.walkSpeed = tableData.getFloatField("walkSpeed", 2.5f);
entry.runSpeed = tableData.getFloatField("runSpeed", 5.0f);
entry.sprintSpeed = tableData.getFloatField("sprintSpeed", 10.0f);
UNUSED_COLUMN(entry.idleTimeMin = tableData.getFloatField("idleTimeMin", 60.0f);)
UNUSED_COLUMN(entry.idleTimeMax = tableData.getFloatField("idleTimeMax", 300.0f);)
UNUSED_COLUMN(entry.petForm = tableData.getIntField("petForm", 0);)
entry.imaginationDrainRate = tableData.getFloatField("imaginationDrainRate", 60.0f);
UNUSED_COLUMN(entry.AudioMetaEventSet = tableData.getStringField("AudioMetaEventSet", "");)
UNUSED_COLUMN(entry.buffIDs = tableData.getStringField("buffIDs", "");)
m_entries.insert(std::make_pair(entry.id, entry));
tableData.nextRow();
}
tableData.finalize();
}
CDPetComponent* CDPetComponentTable::GetByID(unsigned int componentID) {
auto itr = m_entries.find(componentID);
return itr != m_entries.end() ? &itr->second : nullptr;
}

View File

@@ -0,0 +1,32 @@
#pragma once
#include "CDTable.h"
#include <string>
struct CDPetComponent {
unsigned int id;
UNUSED_COLUMN(float minTameUpdateTime;)
UNUSED_COLUMN(float maxTameUpdateTime;)
UNUSED_COLUMN(float percentTameChance;)
UNUSED_COLUMN(float tameability;) // Mispelled as "tamability" in CDClient
UNUSED_COLUMN(unsigned int elementType;)
float walkSpeed;
float runSpeed;
float sprintSpeed;
UNUSED_COLUMN(float idleTimeMin;)
UNUSED_COLUMN(float idleTimeMax;)
UNUSED_COLUMN(unsigned int petForm;)
float imaginationDrainRate;
UNUSED_COLUMN(std::string AudioMetaEventSet;)
UNUSED_COLUMN(std::string buffIDs;)
};
class CDPetComponentTable : public CDTable<CDPetComponentTable> {
public:
void LoadValuesFromDatabase();
static const std::string GetTableName() { return "PetComponent"; };
CDPetComponent* GetByID(unsigned int componentID);
private:
std::map<unsigned int, CDPetComponent> m_entries;
};

View File

@@ -23,6 +23,7 @@ set(DDATABASE_CDCLIENTDATABASE_CDCLIENTTABLES_SOURCES "CDActivitiesTable.cpp"
"CDMovementAIComponentTable.cpp"
"CDObjectSkillsTable.cpp"
"CDObjectsTable.cpp"
"CDPetComponentTable.cpp"
"CDPackageComponentTable.cpp"
"CDPhysicsComponentTable.cpp"
"CDPropertyEntranceComponentTable.cpp"