Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

DALT_Server::WorldMap Class Reference

This class provides a generic interface to the internally stored world map, together with functions for loading maps from XML. More...

#include <worldmap.h>

Collaboration diagram for DALT_Server::WorldMap:

Collaboration graph
[legend]
List of all members.

Public Methods

 WorldMap (map< int, Client *> *entity_dict)
 ~WorldMap ()
int getLocation (const vector< int > &coord)
void newMap (const vector< int > &axis)
void setCell (const vector< int > &coord, int value)
void clearCell (const vector< int > &coord)
int getCell (const vector< int > &coord)
void stateChange (Entity *from_state, Entity *to_state)
void parseMapFile (string file_name)
EntitygetEntityById (int id) throw (runtime_error)

Public Attributes

vector<int> axis
list<Entityall_entities
vector<Entitychanged_entities
vector<Entityto_be_removed

Protected Attributes

int dimensions
vector<int> the_map
map<int, Client*>* entity_dictionary

Detailed Description

This class provides a generic interface to the internally stored world map, together with functions for loading maps from XML.

As the world map is serialised into a vector, functions are provided to access the map by coordinates, no matter how many dimensions are used for the simulation. There are 2 views to the map.

Both views can be used; please note that there is no automatic mechanism to syncronise changes in between the views; if you update one you will have to update the other one aswell

Author:
Vlad Mereuta


Constructor & Destructor Documentation

DALT_Server::WorldMap::WorldMap ( map< int, Client *> * entity_dict )
 

constructor - initialises variabiles.

Parameters:
entity_dict  

DALT_Server::WorldMap::~WorldMap ( )
 

destructor; does nothing.


Member Function Documentation

void DALT_Server::WorldMap::clearCell ( const vector< int > & coord )
 

removes cell information (sets a map cell at given coordinates to 0).

Parameters:
coord  

int DALT_Server::WorldMap::getCell ( const vector< int > & coord )
 

gets the value of a cell at a specific location.

Parameters:
coord  

Entity * DALT_Server::WorldMap::getEntityById ( int id ) throw (runtime_error)
 

returns a pointer to an entity, given its id.

Parameters:
id   the id of the entitiy to search for
Returns:
pointer to that entity
Parameters:
id  

int DALT_Server::WorldMap::getLocation ( const vector< int > & coord )
 

convert the coordinate based location to the linear format used to store the map.

Parameters:
coord  

void DALT_Server::WorldMap::newMap ( const vector< int > & axis )
 

creates a new map, given a set of dimension for each axis.

Parameters:
axis  

void DALT_Server::WorldMap::parseMapFile ( string file_name )
 

parse and load the map from a given file name.

Parameters:
file_name  

void DALT_Server::WorldMap::setCell ( const vector< int > & coord,
int value )
 

set a map cell at given coordinates to a certain value.

Parameters:
coord  
value  

void DALT_Server::WorldMap::stateChange ( Entity * from_state,
Entity * to_state )
 

used to signal a change of staty of an entity.

Parameters:
from_state  
to_state  


Member Data Documentation

list< Entity > DALT_Server::WorldMap::all_entities
 

contains all entities currently present in the simulation.

vector< int > DALT_Server::WorldMap::axis
 

the size of the world on each axis.

vector< Entity > DALT_Server::WorldMap::changed_entities
 

contains pointers to entities that have been changed in the last cycle.

int DALT_Server::WorldMap::dimensions [protected]
 

number of dimensions used by the simulation.

map< int, Client *> * DALT_Server::WorldMap::entity_dictionary [protected]
 

client/agent map.

vector< int > DALT_Server::WorldMap::the_map [protected]
 

the map of the world, serialised into a vector.

vector< Entity > DALT_Server::WorldMap::to_be_removed
 

entities that are queued for removal at the start of the next cycle.


The documentation for this class was generated from the following file:
Generated at Thu Jan 31 15:22:46 2002 for DALT Server by doxygen1.2.8 written by Dimitri van Heesch, © 1997-2001