添加游戏模式选择
This commit is contained in:
parent
0dab2c3071
commit
f7c5b46ed3
@ -22,6 +22,7 @@ class MapInstance
|
||||
void UnInit();
|
||||
|
||||
void AttachRoom(Room* room, RoomInitInfo& init_info);
|
||||
MetaData::Map* GetMapMeta() { return map_meta_; }
|
||||
|
||||
private:
|
||||
void CreateThings();
|
||||
|
@ -8,23 +8,30 @@
|
||||
|
||||
void MapMgr::Init()
|
||||
{
|
||||
{
|
||||
MapInstance* map_instance = new MapInstance();
|
||||
map_instance->map_id = 2001;
|
||||
map_instance->Init();
|
||||
instance_hash_[map_instance->map_id] = map_instance;
|
||||
std::list<MetaData::Map>* maps = MetaMgr::Instance()->GetMaps();
|
||||
if (maps) {
|
||||
for (auto& map_meta : *maps) {
|
||||
MapInstance* map_instance = new MapInstance();
|
||||
map_instance->map_id = map_meta.i->map_id();
|
||||
map_instance->Init();
|
||||
instance_hash_[map_instance->map_id] = map_instance;
|
||||
{
|
||||
auto itr = mode_hash_.find(map_meta.i->map_mode());
|
||||
if (itr != mode_hash_.end()) {
|
||||
itr->second.push_back(map_instance);
|
||||
} else {
|
||||
mode_hash_[map_meta.i->map_mode()] = std::vector<MapInstance*>({map_instance});
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
abort();
|
||||
}
|
||||
if (MetaMgr::Instance()->GetMap(3001)) {
|
||||
MapInstance* map_instance = new MapInstance();
|
||||
map_instance->map_id = 3001;
|
||||
map_instance->Init();
|
||||
instance_hash_[map_instance->map_id] = map_instance;
|
||||
if (mode_hash_.find(kZombieMode) == mode_hash_.end()) {
|
||||
abort();
|
||||
}
|
||||
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;
|
||||
if (mode_hash_.find(kChiJiMode) == mode_hash_.end()) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,19 +46,14 @@ void MapMgr::UnInit()
|
||||
|
||||
void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info)
|
||||
{
|
||||
MapInstance* map_instance = GetMapInstance(2001);
|
||||
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);
|
||||
}
|
||||
}
|
||||
MapInstance* map_instance = init_info.init_map_id == 0 ?
|
||||
RandMapInstance(init_info.room_mode) : GetMapInstance(init_info.init_map_id);
|
||||
if (!map_instance) {
|
||||
map_instance = RandMapInstance(init_info.room_mode);
|
||||
} else if (map_instance->GetMapMeta()->i->map_mode() != init_info.room_mode) {
|
||||
map_instance = RandMapInstance(init_info.room_mode);
|
||||
}
|
||||
|
||||
if (!map_instance) {
|
||||
abort();
|
||||
}
|
||||
@ -63,3 +65,9 @@ MapInstance* MapMgr::GetMapInstance(int map_id)
|
||||
auto itr = instance_hash_.find(map_id);
|
||||
return itr != instance_hash_.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
MapInstance* MapMgr::RandMapInstance(int map_mode)
|
||||
{
|
||||
auto itr = mode_hash_.find(map_mode);
|
||||
return itr != mode_hash_.end() ? itr->second[rand() % itr->second.size()] : nullptr;
|
||||
}
|
||||
|
@ -16,7 +16,9 @@ public:
|
||||
|
||||
private:
|
||||
MapInstance* GetMapInstance(int map_id);
|
||||
MapInstance* RandMapInstance(int map_mode);
|
||||
|
||||
private:
|
||||
std::map<int, MapInstance*> instance_hash_;
|
||||
std::map<int, std::vector<MapInstance*>> mode_hash_;
|
||||
};
|
||||
|
@ -38,6 +38,44 @@ namespace MetaData
|
||||
airdrops.push_back(a8::XValue(str).GetInt());
|
||||
}
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
a8::Split(i->refresh_robot(), strings, '|');
|
||||
if (strings.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(strings[0], strings2, '-');
|
||||
if (strings2.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
refresh_robot_min_num = a8::XValue(strings2[0]);
|
||||
refresh_robot_max_num = a8::XValue(strings2[1]);
|
||||
}
|
||||
{
|
||||
std::vector<std::string> strings2;
|
||||
a8::Split(strings[1], strings2, '-');
|
||||
if (strings2.size() != 2) {
|
||||
abort();
|
||||
}
|
||||
refresh_robot_min_time = a8::XValue(strings2[0]);
|
||||
refresh_robot_max_time = a8::XValue(strings2[1]);
|
||||
}
|
||||
if (refresh_robot_min_num >= refresh_robot_max_num) {
|
||||
abort();
|
||||
}
|
||||
if (refresh_robot_min_time >= refresh_robot_max_time) {
|
||||
abort();
|
||||
}
|
||||
if (refresh_robot_min_num <= 0 || refresh_robot_max_num <= 0 ||
|
||||
refresh_robot_min_time <= 0 || refresh_robot_max_time <= 0) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
if (i->player() < 20) {
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
std::string Map::RandTemplate()
|
||||
|
@ -23,6 +23,10 @@ namespace MetaData
|
||||
std::vector<std::tuple<std::string, int>> template_list;
|
||||
int rand_space = 0;
|
||||
std::vector<int> airdrops;
|
||||
int refresh_robot_min_num = 0;
|
||||
int refresh_robot_max_num = 0;
|
||||
int refresh_robot_min_time = 0;
|
||||
int refresh_robot_max_time = 0;
|
||||
|
||||
void Init();
|
||||
std::string RandTemplate();
|
||||
|
@ -339,10 +339,12 @@ public:
|
||||
METAMGR_READ(level1room_robot_autodie_distance, 500);
|
||||
METAMGR_READ_STR(level1room_born_point, "");
|
||||
|
||||
#if 0
|
||||
METAMGR_READ(refresh_robot_min_num, 5);
|
||||
METAMGR_READ(refresh_robot_max_num, 10);
|
||||
METAMGR_READ(refresh_robot_min_time, 5);
|
||||
METAMGR_READ(refresh_robot_max_time, 10);
|
||||
#endif
|
||||
}
|
||||
if (MetaMgr::Instance()->K < 0.01f) {
|
||||
abort();
|
||||
@ -406,6 +408,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
{
|
||||
if (MetaMgr::Instance()->refresh_robot_min_num >
|
||||
MetaMgr::Instance()->refresh_robot_max_num) {
|
||||
@ -416,6 +419,7 @@ private:
|
||||
abort();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void BindToMetaData()
|
||||
@ -667,6 +671,11 @@ MetaData::Map* MetaMgr::GetMap(int map_id)
|
||||
return itr != loader_->gamemap_hash.end() ? itr->second : nullptr;
|
||||
}
|
||||
|
||||
std::list<MetaData::Map>* MetaMgr::GetMaps()
|
||||
{
|
||||
return &loader_->map_list;
|
||||
}
|
||||
|
||||
MetaData::MapThing* MetaMgr::GetMapThing(int mapthing_id)
|
||||
{
|
||||
auto itr = loader_->mapthing_hash.find(mapthing_id);
|
||||
|
@ -20,6 +20,7 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
double GetSysParamAsFloat(const std::string& param_name, double def_val = 0.0f);
|
||||
std::string GetSysParamAsString(const std::string& param_name, const char* def_val = "");
|
||||
MetaData::Map* GetMap(int map_id);
|
||||
std::list<MetaData::Map>* GetMaps();
|
||||
MetaData::MapThing* GetMapThing(int mapthing_id);
|
||||
MetaData::Player* GetPlayer(int id);
|
||||
MetaData::Equip* GetEquip(int id);
|
||||
@ -120,10 +121,12 @@ class MetaMgr : public a8::Singleton<MetaMgr>
|
||||
int level1room_robot_autodie_distance = 0;
|
||||
std::string level1room_born_point;
|
||||
|
||||
#if 0
|
||||
int refresh_robot_min_num = 0;
|
||||
int refresh_robot_max_num = 0;
|
||||
int refresh_robot_min_time = 0;
|
||||
int refresh_robot_max_time = 0;
|
||||
#endif
|
||||
|
||||
int other_fill_interval = 0;
|
||||
float android_attack_range = 0;
|
||||
|
@ -28,8 +28,10 @@
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
|
||||
#if 0
|
||||
const size_t NORMAL_ROOM_MAX_PLAYER_NUM = 40;
|
||||
const size_t MINI_ROOM_MAX_PLAYER_NUM = 20;
|
||||
#endif
|
||||
|
||||
const int SHUA_RANGE = 580;
|
||||
|
||||
@ -228,10 +230,10 @@ void Room::ShuaAndroid()
|
||||
if (gas_data_.gas_mode != GasInactive) {
|
||||
return;
|
||||
}
|
||||
int robot_num = a8::RandEx(MetaMgr::Instance()->refresh_robot_min_num,
|
||||
MetaMgr::Instance()->refresh_robot_max_num);
|
||||
int refresh_time = a8::RandEx(MetaMgr::Instance()->refresh_robot_min_time,
|
||||
MetaMgr::Instance()->refresh_robot_max_time);
|
||||
int robot_num = a8::RandEx(map_meta_->refresh_robot_min_num,
|
||||
map_meta_->refresh_robot_max_num);
|
||||
int refresh_time = a8::RandEx(map_meta_->refresh_robot_min_time,
|
||||
map_meta_->refresh_robot_max_time);
|
||||
if (robot_num > 0 && refresh_time > 0) {
|
||||
if (IsMiniRoom()) {
|
||||
#if 0
|
||||
@ -742,16 +744,6 @@ bool Room::CanJoin(const std::string& accountid,
|
||||
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;
|
||||
}
|
||||
@ -3323,6 +3315,9 @@ int Room::GetOnlinePlayerNum()
|
||||
|
||||
size_t Room::GetRoomMaxPlayerNum()
|
||||
{
|
||||
#if 1
|
||||
return map_meta_->i->player();
|
||||
#else
|
||||
if (room_mode_ == kZombieMode) {
|
||||
return MetaMgr::Instance()->zbmode_player_num;
|
||||
} else {
|
||||
@ -3332,6 +3327,7 @@ size_t Room::GetRoomMaxPlayerNum()
|
||||
return NORMAL_ROOM_MAX_PLAYER_NUM;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Room::InitAndroidAI()
|
||||
|
@ -266,7 +266,8 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||
game_times,
|
||||
creator_register_time,
|
||||
proto_version,
|
||||
channel);
|
||||
channel,
|
||||
msg.map_id());
|
||||
}
|
||||
if (self_room_type == RT_MidBrid) {
|
||||
return CreateRoom(msg,
|
||||
@ -274,7 +275,8 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||
game_times,
|
||||
creator_register_time,
|
||||
proto_version,
|
||||
channel);
|
||||
channel,
|
||||
msg.map_id());
|
||||
}
|
||||
for (int i = 0; i < RT_Max; ++i) {
|
||||
for (Room* room : group_rooms[i]) {
|
||||
@ -288,7 +290,8 @@ Room* RoomMgr::GetJoinableRoom(const cs::CMJoin& msg,
|
||||
game_times,
|
||||
creator_register_time,
|
||||
proto_version,
|
||||
channel);
|
||||
channel,
|
||||
msg.map_id());
|
||||
}
|
||||
|
||||
Room* RoomMgr::GetRoomByUuid(long long room_uuid)
|
||||
@ -468,7 +471,8 @@ Room* RoomMgr::CreateRoom(const cs::CMJoin& msg,
|
||||
int game_times,
|
||||
int creator_register_time,
|
||||
int creator_proto_version,
|
||||
int creator_channel)
|
||||
int creator_channel,
|
||||
int map_id)
|
||||
{
|
||||
int room_idx = AllocRoomIdx();
|
||||
if (room_idx < 1) {
|
||||
@ -480,6 +484,7 @@ Room* RoomMgr::CreateRoom(const cs::CMJoin& msg,
|
||||
init_info.room_uuid = App::Instance()->NewUuid();
|
||||
init_info.room_type = room_type;
|
||||
init_info.room_mode = (RoomMode_e)msg.room_mode();
|
||||
init_info.init_map_id = map_id;
|
||||
init_info.creator_game_times = game_times;
|
||||
init_info.creator_register_time = creator_register_time;
|
||||
init_info.creator_proto_version = creator_proto_version;
|
||||
|
@ -51,7 +51,8 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
int game_times,
|
||||
int creator_register_time,
|
||||
int creator_proto_version,
|
||||
int creator_channel);
|
||||
int creator_channel,
|
||||
int map_id);
|
||||
void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle);
|
||||
std::string GenTeamHashData(const std::string& team_uuid, std::map<std::string, long long>* team_hash);
|
||||
void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum);
|
||||
|
@ -164,6 +164,7 @@ struct RoomInitInfo
|
||||
int creator_proto_version = 0;
|
||||
int creator_channel = 0;
|
||||
bool force_entry_newbie_room = false;
|
||||
int init_map_id = 0;
|
||||
|
||||
const MetaData::Map* map_meta = nullptr;
|
||||
std::string map_tpl_name;
|
||||
|
@ -754,6 +754,7 @@ message CMJoin
|
||||
optional bool force_entry_newbie_room = 50; //是否强制进新手房
|
||||
repeated MFTeamMember team_members = 51; //包括自己
|
||||
optional int32 room_mode = 52; //0:吃鸡模式 1:僵尸模式
|
||||
optional int32 map_id = 53; //地图id 0:随机地图
|
||||
}
|
||||
|
||||
//断线重连
|
||||
|
@ -28,6 +28,9 @@ message Map
|
||||
optional float map_height = 5;
|
||||
optional string airdrops = 6;
|
||||
optional int32 terminator_airdrop = 7;
|
||||
optional int32 player = 8;
|
||||
optional string refresh_robot = 9;
|
||||
optional int32 map_mode = 10;
|
||||
}
|
||||
|
||||
message MapThing
|
||||
|
Loading…
x
Reference in New Issue
Block a user