Skip to content

Crate overlay cleanup / desync issue #2151

@11EJDE11

Description

@11EJDE11

Description

This code helps prevent a desync occurring in the vanilla game:

DEFINE_HOOK(0x4A1BE8, CrateClass_GetCrate_FixLandType, 0x7)
{
	GET(CellClass*, pCell, EBX);

	pCell->OverlayData = 0;
	pCell->RecalcAttributes(DWORD(-1));

	return 0;
}

DEFINE_HOOK(0x56C1D3, MapClass_RemoveCrate_Campaign_FixLandType, 0x7)
{
	GET(CellClass*, pCell, EBX);

	pCell->OverlayData = 0;
	pCell->RecalcAttributes(DWORD(-1));

	return 0;
}

I don't know what causes the desync. At the very least, the fact that the game isn't calling RecalAttributes at the above locations looks like a bug (check callers for RecalAttributes @ 0x47D2B0).

What lead to finding this was noticing the Ramp fixup tiles CRCs were almost always different in the desync logs. From there I added the LandType logging which shows extra calls for one player. Since I started logging these, I've only seen ORCA and SPYP triggering the change. The extra calls looks like:

Example 1)

---- Frame 16107 ----
Frame:16107 | Cell:(  127,   24) | LandType: 0-> 1 | IsoTile:  469/plat07       ->   469/plat07       | Caller:005684E6 | PlaceDown:004D37E2 | Trigger:02/01110257 ORCA             | House: 2
             | TriggerCells:Cur=(  127,   24) Last=(  129,   26) Dest=(   57,  100) | Mission:  1
             | Cell:Slope= 0 Level= 4 Overlay=  -1/  0 Occ=00000000 AltOcc=00000000 | Jumpjet:00000000 <none>          
             | N:(  127,   23) Iso:  466/plat04       Slope: 0 Land: 0 Overlay:  -1/  0 | E:(  128,   24) Iso:    0/Clear01      Slope: 0 Land: 0 Overlay:  -1/  0
             | S:(  127,   25) Iso:    0/Clear01      Slope: 0 Land: 0 Overlay:  -1/  0 | W:(  126,   24) Iso:  534/Pvclr01      Slope: 0 Land: 0 Overlay:  -1/  0

Example 2)

---- Frame 17115 ----
Frame:17115 | Cell:(  144,  183) | LandType: 0-> 7 | IsoTile:  433/dlat15       ->   433/dlat15       | Caller:005684E6 | PlaceDown:004D37E2 | Trigger:02/01107149 ORCA             | House: 4
             | TriggerCells:Cur=(  144,  183) Last=(  209,  115) Dest=(  208,  114) | Mission:  7
             | Cell:Slope= 0 Level= 4 Overlay=  -1/  0 Occ=00000000 AltOcc=00000000 | Jumpjet:00000000 <none>          
             | N:(  144,  182) Iso:  427/dlat09       Slope: 0 Land: 7 Overlay:  -1/  0 | E:(  145,  183) Iso:    0/Clear01      Slope: 0 Land: 0 Overlay:  -1/  0
             | S:(  144,  184) Iso:    0/Clear01      Slope: 0 Land: 0 Overlay:  -1/  0 | W:(  143,  183) Iso:   83/Cliff35      Slope: 0 Land: 3 Overlay:  -1/  0

Example 3)

---- Frame  9569 ----
Frame: 9569 | Cell:(  120,   35) | LandType: 0-> 7 | IsoTile:  429/dlat11       ->   429/dlat11       | Caller:005684E6 | PlaceDown:004D37E2 | Trigger:02/01106843 SPYP             | House: 7
             | TriggerCells:Cur=(  120,   35) Last=(    0,    0) Dest=(  124,  227) | Mission: 31

We've had several people test and all agree this helps prevent the desync from occurring.

Conditions to reproduce

No response

INI code

Steps to reproduce

The quickest way I've found to trigger the desync:

Using the current live YR:

-Online or LAN game
-Map: Mayflower Rebalanced
-6 Nightmare AI, 2 human players. Human players on different sides, 2 soviet players on different sides, the rest as allied.
-4v4 left vs right
-Extreme crates enabled. You may wish to edit Extreme.ini to make it even more extreme and trigger the bug quicker.
-You can also unlock the game speed to trigger it quicker.

It should desync before frame 40k - usually 25k-30k in my experience.
In 5/5 test runs, the desync happened in all of them. With the fix applied and another 5 games run, all made it to 100k+ frames with no desync.

Expected behaviour

Game shouldn't desync.

Actual behaviour

Game desyncs.

Additional context

Attached are some of my desync logs. They are different to the standard ones provided by Phobos and have a lot of extra bits and bobs, most of it useless. Due to the size, use WinMerge to diff.

Github isn't letting me upload them, so here are some mirrors:
https://file.kiwi/0094ea6b#ey3Ond4W2ixWb89cGnq9sQ
https://filebin.net/7lql0p8gqguk00mi
https://gofile.io/d/SqyXzS
https://limewire.com/d/F7Cto#ChohMr0Sxh

Checklist

  • The issue is not introduced by Phobos or any other engine extension, such as Ares, Kratos etc.
  • The issue wasn't fixed in the most recent version of Ares/Phobos yet.
  • I agree to elaborate the details if requested and provide thorough testing if the bugfix is implemented.
  • I added a very descriptive title to this issue.
  • I used the GitHub search and read the issue list to find a similar issue and didn't find it.
  • I have attached as much information as possible (screenshots, gifs, videos, debug and exception logs, etc).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions