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.8 by root, Thu Sep 14 22:34:04 2006 UTC vs.
Revision 1.13 by root, Thu Jan 4 16:19:32 2007 UTC

59move_ob (object *op, int dir, object *originator) 59move_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");
76 /* If the space the player is trying to is out of the map, 76 /* If the space the player is trying to is out of the map,
77 * bail now - we know it can't work. 77 * bail now - we know it can't work.
78 */ 78 */
79 if (mflags & P_OUT_OF_MAP) 79 if (mflags & P_OUT_OF_MAP)
80 return 0; 80 return 0;
81
82 81
83 /* Is this space blocked? Players with wizpass are immune to 82 /* Is this space blocked? Players with wizpass are immune to
84 * this condition. 83 * this condition.
85 */ 84 */
86 if (blocked_link (op, m, newx, newy) && !QUERY_FLAG (op, FLAG_WIZPASS)) 85 if (blocked_link (op, m, newx, newy) && !QUERY_FLAG (op, FLAG_WIZPASS))
88 87
89 /* 0.94.2 - we need to set the direction for the new animation code. 88 /* 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 89 * it uses it to figure out face to use - I can't see it
91 * breaking anything, but it might. 90 * breaking anything, but it might.
92 */ 91 */
93 if (op->more != NULL && !move_ob (op->more, dir, op->more->head)) 92 if (op->more && !move_ob (op->more, dir, op->more->head))
94 return 0; 93 return 0;
95 94
96 op->direction = dir; 95 op->direction = dir;
97 96
98 if (op->will_apply & 4) 97 if (op->will_apply & 4)
99 check_earthwalls (op, m, newx, newy); 98 check_earthwalls (op, m, newx, newy);
99
100 if (op->will_apply & 8) 100 if (op->will_apply & 8)
101 check_doors (op, m, newx, newy); 101 check_doors (op, m, newx, newy);
102 102
103 /* 0.94.1 - I got a stack trace that showed it crash with remove_ob trying 103 /* 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 104 * to remove a removed object, and this function was the culprit. A possible
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 if (m != op->map && op->contr)
127 {
128 if (INVOKE_MAP (LEAVE, op->map, ARG_PLAYER (op->contr)))
129 return 0;
130
131 op->remove ();
132
133 if (INVOKE_PLAYER (MAP_CHANGE, op->contr, ARG_MAP (m), ARG_INT (newx), ARG_INT (newy)))
134 return 0;
135
136 if (INVOKE_MAP (ENTER, m, ARG_PLAYER (op->contr), ARG_INT (newx), ARG_INT (newy)))
137 return 0;
138 }
139 else
140 op->remove ();
127 141
128 /* we already have newx, newy, and m, so lets use them. 142 /* we already have newx, newy, and m, so lets use them.
129 * In addition, this fixes potential crashes, because multipart object was 143 * In addition, this fixes potential crashes, because multipart object was
130 * on edge of map, +=x, +=y doesn't make correct coordinates. 144 * on edge of map, +=x, +=y doesn't make correct coordinates.
131 */ 145 */
169 if (i == -1) 183 if (i == -1)
170 return 0; /* No free spot */ 184 return 0; /* No free spot */
171 185
172 if (op->head != NULL) 186 if (op->head != NULL)
173 op = op->head; 187 op = op->head;
174 remove_ob (op); 188 op->remove ();
175 for (tmp = op; tmp != NULL; tmp = tmp->more) 189 for (tmp = op; tmp != NULL; tmp = tmp->more)
176 tmp->x = x + freearr_x[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x), 190 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); 191 tmp->y = y + freearr_y[i] + (tmp->arch == NULL ? 0 : tmp->arch->clone.y);
178 192
179 tmp = insert_ob_in_map (op, op->map, originator, 0); 193 tmp = insert_ob_in_map (op, op->map, originator, 0);
199teleport (object *teleporter, uint8 tele_type, object *user) 213teleport (object *teleporter, uint8 tele_type, object *user)
200{ 214{
201 object *altern; 215 object *altern;
202 int i, j, k, nrofalt = 0; 216 int i, j, k, nrofalt = 0;
203 object *other_teleporter, *tmp; 217 object *other_teleporter, *tmp;
204 mapstruct *m; 218 maptile *m;
205 sint16 sx, sy; 219 sint16 sx, sy;
206 220
207 if (user == NULL) 221 if (user == NULL)
208 return 0; 222 return 0;
209 if (user->head != NULL) 223 if (user->head != NULL)
219 if (i == 0 && j == 0) 233 if (i == 0 && j == 0)
220 continue; 234 continue;
221 /* Perhaps this should be extended to support tiled maps */ 235 /* Perhaps this should be extended to support tiled maps */
222 if (OUT_OF_REAL_MAP (teleporter->map, teleporter->x + i, teleporter->y + j)) 236 if (OUT_OF_REAL_MAP (teleporter->map, teleporter->x + i, teleporter->y + j))
223 continue; 237 continue;
224 other_teleporter = get_map_ob (teleporter->map, teleporter->x + i, teleporter->y + j); 238 other_teleporter = GET_MAP_OB (teleporter->map, teleporter->x + i, teleporter->y + j);
225 239
226 while (other_teleporter) 240 while (other_teleporter)
227 { 241 {
228 if (other_teleporter->type == tele_type) 242 if (other_teleporter->type == tele_type)
229 break; 243 break;
272 } 286 }
273 else 287 else
274 return 0; 288 return 0;
275 } 289 }
276 290
277 remove_ob (user); 291 user->remove ();
278 292
279 /* Update location for the object */ 293 /* Update location for the object */
280 for (tmp = user; tmp != NULL; tmp = tmp->more) 294 for (tmp = user; tmp != NULL; tmp = tmp->more)
281 { 295 {
282 tmp->x = other_teleporter->x + freearr_x[k] + (tmp->arch == NULL ? 0 : tmp->arch->clone.x); 296 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. 321 * This is currently only used for the boulder roll code.
308 * Returns 1 if object does not fit, 0 if it does. 322 * Returns 1 if object does not fit, 0 if it does.
309 */ 323 */
310 324
311int 325int
312try_fit (object *op, mapstruct *m, int x, int y) 326try_fit (object *op, maptile *m, int x, int y)
313{ 327{
314 object *tmp, *more; 328 object *tmp, *more;
315 sint16 tx, ty; 329 sint16 tx, ty;
316 int mflags; 330 int mflags;
317 mapstruct *m2; 331 maptile *m2;
318 332
319 if (op->head) 333 if (op->head)
320 op = op->head; 334 op = op->head;
321 335
322 for (more = op; more; more = more->more) 336 for (more = op; more; more = more->more)
327 mflags = get_map_flags (m, &m2, tx, ty, &tx, &ty); 341 mflags = get_map_flags (m, &m2, tx, ty, &tx, &ty);
328 342
329 if (mflags & P_OUT_OF_MAP) 343 if (mflags & P_OUT_OF_MAP)
330 return 1; 344 return 1;
331 345
332 for (tmp = get_map_ob (m2, tx, ty); tmp; tmp = tmp->above) 346 for (tmp = GET_MAP_OB (m2, tx, ty); tmp; tmp = tmp->above)
333 { 347 {
334 if (tmp->head == op || tmp == op) 348 if (tmp->head == op || tmp == op)
335 continue; 349 continue;
336 350
337 if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->type != DOOR)) 351 if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->type != DOOR))
355roll_ob (object *op, int dir, object *pusher) 369roll_ob (object *op, int dir, object *pusher)
356{ 370{
357 object *tmp; 371 object *tmp;
358 sint16 x, y; 372 sint16 x, y;
359 int flags; 373 int flags;
360 mapstruct *m; 374 maptile *m;
361 MoveType move_block; 375 MoveType move_block;
362 376
363 if (op->head) 377 if (op->head)
364 op = op->head; 378 op = op->head;
365 379
378 move_block = GET_MAP_MOVE_BLOCK (m, x, y); 392 move_block = GET_MAP_MOVE_BLOCK (m, x, y);
379 393
380 /* If the target space is not blocked, no need to look at the objects on it */ 394 /* 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) 395 if ((op->move_type & move_block) == op->move_type)
382 { 396 {
383 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 397 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
384 { 398 {
385 if (tmp->head == op) 399 if (tmp->head == op)
386 continue; 400 continue;
387 if (OB_MOVE_BLOCK (op, tmp) && !roll_ob (tmp, dir, pusher)) 401 if (OB_MOVE_BLOCK (op, tmp) && !roll_ob (tmp, dir, pusher))
388 return 0; 402 return 0;
389 } 403 }
390 } 404 }
391 if (try_fit (op, m, x, y)) 405 if (try_fit (op, m, x, y))
392 return 0; 406 return 0;
393 407
394 remove_ob (op); 408 op->remove ();
395 for (tmp = op; tmp != NULL; tmp = tmp->more) 409 for (tmp = op; tmp != NULL; tmp = tmp->more)
396 tmp->x += freearr_x[dir], tmp->y += freearr_y[dir]; 410 tmp->x += freearr_x[dir], tmp->y += freearr_y[dir];
397 insert_ob_in_map (op, op->map, pusher, 0); 411 insert_ob_in_map (op, op->map, pusher, 0);
398 return 1; 412 return 1;
399} 413}
405 int str1, str2; 419 int str1, str2;
406 object *owner; 420 object *owner;
407 421
408 if (who->head != NULL) 422 if (who->head != NULL)
409 who = who->head; 423 who = who->head;
410 owner = get_owner (who); 424 owner = who->owner;
411 425
412 /* Wake up sleeping monsters that may be pushed */ 426 /* Wake up sleeping monsters that may be pushed */
413 CLEAR_FLAG (who, FLAG_SLEEP); 427 CLEAR_FLAG (who, FLAG_SLEEP);
414 428
415 /* player change place with his pets or summoned creature */ 429 /* player change place with his pets or summoned creature */
421 && owner == pusher 435 && owner == pusher
422#endif 436#endif
423 ) 437 )
424 { 438 {
425 int temp; 439 int temp;
426 mapstruct *m; 440 maptile *m;
427 441
428 remove_ob (who); 442 who->remove ();
429 remove_ob (pusher); 443 pusher->remove ();
430 temp = pusher->x; 444 temp = pusher->x;
431 pusher->x = who->x; 445 pusher->x = who->x;
432 who->x = temp; 446 who->x = temp;
433 447
434 temp = pusher->y; 448 temp = pusher->y;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines