Adonthell  0.4
mapsquare Class Reference

Base unit of a landsubmap, where you can place mapobjects or mapcharacters. More...

#include <mapsquare.h>

Inheritance diagram for mapsquare:
Collaboration diagram for mapsquare:

Public Member Functions

 mapsquare ()
 Default constructor. More...
 
 mapsquare (const mapsquare &src)
 Copy constructor. More...
 
 ~mapsquare ()
 Destructor. More...
 
u_int16 x ()
 Returns the X position of this mapsquare. More...
 
u_int16 y ()
 Returns the Y position of this mapsquare. More...
 
bool is_free ()
 Returns whether the mapsquare is free for a character to go on or not. More...
 
mapcharacterwhoshere ()
 Return a pointer to the mapcharacter that occupies this mapsquare. More...
 
- Public Member Functions inherited from mapsquare_walkable
 mapsquare_walkable ()
 Default constructor. More...
 
s_int8 get (igzstream &file)
 Loads a mapsquare_walkable from an opened file. More...
 
s_int8 put (ogzstream &file) const
 Puts a mapsquare_walkable into an opened file. More...
 
bool is_walkable_west () const
 Returns whether a mapsquare is walkable from west. More...
 
bool is_walkable_east () const
 Returns whether a mapsquare is walkable from east. More...
 
bool is_walkable_north () const
 Returns whether a mapsquare is walkable from north. More...
 
bool is_walkable_south () const
 Returns whether a mapsquare is walkable from south. More...
 
void set_walkable_west (bool w)
 Sets the reachability from west of a mapsquare. More...
 
void set_walkable_east (bool w)
 Sets the reachability from east of a mapsquare. More...
 
void set_walkable_north (bool w)
 Sets the reachability from north of a mapsquare. More...
 
void set_walkable_south (bool w)
 Sets the reachability from south of a mapsquare. More...
 
u_int8 get_walkable () const
 Gets the raw walkable parameter of a mapsquare. More...
 
void set_walkable (u_int8 w)
 Sets the walkable parameter of a mapsquare. More...
 

Public Attributes

Pathfinding data members.

These members are here to allow faster and more efficient pathfinding.

Though they can as well be used for something else, but their value isn't guaranteed to stay constant. It is safe to modify them however, so they are public and uninitialised.

u_int16 g
 Distance from the source square. More...
 
u_int16 h
 Estimated distance to the goal square. More...
 
u_int16 f
 Sum of g + h. More...
 
mapsquareparent
 Parent square for the path. More...
 
bool can_use_for_pathfinding
 If == false, then this square will never be considered as walkable by pathfinding functions. More...
 

Friends

class mapcharacter
 
class mapsquare_area
 
class landmap
 
class mapview
 

Detailed Description

Base unit of a landsubmap, where you can place mapobjects or mapcharacters.

A landsubmap is a 2 dimensionnal array of mapsquares. When a mapobject is placed on a landsubmap, it belongs to one or several mapsquares. A mapsquare is made of a list of mapsquare_tiles, containing informations about the objects that are on it, and a list of mapsquare_char, which informs about the mapcharacters here. This make it possible to have several mapobjects and mapcharacters on the same mapsquare.

These two lists are sorted by the position of the object or mapcharacter's base square on the map. This make it fast to iterate through the lists during drawing, as we always want to iterate the list in this order.

Definition at line 230 of file mapsquare.h.

Constructor & Destructor Documentation

mapsquare::mapsquare ( )

Default constructor.

Definition at line 50 of file mapsquare.cc.

mapsquare::mapsquare ( const mapsquare src)

Copy constructor.

Definition at line 56 of file mapsquare.cc.

mapsquare::~mapsquare ( )

Destructor.

Definition at line 69 of file mapsquare.cc.

Member Function Documentation

u_int16 mapsquare::x ( )
inline

Returns the X position of this mapsquare.

Returns
X position of this mapsquare.

Definition at line 259 of file mapsquare.h.

u_int16 mapsquare::y ( )
inline

Returns the Y position of this mapsquare.

Returns
Y position of this mapsquare.

Definition at line 270 of file mapsquare.h.

bool mapsquare::is_free ( )

Returns whether the mapsquare is free for a character to go on or not.

It only checks if a mapcharacter is already here. It doesn't deal with the walkable problem.

Returns
  • false if the mapsquare isn't free.
  • true if the mapsquare is free.

Definition at line 73 of file mapsquare.cc.

mapcharacter * mapsquare::whoshere ( )

Return a pointer to the mapcharacter that occupies this mapsquare.

Returns
pointer to the mapcharacter that occupies the mapsquare, NULL if none.

Definition at line 82 of file mapsquare.cc.

Member Data Documentation

u_int16 mapsquare::g

Distance from the source square.

Definition at line 307 of file mapsquare.h.

u_int16 mapsquare::h

Estimated distance to the goal square.

Definition at line 313 of file mapsquare.h.

u_int16 mapsquare::f

Sum of g + h.

Definition at line 319 of file mapsquare.h.

mapsquare* mapsquare::parent

Parent square for the path.

Definition at line 325 of file mapsquare.h.

bool mapsquare::can_use_for_pathfinding

If == false, then this square will never be considered as walkable by pathfinding functions.

Definition at line 332 of file mapsquare.h.


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