ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/move.C
(Generate patch)

Comparing deliantra/server/server/move.C (file contents):
Revision 1.7 by root, Sun Sep 10 15:59:57 2006 UTC vs.
Revision 1.11 by root, Wed Dec 13 03:28:42 2006 UTC

1
2/*
3 * static char *rcsid_move_c =
4 * "$Id: move.C,v 1.7 2006/09/10 15:59:57 root Exp $";
5 */
6
7/* 1/*
8 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
9 3
10 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
11 Copyright (C) 1992 Frank Tore Johansen 5 Copyright (C) 1992 Frank Tore Johansen
22 16
23 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
25 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 20
27 The author can be reached via e-mail to crossfire-devel@real-time.com 21 The author can be reached via e-mail to <crossfire@schmorp.de>
28*/ 22*/
29 23
30#include <global.h> 24#include <global.h>
31#ifndef __CEXTRACT__ 25#ifndef __CEXTRACT__
32# include <sproto.h> 26# include <sproto.h>
65move_ob (object *op, int dir, object *originator) 59move_ob (object *op, int dir, object *originator)
66{ 60{
67 sint16 newx = op->x + freearr_x[dir]; 61 sint16 newx = op->x + freearr_x[dir];
68 sint16 newy = op->y + freearr_y[dir]; 62 sint16 newy = op->y + freearr_y[dir];
69 object *tmp; 63 object *tmp;
70 mapstruct *m; 64 maptile *m;
71 int mflags; 65 int mflags;
72 66
73 if (op == NULL) 67 if (op == NULL)
74 { 68 {
75 LOG (llevError, "Trying to move NULL.\n"); 69 LOG (llevError, "Trying to move NULL.\n");
127 * ok - the caller will deal with actual object removal/insertion 121 * ok - the caller will deal with actual object removal/insertion
128 */ 122 */
129 if (op->head) 123 if (op->head)
130 return 1; 124 return 1;
131 125
132 remove_ob (op); 126 op->remove ();
133 127
134 /* we already have newx, newy, and m, so lets use them. 128 /* we already have newx, newy, and m, so lets use them.
135 * In addition, this fixes potential crashes, because multipart object was 129 * In addition, this fixes potential crashes, because multipart object was
136 * on edge of map, +=x, +=y doesn't make correct coordinates. 130 * on edge of map, +=x, +=y doesn't make correct coordinates.
137 */ 131 */
175 if (i == -1) 169 if (i == -1)
176 return 0; /* No free spot */ 170 return 0; /* No free spot */
177 171
178 if (op->head != NULL) 172 if (op->head != NULL)
179 op = op->head; 173 op = op->head;
180 remove_ob (op); 174 op->remove ();
181 for (tmp = op; tmp != NULL; tmp = tmp->more) 175 for (tmp = op; tmp != NULL; tmp = tmp->more)
182 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),
183 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);
184 178
185 tmp = insert_ob_in_map (op, op->map, originator, 0); 179 tmp = insert_ob_in_map (op, op->map, originator, 0);
205teleport (object *teleporter, uint8 tele_type, object *user) 199teleport (object *teleporter, uint8 tele_type, object *user)
206{ 200{
207 object *altern; 201 object *altern;
208 int i, j, k, nrofalt = 0; 202 int i, j, k, nrofalt = 0;
209 object *other_teleporter, *tmp; 203 object *other_teleporter, *tmp;
210 mapstruct *m; 204 maptile *m;
211 sint16 sx, sy; 205 sint16 sx, sy;
212 206
213 if (user == NULL) 207 if (user == NULL)
214 return 0; 208 return 0;
215 if (user->head != NULL) 209 if (user->head != NULL)
278 } 272 }
279 else 273 else
280 return 0; 274 return 0;
281 } 275 }
282 276
283 remove_ob (user); 277 user->remove ();
284 278
285 /* Update location for the object */ 279 /* Update location for the object */
286 for (tmp = user; tmp != NULL; tmp = tmp->more) 280 for (tmp = user; tmp != NULL; tmp = tmp->more)
287 { 281 {
288 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);
313 * This is currently only used for the boulder roll code. 307 * This is currently only used for the boulder roll code.
314 * Returns 1 if object does not fit, 0 if it does. 308 * Returns 1 if object does not fit, 0 if it does.
315 */ 309 */
316 310
317int 311int
318try_fit (object *op, mapstruct *m, int x, int y) 312try_fit (object *op, maptile *m, int x, int y)
319{ 313{
320 object *tmp, *more; 314 object *tmp, *more;
321 sint16 tx, ty; 315 sint16 tx, ty;
322 int mflags; 316 int mflags;
323 mapstruct *m2; 317 maptile *m2;
324 318
325 if (op->head) 319 if (op->head)
326 op = op->head; 320 op = op->head;
327 321
328 for (more = op; more; more = more->more) 322 for (more = op; more; more = more->more)
361roll_ob (object *op, int dir, object *pusher) 355roll_ob (object *op, int dir, object *pusher)
362{ 356{
363 object *tmp; 357 object *tmp;
364 sint16 x, y; 358 sint16 x, y;
365 int flags; 359 int flags;
366 mapstruct *m; 360 maptile *m;
367 MoveType move_block; 361 MoveType move_block;
368 362
369 if (op->head) 363 if (op->head)
370 op = op->head; 364 op = op->head;
371 365
395 } 389 }
396 } 390 }
397 if (try_fit (op, m, x, y)) 391 if (try_fit (op, m, x, y))
398 return 0; 392 return 0;
399 393
400 remove_ob (op); 394 op->remove ();
401 for (tmp = op; tmp != NULL; tmp = tmp->more) 395 for (tmp = op; tmp != NULL; tmp = tmp->more)
402 tmp->x += freearr_x[dir], tmp->y += freearr_y[dir]; 396 tmp->x += freearr_x[dir], tmp->y += freearr_y[dir];
403 insert_ob_in_map (op, op->map, pusher, 0); 397 insert_ob_in_map (op, op->map, pusher, 0);
404 return 1; 398 return 1;
405} 399}
411 int str1, str2; 405 int str1, str2;
412 object *owner; 406 object *owner;
413 407
414 if (who->head != NULL) 408 if (who->head != NULL)
415 who = who->head; 409 who = who->head;
416 owner = get_owner (who); 410 owner = who->owner;
417 411
418 /* Wake up sleeping monsters that may be pushed */ 412 /* Wake up sleeping monsters that may be pushed */
419 CLEAR_FLAG (who, FLAG_SLEEP); 413 CLEAR_FLAG (who, FLAG_SLEEP);
420 414
421 /* player change place with his pets or summoned creature */ 415 /* player change place with his pets or summoned creature */
427 && owner == pusher 421 && owner == pusher
428#endif 422#endif
429 ) 423 )
430 { 424 {
431 int temp; 425 int temp;
432 mapstruct *m; 426 maptile *m;
433 427
434 remove_ob (who); 428 who->remove ();
435 remove_ob (pusher); 429 pusher->remove ();
436 temp = pusher->x; 430 temp = pusher->x;
437 pusher->x = who->x; 431 pusher->x = who->x;
438 who->x = temp; 432 who->x = temp;
439 433
440 temp = pusher->y; 434 temp = pusher->y;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines