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

Comparing deliantra/server/socket/info.C (file contents):
Revision 1.53 by root, Thu Oct 15 21:09:32 2009 UTC vs.
Revision 1.54 by root, Wed Nov 4 14:45:30 2009 UTC

283 sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title); 283 sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title);
284} 284}
285 285
286// formerly a macro, used only by magic map, so optimised it out 286// formerly a macro, used only by magic map, so optimised it out
287static inline faceidx 287static inline faceidx
288GET_MAP_FACE (maptile *m, int x, int y, int layer) 288GET_MAP_FACE (mapspace &ms, int layer)
289{ 289{
290 if (object *op = GET_MAP_FACE_OBJ (m, x, y, layer)) 290 if (object *op = ms.faces_obj [layer])
291 return op->face; 291 return op->face;
292 else 292 else
293 return 0; 293 return 0;
294} 294}
295 295
305 * for various code values. 305 * for various code values.
306 */ 306 */
307static void 307static void
308magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) 308magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py)
309{ 309{
310 int x, y, dx, dy, mflags;
311 sint16 nx, ny;
312 maptile *mp;
313
314 for (dx = -1; dx <= 1; dx++) 310 for (int dx = -1; dx <= 1; dx++)
315 { 311 {
316 for (dy = -1; dy <= 1; dy++) 312 for (int dy = -1; dy <= 1; dy++)
317 { 313 {
318 x = px + dx; 314 int x = px + dx;
319 y = py + dy; 315 int y = py + dy;
320 316
321 if (FABS (x) >= MAGIC_MAP_HALF || FABS (y) >= MAGIC_MAP_HALF) 317 if (abs (x) >= MAGIC_MAP_HALF || abs (y) >= MAGIC_MAP_HALF)
322 continue; 318 continue;
323 319
324 mp = pl->map; 320 mapxy pos (pl);
325 nx = pl->x + x; 321 pos.move (x, y);
326 ny = pl->y + y;
327 322
328 mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); 323 if (!pos.normalise ())
329 if (mflags & P_OUT_OF_MAP)
330 continue; 324 continue;
325
326 mapspace &ms = pos.ms ();
331 327
332 if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) 328 if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0)
333 { 329 {
330 int mflags = ms.flags ();
331
334 int f = GET_MAP_FACE (mp, nx, ny, 0); 332 int f = GET_MAP_FACE (ms, 0);
335 if (f == blank_face) 333 if (f == blank_face)
336 { 334 {
337 f = GET_MAP_FACE (mp, nx, ny, 1); 335 f = GET_MAP_FACE (ms, 1);
338 if (f == blank_face) 336 if (f == blank_face)
339 f = GET_MAP_FACE (mp, nx, ny, 2); 337 f = GET_MAP_FACE (ms, 2);
340 } 338 }
341 339
342 int magicmap = faces [f].magicmap; 340 int magicmap = faces [f].magicmap;
343 341
344 /* Should probably have P_NO_MAGIC here also, but then shops don't 342 /* Should probably have P_NO_MAGIC here also, but then shops don't
357} 355}
358 356
359/** 357/**
360 * Creates magic map for player. 358 * Creates magic map for player.
361 * 359 *
362 * Note: For improved magic mapping display, the space that blocks 360 * Note: For improved magic mapping display, the space that blocks
363 * the view is now marked with value 2. Any dependencies of map_mark 361 * the view is now marked with value 2. Any dependencies of map_mark
364 * being nonzero have been changed to check for 1. Also, since 362 * being nonzero have been changed to check for 1. Also, since
365 * map_mark is a char value, putting 2 in should cause no problems. 363 * map_mark is a char value, putting 2 in should cause no problems.
366 * 364 *
367 * This function examines the map the player is on, and determines what 365 * This function examines the map the player is on, and determines what
368 * is visible. 2 is set for walls or objects that blocks view. 1 366 * is visible. 2 is set for walls or objects that blocks view. 1
369 * is for open spaces. map_mark should already have been initialised 367 * is for open spaces. map_mark should already have been initialised
370 * to zero before this is called. 368 * to zero before this is called.
371 * strength is an initial strength*2 rectangular area that we automatically 369 * strength is an initial strength*2 rectangular area that we automatically
372 * see in/penetrate through. 370 * see in/penetrate through.
373 */ 371 */
374void 372void
375magic_mapping_mark (object *pl, char *map_mark, int strength) 373magic_mapping_mark (object *pl, char *map_mark, int strength)
376{ 374{
377 int x, y, mflags;
378 sint16 nx, ny;
379 maptile *mp;
380
381 for (x = -strength; x < strength; x++) 375 for (int x = -strength; x < strength; x++)
382 { 376 {
383 for (y = -strength; y < strength; y++) 377 for (int y = -strength; y < strength; y++)
384 { 378 {
385 mp = pl->map; 379 mapxy pos (pl);
386 nx = pl->x + x; 380 pos.move (x, y);
387 ny = pl->y + y;
388 381
389 mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); 382 if (!pos.normalise ())
390 if (mflags & P_OUT_OF_MAP)
391 continue; 383 continue;
392 384
385 mapspace &ms = pos.ms ();
386
387 int mflags = ms.flags ();
388
393 int f = GET_MAP_FACE (mp, nx, ny, 0); 389 int f = GET_MAP_FACE (ms, 0);
394 if (f == blank_face) 390 if (f == blank_face)
395 { 391 {
396 f = GET_MAP_FACE (mp, nx, ny, 1); 392 f = GET_MAP_FACE (ms, 1);
397 if (f == blank_face) 393 if (f == blank_face)
398 f = GET_MAP_FACE (mp, nx, ny, 2); 394 f = GET_MAP_FACE (ms, 2);
399 } 395 }
400 396
401 int magicmap = faces [f].magicmap; 397 int magicmap = faces [f].magicmap;
402 398
403 if (mflags & P_BLOCKSVIEW) 399 if (mflags & P_BLOCKSVIEW)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines