--- deliantra/server/include/map.h 2006/12/31 10:28:36 1.43 +++ deliantra/server/include/map.h 2007/01/04 16:19:32 1.47 @@ -56,10 +56,12 @@ #define MAP_OVERLAY 0x10 /* Values for in_memory below. Should probably be an enumerations */ -#define MAP_IN_MEMORY 1 -#define MAP_SWAPPED 2 -#define MAP_LOADING 3 -#define MAP_SAVING 4 +enum { + MAP_IN_MEMORY, + MAP_SWAPPED, + MAP_LOADING, + MAP_SAVING, +}; /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should * really be used, as it is multi tile aware. However, there are some cases @@ -98,7 +100,7 @@ #define P_IS_ALIVE 0x10 /* something alive is on this space */ #define P_NO_CLERIC 0x20 /* no clerical spells cast here */ -#define P_NEED_UPDATE 0x80 /* this space is out of date */ +#define P_UPTODATE 0x80 /* this space is up to date */ /* The following two values are not stored in the MapLook flags, but instead * used in the get_map_flags value - that function is used to return @@ -136,7 +138,7 @@ void update_ (); void update () { - if (flags_ & P_NEED_UPDATE) + if (!(flags_ & P_UPTODATE)) update_ (); } @@ -233,6 +235,7 @@ uint32 ACC (RW, reset_timeout); /* How many seconds must elapse before this map * should be reset */ + bool ACC (RW, dirty); /* if true, something was inserted or removed */ bool ACC (RW, fixed_resettime); /* if true, reset time is not affected by * players entering/exiting map */ @@ -286,6 +289,9 @@ MTH void set_darkness_map (); MTH int estimate_difficulty () const; + // set the given flag on all objects in the map + MTH void set_object_flag (int flag, int value = 1); + MTH void link_multipart_objects (); MTH void clear_unique_items (); @@ -319,28 +325,26 @@ MTH object *insert (object *op, int x, int y, object *originator = 0, int flags = 0); -// static maptile *find_map (const char *path, maptile *origin);//PERL -// -// // load a map relative to this one -// maptile *find_map (const char *path) -// { -// return find_map (path, this); -// } -// -// // customise this map for the given player -// // might return this or a completely new map -// maptile *customise_for (object *op); -// -// void do_force_map_sync ();//PERL -// -// // make sure the map is loaded -// MTH void force_map_sync () -// { -// if (in_memory != MAP_IN_MEMORY) -// do_force_map_sync (); -// } + MTH void touch () { last_access = runtime; } + + // find the map that is at coordinate x|y relative to this map + // TODO: need a better way than passing by reference + // TODO: make perl interface + maptile *xy_find (sint16 &x, sint16 &y); + + // like xy_find, but also loads the map + maptile *xy_load (sint16 &x, sint16 &y); + + void do_load_sync ();//PERL + + // make sure the map is loaded + MTH void load_sync () + { + if (!spaces) + do_load_sync (); + } - static maptile *load_map_sync (const char *path, maptile *original = 0);//PERL + static maptile *find_sync (const char *path, maptile *original = 0);//PERL static void emergency_save ();//PERL mapspace const &at (uint32 x, uint32 y) const { return spaces [x * height + y]; }