diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-31 22:05:06 +0100 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-31 22:05:06 +0100 |
commit | 1bae64eddd8a06c0de52f86f92c68bad55975abf (patch) | |
tree | 4972ddd4c8a59217717798e647eaf50562102dc3 /src/game-server/mapcomposite.hpp | |
parent | 393d066045fda5beee4748dc66754d70b4c82d36 (diff) | |
parent | 2141fae61af1fd3f81d792910ffa35d672835523 (diff) | |
download | manaserv-1bae64eddd8a06c0de52f86f92c68bad55975abf.tar.gz manaserv-1bae64eddd8a06c0de52f86f92c68bad55975abf.tar.bz2 manaserv-1bae64eddd8a06c0de52f86f92c68bad55975abf.tar.xz manaserv-1bae64eddd8a06c0de52f86f92c68bad55975abf.zip |
Merge branch 'master' of git@gitorious.org:tmwserv/mainline
Diffstat (limited to 'src/game-server/mapcomposite.hpp')
-rw-r--r-- | src/game-server/mapcomposite.hpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/game-server/mapcomposite.hpp b/src/game-server/mapcomposite.hpp index 3f1225f0..078842d6 100644 --- a/src/game-server/mapcomposite.hpp +++ b/src/game-server/mapcomposite.hpp @@ -120,6 +120,103 @@ struct ObjectIterator }; /** + * Part of a map. + */ +struct MapZone +{ + unsigned short nbCharacters, nbMovingObjects; + /** + * Objects present in this zone. + * Characters are stored first, then the remaining MovingObjects, then the + * remaining Objects. + */ + std::vector< Object * > objects; + + /** + * Destinations of the objects that left this zone. + * This is necessary in order to have an accurate iterator around moving + * objects. + */ + MapRegion destinations; + + MapZone(): nbCharacters(0), nbMovingObjects(0) {} + void insert(Object *); + void remove(Object *); +}; + +/** + * Pool of public IDs for MovingObjects on a map. By maintaining public ID + * availability using bits, it can locate an available public ID fast while + * using minimal memory access. + */ +struct ObjectBucket +{ + static int const int_bitsize = sizeof(unsigned) * 8; + unsigned bitmap[256 / int_bitsize]; /**< Bitmap of free locations. */ + short free; /**< Number of empty places. */ + short next_object; /**< Next object to look at. */ + MovingObject *objects[256]; + + ObjectBucket(); + int allocate(); + void deallocate(int); +}; + +/** + * Entities on a map. + */ +struct MapContent +{ + MapContent(Map *); + ~MapContent(); + + /** + * Allocates a unique ID for a moving object on this map. + */ + bool allocate(MovingObject *); + + /** + * Deallocates an ID. + */ + void deallocate(MovingObject *); + + /** + * Fills a region of zones within the range of a point. + */ + void fillRegion(MapRegion &, Point const &, int) const; + + /** + * Fills a region of zones inside a rectangle. + */ + void fillRegion(MapRegion &, Rectangle const &) const; + + /** + * Gets zone at given position. + */ + MapZone &getZone(Point const &pos) const; + + /** + * Things (items, characters, monsters, etc) located on the map. + */ + std::vector< Thing * > things; + + /** + * Buckets of MovingObjects located on the map, referenced by ID. + */ + ObjectBucket *buckets[256]; + + int last_bucket; /**< Last bucket acted upon. */ + + /** + * Partition of the Objects, depending on their position on the map. + */ + MapZone *zones; + + unsigned short mapWidth; /**< Width with respect to zones. */ + unsigned short mapHeight; /**< Height with respect to zones. */ +}; + +/** * Combined map/entity structure. */ class MapComposite |