From: Ingo Ruhnke Date: Wed, 13 Aug 2014 04:08:57 +0000 (+0200) Subject: Removed load/save functions from scripting interface X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c81b842f4880cd7b4958e03e983e50bff95d02ef;p=supertux.git Removed load/save functions from scripting interface --- diff --git a/data/scripts/console.nut b/data/scripts/console.nut index 16464db49..66d205565 100644 --- a/data/scripts/console.nut +++ b/data/scripts/console.nut @@ -26,13 +26,11 @@ function play() function worldmapfinish() { - save_state(); foreach(world in state.worlds) { foreach(levelname, level in world.levels) { level.solved = true; } } - update_worldmap(); } function grow() diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 045114e7a..5e2aace38 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -97,24 +97,6 @@ void display_text_file(const std::string& filename) g_screen_manager->push_screen(std::unique_ptr(new TextScroller(filename))); } -void load_worldmap(const std::string& filename) -{ - using namespace worldmap; - - if(World::current() == NULL) - throw std::runtime_error("Can't start WorldMap without active world."); - - g_screen_manager->push_screen(std::unique_ptr(new WorldMap(filename, World::current()->get_player_status()))); -} - -void load_level(const std::string& filename) -{ - if(GameSession::current() == NULL) - throw std::runtime_error("Can't start level without active level."); - - g_screen_manager->push_screen(std::unique_ptr(new GameSession(filename, GameSession::current()->get_player_status()))); -} - void import(HSQUIRRELVM vm, const std::string& filename) { IFileStream in(filename); @@ -161,27 +143,6 @@ void debug_worldmap_ghost(bool enable) WorldMap::current()->get_tux()->set_ghost_mode(enable); } -void save_state() -{ - using namespace worldmap; - - if(World::current() == NULL || WorldMap::current() == NULL) - throw std::runtime_error("Can't save state without active World"); - - WorldMap::current()->save_state(); - World::current()->save_state(); -} - -void update_worldmap() -{ - using namespace worldmap; - - if(WorldMap::current() == NULL) - throw std::runtime_error("Can't update Worldmap: none active"); - - WorldMap::current()->load_state(); -} - // not added to header, function to only be used by others // in this file bool validate_sector_player() diff --git a/src/scripting/functions.hpp b/src/scripting/functions.hpp index e1828c2bf..638d77e18 100644 --- a/src/scripting/functions.hpp +++ b/src/scripting/functions.hpp @@ -48,16 +48,6 @@ SQInteger get_current_thread(HSQUIRRELVM vm) __custom("t"); void display_text_file(const std::string& filename); /** - * Load and display a worldmap (on next screenswitch) - */ -void load_worldmap(const std::string& filename); - -/** - * Load and display a level (on next screenswitch) - */ -void load_level(const std::string& filename); - -/** * Suspend the script execution for the specified number of seconds */ void wait(HSQUIRRELVM vm, float seconds) __suspend; @@ -103,16 +93,6 @@ std::string translate(const std::string& text); void import(HSQUIRRELVM v, const std::string& filename); /** - * Save world state to savegame - */ -void save_state(); - -/** - * Update worldmap from worldmap state (state.world variable) - */ -void update_worldmap(); - -/** * enable/disable drawing of collision rectangles */ void debug_collrects(bool enable); diff --git a/src/scripting/wrapper.cpp b/src/scripting/wrapper.cpp index c2bd91ee7..7f5aa4b12 100644 --- a/src/scripting/wrapper.cpp +++ b/src/scripting/wrapper.cpp @@ -3135,52 +3135,6 @@ static SQInteger display_text_file_wrapper(HSQUIRRELVM vm) } -static SQInteger load_worldmap_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - scripting::load_worldmap(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'load_worldmap'")); - return SQ_ERROR; - } - -} - -static SQInteger load_level_wrapper(HSQUIRRELVM vm) -{ - const SQChar* arg0; - if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) { - sq_throwerror(vm, _SC("Argument 1 not a string")); - return SQ_ERROR; - } - - try { - scripting::load_level(arg0); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'load_level'")); - return SQ_ERROR; - } - -} - static SQInteger wait_wrapper(HSQUIRRELVM vm) { HSQUIRRELVM arg0 = vm; @@ -3366,44 +3320,6 @@ static SQInteger import_wrapper(HSQUIRRELVM vm) } -static SQInteger save_state_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - scripting::save_state(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'save_state'")); - return SQ_ERROR; - } - -} - -static SQInteger update_worldmap_wrapper(HSQUIRRELVM vm) -{ - (void) vm; - - try { - scripting::update_worldmap(); - - return 0; - - } catch(std::exception& e) { - sq_throwerror(vm, e.what()); - return SQ_ERROR; - } catch(...) { - sq_throwerror(vm, _SC("Unexpected exception while executing function 'update_worldmap'")); - return SQ_ERROR; - } - -} - static SQInteger debug_collrects_wrapper(HSQUIRRELVM vm) { SQBool arg0; @@ -4436,20 +4352,6 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'display_text_file'"); } - sq_pushstring(v, "load_worldmap", -1); - sq_newclosure(v, &load_worldmap_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|ts"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'load_worldmap'"); - } - - sq_pushstring(v, "load_level", -1); - sq_newclosure(v, &load_level_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|ts"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'load_level'"); - } - sq_pushstring(v, "wait", -1); sq_newclosure(v, &wait_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tn"); @@ -4506,20 +4408,6 @@ void register_supertux_wrapper(HSQUIRRELVM v) throw SquirrelError(v, "Couldn't register function 'import'"); } - sq_pushstring(v, "save_state", -1); - sq_newclosure(v, &save_state_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|t"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'save_state'"); - } - - sq_pushstring(v, "update_worldmap", -1); - sq_newclosure(v, &update_worldmap_wrapper, 0); - sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|t"); - if(SQ_FAILED(sq_createslot(v, -3))) { - throw SquirrelError(v, "Couldn't register function 'update_worldmap'"); - } - sq_pushstring(v, "debug_collrects", -1); sq_newclosure(v, &debug_collrects_wrapper, 0); sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb");