diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 6a1af057..a37cb12f 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -2,6 +2,7 @@ #include +#include #include #include "boxdrop.h" @@ -22,19 +23,6 @@ BoxDrop::BoxDrop(Room* room):room_(room) void BoxDrop::Init() { - if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { - get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx - (SERVER_FRAME_RATE * 10, - [this] (int event, const a8::Args* args) - { - if (a8::TIMER_EXEC_EVENT == event) { - if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { - RequestBoxNum(); - } - } - }, - &room_->xtimer_attacher_); - } } void BoxDrop::UnInit() @@ -66,34 +54,30 @@ void BoxDrop::Drop(int num, const glm::vec3& center) void BoxDrop::OnBattleStart() { - + if (room_->GetMapModeMeta() && room_->GetMapModeMeta()->mapMode() == mt::kTreasureBoxMode) { + get_box_num_timer_ = room_->xtimer.SetTimeoutWpEx + (SERVER_FRAME_RATE * 10, + [this] (int event, const a8::Args* args) + { + if (a8::TIMER_EXEC_EVENT == event) { + if (!room_->IsGameOver() && !room_->GetVictoryTeam()) { + RequestAllocBoxNum(); + } + } + }, + &room_->xtimer_attacher_); + } } -void BoxDrop::RequestBoxNum() +void BoxDrop::RequestAllocBoxNum() { 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(); - }*/ + int nowtime = f8::App::Instance()->GetNowTime(); 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()); + url_params->SetVal("c", "Battle"); + url_params->SetVal("a", "requestBoxNum"); + url_params->SetVal("timestamp", a8::XValue(nowtime)); HttpProxy::Instance()->HttpGet ( [] @@ -123,3 +107,8 @@ void BoxDrop::RequestBoxNum() *url_params ); } + +void BoxDrop::RequestReturnBoxNum() +{ + +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 09126b0b..056ec446 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -14,14 +14,17 @@ class BoxDrop : public std::enable_shared_from_this void OnBattleStart(); void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); + void RequestReturnBoxNum(); private: void Drop(int num, const glm::vec3& center); - void RequestBoxNum(); + void RequestAllocBoxNum(); private: Room* room_ = nullptr; a8::XTimerWp get_box_num_timer_; int box_num_ = 0; + int alloc_box_num_ = 0; + bool returned_ = false; };