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

Crash to desktop while trying to drive the vehicle #56806

Closed
ektoplazm opened this issue Apr 14, 2022 · 1 comment · Fixed by #60963
Closed

Crash to desktop while trying to drive the vehicle #56806

ektoplazm opened this issue Apr 14, 2022 · 1 comment · Fixed by #60963
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Crash / Freeze> Fatal bug that results in hangs or crashes. (S2 - Confirmed) Bug that's been confirmed to exist Vehicles Vehicles, parts, mechanics & interactions

Comments

@ektoplazm
Copy link
Contributor

Describe the bug

Game crashes to desktop when trying to back up from the swamp while driving a specific vehicle.

Does not happen with other vehicles, on other saves etc. Tried using remote control and autopilot to move the vehicle -- also leads to CTD.

Steps to reproduce

  1. Open the attached save file
  2. Take control of the modified RV
  3. Press 2 on NumPad to go backwards
  4. Press 5 to wait.
  5. Game crashes to desktop without any error messages.

Expected behavior

It's possible to move the RV from the swamp.

Screenshots

No response

Versions and configuration

  • OS: Windows
    • OS Version: 10.0.19044.1586 (21H2)
  • Game Version: ba9af2e [64-bit]
  • Graphics Version: Tiles
  • Game Language: English [en]
  • Mods loaded: [
    Dark Days Ahead [dda],
    Disable NPC Needs [no_npc_food],
    Bionic Professions [package_bionic_professions]
    ]

Additional context

config.zip
Dateland.zip

@ektoplazm ektoplazm changed the title Crash to desktop while trying to ride the vehicle Crash to desktop while trying to drive the vehicle Apr 14, 2022
@andrei8l
Copy link
Contributor

quick fix:

diff --git a/src/vehicle_part.cpp b/src/vehicle_part.cpp
index e597263f74..c4ac158451 100644
--- a/src/vehicle_part.cpp
+++ b/src/vehicle_part.cpp
@@ -339,11 +339,12 @@ int vehicle_part::ammo_consume( int qty, const tripoint &pos )
 
 double vehicle_part::consume_energy( const itype_id &ftype, double energy_j )
 {
-    if( base.empty() || !is_fuel_store() ) {
+    std::list<item *> const fuels = base.all_items_top();
+    if( fuels.empty() || !is_fuel_store() ) {
         return 0.0f;
     }
 
-    item &fuel = base.legacy_front();
+    item &fuel = *fuels.front();
     if( fuel.typeId() == ftype ) {
         cata_assert( fuel.is_fuel() );
         // convert energy density in MJ/L to J/ml

A complete fix should handle the migration pockets somehow (spill and/or move contents to a standard pocket).

@NetSysFire NetSysFire added <Crash / Freeze> Fatal bug that results in hangs or crashes. (S2 - Confirmed) Bug that's been confirmed to exist Vehicles Vehicles, parts, mechanics & interactions [C++] Changes (can be) made in C++. Previously named `Code` labels Apr 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Crash / Freeze> Fatal bug that results in hangs or crashes. (S2 - Confirmed) Bug that's been confirmed to exist Vehicles Vehicles, parts, mechanics & interactions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants