… | |
… | |
59 | move_ob (object *op, int dir, object *originator) |
59 | move_ob (object *op, int dir, object *originator) |
60 | { |
60 | { |
61 | sint16 newx = op->x + freearr_x[dir]; |
61 | sint16 newx = op->x + freearr_x[dir]; |
62 | sint16 newy = op->y + freearr_y[dir]; |
62 | sint16 newy = op->y + freearr_y[dir]; |
63 | object *tmp; |
63 | object *tmp; |
64 | mapstruct *m; |
64 | maptile *m; |
65 | int mflags; |
65 | int mflags; |
66 | |
66 | |
67 | if (op == NULL) |
67 | if (op == NULL) |
68 | { |
68 | { |
69 | LOG (llevError, "Trying to move NULL.\n"); |
69 | LOG (llevError, "Trying to move NULL.\n"); |
… | |
… | |
121 | * ok - the caller will deal with actual object removal/insertion |
121 | * ok - the caller will deal with actual object removal/insertion |
122 | */ |
122 | */ |
123 | if (op->head) |
123 | if (op->head) |
124 | return 1; |
124 | return 1; |
125 | |
125 | |
126 | remove_ob (op); |
126 | op->remove (); |
127 | |
127 | |
128 | /* we already have newx, newy, and m, so lets use them. |
128 | /* we already have newx, newy, and m, so lets use them. |
129 | * In addition, this fixes potential crashes, because multipart object was |
129 | * In addition, this fixes potential crashes, because multipart object was |
130 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
130 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
131 | */ |
131 | */ |
… | |
… | |
169 | if (i == -1) |
169 | if (i == -1) |
170 | return 0; /* No free spot */ |
170 | return 0; /* No free spot */ |
171 | |
171 | |
172 | if (op->head != NULL) |
172 | if (op->head != NULL) |
173 | op = op->head; |
173 | op = op->head; |
174 | remove_ob (op); |
174 | op->remove (); |
175 | for (tmp = op; tmp != NULL; tmp = tmp->more) |
175 | for (tmp = op; tmp != NULL; tmp = tmp->more) |
176 | tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), |
176 | tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), |
177 | tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
177 | tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y); |
178 | |
178 | |
179 | tmp = insert_ob_in_map (op, op->map, originator, 0); |
179 | tmp = insert_ob_in_map (op, op->map, originator, 0); |
… | |
… | |
199 | teleport (object *teleporter, uint8 tele_type, object *user) |
199 | teleport (object *teleporter, uint8 tele_type, object *user) |
200 | { |
200 | { |
201 | object *altern; |
201 | object *altern; |
202 | int i, j, k, nrofalt = 0; |
202 | int i, j, k, nrofalt = 0; |
203 | object *other_teleporter, *tmp; |
203 | object *other_teleporter, *tmp; |
204 | mapstruct *m; |
204 | maptile *m; |
205 | sint16 sx, sy; |
205 | sint16 sx, sy; |
206 | |
206 | |
207 | if (user == NULL) |
207 | if (user == NULL) |
208 | return 0; |
208 | return 0; |
209 | if (user->head != NULL) |
209 | if (user->head != NULL) |
… | |
… | |
272 | } |
272 | } |
273 | else |
273 | else |
274 | return 0; |
274 | return 0; |
275 | } |
275 | } |
276 | |
276 | |
277 | remove_ob (user); |
277 | user->remove (); |
278 | |
278 | |
279 | /* Update location for the object */ |
279 | /* Update location for the object */ |
280 | for (tmp = user; tmp != NULL; tmp = tmp->more) |
280 | for (tmp = user; tmp != NULL; tmp = tmp->more) |
281 | { |
281 | { |
282 | tmp->x = other_teleporter->x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); |
282 | tmp->x = other_teleporter->x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); |
… | |
… | |
307 | * This is currently only used for the boulder roll code. |
307 | * This is currently only used for the boulder roll code. |
308 | * Returns 1 if object does not fit, 0 if it does. |
308 | * Returns 1 if object does not fit, 0 if it does. |
309 | */ |
309 | */ |
310 | |
310 | |
311 | int |
311 | int |
312 | try_fit (object *op, mapstruct *m, int x, int y) |
312 | try_fit (object *op, maptile *m, int x, int y) |
313 | { |
313 | { |
314 | object *tmp, *more; |
314 | object *tmp, *more; |
315 | sint16 tx, ty; |
315 | sint16 tx, ty; |
316 | int mflags; |
316 | int mflags; |
317 | mapstruct *m2; |
317 | maptile *m2; |
318 | |
318 | |
319 | if (op->head) |
319 | if (op->head) |
320 | op = op->head; |
320 | op = op->head; |
321 | |
321 | |
322 | for (more = op; more; more = more->more) |
322 | for (more = op; more; more = more->more) |
… | |
… | |
355 | roll_ob (object *op, int dir, object *pusher) |
355 | roll_ob (object *op, int dir, object *pusher) |
356 | { |
356 | { |
357 | object *tmp; |
357 | object *tmp; |
358 | sint16 x, y; |
358 | sint16 x, y; |
359 | int flags; |
359 | int flags; |
360 | mapstruct *m; |
360 | maptile *m; |
361 | MoveType move_block; |
361 | MoveType move_block; |
362 | |
362 | |
363 | if (op->head) |
363 | if (op->head) |
364 | op = op->head; |
364 | op = op->head; |
365 | |
365 | |
… | |
… | |
389 | } |
389 | } |
390 | } |
390 | } |
391 | if (try_fit (op, m, x, y)) |
391 | if (try_fit (op, m, x, y)) |
392 | return 0; |
392 | return 0; |
393 | |
393 | |
394 | remove_ob (op); |
394 | op->remove (); |
395 | for (tmp = op; tmp != NULL; tmp = tmp->more) |
395 | for (tmp = op; tmp != NULL; tmp = tmp->more) |
396 | tmp->x += freearr_x[dir], tmp->y += freearr_y[dir]; |
396 | tmp->x += freearr_x[dir], tmp->y += freearr_y[dir]; |
397 | insert_ob_in_map (op, op->map, pusher, 0); |
397 | insert_ob_in_map (op, op->map, pusher, 0); |
398 | return 1; |
398 | return 1; |
399 | } |
399 | } |
… | |
… | |
421 | && owner == pusher |
421 | && owner == pusher |
422 | #endif |
422 | #endif |
423 | ) |
423 | ) |
424 | { |
424 | { |
425 | int temp; |
425 | int temp; |
426 | mapstruct *m; |
426 | maptile *m; |
427 | |
427 | |
428 | remove_ob (who); |
428 | who->remove (); |
429 | remove_ob (pusher); |
429 | pusher->remove (); |
430 | temp = pusher->x; |
430 | temp = pusher->x; |
431 | pusher->x = who->x; |
431 | pusher->x = who->x; |
432 | who->x = temp; |
432 | who->x = temp; |
433 | |
433 | |
434 | temp = pusher->y; |
434 | temp = pusher->y; |