xoreos  0.0.5
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 
33 
35 
36 namespace Engines {
37 
38 namespace KotOR {
39 
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 
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 
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 
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
NWScript variable.
A class holding an UTF-8 string.
Definition: ustring.h:48
void setLocalBoolean(Aurora::NWScript::FunctionContext &ctx)
void getLocalNumber(Aurora::NWScript::FunctionContext &ctx)
UString composeString(T value)
Convert any POD integer, float/double or bool type into a string.
Definition: strutil.cpp:276
Context of an NWScript function.
void getLocalBoolean(Aurora::NWScript::FunctionContext &ctx)
Utility templates and functions for working with strings and streams.
void setLocalNumber(Aurora::NWScript::FunctionContext &ctx)
Star Wars: Knights of the Old Republic engine functions.
Unicode string handling.
An NWScript object.
NWScript types.