This commit is contained in:
aozhiwei 2022-12-25 13:34:53 +08:00
parent c8b4f4197e
commit 5c145e84d8
3 changed files with 23 additions and 13 deletions

View File

@ -5,29 +5,27 @@
#include "mapinstance.h" #include "mapinstance.h"
#include "roommgr.h" #include "roommgr.h"
#include "mt/Map.h"
void MapMgr::Init() void MapMgr::Init()
{ {
// 111 mt::Map::Traverse
#if 0 (
std::list<const mt::Map>* maps = MetaMgr::Instance()->GetMaps(); [this] (const mt::Map* map_meta, bool& stop)
if (maps) { {
for (auto& map_meta : *maps) {
MapInstance* map_instance = new MapInstance(); MapInstance* map_instance = new MapInstance();
map_instance->map_id = map_meta.pb->map_id(); map_instance->map_id = map_meta->map_id();
map_instance->Init(); map_instance->Init();
instance_hash_[map_instance->map_id] = map_instance; instance_hash_[map_instance->map_id] = map_instance;
{ {
auto itr = mode_hash_.find(map_meta.pb->map_mode()); auto itr = mode_hash_.find(map_meta->map_mode());
if (itr != mode_hash_.end()) { if (itr != mode_hash_.end()) {
itr->second.push_back(map_instance); itr->second.push_back(map_instance);
} else { } else {
mode_hash_[map_meta.pb->map_mode()] = std::vector<MapInstance*>({map_instance}); mode_hash_[map_meta->map_mode()] = std::vector<MapInstance*>({map_instance});
} }
} }
} });
} else {
A8_ABORT();
}
#if 0 #if 0
if (mode_hash_.find(kZombieMode) == mode_hash_.end()) { if (mode_hash_.find(kZombieMode) == mode_hash_.end()) {
A8_ABORT(); A8_ABORT();
@ -39,7 +37,6 @@ void MapMgr::Init()
#ifdef DMAP3D #ifdef DMAP3D
MetaMgr::Instance()->CheckMapSpawnPoint(); MetaMgr::Instance()->CheckMapSpawnPoint();
#endif #endif
#endif
} }
void MapMgr::UnInit() void MapMgr::UnInit()

View File

@ -173,4 +173,15 @@ namespace mt
return map_id() >= 1002 && map_id() <= 1003; return map_id() >= 1002 && map_id() <= 1003;
} }
void Map::Traverse(std::function<void (const Map*, bool&)> cb)
{
bool stop = false;
for (auto& itr : raw_list) {
cb(itr, stop);
if (stop) {
break;
}
}
}
} }

View File

@ -31,6 +31,8 @@ namespace mt
void Init1(); void Init1();
void Init2(); void Init2();
static void Traverse(std::function<void (const Map*, bool&)> cb);
}; };
} }