1
This commit is contained in:
parent
19117a5183
commit
ba28c936c9
@ -44,15 +44,4 @@ namespace mt
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AirDrop::Traverse(std::function<void (const AirDrop*, bool&)> cb)
|
||||
{
|
||||
bool stop = false;
|
||||
for (auto& itr : raw_list) {
|
||||
cb(itr, stop);
|
||||
if (stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ namespace mt
|
||||
void Init1();
|
||||
int RandDrop() const;
|
||||
|
||||
static void Traverse(std::function<void (const AirDrop*, bool&)> cb);
|
||||
|
||||
private:
|
||||
std::vector<std::tuple<int, int>> _drop;
|
||||
};
|
||||
|
@ -30,15 +30,4 @@ namespace mt
|
||||
}
|
||||
}
|
||||
|
||||
void AirRaid::Traverse(std::function<void (const AirRaid*, bool&)> cb)
|
||||
{
|
||||
bool stop = false;
|
||||
for (auto& itr : raw_list) {
|
||||
cb(itr, stop);
|
||||
if (stop) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@ namespace mt
|
||||
std::vector<std::tuple<int, int>> _raid_waves;
|
||||
std::vector<int> _bomb_ids;
|
||||
|
||||
static void Traverse(std::function<void (const AirRaid*, bool&)> cb);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -173,15 +173,4 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ namespace mt
|
||||
void Init1();
|
||||
void Init2();
|
||||
|
||||
static void Traverse(std::function<void (const Map*, bool&)> cb);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -16,32 +16,41 @@ void SafeCallStaticPostInit(int) { T::StaticPostInit(); };
|
||||
|
||||
template<typename T>
|
||||
void SafeCallInit1(...) { };
|
||||
template<typename T, void() = &T::Init1>
|
||||
template<typename T, void (T::*)() = &T::Init1>
|
||||
void SafeCallInit1(int)
|
||||
{
|
||||
for (auto item : T::raw_list) {
|
||||
item->Init1();
|
||||
}
|
||||
T::MutTraverse
|
||||
(
|
||||
[] (T* meta, bool& stop)
|
||||
{
|
||||
meta->Init1();
|
||||
});
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void SafeCallInit2(...) { };
|
||||
template<typename T, void() = &T::Init2>
|
||||
template<typename T, void (T::*)() = &T::Init2>
|
||||
void SafeCallInit2(int)
|
||||
{
|
||||
for (auto item : T::raw_list) {
|
||||
item->Init2();
|
||||
}
|
||||
T::MutTraverse
|
||||
(
|
||||
[] (T* meta, bool& stop)
|
||||
{
|
||||
meta->Init2();
|
||||
});
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
void SafeCallInit3(...) { };
|
||||
template<typename T, void() = &T::Init3>
|
||||
template<typename T, void (T::*)() = &T::Init3>
|
||||
void SafeCallInit3(int)
|
||||
{
|
||||
for (auto item : T::raw_list) {
|
||||
item->Init3();
|
||||
}
|
||||
T::MutTraverse
|
||||
(
|
||||
[] (T* meta, bool& stop)
|
||||
{
|
||||
meta->Init3();
|
||||
});
|
||||
};
|
||||
|
||||
namespace mt
|
||||
|
@ -10,7 +10,10 @@ class classname : public base \
|
||||
static constexpr const char* table_name= filename; \
|
||||
static std::vector<classname*> raw_list; \
|
||||
static std::map<long long, classname*> id_hash; \
|
||||
static std::map<std::string, classname*> name_hash;
|
||||
static std::map<std::string, classname*> name_hash; \
|
||||
public: \
|
||||
static void Traverse(std::function<void (const classname*, bool&)> cb); \
|
||||
static void MutTraverse(std::function<void (classname*, bool&)> cb);
|
||||
|
||||
#define DECLARE_ID_TABLE(classname, base, filename, key) \
|
||||
DECLARE_COMMON_HEAD(classname, base, filename, key, 1) \
|
||||
@ -43,4 +46,27 @@ DECLARE_COMMON_HEAD(classname, base, filename, key, 2) \
|
||||
#define IMPL_TABLE(classname) \
|
||||
std::vector<classname*> classname::raw_list; \
|
||||
std::map<long long, classname*> classname::id_hash; \
|
||||
std::map<std::string, classname*> classname::name_hash;
|
||||
std::map<std::string, classname*> classname::name_hash; \
|
||||
namespace mt \
|
||||
{ \
|
||||
void classname::Traverse(std::function<void (const classname*, bool&)> cb) \
|
||||
{ \
|
||||
bool stop = false; \
|
||||
for (auto& itr : raw_list) { \
|
||||
cb(itr, stop); \
|
||||
if (stop) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
void classname::MutTraverse(std::function<void (classname*, bool&)> cb) \
|
||||
{ \
|
||||
bool stop = false; \
|
||||
for (auto& itr : raw_list) { \
|
||||
cb(itr, stop); \
|
||||
if (stop) { \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user