landmap Class Reference

Map where the world takes place. More...

#include <landmap.h>

Inheritance diagram for landmap:

Inheritance graph
[legend]
Collaboration diagram for landmap:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 landmap ()
 Default constructor.
 ~landmap ()
 Destructor.
void clear ()
 Cleanup the map.
Map information
u_int16 nbr_of_mapobjects () const
 Get the number of mapobjects that the map owns.
u_int16 nbr_of_submaps () const
 Get the number of landsubmaps that the map owns.
u_int16 nbr_of_mapcharacters () const
 Get the number of mapcharacters that are on this map.
string filename () const
 Get the filename of the map, i.e the file from which it has been loaded (if any).
Individual map elements manipulation
Using these methods should be avoided as long as possible.

They are here for completeness, but their use should be exceptionnal.

mapcharacterget_mapcharacter (u_int16 pos)
 Returns a pointer to a mapcharacter on this landmap.
mapobjectget_mapobject (u_int16 pos)
 Returns a pointer to a mapobject belonging to this landmap.
mapsquare_areaget_submap (u_int16 pos)
 Returns a pointer to a submap belonging to this landmap.
State updating
void update ()
 Update the entire map (mapcharacters, mapobjects, etc.
Loading/Saving methods.
s_int8 get (igzstream &file)
 Load a map from an opened file.
s_int8 load (string fname)
 Load a map from a filename.
s_int8 put (ogzstream &file) const
 Put a map into an opened file.
s_int8 save (string fname)
 Save a map into a file.
State loading/saving methods.
s_int8 get_state (igzstream &file)
 Restore the landmap's state from an opened file.
s_int8 put_state (ogzstream &file) const
 Saves the landmap's state into an opened file.
Landmap modification
Although it should be very rare to modify a landmap during gameplay, these methods are here to allow you to safely to it.

Be aware that they check if each element is in a safe state, and modify them if necessary. Therefore, they are quite slow and should be used in exceptionnal situations.

Note however that put_mapobject () and remove_mapobject () should be fast enough to allow real-time map modifications. But beware anyway.

s_int8 put_mapobject (u_int16 smap, u_int16 px, u_int16 py, u_int16 mobjnbr)
 Put a mapobject on the map.
void remove_mapobject (u_int16 smap, u_int16 px, u_int16 py, u_int16 mobjnbr)
 Remove a mapobject from the map.
s_int8 insert_submap (u_int16 pos)
 Inserts an empty landsubmap into the landmap.
s_int8 delete_submap (u_int16 pos)
 Remove a landsubmap from the landmap.
s_int8 insert_mapobject (mapobject *an, u_int16 pos, string srcfile="")
 Adds a mapobject to a landmap.
s_int8 delete_mapobject (u_int16 pos)
 Delete a mapobject from a landmap.

Friends

class mapcharacter
class mapview


Detailed Description

Map where the world takes place.

This class handles everything that is needed for map display. More specifically, it includes:

This class is responsible for the storage of it's submaps and mapobjects, but NOT mapcharacters. So be sure to delete () yourself your mapcharacters when you don't need them anymore.

Definition at line 52 of file landmap.h.


Constructor & Destructor Documentation

landmap::landmap (  ) 

Default constructor.

Definition at line 28 of file landmap.cc.

landmap::~landmap (  ) 

Destructor.

Definition at line 32 of file landmap.cc.


Member Function Documentation

void landmap::clear (  ) 

Cleanup the map.

Totally cleanup a map, that is deleting every mapobject/mapcharacter/landsubmap it contains, and reset it to a stable state (just like it has just been created).

Reimplemented from event_list.

Definition at line 37 of file landmap.cc.

u_int16 landmap::nbr_of_mapobjects (  )  const [inline]

Get the number of mapobjects that the map owns.

Returns:
number of mapobjects the map contains.

Definition at line 85 of file landmap.h.

u_int16 landmap::nbr_of_submaps (  )  const [inline]

Get the number of landsubmaps that the map owns.

Returns:
number of landsubmaps the map contains.

Definition at line 94 of file landmap.h.

u_int16 landmap::nbr_of_mapcharacters (  )  const [inline]

Get the number of mapcharacters that are on this map.

Returns:
number of mapcharacters on this map.

Definition at line 103 of file landmap.h.

string landmap::filename (  )  const [inline]

Get the filename of the map, i.e the file from which it has been loaded (if any).

Returns:
filename of the map.

Definition at line 115 of file landmap.h.

mapcharacter* landmap::get_mapcharacter ( u_int16  pos  )  [inline]

Returns a pointer to a mapcharacter on this landmap.

Parameters:
pos index of the mapcharacter to return.
Returns:
pointer to the pos mapcharacter.

Definition at line 139 of file landmap.h.

mapobject* landmap::get_mapobject ( u_int16  pos  )  [inline]

Returns a pointer to a mapobject belonging to this landmap.

Parameters:
pos index of the mapobject to return.
Returns:
pointer to the pos mapobject.

Definition at line 151 of file landmap.h.

mapsquare_area* landmap::get_submap ( u_int16  pos  )  [inline]

Returns a pointer to a submap belonging to this landmap.

Parameters:
pos index of the submap to return.
Returns:
pointer to the pos submap.

Definition at line 163 of file landmap.h.

void landmap::update (  ) 

Update the entire map (mapcharacters, mapobjects, etc.

.. of 1 cycle.

Definition at line 65 of file landmap.cc.

s_int8 landmap::get ( igzstream file  ) 

Load a map from an opened file.

Parameters:
file the file from which to load.
Returns:
  • 0 in case of success.
  • -1 in case of failure.

Definition at line 78 of file landmap.cc.

s_int8 landmap::load ( string  fname  ) 

Load a map from a filename.

Parameters:
fname the filename from which to load.
Returns:
  • 0 in case of success.
  • -1 in case of failure.

Definition at line 127 of file landmap.cc.

s_int8 landmap::put ( ogzstream file  )  const

Put a map into an opened file.

Parameters:
file the file where to save.
Returns:
  • 0 in case of success.
  • -1 in case of failure.

Definition at line 144 of file landmap.cc.

s_int8 landmap::save ( string  fname  ) 

Save a map into a file.

Parameters:
fname the filename where to save.
Returns:
  • 0 in case of success.
  • -1 in case of failure.

Definition at line 193 of file landmap.cc.

s_int8 landmap::get_state ( igzstream file  ) 

Restore the landmap's state from an opened file.

Parameters:
file the opened file from which to load the state.
Returns:
0 in case of success, error code otherwise.

Reimplemented from event_list.

Definition at line 207 of file landmap.cc.

s_int8 landmap::put_state ( ogzstream file  )  const

Saves the landmap's state into an opened file.

Parameters:
file the opened file where to the state.
Returns:
0 in case of success, error code otherwise.

Reimplemented from event_list.

Definition at line 232 of file landmap.cc.

s_int8 landmap::put_mapobject ( u_int16  smap,
u_int16  px,
u_int16  py,
u_int16  mobjnbr 
)

Put a mapobject on the map.

Parameters:
smap index of the submap to put the object on.
px X position to put the mapobject on
py Y position to put the mapobject on.
mobjnbr index of the mapobject to put.
Returns:
  • 0 in case of success.
  • -1 in case of failure.

Definition at line 364 of file landmap.cc.

void landmap::remove_mapobject ( u_int16  smap,
u_int16  px,
u_int16  py,
u_int16  mobjnbr 
)

Remove a mapobject from the map.

Parameters:
smap index of the submap to remove the object on.
px X position of the mapobject.
py Y position of the mapobject.
mobjnbr index of the mapobject to remove.

Definition at line 370 of file landmap.cc.

s_int8 landmap::insert_submap ( u_int16  pos  ) 

Inserts an empty landsubmap into the landmap.

The landmap can then be accessed for resizing with get_submap ()

Parameters:
pos the position where to insert the submap.
Returns:
  • 0 in case of success.
  • -1 in case of error.
See also:
get_submap ()

Definition at line 317 of file landmap.cc.

s_int8 landmap::delete_submap ( u_int16  pos  ) 

Remove a landsubmap from the landmap.

Parameters:
pos the index of the submap to remove
Returns:
  • 0 in case of success.
  • -1 in case of error.

Definition at line 337 of file landmap.cc.

s_int8 landmap::insert_mapobject ( mapobject an,
u_int16  pos,
string  srcfile = "" 
)

Adds a mapobject to a landmap.

Parameters:
an the mapobject to insert.
pos the position where to insert the mapobject.
srcfile the name of the file where the mapobject come from.
Returns:
  • 0 in case of success.
  • -1 in case of error.

Definition at line 256 of file landmap.cc.

s_int8 landmap::delete_mapobject ( u_int16  pos  ) 

Delete a mapobject from a landmap.

Parameters:
pos the index of the mapobject to delete.
Returns:
  • 0 in case of success.
  • -1 in case of failure.

Definition at line 277 of file landmap.cc.


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

Generated on Wed Jun 18 16:52:52 2008 for Adonthell by  doxygen 1.5.6