This commit is contained in:
aozhiwei 2019-08-29 16:05:23 +08:00
parent 85fd001071
commit 9cb596a01b
2 changed files with 1 additions and 115 deletions

View File

@ -1733,7 +1733,7 @@ void Human::SendUpdateMsg()
void Human::SendGameOver()
{
if (entity_subtype == EST_Player) {
#if 1
//!!!必须要在SendNotifyMsg之前注意哦
if (!sent_battlereport_) {
SendBattleReport();
sent_battlereport_ = true;
@ -1744,11 +1744,6 @@ void Human::SendGameOver()
FillSMGameOver(msg);
SendNotifyMsg(msg);
}
#else
if (!sending_gameover_) {
InternalSendGameOver();
}
#endif
}
}
@ -2182,112 +2177,6 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
params->SetVal("rank_score", stats.rank_score);
}
void Human::InternalSendGameOver()
{
if (entity_subtype != EST_Player) {
return;
}
if (already_report_battle_) {
cs::SMGameOver msg;
FillSMGameOver(msg);
SendNotifyMsg(msg);
return;
}
a8::MutableXObject* params = a8::MutableXObject::NewObject();
GenBattleReportData(params);
auto on_ok = [] (a8::XParams& param, a8::XObject& data)
{
long long room_uuid = param.sender;
int hum_uniid = param.param1;
Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid);
if (room) {
room->pending_request--;
Entity* entity = room->GetEntityByUniId(hum_uniid);
if (entity && entity->entity_type == ET_Player) {
Human* hum = (Human*)entity;
hum->sending_gameover_ = false;
hum->already_report_battle_ = true;
hum->stats.history_time_alive = data.Get("alive_time_his");
hum->stats.history_kills = data.Get("kill_his");
hum->stats.history_damage_amount = data.Get("harm_his");
hum->stats.history_heal_amount = data.Get("add_HP_his");
{
std::string extra_drop = data.Get("extra_drop").GetString();
std::vector<std::string> strings1;
a8::Split(extra_drop, strings1, '|');
for (std::string& str1 : strings1) {
std::vector<std::string> strings2;
a8::Split(str1, strings2, ':');
if (strings2.size() == 2) {
hum->stats.extra_drop.push_back(std::make_pair(
a8::XValue(strings2[0]).GetInt(),
a8::XValue(strings2[1]).GetInt()
)
);
}
}
}
cs::SMGameOver msg;
hum->FillSMGameOver(msg);
hum->SendNotifyMsg(msg);
if (!hum->sent_game_end_ && hum->entity_subtype == EST_Player) {
GameLog::Instance()->GameEnd((Player*)hum);
hum->sent_game_end_ = true;
}
}
}
};
auto on_error = [] (a8::XParams& param, const std::string& response)
{
a8::UdpLog::Instance()->Error("battleReport http error params: %s response: %s",
{
param.param2,
response
});
long long room_uuid = param.sender;
int hum_uniid = param.param1;
Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid);
if (room) {
room->pending_request--;
Entity* entity = room->GetEntityByUniId(hum_uniid);
if (entity && entity->entity_type == ET_Player) {
Human* hum = (Human*)entity;
hum->sending_gameover_ = false;
++hum->send_gameover_trycount_;
if (hum->send_gameover_trycount_ < 10){
hum->SendGameOver();
}
}
}
};
std::string url;
if (!f8::IsOnlineEnv()) {
if (App::Instance()->HasFlag(3)) {
url = "http://192.168.100.41/webapp/index.php?c=Role&a=battleReport";
} else {
url = "https://game2001api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport";
}
} else {
url = "https://game2001api.kingsome.cn/webapp/index.php?c=Role&a=battleReport";
}
room->pending_request++;
std::string data;
params->ToUrlEncodeStr(data);
f8::HttpClientPool::Instance()->HttpGet(
a8::XParams()
.SetSender(room->room_uuid)
.SetParam1(entity_uniid)
.SetParam2(data),
on_ok,
on_error,
url.c_str(),
*params,
MAX_SYS_HTTP_NUM + (room->room_uuid % MAX_USER_HTTP_NUM)
);
delete params;
sending_gameover_ = true;
}
void Human::DeadDrop()
{
for (auto& weapon : weapons) {

View File

@ -217,7 +217,6 @@ protected:
private:
void ClearFrameData();
void GenBattleReportData(a8::MutableXObject* params);
void InternalSendGameOver();
void DeadDrop();
void FillSMGameOver(cs::SMGameOver& msg);
void SendBattleReport();
@ -257,10 +256,8 @@ private:
long long last_sync_gas_frameno = 0;
bool already_report_battle_ = false;
bool sending_gameover_ = false;
bool sent_battlereport_ = false;
bool sent_game_end_ = false;
int send_gameover_trycount_ = 0;
Skin skin;