From 39b4def85cb8f58ba40b3c543b4713a5e7793e98 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 11 Sep 2019 12:12:33 +0800 Subject: [PATCH] 1 --- server/gameserver/room.cc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index dea370f..42a0ae0 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -355,26 +355,31 @@ void Room::CreateThings() { map_tpl_name = map_meta->RandTemplate(); std::vector* things = MetaMgr::Instance()->GetMapTplThing(map_tpl_name); + std::vector spawn_points; if (things) { for (auto& thing_tpl : *things) { - if (thing_tpl.i->weight() >= rand() % 10000) { - switch (thing_tpl.i->_object_type()) { - case kMOT_Object: - { + switch (thing_tpl.i->_object_type()) { + case kMOT_Object: + { + if (thing_tpl.i->weight() >= rand() % 10000) { CreateMapObject(thing_tpl); } - break; - case kMOT_SpawnPoint: - { - CreateMapSpawnPoint(thing_tpl); - } - break; - default: - break; } + break; + case kMOT_SpawnPoint: + { + spawn_points.push_back(&thing_tpl); + } + break; + default: + break; } } } + std::random_shuffle(spawn_points.begin(), spawn_points.end()); + for (auto& thing_tpl : spawn_points) { + CreateMapSpawnPoint(*thing_tpl); + } } void Room::DropItem(a8::Vec2 pos, int item_id, int item_count, int item_lv)