2021-12-05 17:54:36 +00:00
|
|
|
#include "CDBehaviorParameterTable.h"
|
|
|
|
#include "GeneralUtils.h"
|
|
|
|
|
2022-07-09 20:59:36 +00:00
|
|
|
#include "Game.h"
|
|
|
|
#include "dLogger.h"
|
|
|
|
#include "dServer.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
#include "CDProvider.h"
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
CD_PROVIDER(BehaviorParameterProvider, size_t, float);
|
2022-07-09 20:59:36 +00:00
|
|
|
|
|
|
|
//! Constructor
|
|
|
|
CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
2022-08-11 14:36:03 +00:00
|
|
|
NEW_CD_PROVIDER(BehaviorParameterProvider, "BehaviorParameter", [](CppSQLite3Query& query) {
|
|
|
|
size_t hash = 0;
|
2022-07-09 22:40:13 +00:00
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
int32_t behaviorID = query.getIntField(0, -1);
|
|
|
|
std::string parameterID = query.getStringField(1, "");
|
|
|
|
|
|
|
|
GeneralUtils::hash_combine(hash, behaviorID);
|
|
|
|
GeneralUtils::hash_combine(hash, parameterID);
|
2022-07-09 22:40:13 +00:00
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
float value = query.getFloatField(2, -1.0f);
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
return std::make_pair(hash, value);
|
|
|
|
}, [](int32_t size) {
|
|
|
|
return 40 * 1000 * 1000;
|
|
|
|
}, false);
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//! Destructor
|
|
|
|
CDBehaviorParameterTable::~CDBehaviorParameterTable(void) { }
|
|
|
|
|
|
|
|
//! Returns the table's name
|
|
|
|
std::string CDBehaviorParameterTable::GetName(void) const {
|
2022-01-15 18:37:43 +00:00
|
|
|
return "BehaviorParameter";
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|
|
|
|
|
2022-07-09 20:59:36 +00:00
|
|
|
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue)
|
2021-12-05 17:54:36 +00:00
|
|
|
{
|
|
|
|
size_t hash = 0;
|
|
|
|
GeneralUtils::hash_combine(hash, behaviorID);
|
|
|
|
GeneralUtils::hash_combine(hash, name);
|
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
return BehaviorParameterProvider->GetEntry(hash, defaultValue);
|
2022-07-09 06:07:52 +00:00
|
|
|
}
|
2021-12-05 17:54:36 +00:00
|
|
|
|
2022-08-11 14:36:03 +00:00
|
|
|
void CDBehaviorParameterTable::LoadHost()
|
2022-07-09 20:59:36 +00:00
|
|
|
{
|
2022-08-11 14:36:03 +00:00
|
|
|
BehaviorParameterProvider->LoadHost();
|
2021-12-05 17:54:36 +00:00
|
|
|
}
|