LCOV - code coverage report
Current view: top level - src - clientobject.h (source / functions) Hit Total Coverage
Test: report Lines: 7 32 21.9 %
Date: 2015-07-11 18:23:49 Functions: 3 26 11.5 %

          Line data    Source code
       1             : /*
       2             : Minetest
       3             : Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
       4             : 
       5             : This program is free software; you can redistribute it and/or modify
       6             : it under the terms of the GNU Lesser General Public License as published by
       7             : the Free Software Foundation; either version 2.1 of the License, or
       8             : (at your option) any later version.
       9             : 
      10             : This program is distributed in the hope that it will be useful,
      11             : but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      13             : GNU Lesser General Public License for more details.
      14             : 
      15             : You should have received a copy of the GNU Lesser General Public License along
      16             : with this program; if not, write to the Free Software Foundation, Inc.,
      17             : 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      18             : */
      19             : 
      20             : #ifndef CLIENTOBJECT_HEADER
      21             : #define CLIENTOBJECT_HEADER
      22             : 
      23             : #include "irrlichttypes_extrabloated.h"
      24             : #include "activeobject.h"
      25             : #include <map>
      26             : 
      27             : /*
      28             : 
      29             : Some planning
      30             : -------------
      31             : 
      32             : * Client receives a network packet with information of added objects
      33             :   in it
      34             : * Client supplies the information to its ClientEnvironment
      35             : * The environment adds the specified objects to itself
      36             : 
      37             : */
      38             : 
      39             : class ClientEnvironment;
      40             : class ITextureSource;
      41             : class IGameDef;
      42             : class LocalPlayer;
      43             : struct ItemStack;
      44             : class WieldMeshSceneNode;
      45             : 
      46             : class ClientActiveObject : public ActiveObject
      47             : {
      48             : public:
      49             :         ClientActiveObject(u16 id, IGameDef *gamedef, ClientEnvironment *env);
      50             :         virtual ~ClientActiveObject();
      51             : 
      52           0 :         virtual void addToScene(scene::ISceneManager *smgr, ITextureSource *tsrc,
      53           0 :                         IrrlichtDevice *irr){}
      54          47 :         virtual void removeFromScene(bool permanent){}
      55             :         // 0 <= light_at_pos <= LIGHT_SUN
      56           0 :         virtual void updateLight(u8 light_at_pos){}
      57           0 :         virtual v3s16 getLightPosition(){return v3s16(0,0,0);}
      58           0 :         virtual core::aabbox3d<f32>* getSelectionBox(){return NULL;}
      59           0 :         virtual bool getCollisionBox(aabb3f *toset){return false;}
      60           0 :         virtual bool collideWithObjects(){return false;}
      61           0 :         virtual v3f getPosition(){return v3f(0,0,0);}
      62           0 :         virtual scene::ISceneNode *getSceneNode(){return NULL;}
      63           0 :         virtual scene::IMeshSceneNode *getMeshSceneNode(){return NULL;}
      64           0 :         virtual scene::IAnimatedMeshSceneNode *getAnimatedMeshSceneNode(){return NULL;}
      65           0 :         virtual WieldMeshSceneNode *getWieldMeshSceneNode(){return NULL;}
      66           0 :         virtual scene::IBillboardSceneNode *getSpriteSceneNode(){return NULL;}
      67           0 :         virtual bool isPlayer() const {return false;}
      68           0 :         virtual bool isLocalPlayer() const {return false;}
      69           0 :         virtual void setAttachments(){}
      70           0 :         virtual bool doShowSelectionBox(){return true;}
      71           0 :         virtual void updateCameraOffset(v3s16 camera_offset){};
      72             : 
      73             :         // Step object in time
      74           0 :         virtual void step(float dtime, ClientEnvironment *env){}
      75             : 
      76             :         // Process a message sent by the server side object
      77           0 :         virtual void processMessage(const std::string &data){}
      78             : 
      79           0 :         virtual std::string infoText() {return "";}
      80           0 :         virtual std::string debugInfoText() {return "";}
      81             : 
      82             :         /*
      83             :                 This takes the return value of
      84             :                 ServerActiveObject::getClientInitializationData
      85             :         */
      86           0 :         virtual void initialize(const std::string &data){}
      87             : 
      88             :         // Create a certain type of ClientActiveObject
      89             :         static ClientActiveObject* create(ActiveObjectType type, IGameDef *gamedef,
      90             :                         ClientEnvironment *env);
      91             : 
      92             :         // If returns true, punch will not be sent to the server
      93           0 :         virtual bool directReportPunch(v3f dir, const ItemStack *punchitem=NULL,
      94             :                         float time_from_last_punch=1000000)
      95           0 :         { return false; }
      96             : 
      97             : protected:
      98             :         // Used for creating objects based on type
      99             :         typedef ClientActiveObject* (*Factory)(IGameDef *gamedef, ClientEnvironment *env);
     100             :         static void registerType(u16 type, Factory f);
     101             :         IGameDef *m_gamedef;
     102             :         ClientEnvironment *m_env;
     103             : private:
     104             :         // Used for creating objects based on type
     105             :         static std::map<u16, Factory> m_types;
     106             : };
     107             : 
     108             : struct DistanceSortedActiveObject
     109             : {
     110             :         ClientActiveObject *obj;
     111             :         f32 d;
     112             : 
     113       11899 :         DistanceSortedActiveObject(ClientActiveObject *a_obj, f32 a_d)
     114             :         {
     115       11899 :                 obj = a_obj;
     116       11899 :                 d = a_d;
     117       11899 :         }
     118             : 
     119         339 :         bool operator < (const DistanceSortedActiveObject &other) const
     120             :         {
     121         339 :                 return d < other.d;
     122             :         }
     123             : };
     124             : 
     125             : #endif

Generated by: LCOV version 1.11