Allow [endlevel] to be used in victory or defeat events

This commit is contained in:
Celtic Minstrel 2016-08-07 17:12:14 -04:00
parent 0193618052
commit f4ac23a3c5
4 changed files with 4 additions and 14 deletions

View file

@ -30,6 +30,7 @@ Version 1.13.5+dev:
* Renamed [foreach] variable= to array=
* Renamed [foreach] item_var= to variable=
* Fixed several bugs in the name generation of the map generator
* Fixed issues with using [endlevel] in victory/defeat events
* Lua API:
* Added new functions wesnoth.fire_event_by_id and fire_event_by_name. The old
function wesnoth.fire_event is now an alias for wesnoth.fire_event_by_name

View file

@ -1,11 +1,13 @@
local helper = wesnoth.require "lua/helper.lua"
local already_ended = false
function wesnoth.wml_actions.endlevel(cfg)
local parsed = helper.parsed(cfg)
if wesnoth.check_end_level_disabled() then
if already_ended then
wesnoth.message("Repeated [endlevel] execution, ignoring")
return
end
already_ended = true
local next_scenario = cfg.next_scenario
if next_scenario then

View file

@ -1810,12 +1810,6 @@ static int intf_debug(lua_State* L)
return 1;
}
int game_lua_kernel::intf_check_end_level_disabled(lua_State * L)
{
lua_pushboolean(L, play_controller_.is_regular_game_end());
return 1;
}
/**
* Removes all messages from the chat window.
*/
@ -1905,11 +1899,6 @@ int game_lua_kernel::intf_get_end_level_data(lua_State* L)
int game_lua_kernel::intf_end_level(lua_State *L)
{
vconfig cfg(luaW_checkvconfig(L, 1));
if (play_controller_.is_regular_game_end()) {
return 0;
}
end_level_data data;
data.proceed_to_next_level = cfg["proceed_to_next_level"].to_bool(true);
@ -4661,7 +4650,6 @@ game_lua_kernel::game_lua_kernel(CVideo * video, game_state & gs, play_controlle
{ "allow_end_turn", &dispatch<&game_lua_kernel::intf_allow_end_turn > },
{ "allow_undo", &dispatch<&game_lua_kernel::intf_allow_undo > },
{ "animate_unit", &dispatch<&game_lua_kernel::intf_animate_unit > },
{ "check_end_level_disabled", &dispatch<&game_lua_kernel::intf_check_end_level_disabled > },
{ "clear_menu_item", &dispatch<&game_lua_kernel::intf_clear_menu_item > },
{ "clear_messages", &dispatch<&game_lua_kernel::intf_clear_messages > },
{ "color_adjust", &dispatch<&game_lua_kernel::intf_color_adjust > },

View file

@ -104,7 +104,6 @@ class game_lua_kernel : public lua_kernel_base
int impl_game_config_get(lua_State *L);
int impl_game_config_set(lua_State *L);
int impl_current_get(lua_State *L);
int intf_check_end_level_disabled(lua_State *L);
int intf_clear_messages(lua_State*);
int intf_end_level(lua_State*);
int impl_end_level_data_set(lua_State*);