This commit is contained in:
aozhiwei 2023-05-30 14:47:15 +08:00
parent 7a2e5ffbf2
commit ee268025da
2 changed files with 8 additions and 5 deletions

View File

@ -35,16 +35,17 @@ void BatchSync::AddGlobalObject(Creature* c)
sync_obj.pos = c->GetPos().ToGlmVec3(); sync_obj.pos = c->GetPos().ToGlmVec3();
sync_obj.dir = c->GetAttackDir(); sync_obj.dir = c->GetAttackDir();
sync_obj.last_sync_frameno = 0; sync_obj.last_sync_frameno = 0;
#if 0
global_object_hash_[c->GetUniId()] = global_object_hash_[c->GetUniId()] =
std::make_tuple(timer_wp, sync_obj); std::make_tuple(timer_wp, sync_obj);
#endif
} }
void BatchSync::RemoveGlobalObject(int obj_uniid) void BatchSync::RemoveGlobalObject(int obj_uniid)
{ {
auto itr = global_object_hash_.find(obj_uniid); auto itr = global_object_hash_.find(obj_uniid);
if (itr != global_object_hash_.end()) { if (itr != global_object_hash_.end()) {
f8::Timer::Instance()->Delete(std::get<0>(itr->second)); f8::Timer::Instance()->Delete(std::get<0>(*itr->second));
global_object_hash_.erase(itr); global_object_hash_.erase(itr);
} }
} }
@ -76,8 +77,10 @@ void BatchSync::AddTeam(Team* team)
sync_objects.push_back(sync_obj); sync_objects.push_back(sync_obj);
return true; return true;
}); });
#if 0
team_hash_[team] = team_hash_[team] =
std::make_tuple(timer_wp, sync_objects); std::make_tuple(timer_wp, sync_objects);
#endif
} }
void BatchSync::UpdateTeam(Team* team) void BatchSync::UpdateTeam(Team* team)
@ -90,7 +93,7 @@ void BatchSync::RemoveTeam(Team* team)
{ {
auto itr = team_hash_.find(team); auto itr = team_hash_.find(team);
if (itr != team_hash_.end()) { if (itr != team_hash_.end()) {
f8::Timer::Instance()->Delete(std::get<0>(itr->second)); f8::Timer::Instance()->Delete(std::get<0>(*itr->second));
team_hash_.erase(itr); team_hash_.erase(itr);
} }
} }

View File

@ -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, std::tuple<f8::TimerWp, SyncObject>> global_object_hash_; std::map<int, std::shared_ptr<std::tuple<f8::TimerWp, SyncObject>>> global_object_hash_;
std::map<Team*, std::tuple<f8::TimerWp, std::vector<SyncObject>>> team_hash_; std::map<Team*, std::shared_ptr<std::tuple<f8::TimerWp, std::vector<SyncObject>>>> team_hash_;
}; };