添加微信渠道特殊处理

This commit is contained in:
aozhiwei 2020-08-14 19:21:59 +08:00
parent 04253a7d11
commit e2d0e4e430
8 changed files with 68 additions and 13 deletions

View File

@ -322,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";

View File

@ -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()
{ {
@ -40,7 +41,12 @@ 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) {
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) { if (!map_instance) {
abort(); abort();

View File

@ -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;
} }

View File

@ -111,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,
@ -266,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;

View File

@ -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);
@ -220,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;
@ -229,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;
} }
@ -244,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]) {
@ -262,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)
@ -439,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) {
@ -453,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();

View File

@ -38,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();
@ -47,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:

View File

@ -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;

View File

@ -50,7 +50,7 @@ package cs;
// //
enum Constant_e enum Constant_e
{ {
ProtoVersion = 2019071501; // ProtoVersion = 2020081401; //
} }
// //