ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/map.h
(Generate patch)

Comparing deliantra/server/include/map.h (file contents):
Revision 1.29 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.30 by root, Wed Dec 20 11:36:39 2006 UTC

99 * really be used, as it is multi tile aware. However, there are some cases 99 * really be used, as it is multi tile aware. However, there are some cases
100 * where it is known the map is not tiled or the values are known 100 * where it is known the map is not tiled or the values are known
101 * consistent (eg, op->map, op->x, op->y) 101 * consistent (eg, op->map, op->x, op->y)
102 */ 102 */
103// all those macros are herewith declared legacy 103// all those macros are herewith declared legacy
104#define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags 104#define GET_MAP_FLAGS(M,X,Y) (M)->at((X),(Y)).flags ()
105#define SET_MAP_FLAGS(M,X,Y,C) (M)->at((X),(Y)).flags = (C)
106#define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light 105#define GET_MAP_LIGHT(M,X,Y) (M)->at((X),(Y)).light
107#define SET_MAP_LIGHT(M,X,Y,L) (M)->at((X),(Y)).light = (L)
108#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bottom 106#define GET_MAP_OB(M,X,Y) (M)->at((X),(Y)).bottom
109#define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top 107#define GET_MAP_TOP(M,X,Y) (M)->at((X),(Y)).top
110#define SET_MAP_OB(M,X,Y,tmp) (M)->at((X),(Y)).bottom = (tmp)
111#define SET_MAP_TOP(M,X,Y,tmp) (M)->at((X),(Y)).top = (tmp)
112#define SET_MAP_FACE(M,X,Y,C,L) (M)->at((X),(Y)).faces[L] = (C)
113#define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L] 108#define GET_MAP_FACE(M,X,Y,L) (M)->at((X),(Y)).faces[L]
114#define SET_MAP_FACE_OBJ(M,X,Y,C,L) (M)->at((X),(Y)).faces_obj[L] = (C)
115#define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L] 109#define GET_MAP_FACE_OBJ(M,X,Y,L) (M)->at((X),(Y)).faces_obj[L]
116#define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block 110#define GET_MAP_MOVE_BLOCK(M,X,Y) (M)->at((X),(Y)).move_block
117#define SET_MAP_MOVE_BLOCK(M,X,Y,C) (M)->at((X),(Y)).move_block = (C)
118#define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow 111#define GET_MAP_MOVE_SLOW(M,X,Y) (M)->at((X),(Y)).move_slow
119#define SET_MAP_MOVE_SLOW(M,X,Y,C) (M)->at((X),(Y)).move_slow = (C)
120#define GET_MAP_MOVE_ON(M,X,Y) (M)->at((X),(Y)).move_on 112#define GET_MAP_MOVE_ON(M,X,Y) (M)->at((X),(Y)).move_on
121#define SET_MAP_MOVE_ON(M,X,Y,C) (M)->at((X),(Y)).move_on = (C)
122#define GET_MAP_MOVE_OFF(M,X,Y) (M)->at((X),(Y)).move_off 113#define GET_MAP_MOVE_OFF(M,X,Y) (M)->at((X),(Y)).move_off
123#define SET_MAP_MOVE_OFF(M,X,Y,C) (M)->at((X),(Y)).move_off = (C)
124 114
125/* You should really know what you are doing before using this - you 115/* You should really know what you are doing before using this - you
126 * should almost always be using out_of_map instead, which takes into account 116 * should almost always be using out_of_map instead, which takes into account
127 * map tiling. 117 * map tiling.
128 */ 118 */
139 * such as: bombs, potion usage, alchemy, spells 129 * such as: bombs, potion usage, alchemy, spells
140 * this was introduced to make shops safer 130 * this was introduced to make shops safer
141 * but is useful in other situations */ 131 * but is useful in other situations */
142#define P_IS_ALIVE 0x10 /* something alive is on this space */ 132#define P_IS_ALIVE 0x10 /* something alive is on this space */
143#define P_NO_CLERIC 0x20 /* no clerical spells cast here */ 133#define P_NO_CLERIC 0x20 /* no clerical spells cast here */
134
144#define P_NEED_UPDATE 0x40 /* this space is out of date */ 135#define P_NEED_UPDATE 0x80 /* this space is out of date */
145#define P_NO_ERROR 0x80 /* Purely temporary - if set, update_position
146 * does not complain if the flags are different.
147 */
148 136
149/* The following two values are not stored in the MapLook flags, but instead 137/* The following two values are not stored in the MapLook flags, but instead
150 * used in the get_map_flags value - that function is used to return 138 * used in the get_map_flags value - that function is used to return
151 * the flag value, as well as other conditions - using a more general 139 * the flag value, as well as other conditions - using a more general
152 * function that does more of the work can hopefully be used to replace 140 * function that does more of the work can hopefully be used to replace
170struct mapspace 158struct mapspace
171{ 159{
172 object *bottom; /* lowest object on this space */ 160 object *bottom; /* lowest object on this space */
173 object *top; /* Highest object on this space */ 161 object *top; /* Highest object on this space */
174 New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */ 162 New_Face *faces[MAP_LAYERS]; /* faces for the 3 layers */
175 object *faces_obj[MAP_LAYERS]; /* face objects for the 3 layers */ 163 object *faces_obj[MAP_LAYERS];/* face objects for the 3 layers */
176 uint8 flags; /* flags about this space (see the P_ values above) */ 164 uint8 flags_; /* flags about this space (see the P_ values above) */
177 sint8 light; /* How much light this space provides */ 165 sint8 light; /* How much light this space provides */
178 uint8 move_block; /* What movement types this space blocks */ 166 MoveType move_block; /* What movement types this space blocks */
179 uint8 move_slow; /* What movement types this space slows */ 167 MoveType move_slow; /* What movement types this space slows */
180 uint8 move_on; /* What movement types are activated */ 168 MoveType move_on; /* What movement types are activated */
181 uint8 move_off; /* What movement types are activated */ 169 MoveType move_off; /* What movement types are activated */
170
171 void update_ ();
172 void update ()
173 {
174 if (flags_ & P_NEED_UPDATE)
175 update_ ();
176 }
177
178 uint8 flags ()
179 {
180 update ();
181 return flags_;
182 }
183
184 // maybe only inline quick flags_ checking?
185 object *player ()
186 {
187 if (flags () & P_PLAYER)
188 for (object *op = bottom; op; op = op->above)
189 if (op->type == PLAYER)
190 return op;
191
192 return 0;
193 }
182}; 194};
183 195
184/* 196/*
185 * this is an overlay structure of the whole world. It exists as a simple 197 * this is an overlay structure of the whole world. It exists as a simple
186 * high level map, which doesn't contain the full data of the underlying map. 198 * high level map, which doesn't contain the full data of the underlying map.

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines