xoreos
0.0.5
src
engines
kotor
script
functions_local.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
26
#include "
src/common/ustring.h
"
27
#include "
src/common/strutil.h
"
28
29
#include "
src/aurora/nwscript/functioncontext.h
"
30
#include "
src/aurora/nwscript/variable.h
"
31
#include "
src/aurora/nwscript/types.h
"
32
#include "
src/aurora/nwscript/object.h
"
33
34
#include "
src/engines/kotor/script/functions.h
"
35
36
namespace
Engines
{
37
38
namespace
KotOR {
39
40
void
Functions::getLocalBoolean
(
Aurora::NWScript::FunctionContext
&ctx) {
41
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[0].getObject();
42
if
(
object
) {
43
Common::UString
name =
Common::composeString
(ctx.
getParams
()[1].getInt());
44
Aurora::NWScript::Variable
&var =
object
->getVariable(name,
Aurora::NWScript::kTypeInt
);
45
ctx.
getReturn
() = var.
getInt
() != 0;
46
}
47
}
48
49
void
Functions::setLocalBoolean
(
Aurora::NWScript::FunctionContext
&ctx) {
50
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[0].getObject();
51
if
(
object
) {
52
Common::UString
name =
Common::composeString
(ctx.
getParams
()[1].getInt());
53
Aurora::NWScript::Variable
&var =
object
->getVariable(name,
Aurora::NWScript::kTypeInt
);
54
var = ctx.
getParams
()[2].getInt();
55
}
56
}
57
58
void
Functions::getLocalNumber
(
Aurora::NWScript::FunctionContext
&ctx) {
59
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[0].getObject();
60
if
(
object
) {
61
Common::UString
name =
Common::composeString
(ctx.
getParams
()[1].getInt());
62
Aurora::NWScript::Variable
&var =
object
->getVariable(name,
Aurora::NWScript::kTypeInt
);
63
ctx.
getReturn
() = var.
getInt
();
64
}
65
}
66
67
void
Functions::setLocalNumber
(
Aurora::NWScript::FunctionContext
&ctx) {
68
Aurora::NWScript::Object
*
object
= ctx.
getParams
()[0].getObject();
69
if
(
object
) {
70
Common::UString
name =
Common::composeString
(ctx.
getParams
()[1].getInt());
71
Aurora::NWScript::Variable
&var =
object
->getVariable(name,
Aurora::NWScript::kTypeInt
);
72
var = ctx.
getParams
()[2].getInt();
73
}
74
}
75
76
}
// End of namespace KotOR
77
78
}
// End of namespace Engines
Aurora::NWScript::Object
Definition:
object.h:37
variable.h
NWScript variable.
Common::UString
A class holding an UTF-8 string.
Definition:
ustring.h:48
Engines::KotOR::Functions::setLocalBoolean
void setLocalBoolean(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_local.cpp:49
Engines::KotOR::Functions::getLocalNumber
void getLocalNumber(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_local.cpp:58
Common::composeString
UString composeString(T value)
Convert any POD integer, float/double or bool type into a string.
Definition:
strutil.cpp:276
functioncontext.h
Context of an NWScript function.
Aurora::NWScript::kTypeInt
Definition:
types.h:38
Engines::KotOR::Functions::getLocalBoolean
void getLocalBoolean(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_local.cpp:40
strutil.h
Utility templates and functions for working with strings and streams.
Aurora::NWScript::FunctionContext
Definition:
functioncontext.h:42
Engines::KotOR::Functions::setLocalNumber
void setLocalNumber(Aurora::NWScript::FunctionContext &ctx)
Definition:
functions_local.cpp:67
Aurora::NWScript::Variable::getInt
int32 getInt() const
Definition:
variable.cpp:293
Engines
Definition:
console.cpp:69
Aurora::NWScript::Variable
Definition:
variable.h:56
functions.h
Star Wars: Knights of the Old Republic engine functions.
Aurora::NWScript::FunctionContext::getParams
Parameters & getParams()
Definition:
functioncontext.cpp:151
ustring.h
Unicode string handling.
object.h
An NWScript object.
Aurora::NWScript::FunctionContext::getReturn
Variable & getReturn()
Definition:
functioncontext.cpp:143
types.h
NWScript types.
Generated on Sun Nov 18 2018 15:13:40 for xoreos by
1.8.14