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.14 by elmex, Fri Dec 22 16:54:56 2006 UTC vs.
Revision 1.28 by root, Sun Jul 1 05:00:19 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
4 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
6 7 *
7 This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software: you can redistribute it and/or modify
8 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
9 the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version. 11 * (at your option) any later version.
11 12 *
12 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,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 16 * GNU General Public License for more details.
16 17 *
17 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
18 along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 20 *
20
21 The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
22*/ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <living.h> 25#include <living.h>
26#include <spells.h> 26#include <spells.h>
27#include <skills.h> 27#include <skills.h>
38 38
39 ob = GET_MAP_OB (map, x, y); 39 ob = GET_MAP_OB (map, x, y);
40 while (ob) 40 while (ob)
41 { 41 {
42 /* if ob is not a marking rune or floor, then check special cases */ 42 /* if ob is not a marking rune or floor, then check special cases */
43 if (strcmp (ob->arch->name, "rune_mark") && ob->type != FLOOR) 43 if (strcmp (ob->arch->archname, "rune_mark") && ob->type != FLOOR)
44 { 44 {
45 switch (tmp->type) 45 switch (tmp->type)
46 { 46 {
47 case SIGN: 47 case SIGN:
48 case MAGIC_EAR: 48 case MAGIC_EAR:
83 rune = GET_MAP_OB (map, x, y); 83 rune = GET_MAP_OB (map, x, y);
84 while (rune) 84 while (rune)
85 { 85 {
86 next = rune->above; 86 next = rune->above;
87 87
88 if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark"))) 88 if ((rune->type == SIGN) && (!strcmp (rune->arch->archname, "rune_mark")))
89 rune->destroy (); 89 rune->destroy ();
90 90
91 rune = next; 91 rune = next;
92 } 92 }
93} 93}
145 } 145 }
146 146
147 /* Now, find force in player's inventory */ 147 /* Now, find force in player's inventory */
148 force = pl->inv; 148 force = pl->inv;
149 while (force 149 while (force
150 && ((force->type != FORCE) || (!force->slaying) || (strcmp (force->slaying, pl->map->path)) || (!force->msg) 150 && ((force->type != FORCE) || !force->slaying || force->slaying != pl->map->path || !force->msg
151 || (strcmp (force->msg, rune->msg)))) 151 || force->msg != rune->msg))
152 force = force->below; 152 force = force->below;
153 153
154 if (!force) 154 if (!force)
155 /* No force, need to create & insert one */ 155 /* No force, need to create & insert one */
156 { 156 {
161 new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups."); 161 new_draw_info (NDI_UNIQUE, 0, pl, "Could not create more groups.");
162 return -1; 162 return -1;
163 } 163 }
164 164
165 force = get_archetype (FORCE_NAME); 165 force = get_archetype (FORCE_NAME);
166 force->speed = 0;
167 update_ob_speed (force);
168 force->slaying = pl->map->path; 166 force->slaying = pl->map->path;
169 force->msg = rune->msg; 167 force->msg = rune->msg;
170 force->path_attuned = connected; 168 force->path_attuned = connected;
169 force->set_speed (0);
171 insert_ob_in_ob (force, pl); 170 insert_ob_in_ob (force, pl);
172 171
173 return connected; 172 return connected;
174 } 173 }
175 174
184get_connection_rune (object *pl, short x, short y) 183get_connection_rune (object *pl, short x, short y)
185{ 184{
186 object *rune; 185 object *rune;
187 186
188 rune = GET_MAP_OB (pl->map, x, y); 187 rune = GET_MAP_OB (pl->map, x, y);
189 while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->name, "rune_mark")))) 188 while (rune && ((rune->type != SIGN) || (strcmp (rune->arch->archname, "rune_mark"))))
190 rune = rune->above; 189 rune = rune->above;
191 return rune; 190 return rune;
192} 191}
193 192
194/** 193/**
245 if (!wall) 244 if (!wall)
246 /* Nothing -> bail out */ 245 /* Nothing -> bail out */
247 return; 246 return;
248 247
249 /* Find base name */ 248 /* Find base name */
250 strcpy (archetype, wall->arch->name); 249 assign (archetype, wall->arch->archname);
251 underscore = strchr (archetype, '_'); 250 underscore = strchr (archetype, '_');
252 251
253 /* search for the first _ before a number */ 252 /* search for the first _ before a number */
254 while (underscore && !isdigit (*(underscore + 1))) 253 while (underscore && !isdigit (*(underscore + 1)))
255 underscore = strchr (underscore + 1, '_'); 254 underscore = strchr (underscore + 1, '_');
263 262
264 int connect = 0; 263 int connect = 0;
265 264
266 if ((x > 0) && get_wall (map, x - 1, y)) 265 if ((x > 0) && get_wall (map, x - 1, y))
267 connect |= 1; 266 connect |= 1;
268 if ((x < MAP_WIDTH (map) - 1) && get_wall (map, x + 1, y)) 267 if ((x < map->width - 1) && get_wall (map, x + 1, y))
269 connect |= 2; 268 connect |= 2;
270 269
271 if ((y > 0) && get_wall (map, x, y - 1)) 270 if ((y > 0) && get_wall (map, x, y - 1))
272 connect |= 4; 271 connect |= 4;
273 272
274 if ((y < MAP_HEIGHT (map) - 1) && get_wall (map, x, y + 1)) 273 if ((y < map->height - 1) && get_wall (map, x, y + 1))
275 connect |= 8; 274 connect |= 8;
276 275
277 switch (connect) 276 switch (connect)
278 { 277 {
279 case 0: 278 case 0:
352 return; 351 return;
353 352
354 /* Now delete current wall, and insert new one 353 /* Now delete current wall, and insert new one
355 * We save flags to avoid any trouble with buildable/non buildable, and so on 354 * We save flags to avoid any trouble with buildable/non buildable, and so on
356 */ 355 */
357 object::flags_t old_flags = wall->flags; // elmex: this is where C++ pays off 356 object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off
358 357
359 wall->destroy (); 358 wall->destroy ();
360 359
361 wall = arch_to_object (new_arch); 360 wall = arch_to_object (new_arch);
362 wall->type = BUILDABLE_WALL; 361 wall->type = BUILDABLE_WALL;
363 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); 362 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y);
364 wall->flags = old_flags; 363 wall->flag = old_flags;
365} 364}
366 365
367/** 366/**
368 * \brief Floor building function 367 * \brief Floor building function
369 * 368 *
639 case PEDESTAL: 638 case PEDESTAL:
640 case CF_HANDLE: 639 case CF_HANDLE:
641 case MAGIC_EAR: 640 case MAGIC_EAR:
642 case SIGN: 641 case SIGN:
643 /* Signs don't need a connection, but but magic mouths do. */ 642 /* Signs don't need a connection, but but magic mouths do. */
644 if (tmp->type == SIGN && strcmp (tmp->arch->name, "magic_mouth")) 643 if (tmp->type == SIGN && strcmp (tmp->arch->archname, "magic_mouth"))
645 break; 644 break;
646 con_rune = get_connection_rune (pl, x, y); 645 con_rune = get_connection_rune (pl, x, y);
647 connected = find_or_create_connection_for_map (pl, x, y, con_rune); 646 connected = find_or_create_connection_for_map (pl, x, y, con_rune);
648 if (connected == -1) 647 if (connected == -1)
649 { 648 {
691 item = GET_MAP_OB (pl->map, x, y); 690 item = GET_MAP_OB (pl->map, x, y);
692 if (!item) 691 if (!item)
693 { 692 {
694 /* Should not happen with previous tests, but we never know */ 693 /* Should not happen with previous tests, but we never know */
695 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square."); 694 new_draw_info (NDI_UNIQUE, 0, pl, "Invalid square.");
696 LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, pl->map->path); 695 LOG (llevError, "apply_builder_remove: (null) square at (%d, %d, %s)\n", x, y, &pl->map->path);
697 return; 696 return;
698 } 697 }
699 698
700 if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR)) 699 if (item->type == FLOOR || QUERY_FLAG (item, FLAG_IS_FLOOR))
701 item = item->above; 700 item = item->above;
702 701
703 if (!item) 702 if (!item)
704 {
705 new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove."); 703 new_draw_info (NDI_UNIQUE, 0, pl, "Nothing to remove.");
706 return; 704 else if (item->type == BUILDABLE_WALL)
707 }
708
709 /* Now remove object, with special cases (buttons & such) */
710 switch (item->type)
711 {
712 case BUILDABLE_WALL:
713 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); 705 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor.");
714 return; 706 else if (!item->flag [FLAG_IS_BUILDABLE])
715
716 case DOOR:
717 case BUTTON:
718 case GATE:
719 case TIMED_GATE:
720 case DETECTOR:
721 case PEDESTAL:
722 case CF_HANDLE:
723 case MAGIC_EAR:
724 case SIGN:
725 /* Special case: must unconnect */
726 if (QUERY_FLAG (item, FLAG_IS_LINKED))
727 remove_button_link (item);
728
729 /* Fall through */
730
731 default:
732 /* Remove generic item */
733 if (!QUERY_FLAG (item, FLAG_IS_BUILDABLE))
734 {
735 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item)); 707 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't remove the %s, it's not buildable!", query_name (item));
736 return; 708 else
737 } 709 {
738
739 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); 710 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item));
740 item->destroy (); 711 item->destroy ();
741 } 712 }
742} 713}
743 714
744/** 715/**
745 * Global building function 716 * Global building function
771 } 742 }
772 743
773 x = pl->x + freearr_x[dir]; 744 x = pl->x + freearr_x[dir];
774 y = pl->y + freearr_y[dir]; 745 y = pl->y + freearr_y[dir];
775 746
776 if ((1 > x) || (1 > y) || ((MAP_WIDTH (pl->map) - 2) < x) || ((MAP_HEIGHT (pl->map) - 2) < y)) 747 if ((1 > x) || (1 > y) || ((pl->map->width - 2) < x) || ((pl->map->height - 2) < y))
777 { 748 {
778 new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge..."); 749 new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge...");
779 return; 750 return;
780 } 751 }
781 752
788 759
789 tmp = GET_MAP_OB (pl->map, x, y); 760 tmp = GET_MAP_OB (pl->map, x, y);
790 if (!tmp) 761 if (!tmp)
791 { 762 {
792 /* Nothing, meaning player is standing next to an undefined square... */ 763 /* Nothing, meaning player is standing next to an undefined square... */
793 LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, pl->map->path); 764 LOG (llevError, "apply_map_builder: undefined square at (%d, %d, %s)\n", x, y, &pl->map->path);
794 new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird."); 765 new_draw_info (NDI_UNIQUE, 0, pl, "You'd better not build here, it looks weird.");
795 return; 766 return;
796 } 767 }
768
797 tmp2 = find_marked_object (pl); 769 tmp2 = find_marked_object (pl);
798 while (tmp) 770 while (tmp)
799 { 771 {
800 LOG (llevDebug, "CHECK %s %d\n", &tmp->name, &tmp->arch->name, 1 * (QUERY_FLAG (tmp, FLAG_IS_BUILDABLE)));
801 if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && ((tmp->type != SIGN) || (strcmp (tmp->arch->name, "rune_mark")))) 772 if (!QUERY_FLAG (tmp, FLAG_IS_BUILDABLE) && ((tmp->type != SIGN) || (strcmp (tmp->arch->archname, "rune_mark"))))
802 { 773 {
803 /* The item building function already has it's own special 774 /* The item building function already has it's own special
804 * checks for this 775 * checks for this
805 */ 776 */
806 if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM)) 777 if ((!tmp2) || (tmp2->subtype != ST_MAT_ITEM))
811 } 782 }
812 tmp = tmp->above; 783 tmp = tmp->above;
813 } 784 }
814 785
815 /* Now we know the square is ok */ 786 /* Now we know the square is ok */
816 builder = pl->contr->ranges[range_builder]; 787 builder = pl->contr->ranged_ob;
817 788
818 if (builder->subtype == ST_BD_REMOVE) 789 if (builder->subtype == ST_BD_REMOVE)
819 /* Remover -> call specific function and bail out */ 790 /* Remover -> call specific function and bail out */
820 { 791 {
821 apply_builder_remove (pl, dir); 792 apply_builder_remove (pl, dir);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines