From 4559ca444daacfd02ebb05f1657148a2b4cf3d8b Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Wed, 20 Feb 2013 22:46:55 +0100 Subject: Introduced Script::Context This should allow to finally call functions to lua without having to care about working around situations where a lua call causes a c++ call which needs to call to lua again. Tested against the source of tales repository data. --- src/scripting/lua.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/scripting/lua.cpp') diff --git a/src/scripting/lua.cpp b/src/scripting/lua.cpp index 4e2cd283..e305fcd7 100644 --- a/src/scripting/lua.cpp +++ b/src/scripting/lua.cpp @@ -1438,17 +1438,11 @@ static int chr_request_quest(lua_State *s) Script::Ref callback; script->assignCallback(callback); - // Backup the map since execute will reset it - MapComposite *map = script->getMap(); - script->prepare(callback); script->push(ch); script->push(name); script->push(value); - script->execute(); - - // Restore map - script->setMap(map); + script->execute(ch->getMap()); return 0; } @@ -2132,7 +2126,7 @@ static int get_map_id(lua_State *s) { Script *script = getScript(s); - if (MapComposite *mapComposite = script->getMap()) + if (MapComposite *mapComposite = script->getContext()->map) lua_pushinteger(s, mapComposite->getID()); else lua_pushnil(s); -- cgit v1.2.3-70-g09d2