12 changes: 6 additions & 6 deletions src/script/cpp_api/s_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ bool ScriptApiServer::getAuth(const std::string &playername,
getAuthHandler();
lua_getfield(L, -1, "get_auth");
if(lua_type(L, -1) != LUA_TFUNCTION)
throw LuaError(L, "Authentication handler missing get_auth");
throw LuaError(NULL, "Authentication handler missing get_auth");
lua_pushstring(L, playername.c_str());
if(lua_pcall(L, 1, 1, errorhandler))
scriptError();
Expand All @@ -48,13 +48,13 @@ bool ScriptApiServer::getAuth(const std::string &playername,
std::string password;
bool found = getstringfield(L, -1, "password", password);
if(!found)
throw LuaError(L, "Authentication handler didn't return password");
throw LuaError(NULL, "Authentication handler didn't return password");
if(dst_password)
*dst_password = password;

lua_getfield(L, -1, "privileges");
if(!lua_istable(L, -1))
throw LuaError(L, "Authentication handler didn't return privilege table");
throw LuaError(NULL, "Authentication handler didn't return privilege table");
if(dst_privs)
readPrivileges(-1, *dst_privs);
lua_pop(L, 1);
Expand All @@ -74,7 +74,7 @@ void ScriptApiServer::getAuthHandler()
}
lua_remove(L, -2); // Remove minetest
if(lua_type(L, -1) != LUA_TTABLE)
throw LuaError(L, "Authentication handler table not valid");
throw LuaError(NULL, "Authentication handler table not valid");
}

void ScriptApiServer::readPrivileges(int index, std::set<std::string> &result)
Expand Down Expand Up @@ -108,7 +108,7 @@ void ScriptApiServer::createAuth(const std::string &playername,
lua_getfield(L, -1, "create_auth");
lua_remove(L, -2); // Remove auth handler
if(lua_type(L, -1) != LUA_TFUNCTION)
throw LuaError(L, "Authentication handler missing create_auth");
throw LuaError(NULL, "Authentication handler missing create_auth");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
if(lua_pcall(L, 2, 0, errorhandler))
Expand All @@ -128,7 +128,7 @@ bool ScriptApiServer::setPassword(const std::string &playername,
lua_getfield(L, -1, "set_password");
lua_remove(L, -2); // Remove auth handler
if(lua_type(L, -1) != LUA_TFUNCTION)
throw LuaError(L, "Authentication handler missing set_password");
throw LuaError(NULL, "Authentication handler missing set_password");
lua_pushstring(L, playername.c_str());
lua_pushstring(L, password.c_str());
if(lua_pcall(L, 2, 1, errorhandler))
Expand Down
2 changes: 1 addition & 1 deletion src/script/lua_api/l_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ModApiBase {
ScriptApiBase *scriptIface = getScriptApiBase(L);
T *scriptIfaceDowncast = dynamic_cast<T*>(scriptIface);
if (!scriptIfaceDowncast) {
throw LuaError(L, "Requested unavailable ScriptApi - core engine bug!");
throw LuaError(NULL, "Requested unavailable ScriptApi - core engine bug!");
}
return scriptIfaceDowncast;
}
Expand Down
28 changes: 14 additions & 14 deletions src/script/lua_api/l_craft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,24 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(type == "shaped"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
throw LuaError(L, "Crafting definition is missing an output");
throw LuaError(NULL, "Crafting definition is missing an output");

int width = 0;
std::vector<std::string> recipe;
lua_getfield(L, table, "recipe");
if(lua_isnil(L, -1))
throw LuaError(L, "Crafting definition is missing a recipe"
throw LuaError(NULL, "Crafting definition is missing a recipe"
" (output=\"" + output + "\")");
if(!readCraftRecipeShaped(L, -1, width, recipe))
throw LuaError(L, "Invalid crafting recipe"
throw LuaError(NULL, "Invalid crafting recipe"
" (output=\"" + output + "\")");

CraftReplacements replacements;
lua_getfield(L, table, "replacements");
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
throw LuaError(L, "Invalid replacements"
throw LuaError(NULL, "Invalid replacements"
" (output=\"" + output + "\")");
}

Expand All @@ -181,25 +181,25 @@ int ModApiCraft::l_register_craft(lua_State *L)
else if(type == "shapeless"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
throw LuaError(L, "Crafting definition (shapeless)"
throw LuaError(NULL, "Crafting definition (shapeless)"
" is missing an output");

std::vector<std::string> recipe;
lua_getfield(L, table, "recipe");
if(lua_isnil(L, -1))
throw LuaError(L, "Crafting definition (shapeless)"
throw LuaError(NULL, "Crafting definition (shapeless)"
" is missing a recipe"
" (output=\"" + output + "\")");
if(!readCraftRecipeShapeless(L, -1, recipe))
throw LuaError(L, "Invalid crafting recipe"
throw LuaError(NULL, "Invalid crafting recipe"
" (output=\"" + output + "\")");

CraftReplacements replacements;
lua_getfield(L, table, "replacements");
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
throw LuaError(L, "Invalid replacements"
throw LuaError(NULL, "Invalid replacements"
" (output=\"" + output + "\")");
}

Expand All @@ -224,12 +224,12 @@ int ModApiCraft::l_register_craft(lua_State *L)
else if(type == "cooking"){
std::string output = getstringfield_default(L, table, "output", "");
if(output == "")
throw LuaError(L, "Crafting definition (cooking)"
throw LuaError(NULL, "Crafting definition (cooking)"
" is missing an output");

std::string recipe = getstringfield_default(L, table, "recipe", "");
if(recipe == "")
throw LuaError(L, "Crafting definition (cooking)"
throw LuaError(NULL, "Crafting definition (cooking)"
" is missing a recipe"
" (output=\"" + output + "\")");

Expand All @@ -240,7 +240,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
throw LuaError(L, "Invalid replacements"
throw LuaError(NULL, "Invalid replacements"
" (cooking output=\"" + output + "\")");
}

Expand All @@ -254,7 +254,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
else if(type == "fuel"){
std::string recipe = getstringfield_default(L, table, "recipe", "");
if(recipe == "")
throw LuaError(L, "Crafting definition (fuel)"
throw LuaError(NULL, "Crafting definition (fuel)"
" is missing a recipe");

float burntime = getfloatfield_default(L, table, "burntime", 1.0);
Expand All @@ -264,7 +264,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
if(!lua_isnil(L, -1))
{
if(!readCraftReplacements(L, -1, replacements))
throw LuaError(L, "Invalid replacements"
throw LuaError(NULL, "Invalid replacements"
" (fuel recipe=\"" + recipe + "\")");
}

Expand All @@ -274,7 +274,7 @@ int ModApiCraft::l_register_craft(lua_State *L)
}
else
{
throw LuaError(L, "Unknown crafting definition type: \"" + type + "\"");
throw LuaError(NULL, "Unknown crafting definition type: \"" + type + "\"");
}

lua_pop(L, 1);
Expand Down
4 changes: 2 additions & 2 deletions src/script/lua_api/l_item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ int ModApiItemMod::l_register_item_raw(lua_State *L)
name = lua_tostring(L, -1);
verbosestream<<"register_item_raw: "<<name<<std::endl;
} else {
throw LuaError(L, "register_item_raw: name is not defined or not a string");
throw LuaError(NULL, "register_item_raw: name is not defined or not a string");
}

// Check if on_use is defined
Expand Down Expand Up @@ -500,7 +500,7 @@ int ModApiItemMod::l_register_item_raw(lua_State *L)
content_t id = ndef->set(f.name, f);

if(id > MAX_REGISTERED_CONTENT){
throw LuaError(L, "Number of registerable nodes ("
throw LuaError(NULL, "Number of registerable nodes ("
+ itos(MAX_REGISTERED_CONTENT+1)
+ ") exceeded (" + name + ")");
}
Expand Down
4 changes: 2 additions & 2 deletions src/script/lua_api/l_noise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,10 @@ int LuaPseudoRandom::l_next(lua_State *L)
max = luaL_checkinteger(L, 3);
if(max < min){
errorstream<<"PseudoRandom.next(): max="<<max<<" min="<<min<<std::endl;
throw LuaError(L, "PseudoRandom.next(): max < min");
throw LuaError(NULL, "PseudoRandom.next(): max < min");
}
if(max - min != 32767 && max - min > 32767/5)
throw LuaError(L, "PseudoRandom.next() max-min is not 32767"
throw LuaError(NULL, "PseudoRandom.next() max-min is not 32767"
" and is > 32768/5. This is disallowed due to"
" the bad random distribution the"
" implementation would otherwise make.");
Expand Down
17 changes: 0 additions & 17 deletions src/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,6 @@ class ServerEnvironment;
struct SimpleSoundSpec;


class ServerError : public std::exception
{
public:
ServerError(const std::string &s)
{
m_s = "ServerError: ";
m_s += s;
}
virtual ~ServerError() throw()
{}
virtual const char * what() const throw()
{
return m_s.c_str();
}
std::string m_s;
};

/*
Some random functions
*/
Expand Down