diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index f7b37fd..e407b20 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -322,6 +322,11 @@ enum ColliderTag_e kHalfWallTag = 1 }; +enum GameChannel_e +{ + kWxChannelId = 6001 +}; + const char* const PROJ_NAME_FMT = "game%d_gameserver"; const char* const PROJ_ROOT_FMT = "/data/logs/%s"; diff --git a/server/gameserver/mapmgr.cc b/server/gameserver/mapmgr.cc index 9ab4411..8a30e4e 100644 --- a/server/gameserver/mapmgr.cc +++ b/server/gameserver/mapmgr.cc @@ -4,6 +4,7 @@ #include "room.h" #include "mapinstance.h" #include "metamgr.h" +#include "cs_proto.pb.h" void MapMgr::Init() { @@ -40,7 +41,12 @@ void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info) { MapInstance* map_instance = GetMapInstance(2001); if (init_info.room_mode == kZombieMode) { - map_instance = GetMapInstance(3001); + if (init_info.creator_channel == kWxChannelId && + init_info.creator_proto_version == cs::ProtoVersion) { + map_instance = GetMapInstance(4001); + } else { + map_instance = GetMapInstance(3001); + } } if (!map_instance) { abort(); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index a3fe5d3..e26e8da 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -52,6 +52,8 @@ 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; + creator_proto_version_ = init_info.creator_proto_version; + creator_channel_ = init_info.creator_channel; force_entry_newbie_room_ = init_info.force_entry_newbie_room; map_tpl_name_ = init_info.map_tpl_name; @@ -736,8 +738,20 @@ int Room::GetAliveTeamNum() bool Room::CanJoin(const std::string& accountid, 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) { self_room_mode = kChiJiMode; } diff --git a/server/gameserver/room.h b/server/gameserver/room.h index db5ab31..b25439d 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -111,7 +111,9 @@ public: std::set* GetAliveTeam(); bool CanJoin(const std::string& accountid, 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); Entity* FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aabb_box); void FindLocationWithAabb(Entity* target, const a8::Vec2& aabb_pos, AabbCollider* aabb_box, @@ -266,6 +268,8 @@ private: bool show_handed_ = false; int creator_game_times_ = 0; int creator_register_time_ = 0; + int creator_proto_version_ = 0; + int creator_channel_ = 0; bool force_entry_newbie_room_ = false; xtimer_list* battle_report_timer_ = nullptr; bool sent_terminator_airdrop = false; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 22d17be..07f0a27 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -139,10 +139,14 @@ 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()); + int proto_version = msg.proto_version(); + int channel = f8::ExtractChannelIdFromAccountId(msg.account_id()); Room* room = GetJoinableRoom(msg, self_room_type, game_times, - register_time + register_time, + proto_version, + channel ); if (!room) { JoinErrorHandle(msg, 3, hdr.socket_handle); @@ -220,7 +224,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, + int proto_version, + int channel ) { std::vector> group_rooms; @@ -229,7 +235,11 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, } for (auto& pair : inactive_room_hash_) { 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())) { return room; } @@ -244,13 +254,17 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, return CreateRoom(msg, self_room_type, game_times, - creator_register_time); + creator_register_time, + proto_version, + channel); } if (self_room_type == RT_MidBrid) { return CreateRoom(msg, self_room_type, game_times, - creator_register_time); + creator_register_time, + proto_version, + channel); } for (int i = 0; i < RT_Max; ++i) { for (Room* room : group_rooms[i]) { @@ -262,7 +276,9 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg, return CreateRoom(msg, self_room_type, game_times, - creator_register_time); + creator_register_time, + proto_version, + channel); } Room* RoomMgr::GetRoomByUuid(long long room_uuid) @@ -439,7 +455,9 @@ int RoomMgr::AllocRoomIdx() Room* RoomMgr::CreateRoom(const cs::CMJoin& msg, RoomType_e room_type, int game_times, - int creator_register_time) + int creator_register_time, + int creator_proto_version, + int creator_channel) { int room_idx = AllocRoomIdx(); if (room_idx < 1) { @@ -453,6 +471,8 @@ Room* RoomMgr::CreateRoom(const cs::CMJoin& msg, init_info.room_mode = (RoomMode_e)msg.room_mode(); init_info.creator_game_times = game_times; 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(); if (GetRoomByUuid(init_info.room_uuid)) { abort(); diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 84b4b47..f571b6e 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -38,7 +38,9 @@ class RoomMgr : public a8::Singleton Room* GetJoinableRoom(const cs::CMJoin& msg, const RoomType_e self_room_type, 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 FreeOverRoom(long long room_uuid); bool IsLimitJoin(); @@ -47,7 +49,9 @@ class RoomMgr : public a8::Singleton Room* CreateRoom(const cs::CMJoin& msg, RoomType_e room_type, 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); private: diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 5b6f177..f27ac6c 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -160,6 +160,8 @@ struct RoomInitInfo RoomType_e room_type = RT_NewBrid; int creator_game_times = 0; int creator_register_time = 0; + int creator_proto_version = 0; + int creator_channel = 0; bool force_entry_newbie_room = false; const MetaData::Map* map_meta = nullptr; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 7208242..26d3cc9 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -50,7 +50,7 @@ package cs; //常量 enum Constant_e { - ProtoVersion = 2019071501; //系统版本 + ProtoVersion = 2020081401; //系统版本 } //心跳