--- deliantra/server/common/map.C 2006/12/18 04:07:30 1.44 +++ deliantra/server/common/map.C 2006/12/20 09:14:21 1.45 @@ -325,7 +325,7 @@ * true. If we get through the entire stack, that must mean * ob is blocking it, so return 0. */ - for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = tmp->above) + for (tmp = GET_MAP_OB (m, sx, sy); tmp; tmp = tmp->above) { /* This must be before the checks below. Code for inventory checkers. */ @@ -399,7 +399,6 @@ * code, we need to have actual object to check its move_type * against the move_block values. */ - int ob_blocked (const object *ob, maptile *m, sint16 x, sint16 y) { @@ -439,9 +438,9 @@ * head of the object should correspond for the entire object. */ if (OB_TYPE_MOVE_BLOCK (ob, GET_MAP_MOVE_BLOCK (m1, sx, sy))) - return AB_NO_PASS; - + return P_NO_PASS; } + return 0; } @@ -488,7 +487,7 @@ for (x = 0; x < MAP_WIDTH (m); x++) for (y = 0; y < MAP_HEIGHT (m); y++) - for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = above) + for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = above) { above = tmp->above; @@ -583,7 +582,7 @@ { unique = 0; /* check for unique items, or unique squares */ - for (otmp = get_map_ob (m, i, j); otmp; otmp = otmp->above) + for (otmp = GET_MAP_OB (m, i, j); otmp; otmp = otmp->above) { if (QUERY_FLAG (otmp, FLAG_UNIQUE) || QUERY_FLAG (otmp, FLAG_OBJ_SAVE_ON_OVL)) unique = 1; @@ -614,16 +613,13 @@ for (j = 0; j < MAP_HEIGHT (m); j++) { unique = 0; - for (op = get_map_ob (m, i, j); op; op = op->above) + for (op = GET_MAP_OB (m, i, j); op; op = op->above) { if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) unique = 1; if (op->type == PLAYER) - { - LOG (llevDebug, "Player on map that is being saved\n"); - continue; - } + continue; if (op->head || op->owner) continue; @@ -632,9 +628,8 @@ save_object (fp2, op, 3); else if (flag == 0 || (flag == 2 && (!QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) && !QUERY_FLAG (op, FLAG_UNPAID)))) save_object (fp, op, 3); - - } /* for this space */ - } /* for this j */ + } + } } maptile::maptile () @@ -694,8 +689,8 @@ free (spaces); } - spaces = (MapSpace *) - calloc (1, width * height * sizeof (MapSpace)); + spaces = (mapspace *) + calloc (1, width * height * sizeof (mapspace)); if (!spaces) fatal (OUT_OF_MEMORY); @@ -1251,7 +1246,7 @@ { unique = 0; - for (op = get_map_ob (m, i, j); op; op = next) + for (op = GET_MAP_OB (m, i, j); op; op = next) { next = op->above; @@ -1783,7 +1778,7 @@ for (x = 0; x < MAP_WIDTH (m); x++) for (y = 0; y < MAP_HEIGHT (m); y++) - for (op = get_map_ob (m, x, y); op != NULL; op = op->above) + for (op = GET_MAP_OB (m, x, y); op != NULL; op = op->above) { if (QUERY_FLAG (op, FLAG_MONSTER)) { @@ -1886,7 +1881,6 @@ return 1; } - /* * This function updates various attributes about a specific space * on the map (what it looks like, whether it blocks magic, @@ -1896,7 +1890,7 @@ void update_position (maptile *m, int x, int y) { - object *tmp, *last = NULL; + object *tmp, *last = 0; uint8 flags = 0, oldflags, light = 0, anywhere = 0; New_Face *top, *floor, *middle; object *top_obj, *floor_obj, *middle_obj; @@ -1910,20 +1904,19 @@ } middle = blank_face; - top = blank_face; - floor = blank_face; + top = blank_face; + floor = blank_face; - middle_obj = NULL; - top_obj = NULL; - floor_obj = NULL; + middle_obj = 0; + top_obj = 0; + floor_obj = 0; - for (tmp = get_map_ob (m, x, y); tmp; last = tmp, tmp = tmp->above) + for (tmp = GET_MAP_OB (m, x, y); tmp; last = tmp, tmp = tmp->above) { - /* This could be made additive I guess (two lights better than - * one). But if so, it shouldn't be a simple additive - 2 + * one). But if so, it shouldn't be a simple additive - 2 * light bulbs do not illuminate twice as far as once since - * it is a disapation factor that is squared (or is it cubed?) + * it is a dissapation factor that is cubed. */ if (tmp->glow_radius > light) light = tmp->glow_radius; @@ -1971,45 +1964,42 @@ middle_obj = tmp; } } + if (tmp == tmp->above) { LOG (llevError, "Error in structure of map\n"); exit (-1); } - move_slow |= tmp->move_slow; + move_slow |= tmp->move_slow; move_block |= tmp->move_block; - move_on |= tmp->move_on; - move_off |= tmp->move_off; + move_on |= tmp->move_on; + move_off |= tmp->move_off; move_allow |= tmp->move_allow; - if (QUERY_FLAG (tmp, FLAG_ALIVE)) - flags |= P_IS_ALIVE; - if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) - flags |= P_NO_MAGIC; - if (QUERY_FLAG (tmp, FLAG_DAMNED)) - flags |= P_NO_CLERIC; - if (tmp->type == SAFE_GROUND) - flags |= P_SAFE; - - if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) - flags |= P_BLOCKSVIEW; - } /* for stack of objects */ + if (QUERY_FLAG (tmp, FLAG_BLOCKSVIEW)) flags |= P_BLOCKSVIEW; + if (QUERY_FLAG (tmp, FLAG_NO_MAGIC)) flags |= P_NO_MAGIC; + if (tmp->type == PLAYER) flags |= P_PLAYER; + if (tmp->type == SAFE_GROUND) flags |= P_SAFE; + if (QUERY_FLAG (tmp, FLAG_ALIVE)) flags |= P_IS_ALIVE; + if (QUERY_FLAG (tmp, FLAG_DAMNED)) flags |= P_NO_CLERIC; + } /* we don't want to rely on this function to have accurate flags, but * since we're already doing the work, we calculate them here. * if they don't match, logic is broken someplace. */ if (((oldflags & ~(P_NEED_UPDATE | P_NO_ERROR)) != flags) && (!(oldflags & P_NO_ERROR))) - { - LOG (llevDebug, "update_position: updated flags do not match old flags: %s (old=%d,new=%d) %x != %x\n", - m->path, x, y, (oldflags & ~P_NEED_UPDATE), flags); - } - SET_MAP_FLAGS (m, x, y, flags); - SET_MAP_MOVE_BLOCK (m, x, y, move_block & ~move_allow); - SET_MAP_MOVE_ON (m, x, y, move_on); - SET_MAP_MOVE_OFF (m, x, y, move_off); - SET_MAP_MOVE_SLOW (m, x, y, move_slow); + LOG (llevDebug, "update_position: updated flags do not match old flags: %s (old=%d,new=%d) %x != %x\n", + m->path, x, y, (oldflags & ~P_NEED_UPDATE), flags); + + mapspace &s = m->at (x, y); + + s.flags = flags; + s.move_block = move_block & ~move_allow; + s.move_on = move_on; + s.move_off = move_off; + s.move_slow = move_slow; /* At this point, we have a floor face (if there is a floor), * and the floor is set - we are not going to touch it at @@ -2073,25 +2063,31 @@ } } } + if (middle == floor) middle = blank_face; + if (top == middle) middle = blank_face; + SET_MAP_FACE (m, x, y, top, 0); if (top != blank_face) SET_MAP_FACE_OBJ (m, x, y, top_obj, 0); else SET_MAP_FACE_OBJ (m, x, y, NULL, 0); + SET_MAP_FACE (m, x, y, middle, 1); if (middle != blank_face) SET_MAP_FACE_OBJ (m, x, y, middle_obj, 1); else SET_MAP_FACE_OBJ (m, x, y, NULL, 1); + SET_MAP_FACE (m, x, y, floor, 2); if (floor != blank_face) SET_MAP_FACE_OBJ (m, x, y, floor_obj, 2); else SET_MAP_FACE_OBJ (m, x, y, NULL, 2); + SET_MAP_LIGHT (m, x, y, light); }