Map where the world takes place. More...
#include <landmap.h>
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 | |
mapcharacter * | get_mapcharacter (u_int16 pos) |
Returns a pointer to a mapcharacter on this landmap. | |
mapobject * | get_mapobject (u_int16 pos) |
Returns a pointer to a mapobject belonging to this landmap. | |
mapsquare_area * | get_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 |
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.
landmap::landmap | ( | ) |
Default constructor.
Definition at line 28 of file landmap.cc.
landmap::~landmap | ( | ) |
Destructor.
Definition at line 32 of file landmap.cc.
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] |
u_int16 landmap::nbr_of_submaps | ( | ) | const [inline] |
u_int16 landmap::nbr_of_mapcharacters | ( | ) | const [inline] |
string landmap::filename | ( | ) | const [inline] |
mapcharacter* landmap::get_mapcharacter | ( | u_int16 | pos | ) | [inline] |
mapobject* landmap::get_mapobject | ( | u_int16 | pos | ) | [inline] |
mapsquare_area* landmap::get_submap | ( | u_int16 | pos | ) | [inline] |
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.
file | the file from which to load. |
Definition at line 78 of file landmap.cc.
s_int8 landmap::load | ( | string | fname | ) |
Load a map from a filename.
fname | the filename from which to load. |
Definition at line 127 of file landmap.cc.
s_int8 landmap::put | ( | ogzstream & | file | ) | const |
Put a map into an opened file.
file | the file where to save. |
Definition at line 144 of file landmap.cc.
s_int8 landmap::save | ( | string | fname | ) |
Save a map into a file.
fname | the filename where to save. |
Definition at line 193 of file landmap.cc.
s_int8 landmap::get_state | ( | igzstream & | file | ) |
Restore the landmap's state from an opened file.
file | the opened file from which to load the state. |
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.
file | the opened file where to the state. |
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.
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. |
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.
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 ()
pos | the position where to insert the submap. |
Definition at line 317 of file landmap.cc.
s_int8 landmap::delete_submap | ( | u_int16 | pos | ) |
Remove a landsubmap from the landmap.
pos | the index of the submap to remove |
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.
an | the mapobject to insert. | |
pos | the position where to insert the mapobject. | |
srcfile | the name of the file where the mapobject come from. |
Definition at line 256 of file landmap.cc.
s_int8 landmap::delete_mapobject | ( | u_int16 | pos | ) |
Delete a mapobject from a landmap.
pos | the index of the mapobject to delete. |
Definition at line 277 of file landmap.cc.