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.11 by root, Tue Dec 12 20:53:03 2006 UTC vs.
Revision 1.17 by root, Mon Dec 25 14:43:23 2006 UTC

82 82
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 if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark"))) 88 if ((rune->type == SIGN) && (!strcmp (rune->arch->name, "rune_mark")))
88 {
89 rune->remove ();
90 rune->destroy (0); 89 rune->destroy ();
91 } 90
92 rune = next; 91 rune = next;
93 } 92 }
94} 93}
95 94
96/** 95/**
205 book = book->above; 204 book = book->above;
206 return book; 205 return book;
207} 206}
208 207
209/** 208/**
210 * Returns first item of type WALL. 209 * Returns first item of type BUILDABLE_WALL.
211 */ 210 */
212object * 211object *
213get_wall (maptile *map, int x, int y) 212get_wall (maptile *map, int x, int y)
214{ 213{
215 object *wall; 214 object *wall;
216 215
217 wall = GET_MAP_OB (map, x, y); 216 wall = GET_MAP_OB (map, x, y);
218 while (wall && (WALL != wall->type)) 217 while (wall && (BUILDABLE_WALL != wall->type))
219 wall = wall->above; 218 wall = wall->above;
220 219
221 return wall; 220 return wall;
222} 221}
223 222
233 * Note: x & y must be valid map coordinates. 232 * Note: x & y must be valid map coordinates.
234 */ 233 */
235void 234void
236fix_walls (maptile *map, int x, int y) 235fix_walls (maptile *map, int x, int y)
237{ 236{
238 int connect;
239 object *wall; 237 object *wall;
240 char archetype[MAX_BUF]; 238 char archetype[MAX_BUF];
241 char *underscore; 239 char *underscore;
242 uint32 old_flags[4];
243 struct archetype *new_arch; 240 struct archetype *new_arch;
244 int flag;
245 241
246 242
247 /* First, find the wall on that spot */ 243 /* First, find the wall on that spot */
248 wall = get_wall (map, x, y); 244 wall = get_wall (map, x, y);
249 if (!wall) 245 if (!wall)
263 return; 259 return;
264 260
265 underscore++; 261 underscore++;
266 *underscore = '\0'; 262 *underscore = '\0';
267 263
268 connect = 0; 264 int connect = 0;
269 265
270 if ((x > 0) && get_wall (map, x - 1, y)) 266 if ((x > 0) && get_wall (map, x - 1, y))
271 connect |= 1; 267 connect |= 1;
272 if ((x < MAP_WIDTH (map) - 1) && get_wall (map, x + 1, y)) 268 if ((x < map->width - 1) && get_wall (map, x + 1, y))
273 connect |= 2; 269 connect |= 2;
274 270
275 if ((y > 0) && get_wall (map, x, y - 1)) 271 if ((y > 0) && get_wall (map, x, y - 1))
276 connect |= 4; 272 connect |= 4;
277 273
278 if ((y < MAP_HEIGHT (map) - 1) && get_wall (map, x, y + 1)) 274 if ((y < map->height - 1) && get_wall (map, x, y + 1))
279 connect |= 8; 275 connect |= 8;
280 276
281 switch (connect) 277 switch (connect)
282 { 278 {
283 case 0: 279 case 0:
356 return; 352 return;
357 353
358 /* Now delete current wall, and insert new one 354 /* Now delete current wall, and insert new one
359 * We save flags to avoid any trouble with buildable/non buildable, and so on 355 * We save flags to avoid any trouble with buildable/non buildable, and so on
360 */ 356 */
361 for (flag = 0; flag < 4; flag++) 357 object::flags_t old_flags = wall->flag; // elmex: this is where C++ pays off
362 old_flags[flag] = wall->flags[flag]; 358
363 wall->remove ();
364 wall->destroy (0); 359 wall->destroy ();
365 360
366 wall = arch_to_object (new_arch); 361 wall = arch_to_object (new_arch);
367 wall->type = WALL; 362 wall->type = BUILDABLE_WALL;
368 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y); 363 insert_ob_in_map_at (wall, map, NULL, INS_ABOVE_FLOOR_ONLY, x, y);
369 for (flag = 0; flag < 4; flag++)
370 wall->flags[flag] = old_flags[flag]; 364 wall->flag = old_flags;
371} 365}
372 366
373/** 367/**
374 * \brief Floor building function 368 * \brief Floor building function
375 * 369 *
403 if (tmp) 397 if (tmp)
404 { 398 {
405 while (tmp) 399 while (tmp)
406 { 400 {
407 above = tmp->above; 401 above = tmp->above;
408 if (WALL == tmp->type) 402 if (BUILDABLE_WALL == tmp->type)
409 { 403 {
410 /* There was a wall, remove it & keep its archetype to make new walls */ 404 /* There was a wall, remove it & keep its archetype to make new walls */
411 new_wall = tmp->arch; 405 new_wall = tmp->arch;
412 tmp->remove ();
413 tmp->destroy (0); 406 tmp->destroy ();
414 sprintf (message, "You destroy the wall and redo the floor."); 407 sprintf (message, "You destroy the wall and redo the floor.");
415 } 408 }
416 else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR))) 409 else if ((FLOOR == tmp->type) || (QUERY_FLAG (tmp, FLAG_IS_FLOOR)))
417 { 410 {
418 tmp->remove ();
419 tmp->destroy (0); 411 tmp->destroy ();
420 floor_removed = 1; 412 floor_removed = 1;
421 } 413 }
422 else 414 else
423 { 415 {
424 if (floor_removed) 416 if (floor_removed)
466 /* Insert wall if exists. Note: if it doesn't, the map is weird... */ 458 /* Insert wall if exists. Note: if it doesn't, the map is weird... */
467 if (new_wall) 459 if (new_wall)
468 { 460 {
469 tmp = arch_to_object (new_wall); 461 tmp = arch_to_object (new_wall);
470 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 462 SET_FLAG (tmp, FLAG_IS_BUILDABLE);
471 tmp->type = WALL; 463 tmp->type = BUILDABLE_WALL;
472 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt); 464 insert_ob_in_map_at (tmp, pl->map, 0, 0, xt, yt);
473 } 465 }
474 } 466 }
475 } 467 }
476 468
528 /* Grab existing wall, if any */ 520 /* Grab existing wall, if any */
529 current_wall = NULL; 521 current_wall = NULL;
530 tmp = GET_MAP_OB (pl->map, x, y); 522 tmp = GET_MAP_OB (pl->map, x, y);
531 while (tmp && !current_wall) 523 while (tmp && !current_wall)
532 { 524 {
533 if (WALL == tmp->type) 525 if (BUILDABLE_WALL == tmp->type)
534 current_wall = tmp; 526 current_wall = tmp;
535 527
536 tmp = tmp->above; 528 tmp = tmp->above;
537 } 529 }
538 530
546 LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying); 538 LOG (llevError, "apply_builder_wall: unable to find archetype %s\n", &material->slaying);
547 return; 539 return;
548 } 540 }
549 541
550 tmp = arch_to_object (new_wall); 542 tmp = arch_to_object (new_wall);
551 tmp->type = WALL; 543 tmp->type = BUILDABLE_WALL;
552 SET_FLAG (tmp, FLAG_IS_BUILDABLE); 544 SET_FLAG (tmp, FLAG_IS_BUILDABLE);
553 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y); 545 insert_ob_in_map_at (tmp, pl->map, 0, INS_ABOVE_FLOOR_ONLY, x, y);
554 546
555 /* If existing wall, remove it, no need to fix other walls */ 547 /* If existing wall, remove it, no need to fix other walls */
556 if (current_wall) 548 if (current_wall)
557 { 549 {
558 current_wall->remove ();
559 current_wall->destroy (0); 550 current_wall->destroy ();
560 fix_walls (pl->map, x, y); 551 fix_walls (pl->map, x, y);
561 sprintf (message, "You redecorate the wall to better suit your tastes."); 552 sprintf (message, "You redecorate the wall to better suit your tastes.");
562 } 553 }
563 else 554 else
564 { 555 {
655 con_rune = get_connection_rune (pl, x, y); 646 con_rune = get_connection_rune (pl, x, y);
656 connected = find_or_create_connection_for_map (pl, x, y, con_rune); 647 connected = find_or_create_connection_for_map (pl, x, y, con_rune);
657 if (connected == -1) 648 if (connected == -1)
658 { 649 {
659 /* Player already informed of failure by the previous function */ 650 /* Player already informed of failure by the previous function */
660 tmp->destroy (0); 651 tmp->destroy ();
661 return; 652 return;
662 } 653 }
663 /* Remove marking rune */ 654 /* Remove marking rune */
664 con_rune->remove ();
665 con_rune->destroy (0); 655 con_rune->destroy ();
666 } 656 }
667 657
668 /* For magic mouths/ears, and signs, take the msg from a book of scroll */ 658 /* For magic mouths/ears, and signs, take the msg from a book of scroll */
669 if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR)) 659 if ((tmp->type == SIGN) || (tmp->type == MAGIC_EAR))
670 { 660 {
671 if (adjust_sign_msg (pl, x, y, tmp) == -1) 661 if (adjust_sign_msg (pl, x, y, tmp) == -1)
672 { 662 {
673 tmp->destroy (0); 663 tmp->destroy ();
674 return; 664 return;
675 } 665 }
676 } 666 }
677 667
678 insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y); 668 insert_ob_in_map_at (tmp, pl->map, floor, insert_flag, x, y);
717 } 707 }
718 708
719 /* Now remove object, with special cases (buttons & such) */ 709 /* Now remove object, with special cases (buttons & such) */
720 switch (item->type) 710 switch (item->type)
721 { 711 {
722 case WALL: 712 case BUILDABLE_WALL:
723 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor."); 713 new_draw_info (NDI_UNIQUE, 0, pl, "Can't remove a wall with that, build a floor.");
724 return; 714 return;
725 715
726 case DOOR: 716 case DOOR:
727 case BUTTON: 717 case BUTTON:
738 728
739 /* Fall through */ 729 /* Fall through */
740 730
741 default: 731 default:
742 /* Remove generic item */ 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));
736 return;
737 }
738
743 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item)); 739 new_draw_info_format (NDI_UNIQUE, 0, pl, "You remove the %s", query_name (item));
744 item->remove ();
745 item->destroy (0); 740 item->destroy ();
746 } 741 }
747} 742}
748 743
749/** 744/**
750 * Global building function 745 * Global building function
776 } 771 }
777 772
778 x = pl->x + freearr_x[dir]; 773 x = pl->x + freearr_x[dir];
779 y = pl->y + freearr_y[dir]; 774 y = pl->y + freearr_y[dir];
780 775
781 if ((1 > x) || (1 > y) || ((MAP_WIDTH (pl->map) - 2) < x) || ((MAP_HEIGHT (pl->map) - 2) < y)) 776 if ((1 > x) || (1 > y) || ((pl->map->width - 2) < x) || ((pl->map->height - 2) < y))
782 { 777 {
783 new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge..."); 778 new_draw_info (NDI_UNIQUE, 0, pl, "Can't build on map edge...");
784 return; 779 return;
785 } 780 }
786 781
911 } 906 }
912 907
913 tmp->face = book->face; 908 tmp->face = book->face;
914 tmp->invisible = 0; 909 tmp->invisible = 0;
915 } 910 }
916 book->remove (); 911
917 book->destroy (0); 912 book->destroy ();
918 return 0; 913 return 0;
919} 914}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines