From d7eaa2b5d6e6586702da031aa053fc47292a7449 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 30 Jul 2024 20:10:05 +0800 Subject: [PATCH] 1 --- server/gameserver/boxdrop.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 90463584..7dadef27 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -11,6 +11,7 @@ #include "obstacle.h" #include "httpproxy.h" #include "jsondatamgr.h" +#include "player.h" #include "mt/MapMode.h" @@ -71,12 +72,20 @@ void BoxDrop::OnBattleStart() void BoxDrop::RequestAllocBoxNum() { + std::string account_id; + std::string session_id; + if (!FillAccountIdSessionId(account_id, session_id)) { + return; + } + std::string url; JsonDataMgr::Instance()->GetApiUrl(url); auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); url_params->SetVal("a", "requestAllocBoxNum"); url_params->SetVal("room_uuid", room_->GetRoomUuid()); + url_params->SetVal("account_id", account_id); + url_params->SetVal("session_id", session_id); HttpProxy::Instance()->HttpGet ( [] @@ -117,12 +126,21 @@ void BoxDrop::RequestReturnBoxNum() return; } returned_ = true; + + std::string account_id; + std::string session_id; + if (!FillAccountIdSessionId(account_id, session_id)) { + return; + } + std::string url; JsonDataMgr::Instance()->GetApiUrl(url); auto url_params = a8::MutableXObject::CreateObject(); url_params->SetVal("c", "Battle"); url_params->SetVal("a", "requestReturnBoxNum"); url_params->SetVal("room_uuid", room_->GetRoomUuid()); + url_params->SetVal("account_id", account_id); + url_params->SetVal("session_id", session_id); HttpProxy::Instance()->HttpGet ( [] @@ -161,5 +179,13 @@ int BoxDrop::GetRemainNum() bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id) { - return true; + bool ok = false; + room_->TraversePlayerList + ([&ok, &account_id, &session_id] (Player* hum) + { + ok = true; + account_id = hum->account_id; + session_id = hum->session_id; + }); + return ok; }