1
This commit is contained in:
parent
357d105587
commit
a1204c1dca
@ -2054,6 +2054,11 @@ void Human::SendBattleReport()
|
||||
std::string url;
|
||||
JsonDataMgr::Instance()->GetApiUrl(url);
|
||||
if (!f8::IsOnlineEnv()) {
|
||||
#ifdef DEBUG
|
||||
if (proto_version >= 2022032201) {
|
||||
url = "https://game2006api-test.kingsome.cn/new/webapp/index.php";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (url.find('?') != std::string::npos) {
|
||||
url += "c=Battle&a=battleReport";
|
||||
|
@ -417,6 +417,30 @@ bool MatchTeam::HasSameCurrMember(MatchTeam* b)
|
||||
return has;
|
||||
}
|
||||
|
||||
bool MatchTeam::ProtoIsCompatible(MatchTeam* b)
|
||||
{
|
||||
bool is_compatible = true;
|
||||
for (auto& a_member : curr_member_hash_) {
|
||||
for (auto& b_member : b->curr_member_hash_) {
|
||||
if (a_member->msg->proto_version() != 0 &&
|
||||
b_member->msg->proto_version() != 0 &&
|
||||
#ifdef DEBUG
|
||||
(
|
||||
(a_member->msg->proto_version() < 2022032201 && b_member->msg->proto_version() >= 2022032201) ||
|
||||
(a_member->msg->proto_version() >= 2022032201 && b_member->msg->proto_version() < 2022032201)
|
||||
)
|
||||
#else
|
||||
false
|
||||
#endif
|
||||
) {
|
||||
is_compatible = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_compatible;
|
||||
}
|
||||
|
||||
bool MatchTeam::CanCombine(MatchTeam* b)
|
||||
{
|
||||
if (this == b) {
|
||||
@ -502,6 +526,12 @@ bool MatchTeam::CanCombine(MatchTeam* b)
|
||||
if (HasSameCurrMember(b)) {
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("CanCombine 11\n", {});
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
if (!ProtoIsCompatible(b)) {
|
||||
#ifdef DEBUG
|
||||
a8::XPrintf("CanCombine 12\n", {});
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
@ -582,7 +612,7 @@ void MatchTeam::StartGame()
|
||||
}
|
||||
std::string team_uuid = GetTeamUUid();
|
||||
auto cb =
|
||||
[team_uuid] (std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>& results)
|
||||
[team_uuid] (std::vector<BattleDataContext>& results)
|
||||
{
|
||||
MatchTeam* team = MatchMgr::Instance()->GetTeam(team_uuid);
|
||||
if (team) {
|
||||
|
@ -76,6 +76,7 @@ class MatchTeam
|
||||
int GetPredictMemberNum();
|
||||
int GetRawMemberNum() { return raw_member_hash_.size(); };
|
||||
bool HasSameCurrMember(MatchTeam* b);
|
||||
bool ProtoIsCompatible(MatchTeam* b);
|
||||
bool CanCombine(MatchTeam* b);
|
||||
bool IsShuaRobotTime();
|
||||
void Combine(MatchTeam* b);
|
||||
|
@ -155,7 +155,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
||||
auto socket_handle = hdr.socket_handle;
|
||||
auto cb =
|
||||
[ip_saddr, socket_handle, join_msg]
|
||||
(std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>& results)
|
||||
(std::vector<BattleDataContext>& results)
|
||||
{
|
||||
cs::CMJoin& msg = *join_msg;
|
||||
if (RoomMgr::Instance()->IsLimitJoin()) {
|
||||
@ -773,25 +773,39 @@ void RoomMgr::OnJoinResponse(JoinRequest* req)
|
||||
|
||||
void RoomMgr::SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_msgs,
|
||||
std::function<
|
||||
void(std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>&)> cb)
|
||||
void(std::vector<BattleDataContext>&)> cb)
|
||||
{
|
||||
if (join_msgs.empty()) {
|
||||
abort();
|
||||
}
|
||||
std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>> result;
|
||||
std::vector<BattleDataContext> result;
|
||||
bool is_old_version = false;
|
||||
for (auto& msg : join_msgs) {
|
||||
if (msg->proto_version() < 2022032201) {
|
||||
is_old_version = true;
|
||||
break;
|
||||
}
|
||||
result.push_back(
|
||||
std::make_tuple(msg, 0, "")
|
||||
);
|
||||
BattleDataContext context;
|
||||
context.join_msg = msg;
|
||||
result.push_back(context);
|
||||
}
|
||||
if (is_old_version) {
|
||||
cb(result);
|
||||
}
|
||||
std::string url;
|
||||
JsonDataMgr::Instance()->GetApiUrl(url);
|
||||
if (!f8::IsOnlineEnv()) {
|
||||
#ifdef DEBUG
|
||||
if (!is_old_version) {
|
||||
url = "https://game2006api-test.kingsome.cn/new/webapp/index.php";
|
||||
}
|
||||
#endif
|
||||
}
|
||||
if (url.find('?') != std::string::npos) {
|
||||
url += "c=Battle&a=getBattleData";
|
||||
} else {
|
||||
url += "?c=Battle&a=getBattleData";
|
||||
}
|
||||
a8::MutableXObject* url_params = a8::MutableXObject::NewObject();
|
||||
HttpProxy::Instance()->HttpGet
|
||||
(
|
||||
@ -802,7 +816,7 @@ void RoomMgr::SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_m
|
||||
[] (a8::XParams& param, const std::string& response)
|
||||
{
|
||||
},
|
||||
"",
|
||||
url.c_str(),
|
||||
*url_params
|
||||
);
|
||||
delete url_params;
|
||||
|
@ -46,6 +46,13 @@ struct RoomInitInfo
|
||||
const std::vector<MetaData::MapTplThing*>* level0room_spec_things = nullptr;
|
||||
};
|
||||
|
||||
struct BattleDataContext
|
||||
{
|
||||
std::shared_ptr<cs::CMJoin> join_msg;
|
||||
int errcode = 0;
|
||||
std::string errmsg;
|
||||
};
|
||||
|
||||
class Room;
|
||||
class MatchTeam;
|
||||
class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
@ -73,7 +80,7 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
||||
void JoinTeam(MatchTeam* team);
|
||||
void SendGetBattleData(std::vector<std::shared_ptr<cs::CMJoin>>& join_msgs,
|
||||
std::function<
|
||||
void(std::vector<std::tuple<std::shared_ptr<cs::CMJoin>, int, std::string>>&)> cb);
|
||||
void(std::vector<BattleDataContext>&)> cb);
|
||||
|
||||
private:
|
||||
void InstallReportStateTimer();
|
||||
|
Loading…
x
Reference in New Issue
Block a user