Skip to content

Commit 29dc6b4

Browse files
JohnsterIDxezon
authored andcommitted
fix(debug): Simplify unconditional DEBUG_ASSERTCRASH to DEBUG_CRASH (#2067)
Replace DEBUG_ASSERTCRASH(nullptr, ...) with DEBUG_CRASH(...) for unconditional crash assertions in MinGW-w64 debug builds. Changes: - PlayerTemplate.cpp: DEBUG_ASSERTCRASH(nullptr) → DEBUG_CRASH - ChallengeGenerals.cpp: DEBUG_ASSERTCRASH(nullptr) → DEBUG_CRASH - LoadScreen.cpp: 2× DEBUG_ASSERTCRASH(nullptr) → DEBUG_CRASH Total: 4 instances simplified across GeneralsMD codebase Rationale: DEBUG_ASSERTCRASH(nullptr, ...) was causing compilation errors with MinGW-w64 due to implicit nullptr-to-bool conversion. These instances represent "unconditional crash" assertions (always false condition). The DEBUG_CRASH macro is the semantically correct choice for this use case, making the intent explicit and avoiding type conversion issues. Error resolved: error: converting to 'bool' from 'std::nullptr_t' requires direct-initialization [-fpermissive] Historical note: These instances were introduced by commit f891c5f ("refactor: Modernize NULL to nullptr"). The original NULL was semantically 0 (false), not a null pointer check. Affects: GeneralsMD debug builds only
1 parent f8fd4a5 commit 29dc6b4

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

GeneralsMD/Code/GameEngine/Source/Common/RTS/PlayerTemplate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ Int PlayerTemplateStore::getTemplateNumByName(AsciiString name) const
294294
if (m_playerTemplates[num].getName().compareNoCase(name.str()) == 0)
295295
return num;
296296
}
297-
DEBUG_ASSERTCRASH(nullptr, ("Template doesn't exist for given name"));
297+
DEBUG_CRASH(("Template doesn't exist for given name"));
298298
return -1;
299299
}
300300

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ const GeneralPersona* ChallengeGenerals::getPlayerGeneralByCampaignName( AsciiSt
133133
if (campaignName.compareNoCase( name.str() ) == 0)
134134
return &m_position[i];
135135
}
136-
DEBUG_ASSERTCRASH(nullptr, ("Can't find General by Campaign Name"));
136+
DEBUG_CRASH(("Can't find General by Campaign Name"));
137137
return nullptr;
138138
}
139139

GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ void MultiPlayerLoadScreen::init( GameInfo *game )
13081308
else if (pt->getName() == "FactionChina")
13091309
portrait = TheMappedImageCollection->findImageByName("SNFactionLogoLg_China");
13101310
else
1311-
DEBUG_ASSERTCRASH(nullptr, ("Unexpected player template"));
1311+
DEBUG_CRASH(("Unexpected player template"));
13121312

13131313
localName = pt->getDisplayName();
13141314
}
@@ -1579,7 +1579,7 @@ GameSlot *lSlot = game->getSlot(game->getLocalSlotNum());
15791579
else if (pt->getName() == "FactionChina")
15801580
portrait = TheMappedImageCollection->findImageByName("SNFactionLogo144_China");
15811581
else
1582-
DEBUG_ASSERTCRASH(nullptr, ("Unexpected player template"));
1582+
DEBUG_CRASH(("Unexpected player template"));
15831583

15841584
localName = pt->getDisplayName();
15851585
}

0 commit comments

Comments
 (0)