Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7463 for code/trunk/src


Ignore:
Timestamp:
Sep 17, 2010, 9:41:17 PM (14 years ago)
Author:
dafrick
Message:

Fixing "bug", that caused crash in dedicated mode.
Script object can now specify whether the code that is executed by it needs graphics to work.

Location:
code/trunk/src/modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/modules/notifications/Notification.cc

    r7462 r7463  
    114114    bool Notification::send(unsigned int clientId, const std::string & sender = NotificationManager::NONE)
    115115    {
     116        COUT(0) << "MUP: " << Host::getPlayerID() << "|" << clientId << std::endl;
    116117        if(GameMode::isStandalone() || Host::getPlayerID() == clientId)
    117118        {
  • code/trunk/src/modules/objects/Script.cc

    r7410 r7463  
    3232#include "core/CoreIncludes.h"
    3333#include "core/EventIncludes.h"
     34#include "core/GameMode.h"
    3435#include "core/LuaState.h"
    3536#include "core/XMLPort.h"
     
    5758        this->luaState_ = NULL;
    5859        this->remainingExecutions_ = Script::INF;
     60        this->mode_ = ScriptMode::normal;
     61        this->onLoad_ = true;
     62        this->times_ = Script::INF;
     63        this->needsGraphics_ = false;
    5964
    6065    }
     
    8691        XMLPortParam(Script, "onLoad", setOnLoad, isOnLoad, xmlelement, mode).defaultValues(true);
    8792        XMLPortParam(Script, "times", setTimes, getTimes, xmlelement, mode).defaultValues(Script::INF);
     93        XMLPortParam(Script, "needsGraphics", setNeedsGraphics, getNeedsGraphics, xmlelement, mode).defaultValues(false);
    8894
    8995        XMLPortEventSink(Script, BaseObject, "trigger", trigger, xmlelement, mode);
     
    127133    {
    128134        if(this->times_ != Script::INF && this->remainingExecutions_ == 0)
     135            return;
     136
     137        // If the code needs graphics to be executed but the GameMode doesn't show graphics the code isn't executed.
     138        if(this->needsGraphics_ && !GameMode::showsGraphics())
    129139            return;
    130140
  • code/trunk/src/modules/objects/Script.h

    r7407 r7463  
    5555        'mode': The mode, specifying whether the set code should be executed the normal way ('normal') or in lua ('lua'). Default is 'normal'.
    5656        'onLoad': Whether the code is executed upon loading (creation) of this object. Default is true.
     57        'needsGraphics': Whether the code needs graphics to be executed or not. Default is false.
    5758
    5859        Here are two examples illustrating the usage:
    5960        @code
    60         <Script code="showGUI QuestGUI" />
     61        <Script code="showGUI QuestGUI" needsGraphics=true />
    6162        @endcode
    62         This would show the QuestGUI opon creation of the object. The mode is 'normal', not specified here since that is the default, also onLoad is true, also not specified, since it is the default as well.
     63        This would show the QuestGUI opon creation of the object. The mode is 'normal', not specified here since that is the default, also onLoad is true, also not specified, since it is the default as well. Also needsGraphics is set to true because showGUI needs graphics to work.
    6364
    6465        @code
    65         <Script code="hideGUI QuestGUI" mode="normal" onLoad="false">
     66        <Script code="hideGUI QuestGUI" mode="normal" onLoad="false" needsGraphics=true >
    6667            <events>
    6768                <trigger>
     
    7172        </Script>
    7273        @endcode
    73         This would hide the QuestGUI as soon as a Pawn got in range of the DistanceTrigger. The mode is 'normal', it is specified here, but could be ommitted as well, since it is the default. OnLoad is false, that is why it can't be ommitted.
     74        This would hide the QuestGUI as soon as a Pawn got in range of the DistanceTrigger. The mode is 'normal', it is specified here, but could be ommitted as well, since it is the default. OnLoad is false, that is why it can't be ommitted. Also needsGraphics is set to true because showGUI needs graphics to work.
    7475    @author
    7576        Benjamin Knecht
     
    125126                { return this->times_; }
    126127
     128            /**
     129            @brief Set whether the code to be executed needs graphics to work.
     130            @param needsGraphics True if the cde needs graphics to be executed properly.
     131            */
     132            void setNeedsGraphics(bool needsGraphics)
     133                { this->needsGraphics_ = needsGraphics; }
     134            /**
     135            @brief Get whether the code to be executed needs graphics to work.
     136            @return Returns true if the code needs graphic, false if not.
     137            */
     138            bool getNeedsGraphics(void)
     139                { return this->needsGraphics_; }
     140
    127141        private:
    128142            //! Static variables to avoid magic strings.
     
    135149            bool onLoad_; //!< Whether the Scripts code is executed upon loading (creation) of this Script.
    136150            int times_; //!< The number of times the Scripts code is executed at the most. -1 denotes infinity.
     151            bool needsGraphics_; //!< Whether the code to be executed needs graphics.
    137152
    138153            LuaState* luaState_; //!< The LuaState to execute the code in lua.
Note: See TracChangeset for help on using the changeset viewer.