Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#3378 closed defect (fixed)

Crash on rejoin (percentage of map controlled)

Reported by: elexis Owned by: Itms
Priority: Release Blocker Milestone: Alpha 19
Component: Core engine Keywords: patch
Cc: Itms Patch:

Description (last modified by elexis)

If you start a multiplayergame on the skirmish map "Northern Island (2)" or "Neareastern Badlands (4)" and then rejoin with the other client, you get this crash:

CCmpTerritoryManager.cpp(538): Assertion failed: "m_TerritoryTotalPassableCellCount > 0"
Assertion failed: "m_TerritoryTotalPassableCellCount > 0"
Location: CCmpTerritoryManager.cpp:538 (GetTerritoryPercentage)

Refs #3321 r16933

That commit initially sets m_TerritoryTotalPassableCellCount = 0; but requires ENSURE(m_TerritoryTotalPassableCellCount > 0); in the according line.

Sounds like that value should either be serialized or computed again when rejoining.

The serializationtest doesn't fail.

Attachments (2)

3378_v1.patch (1.2 KB ) - added by s0600204 9 years ago.
Proposed fix.
3378_v2.patch (1.2 KB ) - added by s0600204 9 years ago.
Tweaked comment

Download all attachments as: .zip

Change History (7)

comment:1 by elexis, 9 years ago

Description: modified (diff)

by s0600204, 9 years ago

Attachment: 3378_v1.patch added

Proposed fix.

comment:2 by s0600204, 9 years ago

CCmpTerritoryManager is not serialized at all - to quote the in-script comment:

Territory state can be recomputed as required, so we don't need to serialize any of it.

So upon rejoin, the territories must be recalculated. The same function that calculates territories also sets m_TerritoryTotalPassableCellCount.

But... something is calling GetTerritoryPercentage() before CalculateTerritories() has a chance to run. And the only thing that currently uses it is the player (JS) component StatisticsTracker.

Anyhow, attached patch makes sure that CalculateTerritories() runs before m_TerritoryTotalPassableCellCount is used.

comment:3 by s0600204, 9 years ago

Keywords: patch review added

by s0600204, 9 years ago

Attachment: 3378_v2.patch added

Tweaked comment

comment:4 by Itms, 9 years ago

Owner: set to Itms
Resolution: fixed
Status: newclosed

In 16941:

Fix a special situation where map control percentage wasn't computed properly.
Also improve the code and fix a typo.

Based on patch by s0600204, fixes #3378.

comment:5 by Itms, 9 years ago

Keywords: review removed

Thanks for the fix. The comment wasn't really necessary, and I fixed a mistake I hadn't seen in the original patch.

If you wonder, my change <= 0 to == 0 is intentional, as it's better to actually crash if the variable is badly initialized.

Note: See TracTickets for help on using tickets.