This commit is contained in:
aozhiwei 2023-05-30 14:09:02 +08:00
parent 4dc1643d0d
commit 9b83b364ac
2 changed files with 22 additions and 7 deletions

View File

@ -2,6 +2,8 @@
#include "batchsync.h"
#include "creature.h"
BatchSync::BatchSync(Room* room)
{
room_ = room;
@ -14,25 +16,38 @@ BatchSync::~BatchSync()
void BatchSync::AddGlobalObject(Creature* c)
{
if (global_object_hash_.find(c->GetUniId()) != global_object_hash_.end()) {
abort();
}
}
void BatchSync::RemoveGlobalObject(int obj_uniid)
{
auto itr = global_object_hash_.find(obj_uniid);
if (itr != global_object_hash_.end()) {
f8::Timer::Instance()->Delete(std::get<0>(itr->second));
global_object_hash_.erase(itr);
}
}
void BatchSync::AddTeam(Team* team)
{
if (team_hash_.find(team) != team_hash_.end()) {
abort();
}
}
void BatchSync::UpdateTeam(Team* team)
{
RemoveTeam(team);
AddTeam(team);
}
void BatchSync::RemoveTeam(Team* team)
{
auto itr = team_hash_.find(team);
if (itr != team_hash_.end()) {
f8::Timer::Instance()->Delete(std::get<0>(itr->second));
team_hash_.erase(itr);
}
}

View File

@ -29,6 +29,6 @@ class BatchSync
private:
Room* room_ = nullptr;
f8::Attacher timer_attacher_;
std::map<int, SyncObject> global_object_hash_;
std::map<Team*, std::vector<SyncObject>> team_hash_;
std::map<int, std::tuple<f8::TimerWp, SyncObject>> global_object_hash_;
std::map<Team*, std::tuple<f8::TimerWp, std::vector<SyncObject>>> team_hash_;
};