sendgameover ok
This commit is contained in:
parent
8dcf83edc8
commit
3ef654d04b
@ -466,7 +466,6 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
dead = true;
|
dead = true;
|
||||||
health = 0.0f;
|
health = 0.0f;
|
||||||
dead_frameno = room->frame_no;
|
dead_frameno = room->frame_no;
|
||||||
send_gameover = true;
|
|
||||||
room->OnHumanDie(this);
|
room->OnHumanDie(this);
|
||||||
SyncAroundPlayers();
|
SyncAroundPlayers();
|
||||||
if (team_members) {
|
if (team_members) {
|
||||||
@ -477,6 +476,7 @@ void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SendGameOver();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1266,72 +1266,13 @@ void Human::SendUpdateMsg()
|
|||||||
++send_msg_times;
|
++send_msg_times;
|
||||||
}
|
}
|
||||||
ClearFrameData();
|
ClearFrameData();
|
||||||
if (send_gameover) {
|
|
||||||
UpdateGameOver();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::UpdateGameOver()
|
void Human::SendGameOver()
|
||||||
{
|
{
|
||||||
a8::MutableXObject* params = a8::MutableXObject::NewObject();
|
if (!sending_gameover_) {
|
||||||
GenBattleReportData(params);
|
InternalSendGameOver();
|
||||||
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) {
|
|
||||||
Entity* entity = room->GetEntityByUniId(hum_uniid);
|
|
||||||
if (entity && entity->entity_type == ET_Player) {
|
|
||||||
Human* hum = (Human*)entity;
|
|
||||||
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");
|
|
||||||
cs::SMGameOver msg;
|
|
||||||
hum->FillSMGameOver(msg);
|
|
||||||
hum->SendNotifyMsg(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
auto on_error = [] (a8::XParams& param, const std::string& response)
|
|
||||||
{
|
|
||||||
long long room_uuid = param.sender;
|
|
||||||
int hum_uniid = param.param1;
|
|
||||||
Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid);
|
|
||||||
if (room) {
|
|
||||||
Entity* entity = room->GetEntityByUniId(hum_uniid);
|
|
||||||
if (entity && entity->entity_type == ET_Player) {
|
|
||||||
Human* hum = (Human*)entity;
|
|
||||||
++hum->send_gameover_trycount;
|
|
||||||
if (hum->send_gameover_trycount < 10){
|
|
||||||
hum->send_gameover = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
std::string url;
|
|
||||||
if (!f8::IsOnlineEnv()) {
|
|
||||||
if (App::Instance()->flags.find(3) != App::Instance()->flags.end()) {
|
|
||||||
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";
|
|
||||||
}
|
}
|
||||||
f8::HttpClientPool::Instance()->HttpGet(
|
|
||||||
a8::XParams()
|
|
||||||
.SetSender(room->room_uuid)
|
|
||||||
.SetParam1(entity_uniid),
|
|
||||||
on_ok,
|
|
||||||
on_error,
|
|
||||||
url.c_str(),
|
|
||||||
*params,
|
|
||||||
rand()
|
|
||||||
);
|
|
||||||
delete params;
|
|
||||||
send_gameover = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Human::FollowTarget(Human* target)
|
void Human::FollowTarget(Human* target)
|
||||||
@ -1486,3 +1427,75 @@ void Human::GenBattleReportData(a8::MutableXObject* params)
|
|||||||
}
|
}
|
||||||
params->SetVal("score", 0);
|
params->SetVal("score", 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Human::InternalSendGameOver()
|
||||||
|
{
|
||||||
|
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) {
|
||||||
|
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");
|
||||||
|
cs::SMGameOver msg;
|
||||||
|
hum->FillSMGameOver(msg);
|
||||||
|
hum->SendNotifyMsg(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
auto on_error = [] (a8::XParams& param, const std::string& response)
|
||||||
|
{
|
||||||
|
long long room_uuid = param.sender;
|
||||||
|
int hum_uniid = param.param1;
|
||||||
|
Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid);
|
||||||
|
if (room) {
|
||||||
|
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()->flags.find(3) != App::Instance()->flags.end()) {
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
f8::HttpClientPool::Instance()->HttpGet(
|
||||||
|
a8::XParams()
|
||||||
|
.SetSender(room->room_uuid)
|
||||||
|
.SetParam1(entity_uniid),
|
||||||
|
on_ok,
|
||||||
|
on_error,
|
||||||
|
url.c_str(),
|
||||||
|
*params,
|
||||||
|
rand()
|
||||||
|
);
|
||||||
|
delete params;
|
||||||
|
sending_gameover_ = true;
|
||||||
|
}
|
||||||
|
@ -87,9 +87,6 @@ class Human : public Entity
|
|||||||
|
|
||||||
PlayerStats stats;
|
PlayerStats stats;
|
||||||
|
|
||||||
bool send_gameover = false;
|
|
||||||
int send_gameover_trycount = 0;
|
|
||||||
|
|
||||||
int pain_killer_frameno = 0;
|
int pain_killer_frameno = 0;
|
||||||
int pain_killer_lastingtime = 0;
|
int pain_killer_lastingtime = 0;
|
||||||
xtimer_list* pain_killer_timer = nullptr;
|
xtimer_list* pain_killer_timer = nullptr;
|
||||||
@ -167,13 +164,14 @@ class Human : public Entity
|
|||||||
{
|
{
|
||||||
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
GGListener::Instance()->SendToClient(socket_handle, 0, msg);
|
||||||
}
|
}
|
||||||
void UpdateGameOver();
|
void SendGameOver();
|
||||||
void FollowTarget(Human* target);
|
void FollowTarget(Human* target);
|
||||||
void SendDebugMsg(const std::string& debug_msg);
|
void SendDebugMsg(const std::string& debug_msg);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClearFrameData();
|
void ClearFrameData();
|
||||||
void GenBattleReportData(a8::MutableXObject* params);
|
void GenBattleReportData(a8::MutableXObject* params);
|
||||||
|
void InternalSendGameOver();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
long long last_shot_frameno_ = 0;
|
long long last_shot_frameno_ = 0;
|
||||||
@ -205,6 +203,11 @@ protected:
|
|||||||
private:
|
private:
|
||||||
CircleCollider* self_collider_ = nullptr;
|
CircleCollider* self_collider_ = nullptr;
|
||||||
long long last_sync_gas_frameno = 0;
|
long long last_sync_gas_frameno = 0;
|
||||||
|
|
||||||
|
bool already_report_battle_ = false;
|
||||||
|
bool sending_gameover_ = false;
|
||||||
|
int send_gameover_trycount_ = 0;
|
||||||
|
|
||||||
friend class FrameMaker;
|
friend class FrameMaker;
|
||||||
friend class FrameEvent;
|
friend class FrameEvent;
|
||||||
};
|
};
|
||||||
|
@ -825,8 +825,8 @@ void Room::UpdateGas()
|
|||||||
if (pair.second->dead) {
|
if (pair.second->dead) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (game_over) {
|
if (game_over && game_over_frameno == frame_no) {
|
||||||
pair.second->send_gameover = true;
|
pair.second->SendGameOver();
|
||||||
}
|
}
|
||||||
bool b1 = CircleContainCircle(gas_data.pos_old,
|
bool b1 = CircleContainCircle(gas_data.pos_old,
|
||||||
gas_data.gas_progress,
|
gas_data.gas_progress,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user