Skip to content

[Vanilla Fix] Properly remove aircraft, jumpjet and rockets offmap when dead#2149

Open
CnCRAZER wants to merge 5 commits intoPhobos-developers:developfrom
CnCRAZER:ghost-aircraft-test-fix
Open

[Vanilla Fix] Properly remove aircraft, jumpjet and rockets offmap when dead#2149
CnCRAZER wants to merge 5 commits intoPhobos-developers:developfrom
CnCRAZER:ghost-aircraft-test-fix

Conversation

@CnCRAZER
Copy link
Contributor

@CnCRAZER CnCRAZER commented Mar 24, 2026

This pull request addresses a critical bug where units with Fly, Jumpjet, or Rocket locomotors that are destroyed while crashing off-map were not being properly cleaned up. This could lead to production slots being permanently blocked and unit limits being incorrectly counted. The fix ensures these units are now correctly removed from the game, and the documentation has been updated to reflect this change.

Bug fix implementation:

  • Added hooks in src/Misc/Hooks.BugFixes.cpp to ensure that off-map crashing units using FlyLocomotionClass, JumpjetLocomotionClass, and RocketLocomotionClass are treated as having touched the ground, triggering proper cleanup and resource release.

Documentation updates:

  • Updated docs/Fixed-or-Improved-Logics.md to describe the fix for units with Fly, Jumpjet, or Rocket locomotors being destroyed off-map and not being cleaned up, which could block production slots and unit limits.
  • Added the fix to the changelog in docs/Whats-New.md, crediting the contributor.
  • Updated CREDITS.md to include this bug fix in the list of individual contributions.

Add documentation and credit for a bug fix where aircraft destroyed while crashing off-map were not fully cleaned up, which could permanently block production slots and count toward unit limits. Updates CREDITS.md and adds entries to Fixed-or-Improved-Logics.md and Whats-New.md (credit to RAZER).
@github-actions
Copy link

github-actions bot commented Mar 24, 2026

Nightly build for this pull request:

This comment is automatic and is meant to allow guests to get latest nightly builds for this pull request without registering. It is updated on every successful build.

@NetsuNegi NetsuNegi added ❓Vanilla bug Vanilla game bugs that are requested to be fixed Needs testing ⚙️T1 T1 maintainer review is sufficient labels Mar 25, 2026
Copy link
Contributor

@TaranDahl TaranDahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What causes off-map or not to have different effects on crash behavior? The position you hooked doesn't seem to have such a difference.

@CnCRAZER
Copy link
Contributor Author

What causes off-map or not to have different effects on crash behavior? The position you hooked doesn't seem to have such a difference.

AFAIK offmap aircraft types are only removed if they are spawned from spawner or from teamtypes exiting the map. Running uninit to clear the unit from map is also only checked if aircraft type is within radar bounds

@CnCRAZER
Copy link
Contributor Author

CnCRAZER commented Mar 25, 2026

check the discord Phobos chat for the conversation regarding it

@TaranDahl
Copy link
Contributor

Repost:

I checked this. I think the location of the fix in your PR is incorrect.
I believe the root cause of the problem is at 4CD748. If it is outside the map, loco will refuse to set the location. Setting the layer and Mark are also rejected. It is unclear why such a judgment is made.
I think the correct approach should be to make a judgment at 4CD797, treating a crash outside the map the same as touching the ground, and performing subsequent detonation and unit deletion operations.
In addition, I'm afraid the crash of jumpjet has a similar problem (54CBC2). You'd better fix it while you're at it.

@TaranDahl
Copy link
Contributor

Oh. And there's also Rocket (662FD5).

@CnCRAZER
Copy link
Contributor Author

Very interesting. I'll take a look at your suggestions

Handle units with Fly, Jumpjet or Rocket locomotors that die/crash off-map by adding locomotor-specific hooks. Replaces the previous aircraft-only approach by adding three hooks in src/Misc/Hooks.BugFixes.cpp to treat off-map as ground-touch and force the cleanup/detonation path (Fly, Jumpjet, Rocket), including a stack init for the jumpjet "fellOnSomething" flag. Also updates CREDITS.md, docs/Fixed-or-Improved-Logics.md and docs/Whats-New.md to reflect the broader scope of the fix.
@CnCRAZER CnCRAZER changed the title [Vanilla Fix] Aircraft which crash offmap are not properly removed [Vanilla Fix] Properly remove aircraft, jumpjet and rockets offmap when dead Mar 25, 2026
@CnCRAZER
Copy link
Contributor Author

CnCRAZER commented Mar 25, 2026

Oh. And there's also Rocket (662FD5).

Rocket and Jumpjet are now implemented at the addresses you suggested.

Somebody tested the dll and sent me this link here https://drive.google.com/file/d/1MXKb1bCpaL-ZEyU6S_tM41eiYjPuFEMV/view

You can see the aircraft dying offmap and being able to rebuild them now

Comment on lines +2908 to +2909
REF_STACK(BYTE, fellOnSomething, 0x21);
fellOnSomething = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you certain? Doubt if the stack offset calculation is correct. Also, why don't you use the STACK_OFFSET macro?

// Replicate the stack init from the stolen bytes (mov byte ptr [esp+21h], 0)
// so the "fell on something" flag is properly zeroed for the crash path.
REF_STACK(BYTE, fellOnSomething, 0x21);
REF_STACK(BYTE, fellOnSomething, STACK_OFFSET(0x34, -0x13));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you want to change the var below.
I think it should be STACK_OFFSET(0x34, -0x23).
Image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing can try this 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs testing ⚙️T1 T1 maintainer review is sufficient ❓Vanilla bug Vanilla game bugs that are requested to be fixed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants