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.29 by pippijn, Wed Jan 3 00:21:36 2007 UTC vs.
Revision 1.36 by root, Mon Mar 12 01:13:10 2007 UTC

1
2/* 1/*
3 CrossFire, A Multiplayer game for X-windows 2 * CrossFire, A Multiplayer game for X-windows
4 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (C) 1992 Frank Tore Johansen
7 7 *
8 This program is free software; you can redistribute it and/or modify 8 * This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version. 11 * (at your option) any later version.
12 12 *
13 This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details. 16 * GNU General Public License for more details.
17 17 *
18 You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software 19 * along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 21 *
22 The authors can be reached via e-mail at <crossfire@schmorp.de> 22 * The authors can be reached via e-mail at <crossfire@schmorp.de>
23*/ 23 */
24 24
25/** 25/**
26 * \file 26 * \file
27 * Basic client output functions. 27 * Basic client output functions.
28 * 28 *
255} 255}
256 256
257void 257void
258draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...) 258draw_ext_info_format (int flags, int pri, const object *pl, uint8 type, uint8 subtype, const char *old_format, char *new_format, ...)
259{ 259{
260
261 char buf[HUGE_BUF]; 260 char buf[HUGE_BUF];
262 261
263 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL)) 262 if (!pl || (pl->type != PLAYER) || (pl->contr == NULL))
264 return; 263 return;
265 264
294 */ 293 */
295 294
296void 295void
297new_info_map_except (int color, maptile * map, object *op, const char *str) 296new_info_map_except (int color, maptile * map, object *op, const char *str)
298{ 297{
299 player *pl;
300
301 for_all_players (pl) 298 for_all_players (pl)
302 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op) 299 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op)
303 {
304 new_draw_info (color, 0, pl->ob, str); 300 new_draw_info (color, 0, pl->ob, str);
305 }
306} 301}
307 302
308/** 303/**
309 * Writes to everyone on the map except op1 and op2 304 * Writes to everyone on the map except op1 and op2
310 */ 305 */
311 306
312void 307void
313new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str) 308new_info_map_except2 (int color, maptile * map, object *op1, object *op2, const char *str)
314{ 309{
315 player *pl;
316
317 for_all_players (pl) 310 for_all_players (pl)
318 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2) 311 if (pl->ob != NULL && pl->ob->map == map && pl->ob != op1 && pl->ob != op2)
319 {
320 new_draw_info (color, 0, pl->ob, str); 312 new_draw_info (color, 0, pl->ob, str);
321 }
322} 313}
323 314
324/** 315/**
325 * Writes to everyone on the specified map 316 * Writes to everyone on the specified map
326 */ 317 */
327 318
328void 319void
329new_info_map (int color, maptile * map, const char *str) 320new_info_map (int color, maptile * map, const char *str)
330{ 321{
331 player *pl;
332
333 for_all_players (pl) 322 for_all_players (pl)
334 if (pl->ob != NULL && pl->ob->map == map) 323 if (pl->ob != NULL && pl->ob->map == map)
335 {
336 new_draw_info (color, 0, pl->ob, str); 324 new_draw_info (color, 0, pl->ob, str);
337 }
338} 325}
339
340 326
341/** 327/**
342 * This does nothing now. However, in theory, we should probably send 328 * This does nothing now. However, in theory, we should probably send
343 * something to the client and let the client figure out how it might want 329 * something to the client and let the client figure out how it might want
344 * to handle this 330 * to handle this
433 sprintf (buf, "Player: %s the %s", (const char *) pl->name, (const char *) pl->contr->title); 419 sprintf (buf, "Player: %s the %s", (const char *) pl->name, (const char *) pl->contr->title);
434 else 420 else
435 sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title); 421 sprintf (buf, "Player: %s %s", (const char *) pl->name, (const char *) pl->contr->own_title);
436} 422}
437 423
424// formerly a macro, used only by magic map, so optimised it out
425static inline faceidx
426GET_MAP_FACE (maptile *m, int x, int y, int layer)
427{
428 if (object *op = GET_MAP_FACE_OBJ (m, x, y, layer))
429 return op->face;
430 else
431 return 0;
432}
438 433
439/** 434/**
440 * Helper for magic map creation. 435 * Helper for magic map creation.
441 * 436 *
442 * Takes a player, the map_mark array and an x and y starting position. 437 * Takes a player, the map_mark array and an x and y starting position.
451magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py) 446magic_mapping_mark_recursive (object *pl, char *map_mark, int px, int py)
452{ 447{
453 int x, y, dx, dy, mflags; 448 int x, y, dx, dy, mflags;
454 sint16 nx, ny; 449 sint16 nx, ny;
455 maptile *mp; 450 maptile *mp;
456 New_Face *f;
457 451
458 for (dx = -1; dx <= 1; dx++) 452 for (dx = -1; dx <= 1; dx++)
459 { 453 {
460 for (dy = -1; dy <= 1; dy++) 454 for (dy = -1; dy <= 1; dy++)
461 { 455 {
473 if (mflags & P_OUT_OF_MAP) 467 if (mflags & P_OUT_OF_MAP)
474 continue; 468 continue;
475 469
476 if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0) 470 if (map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] == 0)
477 { 471 {
478 f = GET_MAP_FACE (mp, nx, ny, 0); 472 int f = GET_MAP_FACE (mp, nx, ny, 0);
479 if (f == blank_face) 473 if (f == blank_face)
474 {
480 f = GET_MAP_FACE (mp, nx, ny, 1); 475 f = GET_MAP_FACE (mp, nx, ny, 1);
481 if (f == blank_face) 476 if (f == blank_face)
482 f = GET_MAP_FACE (mp, nx, ny, 2); 477 f = GET_MAP_FACE (mp, nx, ny, 2);
478 }
479
480 int magicmap = faces [f].magicmap;
483 481
484 /* Should probably have P_NO_MAGIC here also, but then shops don't 482 /* Should probably have P_NO_MAGIC here also, but then shops don't
485 * work. 483 * work.
486 */ 484 */
487 if (mflags & P_BLOCKSVIEW) 485 if (mflags & P_BLOCKSVIEW)
488 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | (f ? f->magicmap : 0); 486 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | magicmap;
489 else 487 else
490 { 488 {
491 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f ? f->magicmap : 0); 489 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | magicmap;
492 magic_mapping_mark_recursive (pl, map_mark, x, y); 490 magic_mapping_mark_recursive (pl, map_mark, x, y);
493 } 491 }
494 } 492 }
495 } 493 }
496 } 494 }
497} 495}
498
499 496
500/** 497/**
501 * Creates magic map for player. 498 * Creates magic map for player.
502 * 499 *
503 * Note: For improved magic mapping display, the space that blocks 500 * Note: For improved magic mapping display, the space that blocks
510 * is for open spaces. map_mark should already have been initialised 507 * is for open spaces. map_mark should already have been initialised
511 * to zero before this is called. 508 * to zero before this is called.
512 * strength is an initial strength*2 rectangular area that we automatically 509 * strength is an initial strength*2 rectangular area that we automatically
513 * see in/penetrate through. 510 * see in/penetrate through.
514 */ 511 */
515
516void 512void
517magic_mapping_mark (object *pl, char *map_mark, int strength) 513magic_mapping_mark (object *pl, char *map_mark, int strength)
518{ 514{
519 int x, y, mflags; 515 int x, y, mflags;
520 sint16 nx, ny; 516 sint16 nx, ny;
521 maptile *mp; 517 maptile *mp;
522 New_Face *f;
523 518
524 for (x = -strength; x < strength; x++) 519 for (x = -strength; x < strength; x++)
525 { 520 {
526 for (y = -strength; y < strength; y++) 521 for (y = -strength; y < strength; y++)
527 { 522 {
528 mp = pl->map; 523 mp = pl->map;
529 nx = pl->x + x; 524 nx = pl->x + x;
530 ny = pl->y + y; 525 ny = pl->y + y;
526
531 mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny); 527 mflags = get_map_flags (pl->map, &mp, nx, ny, &nx, &ny);
532 if (mflags & P_OUT_OF_MAP) 528 if (mflags & P_OUT_OF_MAP)
533 continue; 529 continue;
534 else 530
531 int f = GET_MAP_FACE (mp, nx, ny, 0);
532 if (f == blank_face)
535 { 533 {
536 f = GET_MAP_FACE (mp, nx, ny, 0);
537 if (f == blank_face)
538 f = GET_MAP_FACE (mp, nx, ny, 1); 534 f = GET_MAP_FACE (mp, nx, ny, 1);
539 if (f == blank_face) 535 if (f == blank_face)
540 f = GET_MAP_FACE (mp, nx, ny, 2); 536 f = GET_MAP_FACE (mp, nx, ny, 2);
541 } 537 }
542 538
539 int magicmap = faces [f].magicmap;
540
543 if (mflags & P_BLOCKSVIEW) 541 if (mflags & P_BLOCKSVIEW)
544 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | (f ? f->magicmap : 0); 542 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_WALL | magicmap;
545 else 543 else
546 { 544 {
547 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | (f ? f->magicmap : 0); 545 map_mark[MAGIC_MAP_HALF + x + MAGIC_MAP_SIZE * (MAGIC_MAP_HALF + y)] = FACE_FLOOR | magicmap;
548 magic_mapping_mark_recursive (pl, map_mark, x, y); 546 magic_mapping_mark_recursive (pl, map_mark, x, y);
549 } 547 }
550 } 548 }
551 } 549 }
552} 550}
557 * The following function is a lot messier than it really should be, 555 * The following function is a lot messier than it really should be,
558 * but there is no real easy solution. 556 * but there is no real easy solution.
559 * 557 *
560 * Mark Wedel 558 * Mark Wedel
561 */ 559 */
562
563void 560void
564draw_magic_map (object *pl) 561draw_magic_map (object *pl)
565{ 562{
566 char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1); 563 char *map_mark = (char *)calloc (MAGIC_MAP_SIZE * MAGIC_MAP_SIZE, 1);
567 int xmin, xmax, ymin, ymax; 564 int xmin, xmax, ymin, ymax;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines