From eea6cbdeecfb46c04b72b4e318cba13888390d10 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 8 Feb 2023 10:18:27 +0800 Subject: [PATCH] 1 --- server/gameserver/debugcmd.cc | 59 ++++++++++++++++++++++++++++++++--- server/gameserver/debugcmd.h | 16 +++++++++- server/gameserver/shot.cc | 9 ++++-- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/server/gameserver/debugcmd.cc b/server/gameserver/debugcmd.cc index 23f6547f..f56f59cb 100644 --- a/server/gameserver/debugcmd.cc +++ b/server/gameserver/debugcmd.cc @@ -11,14 +11,65 @@ static bool EnableDebug() return App::Instance()->instance_id == 6; } -void DebugCmd::CreateSphere(Creature* c, float x, float y, float z) +void DebugCmd::CreateSphere(Creature* c, + const glm::vec3& pos, + const glm::vec3& scale, + int uniid) + { if (c->IsPlayer() && EnableDebug()) { cs::SMDebugCmd msg; msg.set_cmd("create_sphere"); - msg.add_params(x); - msg.add_params(y); - msg.add_params(z); + msg.add_params(pos.x); + msg.add_params(pos.y); + msg.add_params(pos.z); + + msg.add_params(scale.x); + msg.add_params(scale.y); + msg.add_params(scale.z); + + msg.add_params(uniid); + + c->AsPlayer()->SendNotifyMsg(msg); + } +} + +void DebugCmd::CreateCube(Creature* c, + const glm::vec3& pos, + const glm::vec3& scale, + const glm::quat& rotation, + int uniid) +{ + if (c->IsPlayer() && EnableDebug()) { + cs::SMDebugCmd msg; + msg.set_cmd("create_cube"); + msg.add_params(pos.x); + msg.add_params(pos.y); + msg.add_params(pos.z); + + msg.add_params(scale.x); + msg.add_params(scale.y); + msg.add_params(scale.z); + + msg.add_params(rotation.x); + msg.add_params(rotation.y); + msg.add_params(rotation.z); + msg.add_params(rotation.w); + + msg.add_params(uniid); + + c->AsPlayer()->SendNotifyMsg(msg); + } +} + +void DebugCmd::DestoryGameObject(Creature* c, int uniid) +{ + if (c->IsPlayer() && EnableDebug()) { + cs::SMDebugCmd msg; + msg.set_cmd("destory_gameobject"); + + msg.add_params(uniid); + c->AsPlayer()->SendNotifyMsg(msg); } } diff --git a/server/gameserver/debugcmd.h b/server/gameserver/debugcmd.h index 53d5af90..4101c236 100644 --- a/server/gameserver/debugcmd.h +++ b/server/gameserver/debugcmd.h @@ -2,12 +2,26 @@ #ifdef DEBUG +#include +#include + class Creature; class DebugCmd { public: - static void CreateSphere(Creature* c, float x, float y, float z); + static void CreateSphere(Creature* c, + const glm::vec3& pos, + const glm::vec3& scale, + int uniid); + + static void CreateCube(Creature* c, + const glm::vec3& pos, + const glm::vec3& scale, + const glm::quat& rotation, + int uniid); + + static void DestoryGameObject(Creature* c, int uniid); }; diff --git a/server/gameserver/shot.cc b/server/gameserver/shot.cc index 4c49d114..a3475609 100644 --- a/server/gameserver/shot.cc +++ b/server/gameserver/shot.cc @@ -240,9 +240,12 @@ static void InternalCreateBullet(BulletInfo& bullet_info) #ifdef DEBUG DebugCmd::CreateSphere(c, - bullet_info.bullet_born_pos.x, - bullet_info.bullet_born_pos.y, - bullet_info.bullet_born_pos.z); + glm::vec3( + bullet_info.bullet_born_pos.x, + bullet_info.bullet_born_pos.y, + bullet_info.bullet_born_pos.z), + glm::vec3(1, 1, 1), + c->room->AllocUniid()); #endif c->room->frame_event.AddBullet