From 329a1c0a0896c05ffb6954883248cb87f82daa56 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 10 May 2012 20:19:49 +0200 Subject: Removed raiseScriptError It wasn't really adding anything since errors raised using luaL_error are already logged anyway. Reviewed-by: Erik Schilling --- src/scripting/lua.cpp | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 56f60f81..d3218a65 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -238,8 +238,8 @@ static int npc_choice(lua_State *s) } else { - raiseScriptError(s, "npc_choice called " - "with incorrect parameters."); + luaL_error(s, "npc_choice called " + "with incorrect parameters."); return 0; } lua_pop(s, 1); @@ -247,7 +247,7 @@ static int npc_choice(lua_State *s) } else { - raiseScriptError(s, "npc_choice called with incorrect parameters."); + luaL_error(s, "npc_choice called with incorrect parameters."); return 0; } } @@ -397,7 +397,7 @@ static int chr_warp(lua_State *s) bool b = lua_isnil(s, 2); if (!(b || lua_isnumber(s, 2) || lua_isstring(s, 2))) { - raiseScriptError(s, "chr_warp called with incorrect parameters."); + luaL_error(s, "chr_warp called with incorrect parameters."); return 0; } MapComposite *m; @@ -580,8 +580,8 @@ static int chr_inv_change(lua_State *s) if (!(lua_isnumber(s, i * 2 + 2) || lua_isstring(s, i * 2 + 2)) || !lua_isnumber(s, i * 2 + 3)) { - raiseScriptError(s, "chr_inv_change called with " - "incorrect parameters."); + luaL_error(s, "chr_inv_change called with " + "incorrect parameters."); return 0; } @@ -626,7 +626,7 @@ static int chr_inv_count(lua_State *s) Character *q = checkCharacter(s, 1); if (!lua_isboolean(s, 2) || !lua_isboolean(s, 3)) { - raiseScriptError(s, "chr_inv_count called with incorrect parameters."); + luaL_error(s, "chr_inv_count called with incorrect parameters."); return 0; } @@ -761,9 +761,8 @@ static int npc_trade(lua_State *s) Character *q = checkCharacter(s, 2); if (!lua_isboolean(s, 3)) { - raiseWarning(s, "npc_trade called with incorrect parameters."); - lua_pushinteger(s, 2); // return value - return 1; // Returns 1 parameter + luaL_error(s, "npc_trade called with incorrect parameters."); + return 0; } bool sellMode = lua_toboolean(s, 3); @@ -997,8 +996,7 @@ static int being_damage(lua_State *s) if (!being->canFight()) { - raiseScriptError(s, "being_damage called with " - "victim that cannot fight"); + luaL_error(s, "being_damage called with victim that cannot fight"); return 0; } @@ -1015,8 +1013,7 @@ static int being_damage(lua_State *s) if (!source->canFight()) { - raiseScriptError(s, "being_damage called with " - "source that cannot fight"); + luaL_error(s, "being_damage called with source that cannot fight"); return 0; } } @@ -1315,8 +1312,7 @@ static int monster_get_name(lua_State *s) MonsterClass *spec = monsterManager->getMonster(id); if (!spec) { - raiseScriptError(s, "monster_get_name " - "called with unknown monster id."); + luaL_error(s, "monster_get_name called with unknown monster id."); return 0; } lua_pushstring(s, spec->getName().c_str()); @@ -1561,7 +1557,7 @@ static int trigger_create(lua_State *s) if (!lua_isboolean(s, 7)) { - raiseScriptError(s, "trigger_create called with incorrect parameters."); + luaL_error(s, "trigger_create called with incorrect parameters."); return 0; } @@ -1975,8 +1971,11 @@ static int chr_set_special_recharge_speed(lua_State *s) const int speed = luaL_checkint(s, 3); if (c->setSpecialRechargeSpeed(special, speed)) - raiseScriptError(s, "chr_set_special_mana called with special " - "that is not owned by character."); + { + luaL_error(s, + "chr_set_special_mana called with special " + "that is not owned by character."); + } return 0; } @@ -2008,8 +2007,11 @@ static int chr_set_special_mana(lua_State *s) const int special = checkSpecial(s, 2); const int mana = luaL_checkint(s, 3); if (!c->setSpecialMana(special, mana)) - raiseScriptError(s, "chr_set_special_mana called with special " - "that is not owned by character."); + { + luaL_error(s, + "chr_set_special_mana called with special " + "that is not owned by character."); + } return 0; } @@ -2204,7 +2206,7 @@ static int item_get_name(lua_State *s) ItemClass *it = itemManager->getItem(id); if (!it) { - raiseScriptError(s, "item_get_name called with unknown item id."); + luaL_error(s, "item_get_name called with unknown item id."); return 0; } lua_pushstring(s, it->getName().c_str()); -- cgit v1.2.3-70-g09d2