Skip to content

Commit 1cd953a

Browse files
authored
Replace air/top layer sorting with an alternate solution to layering issues (#1179)
* Replace air/top layer sorting with an alternate solution to layering issues * Fix wrong address for jump * Fixup
1 parent a5b0edd commit 1cd953a

File tree

4 files changed

+13
-24
lines changed

4 files changed

+13
-24
lines changed

docs/Fixed-or-Improved-Logics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
111111
- Fixed `LandTargeting=1` not preventing from targeting TerrainTypes (trees etc.) on land.
112112
- Fixed `NavalTargeting=6` not preventing from targeting empty water cells or TerrainTypes (trees etc.) on water.
113113
- Fixed `NavalTargeting=7` and/or `LandTargeting=2` resulting in still targeting TerrainTypes (trees etc.) on land with `Primary` weapon.
114-
- Fixed an issue that causes objects in layers outside ground layer to not be sorted correctly (caused issues with animation and jumpjet layering for an instance)
115114
- Fixed infantry without `C4=true` being killed in water if paradropped, chronoshifted etc. even if they can normally enter water.
116115
- Allowed MCV to redeploy in campaigns using a new toggle different from `[MultiplayerDialogSettings]->MCVRedeploys`.
117116
- Fixed buildings with `UndeploysInto` but `Unsellable=no` & `ConstructionYard=no` unable to be sold normally. Restored `EVA_StructureSold` for buildings with `UndeploysInto` when being selled.
@@ -138,6 +137,7 @@ This page describes all ingame logics that are fixed or improved in Phobos witho
138137
- `Secondary` will now be used against walls if `Primary` weapon Warhead has `Wall=false`, `Secondary` has `Wall=true` and the firer does not have `NoSecondaryWeaponFallback` set to true.
139138
- Setting `ReloadInTransport` to true on units with `Ammo` will allow the ammo to be reloaded according to `Reload` or `EmptyReload` timers even while the unit is inside a transport.
140139
- It is now possible to enable `Verses` and `PercentAtMax` to be applied on negative damage by setting `ApplyModifiersOnNegativeDamage` to true on the Warhead.
140+
- Attached animations on flying units now have their layer updated immediately after the parent unit, if on same layer they always draw above the parent.
141141

142142
## Fixes / interactions with other extensions
143143

docs/Whats-New.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ You can use the migration utility (can be found on [Phobos supplementaries repo]
2020

2121
#### From post-0.3 devbuilds
2222

23+
- Air and Top layer contents are no longer sorted, animations in these layers no longer respect `YSortAdjust`. Animations attached to flying units now get their layer updated immediately after parent unit, if they are on same layer they will draw above the parent unit.
2324
- `AnimList.ShowOnZeroDamage` has been renamed to `CreateAnimsOnZeroDamage` to make it more clear it applies to both `AnimList` and splash animations.
2425
- INI inclusion and inheritance are now turned off by default and need to be turned on via command line flags `-Include` and `-Inheritance`.
2526
- `Level=true` projectiles no longer attempt to do reposition against targets that are behind non-water tiles by default. Use `SubjectToLand=true` to re-enable this behaviour.
@@ -423,6 +424,7 @@ Phobos fixes:
423424
- Fixed a typo in weapon selector code causing issues with `NoAmmoWeapon` and related checks (by Starkku)
424425
- Fixed `DetonateOnAllMapObjects` behaving erratically or potentially crashing if it destroys buildings using Ares' advanced rubble (by Starkku)
425426
- Fixed game crashing on loading save games if the saved game state had active radiation sites (by Starkku)
427+
- Fixed a desync error caused by air/top layer sorting (by Starkku)
426428
427429
Fixes / interactions with other extensions:
428430
- All forms of type conversion (including Ares') now correctly update `OpenTopped` state of passengers in transport that is converted (by Starkku)

src/Ext/Techno/Hooks.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -454,24 +454,21 @@ DEFINE_HOOK(0x70EFE0, TechnoClass_GetMaxSpeed, 0x6)
454454
return SkipGameCode;
455455
}
456456

457-
DEFINE_HOOK(0x54B188, JumpjetLocomotionClass_Process_LayerUpdate, 0x6)
458-
{
459-
GET(TechnoClass*, pLinkedTo, EAX);
457+
#pragma region Fly Layer Update
460458

461-
TechnoExt::UpdateAttachedAnimLayers(pLinkedTo);
459+
// Update attached anim layers after parent unit changes layer.
460+
void __fastcall DisplayClass_Submit_Wrapper(DisplayClass* pThis, void* _, ObjectClass* pObject)
461+
{
462+
pThis->Submit(pObject);
462463

463-
return 0;
464+
if (auto const pTechno = abstract_cast<TechnoClass*>(pObject))
465+
TechnoExt::UpdateAttachedAnimLayers(pTechno);
464466
}
465467

466-
DEFINE_HOOK(0x4CD4E1, FlyLocomotionClass_Update_LayerUpdate, 0x6)
467-
{
468-
GET(TechnoClass*, pLinkedTo, ECX);
469-
470-
if (pLinkedTo->LastLayer != pLinkedTo->InWhichLayer())
471-
TechnoExt::UpdateAttachedAnimLayers(pLinkedTo);
468+
DEFINE_JUMP(CALL, 0x54B18E, GET_OFFSET(DisplayClass_Submit_Wrapper)); // JumpjetLocomotionClass_Process
469+
DEFINE_JUMP(CALL, 0x4CD4E7, GET_OFFSET(DisplayClass_Submit_Wrapper)); // FlyLocomotionClass_Update
472470

473-
return 0;
474-
}
471+
#pragma endregion
475472

476473
// Move to UnitClass hooks file if it is ever created.
477474
DEFINE_HOOK(0x736234, UnitClass_ChronoSparkleDelay, 0x5)

src/Misc/Hooks.BugFixes.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -603,16 +603,6 @@ DEFINE_HOOK(0x56BD8B, MapClass_PlaceRandomCrate_Sampling, 0x5)
603603
return SpawnCrate;
604604
}
605605

606-
// Enable sorted add for Air/Top layers to fix issues with attached anims etc.
607-
DEFINE_HOOK(0x4A9750, DisplayClass_Submit_LayerSort, 0x9)
608-
{
609-
GET(Layer, layer, EDI);
610-
611-
R->ECX(layer != Layer::Surface && layer != Layer::Underground);
612-
613-
return 0;
614-
}
615-
616606
// Fixes C4=no amphibious infantry being killed in water if Chronoshifted/Paradropped there.
617607
DEFINE_HOOK(0x51A996, InfantryClass_PerCellProcess_KillOnImpassable, 0x5)
618608
{

0 commit comments

Comments
 (0)