1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
77 | * bail now - we know it can't work. |
78 | * bail now - we know it can't work. |
78 | */ |
79 | */ |
79 | if (mflags & P_OUT_OF_MAP) |
80 | if (mflags & P_OUT_OF_MAP) |
80 | return 0; |
81 | return 0; |
81 | |
82 | |
82 | |
|
|
83 | /* Is this space blocked? Players with wizpass are immune to |
83 | /* Is this space blocked? Players with wizpass are immune to |
84 | * this condition. |
84 | * this condition. |
85 | */ |
85 | */ |
86 | if (blocked_link (op, m, newx, newy) && !QUERY_FLAG (op, FLAG_WIZPASS)) |
86 | if (blocked_link (op, m, newx, newy) && !QUERY_FLAG (op, FLAG_WIZPASS)) |
87 | return 0; |
87 | return 0; |
88 | |
88 | |
89 | /* 0.94.2 - we need to set the direction for the new animation code. |
89 | /* 0.94.2 - we need to set the direction for the new animation code. |
90 | * it uses it to figure out face to use - I can't see it |
90 | * it uses it to figure out face to use - I can't see it |
91 | * breaking anything, but it might. |
91 | * breaking anything, but it might. |
92 | */ |
92 | */ |
93 | if (op->more != NULL && !move_ob (op->more, dir, op->more->head)) |
93 | if (op->more && !move_ob (op->more, dir, op->more->head)) |
94 | return 0; |
94 | return 0; |
95 | |
95 | |
96 | op->direction = dir; |
96 | op->direction = dir; |
97 | |
97 | |
98 | if (op->will_apply & 4) |
98 | if (op->will_apply & 4) |
99 | check_earthwalls (op, m, newx, newy); |
99 | check_earthwalls (op, m, newx, newy); |
|
|
100 | |
100 | if (op->will_apply & 8) |
101 | if (op->will_apply & 8) |
101 | check_doors (op, m, newx, newy); |
102 | check_doors (op, m, newx, newy); |
102 | |
103 | |
103 | /* 0.94.1 - I got a stack trace that showed it crash with remove_ob trying |
104 | /* 0.94.1 - I got a stack trace that showed it crash with remove_ob trying |
104 | * to remove a removed object, and this function was the culprit. A possible |
105 | * to remove a removed object, and this function was the culprit. A possible |
… | |
… | |
121 | * ok - the caller will deal with actual object removal/insertion |
122 | * ok - the caller will deal with actual object removal/insertion |
122 | */ |
123 | */ |
123 | if (op->head) |
124 | if (op->head) |
124 | return 1; |
125 | return 1; |
125 | |
126 | |
|
|
127 | if (m != op->map && op->contr) |
|
|
128 | { |
|
|
129 | if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr))) |
|
|
130 | return 0; |
|
|
131 | |
|
|
132 | op->remove (); |
|
|
133 | |
|
|
134 | if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (m), ARG_INT (newx), ARG_INT (newy))) |
|
|
135 | return 0; |
|
|
136 | |
|
|
137 | if (INVOKE_MAP (ENTER, m, ARG_PLAYER (op->contr), ARG_INT (newx), ARG_INT (newy))) |
|
|
138 | return 0; |
|
|
139 | } |
|
|
140 | else |
126 | op->remove (); |
141 | op->remove (); |
127 | |
142 | |
128 | /* we already have newx, newy, and m, so lets use them. |
143 | /* we already have newx, newy, and m, so lets use them. |
129 | * In addition, this fixes potential crashes, because multipart object was |
144 | * In addition, this fixes potential crashes, because multipart object was |
130 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
145 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
131 | */ |
146 | */ |
… | |
… | |
219 | if (i == 0 && j == 0) |
234 | if (i == 0 && j == 0) |
220 | continue; |
235 | continue; |
221 | /* Perhaps this should be extended to support tiled maps */ |
236 | /* Perhaps this should be extended to support tiled maps */ |
222 | if (OUT_OF_REAL_MAP (teleporter->map, teleporter->x + i, teleporter->y + j)) |
237 | if (OUT_OF_REAL_MAP (teleporter->map, teleporter->x + i, teleporter->y + j)) |
223 | continue; |
238 | continue; |
224 | other_teleporter = get_map_ob (teleporter->map, teleporter->x + i, teleporter->y + j); |
239 | other_teleporter = GET_MAP_OB (teleporter->map, teleporter->x + i, teleporter->y + j); |
225 | |
240 | |
226 | while (other_teleporter) |
241 | while (other_teleporter) |
227 | { |
242 | { |
228 | if (other_teleporter->type == tele_type) |
243 | if (other_teleporter->type == tele_type) |
229 | break; |
244 | break; |
… | |
… | |
327 | mflags = get_map_flags (m, &m2, tx, ty, &tx, &ty); |
342 | mflags = get_map_flags (m, &m2, tx, ty, &tx, &ty); |
328 | |
343 | |
329 | if (mflags & P_OUT_OF_MAP) |
344 | if (mflags & P_OUT_OF_MAP) |
330 | return 1; |
345 | return 1; |
331 | |
346 | |
332 | for (tmp = get_map_ob (m2, tx, ty); tmp; tmp = tmp->above) |
347 | for (tmp = GET_MAP_OB (m2, tx, ty); tmp; tmp = tmp->above) |
333 | { |
348 | { |
334 | if (tmp->head == op || tmp == op) |
349 | if (tmp->head == op || tmp == op) |
335 | continue; |
350 | continue; |
336 | |
351 | |
337 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->type != DOOR)) |
352 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->type != DOOR)) |
… | |
… | |
378 | move_block = GET_MAP_MOVE_BLOCK (m, x, y); |
393 | move_block = GET_MAP_MOVE_BLOCK (m, x, y); |
379 | |
394 | |
380 | /* If the target space is not blocked, no need to look at the objects on it */ |
395 | /* If the target space is not blocked, no need to look at the objects on it */ |
381 | if ((op->move_type & move_block) == op->move_type) |
396 | if ((op->move_type & move_block) == op->move_type) |
382 | { |
397 | { |
383 | for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) |
398 | for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above) |
384 | { |
399 | { |
385 | if (tmp->head == op) |
400 | if (tmp->head == op) |
386 | continue; |
401 | continue; |
387 | if (OB_MOVE_BLOCK (op, tmp) && !roll_ob (tmp, dir, pusher)) |
402 | if (OB_MOVE_BLOCK (op, tmp) && !roll_ob (tmp, dir, pusher)) |
388 | return 0; |
403 | return 0; |