1 | /* |
1 | /* |
2 | * static char *rcsid_move_c = |
2 | * static char *rcsid_move_c = |
3 | * "$Id: move.c,v 1.1.1.1 2006/02/03 07:14:33 root Exp $"; |
3 | * "$Id: move.c,v 1.4 2006/02/22 18:53:56 elmex Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
27 | */ |
27 | */ |
28 | |
28 | |
29 | #include <global.h> |
29 | #include <global.h> |
30 | #ifndef __CEXTRACT__ |
30 | #ifndef __CEXTRACT__ |
31 | #include <sproto.h> |
31 | #include <sproto.h> |
|
|
32 | #endif |
|
|
33 | |
|
|
34 | #ifdef COZY_SERVER |
|
|
35 | // use a ptotoype |
|
|
36 | extern int same_party (partylist *a, partylist *b); |
32 | #endif |
37 | #endif |
33 | |
38 | |
34 | /* |
39 | /* |
35 | * move_object() tries to move object op in the direction "dir". |
40 | * move_object() tries to move object op in the direction "dir". |
36 | * If it fails (something blocks the passage), it returns 0, |
41 | * If it fails (something blocks the passage), it returns 0, |
… | |
… | |
123 | /* we already have newx, newy, and m, so lets use them. |
128 | /* we already have newx, newy, and m, so lets use them. |
124 | * In addition, this fixes potential crashes, because multipart object was |
129 | * In addition, this fixes potential crashes, because multipart object was |
125 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
130 | * on edge of map, +=x, +=y doesn't make correct coordinates. |
126 | */ |
131 | */ |
127 | for(tmp = op; tmp != NULL; tmp = tmp->more) { |
132 | for(tmp = op; tmp != NULL; tmp = tmp->more) { |
128 | tmp->x = newx + tmp->arch->clone.x; |
133 | tmp->x += freearr_x[dir]; |
129 | tmp->y = newy + tmp->arch->clone.y; |
134 | tmp->y += freearr_y[dir]; |
130 | tmp->map = m; |
135 | tmp->map = get_map_from_coord(tmp->map, &tmp->x, &tmp->y); |
131 | } |
136 | } |
132 | |
137 | |
133 | /* insert_ob_in_map will deal with any tiling issues */ |
138 | /* insert_ob_in_map will deal with any tiling issues */ |
134 | insert_ob_in_map(op, m, originator,0); |
139 | insert_ob_in_map(op, m, originator,0); |
135 | |
140 | |
136 | /* Hmmm. Should be possible for multispace players now */ |
141 | /* Hmmm. Should be possible for multispace players now */ |
137 | if (op->type==PLAYER) { |
142 | if (op->type==PLAYER) { |
138 | esrv_map_scroll(&op->contr->socket, freearr_x[dir],freearr_y[dir]); |
143 | esrv_map_scroll(&op->contr->socket, freearr_x[dir],freearr_y[dir]); |
139 | op->contr->socket.update_look=1; |
144 | op->contr->socket.update_look=1; |
140 | op->contr->socket.look_position=0; |
145 | op->contr->socket.look_position=0; |
|
|
146 | } |
|
|
147 | else if (op->type == TRANSPORT) { |
|
|
148 | object *pl; |
|
|
149 | |
|
|
150 | for (pl=op->inv; pl; pl=pl->below) { |
|
|
151 | if (pl->type == PLAYER) { |
|
|
152 | pl->contr->do_los=1; |
|
|
153 | pl->map = op->map; |
|
|
154 | pl->x = op->x; |
|
|
155 | pl->y = op->y; |
|
|
156 | esrv_map_scroll(&pl->contr->socket, freearr_x[dir],freearr_y[dir]); |
|
|
157 | pl->contr->socket.update_look=1; |
|
|
158 | pl->contr->socket.look_position=0; |
|
|
159 | } |
|
|
160 | } |
141 | } |
161 | } |
142 | |
162 | |
143 | return 1; /* this shouldn't be reached */ |
163 | return 1; /* this shouldn't be reached */ |
144 | } |
164 | } |
145 | |
165 | |
… | |
… | |
395 | /* Wake up sleeping monsters that may be pushed */ |
415 | /* Wake up sleeping monsters that may be pushed */ |
396 | CLEAR_FLAG(who,FLAG_SLEEP); |
416 | CLEAR_FLAG(who,FLAG_SLEEP); |
397 | |
417 | |
398 | /* player change place with his pets or summoned creature */ |
418 | /* player change place with his pets or summoned creature */ |
399 | /* TODO: allow multi arch pushing. Can't be very difficult */ |
419 | /* TODO: allow multi arch pushing. Can't be very difficult */ |
400 | if (who->more == NULL && owner == pusher) { |
420 | if (who->more == NULL |
|
|
421 | #ifdef COZY_SERVER |
|
|
422 | && |
|
|
423 | ( |
|
|
424 | (owner && owner->contr && pusher->contr |
|
|
425 | && same_party (owner->contr->party, pusher->contr->party)) |
|
|
426 | || owner == pusher |
|
|
427 | ) |
|
|
428 | #else |
|
|
429 | && owner == pusher |
|
|
430 | #endif |
|
|
431 | ) { |
401 | int temp; |
432 | int temp; |
402 | mapstruct *m; |
433 | mapstruct *m; |
403 | |
434 | |
404 | remove_ob(who); |
435 | remove_ob(who); |
405 | remove_ob(pusher); |
436 | remove_ob(pusher); |