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