1
This commit is contained in:
parent
7e67bc5f5e
commit
90770e10ff
@ -3,6 +3,7 @@
|
||||
#include "mt/AirLine.h"
|
||||
|
||||
IMPL_TABLE(mt::AirLine)
|
||||
std::map<int, std::vector<const mt::AirLine*>> mt::AirLine::mapid_hash_;
|
||||
|
||||
namespace mt
|
||||
{
|
||||
@ -21,6 +22,21 @@ namespace mt
|
||||
_end_point_x = a8::XValue(strings[0]).GetDouble();
|
||||
_end_point_y = a8::XValue(strings[1]).GetDouble();
|
||||
}
|
||||
{
|
||||
auto itr = map_id_hash_.find(map_id());
|
||||
if (itr != map_id_hash_.end()) {
|
||||
itr->second.push_back(this);
|
||||
} else {
|
||||
map_id_hash_[map_id()] = std::vector<const mt::AirLine*>({this});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const AirLine* AirLine::RandAirLine(int map_id)
|
||||
{
|
||||
auto itr = mapid_hash_.find(map_ida);
|
||||
return itr != mapid_hash_.end && &itr->second.empty() ?
|
||||
itr->second.at(rand() % itr->second.size()) : nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,7 +18,10 @@ namespace mt
|
||||
|
||||
void Init1();
|
||||
|
||||
static const AirLine* RandAirLine(int map_id) {};
|
||||
static const AirLine* RandAirLine(int map_id);
|
||||
|
||||
private:
|
||||
static std::map<int, std::vector<const mt::AirLine*>> mapid_hash_;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user