diff --git a/src/activeobject.h b/src/activeobject.h index 46880fc7f..3dd1f98f5 100644 --- a/src/activeobject.h +++ b/src/activeobject.h @@ -23,7 +23,16 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "irr_aabb3d.h" #include -#define ACTIVEOBJECT_TYPE_INVALID 0 +enum ActiveObjectType { + ACTIVEOBJECT_TYPE_INVALID = 0, + ACTIVEOBJECT_TYPE_TEST = 1, + ACTIVEOBJECT_TYPE_ITEM = 2, + ACTIVEOBJECT_TYPE_LUAENTITY = 7, +// Special type, not stored as a static object + ACTIVEOBJECT_TYPE_PLAYER = 100, +// Special type, only exists as CAO + ACTIVEOBJECT_TYPE_GENERIC = 101, +}; // Other types are defined in content_object.h struct ActiveObjectMessage @@ -60,7 +69,7 @@ public: m_id = id; } - virtual u8 getType() const = 0; + virtual ActiveObjectType getType() const = 0; virtual bool getCollisionBox(aabb3f *toset) = 0; virtual bool collideWithObjects() = 0; protected: diff --git a/src/content_cao.cpp b/src/content_cao.cpp index 6d41b2749..4994c8b20 100644 --- a/src/content_cao.cpp +++ b/src/content_cao.cpp @@ -34,7 +34,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "serialization.h" // For decompressZlib #include "gamedef.h" #include "clientobject.h" -#include "content_object.h" #include "mesh.h" #include "itemdef.h" #include "tool.h" @@ -145,7 +144,7 @@ public: TestCAO(IGameDef *gamedef, ClientEnvironment *env); virtual ~TestCAO(); - u8 getType() const + ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; } @@ -289,7 +288,7 @@ public: ItemCAO(IGameDef *gamedef, ClientEnvironment *env); virtual ~ItemCAO(); - u8 getType() const + ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_ITEM; } diff --git a/src/content_cao.h b/src/content_cao.h index 69e2e54a2..31ccd04d4 100644 --- a/src/content_cao.h +++ b/src/content_cao.h @@ -22,7 +22,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include #include "irrlichttypes_extrabloated.h" -#include "content_object.h" #include "clientobject.h" #include "object_properties.h" #include "itemgroup.h" @@ -115,7 +114,7 @@ public: return new GenericCAO(gamedef, env); } - inline u8 getType() const + inline ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_GENERIC; } diff --git a/src/content_object.h b/src/content_object.h deleted file mode 100644 index 65a829773..000000000 --- a/src/content_object.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -Minetest -Copyright (C) 2010-2013 celeron55, Perttu Ahola - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along -with this program; if not, write to the Free Software Foundation, Inc., -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ - -#ifndef CONTENT_OBJECT_HEADER -#define CONTENT_OBJECT_HEADER - -#define ACTIVEOBJECT_TYPE_TEST 1 -#define ACTIVEOBJECT_TYPE_ITEM 2 -#define ACTIVEOBJECT_TYPE_RAT 3 -#define ACTIVEOBJECT_TYPE_OERKKI1 4 -#define ACTIVEOBJECT_TYPE_FIREFLY 5 -#define ACTIVEOBJECT_TYPE_MOBV2 6 - -#define ACTIVEOBJECT_TYPE_LUAENTITY 7 - -// Special type, not stored as a static object -#define ACTIVEOBJECT_TYPE_PLAYER 100 - -// Special type, only exists as CAO -#define ACTIVEOBJECT_TYPE_GENERIC 101 - -#endif - diff --git a/src/content_sao.cpp b/src/content_sao.cpp index d4b3079ec..8cb8fa788 100644 --- a/src/content_sao.cpp +++ b/src/content_sao.cpp @@ -35,54 +35,6 @@ with this program; if not, write to the Free Software Foundation, Inc., std::map ServerActiveObject::m_types; -/* - DummyLoadSAO -*/ - -class DummyLoadSAO : public ServerActiveObject -{ -public: - DummyLoadSAO(ServerEnvironment *env, v3f pos, u8 type): - ServerActiveObject(env, pos) - { - ServerActiveObject::registerType(type, create); - } - // Pretend to be the test object (to fool the client) - u8 getType() const - { return ACTIVEOBJECT_TYPE_TEST; } - // And never save to disk - bool isStaticAllowed() const - { return false; } - - static ServerActiveObject* create(ServerEnvironment *env, v3f pos, - const std::string &data) - { - return new DummyLoadSAO(env, pos, 0); - } - - void step(float dtime, bool send_recommended) - { - m_removed = true; - infostream<<"DummyLoadSAO step"< box(-BS/3.,0.0,-BS/3., BS/3.,BS*2./3.,BS/3.); - collisionMoveResult moveresult; - // Apply gravity - m_speed_f += v3f(0, -dtime*9.81*BS, 0); - // Maximum movement without glitches - f32 pos_max_d = BS*0.25; - // Limit speed - if(m_speed_f.getLength()*dtime > pos_max_d) - m_speed_f *= pos_max_d / (m_speed_f.getLength()*dtime); - v3f pos_f = getBasePosition(); - v3f accel_f = v3f(0,0,0); - f32 stepheight = 0; - moveresult = collisionMoveSimple(m_env,m_env->getGameDef(), - pos_max_d, box, stepheight, dtime, - pos_f, m_speed_f, accel_f); - - if(send_recommended == false) - return; - - if(pos_f.getDistanceFrom(m_last_sent_position) > 0.05*BS) - { - setBasePosition(pos_f); - m_last_sent_position = pos_f; - - std::ostringstream os(std::ios::binary); - // command (0 = update position) - writeU8(os, 0); - // pos - writeV3F1000(os, m_base_position); - // create message and add to list - ActiveObjectMessage aom(getId(), false, os.str()); - m_messages_out.push_back(aom); - } - if(m_itemstring_changed) - { - m_itemstring_changed = false; - - std::ostringstream os(std::ios::binary); - // command (1 = update itemstring) - writeU8(os, 1); - // itemstring - os<getGameDef()->idef(); - ItemStack item; - item.deSerialize(m_itemstring, idef); - infostream<<__FUNCTION_NAME<<": m_itemstring=\""< item=\""<getInventory(); - if(inv != NULL) - { - std::string wieldlist = puncher->getWieldList(); - ItemStack leftover = inv->addItem(wieldlist, item); - puncher->setInventoryModified(); - if(leftover.empty()) - { - m_removed = true; - } - else - { - m_itemstring = leftover.getItemString(); - m_itemstring_changed = true; - } - } - - return 0; - } - - bool getCollisionBox(aabb3f *toset) { - return false; - } - - bool collideWithObjects() { - return false; - } - -private: - std::string m_itemstring; - bool m_itemstring_changed; - v3f m_speed_f; - v3f m_last_sent_position; - IntervalLimiter m_move_interval; -}; - -// Prototype (registers item for deserialization) -ItemSAO proto_ItemSAO(NULL, v3f(0,0,0), ""); - -ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos, - const std::string &itemstring) -{ - return new ItemSAO(env, pos, itemstring); -} - /* LuaEntitySAO */ diff --git a/src/content_sao.h b/src/content_sao.h index 38baeab3a..05f727e16 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -21,14 +21,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #define CONTENT_SAO_HEADER #include "serverobject.h" -#include "content_object.h" #include "itemgroup.h" #include "player.h" #include "object_properties.h" -ServerActiveObject* createItemSAO(ServerEnvironment *env, v3f pos, - const std::string &itemstring); - /* LuaEntitySAO needs some internals exposed. */ @@ -39,9 +35,9 @@ public: LuaEntitySAO(ServerEnvironment *env, v3f pos, const std::string &name, const std::string &state); ~LuaEntitySAO(); - u8 getType() const + ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_LUAENTITY; } - u8 getSendType() const + ActiveObjectType getSendType() const { return ACTIVEOBJECT_TYPE_GENERIC; } virtual void addedToEnvironment(u32 dtime_s); static ServerActiveObject* create(ServerEnvironment *env, v3f pos, @@ -158,9 +154,9 @@ public: PlayerSAO(ServerEnvironment *env_, Player *player_, u16 peer_id_, const std::set &privs, bool is_singleplayer); ~PlayerSAO(); - u8 getType() const + ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_PLAYER; } - u8 getSendType() const + ActiveObjectType getSendType() const { return ACTIVEOBJECT_TYPE_GENERIC; } std::string getDescription(); diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 2445803d7..505faa09d 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -406,19 +406,6 @@ int ModApiEnvMod::l_add_item(lua_State *L) script_error(L); lua_remove(L, errorhandler); // Remove error handler return 1; - /*lua_pushvalue(L, 1); - lua_pushstring(L, "__builtin:item"); - lua_pushstring(L, item.getItemString().c_str()); - return l_add_entity(L);*/ - /*// Do it - ServerActiveObject *obj = createItemSAO(env, pos, item.getItemString()); - int objectid = env->addActiveObject(obj); - // If failed to add, return nothing (reads as nil) - if(objectid == 0) - return 0; - // Return ObjectRef - objectrefGetOrCreate(L, obj); - return 1;*/ } // get_player_by_name(name) diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 4286840fe..e048d072f 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -26,7 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "log.h" #include "tool.h" #include "serverobject.h" -#include "content_object.h" #include "content_sao.h" #include "server.h" #include "hud.h" diff --git a/src/serverobject.h b/src/serverobject.h index 8e80225e4..96485d7a3 100644 --- a/src/serverobject.h +++ b/src/serverobject.h @@ -58,7 +58,7 @@ public: ServerActiveObject(ServerEnvironment *env, v3f pos); virtual ~ServerActiveObject(); - virtual u8 getSendType() const + virtual ActiveObjectType getSendType() const { return getType(); } // Called after id has been set and has been inserted in environment