X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fcontent_sao.h;h=e9047daf0aa47131c27a4ab2811d0225400c119d;hb=2b3490db1f0e99a427e34135770f8e5afcf275ce;hp=9fbddbc5ad274904adfdb33c9f19a1139af673e3;hpb=a687efa6dfb97927d94db4d2f05970cde9d4181f;p=dragonfireclient.git diff --git a/src/content_sao.h b/src/content_sao.h index 9fbddbc5a..e9047daf0 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -45,23 +45,25 @@ class UnitSAO: public ServerActiveObject inline bool isAttached() const { return getParent(); } + inline bool isImmortal() const - { return itemgroup_get(m_armor_groups, "immortal"); } + { return itemgroup_get(getArmorGroups(), "immortal"); } void setArmorGroups(const ItemGroupList &armor_groups); - const ItemGroupList &getArmorGroups(); + const ItemGroupList &getArmorGroups() const; void setAnimation(v2f frame_range, float frame_speed, float frame_blend, bool frame_loop); void getAnimation(v2f *frame_range, float *frame_speed, float *frame_blend, bool *frame_loop); void setAnimationSpeed(float frame_speed); void setBonePosition(const std::string &bone, v3f position, v3f rotation); void getBonePosition(const std::string &bone, v3f *position, v3f *rotation); void setAttachment(int parent_id, const std::string &bone, v3f position, v3f rotation); - void getAttachment(int *parent_id, std::string *bone, v3f *position, v3f *rotation); + void getAttachment(int *parent_id, std::string *bone, v3f *position, + v3f *rotation) const; void clearChildAttachments(); void clearParentAttachment(); void addAttachmentChild(int child_id); void removeAttachmentChild(int child_id); - const std::unordered_set &getAttachmentChildIds(); + const std::unordered_set &getAttachmentChildIds() const; ServerActiveObject *getParent() const; ObjectProperties* accessObjectProperties(); void notifyObjectPropertiesModified(); @@ -106,7 +108,7 @@ class LuaEntitySAO : public UnitSAO { public: LuaEntitySAO(ServerEnvironment *env, v3f pos, - const std::string &name, const std::string &state); + const std::string &name, const std::string &state); ~LuaEntitySAO(); ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_LUAENTITY; } @@ -114,16 +116,16 @@ class LuaEntitySAO : public UnitSAO { return ACTIVEOBJECT_TYPE_GENERIC; } virtual void addedToEnvironment(u32 dtime_s); static ServerActiveObject* create(ServerEnvironment *env, v3f pos, - const std::string &data); + const std::string &data); void step(float dtime, bool send_recommended); std::string getClientInitializationData(u16 protocol_version); bool isStaticAllowed() const { return m_prop.static_save; } void getStaticData(std::string *result) const; - int punch(v3f dir, - const ToolCapabilities *toolcap=NULL, - ServerActiveObject *puncher=NULL, - float time_from_last_punch=1000000); + u16 punch(v3f dir, + const ToolCapabilities *toolcap = nullptr, + ServerActiveObject *puncher = nullptr, + float time_from_last_punch = 1000000.0f); void rightClick(ServerActiveObject *clicker); void setPos(const v3f &pos); void moveTo(v3f pos, bool continuous); @@ -131,6 +133,7 @@ class LuaEntitySAO : public UnitSAO std::string getDescription(); void setHP(s32 hp, const PlayerHPChangeReason &reason); u16 getHP() const; + /* LuaEntitySAO-specific */ void setVelocity(v3f velocity); void addVelocity(v3f velocity) @@ -216,7 +219,7 @@ class PlayerSAO : public UnitSAO public: PlayerSAO(ServerEnvironment *env_, RemotePlayer *player_, session_t peer_id_, bool is_singleplayer); - ~PlayerSAO(); + ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_PLAYER; } ActiveObjectType getSendType() const @@ -255,7 +258,7 @@ class PlayerSAO : public UnitSAO Interaction interface */ - int punch(v3f dir, + u16 punch(v3f dir, const ToolCapabilities *toolcap, ServerActiveObject *puncher, float time_from_last_punch); @@ -269,16 +272,13 @@ class PlayerSAO : public UnitSAO /* Inventory interface */ - - Inventory* getInventory(); - const Inventory* getInventory() const; + Inventory *getInventory() const; InventoryLocation getInventoryLocation() const; - std::string getWieldList() const; - ItemStack getWieldedItem() const; - ItemStack getWieldedItemOrHand() const; + void setInventoryModified() {} + std::string getWieldList() const { return "main"; } + u16 getWieldIndex() const; + ItemStack getWieldedItem(ItemStack *selected, ItemStack *hand = nullptr) const; bool setWieldedItem(const ItemStack &item); - int getWieldIndex() const; - void setWieldIndex(int i); /* PlayerSAO-specific @@ -322,6 +322,7 @@ class PlayerSAO : public UnitSAO { return m_dig_pool; } + void setMaxSpeedOverride(const v3f &vel); // Returns true if cheated bool checkMovementCheat(); @@ -352,7 +353,6 @@ class PlayerSAO : public UnitSAO RemotePlayer *m_player = nullptr; session_t m_peer_id = 0; - Inventory *m_inventory = nullptr; // Cheat prevention LagPool m_dig_pool; @@ -362,13 +362,14 @@ class PlayerSAO : public UnitSAO float m_time_from_last_punch = 0.0f; v3s16 m_nocheat_dig_pos = v3s16(32767, 32767, 32767); float m_nocheat_dig_time = 0.0f; + float m_max_speed_override_time = 0.0f; + v3f m_max_speed_override = v3f(0.0f, 0.0f, 0.0f); // Timers IntervalLimiter m_breathing_interval; IntervalLimiter m_drowning_interval; IntervalLimiter m_node_hurt_interval; - int m_wield_index = 0; bool m_position_not_sent = false; // Cached privileges for enforcement