summaryrefslogtreecommitdiff
path: root/src/scripting
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-26 17:05:18 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-04-26 17:18:21 +0200
commit43e99491a76bb85faf60c004e84b6c2b14cf41e7 (patch)
tree4aba689b76138118b4da043425fb3e8576db418c /src/scripting
parente726c34606f85347e70a0deb6b180db03b6d0c25 (diff)
downloadmanaserv-43e99491a76bb85faf60c004e84b6c2b14cf41e7.tar.gz
manaserv-43e99491a76bb85faf60c004e84b6c2b14cf41e7.tar.bz2
manaserv-43e99491a76bb85faf60c004e84b6c2b14cf41e7.tar.xz
manaserv-43e99491a76bb85faf60c004e84b6c2b14cf41e7.zip
Standardize on the position of the const keyword
Same as for the client.
Diffstat (limited to 'src/scripting')
-rw-r--r--src/scripting/lua.cpp10
-rw-r--r--src/scripting/luascript.cpp16
-rw-r--r--src/scripting/luascript.hpp15
-rw-r--r--src/scripting/script.cpp9
-rw-r--r--src/scripting/script.hpp15
5 files changed, 34 insertions, 31 deletions
diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp
index 9ddc68e0..c2c6baf9 100644
--- a/src/scripting/lua.cpp
+++ b/src/scripting/lua.cpp
@@ -68,7 +68,7 @@ static int npc_message(lua_State *s)
NPC *p = getNPC(s, 1);
Character *q = getCharacter(s, 2);
size_t l;
- char const *m = lua_tolstring(s, 3, &l);
+ const char *m = lua_tolstring(s, 3, &l);
if (!p || !q || !m)
{
raiseScriptError(s, "npc_message called with incorrect parameters.");
@@ -98,7 +98,7 @@ static int npc_choice(lua_State *s)
msg.writeShort(p->getPublicID());
for (int i = 3, i_end = lua_gettop(s); i <= i_end; ++i)
{
- char const *m = lua_tostring(s, i);
+ const char *m = lua_tostring(s, i);
if (!m)
{
raiseScriptError(s, "npc_Choice called with incorrect parameters.");
@@ -601,7 +601,7 @@ static int chr_get_quest(lua_State *s)
raiseScriptError(s, "chr_get_quest called for nonexistent character.");
}
- char const *m = lua_tostring(s, 2);
+ const char *m = lua_tostring(s, 2);
if (!m || m[0] == 0)
{
raiseScriptError(s, "chr_get_quest called with incorrect parameters.");
@@ -629,8 +629,8 @@ static int chr_get_quest(lua_State *s)
static int chr_set_quest(lua_State *s)
{
Character *q = getCharacter(s, 1);
- char const *m = lua_tostring(s, 2);
- char const *n = lua_tostring(s, 3);
+ const char *m = lua_tostring(s, 2);
+ const char *n = lua_tostring(s, 3);
if (!m || !n || m[0] == 0)
{
raiseScriptError(s, "chr_set_quest called with incorrect parameters.");
diff --git a/src/scripting/luascript.cpp b/src/scripting/luascript.cpp
index c88b95fd..a28c4a9a 100644
--- a/src/scripting/luascript.cpp
+++ b/src/scripting/luascript.cpp
@@ -32,7 +32,7 @@ LuaScript::~LuaScript()
lua_close(mState);
}
-void LuaScript::prepare(std::string const &name)
+void LuaScript::prepare(const std::string &name)
{
assert(nbArgs == -1);
lua_getglobal(mState, name.c_str());
@@ -47,7 +47,7 @@ void LuaScript::push(int v)
++nbArgs;
}
-void LuaScript::push(std::string const &v)
+void LuaScript::push(const std::string &v)
{
assert(nbArgs >= 0);
lua_pushstring(mState, v.c_str());
@@ -68,7 +68,7 @@ int LuaScript::execute()
nbArgs = -1;
if (res || !(lua_isnil(mState, 1) || lua_isnumber(mState, 1)))
{
- char const *s = lua_tostring(mState, 1);
+ const char *s = lua_tostring(mState, 1);
LOG_WARN("Lua Script Error" << std::endl
<< " Script : " << mScriptFile << std::endl
@@ -83,7 +83,7 @@ int LuaScript::execute()
mCurFunction = "";
}
-void LuaScript::load(char const *prog)
+void LuaScript::load(const char *prog)
{
int res = luaL_loadstring(mState, prog);
@@ -128,8 +128,8 @@ void LuaScript::processRemoveEvent(Thing *being)
/**
* Called when the server has recovered the value of a quest variable.
*/
-void LuaScript::getQuestCallback(Character *q, std::string const &name,
- std::string const &value, void *data)
+void LuaScript::getQuestCallback(Character *q, const std::string &name,
+ const std::string &value, void *data)
{
LuaScript *s = static_cast< LuaScript * >(data);
assert(s->nbArgs == -1);
@@ -144,8 +144,8 @@ void LuaScript::getQuestCallback(Character *q, std::string const &name,
/**
* Called when the server has recovered the post for a user
*/
-void LuaScript::getPostCallback(Character *q, std::string const &sender,
- std::string const &letter, void *data)
+void LuaScript::getPostCallback(Character *q, const std::string &sender,
+ const std::string &letter, void *data)
{
// get the script
LuaScript *s = static_cast<LuaScript*>(data);
diff --git a/src/scripting/luascript.hpp b/src/scripting/luascript.hpp
index d4dc116e..398fbecf 100644
--- a/src/scripting/luascript.hpp
+++ b/src/scripting/luascript.hpp
@@ -36,7 +36,8 @@ class LuaScript: public Script
{
public:
/**
- * Constructor.
+ * Constructor. Initializes a new Lua state, registers the native API
+ * and loads the libtmw.lua file.
*/
LuaScript();
@@ -45,9 +46,9 @@ class LuaScript: public Script
*/
~LuaScript();
- void load(char const *);
+ void load(const char *);
- void prepare(std::string const &);
+ void prepare(const std::string &);
void push(int);
@@ -57,11 +58,11 @@ class LuaScript: public Script
int execute();
- static void getQuestCallback(Character *, std::string const &,
- std::string const &, void *);
+ static void getQuestCallback(Character *, const std::string &,
+ const std::string &, void *);
- static void getPostCallback(Character *, std::string const &,
- std::string const &, void *);
+ static void getPostCallback(Character *, const std::string &,
+ const std::string &, void *);
void processDeathEvent(Being* thing);
diff --git a/src/scripting/script.cpp b/src/scripting/script.cpp
index f334eb19..e343b558 100644
--- a/src/scripting/script.cpp
+++ b/src/scripting/script.cpp
@@ -36,7 +36,7 @@ Script::Script():
mEventListener(&scriptEventDispatch)
{}
-void Script::registerEngine(std::string const &name, Factory f)
+void Script::registerEngine(const std::string &name, Factory f)
{
if (!engines)
{
@@ -49,7 +49,7 @@ void Script::registerEngine(std::string const &name, Factory f)
(*engines)[name] = f;
}
-Script *Script::create(std::string const &engine)
+Script *Script::create(const std::string &engine)
{
if (engines)
{
@@ -69,7 +69,7 @@ void Script::update()
execute();
}
-bool Script::loadFile(std::string const &name)
+bool Script::loadFile(const std::string &name)
{
int size;
char *buffer = ResourceManager::loadFile(name, size);
@@ -84,7 +84,8 @@ bool Script::loadFile(std::string const &name)
}
}
-void Script::loadNPC(std::string const &name, int id, int x, int y, char const *prog)
+void Script::loadNPC(const std::string &name, int id, int x, int y,
+ const char *prog)
{
load(prog);
prepare("create_npc_delayed");
diff --git a/src/scripting/script.hpp b/src/scripting/script.hpp
index 24a415ef..1674e483 100644
--- a/src/scripting/script.hpp
+++ b/src/scripting/script.hpp
@@ -41,12 +41,12 @@ class Script
/**
* Registers a new scripting engine.
*/
- static void registerEngine(std::string const &, Factory);
+ static void registerEngine(const std::string &, Factory);
/**
* Creates a new script context for a given engine.
*/
- static Script *create(std::string const &engine);
+ static Script *create(const std::string &engine);
/**
* Constructor.
@@ -62,19 +62,20 @@ class Script
* Loads a chunk of text into script context and executes its global
* statements.
*/
- virtual void load(char const *) = 0;
+ virtual void load(const char *) = 0;
/**
* Loads a text file into script context and executes its global
* statements.
*/
- virtual bool loadFile(std::string const &);
+ virtual bool loadFile(const std::string &);
/**
* Loads a chunk of text and considers it as an NPC handler. This
* handler will later be used to create the given NPC.
*/
- virtual void loadNPC(std::string const &name, int id, int x, int y, char const *);
+ virtual void loadNPC(const std::string &name, int id, int x, int y,
+ const char *);
/**
* Called every tick for the script to manage its data.
@@ -86,7 +87,7 @@ class Script
* Prepares a call to the given function.
* Only one function can be prepared at once.
*/
- virtual void prepare(std::string const &name) = 0;
+ virtual void prepare(const std::string &name) = 0;
/**
* Pushes an integer argument for the function being prepared.
@@ -96,7 +97,7 @@ class Script
/**
* Pushes a string argument for the function being prepared.
*/
- virtual void push(std::string const &) = 0;
+ virtual void push(const std::string &) = 0;
/**
* Pushes a pointer argument to a game entity.