diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game-server/monster.cpp | 16 | ||||
-rw-r--r-- | src/game-server/statusmanager.cpp | 2 | ||||
-rw-r--r-- | src/scripting/luautil.cpp | 18 |
3 files changed, 16 insertions, 20 deletions
diff --git a/src/game-server/monster.cpp b/src/game-server/monster.cpp index ffb178d..14eeee8 100644 --- a/src/game-server/monster.cpp +++ b/src/game-server/monster.cpp @@ -297,20 +297,12 @@ void Monster::update() void Monster::loadScript(const std::string &scriptName) { - if (mScript) - { - delete mScript;// A script has already been loaded for this monster - } + // A script may have already been loaded for this monster + delete mScript; + mScript = 0; if (scriptName.length() == 0) - { - if (mScript) - { - delete mScript; - mScript = NULL; - } return; - } std::stringstream filename; filename << "scripts/monster/" << scriptName; @@ -322,8 +314,6 @@ void Monster::loadScript(const std::string &scriptName) } else { LOG_WARN("Could not find script file \"" << filename.str() << "\" for monster"); } - - } int Monster::calculatePositionPriority(Point position, int targetPriority) diff --git a/src/game-server/statusmanager.cpp b/src/game-server/statusmanager.cpp index 702fd10..21c396e 100644 --- a/src/game-server/statusmanager.cpp +++ b/src/game-server/statusmanager.cpp @@ -87,7 +87,7 @@ void StatusManager::reload() modifiers.setAttributeValue(CHAR_ATTR_WILLPOWER, XML::getProperty(node, "willpower", 0)); */ StatusEffect *statusEffect = new StatusEffect(id); - if (scriptFile != "") + if (!scriptFile.empty()) { std::stringstream filename; filename << "scripts/status/" << scriptFile; diff --git a/src/scripting/luautil.cpp b/src/scripting/luautil.cpp index a3602d2..008a5e3 100644 --- a/src/scripting/luautil.cpp +++ b/src/scripting/luautil.cpp @@ -1,6 +1,7 @@ /* * The Mana Server * Copyright (C) 2007-2010 The Mana World Development Team + * Copyright (C) 2010 The Mana Developers * * This file is part of The Mana Server. * @@ -59,23 +60,28 @@ void raiseWarning(lua_State *s, const char *format, ...) NPC *getNPC(lua_State *s, int p) { - if (!lua_islightuserdata(s, p)) return NULL; + if (!lua_islightuserdata(s, p)) + return 0; Thing *t = static_cast<Thing *>(lua_touserdata(s, p)); - if (t->getType() != OBJECT_NPC) return NULL; + if (t->getType() != OBJECT_NPC) + return 0; return static_cast<NPC *>(t); } Character *getCharacter(lua_State *s, int p) { - if (!lua_islightuserdata(s, p)) return NULL; + if (!lua_islightuserdata(s, p)) + return 0; Thing *t = static_cast<Thing *>(lua_touserdata(s, p)); - if (t->getType() != OBJECT_CHARACTER) return NULL; + if (t->getType() != OBJECT_CHARACTER) + return 0; return static_cast<Character *>(t); } Being *getBeing(lua_State *s, int p) { - if (!lua_islightuserdata(s, p)) return NULL; + if (!lua_islightuserdata(s, p)) + return 0; Thing *t = static_cast<Thing *>(lua_touserdata(s, p)); return static_cast<Being *>(t); } @@ -90,7 +96,7 @@ void push(lua_State *s, const std::string &val) lua_pushstring(s, val.c_str()); } -void push(lua_State *s, Thing* val) +void push(lua_State *s, Thing *val) { lua_pushlightuserdata(s, val); } |