diff --git a/server/gameserver/boxdrop.cc b/server/gameserver/boxdrop.cc index 11030e71..77554620 100644 --- a/server/gameserver/boxdrop.cc +++ b/server/gameserver/boxdrop.cc @@ -156,6 +156,7 @@ void BoxDrop::RequestReturnBoxNum() url_params->SetVal("a", "requestReturnBoxNum"); url_params->SetVal("account_id", account_id); url_params->SetVal("session_id", session_id); + url_params->SetVal("room_uuid", room_->GetRoomUuid()); url_params->SetVal("used_num", GetUsedBoxNum()); url_params->SetVal("alloc_box_num", alloc_box_num_); HttpProxy::Instance()->HttpGet @@ -188,7 +189,7 @@ void BoxDrop::RequestReturnBoxNum() } } -bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session_id) +bool BoxDrop::FillAccountIdSessionId(std::string& account_id, std::string& session_id) { bool ok = false; room_->TraversePlayerList @@ -298,3 +299,17 @@ int BoxDrop::GetUsedBoxNum() }); return num; } + +bool BoxDrop::GetNextBoxPos(glm::vec3& pos) +{ + for (auto& pair : drop_hash_) { + if (pair.second > 0) { + Entity* e = room_->GetEntityByUniId(pair.first); + if (e) { + pos = e->GetPos().ToGlmVec3(); + return true; + } + } + } + return false; +} diff --git a/server/gameserver/boxdrop.h b/server/gameserver/boxdrop.h index 8a5b4986..10b9ab2f 100644 --- a/server/gameserver/boxdrop.h +++ b/server/gameserver/boxdrop.h @@ -15,12 +15,13 @@ class BoxDrop : public std::enable_shared_from_this void OnHeroDeadDrop(Hero* hero); void OnObstacleDeadDrop(Obstacle* ob); void RequestReturnBoxNum(); + bool GetNextBoxPos(glm::vec3& pos); private: void Drop(int num, const glm::vec3& center); void RequestAllocBoxNum(); - bool FillAccountIdSessionId(std::string account_id, std::string session_id); + bool FillAccountIdSessionId(std::string& account_id, std::string& session_id); void OnAllocOk(int box_num); void OnAllocFail(); void AllocBoxToRoom(); diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index a17a3e90..a30e6701 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -16,6 +16,7 @@ #include "loot.h" #include "ability.h" #include "trigger.h" +#include "boxdrop.h" #include "cs_proto.pb.h" @@ -69,6 +70,12 @@ void Player::_CMExecCommand(f8::MsgHdr* hdr, const cs::CMExecCommand& msg) room->grid_service->MoveCreature(this); } } + } else if (cmd == "goto_box") { + glm::vec3 pos; + if (room->GetBoxDrop()->GetNextBoxPos(pos)) { + GetMutablePos().FromGlmVec3(pos); + room->grid_service->MoveCreature(this); + } } else if (cmd == "additem" && cmds.size() >= 3) { int item_id = a8::XValue(cmds[1]); int item_num = a8::XValue(cmds[2]);