--- deliantra/server/include/map.h 2006/12/21 01:33:49 1.31 +++ deliantra/server/include/map.h 2006/12/27 13:13:47 1.39 @@ -32,7 +32,7 @@ #include "cfperl.h" /* We set this size - this is to make magic map work properly on - * tiled maps. There is no requirement that this matches the + * tiled maps. There is no requirement that this matches the * tiled maps size - it just seemed like a reasonable value. * Magic map code now always starts out putting the player in the * center of the map - this makes the most sense when dealing @@ -46,47 +46,11 @@ #define MAP_LAYERS 3 -/* This is when the map will reset */ -#define MAP_WHEN_RESET(m) ((m)->reset_time) - -#define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout) -#define MAP_DIFFICULTY(m) ((m)->difficulty) -#define MAP_TIMEOUT(m) ((m)->timeout) -#define MAP_SWAP_TIME(m) ((m)->swap_time) -#define MAP_OUTDOORS(m) ((m)->outdoor) - -/* mape darkness used to enforce the MAX_DARKNESS value. - * but IMO, if it is beyond max value, that should be fixed - * on the map or in the code. - */ -#define MAP_DARKNESS(m) (m)->darkness - -#define MAP_WIDTH(m) (m)->width -#define MAP_HEIGHT(m) (m)->height - -/* Convenient function - total number of spaces is used - * in many places. - */ -#define MAP_SIZE(m) ((m)->width * (m)->height) - -#define MAP_ENTER_X(m) (m)->enter_x -#define MAP_ENTER_Y(m) (m)->enter_y - -#define MAP_TEMP(m) (m)->temp -#define MAP_PRESSURE(m) (m)->pressure -#define MAP_HUMID(m) (m)->humid -#define MAP_WINDSPEED(m) (m)->windspeed -#define MAP_WINDDIRECTION(m) (m)->winddir -#define MAP_SKYCOND(m) (m)->sky -#define MAP_WORLDPARTX(m) (m)->wpartx -#define MAP_WORLDPARTY(m) (m)->wparty -#define MAP_NOSMOOTH(m) (m)->nosmooth - /* options passed to ready_map_name and load_original_map */ -#define MAP_FLUSH 0x1 -#define MAP_PLAYER_UNIQUE 0x2 -#define MAP_BLOCK 0x4 -#define MAP_STYLE 0x8 +#define MAP_FLUSH 0x01 +#define MAP_PLAYER_UNIQUE 0x02 +#define MAP_BLOCK 0x04 +#define MAP_STYLE 0x08 #define MAP_OVERLAY 0x10 /* Values for in_memory below. Should probably be an enumerations */ @@ -103,7 +67,7 @@ // all those macros are herewith declared legacy #define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags () #define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light -#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bottom +#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bot #define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top #define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L] #define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] @@ -157,8 +121,7 @@ */ struct mapspace { - object *bottom; /* lowest object on this space */ - object *top; /* Highest object on this space */ + object *bot, *top; /* lowest/highest object on this space */ New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */ uint8 flags_; /* flags about this space (see the P_ values above) */ @@ -269,8 +232,8 @@ * (or even through the macros), but doing so will completely * break map tiling. */ -ACC_CLASS (maptile) -struct maptile : zero_initialised, attachable +INTERFACE_CLASS (maptile) +struct maptile : zero_initialised, attachable { sint32 ACC (RO, width), ACC (RO, height); /* Width and height of map. */ struct mapspace *spaces; /* Array of spaces on this map */ @@ -310,7 +273,7 @@ sint8 ACC (RW, windspeed); /* windspeed of this tile */ sint8 ACC (RW, winddir); /* direction of wind */ sint8 ACC (RW, sky); /* sky conditions */ - int ACC (RW, wpartx), ACC (RW, wparty); /*Highly fasten conversion between worldmap and weathermap */ + int ACC (RW, worldpartx), ACC (RW, worldparty); /*Highly fasten conversion between worldmap and weathermap */ struct shopitems *shopitems; /* a semi-colon seperated list of item-types the map's shop will trade in */ char *ACC (RO, shoprace); /* the preffered race of the local shopkeeper */ double ACC (RW, shopgreed); /* how much our shopkeeper overcharges */ @@ -323,12 +286,24 @@ char ACC (RW, path)[HUGE_BUF]; /* Filename of the map */ maptile (); - void allocate (); + ~maptile (); + void do_destroy (); + void gather_callbacks (AV *&callbacks, event_type event) const; + + MTH void allocate (); + MTH int size () const { return width * height; } - mapspace const &at (uint32 x, uint32 y) const { return spaces [x + width * y]; } - mapspace &at (uint32 x, uint32 y) { return spaces [x + width * y]; } + MTH object *insert (object *op, int x, int y, object *originator = 0, int flags = 0); + + MTH void link (); + MTH void unlink (); + + mapspace const &at (uint32 x, uint32 y) const { return spaces [x * height + y]; } + mapspace &at (uint32 x, uint32 y) { return spaces [x * height + y]; } }; +#define for_all_maps(var) for (maptile *var = first_map; var; var = var->next) + /* This is used by get_rangevector to determine where the other * creature is. get_rangevector takes into account map tiling, * so you just can not look the the map coordinates and get the