Skip to content

Downgrade NumCellsInRadius overflow from Log.Error to Log.Warning#4645

Open
WhiteGiverMa wants to merge 1 commit into
CombatExtended-Continued:Developmentfrom
WhiteGiverMa:Development
Open

Downgrade NumCellsInRadius overflow from Log.Error to Log.Warning#4645
WhiteGiverMa wants to merge 1 commit into
CombatExtended-Continued:Developmentfrom
WhiteGiverMa:Development

Conversation

@WhiteGiverMa

@WhiteGiverMa WhiteGiverMa commented Jul 2, 2026

Copy link
Copy Markdown

Changes

  • Harmony_GenRadial.LogNotEnoughSquaresError(): Downgrade Log.ErrorLog.Warning
  • Reword the message from "Not enough squares to get to radius X. Max is Y" to "requested radius X exceeds maximum Y. Radius capped to Y."

Reasoning

GenRadial.MaxRadialPatternRadius is a compile-time const in vanilla RimWorld (~200). Third-party mods compiled against vanilla have this value baked into their IL, and CE cannot override it at runtime. When such a mod (e.g. WVC Work Modes) calls NumCellsInRadius with a radius exceeding CE's cap of 119, the prefix correctly caps the result — the game does not crash. But Log.Error causes unnecessary red error spam that alarms users.

Log.Warning better communicates that this is a compatibility note, not a failure. The updated message also accurately describes the cap behavior instead of sounding like a crash.

The performance-conscious design (separate method to avoid string formatting cost in hot path) is preserved unchanged.

Alternatives

  • Keep Log.Error — causes user-facing red error for a non-fatal compatibility edge case
  • Remove the log entirely — loses useful diagnostic info for mod compatibility debugging
  • Try to modify the compile-time const at runtime — not technically feasible through Harmony

Testing

Check tests you have performed:

  • Compiles without warnings
  • Game runs without errors
  • with and without patched mod loaded
  • Playtested a colony (30 days)

The 'Not enough squares' error triggers when another mod calls
GenRadial.RadialCellsAround with a radius larger than CE's MAX_RADIUS
(119). This is a benign compatibility issue — the result is capped
to the max array size and the game continues normally.

Logging it as Error causes unnecessary user alarm and log spam.
Changed to Warning with a clearer message that explains the cap
behavior rather than sounding like a fatal failure.
@WhiteGiverMa WhiteGiverMa requested review from a team as code owners July 2, 2026 11:20
@WhiteGiverMa WhiteGiverMa marked this pull request as draft July 2, 2026 11:21
@WhiteGiverMa WhiteGiverMa marked this pull request as ready for review July 2, 2026 11:21
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

You can download the rebuilt assembly for this PR here: https://combatextended.lp-programming.com/CombatExtended-28586083722.zip

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

Labels

Download in Comments This PR has a zipfile download available.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant