diff options
author | Matyas Dolak <dolak@eset.cz> | 2015-02-20 09:51:18 +0100 |
---|---|---|
committer | Matyas Dolak <dolak@eset.cz> | 2015-02-20 09:51:18 +0100 |
commit | 5d4dd103a12a44c8482d524c38841221da1d8fb2 (patch) | |
tree | c8d8dabc0efd733919f8eae39c693a01a28e6f11 /src/Bindings/ManualBindings.cpp | |
parent | Flower pots: In 1.8 items are saved with the name and not the id. (diff) | |
download | cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.tar cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.tar.gz cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.tar.bz2 cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.tar.lz cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.tar.xz cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.tar.zst cuberite-5d4dd103a12a44c8482d524c38841221da1d8fb2.zip |
Diffstat (limited to 'src/Bindings/ManualBindings.cpp')
-rw-r--r-- | src/Bindings/ManualBindings.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index 24e3f0052..30bce6525 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -165,6 +165,14 @@ static AString GetLogMessage(lua_State * tolua_S) static int tolua_LOG(lua_State * tolua_S) { + // If there's no param, spit out an error message instead of crashing: + if (lua_isnil(tolua_S, 1)) + { + LOGWARNING("Attempting to LOG a nil value!"); + cLuaState::LogStackTrace(tolua_S); + return 0; + } + // If the param is a cCompositeChat, read the log level from it: cLogger::eLogLevel LogLevel = cLogger::llRegular; tolua_Error err; @@ -184,6 +192,14 @@ static int tolua_LOG(lua_State * tolua_S) static int tolua_LOGINFO(lua_State * tolua_S) { + // If there's no param, spit out an error message instead of crashing: + if (lua_isnil(tolua_S, 1)) + { + LOGWARNING("Attempting to LOGINFO a nil value!"); + cLuaState::LogStackTrace(tolua_S); + return 0; + } + cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llInfo); return 0; } @@ -194,6 +210,14 @@ static int tolua_LOGINFO(lua_State * tolua_S) static int tolua_LOGWARN(lua_State * tolua_S) { + // If there's no param, spit out an error message instead of crashing: + if (lua_isnil(tolua_S, 1)) + { + LOGWARNING("Attempting to LOGWARN a nil value!"); + cLuaState::LogStackTrace(tolua_S); + return 0; + } + cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llWarning); return 0; } @@ -204,6 +228,14 @@ static int tolua_LOGWARN(lua_State * tolua_S) static int tolua_LOGERROR(lua_State * tolua_S) { + // If there's no param, spit out an error message instead of crashing: + if (lua_isnil(tolua_S, 1)) + { + LOGWARNING("Attempting to LOGERROR a nil value!"); + cLuaState::LogStackTrace(tolua_S); + return 0; + } + cLogger::GetInstance().LogSimple(GetLogMessage(tolua_S).c_str(), cLogger::llError); return 0; } |