Skip to content

Commit

Permalink
Add a separate getter pair for playable height and width
Browse files Browse the repository at this point in the history
  • Loading branch information
CelticMinstrel committed Feb 20, 2021
1 parent 14fbc4c commit 28da189
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 3 additions & 4 deletions data/lua/core.lua
Expand Up @@ -834,11 +834,10 @@ if wesnoth.kernel_type() == "Game Lua Kernel" then
end
get_map()[loc] = new_ter
end)
wesnoth.get_map_size = wesnoth.deprecate_api('wesnoth.get_map_size', 'wesnoth.map.get().width,height,border_size', 1, nil, function()
wesnoth.get_map_size = wesnoth.deprecate_api('wesnoth.get_map_size', 'wesnoth.map.get().playable_width,playable_height,border_size', 1, nil, function()
local m = get_map()
local border = m.border_size
return m.width - 2 * border, m.height - 2 * border, border
end, 'Note: width and height on map.get() return the size including the border, while get_map_size() returns the size excluding the border')
return m.playable_width, m.playable_height, m.border_size
end)
wesnoth.special_locations = wesnoth.deprecate_api('wesnoth.special_locations', 'wesnoth.map.get():special_locations', 1, nil, setmetatable({}, {
__index = function(_, k) return get_map().special_locations[k] end,
__newindex = function(_, k, v) get_map().special_locations[k] = v end,
Expand Down
2 changes: 2 additions & 0 deletions src/scripting/lua_terrainmap.cpp
Expand Up @@ -306,6 +306,8 @@ static int impl_terrainmap_get(lua_State *L)
// Find the corresponding attribute.
return_int_attrib("width", tm.total_width());
return_int_attrib("height", tm.total_height());
return_int_attrib("playable_width", tm.w());
return_int_attrib("playable_height", tm.h());
return_int_attrib("border_size", tm.border_size());
return_string_attrib("data", tm.to_string());

Expand Down

0 comments on commit 28da189

Please sign in to comment.