The Battle for Wesnoth  1.19.0-dev
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
lua_unit Class Reference

Storage for a unit, either owned by the Lua code (ptr != 0), a local variable unit (c_ptr != 0), on a recall list (side != 0), or on the map. More...

#include <lua_unit.hpp>

Public Member Functions

 lua_unit (std::size_t u)
 
 lua_unit (unit_ptr u)
 
 lua_unit (int s, std::size_t u)
 
 lua_unit (unit &u)
 
 ~lua_unit ()
 
bool on_map () const
 
int on_recall_list () const
 
unitget () const
 
unit_ptr get_shared () const
 
unitoperator-> () const
 
unitoperator* () const
 
void clear_ref ()
 
bool put_map (const map_location &loc)
 

Private Member Functions

 lua_unit (const lua_unit &)=delete
 
lua_unitoperator= (const lua_unit &)=delete
 

Static Private Member Functions

static void setmetatable (lua_State *L)
 

Private Attributes

std::size_t uid
 
unit_ptr ptr
 
int side
 
unitc_ptr
 

Friends

template<typename... Args>
lua_unitluaW_pushunit (lua_State *L, Args... args)
 
lua_unitluaW_pushlocalunit (lua_State *L, unit &u)
 Pushes a private unit on the stack. More...
 

Detailed Description

Storage for a unit, either owned by the Lua code (ptr != 0), a local variable unit (c_ptr != 0), on a recall list (side != 0), or on the map.

Shared units are represented by their underlying ID (uid).

Definition at line 80 of file lua_unit.hpp.

Constructor & Destructor Documentation

◆ lua_unit() [1/5]

lua_unit::lua_unit ( const lua_unit )
privatedelete

◆ lua_unit() [2/5]

lua_unit::lua_unit ( std::size_t  u)
inline

Definition at line 94 of file lua_unit.hpp.

◆ lua_unit() [3/5]

lua_unit::lua_unit ( unit_ptr  u)
inline

Definition at line 95 of file lua_unit.hpp.

◆ lua_unit() [4/5]

lua_unit::lua_unit ( int  s,
std::size_t  u 
)
inline

Definition at line 96 of file lua_unit.hpp.

◆ lua_unit() [5/5]

lua_unit::lua_unit ( unit u)
inline

Definition at line 97 of file lua_unit.hpp.

◆ ~lua_unit()

lua_unit::~lua_unit ( )

Definition at line 42 of file lua_unit.cpp.

Member Function Documentation

◆ clear_ref()

void lua_unit::clear_ref ( )
inline

Definition at line 110 of file lua_unit.hpp.

References c_ptr, ptr, side, and uid.

◆ get()

unit * lua_unit::get ( ) const

◆ get_shared()

unit_ptr lua_unit::get_shared ( ) const

◆ on_map()

bool lua_unit::on_map ( ) const
inline

Definition at line 100 of file lua_unit.hpp.

References ptr, and side.

Referenced by game_lua_kernel::intf_erase_unit(), and game_lua_kernel::intf_put_unit().

◆ on_recall_list()

int lua_unit::on_recall_list ( ) const
inline
Returns
If this unit is on any side's recall list, the number of that side (1-based). Otherwise, return 0.

Definition at line 102 of file lua_unit.hpp.

References side.

Referenced by game_lua_kernel::intf_erase_unit(), and game_lua_kernel::intf_match_unit().

◆ operator*()

unit& lua_unit::operator* ( ) const
inline

Definition at line 108 of file lua_unit.hpp.

References get().

◆ operator->()

unit* lua_unit::operator-> ( ) const
inline

Definition at line 107 of file lua_unit.hpp.

References get().

◆ operator=()

lua_unit& lua_unit::operator= ( const lua_unit )
privatedelete

◆ put_map()

bool lua_unit::put_map ( const map_location loc)

◆ setmetatable()

void lua_unit::setmetatable ( lua_State *  L)
staticprivate

Definition at line 205 of file lua_unit.cpp.

References getunitKey.

Friends And Related Function Documentation

◆ luaW_pushlocalunit

lua_unit* luaW_pushlocalunit ( lua_State *  L,
unit u 
)
friend

Pushes a private unit on the stack.

Definition at line 210 of file lua_unit.cpp.

◆ luaW_pushunit

template<typename... Args>
lua_unit* luaW_pushunit ( lua_State *  L,
Args...  args 
)
friend

Definition at line 116 of file lua_unit.hpp.

Member Data Documentation

◆ c_ptr

unit* lua_unit::c_ptr
private

Definition at line 85 of file lua_unit.hpp.

Referenced by clear_ref(), and get().

◆ ptr

unit_ptr lua_unit::ptr
private

Definition at line 83 of file lua_unit.hpp.

Referenced by clear_ref(), get(), get_shared(), on_map(), and put_map().

◆ side

int lua_unit::side
private

Definition at line 84 of file lua_unit.hpp.

Referenced by clear_ref(), get(), get_shared(), on_map(), on_recall_list(), and put_map().

◆ uid

std::size_t lua_unit::uid
private

Definition at line 82 of file lua_unit.hpp.

Referenced by clear_ref(), get(), get_shared(), and put_map().


The documentation for this class was generated from the following files: