--- deliantra/server/common/map.C 2007/09/09 06:25:45 1.128 +++ deliantra/server/common/map.C 2007/09/12 11:10:09 1.129 @@ -168,11 +168,11 @@ } /* - * Returns true if the given object can't fit in the given spot. - * This is meant for multi space objects - for single space objecs, + * Returns qthe blocking object if the given object can't fit in the given + * spot. This is meant for multi space objects - for single space objecs, * just calling get_map_blocked and checking that against movement type - * of object. This function goes through all the parts of the - * multipart object and makes sure they can be inserted. + * of object. This function goes through all the parts of the multipart + * object and makes sure they can be inserted. * * While this doesn't call out of map, the get_map_flags does. * @@ -193,48 +193,33 @@ * 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) +bool +object::blocked (maptile *m, int x, int y) const { - archetype *tmp; - int flag; - maptile *m1; - sint16 sx, sy; - - if (!ob) + for (archetype *tmp = arch; tmp; tmp = (archetype *)tmp->more) { - flag = get_map_flags (m, &m1, x, y, &sx, &sy); - if (flag & P_OUT_OF_MAP) - return P_OUT_OF_MAP; + mapxy pos (m, x + tmp->x, y + tmp->y); - /* don't have object, so don't know what types would block */ - return m1->at (sx, sy).move_block; - } + if (!pos.normalise ()) + return 1; - for (tmp = ob->arch; tmp; tmp = (archetype *)tmp->more) - { - flag = get_map_flags (m, &m1, x + tmp->x, y + tmp->y, &sx, &sy); + mapspace &ms = *pos; - if (flag & P_OUT_OF_MAP) - return P_OUT_OF_MAP; - if (flag & P_IS_ALIVE) - return P_IS_ALIVE; + if (ms.flags () & P_IS_ALIVE) + return 1; - mapspace &ms = m1->at (sx, sy); - - /* find_first_free_spot() calls this function. However, often - * ob doesn't have any move type (when used to place exits) + /* However, often ob doesn't have any move type + * (signifying non-moving objects) * so the AND operation in OB_TYPE_MOVE_BLOCK doesn't work. */ - - if (ob->move_type == 0 && ms.move_block != MOVE_ALL) + if (!move_type && ms.move_block != MOVE_ALL) continue; /* Note it is intentional that we check ob - the movement type of the * head of the object should correspond for the entire object. */ - if (OB_TYPE_MOVE_BLOCK (ob, ms.move_block)) - return P_NO_PASS; + if (ms.blocks (move_type)) + return 1; } return 0;