xoreos  0.0.5
functions_event.cpp
Go to the documentation of this file.
1 /* xoreos - A reimplementation of BioWare's Aurora engine
2  *
3  * xoreos is the legal property of its developers, whose names
4  * can be found in the AUTHORS file distributed with this source
5  * distribution.
6  *
7  * xoreos is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 3
10  * of the License, or (at your option) any later version.
11  *
12  * xoreos is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with xoreos. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
25 #include "src/common/util.h"
26 #include "src/common/error.h"
27 
32 
33 #include "src/engines/jade/event.h"
36 
38 
39 namespace Engines {
40 
41 namespace Jade {
42 
44  int32 eventNumber = ctx.getParams()[0].getInt();
45 
46  ctx.getReturn() = Event(kScriptOnUserdefined, eventNumber);
47 }
48 
51  if (!env)
52  return;
53 
55  const Event *event = Jade::ObjectContainer::toEvent(ctx.getParams()[1].getEngineType());
56 
57  if (event->getScript() == kScriptOnUserdefined)
58  env->setVariable("EVENT_USER_DEFINED_" + object->getTag(), event->getEventNumber());
59  object->runScript(event->getScript(), object, object);
60 }
61 
63  ctx.getReturn() = (int32) 0;
64 
66 
68  if (!env || !env->hasVariable("EVENT_USER_DEFINED_" + object->getTag()))
69  return;
70 
71  ctx.getReturn() = env->getVariable("EVENT_USER_DEFINED_" + object->getTag()).getInt();
72 }
73 
76 
78  if (!env)
79  return;
80 
82  int32 eventNumber = ctx.getParams()[1].getInt();
83 
84  env->setVariable("EVENT_USER_DEFINED_" + object->getTag(), eventNumber);
85 }
86 
87 } // End of namespace Jade
88 
89 } // End of namespace Engines
An object within a Jade Empire area.
void signalEvent(Aurora::NWScript::FunctionContext &ctx)
A scripting event.
void eventUserDefined(Aurora::NWScript::FunctionContext &ctx)
Context of an NWScript function.
Jade Empire engine functions.
static Aurora::NWScript::Object * getParamObject(const Aurora::NWScript::FunctionContext &ctx, size_t n)
Definition: functions.cpp:118
static Event * toEvent(Aurora::NWScript::EngineType *engineType)
SDL_Event Event
Definition: types.h:42
const Common::UString & getTag() const
Definition: object.h:49
A container of Jade Empire objects.
void setUserDefinedEventNumber(Aurora::NWScript::FunctionContext &ctx)
An NWScript engine type.
Basic exceptions to throw.
static Jade::Object * toObject(::Aurora::NWScript::Object *object)
Utility templates and functions.
VariableContainer * getCurrentEnvironment() const
An NWScript variable container.
An object within a Jade area.
Definition: object.h:53
void setVariable(const Common::UString &var, const Variable &value)
NWScript types.
void getUserDefinedEventNumber(Aurora::NWScript::FunctionContext &ctx)
int32_t int32
Definition: types.h:203