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

Comparing deliantra/server/server/build_map.C (file contents):
Revision 1.52 by root, Fri Mar 19 22:16:27 2010 UTC vs.
Revision 1.60 by root, Wed Apr 14 21:36:32 2010 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 8 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 9 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 11 * option) any later version.
28#include <skills.h> 28#include <skills.h>
29#include <tod.h> 29#include <tod.h>
30#include <sproto.h> 30#include <sproto.h>
31 31
32// macro for this check, it had been inconsistent in this file. 32// macro for this check, it had been inconsistent in this file.
33#define IS_FLOOR(x) ((x)->type == FLOOR || QUERY_FLAG((x), FLAG_IS_FLOOR)) 33#define IS_FLOOR(x) x->flag [FLAG_IS_FLOOR]
34 34
35/** 35/**
36 * Check if objects on a square interfere with building 36 * Check if objects on a square interfere with building
37 */ 37 */
38static int 38static int
422 LOG (llevError, "apply_builder_floor: unable to find archetype %s.\n", &material->slaying); 422 LOG (llevError, "apply_builder_floor: unable to find archetype %s.\n", &material->slaying);
423 return; 423 return;
424 } 424 }
425 425
426 tmp = new_floor->instance (); 426 tmp = new_floor->instance ();
427 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 427 tmp->set_flag (FLAG_IS_BUILDABLE);
428 SET_FLAG (tmp, FLAG_UNIQUE); 428 tmp->set_flag (FLAG_UNIQUE);
429 SET_FLAG (tmp, FLAG_IS_FLOOR); 429 tmp->set_flag (FLAG_IS_FLOOR);
430 tmp->type = FLOOR; 430 //tmp->type = FLOOR;
431 insert_ob_in_map_at (tmp, pl->map, above_floor, above_floor ? INS_BELOW_ORIGINATOR : INS_ON_TOP, x, y); 431 insert_ob_in_map_at (tmp, pl->map, above_floor, above_floor ? INS_BELOW_ORIGINATOR : INS_ON_TOP, x, y);
432 432
433 /* 433 /*
434 * Next step: make sure there are either walls or floors around the new square 434 * Next step: make sure there are either walls or floors around the new square
435 * Since building, you can have: blocking view / floor / wall / nothing 435 * Since building, you can have: blocking view / floor / wall / nothing
442 if (!tmp) 442 if (!tmp)
443 { 443 {
444 /* Must insert floor & wall */ 444 /* Must insert floor & wall */
445 tmp = new_floor->instance (); 445 tmp = new_floor->instance ();
446 /* Better make the floor unique */ 446 /* Better make the floor unique */
447 SET_FLAG (tmp, FLAG_UNIQUE); 447 tmp->set_flag (FLAG_UNIQUE);
448 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 448 tmp->set_flag (FLAG_IS_BUILDABLE);
449 tmp->type = FLOOR; 449 //tmp->type = FLOOR;
450 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 450 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
451 /* Insert wall if exists. Note: if it doesn't, the map is weird... */ 451 /* Insert wall if exists. Note: if it doesn't, the map is weird... */
452 if (new_wall) 452 if (new_wall)
453 { 453 {
454 tmp = new_wall->instance (); 454 tmp = new_wall->instance ();
455 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 455 tmp->set_flag (FLAG_IS_BUILDABLE);
456 tmp->type = BUILDABLE_WALL; 456 tmp->type = BUILDABLE_WALL;
457 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 457 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
458 } 458 }
459 } 459 }
460 } 460 }
515 return; 515 return;
516 } 516 }
517 517
518 tmp = new_wall->instance (); 518 tmp = new_wall->instance ();
519 tmp->type = BUILDABLE_WALL; 519 tmp->type = BUILDABLE_WALL;
520 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 520 tmp->set_flag (FLAG_IS_BUILDABLE);
521 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); 521 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y);
522 522
523 /* If existing wall, remove it, no need to fix other walls */ 523 /* If existing wall, remove it, no need to fix other walls */
524 if (current_wall) 524 if (current_wall)
525 { 525 {
592 { 592 {
593 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 593 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
594 return; 594 return;
595 } 595 }
596 596
597 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 597 tmp->set_flag (FLAG_IS_BUILDABLE);
598 SET_FLAG (tmp, FLAG_NO_PICK); 598 tmp->set_flag (FLAG_NO_PICK);
599 599
600 /* 600 /*
601 * Str 1 is a flag that the item [pedestal] should go below the floor. 601 * Str 1 is a flag that the item [pedestal] should go below the floor.
602 * Items under the floor on non-unique maps will not be saved, 602 * Items under the floor on non-unique maps will not be saved,
603 * so make the item itself unique in this situation. 603 * so make the item itself unique in this situation.
604 */ 604 */
605 insert_flag = item->stats.Str == 1 ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY; 605 insert_flag = item->stats.Str == 1 ? INS_BELOW_ORIGINATOR : INS_ABOVE_FLOOR_ONLY;
606 if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset) 606 if (insert_flag == INS_BELOW_ORIGINATOR && !pl->map->no_reset)
607 SET_FLAG (tmp, FLAG_UNIQUE); 607 tmp->set_flag (FLAG_UNIQUE);
608 608
609 shstr_tmp connected; 609 shstr_tmp connected;
610 610
611 switch (tmp->type) 611 switch (tmp->type)
612 { 612 {
699 * or remover object. 699 * or remover object.
700 */ 700 */
701void 701void
702apply_map_builder (object *pl, int dir) 702apply_map_builder (object *pl, int dir)
703{ 703{
704 object *builder;
705 object *tmp;
706 object *tmp2;
707 int x, y; 704 int x, y;
708 705
709 if (!pl->type == PLAYER) 706 if (!pl->type == PLAYER)
710 return; 707 return;
711 708
735 * The square must have only buildable items 732 * The square must have only buildable items
736 * Exception: marking runes are all right, 733 * Exception: marking runes are all right,
737 * since they are used for special things like connecting doors / buttons 734 * since they are used for special things like connecting doors / buttons
738 */ 735 */
739 736
740 tmp = GET_MAP_OB (pl->map, x, y); 737 object *tmp = GET_MAP_OB (pl->map, x, y);
741 if (!tmp) 738 if (!tmp)
742 { 739 {
743 /* Nothing, meaning player is standing next to an undefined square... */ 740 /* Nothing, meaning player is standing next to an undefined square... */
744 LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, &pl->map->path); 741 LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, &pl->map->path);
745 new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird."); 742 new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird.");
746 return; 743 return;
747 } 744 }
748 745
749 if (INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder), ARG_MAP (pl->map), ARG_INT (x), ARG_INT (y))) 746 object *builder = pl->contr->ranged_ob;
750 return;
751 747
752 tmp2 = find_marked_object (pl); 748 object *tmp2 = pl->mark ();
749
753 while (tmp) 750 while (tmp)
754 { 751 {
755 if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark)) 752 if (!tmp->flag [FLAG_IS_BUILDABLE] && (tmp->type != SIGN || tmp->arch->archname != shstr_rune_mark))
756 { 753 {
757 /* The item building function already has it's own special 754 /* The item building function already has it's own special
758 * checks for this 755 * checks for this
759 */ 756 */
760 if (!tmp2 || tmp2->subtype != ST_MAT_ITEM) 757 if (!tmp2 || tmp2->subtype != ST_MAT_ITEM)
761 { 758 {
759 if (!INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder), ARG_MAP (pl->map), ARG_INT (x), ARG_INT (y), ARG_INT (0)))
762 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here."); 760 new_draw_info (NDI_UNIQUE, 0, pl, "You can't build here.");
761
763 return; 762 return;
764 } 763 }
765 } 764 }
766 765
767 tmp = tmp->above; 766 tmp = tmp->above;
768 } 767 }
769 768
770 /* Now we know the square is ok */ 769 /* Now we know the square is ok */
771 builder = pl->contr->ranged_ob; 770 if (INVOKE_PLAYER (BUILD, pl->contr, ARG_OBJECT (builder), ARG_MAP (pl->map), ARG_INT (x), ARG_INT (y), ARG_INT (1)))
771 return;
772 772
773 if (builder->subtype == ST_BD_REMOVE) 773 if (builder->subtype == ST_BD_REMOVE)
774 /* Remover -> call specific function and bail out */ 774 /* Remover -> call specific function and bail out */
775 { 775 {
776 apply_builder_remove (pl, dir); 776 apply_builder_remove (pl, dir);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines