From 3d5bcc32ea4ac19e8da7bcf4a59443f3a013ba6d Mon Sep 17 00:00:00 2001 From: Aaron Marks Date: Tue, 15 Nov 2005 11:41:17 +0000 Subject: Updated bindings, game state class and more (see ChangeLog). --- src/state.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 20 deletions(-) (limited to 'src/state.h') diff --git a/src/state.h b/src/state.h index 21bb7566..4d1c9a37 100644 --- a/src/state.h +++ b/src/state.h @@ -36,7 +36,7 @@ namespace tmwserv /** * State class contains all information/procedures associated with the game - * state. + * world's state. */ class State : public utils::Singleton { @@ -45,36 +45,92 @@ class State : public utils::Singleton State() throw() { } ~State() throw() { } + /** + * Combined map/entity structure + */ + struct MapComposite { + /** + * Default constructor + */ + MapComposite() : map(NULL) { } + + /** + * Actual map + */ + Map *map; + + /** + * Beings located on the map + */ + Beings beings; + + /** + * Items located on the map + */ + std::vector objects; + }; + + /** + * List of maps + */ + std::map maps; + public: + /** - * Beings on map - * - * The key/value pair conforms to: - * First - map name - * Second - list of beings/players on the map - * - * NOTE: This could possibly be optimized by making first Being & second string. This will make many operations easier. + * Update game state (contains core server logic) */ - std::map beings; + void update(ConnectionHandler &); /** - * Items on map - * - * The key/value pair conforms to: - * First - map name - * Second - Item ID + * Add being to game world at specified map */ - std::map items; + void addBeing(Being *being, const std::string &map); /** - * Container for loaded maps. + * Remove being from game world */ - std::map maps; - + void removeBeing(Being *being); + /** - * Update game state (contains core server logic) + * Check to see if a map exists in game world */ - void update(ConnectionHandler &); + bool mapExists(const std::string &map); + + /** + * Check if being exists in game world already + */ + bool beingExists(Being *being); + + /** + * Load map into game world + */ + void loadMap(const std::string &map); + + /** + * Add object to the map + */ + void addObject(Object *object, const std::string &map); + + /** + * Remove an object from the map + */ + void removeObject(Object *object); + + /** + * Find out whether an object exists in the game world or not + */ + bool objectExists(Object *object); + + /** + * Find map player in world is on + */ + const std::string findPlayer(Being *being); + + /** + * Find map object in world is on + */ + const std::string findObject(Object *object); }; } // namespace tmwserv -- cgit v1.2.3-70-g09d2