The Battle for Wesnoth  1.17.21+dev
Public Member Functions | Private Attributes | List of all members
temporary_unit_mover Struct Reference

This object is used to temporary move a unit in the unit map, swapping out any unit that is already there. More...

#include <game_board.hpp>

Public Member Functions

 temporary_unit_mover (unit_map &m, const map_location &src, const map_location &dst, int new_moves)
 Constructor This version will change the unit's current movement to new_moves while the unit is moved (and restored to its previous value upon this object's destruction). More...
 
 temporary_unit_mover (unit_map &m, const map_location &src, const map_location &dst)
 Constructor This version does not change (nor restore) the unit's movement. More...
 
 temporary_unit_mover (game_board &b, const map_location &src, const map_location &dst, int new_moves)
 
 temporary_unit_mover (game_board &b, const map_location &src, const map_location &dst)
 
virtual ~temporary_unit_mover ()
 

Private Attributes

unit_mapm_
 
const map_location src_
 
const map_location dst_
 
int old_moves_
 
unit_ptr temp_
 

Detailed Description

This object is used to temporary move a unit in the unit map, swapping out any unit that is already there.

On destruction, it restores the unit map to its original.

Definition at line 230 of file game_board.hpp.

Constructor & Destructor Documentation

◆ temporary_unit_mover() [1/4]

temporary_unit_mover::temporary_unit_mover ( unit_map m,
const map_location src,
const map_location dst,
int  new_moves 
)

Constructor This version will change the unit's current movement to new_moves while the unit is moved (and restored to its previous value upon this object's destruction).

Definition at line 473 of file game_board.cpp.

References dst_, m_, unit_map::move(), old_moves_, and src_.

◆ temporary_unit_mover() [2/4]

temporary_unit_mover::temporary_unit_mover ( unit_map m,
const map_location src,
const map_location dst 
)

Constructor This version does not change (nor restore) the unit's movement.

Definition at line 510 of file game_board.cpp.

References dst_, m_, unit_map::move(), and src_.

◆ temporary_unit_mover() [3/4]

temporary_unit_mover::temporary_unit_mover ( game_board b,
const map_location src,
const map_location dst,
int  new_moves 
)

Definition at line 489 of file game_board.cpp.

References dst_, m_, unit_map::move(), old_moves_, and src_.

◆ temporary_unit_mover() [4/4]

temporary_unit_mover::temporary_unit_mover ( game_board b,
const map_location src,
const map_location dst 
)

Definition at line 520 of file game_board.cpp.

References dst_, m_, unit_map::move(), and src_.

◆ ~temporary_unit_mover()

temporary_unit_mover::~temporary_unit_mover ( )
virtual

Member Data Documentation

◆ dst_

const map_location temporary_unit_mover::dst_
private

Definition at line 245 of file game_board.hpp.

Referenced by temporary_unit_mover(), and ~temporary_unit_mover().

◆ m_

unit_map& temporary_unit_mover::m_
private

Definition at line 243 of file game_board.hpp.

Referenced by temporary_unit_mover(), and ~temporary_unit_mover().

◆ old_moves_

int temporary_unit_mover::old_moves_
private

Definition at line 246 of file game_board.hpp.

Referenced by temporary_unit_mover(), and ~temporary_unit_mover().

◆ src_

const map_location temporary_unit_mover::src_
private

Definition at line 244 of file game_board.hpp.

Referenced by temporary_unit_mover(), and ~temporary_unit_mover().

◆ temp_

unit_ptr temporary_unit_mover::temp_
private

Definition at line 247 of file game_board.hpp.

Referenced by ~temporary_unit_mover().


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