add HasFlag 移除自动跟随测试代码
This commit is contained in:
parent
c400f00536
commit
f0dbfa1f78
@ -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();
|
||||
}
|
||||
|
@ -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<int> flags;
|
||||
|
||||
private:
|
||||
|
@ -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";
|
||||
|
@ -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",
|
||||
{
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
if (App::Instance()->HasFlag(5)) {
|
||||
return accountid_hash_.size() < 1;
|
||||
} else {
|
||||
return accountid_hash_.size() < ROOM_MAX_PLAYER_NUM;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<Human*>* 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<Human*> 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user