The Battle for Wesnoth  1.15.12+dev
Classes | Namespaces | Macros | Enumerations | Functions | Variables
lua_terrainmap.cpp File Reference
#include "scripting/lua_terrainmap.hpp"
#include "scripting/lua_terrainfilter.hpp"
#include "formatter.hpp"
#include "global.hpp"
#include "log.hpp"
#include "map/location.hpp"
#include "map/map.hpp"
#include "scripting/lua_common.hpp"
#include "scripting/push_check.hpp"
#include "scripting/game_lua_kernel.hpp"
#include "resources.hpp"
#include "game_board.hpp"
#include "play_controller.hpp"
#include "lua/lauxlib.h"
#include "lua/lua.h"
Include dependency graph for lua_terrainmap.cpp:

Go to the source code of this file.


struct  lua_map_ref




#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)
#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)


enum  { replace_if_failed_idx::CODE = 1, replace_if_failed_idx::MODE = 2 }


int impl_slocs_get (lua_State *L)
int impl_slocs_set (lua_State *L)
int impl_slocs_next (lua_State *L)
int impl_slocs_iter (lua_State *L)
void simplemerge (t_translation::terrain_code old_t, t_translation::terrain_code &new_t, const terrain_type_data::merge_mode mode)
bool luaW_isterrainmap (lua_State *L, int index)
gamemap_baseluaW_toterrainmap (lua_State *L, int index)
gamemap_baseluaW_checkterrainmap (lua_State *L, int index)
int intf_terrainmap_create (lua_State *L)
 Create a map. More...
int intf_terrainmap_get (lua_State *L)
static int impl_terrainmap_collect (lua_State *L)
 Destroys a map object before it is collected (__gc metamethod). More...
static void luaW_push_terrain (lua_State *L, gamemap_base &map, map_location loc)
static void impl_merge_terrain (lua_State *L, gamemap_base &map, map_location loc)
static int impl_terrainmap_get (lua_State *L)
 Gets some data on a map (__index metamethod). More...
static int impl_terrainmap_set (lua_State *L)
 Sets some data on a map (__newindex metamethod). More...
template<bool with_border>
static int impl_terrainmap_iter (lua_State *L)
int intf_terrainmap_iter (lua_State *L)
int intf_on_board (lua_State *L)
int intf_on_border (lua_State *L)
static std::vector< gamemap::overlay_ruleread_rules_vector (lua_State *L, int index)
int intf_terrain_mask (lua_State *L)
 Replaces part of the map. More...
int intf_replace_if_failed (lua_State *L)
static int impl_replace_if_failed_tostring (lua_State *L)
std::string lua_terrainmap::register_metatables (lua_State *L)


static lg::log_domain log_scripting_lua ("scripting/lua")
static const char terrainmapKey [] = "terrain map"
static const char maplocationKey [] = "special locations"
static const char mapReplaceIfFailedKey [] = "replace_if_failed terrain code"

Macro Definition Documentation


#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)

Definition at line 34 of file lua_terrainmap.cpp.


#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)

Definition at line 33 of file lua_terrainmap.cpp.

Function Documentation

◆ impl_merge_terrain()

static void impl_merge_terrain ( lua_State L,
gamemap_base map,
map_location  loc 

◆ impl_replace_if_failed_tostring()

static int impl_replace_if_failed_tostring ( lua_State L)

◆ impl_slocs_get()

int impl_slocs_get ( lua_State L)

◆ impl_slocs_iter()

int impl_slocs_iter ( lua_State L)

◆ impl_slocs_next()

int impl_slocs_next ( lua_State L)

◆ impl_slocs_set()

int impl_slocs_set ( lua_State L)

◆ impl_terrainmap_collect()

static int impl_terrainmap_collect ( lua_State L)

Destroys a map object before it is collected (__gc metamethod).

Definition at line 226 of file lua_terrainmap.cpp.

References lua_touserdata().

Referenced by lua_terrainmap::register_metatables().

◆ impl_terrainmap_get()

static int impl_terrainmap_get ( lua_State L)

Gets some data on a map (__index metamethod).

  • Arg 1: full userdata containing the map.
  • Arg 2: string containing the name of the property.
  • Ret 1: something containing the attribute.

Definition at line 282 of file lua_terrainmap.cpp.

References gamemap_base::border_size(), gamemap_base::h(), luaL_checkstring, luaL_setmetatable(), luaW_checkterrainmap(), luaW_getglobal(), luaW_push_terrain(), luaW_tolocation(), maplocationKey, return_int_attrib, return_string_attrib, gamemap_base::to_string(), gamemap_base::total_height(), gamemap_base::total_width(), and gamemap_base::w().

Referenced by lua_terrainmap::register_metatables().

◆ impl_terrainmap_iter()

template<bool with_border>
static int impl_terrainmap_iter ( lua_State L)

◆ impl_terrainmap_set()

static int impl_terrainmap_set ( lua_State L)

Sets some data on a map (__newindex metamethod).

  • Arg 1: full userdata containing the map.
  • Arg 2: string containing the name of the property.
  • Arg 3: something containing the attribute.

Definition at line 318 of file lua_terrainmap.cpp.

References impl_merge_terrain(), LUA_TNUMBER, lua_type(), luaL_argerror(), luaL_checkstring, luaW_checkterrainmap(), and luaW_tolocation().

Referenced by lua_terrainmap::register_metatables().

◆ intf_on_board()

int intf_on_board ( lua_State L)

◆ intf_on_border()

int intf_on_border ( lua_State L)

◆ intf_replace_if_failed()

int intf_replace_if_failed ( lua_State L)

◆ intf_terrain_mask()

int intf_terrain_mask ( lua_State L)

Replaces part of the map.

  • Arg 1: map location.
  • Arg 2: map data string.
  • Arg 3: table for optional named arguments
    • is_odd: boolean, if Arg2 has the odd map format (as if it was cut from a odd map location)
    • ignore_special_locations: boolean
    • rules: table of tables

Definition at line 486 of file lua_terrainmap.cpp.

References resources::controller, resources::gameboard, play_controller::get_display(), is_odd(), lua_isstring(), lua_istable, lua_pop, luaL_argerror(), luaL_checkstring, luaW_checklocation(), luaW_checkterrainmap(), luaW_table_get_def(), luaW_tableget(), mapgen_gamemap::mapgen_gamemap(), game_display::needs_rebuild(), gamemap_base::overlay(), read_rules_vector(), and t.

Referenced by mapgen_gamemap::for_each_loc(), and game_lua_kernel::game_lua_kernel().

◆ intf_terrainmap_create()

int intf_terrainmap_create ( lua_State L)

Create a map.

  • Arg 1: string describing the map data.
  • or:
  • Arg 1: int, width
  • Arg 2: int, height
  • Arg 3: string, terrain

Definition at line 201 of file lua_terrainmap.cpp.

References gamemap_base::h(), lua_isnumber(), lua_tonumber, luaL_checkstring, luaL_setmetatable(), t_translation::read_terrain_code(), terrainmapKey, and gamemap_base::w().

Referenced by mapgen_gamemap::for_each_loc(), and mapgen_lua_kernel::mapgen_lua_kernel().

◆ intf_terrainmap_get()

int intf_terrainmap_get ( lua_State L)

◆ intf_terrainmap_iter()

int intf_terrainmap_iter ( lua_State L)

◆ luaW_checkterrainmap()

gamemap_base& luaW_checkterrainmap ( lua_State L,
int  index 

◆ luaW_isterrainmap()

bool luaW_isterrainmap ( lua_State L,
int  index 

◆ luaW_push_terrain()

static void luaW_push_terrain ( lua_State L,
gamemap_base map,
map_location  loc 

◆ luaW_toterrainmap()

gamemap_base* luaW_toterrainmap ( lua_State L,
int  index 

Definition at line 176 of file lua_terrainmap.cpp.

References lua_touserdata(), and luaW_isterrainmap().

Referenced by mapgen_gamemap::for_each_loc().

◆ read_rules_vector()

static std::vector<gamemap::overlay_rule> read_rules_vector ( lua_State L,
int  index 

◆ simplemerge()

void simplemerge ( t_translation::terrain_code  old_t,
t_translation::terrain_code new_t,
const terrain_type_data::merge_mode  mode 

Variable Documentation

◆ log_scripting_lua

lg::log_domain log_scripting_lua("scripting/lua")

◆ maplocationKey

const char maplocationKey[] = "special locations"

◆ mapReplaceIfFailedKey

const char mapReplaceIfFailedKey[] = "replace_if_failed terrain code"

◆ terrainmapKey

const char terrainmapKey[] = "terrain map"