merge master
This commit is contained in:
commit
f30bf003ad
@ -166,6 +166,7 @@ enum HumanAttrType_e
|
|||||||
kHAT_FireRate = 9,
|
kHAT_FireRate = 9,
|
||||||
kHAT_Volume = 10,
|
kHAT_Volume = 10,
|
||||||
kHAT_MaxHp = 11,
|
kHAT_MaxHp = 11,
|
||||||
|
kHAT_ReloadTime = 14,
|
||||||
kHAT_BulletAngle = 20,
|
kHAT_BulletAngle = 20,
|
||||||
kHAT_End
|
kHAT_End
|
||||||
};
|
};
|
||||||
@ -321,6 +322,11 @@ enum ColliderTag_e
|
|||||||
kHalfWallTag = 1
|
kHalfWallTag = 1
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum GameChannel_e
|
||||||
|
{
|
||||||
|
kWxChannelId = 6001
|
||||||
|
};
|
||||||
|
|
||||||
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
const char* const PROJ_NAME_FMT = "game%d_gameserver";
|
||||||
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
const char* const PROJ_ROOT_FMT = "/data/logs/%s";
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ void HandlerMgr::RegisterNetMsgHandlers()
|
|||||||
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_WSP_SocketDisconnect);
|
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_WSP_SocketDisconnect);
|
||||||
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_Ping);
|
RegisterNetMsgHandler(&ggmsghandler, &PlayerMgr::_SS_Ping);
|
||||||
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMJoin);
|
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMJoin);
|
||||||
|
RegisterNetMsgHandler(&ggmsghandler, &RoomMgr::_CMReconnect);
|
||||||
|
|
||||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
|
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMMove);
|
||||||
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMEmote);
|
RegisterNetMsgHandler(&ggmsghandler, &Player::_CMEmote);
|
||||||
|
@ -135,7 +135,12 @@ void Human::Initialize()
|
|||||||
RecalcSelfCollider();
|
RecalcSelfCollider();
|
||||||
volume_ = meta->volume;
|
volume_ = meta->volume;
|
||||||
observers_.insert(this);
|
observers_.insert(this);
|
||||||
ability.hp = meta->i->health() + (spec_weapon.meta ? spec_weapon.GetAttrValue(kHAT_MaxHp) : 0);
|
ability.hp = meta->i->health();
|
||||||
|
for (auto& weapon : spec_weapons) {
|
||||||
|
if (weapon.meta) {
|
||||||
|
ability.hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float Human::GetSpeed()
|
float Human::GetSpeed()
|
||||||
@ -829,7 +834,7 @@ void Human::AutoLoadingBullet(bool manual)
|
|||||||
on_loading_bullet();
|
on_loading_bullet();
|
||||||
}
|
}
|
||||||
StartAction(AT_Reload,
|
StartAction(AT_Reload,
|
||||||
p_weapon->meta->i->reload_time(),
|
p_weapon->GetAttrValue(kHAT_ReloadTime),
|
||||||
p_weapon->weapon_id,
|
p_weapon->weapon_id,
|
||||||
p_weapon->weapon_idx);
|
p_weapon->weapon_idx);
|
||||||
}
|
}
|
||||||
@ -848,6 +853,7 @@ void Human::StartAction(ActionType_e action_type,
|
|||||||
this->action_target_id == target_id) {
|
this->action_target_id == target_id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
action_duration = std::max(0, action_duration);
|
||||||
this->action_type = action_type;
|
this->action_type = action_type;
|
||||||
this->action_frameno = room->GetFrameNo();
|
this->action_frameno = room->GetFrameNo();
|
||||||
this->action_duration = action_duration;
|
this->action_duration = action_duration;
|
||||||
@ -3950,7 +3956,12 @@ void Human::OnMetaChange()
|
|||||||
curr_weapon = &weapons[0];
|
curr_weapon = &weapons[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ability.hp = meta->i->health() + (spec_weapon.meta ? spec_weapon.GetAttrValue(kHAT_MaxHp) : 0);
|
ability.hp = meta->i->health();
|
||||||
|
for (auto& weapon : spec_weapons) {
|
||||||
|
if (weapon.meta) {
|
||||||
|
ability.hp += weapon.meta ? weapon.GetAttrValue(kHAT_MaxHp) : 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
room->frame_event.AddHpChg(this);
|
room->frame_event.AddHpChg(this);
|
||||||
RecalcBaseAttr();
|
RecalcBaseAttr();
|
||||||
skill_meta_ = MetaMgr::Instance()->GetSkill(meta->i->active_skill());
|
skill_meta_ = MetaMgr::Instance()->GetSkill(meta->i->active_skill());
|
||||||
|
@ -129,7 +129,7 @@ class Human : public MoveableEntity
|
|||||||
|
|
||||||
long long send_msg_times = 0;
|
long long send_msg_times = 0;
|
||||||
|
|
||||||
Weapon spec_weapon;
|
std::list<Weapon> spec_weapons;
|
||||||
Weapon grow_weapon;
|
Weapon grow_weapon;
|
||||||
std::map<int, int> weapon_configs;
|
std::map<int, int> weapon_configs;
|
||||||
std::map<int, int> skin_configs;
|
std::map<int, int> skin_configs;
|
||||||
|
@ -34,6 +34,7 @@ void JsonDataMgr::Init()
|
|||||||
gameserver_cluster_json_.ReadFromFile(gameserver_cluster_json_file);
|
gameserver_cluster_json_.ReadFromFile(gameserver_cluster_json_file);
|
||||||
ip = GetConf()->At("ip")->AsXValue().GetString();
|
ip = GetConf()->At("ip")->AsXValue().GetString();
|
||||||
listen_port = GetConf()->At("listen_port")->AsXValue();
|
listen_port = GetConf()->At("listen_port")->AsXValue();
|
||||||
|
server_info = a8::Format("%s:%d", {ip, listen_port});
|
||||||
Reload();
|
Reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@ public:
|
|||||||
std::string ip;
|
std::string ip;
|
||||||
int listen_port = 0;
|
int listen_port = 0;
|
||||||
|
|
||||||
|
std::string server_info;
|
||||||
|
|
||||||
void Reload();
|
void Reload();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -46,4 +46,5 @@ void Loot::FillMFObjectFull(Room* room, Human* hum, cs::MFObjectFull* full_data)
|
|||||||
|
|
||||||
p->set_item_id(item_id);
|
p->set_item_id(item_id);
|
||||||
p->set_count(count);
|
p->set_count(count);
|
||||||
|
p->set_item_level(item_level);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "room.h"
|
#include "room.h"
|
||||||
#include "mapinstance.h"
|
#include "mapinstance.h"
|
||||||
#include "metamgr.h"
|
#include "metamgr.h"
|
||||||
|
#include "cs_proto.pb.h"
|
||||||
|
|
||||||
void MapMgr::Init()
|
void MapMgr::Init()
|
||||||
{
|
{
|
||||||
@ -19,6 +20,12 @@ void MapMgr::Init()
|
|||||||
map_instance->Init();
|
map_instance->Init();
|
||||||
instance_hash_[map_instance->map_id] = map_instance;
|
instance_hash_[map_instance->map_id] = map_instance;
|
||||||
}
|
}
|
||||||
|
if (MetaMgr::Instance()->GetMap(4001)) {
|
||||||
|
MapInstance* map_instance = new MapInstance();
|
||||||
|
map_instance->map_id = 4001;
|
||||||
|
map_instance->Init();
|
||||||
|
instance_hash_[map_instance->map_id] = map_instance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapMgr::UnInit()
|
void MapMgr::UnInit()
|
||||||
@ -34,8 +41,17 @@ void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info)
|
|||||||
{
|
{
|
||||||
MapInstance* map_instance = GetMapInstance(2001);
|
MapInstance* map_instance = GetMapInstance(2001);
|
||||||
if (init_info.room_mode == kZombieMode) {
|
if (init_info.room_mode == kZombieMode) {
|
||||||
|
if (init_info.creator_channel == kWxChannelId &&
|
||||||
|
init_info.creator_proto_version == cs::ProtoVersion) {
|
||||||
|
map_instance = GetMapInstance(4001);
|
||||||
|
} else {
|
||||||
|
if (init_info.creator_proto_version == cs::ProtoVersion) {
|
||||||
|
map_instance = GetMapInstance(4001);
|
||||||
|
} else {
|
||||||
map_instance = GetMapInstance(3001);
|
map_instance = GetMapInstance(3001);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!map_instance) {
|
if (!map_instance) {
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
#include "metadata.h"
|
#include "metadata.h"
|
||||||
#include "metamgr.h"
|
#include "metamgr.h"
|
||||||
|
|
||||||
|
#include "framework/cpp/utils.h"
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
void Parameter::Init()
|
void Parameter::Init()
|
||||||
@ -102,7 +104,11 @@ namespace MetaData
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::vector<std::string> strings;
|
std::vector<std::string> strings;
|
||||||
|
if (!i->spera_type().empty()) {
|
||||||
|
a8::Split(i->spera_type(), strings, '|');
|
||||||
|
} else {
|
||||||
a8::Split(i->attr_type(), strings, '|');
|
a8::Split(i->attr_type(), strings, '|');
|
||||||
|
}
|
||||||
int level = 1;
|
int level = 1;
|
||||||
for (auto& str : strings) {
|
for (auto& str : strings) {
|
||||||
if (str.empty()) {
|
if (str.empty()) {
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
#include "typeconvert.h"
|
#include "typeconvert.h"
|
||||||
#include "playermgr.h"
|
#include "playermgr.h"
|
||||||
#include "perfmonitor.h"
|
#include "perfmonitor.h"
|
||||||
|
#include "jsondatamgr.h"
|
||||||
|
|
||||||
const int kREVIVE_BUFF_ID = 1005;
|
const int kREVIVE_BUFF_ID = 1005;
|
||||||
|
|
||||||
@ -872,22 +873,24 @@ void Player::ProcPrepareItems(const ::google::protobuf::RepeatedField< ::google:
|
|||||||
curr_weapon->ammo = add_num;
|
curr_weapon->ammo = add_num;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (spec_weapon.weapon_id != 0) {
|
for (auto& spec_weapon : spec_weapons) {
|
||||||
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(spec_weapon.weapon_id);
|
MetaData::Equip* item_meta = MetaMgr::Instance()->GetEquip(spec_weapon.weapon_id);
|
||||||
if (item_meta &&
|
if (item_meta &&
|
||||||
item_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
|
item_meta->i->equip_type() == EQUIP_TYPE_WEAPON) {
|
||||||
if (item_meta->i->equip_subtype() != 1) {
|
if (item_meta->i->equip_subtype() != 1) {
|
||||||
Weapon* weapon = &weapons[GUN_SLOT1];
|
int weapon_idx = GUN_SLOT1;
|
||||||
weapon->weapon_idx = GUN_SLOT1;
|
if (weapons[weapon_idx].weapon_id != 0) {
|
||||||
if (curr_weapon != &weapons[GUN_SLOT2]) {
|
weapon_idx = GUN_SLOT2;
|
||||||
curr_weapon = &weapons[GUN_SLOT1];
|
|
||||||
}
|
}
|
||||||
if (weapon) {
|
if (weapons[weapon_idx].weapon_id == 0) {
|
||||||
|
Weapon* weapon = &weapons[weapon_idx];
|
||||||
|
weapon->weapon_idx = weapon_idx;
|
||||||
weapon->weapon_id = spec_weapon.weapon_id;
|
weapon->weapon_id = spec_weapon.weapon_id;
|
||||||
weapon->weapon_lv = spec_weapon.weapon_lv;
|
weapon->weapon_lv = spec_weapon.weapon_lv;
|
||||||
weapon->ammo = spec_weapon.ammo;
|
weapon->ammo = spec_weapon.ammo;
|
||||||
weapon->meta = item_meta;
|
weapon->meta = item_meta;
|
||||||
weapon->Recalc();
|
weapon->Recalc();
|
||||||
|
curr_weapon = &weapons[GUN_SLOT1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -906,6 +909,36 @@ void Player::ProcPrepareItems2(const ::google::protobuf::RepeatedPtrField< cs::M
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
|
||||||
|
{
|
||||||
|
int old_socket_handle = socket_handle;
|
||||||
|
if (socket_handle != 0) {
|
||||||
|
GGListener::Instance()->ForceCloseChildSocket(socket_handle);
|
||||||
|
PlayerMgr::Instance()->RemovePlayerBySocket(socket_handle);
|
||||||
|
}
|
||||||
|
socket_handle = hdr.socket_handle;
|
||||||
|
TouchAllLayerHumanList
|
||||||
|
(
|
||||||
|
[this] (Human* hum, bool& stop)
|
||||||
|
{
|
||||||
|
AddToNewObjects(hum);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
need_sync_active_player = true;
|
||||||
|
cs::SMReconnect respmsg;
|
||||||
|
respmsg.set_errcode(0);
|
||||||
|
respmsg.set_errmsg("战斗重连成功");
|
||||||
|
SendNotifyMsg(respmsg);
|
||||||
|
PlayerMgr::Instance()->ReBindSocket(this);
|
||||||
|
a8::UdpLog::Instance()->Debug
|
||||||
|
("战斗服重连成功 %s %d %d",
|
||||||
|
{
|
||||||
|
account_id,
|
||||||
|
hdr.socket_handle,
|
||||||
|
old_socket_handle
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
void Player::_CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg)
|
||||||
{
|
{
|
||||||
moving = false;
|
moving = false;
|
||||||
@ -1314,6 +1347,7 @@ void Player::PushJoinRoomMsg()
|
|||||||
cs::SMJoinedNotify notifymsg;
|
cs::SMJoinedNotify notifymsg;
|
||||||
notifymsg.set_error_code(0);
|
notifymsg.set_error_code(0);
|
||||||
notifymsg.set_room_mode((int)room->GetRoomMode());
|
notifymsg.set_room_mode((int)room->GetRoomMode());
|
||||||
|
notifymsg.set_server_info(JsonDataMgr::Instance()->server_info);
|
||||||
room->FillSMJoinedNotify(this, notifymsg);
|
room->FillSMJoinedNotify(this, notifymsg);
|
||||||
GGListener::Instance()->SendToClient(socket_handle, 0, notifymsg);
|
GGListener::Instance()->SendToClient(socket_handle, 0, notifymsg);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace cs
|
namespace cs
|
||||||
{
|
{
|
||||||
|
class CMReconnect;
|
||||||
class CMMove;
|
class CMMove;
|
||||||
class CMDropItem;
|
class CMDropItem;
|
||||||
class CMEmote;
|
class CMEmote;
|
||||||
@ -88,6 +89,7 @@ class Player : public Human
|
|||||||
void ProcPreSettlementInfo(const std::string& pre_settlement_info);
|
void ProcPreSettlementInfo(const std::string& pre_settlement_info);
|
||||||
void PushJoinRoomMsg();
|
void PushJoinRoomMsg();
|
||||||
|
|
||||||
|
void _CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg);
|
||||||
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
void _CMMove(f8::MsgHdr& hdr, const cs::CMMove& msg);
|
||||||
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
void _CMEmote(f8::MsgHdr& hdr, const cs::CMEmote& msg);
|
||||||
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
void _CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg);
|
||||||
|
@ -82,11 +82,12 @@ Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum,
|
|||||||
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(weapon.weapon_id());
|
MetaData::Equip* equip_meta = MetaMgr::Instance()->GetEquip(weapon.weapon_id());
|
||||||
if (equip_meta) {
|
if (equip_meta) {
|
||||||
hum->weapon_configs[weapon.weapon_id()] = weapon.weapon_lv();
|
hum->weapon_configs[weapon.weapon_id()] = weapon.weapon_lv();
|
||||||
hum->spec_weapon.weapon_id = weapon.weapon_id();
|
Weapon& spec_weapon = a8::FastAppend(hum->spec_weapons);
|
||||||
hum->spec_weapon.weapon_lv = weapon.weapon_lv();
|
spec_weapon.weapon_id = weapon.weapon_id();
|
||||||
hum->spec_weapon.ammo = weapon.ammo();
|
spec_weapon.weapon_lv = weapon.weapon_lv();
|
||||||
hum->spec_weapon.meta = equip_meta;
|
spec_weapon.ammo = weapon.ammo();
|
||||||
hum->spec_weapon.Recalc();
|
spec_weapon.meta = equip_meta;
|
||||||
|
spec_weapon.Recalc();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -194,3 +195,8 @@ void PlayerMgr::DecAccountNum(const std::string& account_id)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::ReBindSocket(Player* hum)
|
||||||
|
{
|
||||||
|
socket_hash_[hum->socket_handle] = hum;
|
||||||
|
}
|
||||||
|
@ -36,6 +36,7 @@ class PlayerMgr : public a8::Singleton<PlayerMgr>
|
|||||||
size_t GetAccountNum() { return account_num_hash_.size(); }
|
size_t GetAccountNum() { return account_num_hash_.size(); }
|
||||||
void IncAccountNum(const std::string& account_id);
|
void IncAccountNum(const std::string& account_id);
|
||||||
void DecAccountNum(const std::string& account_id);
|
void DecAccountNum(const std::string& account_id);
|
||||||
|
void ReBindSocket(Player* hum);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<int, Player*> socket_hash_;
|
std::map<int, Player*> socket_hash_;
|
||||||
|
@ -52,6 +52,8 @@ void Room::InitData(RoomInitInfo& init_info)
|
|||||||
room_type_ = init_info.room_type;
|
room_type_ = init_info.room_type;
|
||||||
creator_game_times_ = init_info.creator_game_times;
|
creator_game_times_ = init_info.creator_game_times;
|
||||||
creator_register_time_ = init_info.creator_register_time;
|
creator_register_time_ = init_info.creator_register_time;
|
||||||
|
creator_proto_version_ = init_info.creator_proto_version;
|
||||||
|
creator_channel_ = init_info.creator_channel;
|
||||||
force_entry_newbie_room_ = init_info.force_entry_newbie_room;
|
force_entry_newbie_room_ = init_info.force_entry_newbie_room;
|
||||||
|
|
||||||
map_tpl_name_ = init_info.map_tpl_name;
|
map_tpl_name_ = init_info.map_tpl_name;
|
||||||
@ -736,8 +738,20 @@ int Room::GetAliveTeamNum()
|
|||||||
|
|
||||||
bool Room::CanJoin(const std::string& accountid,
|
bool Room::CanJoin(const std::string& accountid,
|
||||||
RoomType_e self_room_type,
|
RoomType_e self_room_type,
|
||||||
RoomMode_e self_room_mode)
|
RoomMode_e self_room_mode,
|
||||||
|
int self_proto_version,
|
||||||
|
int self_channel)
|
||||||
{
|
{
|
||||||
|
#if 1
|
||||||
|
if (creator_channel_ == kWxChannelId) {
|
||||||
|
if (self_channel != creator_channel_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (self_proto_version != creator_proto_version_) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
if (self_room_mode < kChiJiMode) {
|
if (self_room_mode < kChiJiMode) {
|
||||||
self_room_mode = kChiJiMode;
|
self_room_mode = kChiJiMode;
|
||||||
}
|
}
|
||||||
@ -768,15 +782,21 @@ bool Room::CanJoin(const std::string& accountid,
|
|||||||
|
|
||||||
void Room::OnPlayerOffline(Player* hum)
|
void Room::OnPlayerOffline(Player* hum)
|
||||||
{
|
{
|
||||||
bool has_player = false;
|
if (GetOnlinePlayerNum() <= 0) {
|
||||||
for (auto& pair : accountid_hash_) {
|
xtimer.AddDeadLineTimerAndAttach
|
||||||
if (pair.second->socket_handle != 0) {
|
(
|
||||||
has_player = true;
|
SERVER_FRAME_RATE * 15,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(this),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
Room* room = (Room*)param.sender.GetUserData();
|
||||||
|
if (room->GetOnlinePlayerNum() <= 0 && !room->added_to_over_room) {
|
||||||
|
GameLog::Instance()->ForceOver(room);
|
||||||
|
RoomMgr::Instance()->AddOverRoom(room->room_uuid_);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
if (!has_player) {
|
&xtimer_attacher_.timer_list_);
|
||||||
GameLog::Instance()->ForceOver(this);
|
|
||||||
RoomMgr::Instance()->AddOverRoom(room_uuid_);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3295,6 +3315,17 @@ int Room::GetAliveCountByRace(RaceType_e race)
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Room::GetOnlinePlayerNum()
|
||||||
|
{
|
||||||
|
int num = 0;
|
||||||
|
for (auto& pair : accountid_hash_) {
|
||||||
|
if (pair.second->socket_handle != 0) {
|
||||||
|
++num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
size_t Room::GetRoomMaxPlayerNum()
|
size_t Room::GetRoomMaxPlayerNum()
|
||||||
{
|
{
|
||||||
if (room_mode_ == kZombieMode) {
|
if (room_mode_ == kZombieMode) {
|
||||||
|
@ -43,6 +43,7 @@ public:
|
|||||||
GridService* grid_service = nullptr;
|
GridService* grid_service = nullptr;
|
||||||
MapService* map_service = nullptr;
|
MapService* map_service = nullptr;
|
||||||
bool debug_trace = false;
|
bool debug_trace = false;
|
||||||
|
bool added_to_over_room = false;
|
||||||
|
|
||||||
~Room();
|
~Room();
|
||||||
void InitData(RoomInitInfo& init_info);
|
void InitData(RoomInitInfo& init_info);
|
||||||
@ -110,7 +111,9 @@ public:
|
|||||||
std::set<Human*>* GetAliveTeam();
|
std::set<Human*>* GetAliveTeam();
|
||||||
bool CanJoin(const std::string& accountid,
|
bool CanJoin(const std::string& accountid,
|
||||||
RoomType_e self_roomm_type,
|
RoomType_e self_roomm_type,
|
||||||
RoomMode_e self_room_mode);
|
RoomMode_e self_room_mode,
|
||||||
|
int self_proto_version,
|
||||||
|
int self_channel);
|
||||||
void OnPlayerOffline(Player* hum);
|
void OnPlayerOffline(Player* hum);
|
||||||
Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
|
Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box);
|
||||||
void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box,
|
void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box,
|
||||||
@ -142,6 +145,7 @@ public:
|
|||||||
void NotifySysPiao(const std::string& msg, int color, int duration);
|
void NotifySysPiao(const std::string& msg, int color, int duration);
|
||||||
void OnZombieAppear(Human* hum);
|
void OnZombieAppear(Human* hum);
|
||||||
int GetAliveCountByRace(RaceType_e race);
|
int GetAliveCountByRace(RaceType_e race);
|
||||||
|
int GetOnlinePlayerNum();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int AllocUniid();
|
int AllocUniid();
|
||||||
@ -264,6 +268,8 @@ private:
|
|||||||
bool show_handed_ = false;
|
bool show_handed_ = false;
|
||||||
int creator_game_times_ = 0;
|
int creator_game_times_ = 0;
|
||||||
int creator_register_time_ = 0;
|
int creator_register_time_ = 0;
|
||||||
|
int creator_proto_version_ = 0;
|
||||||
|
int creator_channel_ = 0;
|
||||||
bool force_entry_newbie_room_ = false;
|
bool force_entry_newbie_room_ = false;
|
||||||
xtimer_list* battle_report_timer_ = nullptr;
|
xtimer_list* battle_report_timer_ = nullptr;
|
||||||
bool sent_terminator_airdrop = false;
|
bool sent_terminator_airdrop = false;
|
||||||
|
@ -139,10 +139,14 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
int game_times = 0;
|
int game_times = 0;
|
||||||
RoomType_e self_room_type = GetHumanRoomType(msg, game_times);
|
RoomType_e self_room_type = GetHumanRoomType(msg, game_times);
|
||||||
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
|
time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id());
|
||||||
|
int proto_version = msg.proto_version();
|
||||||
|
int channel = f8::ExtractChannelIdFromAccountId(msg.account_id());
|
||||||
Room* room = GetJoinableRoom(msg,
|
Room* room = GetJoinableRoom(msg,
|
||||||
self_room_type,
|
self_room_type,
|
||||||
game_times,
|
game_times,
|
||||||
register_time
|
register_time,
|
||||||
|
proto_version,
|
||||||
|
channel
|
||||||
);
|
);
|
||||||
if (!room) {
|
if (!room) {
|
||||||
JoinErrorHandle(msg, 3, hdr.socket_handle);
|
JoinErrorHandle(msg, 3, hdr.socket_handle);
|
||||||
@ -164,6 +168,49 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
PlayerMgr::Instance()->IncAccountNum(msg.account_id());
|
PlayerMgr::Instance()->IncAccountNum(msg.account_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RoomMgr::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg)
|
||||||
|
{
|
||||||
|
auto send_reconnect_failed =
|
||||||
|
[] (int socket_handle, int errcode, const std::string& errmsg)
|
||||||
|
{
|
||||||
|
cs::SMReconnect respmsg;
|
||||||
|
respmsg.set_errcode(errcode);
|
||||||
|
respmsg.set_errmsg(errmsg);
|
||||||
|
GGListener::Instance()->SendToClient(socket_handle, 0, respmsg);
|
||||||
|
a8::Timer::Instance()->AddDeadLineTimer
|
||||||
|
(
|
||||||
|
1000 * 3,
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(socket_handle),
|
||||||
|
[] (const a8::XParams& param)
|
||||||
|
{
|
||||||
|
GGListener::Instance()->ForceCloseChildSocket(param.sender);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
Room* room = GetRoomByUuid(a8::XValue(msg.room_uuid()));
|
||||||
|
if (!room) {
|
||||||
|
send_reconnect_failed(hdr.socket_handle, 1, "房间已销毁");
|
||||||
|
a8::UdpLog::Instance()->Debug
|
||||||
|
("房间已销毁 %s",
|
||||||
|
{
|
||||||
|
msg.room_uuid()
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (room->GetRoomMode() != kChiJiMode) {
|
||||||
|
send_reconnect_failed(hdr.socket_handle, 1, "只有吃鸡模式支持重连");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player* hum = room->GetPlayerByAccountId(msg.account_id());
|
||||||
|
if (!hum) {
|
||||||
|
send_reconnect_failed(hdr.socket_handle, 1, "accountid未在房间列表");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hum->_CMReconnect(hdr, msg);
|
||||||
|
}
|
||||||
|
|
||||||
int RoomMgr::RoomNum()
|
int RoomMgr::RoomNum()
|
||||||
{
|
{
|
||||||
return room_hash_.size();
|
return room_hash_.size();
|
||||||
@ -177,7 +224,9 @@ int RoomMgr::OverRoomNum()
|
|||||||
Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||||
const RoomType_e self_room_type,
|
const RoomType_e self_room_type,
|
||||||
int game_times,
|
int game_times,
|
||||||
int creator_register_time
|
int creator_register_time,
|
||||||
|
int proto_version,
|
||||||
|
int channel
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
std::vector<std::vector<Room*>> group_rooms;
|
std::vector<std::vector<Room*>> group_rooms;
|
||||||
@ -186,7 +235,11 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
|||||||
}
|
}
|
||||||
for (auto& pair : inactive_room_hash_) {
|
for (auto& pair : inactive_room_hash_) {
|
||||||
Room* room = pair.second;
|
Room* room = pair.second;
|
||||||
if (room->CanJoin(msg.account_id(), self_room_type, (RoomMode_e)msg.room_mode())) {
|
if (room->CanJoin(msg.account_id(),
|
||||||
|
self_room_type,
|
||||||
|
(RoomMode_e)msg.room_mode(),
|
||||||
|
proto_version,
|
||||||
|
channel)) {
|
||||||
if (!msg.team_uuid().empty() && room->HaveMyTeam(msg.team_uuid())) {
|
if (!msg.team_uuid().empty() && room->HaveMyTeam(msg.team_uuid())) {
|
||||||
return room;
|
return room;
|
||||||
}
|
}
|
||||||
@ -201,13 +254,17 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
|||||||
return CreateRoom(msg,
|
return CreateRoom(msg,
|
||||||
self_room_type,
|
self_room_type,
|
||||||
game_times,
|
game_times,
|
||||||
creator_register_time);
|
creator_register_time,
|
||||||
|
proto_version,
|
||||||
|
channel);
|
||||||
}
|
}
|
||||||
if (self_room_type == RT_MidBrid) {
|
if (self_room_type == RT_MidBrid) {
|
||||||
return CreateRoom(msg,
|
return CreateRoom(msg,
|
||||||
self_room_type,
|
self_room_type,
|
||||||
game_times,
|
game_times,
|
||||||
creator_register_time);
|
creator_register_time,
|
||||||
|
proto_version,
|
||||||
|
channel);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < RT_Max; ++i) {
|
for (int i = 0; i < RT_Max; ++i) {
|
||||||
for (Room* room : group_rooms[i]) {
|
for (Room* room : group_rooms[i]) {
|
||||||
@ -219,7 +276,9 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
|||||||
return CreateRoom(msg,
|
return CreateRoom(msg,
|
||||||
self_room_type,
|
self_room_type,
|
||||||
game_times,
|
game_times,
|
||||||
creator_register_time);
|
creator_register_time,
|
||||||
|
proto_version,
|
||||||
|
channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
|
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
|
||||||
@ -250,6 +309,7 @@ void RoomMgr::AddOverRoom(long long room_uuid)
|
|||||||
inactive_room_hash_.erase(room_uuid);
|
inactive_room_hash_.erase(room_uuid);
|
||||||
Room* room = GetRoomByUuid(room_uuid);
|
Room* room = GetRoomByUuid(room_uuid);
|
||||||
if (room) {
|
if (room) {
|
||||||
|
room->added_to_over_room = true;
|
||||||
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
a8::Timer::Instance()->AddRepeatTimerAndAttach
|
||||||
(1000 * 5,
|
(1000 * 5,
|
||||||
a8::XParams()
|
a8::XParams()
|
||||||
@ -395,7 +455,9 @@ int RoomMgr::AllocRoomIdx()
|
|||||||
Room* RoomMgr::CreateRoom(const cs::CMJoin& msg,
|
Room* RoomMgr::CreateRoom(const cs::CMJoin& msg,
|
||||||
RoomType_e room_type,
|
RoomType_e room_type,
|
||||||
int game_times,
|
int game_times,
|
||||||
int creator_register_time)
|
int creator_register_time,
|
||||||
|
int creator_proto_version,
|
||||||
|
int creator_channel)
|
||||||
{
|
{
|
||||||
int room_idx = AllocRoomIdx();
|
int room_idx = AllocRoomIdx();
|
||||||
if (room_idx < 1) {
|
if (room_idx < 1) {
|
||||||
@ -409,6 +471,8 @@ Room* RoomMgr::CreateRoom(const cs::CMJoin& msg,
|
|||||||
init_info.room_mode = (RoomMode_e)msg.room_mode();
|
init_info.room_mode = (RoomMode_e)msg.room_mode();
|
||||||
init_info.creator_game_times = game_times;
|
init_info.creator_game_times = game_times;
|
||||||
init_info.creator_register_time = creator_register_time;
|
init_info.creator_register_time = creator_register_time;
|
||||||
|
init_info.creator_proto_version = creator_proto_version;
|
||||||
|
init_info.creator_channel = creator_channel;
|
||||||
init_info.force_entry_newbie_room = msg.force_entry_newbie_room();
|
init_info.force_entry_newbie_room = msg.force_entry_newbie_room();
|
||||||
if (GetRoomByUuid(init_info.room_uuid)) {
|
if (GetRoomByUuid(init_info.room_uuid)) {
|
||||||
abort();
|
abort();
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
namespace cs
|
namespace cs
|
||||||
{
|
{
|
||||||
class CMJoin;
|
class CMJoin;
|
||||||
|
class CMReconnect;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Room;
|
class Room;
|
||||||
@ -23,6 +24,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
void Update(int delta_time);
|
void Update(int delta_time);
|
||||||
|
|
||||||
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
|
void _CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg);
|
||||||
|
void _CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg);
|
||||||
void ActiveRoom(long long room_uuid);
|
void ActiveRoom(long long room_uuid);
|
||||||
int RoomNum();
|
int RoomNum();
|
||||||
int OverRoomNum();
|
int OverRoomNum();
|
||||||
@ -36,7 +38,9 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
Room* GetJoinableRoom(const cs::CMJoin& msg,
|
Room* GetJoinableRoom(const cs::CMJoin& msg,
|
||||||
const RoomType_e self_room_type,
|
const RoomType_e self_room_type,
|
||||||
int game_times,
|
int game_times,
|
||||||
int creator_register_time);
|
int creator_register_time,
|
||||||
|
int proto_version,
|
||||||
|
int channel);
|
||||||
void ReportServerState(int instance_id, const std::string& host, int port);
|
void ReportServerState(int instance_id, const std::string& host, int port);
|
||||||
void FreeOverRoom(long long room_uuid);
|
void FreeOverRoom(long long room_uuid);
|
||||||
bool IsLimitJoin();
|
bool IsLimitJoin();
|
||||||
@ -45,7 +49,9 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
Room* CreateRoom(const cs::CMJoin& msg,
|
Room* CreateRoom(const cs::CMJoin& msg,
|
||||||
RoomType_e room_type,
|
RoomType_e room_type,
|
||||||
int game_times,
|
int game_times,
|
||||||
int creator_register_time);
|
int creator_register_time,
|
||||||
|
int creator_proto_version,
|
||||||
|
int creator_channel);
|
||||||
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
|
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -57,6 +57,12 @@ float Weapon::GetAttrValue(HumanAttrType_e attr_type)
|
|||||||
(upgrade_meta ? upgrade_meta->GetAttrValue(weapon_lv, attr_type) : 0);
|
(upgrade_meta ? upgrade_meta->GetAttrValue(weapon_lv, attr_type) : 0);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case kHAT_ReloadTime:
|
||||||
|
{
|
||||||
|
return meta->i->reload_time() -
|
||||||
|
(upgrade_meta ? upgrade_meta->GetAttrValue(weapon_lv, attr_type) : 0);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -160,6 +160,8 @@ struct RoomInitInfo
|
|||||||
RoomType_e room_type = RT_NewBrid;
|
RoomType_e room_type = RT_NewBrid;
|
||||||
int creator_game_times = 0;
|
int creator_game_times = 0;
|
||||||
int creator_register_time = 0;
|
int creator_register_time = 0;
|
||||||
|
int creator_proto_version = 0;
|
||||||
|
int creator_channel = 0;
|
||||||
bool force_entry_newbie_room = false;
|
bool force_entry_newbie_room = false;
|
||||||
|
|
||||||
const MetaData::Map* map_meta = nullptr;
|
const MetaData::Map* map_meta = nullptr;
|
||||||
|
@ -50,7 +50,7 @@ package cs;
|
|||||||
//常量
|
//常量
|
||||||
enum Constant_e
|
enum Constant_e
|
||||||
{
|
{
|
||||||
ProtoVersion = 2019071501; //系统版本
|
ProtoVersion = 2020081401; //系统版本
|
||||||
}
|
}
|
||||||
|
|
||||||
//心跳
|
//心跳
|
||||||
@ -743,7 +743,9 @@ message CMReconnect
|
|||||||
optional int32 server_id = 1; //保留
|
optional int32 server_id = 1; //保留
|
||||||
optional string team_uuid = 2; //保留
|
optional string team_uuid = 2; //保留
|
||||||
optional string account_id = 3; //账号id
|
optional string account_id = 3; //账号id
|
||||||
optional string room_uuid = 4; //房间唯一id
|
optional string session_id = 4; //session_id
|
||||||
|
optional string room_uuid = 5; //房间唯一id
|
||||||
|
optional string server_info = 6; //服务器信息
|
||||||
}
|
}
|
||||||
|
|
||||||
//断线重连回复
|
//断线重连回复
|
||||||
@ -877,6 +879,8 @@ message SMJoinedNotify
|
|||||||
|
|
||||||
optional int32 error_code = 7; //错误 1:服务器维护中 2:服务器繁忙请稍后再进入
|
optional int32 error_code = 7; //错误 1:服务器维护中 2:服务器繁忙请稍后再进入
|
||||||
optional int32 room_mode = 8; //0:吃鸡模式 1:僵尸模式
|
optional int32 room_mode = 8; //0:吃鸡模式 1:僵尸模式
|
||||||
|
|
||||||
|
optional string server_info = 9; //服务器信息(重连时使用)
|
||||||
}
|
}
|
||||||
|
|
||||||
//地图信息
|
//地图信息
|
||||||
|
@ -104,6 +104,7 @@ message EquipUpgrade
|
|||||||
{
|
{
|
||||||
optional int32 id = 1;
|
optional int32 id = 1;
|
||||||
optional string attr_type = 4;
|
optional string attr_type = 4;
|
||||||
|
optional string spera_type = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
message Player
|
message Player
|
||||||
|
Loading…
x
Reference in New Issue
Block a user