diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index a905d17..02cb191 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -8,6 +8,7 @@ #include "skill.h" #include "human.h" #include "collider.h" +#include "roomobstacle.h" void InternalShot(Creature* c, MetaData::Equip* weapon_meta, @@ -1203,3 +1204,40 @@ void Creature::CheckSpecObject() } #endif } + +RoomObstacle* Creature::SummonObstacle(int id, const a8::Vec2& pos) +{ + RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y); + if (obstacle) { + obstacle->master.Attach(this); + room->xtimer.AddRepeatTimerAndAttach + ( + SERVER_FRAME_RATE, + a8::XParams() + .SetSender(obstacle), + [] (const a8::XParams& param) + { + RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData(); + obstacle->ActiveTimerFunc(); + }, + &obstacle->xtimer_attacher.timer_list_ + ); + + room->xtimer.AddRepeatTimerAndAttach + ( + SERVER_FRAME_RATE, + a8::XParams() + .SetSender(obstacle), + [] (const a8::XParams& param) + { + RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData(); + obstacle->UpdateTimerFunc(); + }, + &obstacle->xtimer_attacher.timer_list_ + ); + + } else { + abort(); + } + return obstacle; +} diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 3a1a4b2..e62ccb2 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -15,6 +15,7 @@ namespace MetaData struct xtimer_list; class Skill; class Obstacle; +class RoomObstacle; class Creature : public MoveableEntity { public: @@ -113,6 +114,7 @@ class Creature : public MoveableEntity virtual void _UpdateMove(int speed) {}; void CheckSpecObject(); + RoomObstacle* SummonObstacle(int id, const a8::Vec2& pos); private: diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index e08c745..c9414a4 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -1878,43 +1878,6 @@ void Human::WinExp(Human* sender, int exp) } } -RoomObstacle* Human::SummonObstacle(int id, const a8::Vec2& pos) -{ - RoomObstacle* obstacle = room->CreateObstacle(id, pos.x, pos.y); - if (obstacle) { - obstacle->master.Attach(this); - room->xtimer.AddRepeatTimerAndAttach - ( - SERVER_FRAME_RATE, - a8::XParams() - .SetSender(obstacle), - [] (const a8::XParams& param) - { - RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData(); - obstacle->ActiveTimerFunc(); - }, - &obstacle->xtimer_attacher.timer_list_ - ); - - room->xtimer.AddRepeatTimerAndAttach - ( - SERVER_FRAME_RATE, - a8::XParams() - .SetSender(obstacle), - [] (const a8::XParams& param) - { - RoomObstacle* obstacle = (RoomObstacle*)param.sender.GetUserData(); - obstacle->UpdateTimerFunc(); - }, - &obstacle->xtimer_attacher.timer_list_ - ); - - } else { - abort(); - } - return obstacle; -} - void Human::_InternalUpdateMove(float speed) { float nx = move_dir.x * speed; diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 960f925..4eca4bf 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -238,7 +238,6 @@ class Human : public Creature int GetSeat() { return seat_; } void SetSeat(int seat) { seat_ = seat; } void DeadDrop(); - RoomObstacle* SummonObstacle(int id, const a8::Vec2& pos); virtual std::string GetName() override { return name;}; protected: