CogEngine: Fix crash when the CogEngine data asset is not present

Fix cheat colors always overriding the user color
This commit is contained in:
Arnaud Jamin
2025-02-06 10:21:31 -05:00
parent e56966482e
commit 27ad15488d
6 changed files with 51 additions and 24 deletions
@@ -16,13 +16,20 @@ void FCogEngineWindow_Cheats::RenderHelp()
{
ImGui::Text(
"This window can be used to apply cheats to the selected actor (by default). "
"The cheats can be configured in the '%s' data asset. "
"When clicking a cheat button, press:\n"
" [CTRL] to apply the cheat to controlled actor\n"
" [ALT] to apply the cheat to the allies of the selected actor\n"
" [SHIFT] to apply the cheat to the enemies of the selected actor\n"
, TCHAR_TO_ANSI(*GetNameSafe(Asset.Get()))
);
if (Asset == nullptr)
{
ImGui::Text("Create a DataAsset child of 'CogEngineDataAsset' to configure the cheats. ");
}
else
{
ImGui::Text("The cheats can be configured in the '%s' data asset. ", StringCast<ANSICHAR>(*GetNameSafe(Asset.Get())).Get());
}
}
//--------------------------------------------------------------------------------------------------------------------------
@@ -436,6 +443,9 @@ void FCogEngineWindow_Cheats::RequestCheat(ACogEngineReplicator& Replicator, AAc
//--------------------------------------------------------------------------------------------------------------------------
const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& CheatName, const bool OnlyPersistentCheats)
{
if (Asset == nullptr)
{ return nullptr; }
for (const FCogEngineCheatCategory& CheatCategory : Asset->CheatCategories)
{
for (const FCogEngineCheat& Cheat : CheatCategory.PersistentCheats)
@@ -447,9 +457,7 @@ const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& C
}
if (OnlyPersistentCheats)
{
continue;
}
{ continue; }
for (const FCogEngineCheat& Cheat : CheatCategory.InstantCheats)
{
@@ -458,8 +466,6 @@ const FCogEngineCheat* FCogEngineWindow_Cheats::FindCheatByName(const FString& C
return &Cheat;
}
}
}
return nullptr;