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

Comparing deliantra/server/random_maps/treasure.C (file contents):
Revision 1.65 by root, Sun Jan 29 02:47:05 2017 UTC vs.
Revision 1.66 by root, Sat Sep 16 22:17:42 2017 UTC

114 } 114 }
115 115
116 // can freeindex ever be < 0? 116 // can freeindex ever be < 0?
117 if (freeindex >= 0) 117 if (freeindex >= 0)
118 { 118 {
119 kx += freearr_x [freeindex]; 119 kx += DIRX (freeindex);
120 ky += freearr_y [freeindex]; 120 ky += DIRY (freeindex);
121 } 121 }
122 } 122 }
123 } 123 }
124 else 124 else
125 { /* NO_PASS_DOORS --we have to work harder. */ 125 { /* NO_PASS_DOORS --we have to work harder. */
341 { 341 {
342 the_chest->destroy (); 342 the_chest->destroy ();
343 return NULL; 343 return NULL;
344 } 344 }
345 345
346 int xl = x + freearr_x[i]; 346 int xl = x + DIRX (i);
347 int yl = y + freearr_y[i]; 347 int yl = y + DIRY (i);
348 348
349 /* if the placement is blocked, return a fail. */ 349 /* if the placement is blocked, return a fail. */
350 if (wall_blocked (map, xl, yl)) 350 if (wall_blocked (map, xl, yl))
351 return 0; 351 return 0;
352 352
425 425
426 for (i = 0; i < SIZEOFFREE; i++) 426 for (i = 0; i < SIZEOFFREE; i++)
427 { 427 {
428 int lx, ly; 428 int lx, ly;
429 429
430 lx = x + freearr_x[i]; 430 lx = x + DIRX (i);
431 ly = y + freearr_y[i]; 431 ly = y + DIRY (i);
432 /* boundscheck */ 432 /* boundscheck */
433 if (lx >= 0 && ly >= 0 && lx < map->width && ly < map->height) 433 if (lx >= 0 && ly >= 0 && lx < map->width && ly < map->height)
434 /* don't bother searching this square unless the map says life exists. */ 434 /* don't bother searching this square unless the map says life exists. */
435 if (GET_MAP_FLAGS (map, lx, ly) & P_IS_ALIVE) 435 if (GET_MAP_FLAGS (map, lx, ly) & P_IS_ALIVE)
436 { 436 {
486 } 486 }
487 487
488 /* now search all the 8 squares around recursively for a monster,in random order */ 488 /* now search all the 8 squares around recursively for a monster,in random order */
489 for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) 489 for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++)
490 { 490 {
491 theMonsterToFind = find_monster_in_room_recursive (maze, map, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1]); 491 theMonsterToFind = find_monster_in_room_recursive (maze, map, x + DIRX (i % 8 + 1), y + DIRY (i % 8 + 1));
492 if (theMonsterToFind) 492 if (theMonsterToFind)
493 return theMonsterToFind; 493 return theMonsterToFind;
494 } 494 }
495 495
496 return theMonsterToFind; 496 return theMonsterToFind;
534 maze[x][y] = 1; 534 maze[x][y] = 1;
535 spots.push (point (x, y)); 535 spots.push (point (x, y));
536 536
537 /* now search all the 8 squares around recursively for free spots,in random order */ 537 /* now search all the 8 squares around recursively for free spots,in random order */
538 for (int i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) 538 for (int i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++)
539 find_spot_in_room_recursive (maze, spots, x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1]); 539 find_spot_in_room_recursive (maze, spots, x + DIRX (i % 8 + 1), y + DIRY (i % 8 + 1));
540 540
541} 541}
542 542
543/* find a random non-blocked spot in this room to drop a key. */ 543/* find a random non-blocked spot in this room to drop a key. */
544static void 544static void
579 579
580 for (i = 0; i <= SIZEOFFREE1; i++) 580 for (i = 0; i <= SIZEOFFREE1; i++)
581 { 581 {
582 int lx, ly, sindex; 582 int lx, ly, sindex;
583 583
584 lx = x + freearr_x[i]; 584 lx = x + DIRX (i);
585 ly = y + freearr_y[i]; 585 ly = y + DIRY (i);
586 sindex = surround_flag3 (map, lx, ly); 586 sindex = surround_flag3 (map, lx, ly);
587 /* if it's blocked on 3 sides, it's enclosed */ 587 /* if it's blocked on 3 sides, it's enclosed */
588 if (sindex == 7 || sindex == 11 || sindex == 13 || sindex == 14) 588 if (sindex == 7 || sindex == 11 || sindex == 13 || sindex == 14)
589 { 589 {
590 *cx = lx; 590 *cx = lx;
597 spots--try to find someplace which is 2x enclosed. */ 597 spots--try to find someplace which is 2x enclosed. */
598 for (i = 0; i <= SIZEOFFREE1; i++) 598 for (i = 0; i <= SIZEOFFREE1; i++)
599 { 599 {
600 int lx, ly, sindex; 600 int lx, ly, sindex;
601 601
602 lx = x + freearr_x[i]; 602 lx = x + DIRX (i);
603 ly = y + freearr_y[i]; 603 ly = y + DIRY (i);
604 sindex = surround_flag3 (map, lx, ly); 604 sindex = surround_flag3 (map, lx, ly);
605 /* if it's blocked on 3 sides, it's enclosed */ 605 /* if it's blocked on 3 sides, it's enclosed */
606 if (sindex == 3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex == 10 || sindex == 12) 606 if (sindex == 3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex == 10 || sindex == 12)
607 { 607 {
608 *cx = lx; 608 *cx = lx;
614 /* settle for one surround point */ 614 /* settle for one surround point */
615 for (i = 0; i <= SIZEOFFREE1; i++) 615 for (i = 0; i <= SIZEOFFREE1; i++)
616 { 616 {
617 int lx, ly, sindex; 617 int lx, ly, sindex;
618 618
619 lx = x + freearr_x[i]; 619 lx = x + DIRX (i);
620 ly = y + freearr_y[i]; 620 ly = y + DIRY (i);
621 sindex = surround_flag3 (map, lx, ly); 621 sindex = surround_flag3 (map, lx, ly);
622 /* if it's blocked on 3 sides, it's enclosed */ 622 /* if it's blocked on 3 sides, it's enclosed */
623 if (sindex) 623 if (sindex)
624 { 624 {
625 *cx = lx; 625 *cx = lx;
630 /* give up and return the closest free spot. */ 630 /* give up and return the closest free spot. */
631 i = rmg_find_free_spot (archetype::find (shstr_chest), map, x, y, 1, SIZEOFFREE1 + 1); 631 i = rmg_find_free_spot (archetype::find (shstr_chest), map, x, y, 1, SIZEOFFREE1 + 1);
632 632
633 if (i != -1) 633 if (i != -1)
634 { 634 {
635 *cx = x + freearr_x[i]; 635 *cx = x + DIRX (i);
636 *cy = y + freearr_y[i]; 636 *cy = y + DIRY (i);
637 } 637 }
638 else 638 else
639 { 639 {
640 /* indicate failure */ 640 /* indicate failure */
641 *cx = -1; 641 *cx = -1;
682 } 682 }
683 683
684 /* place doors in all the 8 adjacent unblocked squares. */ 684 /* place doors in all the 8 adjacent unblocked squares. */
685 for (i = 1; i < 9; i++) 685 for (i = 1; i < 9; i++)
686 { 686 {
687 int x1 = x + freearr_x[i], y1 = y + freearr_y[i]; 687 int x1 = x + DIRX (i), y1 = y + DIRY (i);
688 688
689 if (!wall_blocked (map, x1, y1) && maze[x1][y1] == '>') 689 if (!wall_blocked (map, x1, y1) && maze[x1][y1] == '>')
690 { /* place a door */ 690 { /* place a door */
691 remove_monsters (x1, y1, map); 691 remove_monsters (x1, y1, map);
692 692
693 object *new_door = archetype::get (freearr_x[i] == 0 ? doors[1] : doors[0]); 693 object *new_door = archetype::get (DIRX (i) == 0 ? doors[1] : doors[0]);
694 map->insert (new_door, x1, y1); 694 map->insert (new_door, x1, y1);
695 doorlist[ndoors_made] = new_door; 695 doorlist[ndoors_made] = new_door;
696 ndoors_made++; 696 ndoors_made++;
697 } 697 }
698 } 698 }
749 maze[x][y] = 1; 749 maze[x][y] = 1;
750 750
751 /* now search all the 8 squares around recursively for free spots,in random order */ 751 /* now search all the 8 squares around recursively for free spots,in random order */
752 for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++) 752 for (i = rmg_rndm (8), j = 0; j < 8 && !theMonsterToFind; i++, j++)
753 find_doors_in_room_recursive (maze, map, 753 find_doors_in_room_recursive (maze, map,
754 x + freearr_x[i % 8 + 1], y + freearr_y[i % 8 + 1], 754 x + DIRX (i % 8 + 1), y + DIRY (i % 8 + 1),
755 doorlist, ndoors); 755 doorlist, ndoors);
756 } 756 }
757} 757}
758 758
759/* find a random non-blocked spot in this room to drop a key. */ 759/* find a random non-blocked spot in this room to drop a key. */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines