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

Go to the source code of this file.

Classes

struct  lua_map_ref
 

Namespaces

 replace_if_failed_idx
 
 lua_terrainmap
 

Macros

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

Enumerations

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

Functions

static int impl_slocs_get (lua_State *L)
 
static int impl_slocs_set (lua_State *L)
 
static int impl_slocs_next (lua_State *L)
 
static int impl_slocs_iter (lua_State *L)
 
static 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)
 

Variables

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

◆ ERR_LUA

#define ERR_LUA   LOG_STREAM(err, log_scripting_lua)

Definition at line 29 of file lua_terrainmap.cpp.

◆ LOG_LUA

#define LOG_LUA   LOG_STREAM(info, log_scripting_lua)

Definition at line 28 of file lua_terrainmap.cpp.

Function Documentation

◆ impl_merge_terrain()

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

◆ impl_replace_if_failed_tostring()

static int impl_replace_if_failed_tostring ( lua_State *  L)
static

◆ impl_slocs_get()

static int impl_slocs_get ( lua_State *  L)
static

◆ impl_slocs_iter()

static int impl_slocs_iter ( lua_State *  L)
static

Definition at line 91 of file lua_terrainmap.cpp.

References impl_slocs_next().

Referenced by lua_terrainmap::register_metatables().

◆ impl_slocs_next()

static int impl_slocs_next ( lua_State *  L)
static

◆ impl_slocs_set()

static int impl_slocs_set ( lua_State *  L)
static

◆ impl_terrainmap_collect()

static int impl_terrainmap_collect ( lua_State *  L)
static

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

Definition at line 221 of file lua_terrainmap.cpp.

Referenced by lua_terrainmap::register_metatables().

◆ impl_terrainmap_get()

static int impl_terrainmap_get ( lua_State *  L)
static

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 277 of file lua_terrainmap.cpp.

References gamemap_base::border_size(), gamemap_base::h(), 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)
static

◆ impl_terrainmap_set()

static int impl_terrainmap_set ( lua_State *  L)
static

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 313 of file lua_terrainmap.cpp.

References impl_merge_terrain(), 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 481 of file lua_terrainmap.cpp.

References resources::controller, resources::gameboard, play_controller::get_display(), is_odd(), luaW_checklocation(), luaW_checkterrainmap(), luaW_table_get_def(), luaW_tableget(), game_display::needs_rebuild(), gamemap_base::overlay(), read_rules_vector(), and t.

Referenced by 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 196 of file lua_terrainmap.cpp.

References h, t_translation::read_terrain_code(), terrainmapKey, and w.

Referenced by mapgen_lua_kernel::mapgen_lua_kernel().

◆ intf_terrainmap_get()

int intf_terrainmap_get ( lua_State *  L)

Definition at line 211 of file lua_terrainmap.cpp.

References resources::gameboard, and terrainmapKey.

◆ 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 
)

Definition at line 165 of file lua_terrainmap.cpp.

References utf8::index(), maplocationKey, and terrainmapKey.

Referenced by luaW_checkterrainmap(), and luaW_toterrainmap().

◆ luaW_push_terrain()

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

◆ luaW_toterrainmap()

gamemap_base* luaW_toterrainmap ( lua_State *  L,
int  index 
)

Definition at line 171 of file lua_terrainmap.cpp.

References utf8::index(), and luaW_isterrainmap().

◆ read_rules_vector()

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

◆ simplemerge()

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

Variable Documentation

◆ log_scripting_lua

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

◆ maplocationKey

const char maplocationKey[] = "special locations"
static

◆ mapReplaceIfFailedKey

const char mapReplaceIfFailedKey[] = "replace_if_failed terrain code"
static

◆ terrainmapKey

const char terrainmapKey[] = "terrain map"
static