[Orxonox-commit 2758] r7463 - in code/trunk: data/levels data/levels/old src/modules/notifications src/modules/objects
dafrick at orxonox.net
dafrick at orxonox.net
Fri Sep 17 21:41:17 CEST 2010
Author: dafrick
Date: 2010-09-17 21:41:17 +0200 (Fri, 17 Sep 2010)
New Revision: 7463
Modified:
code/trunk/data/levels/Fight in our Back.oxw
code/trunk/data/levels/Quest_PirateAttack.oxw
code/trunk/data/levels/notifications.oxw
code/trunk/data/levels/old/princessaeryn.oxw
code/trunk/data/levels/old/questsystem.oxw
code/trunk/data/levels/princessaeryn.oxw
code/trunk/src/modules/notifications/Notification.cc
code/trunk/src/modules/objects/Script.cc
code/trunk/src/modules/objects/Script.h
Log:
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.
Modified: code/trunk/data/levels/Fight in our Back.oxw
===================================================================
--- code/trunk/data/levels/Fight in our Back.oxw 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/data/levels/Fight in our Back.oxw 2010-09-17 19:41:17 UTC (rev 7463)
@@ -68,7 +68,7 @@
skybox="Orxonox/skypanoramagen1"
>
- <Script code="showGUI NotificationLayer false true" />
+ <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
<!--Light: noch zu aendern -->
<Light type=directional position="0,0,0" direction="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 1.0, 0.9" />
Modified: code/trunk/data/levels/Quest_PirateAttack.oxw
===================================================================
--- code/trunk/data/levels/Quest_PirateAttack.oxw 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/data/levels/Quest_PirateAttack.oxw 2010-09-17 19:41:17 UTC (rev 7463)
@@ -34,7 +34,7 @@
skybox = "Orxonox/skypanoramagen1"
>
- <Script code="showGUI NotificationLayer false true" />
+ <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
Modified: code/trunk/data/levels/notifications.oxw
===================================================================
--- code/trunk/data/levels/notifications.oxw 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/data/levels/notifications.oxw 2010-09-17 19:41:17 UTC (rev 7463)
@@ -18,7 +18,7 @@
skybox = "Orxonox/skypanoramagen1"
>
- <Script code="showGUI NotificationLayer false true" />
+ <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
Modified: code/trunk/data/levels/old/princessaeryn.oxw
===================================================================
--- code/trunk/data/levels/old/princessaeryn.oxw 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/data/levels/old/princessaeryn.oxw 2010-09-17 19:41:17 UTC (rev 7463)
@@ -17,7 +17,7 @@
skybox = "Orxonox/skypanoramagen1"
>
- <Script code="showGUI NotificationLayer false true" />
+ <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
Modified: code/trunk/data/levels/old/questsystem.oxw
===================================================================
--- code/trunk/data/levels/old/questsystem.oxw 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/data/levels/old/questsystem.oxw 2010-09-17 19:41:17 UTC (rev 7463)
@@ -13,7 +13,7 @@
skybox = "Orxonox/Starbox"
>
- <Script code="showGUI NotificationLayer false true" />
+ <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
<GlobalQuest id="b80c2c60-e62c-4637-80f8-5aa18dc93b34">
<QuestDescription title="The Main QUest" description="This is the main quest hooray. Solve it!" failMessage="You fail. Looser." completeMessage="You Win." />
Modified: code/trunk/data/levels/princessaeryn.oxw
===================================================================
--- code/trunk/data/levels/princessaeryn.oxw 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/data/levels/princessaeryn.oxw 2010-09-17 19:41:17 UTC (rev 7463)
@@ -23,7 +23,7 @@
skybox = "Orxonox/skypanoramagen1"
>
- <Script code="showGUI NotificationLayer false true" />
+ <Script code="showGUI NotificationLayer false true" needsGraphics="true" />
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" />
Modified: code/trunk/src/modules/notifications/Notification.cc
===================================================================
--- code/trunk/src/modules/notifications/Notification.cc 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/src/modules/notifications/Notification.cc 2010-09-17 19:41:17 UTC (rev 7463)
@@ -113,6 +113,7 @@
*/
bool Notification::send(unsigned int clientId, const std::string & sender = NotificationManager::NONE)
{
+ COUT(0) << "MUP: " << Host::getPlayerID() << "|" << clientId << std::endl;
if(GameMode::isStandalone() || Host::getPlayerID() == clientId)
{
this->sendHelper(sender);
Modified: code/trunk/src/modules/objects/Script.cc
===================================================================
--- code/trunk/src/modules/objects/Script.cc 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/src/modules/objects/Script.cc 2010-09-17 19:41:17 UTC (rev 7463)
@@ -31,6 +31,7 @@
#include "core/command/CommandExecutor.h"
#include "core/CoreIncludes.h"
#include "core/EventIncludes.h"
+#include "core/GameMode.h"
#include "core/LuaState.h"
#include "core/XMLPort.h"
@@ -56,6 +57,10 @@
// Initialize variables.
this->luaState_ = NULL;
this->remainingExecutions_ = Script::INF;
+ this->mode_ = ScriptMode::normal;
+ this->onLoad_ = true;
+ this->times_ = Script::INF;
+ this->needsGraphics_ = false;
}
@@ -85,6 +90,7 @@
XMLPortParamTemplate(Script, "mode", setMode, getMode, xmlelement, mode, const std::string&).defaultValues(Script::NORMAL);
XMLPortParam(Script, "onLoad", setOnLoad, isOnLoad, xmlelement, mode).defaultValues(true);
XMLPortParam(Script, "times", setTimes, getTimes, xmlelement, mode).defaultValues(Script::INF);
+ XMLPortParam(Script, "needsGraphics", setNeedsGraphics, getNeedsGraphics, xmlelement, mode).defaultValues(false);
XMLPortEventSink(Script, BaseObject, "trigger", trigger, xmlelement, mode);
@@ -128,6 +134,10 @@
if(this->times_ != Script::INF && this->remainingExecutions_ == 0)
return;
+ // If the code needs graphics to be executed but the GameMode doesn't show graphics the code isn't executed.
+ if(this->needsGraphics_ && !GameMode::showsGraphics())
+ return;
+
if(this->mode_ == ScriptMode::normal) // If the mode is 'normal'.
CommandExecutor::execute(this->code_);
else if(this->mode_ == ScriptMode::lua) // If it's 'lua'.
Modified: code/trunk/src/modules/objects/Script.h
===================================================================
--- code/trunk/src/modules/objects/Script.h 2010-09-17 18:49:06 UTC (rev 7462)
+++ code/trunk/src/modules/objects/Script.h 2010-09-17 19:41:17 UTC (rev 7463)
@@ -54,15 +54,16 @@
'code': The code that should be executed.
'mode': The mode, specifying whether the set code should be executed the normal way ('normal') or in lua ('lua'). Default is 'normal'.
'onLoad': Whether the code is executed upon loading (creation) of this object. Default is true.
+ 'needsGraphics': Whether the code needs graphics to be executed or not. Default is false.
Here are two examples illustrating the usage:
@code
- <Script code="showGUI QuestGUI" />
+ <Script code="showGUI QuestGUI" needsGraphics=true />
@endcode
- 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.
+ 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.
@code
- <Script code="hideGUI QuestGUI" mode="normal" onLoad="false">
+ <Script code="hideGUI QuestGUI" mode="normal" onLoad="false" needsGraphics=true >
<events>
<trigger>
<DistanceTrigger distance=10 target="Pawn" />
@@ -70,7 +71,7 @@
</events>
</Script>
@endcode
- 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.
+ 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.
@author
Benjamin Knecht
Damian 'Mozork' Frick
@@ -124,6 +125,19 @@
inline int getTimes(void)
{ return this->times_; }
+ /**
+ @brief Set whether the code to be executed needs graphics to work.
+ @param needsGraphics True if the cde needs graphics to be executed properly.
+ */
+ void setNeedsGraphics(bool needsGraphics)
+ { this->needsGraphics_ = needsGraphics; }
+ /**
+ @brief Get whether the code to be executed needs graphics to work.
+ @return Returns true if the code needs graphic, false if not.
+ */
+ bool getNeedsGraphics(void)
+ { return this->needsGraphics_; }
+
private:
//! Static variables to avoid magic strings.
static const std::string NORMAL;
@@ -134,6 +148,7 @@
ScriptMode::Value mode_; //!< The mode the Script is in. Determines whether the code is executed the normal way or in lua.
bool onLoad_; //!< Whether the Scripts code is executed upon loading (creation) of this Script.
int times_; //!< The number of times the Scripts code is executed at the most. -1 denotes infinity.
+ bool needsGraphics_; //!< Whether the code to be executed needs graphics.
LuaState* luaState_; //!< The LuaState to execute the code in lua.
int remainingExecutions_; //!< The number of remainign executions. -1 denotes infinity.
More information about the Orxonox-commit
mailing list