diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index 6b79220..b3d9a56 100755 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -58,7 +58,7 @@ static void SavePerfLog() App::Instance()->perf.max_run_delay_time, RoomMgr::Instance()->RoomNum() }); - if (App::Instance()->flags.find(4) != App::Instance()->flags.end()) { + if (App::Instance()->HasFlag(4)) { a8::XPrintf("max_mainloop_rundelay:%d max_dispatchmsg_time:%d room_num:%d online_num:%d\n", { App::Instance()->perf.max_run_delay_time, @@ -500,3 +500,8 @@ a8::XParams* App::GetContext(long long context_id) auto itr = context_hash_.find(context_id); return itr != context_hash_.end() ? &(itr->second) : nullptr; } + +bool App::HasFlag(int flag) +{ + return flags.find(flag) != flags.end(); +} diff --git a/server/gameserver/app.h b/server/gameserver/app.h index 815c1d3..0b2ba5d 100644 --- a/server/gameserver/app.h +++ b/server/gameserver/app.h @@ -32,6 +32,7 @@ public: a8::XParams* AddContext(long long context_id); void DelContext(long long context_id); a8::XParams* GetContext(long long context_id); + bool HasFlag(int flag); private: void QuickExecute(int delta_time); @@ -60,6 +61,13 @@ public: int instance_id = 0; bool is_test_mode = false; int test_param = 0; + /* + 1: 是否自动匹配机器人组队 + 2: 是否发布环境 + 3: battleReport环境 + 4: 测试自动跟随 + 5: 压力测试 + */ std::set flags; private: diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 1775014..e8184da 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1868,7 +1868,7 @@ void Human::InternalSendGameOver() }; std::string url; if (!f8::IsOnlineEnv()) { - if (App::Instance()->flags.find(3) != App::Instance()->flags.end()) { + if (App::Instance()->HasFlag(3)) { url = "http://192.168.100.41/webapp/index.php?c=Role&a=battleReport"; } else { url = "https://game2001api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; diff --git a/server/gameserver/jsondatamgr.cc b/server/gameserver/jsondatamgr.cc index c6c23bc..83955bf 100644 --- a/server/gameserver/jsondatamgr.cc +++ b/server/gameserver/jsondatamgr.cc @@ -10,7 +10,7 @@ void JsonDataMgr::Init() std::string gameserver_cluster_json_file; std::string masterserver_cluster_json_file; if (!f8::IsOnlineEnv()) { - if (App::Instance()->flags.find(2) != App::Instance()->flags.end()) { + if (App::Instance()->HasFlag(2)) { gameserver_cluster_json_file = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver/" "game%d.gameserver.cluster.json", { diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 364f47b..25688a4 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -65,7 +65,7 @@ public: void Load() { if (!f8::IsOnlineEnv()) { - if (App::Instance()->flags.find(2) != App::Instance()->flags.end()) { + if (App::Instance()->HasFlag(2)) { res_path = a8::Format("/root/pub/%d/%d/conf_test/game%d/gameserver/res/", { GAME_ID, diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index c857e62..3eb9fad 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -59,7 +59,7 @@ void Room::Init() } } ); - if (App::Instance()->flags.find(1) != App::Instance()->flags.end()) { + if (App::Instance()->HasFlag(1)) { xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * 3, a8::XParams() .SetSender(this), @@ -687,7 +687,11 @@ bool Room::CanJoin(const std::string& accountid) if (gas_data.gas_mode != GasInactive) { return false; } - return accountid_hash_.size() < ROOM_MAX_PLAYER_NUM; + if (App::Instance()->HasFlag(5)) { + return accountid_hash_.size() < 1; + } else { + return accountid_hash_.size() < ROOM_MAX_PLAYER_NUM; + } } std::set* Room::GetAliveTeam() @@ -806,32 +810,6 @@ void Room::UpdateGas() } return true; }); - for (auto& pair : accountid_hash_) { - if (App::Instance()->flags.find(4) != App::Instance()->flags.end()) { - xtimer.AddRepeatTimerAndAttach(SERVER_FRAME_RATE * 5, - a8::XParams() - .SetSender(this) - .SetParam1(pair.second->entity_uniid), - [] (const a8::XParams& param) - { - Room* room = (Room*)param.sender.GetUserData(); - Human* hum = room->GetPlayerByUniId(param.param1); - if (hum) { - std::vector humans; - for (auto& pair : room->human_hash_) { - if (pair.first != param.param1.GetInt()) { - humans.push_back(pair.second); - } - } - if (!humans.empty()) { - Human* target = humans[rand() % humans.size()]; - hum->FollowTarget(target); - } - } - }, - &xtimer_attacher.timer_list_); - } - } gas_data.gas_mode = GasWaiting; gas_data.old_area_meta = MetaMgr::Instance()->GetSafeArea(30001); gas_data.new_area_meta = MetaMgr::Instance()->GetSafeArea(30002);