Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

- Fix definitivly clear lua environment precedent problem (precedent …

…commit fix was wrong)
  • Loading branch information...
commit 4ef5022e0dca3a2ff1d2fd64019b9b440f87fde5 1 parent 9d1db21
Mathieu MathieuPOUX authored
8 CumulusServer/sources/Script.cpp
View
@@ -35,9 +35,13 @@ using namespace Cumulus;
lua_Debug Script::LuaDebug;
const char* Script::LastError(lua_State *pState) {
+ int top = lua_gettop(pState);
+ if(top==0)
+ return "Unknown error";
const char* error = lua_tostring(pState,-1);
- if(error)
- lua_pop(pState,1);
+ lua_pop(pState,1);
+ if(!error)
+ return "Unknown error";
return error;
}
14 CumulusServer/sources/Service.cpp
View
@@ -380,10 +380,9 @@ void Service::load() {
while (lua_next(_pState, -2) != 0) {
// uses 'key' (at index -2) and 'value' (at index -1)
// remove the raw!
- if(lua_istable(_pState,-1)) {
- lua_pushnil(_pState);
- lua_setfield(_pState,-4,lua_tostring(_pState,-3));
- }
+ lua_pushvalue(_pState,-2); // duplicate key
+ lua_pushnil(_pState);
+ lua_rawset(_pState,-5);
lua_pop(_pState,1);
}
}
@@ -435,10 +434,9 @@ void Service::clear() {
while (lua_next(_pState, -2) != 0) {
// uses 'key' (at index -2) and 'value' (at index -1)
// remove the raw!
- if(lua_istable(_pState,-1)) {
- lua_pushnil(_pState);
- lua_setfield(_pState,-4,lua_tostring(_pState,-3));
- }
+ lua_pushvalue(_pState,-2); // duplicate key
+ lua_pushnil(_pState);
+ lua_rawset(_pState,-5);
lua_pop(_pState,1);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.