Skip to content

chore: Apply clang-format to entire codebase - #2820

Open
mirelle7 wants to merge 1 commit into
TheSuperHackers:mainfrom
mirelle7:chore/clang-format-codebase
Open

chore: Apply clang-format to entire codebase#2820
mirelle7 wants to merge 1 commit into
TheSuperHackers:mainfrom
mirelle7:chore/clang-format-codebase

Conversation

@mirelle7

@mirelle7 mirelle7 commented Jun 21, 2026

Copy link
Copy Markdown

This PR applies a repository-wide mechanical reformatting across all project source code using clang-format.

This is the successor to the original formatting attempt in PR #2638 (submitted by @DevGeniusCode). Following up on the community poll in Discord ("Apply clang-format on all code", which passed with 53%), this PR establishes the formatting baseline. Because the output is 100% automated, if conflicts arise from other PRs landing before this one, regenerating the diff is trivial (re-run the formatter and force-push).

A follow-up PR will add a .git-blame-ignore-revs file containing the commit hash of this formatting pass so that git blame (both locally and on GitHub) automatically skips over the formatting changes and preserves the historical authorship of every line.


What Changed vs PR #2638

Three config adjustments have been applied based on review feedback and legacy toolchain compatibility:

-UseTab: AlignWithSpaces
+UseTab: ForIndentation
+SpacesInAngles: Leave
+Cpp11BracedListStyle: false
  • UseTab: ForIndentation: Fixes the tab-space rendering mismatch in preprocessor block comments on GitHub (where GitHub defaults to tab=8, causing space-aligned block comments inside tab-indented preprocessor blocks to look misaligned).
  • SpacesInAngles: Leave: Retains existing spacing inside template brackets (e.g., keeping > > rather than collapsing them to >>), which is required for legacy C++98 / VC6 compiler compatibility.
  • Cpp11BracedListStyle: false: Prevents the formatter from collapsing braced initializer lists to C++11 single-line style, maintaining Allman brace layout consistency.

1. UseTab: ForIndentation GameLogic.h 25–45

Current (Before):

#pragma once

#include "Common/GameCommon.h"	// ensure we get DUMP_PERF_STATS, or not
#include "Common/GameType.h"
#include "Common/Snapshot.h"
#include "Common/STLTypedefs.h"
#include "Common/ObjectStatusTypes.h"
#include "GameNetwork/NetworkDefs.h"
#include "GameLogic/AI.h"
#include "GameLogic/Module/UpdateModule.h"	// needed for DIRECT_UPDATEMODULE_ACCESS
#pragma once

#include "Common/GameCommon.h"    // ensure we get DUMP_PERF_STATS, or not
#include "Common/GameType.h"
#include "Common/Snapshot.h"
#include "Common/STLTypedefs.h"
#include "Common/ObjectStatusTypes.h"
#include "GameNetwork/NetworkDefs.h"
#include "GameLogic/AI.h"
#include "GameLogic/Module/UpdateModule.h"    // needed for DIRECT_UPDATEMODULE_ACCESS

2. SpacesInAngles: Leave PerfTimer.cpp 205–225

/*static*/ Bool AutoPerfGatherIgnore::s_ignoring = false;

//-------------------------------------------------------------------------------------------------
typedef std::vector< std::pair< AsciiString, AsciiString >/**/> StringPairVec;
/*static*/ Bool AutoPerfGatherIgnore::s_ignoring = false;

//-------------------------------------------------------------------------------------------------
typedef std::vector< std::pair< AsciiString, AsciiString > /**/> StringPairVec;

3. Cpp11BracedListStyle: false WOLGameSetupMenu.cpp 218–226

static GameWindow *genericPingWindow[MAX_SLOTS] = {0};

static const Image *pingImages[3] = { nullptr, nullptr, nullptr };
static GameWindow* genericPingWindow[MAX_SLOTS] = { 0 };

static const Image* pingImages[3] = { nullptr, nullptr, nullptr };

All other open review items from PR #2638 have been resolved, are hardcoded clang-format parser behaviors (such as the Doxygen Javadoc star alignment), or have since landed on main.


Key Legacy & Toolchain Compatibility Settings

To ensure the codebase continues to compile cleanly on both modern toolchains (VS2022) and the legacy target toolchain (Visual C++ 6), the following settings are established in .clang-format:

  1. VC6 Template Compatibility (SpacesInAngles: Leave):
    Prevents clang-format from collapsing nested template arguments (e.g., std::vector<std::vector<int> > to >>). VC6 and older compilers misparse >> as a right-shift operator. PR chore: Prevent conflict between clang-format and pre-C++11 nested template parsing #2760 (and its closed predecessor PR refactor: Extract nested templates into typedefs for legacy compatibility #2642) already resolved the instances where it was collapsed, and this setting ensures it stays that way.
  2. VC6 Braced Initializer Compatibility (Cpp11BracedListStyle: false):
    Prevents formatting braced-init-lists in C++11 style, which causes parsing issues on legacy compilers.
  3. MSVC Inline Assembly Safety:
    clang-format has known parser conflicts with MSVC-style inline assembly blocks when not enclosed in curly braces (which can cause the formatter to join assembly lines and break compilation). These have been pre-emptively wrapped in curly braces (__asm { ... }) in main via PR chore: Prevent conflict between clang-format and MSVC by wrapping inline assembly blocks in curly braces #2811, making the formatter pass entirely safe.
  4. Macro-Split Assignments Resolved:
    Problems regarding assignment formatting split across macros have been pre-emptively addressed by PR refactor: Eliminate macro-split assignments #2641.

Scope & Merging Strategy

The PR includes the full codebase diff across all source files.

  • Open to Review Rounds: This PR is open to further review rounds. If any formatting settings need adjustments, the codebase can be formatted again and the branch force-pushed.
  • Trivial Merge Conflict Resolution: If another pull request gets merged into main before this one, resolving conflicts is trivial: we simply re-run the formatter locally on top of the updated main branch and force-push.

Zero-Trust Verification

Reviewers can verify that this PR is 100% mechanically generated with no manual edits by running the following steps directly from main without checking out this branch:

# 1. Fetch the PR branch head natively from the repository URL
Write-Host "Fetching PR branch..."
git fetch https://github.com/TheSuperHackers/GeneralsGameCode.git pull/2820/head

# 2. Pull the .clang-format configuration from the PR commit
Write-Host "Getting .clang-format configuration..."
git checkout FETCH_HEAD -- .clang-format

# 3. Format the codebase locally
Write-Host "Formatting codebase locally..."
Get-ChildItem -Path Core, Generals, GeneralsMD, scripts, resources/gitinfo -Include *.cpp, *.h, *.inl -Recurse | ForEach-Object { clang-format -i $_.FullName }

# 4. Compare your local formatted working tree directly against the PR branch in-memory
# (We add --ignore-cr-at-eol to handle Windows CRLF line ending differences cleanly)
Write-Host "Comparing local formatting against the PR..."
git diff --ignore-cr-at-eol FETCH_HEAD -- Core Generals GeneralsMD scripts resources/gitinfo

Expected result: The diff output must be completely empty. If silent, it guarantees the PR contains only tool-generated formatting changes.


How to Migrate Existing Feature Branches

If you have an active feature branch developed before this bulk formatting pass, you can migrate it to the new formatted main branch by letting Git automatically ignore whitespace-only conflicts during the rebase. Any remaining conflicts after this step are genuine code-logic overlaps between your changes and this PR and will need to be resolved manually as usual.

git fetch upstream pull/2820/head:clang-fmt
git rebase clang-fmt -Xignore-all-space

@greptile-apps

greptile-apps Bot commented Jun 21, 2026

Copy link
Copy Markdown

Too many files changed for review (3000 files, 500 file limit).

@DevGeniusCode

Copy link
Copy Markdown
-AlignEscapedNewlines: Left

If I remember correctly, we intentionally chose left alignment with a 4-character spacing.

@mirelle7

Copy link
Copy Markdown
Author
-AlignEscapedNewlines: Left

If I remember correctly, we intentionally chose left alignment with a 4-character spacing.

Thanks. Updated description, accidentally pasted older version. This line wasn't changed.

@xezon

xezon commented Jun 22, 2026

Copy link
Copy Markdown

What is the correct strategy to migrate old branches to new main after the formatting was merged into main?

@mirelle7

mirelle7 commented Jun 22, 2026

Copy link
Copy Markdown
Author

removed this text, everything is in the main description

@xezon

xezon commented Jun 22, 2026

Copy link
Copy Markdown

Did you test it? Does it work? This does not look as if it would work. I would expect the formatting needs to be merged into each commit of the branch?

@DevGeniusCode

Copy link
Copy Markdown
-UseTab: AlignWithSpaces
+UseTab: ForIndentation
+SpacesInAngles: Leave
+Cpp11BracedListStyle: false

Can you plz add short code examples before and after the changes?

@mirelle7
mirelle7 marked this pull request as draft June 23, 2026 12:49
@mirelle7

Copy link
Copy Markdown
Author

I'll update the description soon with more validating, newer guide, and code examples.

@xezon

xezon commented Jun 29, 2026

Copy link
Copy Markdown

This needs progress.

@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch 2 times, most recently from bf5acb4 to 0a067f8 Compare July 6, 2026 17:32
@mirelle7

mirelle7 commented Jul 6, 2026

Copy link
Copy Markdown
Author
image

Updated PRs description. Code examples added. Tested the script from "Migrate Existing Feature Branches" between a clang-formatted main from 2026-07-06 and 10 prs. Undrafted.

Tested against 10 open PRs: the single rebase command resolves all whitespace-only conflicts automatically. Only genuine code-logic overlaps require manual resolution (1–6 hunks in the affected PRs). Per-commit formatting is not required

@mirelle7
mirelle7 marked this pull request as ready for review July 6, 2026 17:46
@xezon

xezon commented Jul 6, 2026

Copy link
Copy Markdown

So now the big question is: WHEN MERGE? 👀

: m_offset(0)
, m_size(0)
: m_offset(0)
, m_size(0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Leading tab and then 2 spaces, is that as intended? Naturally we would have expected leading tabs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This was intentional to prevent Github from showing the wrong width. We can revert this to "AlignWithSpaces".

"UseTab: ForIndentation: Fixes the tab-space rendering mismatch in preprocessor block comments on GitHub (where GitHub defaults to tab=8, causing space-aligned block comments inside tab-indented preprocessor blocks to look misaligned)."

Didn't find a UseTab that wouldn't either uglify, keep github aligned or uses a single type of whitespace.

#define DEBUG_LOG_RAW(m) do { { DebugLogRaw m ; } } while (0) // Log message without trailing new line character (LF)
#define DEBUG_LOG_LEVEL(l, m) do { if (l & DebugLevelMask) { DebugLog m ; } } while (0)
#define DEBUG_LOG_LEVEL_RAW(l, m) do { if (l & DebugLevelMask) { DebugLogRaw m ; } } while (0)
#define DEBUG_ASSERTLOG(c, m) do { { if (!(c)) DebugLog m ; } } while (0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe a clang format off would be better readable for these macros

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We can also try AfterControlStatement: MultiLine.

"Changing AfterControlStatement from Always to MultiLine tells clang-format to only break the { onto a new line if the controlling expression spans multiple lines. Since do has no condition, and single-line if (cond) conditions stay on one line, the { stays inline for all short macro bodies."

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That does not sound ideal for this one case.

Comment thread Core/GameEngine/Include/Common/CRCDebug.h Outdated
Comment thread Core/GameEngine/Include/Common/INI.h Outdated
@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Jul 7, 2026
@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch from 0a067f8 to cd0af70 Compare July 17, 2026 21:44
@xezon

xezon commented Jul 19, 2026

Copy link
Copy Markdown

Dependencies #2883, #2885 merged

@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch from cd0af70 to d65ade8 Compare July 20, 2026 21:23
Comment thread Core/GameEngine/Include/Common/GameMemory.h
Comment thread Core/GameEngine/Include/Common/GameMemory.h
Comment thread Core/GameEngine/Include/Common/GameMemory.h
Comment thread Core/GameEngine/Include/GameClient/GraphDraw.h
Comment thread Core/GameEngine/Include/GameClient/MetaEvent.h
Comment thread Core/GameEngine/Include/GameClient/MetaEvent.h
@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch from d65ade8 to f1e1de1 Compare July 29, 2026 12:32
@mirelle7

Copy link
Copy Markdown
Author

Regenerated with:

IndentPPDirectives: None
IndentCaseLabels: false
BraceWrapping:
AfterEnum: false
AllowShortEnumsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true

@xezon xezon left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks almost very good

Comment thread Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h Outdated
Comment thread Core/Tools/Launcher/Toolkit/Support/RefCounted.h
@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch from f1e1de1 to c8524e9 Compare July 30, 2026 14:48
@mirelle7

Copy link
Copy Markdown
Author

Regenerated with:
BraceWrapping: AfterEnum: true
AllowShortEnumsOnASingleLine: false

Comment thread Generals/Code/GameEngine/Source/GameClient/Drawable.cpp Outdated
@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch 2 times, most recently from ebf1d78 to be9637b Compare July 31, 2026 21:58
@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch 2 times, most recently from 77f0cd5 to d698faf Compare August 1, 2026 12:20

@Skyaero42 Skyaero42 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Overall, looks good.
I would recommend ripping of the bandaid a.s.a.p.

We also need to have checks in place that all new code follows clang format (or that the author has applied clang format).

If I understand correctly (with a bit of help from Claude), you can add the following to CI:

- name: Check formatting (diff-only)
        run: |
          git fetch origin ${{ github.base_ref }} --depth=1
          git-clang-format-18 --binary clang-format-18 --diff origin/${{ github.base_ref }} HEAD

or if git-clang-format isn't available

- name: Check formatting
  run: |
    git fetch origin ${{ github.base_ref }} --depth=1
    git diff --name-only origin/${{ github.base_ref }}...HEAD -- '*.cpp' '*.h' \
      | xargs -r clang-format --dry-run --Werror

@tintinhamans what are our options here.

Comment thread Core/GameEngine/Source/Common/INI/INIMapCache.cpp
Comment thread Core/GameEngine/Source/Common/System/LocalFile.cpp Outdated
@mirelle7
mirelle7 marked this pull request as draft August 18, 2026 01:05
@mirelle7
mirelle7 force-pushed the chore/clang-format-codebase branch from d698faf to 105648a Compare September 2, 2026 17:07
@mirelle7
mirelle7 marked this pull request as ready for review September 2, 2026 17:22
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Establish repository-wide clang-format baseline

⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Adds clang-format rules preserving VC6-compatible templates and braced initializers.
• Mechanically reformats C++ sources across engines, libraries, games, and tools.
• Establishes a reproducible formatting baseline without intended behavioral changes.
Diagram

graph TD
  CFG["Format rules"] --> FMT["clang-format"] --> CORE["Core sources"] --> BASE["Formatted baseline"]
  FMT --> GEN["Generals sources"] --> BASE
  FMT --> MD["Zero Hour sources"] --> BASE
  FMT --> TOOLS["Tool sources"] --> BASE
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Format subsystems incrementally
  • ➕ Produces smaller diffs for manual inspection
  • ➕ Reduces conflicts for unrelated active branches
  • ➖ Leaves formatting inconsistent between batches
  • ➖ Creates repeated blame-disruption commits
  • ➖ Extends the period of formatting-related merge conflicts
2. Enforce formatting only on changed lines
  • ➕ Avoids a repository-wide diff
  • ➕ Preserves existing blame history without ignore revisions
  • ➖ Maintains inconsistent legacy formatting indefinitely
  • ➖ Formatting depends on which lines happen to change
  • ➖ Makes whole-file formatter runs noisy later

Recommendation: Keep the single atomic formatting pass. It establishes one reproducible baseline and is preferable to prolonged partial adoption, provided reviewers reproduce the diff with the pinned configuration and both modern and VC6-compatible build paths are validated. The planned blame-ignore revision should follow immediately.

Files changed (21) +26088 / -22116

Refactor (20) +26018 / -22116
GameMemory.hReformat shared memory interfaces +492/-483

Reformat shared memory interfaces

• Mechanically applies the new formatting baseline to memory declarations, macros, comments, and inline implementation code without intended semantic changes.

Core/GameEngine/Include/Common/GameMemory.h

GameMemory.cppReformat shared memory implementation +988/-837

Reformat shared memory implementation

• Normalizes preprocessor indentation, declarations, comments, braces, and spacing in the memory pool implementation. Runtime behavior is intended to remain unchanged.

Core/GameEngine/Source/Common/System/GameMemory.cpp

GameWindowManager.cppReformat window manager implementation +1894/-1789

Reformat window manager implementation

• Applies the formatter to the core GUI window-management implementation, standardizing control-flow braces, pointer spacing, indentation, and declarations.

Core/GameEngine/Source/GameClient/GUI/GameWindowManager.cpp

ConnectionManager.cppReformat network connection management +923/-606

Reformat network connection management

• Mechanically reformats connection-management code and its preprocessor branches without changing network behavior.

Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp

MilesAudioManager.cppReformat Miles audio manager +1111/-814

Reformat Miles audio manager

• Standardizes formatting throughout the Miles audio backend, including declarations, conditionals, macros, and comments.

Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp

W3DShaderManager.cppReformat W3D shader management +1738/-1455

Reformat W3D shader management

• Applies consistent spacing, indentation, and brace placement throughout shader-management code without intended rendering changes.

Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp

dx8wrapper.cppReformat DirectX 8 wrapper +2545/-1961

Reformat DirectX 8 wrapper

• Normalizes declarations, preprocessor directives, comments, pointer placement, and control-flow formatting in the DirectX wrapper. Legacy platform guards remain intact.

Core/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp

WWAudio.cppReformat WWAudio implementation +974/-1013

Reformat WWAudio implementation

• Mechanically reformats the shared audio library while preserving its existing interfaces and execution flow.

Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp

matrix3d.hReformat matrix utilities +630/-574

Reformat matrix utilities

• Applies the repository formatting baseline to matrix declarations and inline mathematical operations without changing calculations.

Core/Libraries/Source/WWVegas/WWMath/matrix3d.h

MainFrm.cppReformat W3D viewer frame code +1724/-1993

Reformat W3D viewer frame code

• Standardizes the W3D viewer's frame and UI implementation using the new formatting rules.

Core/Tools/W3DView/MainFrm.cpp

w3d_file.hReformat W3D exporter format definitions +1079/-1131

Reformat W3D exporter format definitions

• Mechanically formats legacy W3D structures and declarations while retaining existing binary-format definitions.

Core/Tools/WW3D/max2w3d/w3d_file.h

Drawable.cppReformat Generals drawable implementation +1884/-1628

Reformat Generals drawable implementation

• Applies consistent formatting to drawable lifecycle, rendering integration, and state-handling code without intended behavior changes.

Generals/Code/GameEngine/Source/GameClient/Drawable.cpp

AIStates.cppReformat Generals AI states +2011/-1523

Reformat Generals AI states

• Mechanically reformats AI state logic, including conditionals, declarations, and function calls, while preserving state behavior.

Generals/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp

ScriptEngine.cppReformat Generals script engine +2287/-1724

Reformat Generals script engine

• Standardizes script-engine declarations, macros, preprocessor sections, pointer spacing, and control-flow layout without intended semantic changes.

Generals/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptEngine.cpp

GUIEdit.cppReformat GUI editor implementation +2155/-2154

Reformat GUI editor implementation

• Applies the canonical formatting rules across the Generals GUI editor's primary implementation.

Generals/Code/Tools/GUIEdit/Source/GUIEdit.cpp

WHeightMapEdit.cppReformat WorldBuilder height-map editor +2428/-1370

Reformat WorldBuilder height-map editor

• Mechanically reformats the large height-map editing implementation, standardizing braces, indentation, spacing, and declarations.

Generals/Code/Tools/WorldBuilder/src/WHeightMapEdit.cpp

GlobalData.hReformat Zero Hour global data declarations +229/-228

Reformat Zero Hour global data declarations

• Applies the shared formatting baseline to Zero Hour global configuration declarations while preserving game-specific fields.

GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h

InGameUI.hReformat Zero Hour in-game UI interface +457/-463

Reformat Zero Hour in-game UI interface

• Standardizes formatting for Zero Hour UI declarations and inline methods without changing interfaces or behavior.

GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h

AIStateMachine.hReformat Zero Hour AI state machine +462/-357

Reformat Zero Hour AI state machine

• Mechanically formats AI state-machine declarations, helpers, and control structures while retaining existing behavior.

GeneralsMD/Code/GameEngine/Include/GameLogic/AIStateMachine.h

CreateObjectDie.hReformat Zero Hour object-death module +7/-13

Reformat Zero Hour object-death module

• Applies consistent declaration, pointer, brace, and indentation formatting to the object creation-on-death module.

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CreateObjectDie.h

Other (1) +70 / -0
.clang-formatDefine repository-wide C++ formatting rules +70/-0

Define repository-wide C++ formatting rules

• Adds the canonical clang-format configuration with Allman braces, indentation tabs, unbounded lines, unsorted includes, and left-aligned pointers. Preserves legacy compiler behavior through unchanged angle spacing, non-C++11 braced-list formatting, and custom macro handling.

.clang-format

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@Caball009

Caball009 commented Sep 2, 2026

Copy link
Copy Markdown

As for accidental behavior changes, I compared two VS22 release builds, one with this PR and one without. I disabled /DYNAMICBASE for the linker and replaced all instances of __LINE__ to 0. The two builds still differ a tiny bit, but nothing that warrants attention, I think.

I also checked with retail CRC and SAVE compatibility disabled and same result there.

@xezon

xezon commented Sep 3, 2026

Copy link
Copy Markdown

Switch cases still use indentation.

	switch (m_type)
	{
		case CONSTANT:
			DEBUG_ASSERTLOG(m_low == m_high, ("m_low != m_high for a CONSTANT GameLogicRandomVariable"));
			if (m_low == m_high)
			{
				return m_low;
			}
			FALLTHROUGH;

		case UNIFORM:
			return GameLogicRandomValueReal(m_low, m_high);

		default:
			/// @todo fill in support for nonuniform GameLogicRandomVariables.
			DEBUG_CRASH(("unsupported DistributionType in GameLogicRandomVariable::getValue"));
			return 0.0f;
	}

Expected:

	switch (m_type)
	{
    case CONSTANT:
        DEBUG_ASSERTLOG(m_low == m_high, ("m_low != m_high for a CONSTANT GameLogicRandomVariable"));
        if (m_low == m_high)
        {
            return m_low;
        }
        FALLTHROUGH;

    case UNIFORM:
        return GameLogicRandomValueReal(m_low, m_high);

    default:
        /// @todo fill in support for nonuniform GameLogicRandomVariables.
        DEBUG_CRASH(("unsupported DistributionType in GameLogicRandomVariable::getValue"));
        return 0.0f;
	}

"TerrainRoadType",
64,
64,
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

There are a couple more cases like this in that file and the Zero Hour version.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That is strange yes.

Comment thread Core/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp
//virtual void* getDevice() override { return nullptr; }
// virtual void openDevice() override {}
// virtual void closeDevice() override {}
// virtual void* getDevice() override { return nullptr; }

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 suspect it cannot differentiate between code that's commented out and regular comments, right?

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

Labels

Refactor Edits the code with insignificant behavior changes, is never user facing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants