Skip to content

Conversation

@bobtista
Copy link

@bobtista bobtista commented Dec 2, 2025

  • Used clang-tidy to consistently change NULL->nullptr
  • Added include for cppMacros to files that use nullptr and didn't have it (required for VC6)

Tested build and played a game successfully.

A Follow up PR can:

  • clean up the #define NULL 0
  • replace remaining NULLs with 0 (or a named

@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from 5903988 to af7b405 Compare December 2, 2025 01:12
@bobtista bobtista closed this Dec 4, 2025
@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from 050b3f0 to e6c28a4 Compare December 4, 2025 17:24
@bobtista bobtista reopened this Dec 4, 2025
@bobtista bobtista marked this pull request as ready for review December 4, 2025 19:35
@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch 7 times, most recently from 149474b to 5f9990b Compare December 5, 2025 04:02
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Adding the CppMacros include everwhere should not be necessary.

* DecalGeneratorClass::Set_Mesh_Transform -- sets the current mesh coordinate system *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#include <Utility/CppMacros.h>
Copy link

@xezon xezon Dec 5, 2025

Choose a reason for hiding this comment

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

These includes should not be necessary in most cases. The include should come through WWCommon already. If not, then an always.h (WWVegas) or PreRTS.h (GameEngine) include is missing somewhere. GameEngineDevice does not use PreRTS.h there is may be necessary sometimes, but I would expect not in many cases because WWVegas stuff gets always.h

Copy link
Author

@bobtista bobtista Dec 6, 2025

Choose a reason for hiding this comment

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

Good catch, I removed it from files that include always.h, PreRTS.h, and BaseType.h - cleaned up 387 of 395 of them

@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch 2 times, most recently from 13beb77 to 252dac3 Compare December 6, 2025 03:19
@xezon
Copy link

xezon commented Dec 6, 2025

Can you merge the last commit with the first, to see which includes are left over?

@Mauller
Copy link

Mauller commented Dec 6, 2025

If you interactively rebase you should be able to drop the first and last commit entirely during the rebase so you only have the wanted commits left.

@xezon
Copy link

xezon commented Dec 6, 2025

It depends if there are any includes left added. But it is hard to review because github has trouble showing the diff :D

@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from 252dac3 to fa822b2 Compare December 6, 2025 17:10
@bobtista
Copy link
Author

bobtista commented Dec 6, 2025

Can you merge the last commit with the first, to see which includes are left over?

Done

@xezon
Copy link

xezon commented Dec 7, 2025

This needs another pass because #1594 has added a few new NULL's

@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from fa822b2 to d88acf7 Compare December 7, 2025 15:12
Copy link

@xezon xezon left a comment

Choose a reason for hiding this comment

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

When I search for NULL across whole project, then it finds 20231 NULLs, but this change only touched 8724 NULLs lines. Why is there this large discrepancy?

@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from d88acf7 to f312de3 Compare December 7, 2025 23:12
{ "ZoomMaxDistance", INI::parseReal, nullptr, offsetof( AudioSettings, m_zoomMaxDistance ) },
{ "ZoomSoundVolumePercentageAmount", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_zoomSoundVolumePercentageAmount ) },

{ nullptr, nullptr, nullptr, NULL }
Copy link

@localspook localspook Dec 9, 2025

Choose a reason for hiding this comment

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

Only 3 of the 4 NULLs got converted? 🤔

Copy link

@localspook localspook Dec 9, 2025

Choose a reason for hiding this comment

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

Oh I see, because the last field is an integer. (so the last NULL should ideally be 0)

@xezon
Copy link

xezon commented Dec 9, 2025

When I search for NULL across whole project, then it finds 20231 NULLs, but this change only touched 8724 NULLs lines. Why is there this large discrepancy?

And now it touches 28936 lines when there are 20231 NULLs. How is this possible?

@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch 2 times, most recently from 253af97 to f92b43a Compare December 14, 2025 15:42
@xezon
Copy link

xezon commented Dec 14, 2025

Now 35000 lines 👀

@bobtista
Copy link
Author

Now 35000 lines 👀

It's getting close to complete, I'm actively working on it :)

@xezon
Copy link

xezon commented Dec 14, 2025

But why is it 35000 lines? When I search in VS Code I get 20000 hits for NULL. Are there 15000 zeros for null?

@bobtista bobtista marked this pull request as draft December 14, 2025 19:21
@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch 5 times, most recently from 70d4d06 to 029eaf1 Compare December 14, 2025 22:35
refactor(core): modernize NULL to nullptr

refactor(generalsMD): modernize NULL to nullptr

refactor(generals): modernize NULL to nullptr

build: remove unnecessary includes

refactor: modernize NULL to nullptr with clang-tidy --fix-errors

refactor: Convert NULL to nullptr in Tools directories via clang-tidy

use a script to convert remaining NULLs to nullptrs
fix: add CppMacros.h includes for VC6 nullptr compatibility

fix: add core_utility link for Babylon tool to access CppMacros.h

fix: add core_utility link for buildVersionUpdate tool to access CppMacros.h

fix: add core_utility link for Tools that include CppMacros.h

fix: Add core_utility to DebugWindow target to resolve CppMacros.h include

fix: add CppMacros.h include for nullptr support in dialog.cpp

fix: add CppMacros.h include to BFISH.cpp for nullptr support
fix: change nullptr to 0 for unsigned return type in GetLine

fix: change nullptr to appropriate values for non-pointer return types

fix: change false to nullptr for Path* return types in AIPathfind

fix: change nullptr to false for Bool return type in pathDestination

fix: correct nullptr to FALSE in Bool isPatchShadowed function
@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from ec089de to 71957f4 Compare December 15, 2025 01:41
@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from 71957f4 to 3f53db9 Compare December 15, 2025 01:49
@bobtista bobtista force-pushed the bobtista/build/modernize-use-nullptr branch from 22c4663 to 6a4d020 Compare December 15, 2025 02:05
@bobtista bobtista marked this pull request as ready for review December 15, 2025 02:08
@bobtista
Copy link
Author

Ok I think we got it done :) All NULLs (other than ones inside comments or strings) are modernized. I comment out NULL definitions, and builds are passing.

On main, there are 37,524 occurrences of "NULL" (grep -rw "NULL" . | wc -l) - only about 100 of them were converted to 0 or False, the rest are now nullptr.

All 1,750 remaining NULLs are intentionally left.

  • 1,275 in comments/documentation
  • 250 in debug/assert messages (error strings)
  • 38 in string literals (identifiers/logging)
  • 187 in names/constants (Windows API, enums, function names)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants