This commit is contained in:
aozhiwei 2024-03-17 10:32:18 +08:00
parent 4b91640ad9
commit 0a50e4ae91
2 changed files with 16 additions and 19 deletions

View File

@ -1,8 +1,7 @@
#pragma once
const int CUSTOM_ROOM_PVP = 0;
const int CUSTOM_ROOM_MOBA = 1;
const int CUSTOM_ROOM_NORMAL = 2;
const int CUSTOM_ROOM_CUSTOM = 0;
const int CUSTOM_ROOM_NORMAL = 1;
class Room;
class CustomTeam;
@ -36,13 +35,16 @@ class CustomBattle
void TraverseTeamList(std::function<bool (std::shared_ptr<CustomTeam>)> cb);
void TraverseObList(std::function<bool (std::shared_ptr<CustomMember>)> cb);
void SetCustomRoomType(int custom_room_type) { custom_room_type_ = custom_room_type; }
bool IsPvp() { return custom_room_type_ == CUSTOM_ROOM_PVP; }
bool IsMoba() { return custom_room_type_ == CUSTOM_ROOM_MOBA; }
bool IsNormalMode() { return custom_room_type_ == CUSTOM_ROOM_NORMAL; }
bool IsCustomMode() { return custom_room_type_ == CUSTOM_ROOM_CUSTOM; }
bool IsPvp() { return !is_moba_; }
bool IsMoba() { return is_moba_; }
private:
bool parse_ok_ = false;
Room *room_ = nullptr;
int custom_room_type_ = CUSTOM_ROOM_PVP;
int custom_room_type_ = CUSTOM_ROOM_CUSTOM;
bool is_moba_ = false;
std::string room_id_;
std::string room_uuid_;
int zone_id_ = 0;

View File

@ -1084,11 +1084,11 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr<cs::CMJoin> join_msg,
{
std::string url;
JsonDataMgr::Instance()->GetApiUrl(url);
if (custom_room_type == CUSTOM_ROOM_MOBA) {
if (custom_room_type == CUSTOM_ROOM_CUSTOM) {
if (url.find('?') != std::string::npos) {
url += "&c=Battle&a=getMobaBattleData";
url += "&c=Battle&a=getCustomBattleDataNew";
} else {
url += "?&c=Battle&a=getMobaBattleData";
url += "?&c=Battle&a=getCustomBattleDataNew";
}
} else if (custom_room_type == CUSTOM_ROOM_NORMAL) {
if (url.find('?') != std::string::npos) {
@ -1096,13 +1096,8 @@ void RoomMgr::SendGetCustomBattleData(std::shared_ptr<cs::CMJoin> join_msg,
} else {
url += "?&c=Battle&a=getNormalBattleData";
}
} else {
if (url.find('?') != std::string::npos) {
url += "&c=Battle&a=getCustomBattleData";
} else {
url += "?&c=Battle&a=getCustomBattleData";
}
A8_ABORT();
}
auto url_params = a8::MutableXObject::CreateObject();
url_params->SetVal("account_id", join_msg->account_id());
@ -1183,14 +1178,14 @@ void RoomMgr::DispatchSpecRoom(f8::MsgHdr* hdr, const cs::CMJoin& msg)
a8::Split(head, strings, ':');
if (strings.size() > 1) {
if (strings.at(1) == "custom_room") {
_CMJoinCustomBattle(hdr, msg, CUSTOM_ROOM_PVP);
_CMJoinCustomBattle(hdr, msg, CUSTOM_ROOM_CUSTOM);
} else if (strings.at(1) == "normal_room") {
_CMJoinCustomBattle(hdr, msg, CUSTOM_ROOM_NORMAL);
} else if (strings.at(1) == "moba_room") {
_CMJoinCustomBattle(hdr, msg, CUSTOM_ROOM_MOBA);
} else {
A8_ABORT();
}
} else {
_CMJoinCustomBattle(hdr, msg, CUSTOM_ROOM_PVP);
A8_ABORT();
}
}