diff --git a/server/gameserver/commands.cc b/server/gameserver/commands.cc index 6f7b568a..3414aad4 100644 --- a/server/gameserver/commands.cc +++ b/server/gameserver/commands.cc @@ -11,6 +11,7 @@ #include "airraid.h" #include "car.h" #include "incubator.h" +#include "mapinstance.h" #include "cs_proto.pb.h" @@ -45,6 +46,26 @@ void Player::_CMExecCommand(f8::MsgHdr& hdr, const cs::CMExecCommand& msg) float z = a8::XValue(cmds[3]).GetDouble(); GetMutablePos().FromGlmVec3(glm::vec3(x, y, z)); room->grid_service->MoveCreature(this); + { + glm::vec3 center = GetPos().ToGlmVec3(); +#if 0 + room->map_instance->PtInHouse(GetPos().ToGlmVec3(), center); +#endif + room->map_instance->Scale(center); + glm::vec3 point; + bool ok = false; + for (int i = 0; i < 10; ++i) { + ok = room->map_instance->FindConnectableNearestPoint(center, 1.0f + 10 * i, point); + if (ok) { + break; + } + } + if (ok) { + room->map_instance->UnScale(point); + GetMutablePos().FromGlmVec3(point); + room->grid_service->MoveCreature(this); + } + } } else if (cmd == "setmode") { if (cmds.empty()) { App::Instance()->UnSetFlag(20);