1
This commit is contained in:
commit
8d86e2736d
@ -75,6 +75,15 @@ void AndroidNewAI::Update(int delta_time)
|
||||
UpdateNewAI();
|
||||
}
|
||||
|
||||
float AndroidNewAI::GetAttackRate()
|
||||
{
|
||||
if (!ai_meta) {
|
||||
return 1;
|
||||
} else {
|
||||
return ai_meta->i->attack_rate();
|
||||
}
|
||||
}
|
||||
|
||||
void AndroidNewAI::DefaultAi()
|
||||
{
|
||||
Human* hum = (Human*)owner;
|
||||
|
@ -53,6 +53,7 @@ public:
|
||||
|
||||
virtual ~AndroidNewAI() override;
|
||||
virtual void Update(int delta_time) override;
|
||||
float GetAttackRate();
|
||||
|
||||
private:
|
||||
void DefaultAi();
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "collider.h"
|
||||
#include "obstacle.h"
|
||||
#include "player.h"
|
||||
#include "android.h"
|
||||
#include "android_new.ai.h"
|
||||
#include "app.h"
|
||||
#include "perfmonitor.h"
|
||||
|
||||
@ -235,6 +237,11 @@ void Bullet::MapServiceUpdate()
|
||||
|
||||
float Bullet::GetAtk()
|
||||
{
|
||||
return gun_meta->i->atk() +
|
||||
float atk = gun_meta->i->atk() +
|
||||
(gun_upgrade_meta ? gun_upgrade_meta->GetAttrValue(gun_lv, kHAT_Atk) : 0);
|
||||
if (player->IsAndroid()) {
|
||||
Android* android = (Android*)player;
|
||||
atk *= android->ai->GetAttackRate();
|
||||
}
|
||||
return atk;
|
||||
}
|
||||
|
@ -278,12 +278,6 @@ enum ObjectSyncFlags_e
|
||||
kOsfIsDead = 0,
|
||||
};
|
||||
|
||||
enum AiCommand_e
|
||||
{
|
||||
kAiNone = 0,
|
||||
|
||||
};
|
||||
|
||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||
|
||||
@ -331,3 +325,5 @@ const int FIXED_OBJECT_MAXID = 1024;
|
||||
const int MAX_ROOM_IDX = 2018;
|
||||
|
||||
const int VIEW_RANGE = 512;
|
||||
|
||||
const int MAX_AI_LEVEL = 8;
|
||||
|
@ -1006,10 +1006,12 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
||||
void Human::DecHP(float dec_hp, int killer_id, const std::string& killer_name, int weapon_id)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#if 0
|
||||
if (IsPlayer()) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
auto downed_func = [] (const a8::XParams& param)
|
||||
{
|
||||
Human* hum = (Human*)param.sender.GetUserData();
|
||||
@ -2101,7 +2103,11 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
|
||||
stats.pass_score = MetaMgr::Instance()->GetKillPointParam1(stats.kills);
|
||||
stats.pass_score += MetaMgr::Instance()->GetRankPointParam1(rank);
|
||||
stats.rank_score = MetaMgr::Instance()->GetKillPointParam2(stats.kills);
|
||||
stats.rank_score += MetaMgr::Instance()->GetRankPointParam2(rank);
|
||||
if (room->IsMiniRoom()) {
|
||||
stats.rank_score += MetaMgr::Instance()->GetRankPointParam3(rank);
|
||||
} else {
|
||||
stats.rank_score += MetaMgr::Instance()->GetRankPointParam2(rank);
|
||||
}
|
||||
}
|
||||
params->SetVal("score", 0);
|
||||
params->SetVal("pass_score", has_pass ? stats.pass_score * 2 : stats.pass_score);
|
||||
|
@ -235,52 +235,77 @@ public:
|
||||
}
|
||||
}
|
||||
{
|
||||
METAMGR_READ_STR(mini_room_ai, "");
|
||||
METAMGR_READ_STR(a_room_ai, "");
|
||||
std::vector<std::string> tmpstrings;
|
||||
a8::Split(MetaMgr::Instance()->mini_room_ai, tmpstrings, '|');
|
||||
a8::Split(MetaMgr::Instance()->a_room_ai, tmpstrings, '|');
|
||||
int i = 1;
|
||||
for (auto& str : tmpstrings) {
|
||||
int weight = a8::XValue(str).GetInt();
|
||||
MetaMgr::Instance()->mini_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->mini_room_ai_weights.push_back
|
||||
MetaMgr::Instance()->a_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->a_room_ai_weights.push_back
|
||||
(
|
||||
std::make_tuple
|
||||
(
|
||||
i,
|
||||
MetaMgr::Instance()->mini_room_ai_weights_space
|
||||
MetaMgr::Instance()->a_room_ai_weights_space
|
||||
)
|
||||
);
|
||||
++i;
|
||||
}
|
||||
if (MetaMgr::Instance()->mini_room_ai_weights.size() != 8) {
|
||||
if (MetaMgr::Instance()->a_room_ai_weights.size() != MAX_AI_LEVEL) {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->mini_room_ai_weights_space <= 0) {
|
||||
if (MetaMgr::Instance()->a_room_ai_weights_space <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
{
|
||||
METAMGR_READ_STR(normal_room_ai, "");
|
||||
METAMGR_READ_STR(b_room_ai, "");
|
||||
std::vector<std::string> tmpstrings;
|
||||
a8::Split(MetaMgr::Instance()->mini_room_ai, tmpstrings, '|');
|
||||
a8::Split(MetaMgr::Instance()->b_room_ai, tmpstrings, '|');
|
||||
int i = 1;
|
||||
for (auto& str : tmpstrings) {
|
||||
int weight = a8::XValue(str).GetInt();
|
||||
MetaMgr::Instance()->normal_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->normal_room_ai_weights.push_back
|
||||
MetaMgr::Instance()->b_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->b_room_ai_weights.push_back
|
||||
(
|
||||
std::make_tuple
|
||||
(
|
||||
i,
|
||||
MetaMgr::Instance()->normal_room_ai_weights_space
|
||||
MetaMgr::Instance()->b_room_ai_weights_space
|
||||
)
|
||||
);
|
||||
++i;
|
||||
}
|
||||
if (MetaMgr::Instance()->normal_room_ai_weights.size() != 8) {
|
||||
if (MetaMgr::Instance()->b_room_ai_weights.size() != MAX_AI_LEVEL) {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->normal_room_ai_weights_space <= 0) {
|
||||
if (MetaMgr::Instance()->b_room_ai_weights_space <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
{
|
||||
METAMGR_READ_STR(c_room_ai, "");
|
||||
std::vector<std::string> tmpstrings;
|
||||
a8::Split(MetaMgr::Instance()->c_room_ai, tmpstrings, '|');
|
||||
int i = 1;
|
||||
for (auto& str : tmpstrings) {
|
||||
int weight = a8::XValue(str).GetInt();
|
||||
MetaMgr::Instance()->c_room_ai_weights_space += weight;
|
||||
MetaMgr::Instance()->c_room_ai_weights.push_back
|
||||
(
|
||||
std::make_tuple
|
||||
(
|
||||
i,
|
||||
MetaMgr::Instance()->c_room_ai_weights_space
|
||||
)
|
||||
);
|
||||
++i;
|
||||
}
|
||||
if (MetaMgr::Instance()->c_room_ai_weights.size() != MAX_AI_LEVEL) {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->c_room_ai_weights_space <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
@ -762,6 +787,12 @@ int MetaMgr::GetRankPointParam2(int rank)
|
||||
return itr != loader_->rankpoint_hash.end() ? itr->second->i->parameter2() : 0;
|
||||
}
|
||||
|
||||
int MetaMgr::GetRankPointParam3(int rank)
|
||||
{
|
||||
auto itr = loader_->rankpoint_hash.find(rank);
|
||||
return itr != loader_->rankpoint_hash.end() ? itr->second->i->parameter3() : 0;
|
||||
}
|
||||
|
||||
int MetaMgr::GetKillPointParam1(int kill_num)
|
||||
{
|
||||
auto itr = loader_->killpoint_hash.find(kill_num);
|
||||
|
@ -42,6 +42,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
float GetKillRewardParam(int kill_num);
|
||||
int GetRankPointParam1(int rank);
|
||||
int GetRankPointParam2(int rank);
|
||||
int GetRankPointParam3(int rank);
|
||||
int GetKillPointParam1(int kill_num);
|
||||
int GetKillPointParam2(int kill_num);
|
||||
MetaData::Robot* RandRobot(std::set<int>& refreshed_robot_set);
|
||||
@ -91,12 +92,15 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
int level0room_robot_autodie_distance = 0;
|
||||
std::set<int> level0room_spec_things_set;
|
||||
std::vector<int> level0room_spec_airdrops;
|
||||
std::vector<std::tuple<int, int>> mini_room_ai_weights;
|
||||
int mini_room_ai_weights_space = 0;
|
||||
std::vector<std::tuple<int, int>> normal_room_ai_weights;
|
||||
int normal_room_ai_weights_space = 0;
|
||||
std::string mini_room_ai;
|
||||
std::string normal_room_ai;
|
||||
std::vector<std::tuple<int, int>> a_room_ai_weights;
|
||||
int a_room_ai_weights_space = 0;
|
||||
std::vector<std::tuple<int, int>> b_room_ai_weights;
|
||||
int b_room_ai_weights_space = 0;
|
||||
std::vector<std::tuple<int, int>> c_room_ai_weights;
|
||||
int c_room_ai_weights_space = 0;
|
||||
std::string a_room_ai;
|
||||
std::string b_room_ai;
|
||||
std::string c_room_ai;
|
||||
|
||||
int level1room_shua_robot_min_time = 0;
|
||||
int level1room_shua_robot_max_time = 0;
|
||||
|
@ -49,6 +49,7 @@ void Room::InitData(RoomInitInfo& init_info)
|
||||
room_type_ = init_info.room_type;
|
||||
creator_game_times_ = init_info.creator_game_times;
|
||||
creator_register_time_ = init_info.creator_register_time;
|
||||
force_entry_newbie_room_ = init_info.force_entry_newbie_room;
|
||||
|
||||
map_tpl_name_ = init_info.map_tpl_name;
|
||||
grid_service = init_info.grid_service;
|
||||
@ -2878,19 +2879,14 @@ void Room::ShuaLastGas()
|
||||
|
||||
bool Room::IsMiniRoom()
|
||||
{
|
||||
#if 0
|
||||
if (GetRoomType() == RT_NewBrid ||
|
||||
GetRoomType() == RT_MidBrid) {
|
||||
if (a8::BetweenDays(Global::g_nowtime, creator_register_time_) > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 1
|
||||
return false;
|
||||
#else
|
||||
return
|
||||
GetRoomType() == RT_NewBrid ||
|
||||
GetRoomType() == RT_MidBrid ||
|
||||
GetRoomType() == RT_OldBrid1;
|
||||
#endif
|
||||
}
|
||||
|
||||
size_t Room::GetRoomMaxPlayerNum()
|
||||
@ -2911,7 +2907,35 @@ void Room::InitAndroidAI()
|
||||
androids.push_back((Android*)hum);
|
||||
}
|
||||
}
|
||||
std::array<int, 8> ai_num = {};
|
||||
std::vector<std::tuple<int, int>>* ai_weights = nullptr;
|
||||
int ai_weights_space = 0;
|
||||
switch (GetRoomType()) {
|
||||
case RT_OldBrid1:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->a_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->a_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
case RT_OldBrid2:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->b_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->b_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
case RT_OldBrid3:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->c_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->c_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
ai_weights = &MetaMgr::Instance()->a_room_ai_weights;
|
||||
ai_weights_space = MetaMgr::Instance()->a_room_ai_weights_space;
|
||||
}
|
||||
break;
|
||||
}
|
||||
std::array<int, MAX_AI_LEVEL> ai_num = {};
|
||||
for (Android* hum : androids) {
|
||||
#ifdef DEBUG
|
||||
#if 0
|
||||
@ -2919,33 +2943,14 @@ void Room::InitAndroidAI()
|
||||
continue;
|
||||
#endif
|
||||
#endif
|
||||
if (IsMiniRoom()) {
|
||||
int rnd = rand() % MetaMgr::Instance()->mini_room_ai_weights_space;
|
||||
++rnd;
|
||||
for (auto& tuple : MetaMgr::Instance()->mini_room_ai_weights) {
|
||||
int ai_level = std::get<0>(tuple);
|
||||
int space = std::get<1>(tuple);
|
||||
if (rnd <= space) {
|
||||
hum->SetAiLevel(ai_level);
|
||||
#ifdef DEBUG
|
||||
++ai_num[ai_level - 1];
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
int rnd = rand() % MetaMgr::Instance()->normal_room_ai_weights_space;
|
||||
++rnd;
|
||||
for (auto& tuple : MetaMgr::Instance()->normal_room_ai_weights) {
|
||||
int ai_level = std::get<0>(tuple);
|
||||
int space = std::get<1>(tuple);
|
||||
if (rnd <= space) {
|
||||
hum->SetAiLevel(ai_level);
|
||||
#ifdef DEBUG
|
||||
++ai_num[ai_level - 1];
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
int rnd = rand() % ai_weights_space;
|
||||
++rnd;
|
||||
for (auto& tuple : *ai_weights) {
|
||||
int ai_level = std::get<0>(tuple);
|
||||
int space = std::get<1>(tuple);
|
||||
if (rnd <= space) {
|
||||
hum->SetAiLevel(ai_level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +122,7 @@ public:
|
||||
void GetAlivePlayers(std::vector<Player*>& humans, size_t num);
|
||||
int GetCanShuaNum(int shua_num);
|
||||
void AdjustPosInnerMap(a8::Vec2& pos, float radius);
|
||||
bool IsMiniRoom();
|
||||
|
||||
private:
|
||||
int AllocUniid();
|
||||
@ -196,7 +197,6 @@ private:
|
||||
void CheckShowHand();
|
||||
void ShowHand();
|
||||
void ShuaLastGas();
|
||||
bool IsMiniRoom();
|
||||
size_t GetRoomMaxPlayerNum();
|
||||
void InitAndroidAI();
|
||||
|
||||
@ -237,6 +237,7 @@ private:
|
||||
bool show_handed_ = false;
|
||||
int creator_game_times_ = 0;
|
||||
int creator_register_time_ = 0;
|
||||
bool force_entry_newbie_room_ = false;
|
||||
|
||||
int current_teamid_ = 0;
|
||||
int current_uniid_ = FIXED_OBJECT_MAXID;
|
||||
|
@ -32,7 +32,8 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
|
||||
}
|
||||
//游戏次数,吃鸡数,击杀数,段位
|
||||
game_times = a8::XValue(tmp_strings[0]);
|
||||
int rank = tmp_strings.size() > 3 ? a8::XValue(tmp_strings[3]).GetInt() : 0;
|
||||
int room_rank = tmp_strings.size() > 3 ? a8::XValue(tmp_strings[3]).GetInt() : 0;
|
||||
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
|
||||
#if 1
|
||||
#else
|
||||
if (!f8::IsOnlineEnv() || RoomMgr::Instance()->IsGM(msg)) {
|
||||
@ -43,88 +44,65 @@ static RoomType_e GetHumanRoomType(const cs::CMJoin& msg, int& game_times)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (msg.force_entry_newbie_room()) {
|
||||
if (msg.team_uuid().empty()) {
|
||||
return RT_NewBrid;
|
||||
} else {
|
||||
RoomMgr::Instance()->AddProtectTeam(msg.team_uuid());
|
||||
return RT_MidBrid;
|
||||
}
|
||||
}
|
||||
if (!msg.team_uuid().empty()) {
|
||||
if (RoomMgr::Instance()->IsProtectTeam(msg.team_uuid())) {
|
||||
return RT_MidBrid;
|
||||
}
|
||||
bool has_mid_brid = false;
|
||||
bool has_old_brid1 = false;
|
||||
if (!msg.team_uuid().empty() && msg.team_members().size() > 1) {
|
||||
for (auto& team_member : msg.team_members()) {
|
||||
if (team_member.game_times() >= 1 && team_member.game_times() <= 1) {
|
||||
has_mid_brid = true;
|
||||
}
|
||||
if (team_member.game_times() >= 2 && team_member.game_times() <= 2) {
|
||||
has_old_brid1 = true;
|
||||
}
|
||||
}
|
||||
if (has_mid_brid) {
|
||||
return RT_MidBrid;
|
||||
}
|
||||
if (has_old_brid1) {
|
||||
return RT_OldBrid1;
|
||||
}
|
||||
}
|
||||
|
||||
if (game_times <= 0) {
|
||||
return RT_NewBrid;
|
||||
} else if (game_times == 1) {
|
||||
return RT_MidBrid;
|
||||
} else {
|
||||
switch (game_times) {
|
||||
case 2:
|
||||
{
|
||||
if (msg.team_uuid().empty()) {
|
||||
return RT_NewBrid;
|
||||
} else {
|
||||
return RT_OldBrid1;
|
||||
if (team_member.rank() > 0) {
|
||||
if (team_member.rank() > room_rank) {
|
||||
room_rank = team_member.rank();
|
||||
register_time = team_member.create_time();
|
||||
} else if(team_member.rank() == room_rank &&
|
||||
team_member.create_time() > register_time) {
|
||||
register_time = team_member.create_time();
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
|
||||
if (!msg.team_uuid().empty()) {
|
||||
bool has_new_brid = false;
|
||||
for (auto& team_member : msg.team_members()) {
|
||||
if (team_member.create_time() != 0 &&
|
||||
a8::BetweenDays(Global::g_nowtime, team_member.create_time()) <= 0) {
|
||||
has_new_brid = true;
|
||||
} else {
|
||||
if (msg.force_entry_newbie_room()) {
|
||||
return RT_NewBrid;
|
||||
}
|
||||
if (game_times <= 0) {
|
||||
return RT_NewBrid;
|
||||
} else if (game_times == 1) {
|
||||
return RT_MidBrid;
|
||||
} else {
|
||||
switch (game_times) {
|
||||
case 2:
|
||||
{
|
||||
if (msg.team_uuid().empty()) {
|
||||
return RT_NewBrid;
|
||||
} else {
|
||||
return RT_OldBrid1;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (has_new_brid) {
|
||||
}
|
||||
|
||||
if (!msg.team_uuid().empty() && msg.team_members().size() > 1) {
|
||||
if (room_rank >= 0 && room_rank <= 6) {
|
||||
return RT_OldBrid1;
|
||||
} else {
|
||||
} else if (a8::BetweenDays(Global::g_nowtime, register_time) <= 0) {
|
||||
return RT_OldBrid2;
|
||||
} else {
|
||||
return RT_OldBrid3;
|
||||
}
|
||||
} else {
|
||||
if (a8::BetweenDays(Global::g_nowtime, register_time) <= 0) {
|
||||
if (room_rank >= 0 && room_rank <= 6) {
|
||||
//黄金段位以下
|
||||
return RT_OldBrid1;
|
||||
} else {
|
||||
} else if (a8::BetweenDays(Global::g_nowtime, register_time) <= 0) {
|
||||
//第一天,黄金段位以上
|
||||
return RT_OldBrid2;
|
||||
} else {
|
||||
//其他
|
||||
return RT_OldBrid3;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (rank >= 0 && rank <= 10) {
|
||||
return RT_OldBrid1;
|
||||
} else {
|
||||
return RT_OldBrid2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void RoomMgr::Init()
|
||||
@ -165,7 +143,12 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
int game_times = 0;
|
||||
RoomType_e self_room_type = GetHumanRoomType(msg, game_times);
|
||||
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
|
||||
Room* room = GetJoinableRoom(msg, self_room_type, game_times, register_time);
|
||||
Room* room = GetJoinableRoom(msg,
|
||||
self_room_type,
|
||||
game_times,
|
||||
register_time,
|
||||
msg.force_entry_newbie_room()
|
||||
);
|
||||
if (!room) {
|
||||
JoinErrorHandle(msg, 3, hdr.socket_handle);
|
||||
return;
|
||||
@ -176,7 +159,8 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
CreatePlayerByCMJoin(hum,
|
||||
hdr.ip_saddr,
|
||||
hdr.socket_handle,
|
||||
msg);
|
||||
msg
|
||||
);
|
||||
hum->meta = MetaMgr::Instance()->human_meta;
|
||||
hum->room = room;
|
||||
hum->ProcPrepareItems(msg.prepare_items());
|
||||
@ -198,7 +182,9 @@ int RoomMgr::OverRoomNum()
|
||||
Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||
const RoomType_e self_room_type,
|
||||
int game_times,
|
||||
int creator_register_time)
|
||||
int creator_register_time,
|
||||
bool force_entry_newbie_room
|
||||
)
|
||||
{
|
||||
std::vector<std::vector<Room*>> group_rooms;
|
||||
for (int i = 0; i < RT_Max; ++i) {
|
||||
@ -218,10 +204,16 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||
return group_rooms[self_room_type][rand() % group_rooms[self_room_type].size()];
|
||||
}
|
||||
if (self_room_type == RT_NewBrid) {
|
||||
return CreateRoom(self_room_type, game_times, creator_register_time);
|
||||
return CreateRoom(self_room_type,
|
||||
game_times,
|
||||
creator_register_time,
|
||||
force_entry_newbie_room);
|
||||
}
|
||||
if (self_room_type == RT_MidBrid) {
|
||||
return CreateRoom(self_room_type, game_times, creator_register_time);
|
||||
return CreateRoom(self_room_type,
|
||||
game_times,
|
||||
creator_register_time,
|
||||
force_entry_newbie_room);
|
||||
}
|
||||
for (int i = 0; i < RT_Max; ++i) {
|
||||
for (Room* room : group_rooms[i]) {
|
||||
@ -230,7 +222,10 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||
}
|
||||
}
|
||||
}
|
||||
return CreateRoom(self_room_type, game_times, creator_register_time);
|
||||
return CreateRoom(self_room_type,
|
||||
game_times,
|
||||
creator_register_time,
|
||||
force_entry_newbie_room);
|
||||
}
|
||||
|
||||
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
|
||||
@ -403,7 +398,10 @@ int RoomMgr::AllocRoomIdx()
|
||||
return current_room_idx_;
|
||||
}
|
||||
|
||||
Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times, int creator_register_time)
|
||||
Room* RoomMgr::CreateRoom(RoomType_e room_type,
|
||||
int game_times,
|
||||
int creator_register_time,
|
||||
bool force_entry_newbie_room)
|
||||
{
|
||||
int room_idx = AllocRoomIdx();
|
||||
if (room_idx < 1) {
|
||||
@ -416,6 +414,7 @@ Room* RoomMgr::CreateRoom(RoomType_e room_type, int game_times, int creator_regi
|
||||
init_info.room_type = room_type;
|
||||
init_info.creator_game_times = game_times;
|
||||
init_info.creator_register_time = creator_register_time;
|
||||
init_info.force_entry_newbie_room = force_entry_newbie_room;
|
||||
if (GetRoomByUuid(init_info.room_uuid)) {
|
||||
abort();
|
||||
}
|
||||
@ -487,23 +486,3 @@ bool RoomMgr::IsGM(const cs::CMJoin& msg)
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RoomMgr::AddProtectTeam(const std::string& team_uuid)
|
||||
{
|
||||
protect_team_hash_[team_uuid] = 1;
|
||||
a8::Timer::Instance()->AddDeadLineTimer
|
||||
(
|
||||
1000 * 30,
|
||||
a8::XParams()
|
||||
.SetSender(team_uuid),
|
||||
[] (const a8::XParams& param)
|
||||
{
|
||||
RoomMgr::Instance()->protect_team_hash_.erase(param.sender.GetString());
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
bool RoomMgr::IsProtectTeam(const std::string& team_uuid)
|
||||
{
|
||||
return protect_team_hash_.find(team_uuid) != protect_team_hash_.end();
|
||||
}
|
||||
|
@ -29,8 +29,6 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
Room* GetRoomByUuid(long long uuid);
|
||||
void AddOverRoom(long long room_uuid);
|
||||
bool IsGM(const cs::CMJoin& msg);
|
||||
void AddProtectTeam(const std::string& team_uuid);
|
||||
bool IsProtectTeam(const std::string& team_uuid);
|
||||
|
||||
private:
|
||||
void InstallReportStateTimer();
|
||||
@ -38,13 +36,17 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
Room* GetJoinableRoom(const cs::CMJoin& msg,
|
||||
const RoomType_e self_room_type,
|
||||
int game_times,
|
||||
int creator_register_time);
|
||||
int creator_register_time,
|
||||
bool force_entry_newbie_room);
|
||||
void ReportServerState(int instance_id, const std::string& host, int port);
|
||||
void FreeOverRoom(long long room_uuid);
|
||||
bool IsLimitJoin();
|
||||
|
||||
int AllocRoomIdx();
|
||||
Room* CreateRoom(RoomType_e room_type, int game_times, int creator_register_time);
|
||||
Room* CreateRoom(RoomType_e room_type,
|
||||
int game_times,
|
||||
int creator_register_time,
|
||||
bool force_entry_newbie_room);
|
||||
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
|
||||
|
||||
private:
|
||||
@ -56,5 +58,4 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
std::map<long long, Room*> over_room_hash_;
|
||||
a8::TimerAttacher reportstate_timer_attacher_;
|
||||
std::map<std::string, int> gm_hash_;
|
||||
std::map<std::string, int> protect_team_hash_;
|
||||
};
|
||||
|
@ -155,6 +155,7 @@ struct RoomInitInfo
|
||||
RoomType_e room_type = RT_NewBrid;
|
||||
int creator_game_times = 0;
|
||||
int creator_register_time = 0;
|
||||
bool force_entry_newbie_room = false;
|
||||
|
||||
const MetaData::Map* map_meta = nullptr;
|
||||
std::string map_tpl_name;
|
||||
|
@ -220,6 +220,7 @@ message RankPoint
|
||||
optional int32 rank = 1;
|
||||
optional int32 parameter = 2;
|
||||
optional int32 parameter2 = 3;
|
||||
optional int32 parameter3 = 4;
|
||||
}
|
||||
|
||||
message KillReward
|
||||
@ -246,6 +247,7 @@ message AI
|
||||
optional string random_move_idle_time = 8;
|
||||
optional string random_move_time = 9;
|
||||
optional int32 attack_range = 10;
|
||||
optional float attack_rate = 11;
|
||||
}
|
||||
|
||||
//end
|
||||
|
Loading…
x
Reference in New Issue
Block a user