Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7483 for code/trunk/src


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

Removing some debug output and come minor cleaning up.

Location:
code/trunk/src/modules/objects
Files:
2 edited

Legend:

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

    r7482 r7483  
    5555    /*static*/ const int Script::INF = -1;
    5656
    57     /*static*/ LuaState* Script::LUA_STATE = NULL;
    58 
    5957    /**
    6058    @brief
     
    185183    void Script::execute(unsigned int clientId, bool fromCallback)
    186184    {
    187         COUT(0) << "EXECUTE: " << Host::getPlayerID() << " | " << clientId << std::endl; //TODO: Remove.
    188185        // If this is the server or we're in standalone mode we check whether we still want to execute the code and if so decrease the number of remaining executions.
    189186        if(GameMode::isServer() || GameMode::isStandalone())
     
    192189            if(this->times_ != Script::INF && this->remainingExecutions_ == 0)
    193190                return;
    194 
    195             // Decrement the number of remaining executions.
    196             //TODO: Mode such that this is consistent in any case.
    197             if(this->times_ != Script::INF)
    198                 this->remainingExecutions_--;
    199191        }
    200192
     
    208200        if(!GameMode::isStandalone() && GameMode::isServer() && Host::getPlayerID() != clientId)
    209201        {
    210             COUT(0) << "1" << std::endl; //TODO: Remove.
    211202            // If this is not the result of a clientConnected callback and we want to execute the code for all clients.
    212203            //TODO: In this case does the server get executed as well?
     
    217208                {
    218209                    callStaticNetworkFunction(Script::executeHelper, it->first, this->getCode(), this->getMode(), this->getNeedsGraphics());
     210                    if(this->times_ != Script::INF) // Decrement the number of remaining executions.
     211                        this->remainingExecutions_--;
    219212                }
    220213            }
     
    222215            else
    223216            {
    224                 COUT(0) << "2" << std::endl; //TODO: Remove.
    225217                callStaticNetworkFunction(Script::executeHelper, clientId, this->getCode(), this->getMode(), this->getNeedsGraphics());
     218                if(this->times_ != Script::INF) // Decrement the number of remaining executions.
     219                    this->remainingExecutions_--;
    226220            }
    227221        }
     
    234228    /*static*/ void Script::executeHelper(const std::string& code, const std::string& mode, bool needsGraphics)
    235229    {
    236         COUT(0) << "HELPER: " << code << " | " << mode << " | " << needsGraphics << std::endl; //TODO: Remove.
    237 
    238230        // If the code needs graphics to be executed but the GameMode doesn't show graphics the code isn't executed.
    239231        if(needsGraphics && !GameMode::showsGraphics())
     
    244236        else if(mode == Script::LUA) // If it's 'lua'.
    245237        {
    246             if(Script::LUA_STATE == NULL)
    247                 Script::LUA_STATE = new LuaState();
    248             Script::LUA_STATE->doString(code);
     238            LuaState* luaState = new LuaState();
     239            luaState->doString(code);
     240            delete luaState;
    249241        }
    250242    }
     
    261253        if(!GameMode::isStandalone() && GameMode::isServer() && this->isOnLoad())
    262254        {
    263             if(clientId != 0) //TODO: Remove if not needed.
    264                 this->execute(clientId, true);
     255            this->execute(clientId, true);
    265256        }
    266257    }
  • code/trunk/src/modules/objects/Script.h

    r7482 r7483  
    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             static LuaState* LUA_STATE; //!< The LuaState to execute the code in lua.
    179178            int remainingExecutions_; //!< The number of remainign executions. -1 denotes infinity.
    180179
Note: See TracChangeset for help on using the changeset viewer.