mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Initial concept for CDClient rework.
Utilizes `boost::interprocess` to share a map between worlds. The master server loads the table into memory, and the worlds hook into it when they want to get an entry. This solves the issue of skill delay, but introduces the third-party library Boost. There should be a conversation about the introduction of Boost — it is a large library and adds extra steps to the installation.
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "Game.h"
|
||||
#include "dLogger.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
void AndBehavior::Handle(BehaviorContext* context, RakNet::BitStream* bitStream, const BehaviorBranchContext branch)
|
||||
{
|
||||
for (auto* behavior : this->m_behaviors)
|
||||
@@ -27,15 +29,19 @@ void AndBehavior::UnCast(BehaviorContext* context, const BehaviorBranchContext b
|
||||
|
||||
void AndBehavior::Load()
|
||||
{
|
||||
const auto parameters = GetParameterNames();
|
||||
std::string ss = "behavior ";
|
||||
|
||||
for (const auto& parameter : parameters)
|
||||
{
|
||||
if (parameter.first.rfind("behavior", 0) == 0)
|
||||
{
|
||||
auto* action = GetAction(parameter.second);
|
||||
int i = 1;
|
||||
|
||||
this->m_behaviors.push_back(action);
|
||||
while (true) {
|
||||
std::string s = ss + std::to_string(i);
|
||||
|
||||
if (GetInt(s, 0) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
m_behaviors.push_back(GetAction(s));
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
@@ -453,7 +453,7 @@ float Behavior::GetFloat(const std::string& name, const float defaultValue) cons
|
||||
{
|
||||
// Get the behavior parameter entry and return its value.
|
||||
if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
||||
return BehaviorParameterTable->GetEntry(this->m_behaviorId, name, defaultValue).value;
|
||||
return BehaviorParameterTable->GetEntry(this->m_behaviorId, name, defaultValue);
|
||||
}
|
||||
|
||||
|
||||
@@ -485,10 +485,10 @@ std::map<std::string, float> Behavior::GetParameterNames() const
|
||||
{
|
||||
std::map<std::string, float> templatesInDatabase;
|
||||
// Find behavior template by its behavior id.
|
||||
if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
||||
/*if (!BehaviorParameterTable) BehaviorParameterTable = CDClientManager::Instance()->GetTable<CDBehaviorParameterTable>("BehaviorParameter");
|
||||
if (BehaviorParameterTable) {
|
||||
templatesInDatabase = BehaviorParameterTable->GetParametersByBehaviorID(this->m_behaviorId);
|
||||
}
|
||||
}*/
|
||||
|
||||
return templatesInDatabase;
|
||||
}
|
||||
|
@@ -26,15 +26,19 @@ void ChainBehavior::Calculate(BehaviorContext* context, RakNet::BitStream* bitSt
|
||||
|
||||
void ChainBehavior::Load()
|
||||
{
|
||||
const auto parameters = GetParameterNames();
|
||||
std::string ss = "behavior ";
|
||||
|
||||
for (const auto& parameter : parameters)
|
||||
{
|
||||
if (parameter.first.rfind("behavior", 0) == 0)
|
||||
{
|
||||
auto* action = GetAction(parameter.second);
|
||||
int i = 1;
|
||||
|
||||
this->m_behaviors.push_back(action);
|
||||
while (true) {
|
||||
std::string s = ss + std::to_string(i);
|
||||
|
||||
if (GetInt(s, 0) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
m_behaviors.push_back(GetAction(s));
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
@@ -17,15 +17,19 @@ void NpcCombatSkillBehavior::Load()
|
||||
{
|
||||
this->m_npcSkillTime = GetFloat("npc skill time");
|
||||
|
||||
const auto parameters = GetParameterNames();
|
||||
std::string ss = "behavior ";
|
||||
|
||||
for (const auto& parameter : parameters)
|
||||
{
|
||||
if (parameter.first.rfind("behavior", 0) == 0)
|
||||
{
|
||||
auto* action = GetAction(parameter.second);
|
||||
int i = 1;
|
||||
|
||||
this->m_behaviors.push_back(action);
|
||||
while (true) {
|
||||
std::string s = ss + std::to_string(i);
|
||||
|
||||
if (GetInt(s, 0) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
m_behaviors.push_back(GetAction(s));
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user