… | |
… | |
1097 | |
1097 | |
1098 | if (object *pl = ms.player ()) |
1098 | if (object *pl = ms.player ()) |
1099 | { |
1099 | { |
1100 | if (is_player ()) |
1100 | if (is_player ()) |
1101 | { |
1101 | { |
|
|
1102 | if (!flag [FLAG_WIZPASS]) |
1102 | ms.smell = ++mapspace::smellcount; // remember the smell of the player |
1103 | ms.smell = ++mapspace::smellcount; // remember the smell of the player |
1103 | |
1104 | |
1104 | // leaving a spot always closes any open container on the ground |
1105 | // leaving a spot always closes any open container on the ground |
1105 | if (container && !container->env) |
1106 | if (container && !container->env) |
1106 | // this causes spurious floorbox updates, but it ensures |
1107 | // this causes spurious floorbox updates, but it ensures |
1107 | // that the CLOSE event is being sent. |
1108 | // that the CLOSE event is being sent. |
… | |
… | |
1285 | |
1286 | |
1286 | /* Ideally, the caller figures this out. However, it complicates a lot |
1287 | /* Ideally, the caller figures this out. However, it complicates a lot |
1287 | * of areas of callers (eg, anything that uses find_free_spot would now |
1288 | * of areas of callers (eg, anything that uses find_free_spot would now |
1288 | * need extra work |
1289 | * need extra work |
1289 | */ |
1290 | */ |
|
|
1291 | maptile *newmap = m; |
1290 | if (!xy_normalise (m, op->x, op->y)) |
1292 | if (!xy_normalise (newmap, op->x, op->y)) |
1291 | { |
1293 | { |
1292 | op->head_ ()->destroy ();// remove head_ once all tail object destroyers found |
1294 | op->head_ ()->destroy ();// remove head_ once all tail object destroyers found |
1293 | return 0; |
1295 | return 0; |
1294 | } |
1296 | } |
1295 | |
1297 | |
… | |
… | |
1297 | if (!insert_ob_in_map (more, m, originator, flag)) |
1299 | if (!insert_ob_in_map (more, m, originator, flag)) |
1298 | return 0; |
1300 | return 0; |
1299 | |
1301 | |
1300 | CLEAR_FLAG (op, FLAG_REMOVED); |
1302 | CLEAR_FLAG (op, FLAG_REMOVED); |
1301 | |
1303 | |
1302 | op->map = m; |
1304 | op->map = newmap; |
1303 | mapspace &ms = op->ms (); |
1305 | mapspace &ms = op->ms (); |
1304 | |
1306 | |
1305 | /* this has to be done after we translate the coordinates. |
1307 | /* this has to be done after we translate the coordinates. |
1306 | */ |
1308 | */ |
1307 | if (op->nrof && !(flag & INS_NO_MERGE)) |
1309 | if (op->nrof && !(flag & INS_NO_MERGE)) |
… | |
… | |
2055 | * there is capable of. |
2057 | * there is capable of. |
2056 | */ |
2058 | */ |
2057 | int |
2059 | int |
2058 | find_dir (maptile *m, int x, int y, object *exclude) |
2060 | find_dir (maptile *m, int x, int y, object *exclude) |
2059 | { |
2061 | { |
2060 | int i, max = SIZEOFFREE, mflags; |
2062 | int max = SIZEOFFREE, mflags; |
2061 | |
|
|
2062 | sint16 nx, ny; |
|
|
2063 | object *tmp; |
|
|
2064 | maptile *mp; |
|
|
2065 | |
|
|
2066 | MoveType blocked, move_type; |
2063 | MoveType move_type; |
2067 | |
2064 | |
2068 | if (exclude && exclude->head_ () != exclude) |
2065 | if (exclude && exclude->head_ () != exclude) |
2069 | { |
2066 | { |
2070 | exclude = exclude->head; |
2067 | exclude = exclude->head; |
2071 | move_type = exclude->move_type; |
2068 | move_type = exclude->move_type; |
… | |
… | |
2074 | { |
2071 | { |
2075 | /* If we don't have anything, presume it can use all movement types. */ |
2072 | /* If we don't have anything, presume it can use all movement types. */ |
2076 | move_type = MOVE_ALL; |
2073 | move_type = MOVE_ALL; |
2077 | } |
2074 | } |
2078 | |
2075 | |
2079 | for (i = 1; i < max; i++) |
2076 | for (int i = 1; i < max; i++) |
2080 | { |
2077 | { |
2081 | mp = m; |
2078 | mapxy pos (m, x, y); |
2082 | nx = x + freearr_x[i]; |
2079 | pos.move (i); |
2083 | ny = y + freearr_y[i]; |
|
|
2084 | |
2080 | |
2085 | mflags = get_map_flags (m, &mp, nx, ny, &nx, &ny); |
2081 | if (!pos.normalise ()) |
2086 | |
|
|
2087 | if (mflags & P_OUT_OF_MAP) |
|
|
2088 | max = maxfree[i]; |
2082 | max = maxfree[i]; |
2089 | else |
2083 | else |
2090 | { |
2084 | { |
2091 | mapspace &ms = mp->at (nx, ny); |
2085 | mapspace &ms = *pos; |
2092 | |
2086 | |
2093 | blocked = ms.move_block; |
|
|
2094 | |
|
|
2095 | if ((move_type & blocked) == move_type) |
2087 | if ((move_type & ms.move_block) == move_type) |
2096 | max = maxfree[i]; |
2088 | max = maxfree [i]; |
2097 | else if (mflags & P_IS_ALIVE) |
2089 | else if (ms.flags () & P_IS_ALIVE) |
2098 | { |
2090 | { |
2099 | for (tmp = ms.bot; tmp; tmp = tmp->above) |
2091 | for (object *tmp = ms.bot; tmp; tmp = tmp->above) |
2100 | if ((tmp->flag [FLAG_MONSTER] || tmp->is_player ()) |
2092 | if ((tmp->flag [FLAG_MONSTER] || tmp->is_player ()) |
2101 | && (tmp != exclude || (tmp->head_ () != tmp && tmp->head_ () != exclude))) |
2093 | && (tmp != exclude || (tmp->head_ () != tmp && tmp->head_ () != exclude))) |
2102 | break; |
|
|
2103 | |
|
|
2104 | if (tmp) |
|
|
2105 | return freedir[i]; |
2094 | return freedir [i]; |
2106 | } |
2095 | } |
2107 | } |
2096 | } |
2108 | } |
2097 | } |
2109 | |
2098 | |
2110 | return 0; |
2099 | return 0; |