aboutsummaryrefslogtreecommitdiff
path: root/src/server/serveractiveobject.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/serveractiveobject.h')
-rw-r--r--src/server/serveractiveobject.h128
1 files changed, 66 insertions, 62 deletions
diff --git a/src/server/serveractiveobject.h b/src/server/serveractiveobject.h
index 927009aef..7af1c24c4 100644
--- a/src/server/serveractiveobject.h
+++ b/src/server/serveractiveobject.h
@@ -58,8 +58,7 @@ public:
ServerActiveObject(ServerEnvironment *env, v3f pos);
virtual ~ServerActiveObject() = default;
- virtual ActiveObjectType getSendType() const
- { return getType(); }
+ virtual ActiveObjectType getSendType() const { return getType(); }
// Called after id has been set and has been inserted in environment
virtual void addedToEnvironment(u32 dtime_s){};
@@ -67,35 +66,31 @@ public:
virtual void removingFromEnvironment(){};
// Returns true if object's deletion is the job of the
// environment
- virtual bool environmentDeletes() const
- { return true; }
+ virtual bool environmentDeletes() const { return true; }
// Create a certain type of ServerActiveObject
- static ServerActiveObject* create(ActiveObjectType type,
- ServerEnvironment *env, u16 id, v3f pos,
- const std::string &data);
+ static ServerActiveObject *create(ActiveObjectType type, ServerEnvironment *env,
+ u16 id, v3f pos, const std::string &data);
/*
Some simple getters/setters
*/
v3f getBasePosition() const { return m_base_position; }
- void setBasePosition(v3f pos){ m_base_position = pos; }
- ServerEnvironment* getEnv(){ return m_env; }
+ void setBasePosition(v3f pos) { m_base_position = pos; }
+ ServerEnvironment *getEnv() { return m_env; }
/*
Some more dynamic interface
*/
- virtual void setPos(const v3f &pos)
- { setBasePosition(pos); }
+ virtual void setPos(const v3f &pos) { setBasePosition(pos); }
// continuous: if true, object does not stop immediately at pos
- virtual void moveTo(v3f pos, bool continuous)
- { setBasePosition(pos); }
+ virtual void moveTo(v3f pos, bool continuous) { setBasePosition(pos); }
// If object has moved less than this and data has not changed,
// saving to disk may be omitted
virtual float getMinimumSavedMovement();
- virtual std::string getDescription(){return "SAO";}
+ virtual std::string getDescription() { return "SAO"; }
/*
Step object in time.
@@ -107,13 +102,16 @@ public:
same time so that the data can be combined in a single
packet.
*/
- virtual void step(float dtime, bool send_recommended){}
+ virtual void step(float dtime, bool send_recommended) {}
/*
The return value of this is passed to the client-side object
when it is created
*/
- virtual std::string getClientInitializationData(u16 protocol_version) {return "";}
+ virtual std::string getClientInitializationData(u16 protocol_version)
+ {
+ return "";
+ }
/*
The return value of this is passed to the server-side object
@@ -129,59 +127,65 @@ public:
Return false in here to never save and instead remove object
on unload. getStaticData() will not be called in that case.
*/
- virtual bool isStaticAllowed() const
- {return true;}
+ virtual bool isStaticAllowed() const { return true; }
// Returns tool wear
- virtual u16 punch(v3f dir,
- const ToolCapabilities *toolcap = nullptr,
+ virtual u16 punch(v3f dir, const ToolCapabilities *toolcap = nullptr,
ServerActiveObject *puncher = nullptr,
float time_from_last_punch = 1000000.0f)
- { return 0; }
- virtual void rightClick(ServerActiveObject *clicker)
- {}
- virtual void setHP(s32 hp, const PlayerHPChangeReason &reason)
- {}
- virtual u16 getHP() const
- { return 0; }
-
- virtual void setArmorGroups(const ItemGroupList &armor_groups)
- {}
+ {
+ return 0;
+ }
+ virtual void rightClick(ServerActiveObject *clicker) {}
+ virtual void setHP(s32 hp, const PlayerHPChangeReason &reason) {}
+ virtual u16 getHP() const { return 0; }
+
+ virtual void setArmorGroups(const ItemGroupList &armor_groups) {}
virtual const ItemGroupList &getArmorGroups() const
- { static ItemGroupList rv; return rv; }
- virtual void setPhysicsOverride(float physics_override_speed, float physics_override_jump, float physics_override_gravity)
- {}
- virtual void setAnimation(v2f frames, float frame_speed, float frame_blend, bool frame_loop)
- {}
- virtual void getAnimation(v2f *frames, float *frame_speed, float *frame_blend, bool *frame_loop)
- {}
- virtual void setAnimationSpeed(float frame_speed)
- {}
+ {
+ static ItemGroupList rv;
+ return rv;
+ }
+ virtual void setPhysicsOverride(float physics_override_speed,
+ float physics_override_jump, float physics_override_gravity)
+ {
+ }
+ virtual void setAnimation(
+ v2f frames, float frame_speed, float frame_blend, bool frame_loop)
+ {
+ }
+ virtual void getAnimation(v2f *frames, float *frame_speed, float *frame_blend,
+ bool *frame_loop)
+ {
+ }
+ virtual void setAnimationSpeed(float frame_speed) {}
virtual void setBonePosition(const std::string &bone, v3f position, v3f rotation)
- {}
- virtual void getBonePosition(const std::string &bone, v3f *position, v3f *lotation)
- {}
+ {
+ }
+ virtual void getBonePosition(
+ const std::string &bone, v3f *position, v3f *lotation)
+ {
+ }
virtual const std::unordered_set<int> &getAttachmentChildIds() const
- { static std::unordered_set<int> rv; return rv; }
+ {
+ static std::unordered_set<int> rv;
+ return rv;
+ }
virtual ServerActiveObject *getParent() const { return nullptr; }
- virtual ObjectProperties* accessObjectProperties()
- { return NULL; }
- virtual void notifyObjectPropertiesModified()
- {}
+ virtual ObjectProperties *accessObjectProperties() { return NULL; }
+ virtual void notifyObjectPropertiesModified() {}
// Inventory and wielded item
- virtual Inventory *getInventory() const
- { return NULL; }
+ virtual Inventory *getInventory() const { return NULL; }
virtual InventoryLocation getInventoryLocation() const
- { return InventoryLocation(); }
- virtual void setInventoryModified()
- {}
- virtual std::string getWieldList() const
- { return ""; }
- virtual u16 getWieldIndex() const
- { return 0; }
- virtual ItemStack getWieldedItem(ItemStack *selected,
- ItemStack *hand = nullptr) const;
+ {
+ return InventoryLocation();
+ }
+ virtual void setInventoryModified() {}
+ virtual std::string getWieldList() const { return ""; }
+ virtual u16 getWieldIndex() const { return 0; }
+ virtual ItemStack getWieldedItem(
+ ItemStack *selected, ItemStack *hand = nullptr) const;
virtual bool setWieldedItem(const ItemStack &item);
inline void attachParticleSpawner(u32 id)
{
@@ -193,7 +197,8 @@ public:
}
std::string generateUpdateInfantCommand(u16 infant_id, u16 protocol_version);
- std::string generateUpdateNametagAttributesCommand(const video::SColor &color) const;
+ std::string generateUpdateNametagAttributesCommand(
+ const video::SColor &color) const;
void dumpAOMessagesToQueue(std::queue<ActiveObjectMessage> &queue);
@@ -227,8 +232,7 @@ public:
A getter that unifies the above to answer the question:
"Can the environment still interact with this object?"
*/
- inline bool isGone() const
- { return m_pending_removal || m_pending_deactivation; }
+ inline bool isGone() const { return m_pending_removal || m_pending_deactivation; }
/*
Whether the object's static data has been stored to a block
@@ -238,7 +242,7 @@ public:
The block from which the object was loaded from, and in which
a copy of the static data resides.
*/
- v3s16 m_static_block = v3s16(1337,1337,1337);
+ v3s16 m_static_block = v3s16(1337, 1337, 1337);
protected:
virtual void onAttach(int parent_id) {}