diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index e0f7eae..c319981 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -130,6 +130,7 @@ void Human::FillMFObjectFull(cs::MFObjectFull* full_data) void Human::FillMFPlayerStats(cs::MFPlayerStats* stats_pb) { + #if 0 stats_pb->set_player_id(entity_uniid); stats_pb->set_player_avatar_url(avatar_url); @@ -155,6 +156,7 @@ void Human::FillMFPlayerStats(cs::MFPlayerStats* stats_pb) stats_pb->set_killer_name(stats.killer_name); stats_pb->set_account_id(account_id); + #endif } void Human::GetAabbBox(AabbCollider& aabb_box) @@ -489,60 +491,18 @@ void Human::ResetAction() need_sync_active_player = true; } -void Human::FillSMGameOver(cs::SMGameOver& msg) -{ - if (stats.rank <= 0) { - std::vector human_list; - room->TouchHumanList(a8::XParams(), - [&human_list] (Human* hum, a8::XParams& param) -> bool - { - if (hum->leave_frameno_ == 0 || - hum->leave_frameno_ > hum->room->battle_start_frameno_) { - human_list.push_back(hum); - } - return true; - }); - std::sort(human_list.begin(), human_list.end(), - [] (Human* a, Human* b ) - { - if (a->dead_frameno == b->dead_frameno) { - return a->entity_uniid < b->entity_uniid; - } else { - return a->dead_frameno == 0 || - (b->dead_frameno != 0 && a->dead_frameno > b->dead_frameno); - } - }); - int rank = human_list.size(); - for (size_t i = 0; i < human_list.size(); ++i) { - if (human_list[i] == this) { - rank = i + 1; - break; - } - } - if (room->GetAliveTeamNum() == 1) { - std::set* alive_team = room->GetAliveTeam(); - if (alive_team == team_members) { - rank = 1; - } - } - stats.rank = rank; - } - - msg.set_team_id(team_id); - msg.set_team_rank(stats.rank); - msg.set_team_allcnt(1); - msg.set_game_over(room->game_over); - msg.set_victory(!dead); - msg.set_room_uuid(a8::XValue(room->room_uuid)); - - cs::MFPlayerStats* p = msg.add_player_stats(); - FillMFPlayerStats(p); -} - void Human::BeKill(int killer_id, const std::string& killer_name, int weapon_id) { if (!dead && !room->game_over) { lethal_weapon = weapon_id; + { + Entity* entity = room->GetEntityByUniId(killer_id); + if (entity && entity->entity_type == ET_Player) { + Human* killer = (Human*)entity; + killer->stats.dead_times++; + } + } + ++stats.dead_times; stats.killer_id = killer_id; stats.killer_name = killer_name; stats.weapon_id = weapon_id; @@ -1326,15 +1286,6 @@ void Human::SendUpdateMsg() ClearFrameData(); } -void Human::SendGameOver() -{ - if (entity_subtype == EST_Player) { - if (!sending_gameover_) { - InternalSendGameOver(); - } - } -} - void Human::FollowTarget(Human* target) { if (target == this) { @@ -1729,96 +1680,6 @@ void Human::GenBattleReportData(a8::MutableXObject* params) params->SetVal("score", 0); } -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"); - 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://game2002api-test.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; - } - } else { - url = "https://game2002api.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, - room->room_uuid - ); - delete params; - sending_gameover_ = true; -} - void Human::DeadDrop() { for (auto& weapon : weapons) { diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 7e757d8..7ac385c 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -177,7 +177,6 @@ class Human : public Entity { GGListener::Instance()->SendToClient(socket_handle, 0, msg); } - void SendGameOver(); void FollowTarget(Human* target); void SendDebugMsg(const std::string& debug_msg); void SendRollMsg(const std::string& roll_msg); @@ -197,9 +196,7 @@ protected: private: void ClearFrameData(); void GenBattleReportData(a8::MutableXObject* params); - void InternalSendGameOver(); void DeadDrop(); - void FillSMGameOver(cs::SMGameOver& msg); void Relive(); protected: @@ -236,9 +233,7 @@ private: long long last_sync_gas_frameno = 0; bool already_report_battle_ = false; - bool sending_gameover_ = false; bool sent_game_end_ = false; - int send_gameover_trycount_ = 0; Skin skin; diff --git a/server/gameserver/metamgr.cc b/server/gameserver/metamgr.cc index 68f0b92..4d35c44 100755 --- a/server/gameserver/metamgr.cc +++ b/server/gameserver/metamgr.cc @@ -106,6 +106,7 @@ public: MetaMgr::Instance()->rank_param = MetaMgr::Instance()->GetSysParamAsFloat("rank_parameter"); MetaMgr::Instance()->fighting_mode = MetaMgr::Instance()->GetSysParamAsInt("fighting_mode", 1); MetaMgr::Instance()->revive_time = MetaMgr::Instance()->GetSysParamAsInt("revive_time", 5); + MetaMgr::Instance()->game_duration = MetaMgr::Instance()->GetSysParamAsInt("revive_time", 60 * 2); if (MetaMgr::Instance()->K < 0.01f) { abort(); } diff --git a/server/gameserver/metamgr.h b/server/gameserver/metamgr.h index d8e3bb7..4b9c72e 100755 --- a/server/gameserver/metamgr.h +++ b/server/gameserver/metamgr.h @@ -43,6 +43,7 @@ class MetaMgr : public a8::Singleton float rank_param = 0.0f; int fighting_mode = 0; int revive_time = 5; + int game_duration = 60 * 2; private: MetaDataLoader* loader_ = nullptr; diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 90b16e5..3ac17c3 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -984,7 +984,6 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg) void Player::_CMGameOver(f8::MsgHdr& hdr, const cs::CMGameOver& msg) { - SendGameOver(); } void Player::_CMWatchWar(f8::MsgHdr& hdr, const cs::CMWatchWar& msg) diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 6485c91..b09092b 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -795,9 +795,22 @@ void Room::UpdateGas() NotifyWxVoip(); RoomMgr::Instance()->ActiveRoom(room_uuid); battle_start_frameno_ = frame_no; + xtimer.AddDeadLineTimerAndAttach(SERVER_FRAME_RATE * MetaMgr::Instance()->game_duration, + a8::XParams() + .SetSender(this), + [] (const a8::XParams& param) + { + Room* room = (Room*)param.sender.GetUserData(); + room->BattleReport(); + }, + &xtimer_attacher.timer_list_); } } break; + case GasStarted: + { + } + break; } } @@ -912,16 +925,6 @@ void Room::AddObjectLater(Entity* entity) &entity->xtimer_attacher.timer_list_); } -void Room::OnGameOver() -{ - for (auto& pair : human_hash_) { - if (game_over && game_over_frameno == frame_no) { - pair.second->SendGameOver(); - } - } - RoomMgr::Instance()->AddOverRoom(room_uuid); -} - void Room::RandRemoveAndroid() { Human* hum = nullptr; @@ -985,3 +988,8 @@ void Room::NotifyWxVoip() }, &xtimer_attacher.timer_list_); } + +void Room::BattleReport() +{ + +} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 1ddac0b..ce1b664 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -102,10 +102,10 @@ private: Obstacle* InternalCreateObstacle(int id, float x, float y, std::function on_precreate); void AddObjectLater(Entity* entity); - void OnGameOver(); void RandRemoveAndroid(); void NotifyUiUpdate(); void NotifyWxVoip(); + void BattleReport(); private: int elapsed_time_ = 0; @@ -115,6 +115,8 @@ private: int current_teamid = 0; int current_uniid = 0; + xtimer_list* battle_report_timer_ = nullptr; + std::set refreshed_robot_set_; std::map> team_hash_; std::map accountid_hash_; diff --git a/server/gameserver/types.h b/server/gameserver/types.h index 5ac8c5f..6c07165 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -70,6 +70,7 @@ struct Skin struct PlayerStats { int kills = 0; + int dead_times = 0; int damage_amount_in = 0; int damage_amount_out = 0; int heal_amount = 0; diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index e2e2788..cd5e88c 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -505,28 +505,13 @@ message MFEmote //游戏结束时玩家统计信息 message MFPlayerStats { - optional int32 player_id = 1; //玩家id - optional string player_avatar_url = 2; //玩家头像 + optional int32 rank = 1; //排名 + optional int32 player_id = 2; //玩家id + optional string player_avatar_url = 3; //玩家头像 + optional string account_id = 4; //账号id - //本次成绩 - optional int32 time_alive = 3; //存活时间(毫秒) - optional int32 kills = 4; //击杀敌人数 - optional int32 damage_amount = 8; //伤害总量 - optional int32 heal_amount = 20; //治疗总量 - //历史最佳成绩 - optional int32 history_time_alive = 30; //存活时间(毫秒) - optional int32 history_kills = 31; //击杀敌人数 - optional int32 history_damage_amount = 32; //伤害总量 - optional int32 history_heal_amount = 33; //治疗总量 - - optional int32 gold = 10; //金币 - optional int32 score = 11; //积分 - - optional bool dead = 5; //是否已死亡 - optional int32 killer_id = 7; //杀手id(自杀时为自己) 特殊id: -1:倒在安全区 - optional string killer_name = 40; //杀手名称 - - optional string account_id = 21; //账号id + optional int32 kills = 5; //击杀敌人数 + optional int32 dead_times = 6; //死亡次数 } //空投 @@ -581,7 +566,8 @@ message CMJoin optional int32 server_id = 1; //serverid optional string team_uuid = 2; //队伍唯一id (没组队时为空字符串) optional string account_id = 3; //账号id account_id - optional int32 team_mode = 4; //队伍模式 0:单人 1:多人 + optional string session_id = 4; //session_id + optional int32 team_mode = 20; //队伍模式 0:单人 1:多人 optional int32 player_count = 5; //玩家数(单人时为1) optional bool auto_fill = 6; //是否自动填充玩家 optional int32 bot = 7; //是否机器人 @@ -596,7 +582,7 @@ message CMJoin repeated MFWeapon weapons = 17; //武器列表 repeated MFSkin skins = 18; //皮肤列表 key: 皮肤id value:皮肤等级 repeated int32 prepare_items = 19; //战斗前准备道具 战前准备护盾存到energy_shield - optional string session_id = 20; //session_id + optional string from_appid = 21; //from_appid }