This commit is contained in:
aozhiwei 2022-04-01 08:18:49 +08:00
parent 874b0935b9
commit 6a9340e084
5 changed files with 22 additions and 8 deletions

View File

@ -1784,6 +1784,7 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
stats.rank = rank;
params->SetVal("account_id", account_id);
params->SetVal("session_id", session_id);
params->SetVal("battle_uuid", battle_uuid);
params->SetVal("map_id", room->GetMapMeta()->i->map_id());
params->SetVal("map_name", room->GetMapMeta()->i->map_name());
params->SetVal("team_mode", GetTeam() && GetTeam()->GetMemberNum() > 1 ? 1 : 0);

View File

@ -616,6 +616,19 @@ void MatchTeam::StartGame()
{
MatchTeam* team = MatchMgr::Instance()->GetTeam(team_uuid);
if (team) {
for (auto context : results) {
bool found = false;
for (auto& member : team->GetCurrMembers()) {
if (member->msg->account_id() == context.join_msg->account_id()){
member->battle_uuid = context.battle_uuid;
found = true;
break;
}
}
if (!found) {
abort();
}
}
RoomMgr::Instance()->JoinTeam(team);
team->RemoveTeam();
}

View File

@ -31,6 +31,7 @@ namespace MetaData
struct RawTeamMember
{
class MatchTeam* team = nullptr;
long long battle_uuid = 0;
long long add_tick = 0;
int socket_handle = 0;
std::shared_ptr<cs::CMJoin> msg;

View File

@ -186,6 +186,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
Player* hum = room->NewPlayer();
hum->proto_version = msg.proto_version();
hum->hero_uniid = msg.hero_uniid();
hum->battle_uuid = results.at(0).battle_uuid;
hum->ProcPreSettlementInfo(msg.pre_settlement_info());
PlayerMgr::Instance()->
CreatePlayerByCMJoin(hum,
@ -734,6 +735,7 @@ void RoomMgr::SendGetBattleData(int mode,
}
BattleDataContext context;
context.join_msg = msg;
context.battle_uuid = App::Instance()->NewUuid();
context.errcode = 100;
context.errmsg = "";
result->push_back(context);
@ -747,13 +749,6 @@ void RoomMgr::SendGetBattleData(int mode,
{
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 {
@ -763,12 +758,15 @@ void RoomMgr::SendGetBattleData(int mode,
{
auto data = a8::MutableXObject::CreateObject();
auto members = a8::MutableXObject::CreateArray();
int i = 0;
for (auto msg : join_msgs) {
auto member = a8::MutableXObject::CreateObject();
member->SetVal("account_id", msg->account_id());
member->SetVal("session_id", msg->session_id());
member->SetVal("hero_uniid", msg->hero_uniid());
member->SetVal("battle_uuid", result->at(i).battle_uuid);
member->SetVal("cmjoin", f8::PbToJson(msg.get()));
++i;
members->Push(*member.get());
}
data->SetVal("members", *members);
@ -780,7 +778,7 @@ void RoomMgr::SendGetBattleData(int mode,
HttpProxy::Instance()->HttpGet
(
a8::XParams()
.SetSender(new std::shared_ptr<std::vector<BattleDataContext>>(result))
.SetSender(new std::shared_ptr<std::vector<BattleDataContext>>(result))
.SetParam1(new std::function<
void(std::vector<BattleDataContext>&)>(cb)),
[] (a8::XParams& param, a8::XObject& data)

View File

@ -49,6 +49,7 @@ struct RoomInitInfo
struct BattleDataContext
{
std::shared_ptr<cs::CMJoin> join_msg;
long long battle_uuid = 0;
int errcode = 0;
std::string errmsg;
};