mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-23 22:17:31 +00:00
56f371216b
There is now an option to utilize shared memory for some CDClient tables by adding `CD_PROVIDER_MEMORY=1` to the CMakeVariables.txt file. Allows masterconfig.ini to specify another run command for the world server, to allow for easier debugging through `valgrind`.
52 lines
1.3 KiB
C++
52 lines
1.3 KiB
C++
#include "CDBehaviorParameterTable.h"
|
|
#include "GeneralUtils.h"
|
|
|
|
#include "Game.h"
|
|
#include "dLogger.h"
|
|
#include "dServer.h"
|
|
|
|
#include "CDProvider.h"
|
|
|
|
CD_PROVIDER(BehaviorParameterProvider, size_t, float);
|
|
|
|
//! Constructor
|
|
CDBehaviorParameterTable::CDBehaviorParameterTable(void) {
|
|
NEW_CD_PROVIDER(BehaviorParameterProvider, "BehaviorParameter", [](CppSQLite3Query& query) {
|
|
size_t hash = 0;
|
|
|
|
int32_t behaviorID = query.getIntField(0, -1);
|
|
std::string parameterID = query.getStringField(1, "");
|
|
|
|
GeneralUtils::hash_combine(hash, behaviorID);
|
|
GeneralUtils::hash_combine(hash, parameterID);
|
|
|
|
float value = query.getFloatField(2, -1.0f);
|
|
|
|
return std::make_pair(hash, value);
|
|
}, [](int32_t size) {
|
|
return 40 * 1000 * 1000;
|
|
}, false);
|
|
}
|
|
|
|
//! Destructor
|
|
CDBehaviorParameterTable::~CDBehaviorParameterTable(void) { }
|
|
|
|
//! Returns the table's name
|
|
std::string CDBehaviorParameterTable::GetName(void) const {
|
|
return "BehaviorParameter";
|
|
}
|
|
|
|
float CDBehaviorParameterTable::GetEntry(const uint32_t behaviorID, const std::string& name, const float defaultValue)
|
|
{
|
|
size_t hash = 0;
|
|
GeneralUtils::hash_combine(hash, behaviorID);
|
|
GeneralUtils::hash_combine(hash, name);
|
|
|
|
return BehaviorParameterProvider->GetEntry(hash, defaultValue);
|
|
}
|
|
|
|
void CDBehaviorParameterTable::LoadHost()
|
|
{
|
|
BehaviorParameterProvider->LoadHost();
|
|
}
|