Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Sep 23, 2010, 11:12:22 AM (14 years ago)
Author:
dafrick
Message:

Fixed Script class. Works now without having to rely on guessing how long it is going to take for the object to be synchronized.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/objects/Script.h

    r7474 r7482  
     1
    12/*
    23 *   ORXONOX - the hottest 3D action shooter ever to exist
     
    3637
    3738#include "core/BaseObject.h"
    38 #include "tools/interfaces/Tickable.h"
    3939#include "network/synchronisable/Synchronisable.h"
    4040#include "network/ClientConnectionListener.h"
     
    8383        Damian 'Mozork' Frick
    8484    */
    85     class _ObjectsExport Script : public BaseObject, public Synchronisable, public ClientConnectionListener, public Tickable
     85    class _ObjectsExport Script : public BaseObject, public Synchronisable, public ClientConnectionListener
    8686    {
    8787        public:
     
    9292            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); //!< Creates a port that can be used to channel events and react to them.
    9393
    94             virtual void tick(float dt);
    95 
    9694            bool trigger(bool triggered, BaseObject* trigger); //!< Is called when an event comes in trough the event port.
    9795            void execute(unsigned int clientId, bool fromCallback = false); //!< Executes the Scripts code for the input client, depending on the mode.
     96            static void executeHelper(const std::string& code, const std::string& mode, bool needsGraphics); //!< Helper method that is used to reach this Script object on other clients.
    9897
    9998            /**
     
    160159                { return this->forAll_; }
    161160
    162             virtual void clientConnected(unsigned int clientId);
     161            virtual void clientConnected(unsigned int clientId); //!< Callback that is called when a new client has connected.
    163162            virtual void clientDisconnected(unsigned int clientid) {}
    164163
     
    171170            std::string code_; //!< The code that is executed by this Script.
    172171            ScriptMode::Value mode_; //!< The mode the Script is in. Determines whether the code is executed the normal way or in lua.
     172            std::string modeStr_; //!< The mode the Script is in, as a string. Is used for networking purposes.
    173173            bool onLoad_; //!< Whether the Scripts code is executed upon loading (creation) of this Script.
    174174            int times_; //!< The number of times the Scripts code is executed at the most. -1 denotes infinity.
     
    176176            bool forAll_; //!< Whether the code is executed for all players (in a multiplayer setup) or just for the one triggering the Script.
    177177
    178             std::string modeStr_;
    179 
    180             std::vector<unsigned int> clientCallbacks_;
    181             float counter_;
    182 
    183             LuaState* luaState_; //!< The LuaState to execute the code in lua.
     178            static LuaState* LUA_STATE; //!< The LuaState to execute the code in lua.
    184179            int remainingExecutions_; //!< The number of remainign executions. -1 denotes infinity.
    185180
    186             void registerVariables(void);
    187             void modeChanged();
     181            void modeChanged(); //!< Sets the mode to the mode specified in this->modeStr_.
    188182
    189183            /**
Note: See TracChangeset for help on using the changeset viewer.