mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-21 21:17:25 +00:00
busting out the multimap ig (#1602)
This commit is contained in:
parent
342da927f5
commit
a54600b41e
@ -105,7 +105,7 @@ void BehaviorContext::ExecuteUpdates() {
|
|||||||
this->scheduledUpdates.clear();
|
this->scheduledUpdates.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bitStream) {
|
bool BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bitStream) {
|
||||||
BehaviorSyncEntry entry;
|
BehaviorSyncEntry entry;
|
||||||
auto found = false;
|
auto found = false;
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bit
|
|||||||
if (!found) {
|
if (!found) {
|
||||||
LOG("Failed to find behavior sync entry with sync id (%i)!", syncId);
|
LOG("Failed to find behavior sync entry with sync id (%i)!", syncId);
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* behavior = entry.behavior;
|
auto* behavior = entry.behavior;
|
||||||
@ -137,10 +137,11 @@ void BehaviorContext::SyncBehavior(const uint32_t syncId, RakNet::BitStream& bit
|
|||||||
if (behavior == nullptr) {
|
if (behavior == nullptr) {
|
||||||
LOG("Invalid behavior for sync id (%i)!", syncId);
|
LOG("Invalid behavior for sync id (%i)!", syncId);
|
||||||
|
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
behavior->Sync(this, bitStream, branch);
|
behavior->Sync(this, bitStream, branch);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ struct BehaviorContext
|
|||||||
|
|
||||||
void ExecuteUpdates();
|
void ExecuteUpdates();
|
||||||
|
|
||||||
void SyncBehavior(uint32_t syncId, RakNet::BitStream& bitStream);
|
bool SyncBehavior(uint32_t syncId, RakNet::BitStream& bitStream);
|
||||||
|
|
||||||
void Update(float deltaTime);
|
void Update(float deltaTime);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t s
|
|||||||
|
|
||||||
context->skillID = skillID;
|
context->skillID = skillID;
|
||||||
|
|
||||||
this->m_managedBehaviors.insert_or_assign(skillUid, context);
|
this->m_managedBehaviors.insert({ skillUid, context });
|
||||||
|
|
||||||
auto* behavior = Behavior::CreateBehavior(behaviorId);
|
auto* behavior = Behavior::CreateBehavior(behaviorId);
|
||||||
|
|
||||||
@ -52,17 +52,24 @@ bool SkillComponent::CastPlayerSkill(const uint32_t behaviorId, const uint32_t s
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syncId, RakNet::BitStream& bitStream) {
|
void SkillComponent::SyncPlayerSkill(const uint32_t skillUid, const uint32_t syncId, RakNet::BitStream& bitStream) {
|
||||||
const auto index = this->m_managedBehaviors.find(skillUid);
|
const auto index = this->m_managedBehaviors.equal_range(skillUid);
|
||||||
|
|
||||||
if (index == this->m_managedBehaviors.end()) {
|
if (index.first == this->m_managedBehaviors.end()) {
|
||||||
LOG("Failed to find skill with uid (%i)!", skillUid, syncId);
|
LOG("Failed to find skill with uid (%i)!", skillUid, syncId);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* context = index->second;
|
bool foundSyncId = false;
|
||||||
|
for (auto it = index.first; it != index.second && !foundSyncId; ++it) {
|
||||||
|
const auto& context = it->second;
|
||||||
|
|
||||||
context->SyncBehavior(syncId, bitStream);
|
foundSyncId = context->SyncBehavior(syncId, bitStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundSyncId) {
|
||||||
|
LOG("Failed to find sync id (%i) for skill with uid (%i)!", syncId, skillUid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,7 +145,7 @@ void SkillComponent::Update(const float deltaTime) {
|
|||||||
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
|
for (const auto& pair : this->m_managedBehaviors) pair.second->UpdatePlayerSyncs(deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint32_t, BehaviorContext*> keep{};
|
std::multimap<uint32_t, BehaviorContext*> keep{};
|
||||||
|
|
||||||
for (const auto& pair : this->m_managedBehaviors) {
|
for (const auto& pair : this->m_managedBehaviors) {
|
||||||
auto* context = pair.second;
|
auto* context = pair.second;
|
||||||
@ -176,7 +183,7 @@ void SkillComponent::Update(const float deltaTime) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
keep.insert_or_assign(pair.first, context);
|
keep.insert({ pair.first, context });
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_managedBehaviors = keep;
|
this->m_managedBehaviors = keep;
|
||||||
@ -285,7 +292,7 @@ SkillExecutionResult SkillComponent::CalculateBehavior(
|
|||||||
return { false, 0 };
|
return { false, 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
this->m_managedBehaviors.insert_or_assign(context->skillUId, context);
|
this->m_managedBehaviors.insert({ context->skillUId, context });
|
||||||
|
|
||||||
if (!clientInitalized) {
|
if (!clientInitalized) {
|
||||||
// Echo start skill
|
// Echo start skill
|
||||||
|
@ -188,7 +188,7 @@ private:
|
|||||||
/**
|
/**
|
||||||
* All of the active skills mapped by their unique ID.
|
* All of the active skills mapped by their unique ID.
|
||||||
*/
|
*/
|
||||||
std::map<uint32_t, BehaviorContext*> m_managedBehaviors;
|
std::multimap<uint32_t, BehaviorContext*> m_managedBehaviors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All active projectiles.
|
* All active projectiles.
|
||||||
|
Loading…
Reference in New Issue
Block a user