CleverRaven / CleverRaven/Cataclysm-DDA

Crash when there are no placable terrains in a city

Open
#62,011 2 comments 0 reactions 0 assignees View on GitHub
(P4 - Low) [C++] <Crash / Freeze> Map / Mapgen
Dominant language
C++
Stars
13.1k
Forks
4.6k
Avg merge
1d 23h
Merged PRs (30d)
186

Description

### Describe the bug

I am fiddling around with modding and overwrote the default region.

```json
"city": {
"shop_radius": 1,
"shop_sigma": 1,
"park_radius": 1,
"park_sigma": 1,
"houses": { "does_not_exist": 1 },
"parks": { "field": 1 },
"shops": { "field": 1 }
}
```

This will cause a crash after several debug errors since the game has nothing to place.

### Steps to reproduce

1. Alter your *default* region settings in a mod, making a subset (I used houses here but I am pretty sure this also applies to parks and shops) empty/not being able to generate due to an error
2. Try to create a character, you will get:
```
DEBUG : Tried to add city building does_not_exist, but it is neither a special nor a terrain type

FUNCTION : void building_bin::finalize()
FILE : src/regional_settings.cpp
LINE : 1168
VERSION : 0.F-11996-gd0fa99b1bbb
```
4. Skip it and wait until the next error:

```
DEBUG : Mapgen does_not_exist is not used by anything!

FUNCTION : void mapgen_factory::check_consistency()
FILE : src/mapgen.cpp
LINE : 446
VERSION : 0.F-11996-gd0fa99b1bbb
```

6. The game crashes after you finish character creation and enter the world (during the "Please wait while we build your world" step).

```
STACK TRACE:

cataclysm-tiles(debug_write_backtrace(std::ostream&)+0x42) [0x55b1b1d0bd29]
cataclysm-tiles(+0xccfb4f) [0x55b1b1ce9b4f]
cataclysm-tiles(+0xccfde0) [0x55b1b1ce9de0]
/usr/lib/libc.so.6(+0x38a00) [0x7f3350062a00]
cataclysm-tiles(building_bin::pick() const+0xe1) [0x55b1b2650bbf]
cataclysm-tiles(overmap::pick_random_building_to_place(int) const+0xa9) [0x55b1b253b97d]
cataclysm-tiles(overmap::place_building(coords::coord_point const&, om_direction::type, city const&)+0xb1) [0x55b1b254623d]
cataclysm-tiles(overmap::build_city_street(overmap_connection const&, coords::coord_point const&, int, om_direction::type, city const&, int)+0x30a) [0x55b1b25465ce]
cataclysm-tiles(overmap::place_cities()+0x519) [0x55b1b2546bff]
cataclysm-tiles(overmap::generate(overmap const*, overmap const*, overmap const*, overmap const*, overmap_special_batch&)+0x596) [0x55b1b254a6ac]
cataclysm-tiles(overmap::open(overmap_special_batch&)+0x20e) [0x55b1b254ab4e]
cataclysm-tiles(overmap::populate(overmap_special_batch&)+0x24) [0x55b1b254ac0a]
cataclysm-tiles(overmap::populate()+0xb4) [0x55b1b254ad64]
cataclysm-tiles(overmapbuffer::get(coords::coord_point const&)+0xa1) [0x55b1b259cfd7]
cataclysm-tiles(start_location::find_player_initial_location(coords::coord_point const&) const+0x82) [0x55b1b2751e7c]
cataclysm-tiles(game::start_game()+0x55e) [0x55b1b1e96610]
cataclysm-tiles(main_menu::new_character_tab()+0xafe) [0x55b1b2199490]
cataclysm-tiles(main_menu::opening_screen()+0x12c8) [0x55b1b219b2fa]
cataclysm-tiles(main+0x1dfc) [0x55b1b17ab6d5]
/usr/lib/libc.so.6(+0x23290) [0x7f335004d290]

Attempting to repeat stack trace using debug symbols…
debug_write_backtrace(std::ostream&)
??:?
init_crash_handlers()
??:?
init_crash_handlers()
??:?
??
??:0
building_bin::pick() const
??:?
overmap::pick_random_building_to_place(int) const
??:?
overmap::place_building(coords::coord_point const&, om_direction::type, city const&)
??:?
overmap::build_city_street(overmap_connection const&, coords::coord_point const&, int, om_direction::type, city const&, int)
??:?
overmap::place_cities()
??:?
overmap::generate(overmap const*, overmap const*, overmap const*, overmap const*, overmap_special_batch&)
??:?
overmap::open(overmap_special_batch&)
??:?
overmap::populate(overmap_special_batch&)
??:?
overmap::populate()
??:?
overmapbuffer::get(coords::coord_point const&)
??:?
start_location::find_player_initial_location(coords::coord_point const&) const
??:?
game::start_game()
??:?
main_menu::new_character_tab()
??:?
main_menu::opening_screen()
??:?
main
??:?
??
??:0
```

### Expected behavior

No crash but a fatal error which drops you back to the main menu. This is a fairly obscure crash which can only be reproduced under very specific conditions with a special mod. Still shouldn't happen though but justifies a low priority.

Also I know my version is fairly old but this should not matter too much. Too lazy to hit compile since the builds on here simply wont cut it for me.

### Screenshots

_No response_

### Versions and configuration

- OS: Linux
- OS Version: LSB Version: n/a; Distributor ID: Arch; Description: Arch Linux; Release: rolling; Codename: n/a;
- Game Version: 0.F-11996-gd0fa99b1bbb [64-bit]
- Graphics Version: Tiles
- Game Language: System language []
- Mods loaded: [
Dark Days Ahead [dda],
Crash the Game [demo]
]

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the crash with the shown default-region mod, then trace building_bin::pick through overmap::pick_random_building_to_place and overmap::place_cities; src/regional_settings.cpp reports the invalid building. The fix is complete when an empty or unusable building set produces a fatal error and returns to the main menu instead of crashing during world generation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.