Skip to content

bugfix: Restore retail compatibility after retail behavior flags change#2727

Open
Caball009 wants to merge 3 commits into
TheSuperHackers:mainfrom
Caball009:fix_retail_behavior_flags
Open

bugfix: Restore retail compatibility after retail behavior flags change#2727
Caball009 wants to merge 3 commits into
TheSuperHackers:mainfrom
Caball009:fix_retail_behavior_flags

Conversation

@Caball009
Copy link
Copy Markdown

#2691 Turned off some retail behavior which introduces mismatches. This PR aims to fix that.

TODO:

  • Replicate in Generals.

@Caball009 Caball009 added Bug Something is not working right, typically is user facing Critical Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour ThisProject The issue was introduced by this project, or this task is specific to this project labels May 17, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 17, 2026

Greptile Summary

This PR is a follow-up to #2691, which inadvertently broke retail CRC compatibility by hardcoding several PRESERVE_* behavior flags to (0). It introduces a PRESERVE_RETAIL_BEHAVIOR sentinel tied to RETAIL_COMPATIBLE_CRC so the flags default to retail-compatible values in normal builds while remaining overridable for non-retail builds.

  • RETAIL_COMPATIBLE_CRC and RETAIL_COMPATIBLE_XFER_SAVE are moved to the top of GameDefines.h so they are available before PRESERVE_RETAIL_BEHAVIOR is defined, and six PRESERVE_* / ALLOW_* flags are changed from (0) to PRESERVE_RETAIL_BEHAVIOR to restore retail defaults.
  • Several #if !A && !B preprocessor conditions are refactored to the logically equivalent #if !(A || B) form for readability, and operand order in tunnel-heal conditions is made consistent by placing RETAIL_COMPATIBLE_CRC first.

Confidence Score: 5/5

Safe to merge for default retail-compatible builds; all logical changes are correct equivalents of the original conditions.

The De Morgan rewrites and operand reorderings are all provably equivalent. The macro defaults are restored to their pre-#2691 values as intended, and no new paths are introduced. The one structural concern with PRESERVE_RETAIL_BEHAVIOR was already raised in a prior review thread.

Core/GameEngine/Include/Common/GameDefines.h — the PRESERVE_RETAIL_BEHAVIOR sentinel definition deserves a second look before any non-retail build is attempted.

Important Files Changed

Filename Overview
Core/GameEngine/Include/Common/GameDefines.h Central change: introduces PRESERVE_RETAIL_BEHAVIOR and reorders macro definitions; the sentinel's condition always evaluates true when the macro is not pre-defined, so setting RETAIL_COMPATIBLE_CRC=0 does not propagate to the dependent PRESERVE_* flags as intended (already flagged in a prior review thread).
GeneralsMD/Code/GameEngine/Include/Common/TunnelTracker.h Reorders RETAIL_COMPATIBLE_CRC before PRESERVE_TUNNEL_HEAL_STACKING in the #if guard for healObjects; logically equivalent, style-consistent change.
GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp Refactors !A && !B to !(A
GeneralsMD/Code/GameEngine/Source/Common/RTS/TunnelTracker.cpp Reorders operands in two tunnel-heal #if guards to match the new canonical order; no functional change.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp Rewrites !RETAIL_COMPATIBLE_CRC && !PRESERVE_NO_XP_FROM_POISON_KILLS as !(RETAIL_COMPATIBLE_CRC
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TunnelContain.cpp Reorders RETAIL_COMPATIBLE_CRC before PRESERVE_TUNNEL_HEAL_STACKING in the update() guard; equivalent change for consistency.
GeneralsMD/Code/GameEngine/Source/GameLogic/Object/ObjectCreationList.cpp Rewrites !RETAIL_COMPATIBLE_CRC && !PRESERVE_NO_XP_FROM_OCL_KILLS to !(RETAIL_COMPATIBLE_CRC

Reviews (2): Last reviewed commit: "Changed macro expressions." | Re-trigger Greptile

Comment on lines +34 to +36
#if RETAIL_COMPATIBLE_CRC || !defined(PRESERVE_RETAIL_BEHAVIOR)
#define PRESERVE_RETAIL_BEHAVIOR (1) // Retain specific behavior present in retail Generals 1.08 and Zero Hour 1.04. Should only be used in this file.
#endif
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 The PRESERVE_RETAIL_BEHAVIOR condition is always true at this point in the file, making RETAIL_COMPATIBLE_CRC have no practical effect. When RETAIL_COMPATIBLE_CRC is 0, the expression evaluates to 0 || !defined(PRESERVE_RETAIL_BEHAVIOR). Since PRESERVE_RETAIL_BEHAVIOR has not been defined yet at this location, !defined(PRESERVE_RETAIL_BEHAVIOR) is unconditionally true, so the macro is set to 1 regardless of the CRC flag. A developer setting RETAIL_COMPATIBLE_CRC=0 to test bug-fixed code will find that all PRESERVE_RETAIL_BEHAVIOR-gated paths (building resumption delay, multi-crate pickup, flame-kill XP, structure stealth, unreliable firestorms, money-per-minute) remain active.

Suggested change
#if RETAIL_COMPATIBLE_CRC || !defined(PRESERVE_RETAIL_BEHAVIOR)
#define PRESERVE_RETAIL_BEHAVIOR (1) // Retain specific behavior present in retail Generals 1.08 and Zero Hour 1.04. Should only be used in this file.
#endif
#ifndef PRESERVE_RETAIL_BEHAVIOR
#define PRESERVE_RETAIL_BEHAVIOR RETAIL_COMPATIBLE_CRC // Retain specific behavior present in retail Generals 1.08 and Zero Hour 1.04. Should only be used in this file.
#endif
Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngine/Include/Common/GameDefines.h
Line: 34-36

Comment:
The `PRESERVE_RETAIL_BEHAVIOR` condition is always true at this point in the file, making `RETAIL_COMPATIBLE_CRC` have no practical effect. When `RETAIL_COMPATIBLE_CRC` is 0, the expression evaluates to `0 || !defined(PRESERVE_RETAIL_BEHAVIOR)`. Since `PRESERVE_RETAIL_BEHAVIOR` has not been defined yet at this location, `!defined(PRESERVE_RETAIL_BEHAVIOR)` is unconditionally true, so the macro is set to 1 regardless of the CRC flag. A developer setting `RETAIL_COMPATIBLE_CRC=0` to test bug-fixed code will find that all `PRESERVE_RETAIL_BEHAVIOR`-gated paths (building resumption delay, multi-crate pickup, flame-kill XP, structure stealth, unreliable firestorms, money-per-minute) remain active.

```suggestion
#ifndef PRESERVE_RETAIL_BEHAVIOR
#define PRESERVE_RETAIL_BEHAVIOR RETAIL_COMPATIBLE_CRC // Retain specific behavior present in retail Generals 1.08 and Zero Hour 1.04. Should only be used in this file.
#endif
```

How can I resolve this? If you propose a fix, please make it concise.

Comment thread Core/GameEngine/Include/Common/GameDefines.h
Copy link
Copy Markdown

@Mauller Mauller left a comment

Choose a reason for hiding this comment

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

If we do add the overall preserve retail flag pattern, it might be better to split out the custom configuration into a cmake file for the pre configured flags that we are setting.

#define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04
#endif

#if RETAIL_COMPATIBLE_CRC || !defined(PRESERVE_RETAIL_BEHAVIOR)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think re-adding the PRESEVE_RETAIL_BEHAVIOR flag is really necessary.

We only need to fix the site of use.

Copy link
Copy Markdown

@xezon xezon May 18, 2026

Choose a reason for hiding this comment

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

Yes. Just add RETAIL_COMPATIBLE_CRC next to PRESERVE_STRUCTURE_STEALTH_DURING_REPAIR and PRESERVE_MULTI_CRATE_PICKUP and this will be it.

Comment thread GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp Outdated

#ifndef PRESERVE_BUILDING_RESUMPTION_DELAY
#define PRESERVE_BUILDING_RESUMPTION_DELAY (0) // The fix for this unfavorable behavior was approved by the Game Design Committee.
#define PRESERVE_BUILDING_RESUMPTION_DELAY PRESERVE_RETAIL_BEHAVIOR // The fix for this unfavorable behavior was approved by the Game Design Committee.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The problem here is that you have re-enabled the retail behaviour being used when retail compatibler CRC is disabled.

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

Labels

Bug Something is not working right, typically is user facing Critical Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ThisProject The issue was introduced by this project, or this task is specific to this project ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants