1
This commit is contained in:
parent
4dc1643d0d
commit
9b83b364ac
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
#include "batchsync.h"
|
#include "batchsync.h"
|
||||||
|
|
||||||
|
#include "creature.h"
|
||||||
|
|
||||||
BatchSync::BatchSync(Room* room)
|
BatchSync::BatchSync(Room* room)
|
||||||
{
|
{
|
||||||
room_ = room;
|
room_ = room;
|
||||||
@ -14,25 +16,38 @@ BatchSync::~BatchSync()
|
|||||||
|
|
||||||
void BatchSync::AddGlobalObject(Creature* c)
|
void BatchSync::AddGlobalObject(Creature* c)
|
||||||
{
|
{
|
||||||
|
if (global_object_hash_.find(c->GetUniId()) != global_object_hash_.end()) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchSync::RemoveGlobalObject(int obj_uniid)
|
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)
|
void BatchSync::AddTeam(Team* team)
|
||||||
{
|
{
|
||||||
|
if (team_hash_.find(team) != team_hash_.end()) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchSync::UpdateTeam(Team* team)
|
void BatchSync::UpdateTeam(Team* team)
|
||||||
{
|
{
|
||||||
|
RemoveTeam(team);
|
||||||
|
AddTeam(team);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BatchSync::RemoveTeam(Team* 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,6 @@ class BatchSync
|
|||||||
private:
|
private:
|
||||||
Room* room_ = nullptr;
|
Room* room_ = nullptr;
|
||||||
f8::Attacher timer_attacher_;
|
f8::Attacher timer_attacher_;
|
||||||
std::map<int, SyncObject> global_object_hash_;
|
std::map<int, std::tuple<f8::TimerWp, SyncObject>> global_object_hash_;
|
||||||
std::map<Team*, std::vector<SyncObject>> team_hash_;
|
std::map<Team*, std::tuple<f8::TimerWp, std::vector<SyncObject>>> team_hash_;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user