@@ -625,34 +625,72 @@ static auto room_flip_horiz(class Room *r) -> class Room *
625625//
626626// Has to be a tile you could walk or swim on
627627//
628- [[nodiscard]] static auto room_tile_is_traversable (class Room *r, int x, int y) -> bool
628+ // Need to include chasms as we use this in pathing entrance to exit and that might involve a jump
629+ //
630+ [[nodiscard]] static auto level_char_is_traversable (char c) -> bool
629631{
630- auto c = r->data [ (y * r->width ) + x ];
631632 switch (c) {
632633 case CHARMAP_BARREL : return true ;
634+ case CHARMAP_BORDER : return false ;
635+ case CHARMAP_BRAZIER : return true ;
633636 case CHARMAP_BRIDGE : return true ;
637+ case CHARMAP_CHASM : return true ;
638+ case CHARMAP_CHASM_50 : return true ;
634639 case CHARMAP_CORRIDOR : return true ;
635640 case CHARMAP_DEEP_WATER : return true ;
641+ case CHARMAP_DIRT : return true ;
636642 case CHARMAP_DOOR_LOCKED : return true ;
643+ case CHARMAP_DOOR_SECRET : return true ;
637644 case CHARMAP_DOOR_UNLOCKED : return true ;
638- case CHARMAP_DOOR_SECRET : return true ; // needed
645+ case CHARMAP_EMPTY : return false ;
639646 case CHARMAP_ENTRANCE : return true ;
640647 case CHARMAP_EXIT : return true ;
648+ case CHARMAP_FIRE : return true ;
641649 case CHARMAP_FLOOR : return true ;
650+ case CHARMAP_FLOOR_50 : return true ;
642651 case CHARMAP_FOLIAGE : return true ;
643- case CHARMAP_REEDS : return true ;
644652 case CHARMAP_GRASS : return true ;
645653 case CHARMAP_JOIN : return true ;
646654 case CHARMAP_KEY : return true ;
655+ case CHARMAP_LAVA : return true ;
647656 case CHARMAP_MOB1 : return true ;
648657 case CHARMAP_MOB2 : return true ;
649658 case CHARMAP_MONST1 : return true ;
650659 case CHARMAP_MONST2 : return true ;
660+ case CHARMAP_PILLAR : return false ;
661+ case CHARMAP_REEDS : return true ;
662+ case CHARMAP_ROCK : return false ;
663+ case CHARMAP_SMOKE : return true ;
664+ case CHARMAP_STEAM : return true ;
665+ case CHARMAP_TELEPORT : return true ;
651666 case CHARMAP_TRAP : return true ;
652667 case CHARMAP_TREASURE : return true ;
668+ case CHARMAP_VAULT : return false ;
669+ case CHARMAP_WALL : return false ;
653670 case CHARMAP_WATER : return true ;
654- default : return false ;
671+ case CHARMAP_WEAPON : return true ;
672+ case CHARMAP_WILDCARD : return false ;
655673 }
674+ return false ;
675+ }
676+
677+ //
678+ // Has to be a tile you could walk or swim on
679+ //
680+ // Need to include chasms as we use this in pathing entrance to exit and that might involve a jump
681+ //
682+ [[nodiscard]] static auto room_tile_is_traversable (class Room *r, int x, int y) -> bool
683+ {
684+ auto c = r->data [ (y * r->width ) + x ];
685+ return level_char_is_traversable (c);
686+ }
687+
688+ //
689+ // Has to be a tile you could walk or swim on
690+ //
691+ [[nodiscard]] static auto level_gen_tile_is_traversable (class LevelGen *lg, int x, int y) -> bool
692+ {
693+ return level_char_is_traversable (lg->data [ x ][ y ].c );
656694}
657695
658696//
@@ -2325,8 +2363,8 @@ static void level_gen_dump(class LevelGen *lg, const char *msg)
23252363
23262364 for (int y = 0 ; y < MAP_HEIGHT ; y++) {
23272365 std::string tmp;
2328- for (auto &x : lg-> data ) {
2329- auto c = x [ y ].c ;
2366+ for (int x = 0 ; x < MAP_WIDTH ; x++ ) {
2367+ char c = lg-> data [ x ] [ y ].c ;
23302368 tmp += c;
23312369 }
23322370 log (" [%s]" , tmp.c_str ());
@@ -2337,7 +2375,7 @@ static void level_gen_dump(class LevelGen *lg, const char *msg)
23372375 //
23382376 // Sometimes useful to see walkable paths
23392377 //
2340- if (compiler_unused) {
2378+ if (lg-> debug ) [[unlikely]] {
23412379 for (int y = 0 ; y < MAP_HEIGHT ; y++) {
23422380 std::string tmp;
23432381 for (int x = 0 ; x < MAP_WIDTH ; x++) {
@@ -3170,38 +3208,6 @@ static auto level_proc_gen_create_rooms(Gamep g, LevelNum level_num) -> class Le
31703208 return nullptr ;
31713209}
31723210
3173- //
3174- // Has to be a tile you could walk or swim on
3175- //
3176- [[nodiscard]] static auto level_gen_tile_is_traversable (class LevelGen *lg, int x, int y) -> bool
3177- {
3178- switch (lg->data [ x ][ y ].c ) {
3179- case CHARMAP_BARREL : return true ;
3180- case CHARMAP_BRIDGE : return true ;
3181- case CHARMAP_CORRIDOR : return true ;
3182- case CHARMAP_DEEP_WATER : return true ;
3183- case CHARMAP_DOOR_LOCKED : return true ;
3184- case CHARMAP_DOOR_UNLOCKED : return true ;
3185- case CHARMAP_DOOR_SECRET : return true ; // needed
3186- case CHARMAP_ENTRANCE : return true ;
3187- case CHARMAP_EXIT : return true ;
3188- case CHARMAP_FLOOR : return true ;
3189- case CHARMAP_FOLIAGE : return true ;
3190- case CHARMAP_REEDS : return true ;
3191- case CHARMAP_GRASS : return true ;
3192- case CHARMAP_JOIN : return true ;
3193- case CHARMAP_KEY : return true ;
3194- case CHARMAP_MOB1 : return true ;
3195- case CHARMAP_MOB2 : return true ;
3196- case CHARMAP_MONST1 : return true ;
3197- case CHARMAP_MONST2 : return true ;
3198- case CHARMAP_TRAP : return true ;
3199- case CHARMAP_TREASURE : return true ;
3200- case CHARMAP_WATER : return true ;
3201- default : return false ;
3202- }
3203- }
3204-
32053211//
32063212// Get rid of tiles that go nowhere
32073213//
@@ -4710,13 +4716,22 @@ static void level_gen_add_missing_teleports(class LevelGen *lg)
47104716 }
47114717 }
47124718
4719+ if (lg->debug ) [[unlikely]] {
4720+ log (" teleport count: %d" , lg->info .teleport_count );
4721+ log (" reachable teleports: %d" , reachable_teleports);
4722+ log (" teleport cands: %d" , (int ) cands.size ());
4723+ }
4724+
47134725 //
47144726 // Place an additional teleport
47154727 //
47164728 if ((lg->info .teleport_count > 0 ) || (reachable_teleports == 0 )) {
47174729 auto tries = MAX_LEVEL_GEN_PLACE_ADDITIONAL_TELEPORT_TRIES ;
47184730 while (tries-- > 0 ) {
47194731 if (level_gen_add_missing_teleport_do (lg, cands)) {
4732+ if (lg->debug ) [[unlikely]] {
4733+ log (" added missing reachable teleport" );
4734+ }
47204735 return ;
47214736 }
47224737 }
@@ -4725,6 +4740,9 @@ static void level_gen_add_missing_teleports(class LevelGen *lg)
47254740 auto tries = MAX_LEVEL_GEN_PLACE_ADDITIONAL_TELEPORT_TRIES ;
47264741 while (tries-- > 0 ) {
47274742 if (level_gen_add_missing_teleport_do (lg, cands)) {
4743+ if (lg->debug ) [[unlikely]] {
4744+ log (" added additional teleport" );
4745+ }
47284746 return ;
47294747 }
47304748 }
0 commit comments