From c4febfc0bc79b15eec22d44747f6407f079c9837 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 3 Jun 2019 15:36:57 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A2=B0=E6=92=9E?= =?UTF-8?q?=E6=A3=80=E6=B5=8B=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/obstacle.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 715b3ba..0103c8a 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -42,7 +42,7 @@ void Obstacle::RecalcSelfCollider() } else { self_collider2_->_min = Vector2D(0.0f - door_state1->width() / 2.0f, 0.0f - door_state1->height() / 2.0f); - self_collider2_->_max = Vector2D(door_state1->width(), door_state1->height()); + self_collider2_->_max = Vector2D(door_state1->width() / 2.0f, door_state1->height() / 2.0f); } } else if (meta->i->attack_type() != 2){ switch (meta->i->type()) { From f20fd2a1cdfd137ab7a18c1c05e84129ed67c1c2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 4 Jun 2019 09:27:56 +0800 Subject: [PATCH 2/4] 1 --- server/bin/gmtool.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/bin/gmtool.sh b/server/bin/gmtool.sh index f7716be..ca928a4 100755 --- a/server/bin/gmtool.sh +++ b/server/bin/gmtool.sh @@ -2,4 +2,4 @@ cd ../tools/robot/virtualclient python robot.py ws://192.168.100.21:7101 hao1069 hao1069 $1 - +#python robot.py "wss://game2001.kingsome.cn" hao1069 hao1069 $1 From 87ac55c041aa1d4181f0309161fb9dad0e974ba2 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 4 Jun 2019 09:49:46 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E7=BB=93=E7=AE=97=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 32af722..0ffbcec 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1867,6 +1867,10 @@ void Human::InternalSendGameOver() }; auto on_error = [] (a8::XParams& param, const std::string& response) { + a8::UdpLog::Instance()->Error("battleReport params: ", + { + param.param2 + }); long long room_uuid = param.sender; int hum_uniid = param.param1; Room* room = RoomMgr::Instance()->GetRoomByUuid(room_uuid); @@ -1892,10 +1896,13 @@ void Human::InternalSendGameOver() } else { url = "https://game2001api.kingsome.cn/webapp/index.php?c=Role&a=battleReport"; } + 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(), From 027a3de2ea94335d73d4fb80244fe6ded13c91a3 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 4 Jun 2019 10:37:46 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=88=BF=E9=97=B4=E5=86=85=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=8E=A9=E5=AE=B6=E4=B8=8B=E7=BA=BF=E5=90=8E=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=87=8A=E6=94=BE=E6=88=BF=E9=97=B4=E5=AF=B9=E8=B1=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/gameserver/human.cc | 7 ++++--- server/gameserver/playermgr.cc | 21 +++++++++++++++------ server/gameserver/room.cc | 13 +++++++++++++ server/gameserver/room.h | 1 + 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 0ffbcec..00c894d 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1867,9 +1867,10 @@ void Human::InternalSendGameOver() }; auto on_error = [] (a8::XParams& param, const std::string& response) { - a8::UdpLog::Instance()->Error("battleReport params: ", + a8::UdpLog::Instance()->Error("battleReport params: %s response: %s", { - param.param2 + param.param2, + response }); long long room_uuid = param.sender; int hum_uniid = param.param1; @@ -1901,7 +1902,7 @@ void Human::InternalSendGameOver() f8::HttpClientPool::Instance()->HttpGet( a8::XParams() .SetSender(room->room_uuid) - .SetParam1(entity_uniid), + .SetParam1(entity_uniid) .SetParam2(data), on_ok, on_error, diff --git a/server/gameserver/playermgr.cc b/server/gameserver/playermgr.cc index 197fee3..720dbc5 100644 --- a/server/gameserver/playermgr.cc +++ b/server/gameserver/playermgr.cc @@ -3,6 +3,7 @@ #include "playermgr.h" #include "player.h" #include "cs_proto.pb.h" +#include "room.h" void PlayerMgr::Init() { @@ -14,10 +15,10 @@ void PlayerMgr::UnInit() void PlayerMgr::_SS_WSP_SocketDisconnect(f8::MsgHdr& hdr, const ss::SS_WSP_SocketDisconnect& msg) { - auto itr = socket_hash_.find(hdr.socket_handle); - if (itr != socket_hash_.end()) { - itr->second->socket_handle = 0; - socket_hash_.erase(itr); + Player* hum = GetPlayerBySocket(hdr.socket_handle); + if (hum) { + RemovePlayerBySocket(hdr.socket_handle); + hum->room->OnPlayerOffline(hum); } } @@ -78,11 +79,19 @@ void PlayerMgr::OnClientDisconnect(a8::XParams& param) } } for (int socket_handle : socket_list) { - socket_hash_.erase(socket_handle); + Player* hum = GetPlayerBySocket(socket_handle); + if (hum) { + RemovePlayerBySocket(socket_handle); + hum->room->OnPlayerOffline(hum); + } } } void PlayerMgr::RemovePlayerBySocket(int socket_handle) { - socket_hash_.erase(socket_handle); + auto itr = socket_hash_.find(socket_handle); + if (itr != socket_hash_.end()) { + itr->second->socket_handle = 0; + socket_hash_.erase(itr); + } } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 0c930f6..c7ff655 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -713,6 +713,19 @@ bool Room::CanJoin(const std::string& accountid) } } +void Room::OnPlayerOffline(Player* hum) +{ + bool has_player = false; + for (auto& pair : accountid_hash_) { + if (pair.second->socket_handle != 0) { + has_player = true; + } + } + if (!has_player) { + RoomMgr::Instance()->AddOverRoom(room_uuid); + } +} + std::set* Room::GetAliveTeam() { for (auto& pair : team_hash_) { diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 11002d3..e9955c8 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -88,6 +88,7 @@ public: int GetAliveTeamNum(); std::set* GetAliveTeam(); bool CanJoin(const std::string& accountid); + void OnPlayerOffline(Player* hum); private: unsigned short AllocUniid();