diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 1f210a60..6a1af057 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -1,9 +1,15 @@ #include "precompile.h" +#include + +#include + #include "boxdrop.h" #include "room.h" #include "hero.h" #include "obstacle.h" +#include "httpproxy.h" +#include "jsondatamgr.h" #include "mt/MapMode.h" @@ -23,6 +29,7 @@ void BoxDrop::Init() { if (a8::TIMER_EXEC_EVENT == event) { if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + RequestBoxNum(); } } }, @@ -61,3 +68,58 @@ void BoxDrop::OnBattleStart() { } + +void BoxDrop::RequestBoxNum() +{ + std::string url; + JsonDataMgr::Instance()->GetApiUrl(url); + /* + if (custom_room_type == CUSTOM_ROOM_CUSTOM) { + if (url.find('?') != std::string::npos) { + url += "&c=Battle&a=getCustomBattleDataNew"; + } else { + url += "?&c=Battle&a=getCustomBattleDataNew"; + } + } else if (custom_room_type == CUSTOM_ROOM_NORMAL) { + if (url.find('?') != std::string::npos) { + url += "&c=Battle&a=getNormalBattleData"; + } else { + url += "?&c=Battle&a=getNormalBattleData"; + } + } else { + A8_ABORT(); + }*/ + auto url_params = a8::MutableXObject::CreateObject(); + //url_params->SetVal("account_id", join_msg->account_id()); + //url_params->SetVal("session_id", join_msg->session_id()); + url_params->SetVal("version", 1); + //url_params->SetVal("__POST", join_msg->payload_data()); + HttpProxy::Instance()->HttpGet + ( + [] + (bool ok, a8::XObject* rsp_obj, f8::HttpContext* ctx) + { + if (ok) { + f8::UdpLog::Instance()->Info + ("GetBattleData ok %s", + { + rsp_obj->ToJsonStr() + }); + if (rsp_obj->GetType() != a8::XOT_OBJECT || + !rsp_obj->HasKey("errcode")) { + //cb(1, "", nullptr); + return; + } + } else { + f8::UdpLog::Instance()->Warning + ("GetCustomBattleData error %s", + { + "" + }); + //cb(1, "custom battle data error", nullptr); + } + }, + url.c_str(), + *url_params + ); +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 6a3b90e3..09126b0b 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -18,6 +18,7 @@ class BoxDrop : public std::enable_shared_from_this private: void Drop(int num, const glm::vec3& center); + void RequestBoxNum(); private: Room* room_ = nullptr;