From d83b3b04f0da53a0602a3cc073e95540cca1ab1b Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 7 Jul 2023 20:36:16 +0800 Subject: [PATCH] 1 --- server/gameserver/debugcmd.cc | 5 +++++ server/gameserver/debugcmd.h | 1 + server/gameserver/mapinstance.cc | 13 ++++++++++++- server/gameserver/mapmgr.cc | 12 +++++++++++- server/gameserver/player.cc | 6 ++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/server/gameserver/debugcmd.cc b/server/gameserver/debugcmd.cc index 6a382c15..a4657849 100644 --- a/server/gameserver/debugcmd.cc +++ b/server/gameserver/debugcmd.cc @@ -11,6 +11,11 @@ bool DebugCmd::Enable() return App::Instance()->instance_id == 6; } +bool DebugCmd::EnableNewMap() +{ + return App::Instance()->instance_id == 3; +} + void DebugCmd::CreateSphere(Creature* c, const glm::vec3& pos, const glm::vec3& scale, diff --git a/server/gameserver/debugcmd.h b/server/gameserver/debugcmd.h index 5136b4e3..b5049349 100644 --- a/server/gameserver/debugcmd.h +++ b/server/gameserver/debugcmd.h @@ -11,6 +11,7 @@ class DebugCmd public: static bool Enable(); + static bool EnableNewMap(); static void CreateSphere(Creature* c, const glm::vec3& pos, diff --git a/server/gameserver/mapinstance.cc b/server/gameserver/mapinstance.cc index 932f1fb9..51780c4d 100644 --- a/server/gameserver/mapinstance.cc +++ b/server/gameserver/mapinstance.cc @@ -108,7 +108,13 @@ void MapInstance::Init() MAP_GRID_WIDTH); { navmesh_ = dtAllocNavMesh(); - FILE *fp = fopen((mt::MetaMgr::Instance()->GetResDir() + "map4.bin").c_str(), "rb"); + std::string navmesh_file = "map4.bin"; +#ifdef DEBUG + if (DebugCmd::EnableNewMap() && map_id == 2002) { + navmesh_file = "map5.bin"; + } +#endif + FILE *fp = fopen((mt::MetaMgr::Instance()->GetResDir() + navmesh_file).c_str(), "rb"); if(fp){ //fseek(fp, 0, SEEK_END); //int file_size = ftell(fp); @@ -1245,6 +1251,11 @@ void MapInstance::MarkConnectablePolys() dtPolyRef startRef = INVALID_NAVMESH_POLYREF; { glm::vec3 pos = glm::vec3(5120.000000000000f, 6.250846862793f, 5120.000000000000f); +#ifdef DEBUG + if (DebugCmd::EnableNewMap() && map_id == 2002) { + pos = glm::vec3(287.000000000000f, 6.19, 453); + } +#endif dtQueryFilter filter; filter.setIncludeFlags(0xffff); diff --git a/server/gameserver/mapmgr.cc b/server/gameserver/mapmgr.cc index 5351f31c..30b025fc 100644 --- a/server/gameserver/mapmgr.cc +++ b/server/gameserver/mapmgr.cc @@ -4,6 +4,7 @@ #include "room.h" #include "mapinstance.h" #include "roommgr.h" +#include "debugcmd.h" #include "mt/Map.h" #include "mt/PveGemini.h" @@ -17,7 +18,11 @@ void MapMgr::Init() [this] (const mt::Map* map_meta, bool& stop) { if (map_meta->map_id() == 2001 || - map_meta->map_id() == 1003 + map_meta->map_id() == 1003 || +#ifdef DEBUG + (DebugCmd::EnableNewMap() && map_meta->map_id() == 2002) || +#endif + false ) { auto map_instance = std::make_shared(); map_instance->map_id = map_meta->map_id(); @@ -98,6 +103,11 @@ void MapMgr::AttachRoom(Room* room, RoomInitInfo& init_info) } #endif } +#endif +#ifdef DEBUG + if (DebugCmd::EnableNewMap()) { + map_instance = GetMapInstance(2002); + } #endif if (!map_instance) { A8_ABORT(); diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 2d495ee4..f32ede33 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -35,6 +35,7 @@ #include "guide.h" #include "mapinstance.h" #include "compose.h" +#include "debugcmd.h" #include "mt/Param.h" #include "mt/Equip.h" @@ -1439,6 +1440,11 @@ void Player::PushJoinRoomMsg() notifymsg.set_map_id(room->GetMapMeta()->map_id()); #if 1 notifymsg.set_map_id(1001); +#endif +#ifdef DEBUG + if (DebugCmd::EnableNewMap()) { + notifymsg.set_map_id(room->GetMapMeta()->map_id()); + } #endif notifymsg.set_map_width(room->GetMapMeta()->map_width()); notifymsg.set_map_height(room->GetMapMeta()->map_height());