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 "roommgr.h"
#include "mt/Map.h"
void MapMgr::Init()
{
// 111
#if 0
std::list<const mt::Map>* maps = MetaMgr::Instance()->GetMaps();
if (maps) {
for (auto& map_meta : *maps) {
mt::Map::Traverse
(
[this] (const mt::Map* map_meta, bool& stop)
{
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();
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()) {
itr->second.push_back(map_instance);
} 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 (mode_hash_.find(kZombieMode) == mode_hash_.end()) {
A8_ABORT();
@ -39,7 +37,6 @@ void MapMgr::Init()
#ifdef DMAP3D
MetaMgr::Instance()->CheckMapSpawnPoint();
#endif
#endif
}
void MapMgr::UnInit()

View File

@ -173,4 +173,15 @@ namespace mt
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 Init2();
static void Traverse(std::function<void (const Map*, bool&)> cb);
};
}