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

Comparing deliantra/server/server/attack.C (file contents):
Revision 1.40 by root, Sun Jan 14 22:06:05 2007 UTC vs.
Revision 1.41 by root, Mon Jan 15 00:40:49 2007 UTC

305 305
306 map = op->map; 306 map = op->map;
307 x = op->x + freearr_x[dir]; 307 x = op->x + freearr_x[dir];
308 y = op->y + freearr_y[dir]; 308 y = op->y + freearr_y[dir];
309 309
310 int mflags = get_map_flags (map, &map, x, y, &x, &y); 310 if (!xy_normalise (map, x, y))
311 return 0;
311 312
312 // elmex: a safe map tile can't be hit! 313 // elmex: a safe map tile can't be hit!
313 // this should prevent most harmful effects on items and players there. 314 // this should prevent most harmful effects on items and players there.
314 if (mflags & (P_OUT_OF_MAP | P_SAFE)) 315 mapspace &ms = map->at (x, y);
316
317 if (ms.flags () & P_SAFE)
315 return 0; 318 return 0;
316 319
317 /* peterm: a few special cases for special attacktypes --counterspell 320 /* peterm: a few special cases for special attacktypes --counterspell
318 * must be out here because it strikes things which are not alive 321 * must be out here because it strikes things which are not alive
319 */ 322 */
320 323 if (type & (AT_COUNTERSPELL | AT_CHAOS))
324 {
321 if (type & AT_COUNTERSPELL) 325 if (type & AT_COUNTERSPELL)
322 { 326 {
323 counterspell (op, dir); /* see spell_effect.c */ 327 counterspell (op, dir); /* see spell_effect.c */
324 328
325 /* If the only attacktype is counterspell or magic, don't need 329 /* If the only attacktype is counterspell or magic, don't need
326 * to do any further processing. 330 * to do any further processing.
327 */ 331 */
328 if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC))) 332 if (!(type & ~(AT_COUNTERSPELL | AT_MAGIC)))
329 return 0; 333 return 0;
330 334
331 type &= ~AT_COUNTERSPELL; 335 type &= ~AT_COUNTERSPELL;
332 } 336 }
333 337
334 if (type & AT_CHAOS) 338 if (type & AT_CHAOS)
335 { 339 {
336 shuffle_attack (op, 1); /*1 flag tells it to change the face */ 340 shuffle_attack (op, 1); /* flag tells it to change the face */
337 update_object (op, UP_OBJ_FACE); 341 update_object (op, UP_OBJ_FACE);
338 type &= ~AT_CHAOS; 342 type &= ~AT_CHAOS;
343 }
339 } 344 }
340 345
341 /* There may still be objects that were above 'next', but there is no 346 /* There may still be objects that were above 'next', but there is no
342 * simple way to find out short of copying all object references and 347 * simple way to find out short of copying all object references and
343 * tags into a temporary array before we start processing the first 348 * tags into a temporary array before we start processing the first
344 * object. That's why we just abort on destroy. 349 * object. That's why we just abort on destroy.
345 * 350 *
346 * This happens whenever attack spells (like fire) hit a pile 351 * This happens whenever attack spells (like fire) hit a pile
347 * of objects. This is not a bug - nor an error. 352 * of objects. This is not a bug - nor an error.
348 */ 353 */
349 for (object *next = map->at (x, y).bot; next && !next->destroyed (); ) 354 for (object *next = ms.bot; next && !next->destroyed (); )
350 { 355 {
351 object *tmp = next; 356 object *tmp = next;
352 next = tmp->above; 357 next = tmp->above;
353 358
354 /* Something could have happened to 'tmp' while 'tmp->below' was processed. 359 /* Something could have happened to 'tmp' while 'tmp->below' was processed.
360 365
361 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 366 if (QUERY_FLAG (tmp, FLAG_ALIVE))
362 { 367 {
363 hit_player (tmp, op->stats.dam, op, type, full_hit); 368 hit_player (tmp, op->stats.dam, op, type, full_hit);
364 retflag |= 1; 369 retflag |= 1;
370
365 if (op->destroyed ()) 371 if (op->destroyed ())
366 break; 372 break;
367 } 373 }
368 /* Here we are potentially destroying an object. If the object has 374 /* Here we are potentially destroying an object. If the object has
369 * NO_PASS set, it is also immune - you can't destroy walls. Note 375 * NO_PASS set, it is also immune - you can't destroy walls. Note

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines