Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge from origin fork #1

Merged
merged 19 commits into from
Jun 14, 2020
Merged

merge from origin fork #1

merged 19 commits into from
Jun 14, 2020

Conversation

jim-huynh
Copy link
Owner

Summary

Purpose of change

Describe the solution

Describe alternatives you've considered

Testing

Additional context

kevingranade and others added 19 commits June 13, 2020 08:01
Remove dependency on mapgen.h from map.h
Document item longest_side attribute
Removes inclusion of units.h from game_constants.h
* Expanded Digestive System to extract more vitamins

Changed the vitamin extraction bonus to match the kcal extraction bonus supplied by Expanded Digestive System.
* New Hub 01 related sidequest

* Update mission related dialogue/effects
KitchenMaster cooking buddy (afs_kitchen_rig) recipe includes two listings for cable (10 + 5), with no alternative ingredients. Combining to avoid confusion when attempting to craft with less than 15 cable.
[Aftershock] Removing duplicate cable entry from the afs_kitchen_rig recipe
[DinoMod] Create DESIGN.md
Bugfix for cancelling unwielding when wielding an item and has item in hand
@jim-huynh jim-huynh merged commit 7b651f0 into jim-huynh:master Jun 14, 2020
jim-huynh pushed a commit that referenced this pull request Aug 21, 2021
Perform two optimizations on Character::bodytemp
1. Store the items worn on each bodypart, and refer to that instead of
   iterating through all worn items and selecting the ones for the
   relevant body part multiple times.
2. Adjust some functions to run once, and return the data for all body
   parts. This optimization has a fair bit of overlap with #1, but I
   think both have value

There should be no behavioural changes.
jim-huynh pushed a commit that referenced this pull request Oct 20, 2021
jim-huynh pushed a commit that referenced this pull request Jan 20, 2022
jim-huynh pushed a commit that referenced this pull request May 11, 2022
jim-huynh pushed a commit that referenced this pull request Oct 13, 2022
* Update scrap_trader.json

* Post-purchase screen update

* Scrapper sells via shop instead of dialogue

* Specialty metals update

* Tuning

* Fixed pricing

* Scrap merchant gets his own outfit and class

* Carried

* Linting

* Pricing adjustments

* Uyen Tran and Doctor now merchants

* Linting

* Update scrap_trader.json

* Discourage players from buying possessions

* Cash register not for sale

* Linting

* Removes cash register custom price

* No spawning with cash register unless from mapgen

* Mapgen Update #1

* Update fortified_scrap_yard.json

* More defensive tools for scrapper

* Tow Truck Variant, Appliances, Furniture, Remodel

* Coat rack, mechanics skill, tools

* Utility shelf, zones reorganization

* Decrease scrap count

* Lint

* lint

* Coordinates updates, tire change, skills

* Swimmin

* Minor changes

* Wheels
jim-huynh pushed a commit that referenced this pull request Jun 28, 2023
* Modernize survivor boots

* commae

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* recipes #1

* Update feet.json

* Update custom_boots.json

* a fix

* fixes

* thickness

* recipe stuff

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Update feet.json

* Apply suggestions from code review

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* xl and xs recipes

* fixes

* nylon->leather

* nylon->leather

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jim-huynh pushed a commit that referenced this pull request Jun 28, 2023
…n#66347)

* increase penalties to dispersion at low skills.

* make skill effect on base_aim_speed_cap frontloaded

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* make aiming a combo of limb scores

* Low marksman skill makes it harder to reorient your aim

* add a final divisor to aim speed based on skill

* Update src/character.cpp

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* attempt #1 to fix this test

* test fix

* more test fixes

* more fixes

* Update ranged_balance_test.cpp

* Update ranged_balance_test.cpp

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
jim-huynh pushed a commit that referenced this pull request Aug 22, 2023
…63590)

* Prof Biology added

* Update data/mods/Megafauna/monsters/mf_domestic.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* First steps defining weakpoints

* The eyes #1

* Update data/mods/Megafauna/mf_weakpoint_sets.json

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* Basic weakpoints and linting

* fix bad language

* Update data/mods/Megafauna/proficiencies/mf_weakpoints.json

* Update data/mods/Megafauna/proficiencies/mf_weakpoints.json

* Update data/mods/Megafauna/mf_weakpoint_sets.json

---------

Co-authored-by: merrygin <smitzjak@hu-berlin.de>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Maleclypse <54345792+Maleclypse@users.noreply.github.com>
Co-authored-by: David Seguin <davidseguin@live.ca>
jim-huynh pushed a commit that referenced this pull request Jun 28, 2024
Add example, clarify some wording, and link to the name of the test in
the script that enforces it.
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
Prevents segfault when performing `firstaid_activity_actor` but the
bandage tool disappeared. Backtrace of fixed segfault:
```
Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault.
(gdb) bt
 #0  0x0000555555ece5a4 in item::get_usable_item_helper<item> (use_name="heal", self=...) at src/item.cpp:11584
 #1  item::get_usable_item (this=0x0, use_name="heal") at src/item.cpp:11606
 CleverRaven#2  0x000055555599c6bf in firstaid_activity_actor::finish (this=0x55559b583f20, act=..., who=...) at src/activity_actor.cpp:6651
 CleverRaven#3  0x00005555564d8c6b in player_activity::do_turn (this=0x555558108218, you=...) at src/player_activity.cpp:391
 CleverRaven#4  0x0000555555ce3fa6 in do_turn () at src/do_turn.cpp:532
 CleverRaven#5  0x000055555577511a in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```

An example where this happened was when the bandage was inside a
spillable container (clay canning pot), that spilled its contents when
starting the activity. Spiling the clay canning pot invalidates the
`item_location`. Backtrace of when the clay canning pot was spilled:
```
 #0  item_pocket::get_name (this=0x555557fa7540) at src/item_pocket.cpp:2117
 #1  item_pocket::handle_liquid_or_spill (this=this@entry=0x555557fa7540, guy=..., avoid=0x555557fa8060) at src/item_pocket.cpp:806
 CleverRaven#2  0x0000555555a6aa60 in avatar_action::use_item (you=..., loc=..., method="heal") at src/avatar_action.cpp:1212
 CleverRaven#3  0x0000555555a6dda7 in avatar_action::eat_or_use (you=..., loc=...) at src/avatar_action.cpp:988
 CleverRaven#4  0x0000555555e3e1c5 in game::do_regular_action (this=this@entry=0x555557f94a60, act=@0x7fffffffd1b0: ACTION_EAT, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2479
 CleverRaven#5  0x0000555555e41260 in game::handle_action (this=0x555557f94a60) at src/handle_action.cpp:3176
 CleverRaven#6  0x0000555555ce422f in do_turn () at /usr/include/c++/13/bits/unique_ptr.h:199
 CleverRaven#7  0x000055555577511a in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
Prevents segfault that could previously occur if the item being repaired
was invalidated. The target item being repaired could get invalidated
for various reasons, such as a follower moving it via zone sorting, the
item could burn up in a fire, etc.

Previous segfault that this commit attempts to prevent:
```
 #0  0x0000555555ef9057 in item::is_null (this=this@entry=0x0) at src/item.cpp:943
 #1  0x000055555602322c in repair_item_actor::can_repair_target (this=this@entry=0x555560003e80, pl=..., fix=..., print_msg=print_msg@entry=true, check_consumed_available=check_consumed_available@entry=true) at src/iuse_actor.cpp:2920
 CleverRaven#2  0x00005555560243c2 in repair_item_actor::repair (this=this@entry=0x555560003e80, pl=..., tool=..., fix=..., refit_only=refit_only@entry=false) at src/iuse_actor.cpp:3106
 CleverRaven#3  0x00005555559d5b55 in repair_item_finish (act=0x5555580cdf58, you=0x5555580cd890, no_menu=false) at src/activity_handlers.cpp:2477
 CleverRaven#4  0x0000555555a00f52 in std::function<void (player_activity*, Character*)>::operator()(player_activity*, Character*) const (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0x5555580cdf58, __args#1=<optimized out>, __args#1@entry=0x5555580cd890) at /usr/include/c++/13/bits/std_function.h:591
 CleverRaven#5  0x00005555559ff229 in activity_type::call_finish (this=<optimized out>, act=act@entry=0x5555580cdf58, you=you@entry=0x5555580cd890) at src/activity_type.cpp:168
 CleverRaven#6  0x00005555564e368b in player_activity::do_turn (this=0x5555580cdf58, you=...) at src/player_activity.cpp:393
 CleverRaven#7  0x0000555555cec856 in do_turn () at src/do_turn.cpp:532
 CleverRaven#8  0x0000555555776e74 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```

Instead, this commit adds a message shown to the player if the target
item is no longer valid for whatever reason.
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
Prevents division by zero crash when displaying widgets with defined
break levels.

Example of where previous crash from div-by-zero happened:
* Provided save used the `zenfs_thick_sidebar`, which includes widget
  `zenfs_mana_bar_14_no_label` that defines break levels.
* When running the provided save, mana value is usually at `v=201` with
  `min=0` `max=201`.
* Those values are computed by `known_magic::max_mana` where internal
  values are `bionic_penalty=999` `mana_base=1000` `int_bonus=200`.
* But when int falls (because of tiredness), then
  `known_magic::max_mana` will return `0` because `int_bonus=-100`.
* This leads to `_var_max=0` in `widget::value_color` and thus
  `var_range=0` which causes the div by zero.

Backtrace of previous crash beng fixed:
```
Thread 1 "cataclysm-tiles" received signal SIGFPE, Arithmetic exception.
0x0000555556a9c54e in widget::value_color (this=this@entry=0x7fffffffb8d8, value=value@entry=201) at src/widget.cpp:1310
1310            const int value_offset = ( 100 * ( value - _var_min ) ) / var_range;

(gdb) bt
 #0  0x0000555556a9c54e in widget::value_color (this=this@entry=0x7fffffffb8d8, value=value@entry=201) at src/widget.cpp:1310
 #1  0x0000555556aa37dc in widget::color_value_string[abi:cxx11](int, int) (this=this@entry=0x7fffffffb8d8, value=201, width_max=width_max@entry=14) at src/widget.cpp:1262
 CleverRaven#2  0x0000555556aa38ca in widget::show[abi:cxx11](avatar const&, unsigned int) (this=this@entry=0x7fffffffb8d8, ava=..., max_width=max_width@entry=14) at src/widget.cpp:890
 CleverRaven#3  0x0000555556aa497f in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffb8d8, ava=..., max_width=<optimized out>, label_width=label_width@entry=0, skip_pad=false) at src/widget.cpp:1834
 CleverRaven#4  0x0000555556aa42c2 in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffbe88, ava=..., max_width=<optimized out>, label_width=label_width@entry=9, skip_pad=false) at src/widget.cpp:1794
 CleverRaven#5  0x0000555556aa3cfa in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffc438, ava=..., max_width=<optimized out>, label_width=label_width@entry=0, skip_pad=false) at src/widget.cpp:1724
 CleverRaven#6  0x0000555556aa42c2 in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x7fffffffc9e8, ava=..., max_width=<optimized out>, label_width=label_width@entry=0, skip_pad=false) at src/widget.cpp:1794
 CleverRaven#7  0x0000555556aa42c2 in widget::layout[abi:cxx11](avatar const&, unsigned int, int, bool) (this=this@entry=0x555562c47160, ava=..., max_width=<optimized out>, max_width@entry=64, label_width=<optimized out>, skip_pad=skip_pad@entry=false) at src/widget.cpp:1794
 CleverRaven#8  0x0000555556aa5222 in custom_draw_func (args=...) at src/widget.cpp:970
 CleverRaven#9  0x0000555555ec4360 in std::function<int(draw_args const&)>::operator() (this=0x555597eb1780, __args#0=...) at /usr/include/c++/14/bits/std_function.h:591
 CleverRaven#10 game::draw_panels (this=this@entry=0x55555827ef50, force_draw=force_draw@entry=true) at src/game.cpp:4007
 CleverRaven#11 0x0000555555eed1ac in game::draw (this=0x55555827ef50, ui=...) at src/game.cpp:3961
 CleverRaven#12 0x00005555569a962c in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440
 CleverRaven#13 0x00005555569a96e9 in ui_adaptor::redraw () at src/ui_manager.cpp:345
 CleverRaven#14 0x00005555569a9710 in ui_manager::redraw () at src/ui_manager.cpp:506
 CleverRaven#15 0x0000555555dd0850 in do_turn () at src/do_turn.cpp:712
 CleverRaven#16 0x00005555557a138d in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873

(gdb) print var_range
$1 = 0
(gdb) print value
$2 = 201
(gdb) print _var_min
$3 = 0
(gdb) print _var_max
$4 = 0
```
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
Prevents the crash listed below that previously happened when searching
for zones to add, but the search yielded no results:

```
Thread 1 "cataclysm-tiles" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44

(gdb) bt
 #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
 #1  0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
 CleverRaven#2  0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
 CleverRaven#3  0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79
 CleverRaven#4  0x00007ffff7ad501e in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6
 CleverRaven#5  0x0000555555de2639 in std::vector<uilist_entry, std::allocator<uilist_entry> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14/bits/stl_vector.h:1130
 CleverRaven#6  std::vector<uilist_entry, std::allocator<uilist_entry> >::operator[] (this=<optimized out>, __n=<optimized out>) at /usr/include/c++/14/bits/stl_vector.h:1128
 CleverRaven#7  0x000055555699deac in uilist_impl::draw_controls (this=0x555599a181d0) at src/ui.cpp:138
 CleverRaven#8  0x0000555555b7c312 in cataimgui::window::draw (this=0x555599a181d0) at src/cata_imgui.cpp:631
 CleverRaven#9  cataimgui::window::draw (this=0x555599a181d0) at src/cata_imgui.cpp:600
 CleverRaven#10 0x00005555569a2b1c in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440
 CleverRaven#11 0x00005555569a2bd9 in ui_adaptor::redraw () at src/ui_manager.cpp:345
 CleverRaven#12 0x00005555569a2c00 in ui_manager::redraw () at src/ui_manager.cpp:508
 CleverRaven#13 0x000055555699bfa4 in uilist::inputfilter (this=this@entry=0x7fffffffb9c8) at src/ui.cpp:531
 CleverRaven#14 0x000055555699ead4 in uilist::query (this=this@entry=0x7fffffffb9c8, loop=loop@entry=true, timeout=timeout@entry=-1, allow_unfiltered_hotkeys=allow_unfiltered_hotkeys@entry=false) at src/ui.cpp:865
 CleverRaven#15 0x0000555555c610d4 in zone_manager::query_type (this=this@entry=0x555557274060 <zone_manager::get_manager()::manager>, personal=personal@entry=false) at src/clzones.cpp:621
 CleverRaven#16 0x0000555555ef3894 in game::zones_manager (this=this@entry=0x555558291db0) at src/game.cpp:6944
 CleverRaven#17 0x0000555555f5d279 in game::do_regular_action (this=this@entry=0x555558291db0, act=@0x7fffffffcfec: ACTION_ZONES, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2438
 CleverRaven#18 0x0000555555f60769 in game::handle_action (this=0x555558291db0) at src/handle_action.cpp:3172
 CleverRaven#19 0x0000555555dcf14d in do_turn () at src/do_turn.cpp:579
 CleverRaven#20 0x00005555557a1217 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```

gdb shows that `parent.selected` was negative:
```
(gdb) frame 7
138                                           parent.entries[parent.selected].desc.c_str()
(gdb) print parent.selected
$1 = -1
(gdb) print parent.entries.size()
$2 = 63
```
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
Prevents crashes that previously happened from using references to
`explosion_data` that had been invalidated.

The problem before happened when killing "unfolded impossibility" in
LIXA facility with a grenade, since this monster runs an eoc that
switches maps. That led to `explosion_handler::process_explosions` being
called twice recursively. First invocation iterates references, and the
second invocation might append to the vector, and most certaily will
clear the vector, thus invalidating references for the first invocation.

Example crash being fixed by this commit, notice how
`explosion_handler::process_explosions` occurs twice in the callstack:

```
Thread 1 "cataclysm-tiles" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44

(gdb) bt
 #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
 #1  0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
 CleverRaven#2  0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
 CleverRaven#3  0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79
 CleverRaven#4  0x00007ffff7ad501e in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6
 CleverRaven#5  0x000055555688b471 in std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*> >::operator[] (this=<optimized out>, __n=1967424379) at /usr/include/c++/14/bits/stl_vector.h:1128
 CleverRaven#6  std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const*> >::operator[] (this=<optimized out>, __n=1967424379) at /usr/include/c++/14/bits/stl_vector.h:1128
 CleverRaven#7  string_identity_static::get_interned_string[abi:cxx11](int) (id=1967424379) at src/string_id.cpp:51
 CleverRaven#8  0x0000555555fffed7 in string_identity_static::str[abi:cxx11]() const (this=<optimized out>) at src/string_id.h:140
 CleverRaven#9  0x0000555556057423 in string_id<itype>::c_str (this=this@entry=0x5555a126a718) at src/string_id.h:253
 CleverRaven#10 0x00005555560be56a in Item_factory::find_template (this=0x55555751cad0, id=...) at src/item_factory.cpp:2563
 CleverRaven#11 0x0000555555e4b0c5 in explosion_handler::_make_explosion (source=<optimized out>, p=..., ex=...) at /usr/include/c++/14/bits/unique_ptr.h:193
 CleverRaven#12 0x0000555555e4b704 in explosion_handler::process_explosions () at src/explosion.cpp:923
 CleverRaven#13 0x0000555556246e97 in map::actualize (this=this@entry=0x5555a12bf890, grid=...) at src/map.cpp:9168
 CleverRaven#14 0x00005555562472c0 in map::load (this=this@entry=0x5555a12bf890, w=..., update_vehicle=update_vehicle@entry=true, pump_events=pump_events@entry=false) at src/map.cpp:8387
 CleverRaven#15 0x0000555555de2546 in tinymap::load (this=this@entry=0x5555a12bf890, w=..., update_vehicles=update_vehicles@entry=true, pump_events=pump_events@entry=false) at src/map.h:2765
 CleverRaven#16 0x00005555562a7e6f in update_mapgen_function_json::update_map (this=0x55555a8ce8f0, omt_pos=..., args=..., offset=..., miss=miss@entry=0x0, verify=verify@entry=true, mirror_horizontal=false, mirror_vertical=false, rotation=0) at src/mapgen.cpp:8015
 CleverRaven#17 0x00005555562a81e3 in run_mapgen_update_func (update_mapgen_id=..., omt_pos=..., args=..., miss=miss@entry=0x0, cancel_on_collision=cancel_on_collision@entry=true, mirror_horizontal=mirror_horizontal@entry=false, mirror_vertical=false, rotation=0) at src/mapgen.cpp:8117
 CleverRaven#18 0x00005555565a0250 in operator() (__closure=<optimized out>, d=...) at src/npctalk.cpp:3964
 CleverRaven#19 0x000055555659c7a4 in talk_effect_t::apply (this=this@entry=0x55555d5211d8, d=...) at src/npctalk.cpp:6526
 CleverRaven#20 0x0000555555e0c9ba in effect_on_condition::activate (this=0x55555d521160, d=..., require_callstack_check=require_callstack_check@entry=true) at src/effect_on_condition.cpp:329
 CleverRaven#21 0x00005555561f9693 in spell_effect::effect_on_condition (sp=..., caster=..., target=...) at src/magic_spell_effect.cpp:1806
 CleverRaven#22 0x00005555561d101e in spell::cast_all_effects (this=0x7fffffffc788, source=..., target=...) at src/magic.cpp:1907
 CleverRaven#23 0x0000555556463bec in monster::die (this=0x55559c7fc0a0, nkiller=0x0) at src/monster.cpp:2941
 CleverRaven#24 0x0000555555d33386 in Creature::deal_projectile_attack (this=0x55559c7fc0a0, source=0x0, attack=..., print_messages=<optimized out>, wp_attack=...) at src/creature.cpp:1311
 CleverRaven#25 0x0000555556465049 in monster::deal_projectile_attack (this=this@entry=0x55559c7fc0a0, source=source@entry=0x0, attack=..., print_messages=print_messages@entry=false, wp_attack=...) at src/monster.cpp:2212
 CleverRaven#26 0x0000555555e4a9d9 in explosion_handler::shrapnel (range=-1, source=<optimized out>, src=..., power=<optimized out>, casing_mass=<optimized out>, per_fragment_mass=<optimized out>) at src/explosion.cpp:463
 CleverRaven#27 explosion_handler::_make_explosion (source=<optimized out>, p=..., ex=...) at src/explosion.cpp:536
 CleverRaven#28 0x0000555555e4b704 in explosion_handler::process_explosions () at src/explosion.cpp:923
 CleverRaven#29 0x0000555555dcf46f in do_turn () at src/do_turn.cpp:648
 CleverRaven#30 0x00005555557a1227 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```

In the crash above, the `explosion_data` has been invalidated:
```
(gdb) frame 11
193           pointer    _M_ptr() const noexcept { return std::get<0>(_M_t); }

(gdb) print ex
$1 = (const explosion_data &) @0x5555a126a6f8: {power = 1.75295132e+25, distance_factor = 2.76847299e+20, max_noise = 1667855474, fire = 117, shrapnel = {casing_mass = 1936026889, fragment_mass = 6.82915174e+22, recovery = -1584519120, drop = {_version = 13059389229367304, _cid = 2019155690, _id = {
        _id = 1967424379}}}}

(gdb) print ex.shrapnel.drop
$2 = {_version = 13059389229367304, _cid = 2019155690, _id = {_id = 1967424379}}
```
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
…aven#75521)

Prevents referencing `visibility_cache` using out-of-bounds array
indexes such as negative values. Using out-of-bound indexes for this
array previously caused crashes when compiled with
`-D_GLIBCXX_ASSERTIONS`.

The function `pixel_minimap::render_critters` is, for example, called
with `center=(64,59,-5)`, which gives `start=(4,-1)` and then
`p=(4,-1,-5)`, which previously crashed because
`visibility_cache[p.x][p.y]` then gives a negative array index. Such
values were seen when peeking using `X` at a submap boundary.

Gdb backtrace of previous crash being fixed:
```
(gdb) bt
 #0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at ./nptl/pthread_kill.c:44
 #1  0x00007ffff787840f in __pthread_kill_internal (signo=6, threadid=<optimized out>) at ./nptl/pthread_kill.c:78
 CleverRaven#2  0x00007ffff78294f2 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26
 CleverRaven#3  0x00007ffff78124ed in __GI_abort () at ./stdlib/abort.c:79
 CleverRaven#4  0x00007ffff7ad30be in std::__glibcxx_assert_fail(char const*, int, char const*, char const*) () from /lib/x86_64-linux-gnu/libstdc++.so.6
 CleverRaven#5  0x000055555668a04e in std::array<lit_level, 132ul>::operator[] (__n=18446744073709551615, this=0x555599f30348) at /usr/include/c++/13/array:211
 CleverRaven#6  0x000055555668ab7a in std::array<lit_level, 132ul>::operator[] (__n=18446744073709551615, this=0x555599f30348) at /usr/include/c++/13/array:211
 CleverRaven#7  pixel_minimap::render_critters (this=this@entry=0x555558108960, center=...) at src/pixel_minimap.cpp:521
 CleverRaven#8  0x000055555668ada2 in pixel_minimap::render (this=0x555558108960, center=...) at src/pixel_minimap.cpp:447
 CleverRaven#9  0x000055555668bb69 in pixel_minimap::draw (this=<optimized out>, screen_rect=..., center=...) at src/pixel_minimap.cpp:555
 CleverRaven#10 0x0000555555b3fd5c in cata_tiles::draw_minimap (this=this@entry=0x555558093020, dest=..., center=..., width=width@entry=352, height=height@entry=352) at src/cata_tiles.cpp:1919
 CleverRaven#11 0x00005555567f43d3 in cata_cursesport::curses_drawwindow (w=...) at src/sdltiles.cpp:1428
 CleverRaven#12 0x000055555666f5e2 in std::function<void(draw_args const&)>::operator() (__args#0=..., this=<optimized out>) at /usr/include/c++/13/bits/std_function.h:591
 CleverRaven#13 operator() (d=..., __closure=<optimized out>) at src/panels.cpp:54
 CleverRaven#14 std::__invoke_impl<int, window_panel::window_panel(const std::function<void(const draw_args&)>&, const std::string&, const translation&, int, int, bool, const std::function<bool()>&, bool)::<lambda(const draw_args&)>&, const draw_args&> (__f=...) at /usr/include/c++/13/bits/invoke.h:61
 CleverRaven#15 std::__invoke_r<int, window_panel::window_panel(const std::function<void(const draw_args&)>&, const std::string&, const translation&, int, int, bool, const std::function<bool()>&, bool)::<lambda(const draw_args&)>&, const draw_args&> (__fn=...) at /usr/include/c++/13/bits/invoke.h:114
 CleverRaven#16 std::_Function_handler<int(const draw_args&), window_panel::window_panel(const std::function<void(const draw_args&)>&, const std::string&, const translation&, int, int, bool, const std::function<bool()>&, bool)::<lambda(const draw_args&)> >::_M_invoke(const std::_Any_data &, const draw_args &) (__functor=...,     __args#0=...) at /usr/include/c++/13/bits/std_function.h:290
 CleverRaven#17 0x0000555555e7c9ec in std::function<int(draw_args const&)>::operator() (__args#0=..., this=0x55559461d638) at /usr/include/c++/13/bits/std_function.h:591
 CleverRaven#18 game::draw_panels (this=this@entry=0x555558276c40, force_draw=force_draw@entry=true) at src/game.cpp:4006
 CleverRaven#19 0x0000555555e984f8 in game::draw (this=0x555558276c40, ui=...) at src/game.cpp:3960
 CleverRaven#20 0x000055555695df35 in ui_adaptor::redraw_invalidated () at src/ui_manager.cpp:440
 CleverRaven#21 0x000055555695e039 in ui_adaptor::redraw () at src/ui_manager.cpp:345
 CleverRaven#22 0x000055555695e060 in ui_manager::redraw () at src/ui_manager.cpp:506
 CleverRaven#23 0x0000555555ea95cf in game::look_around (this=this@entry=0x555558276c40, show_window=show_window@entry=true, center=..., start_point=..., has_first_point=has_first_point@entry=false, select_zone=false, peeking=true, is_moving_zone=<optimized out>, end_point=..., change_lv=true) at src/game.cpp:7529
 CleverRaven#24 0x0000555555eadd32 in game::look_around (this=this@entry=0x555558276c40, looka_params=...) at src/game.cpp:7697
 CleverRaven#25 0x0000555555eadecb in game::peek (this=this@entry=0x555558276c40, p=...) at src/game.cpp:6071
 CleverRaven#26 0x0000555555ec441a in game::peek (this=this@entry=0x555558276c40) at src/game.cpp:6050
 CleverRaven#27 0x0000555555f124ec in game::do_regular_action (this=this@entry=0x555558276c40, act=@0x7fffffffd104: ACTION_PEEK, player_character=..., mouse_target=std::optional [no contained value]) at src/handle_action.cpp:2432
 CleverRaven#28 0x0000555555f15b09 in game::handle_action (this=0x555558276c40) at src/handle_action.cpp:3174
 CleverRaven#29 0x0000555555d8a108 in do_turn () at /usr/include/c++/13/bits/unique_ptr.h:199
 CleverRaven#30 0x0000555555781b4e in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873

(gdb) frame 7
(gdb) print p
$1 = {static dimension = 3, x = 4, y = -1, z = -5}
(gdb) print center
$2 = (const tripoint &) @0x7fffffffbda8: {static dimension = 3, x = 64, y = 59, z = -5}
```
jim-huynh pushed a commit that referenced this pull request Sep 5, 2024
…75703)

Previous segfault happened when trying to display the list of items that
deconstruction would yield, but this terrain has no `deconstruct` json.

This commit also adds a check with `debugmsg` for future such cases
during the game startup validation.

Previous crash being fixed:
```
Thread 1 "cataclysm-tiles" received signal SIGSEGV, Segmentation fault.
0x0000555555cb9602 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2049
2049                            item_group::spawn_data_from_group( drop_group )->every_item_min_max();
(gdb) bt
 #0  0x0000555555cb9602 in operator() (drop_group=..., __closure=<optimized out>) at src/construction.cpp:2049
 #1  0x0000555555cb9af2 in construct::do_turn_deconstruct (p=..., who=...) at src/construction.cpp:2086
 CleverRaven#2  0x0000555555a32fad in activity_handlers::build_do_turn (act=0x5555583e4338, you=0x5555583e3c70) at src/activity_handlers.cpp:3424
 CleverRaven#3  0x0000555555a6b7de in std::function<void(player_activity*, Character*)>::operator() (this=<optimized out>, __args#0=<optimized out>, __args#0@entry=0x5555583e4338, __args#1=<optimized out>, __args#1@entry=0x5555583e3c70) at /usr/include/c++/14/bits/std_function.h:591
 CleverRaven#4  0x0000555555a69647 in activity_type::call_do_turn (this=<optimized out>, act=act@entry=0x5555583e4338, you=you@entry=0x5555583e3c70) at src/activity_type.cpp:160
 CleverRaven#5  0x00005555566d3a1c in player_activity::do_turn (this=0x5555583e4338, you=...) at src/player_activity.cpp:320
 CleverRaven#6  0x0000555555dcef82 in do_turn () at src/do_turn.cpp:592
 CleverRaven#7  0x00005555557a1217 in main (argc=<optimized out>, argv=<optimized out>) at src/main.cpp:873
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.