Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gamenetwork): name every AI rung from one list

Olcay Seyganbd51244a2def
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 55562a496..d260cc343 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -83,6 +83,7 @@ found and fixed — EA's own, not port damage.**
- Each step up switches on exactly one new thing, so you can say in a sentence what you get for climbing.
- Measured, not asserted: Merciless beats Easy 15-0 over 32 headless matches with the seats swapped both ways, on twice the army and twice the spending.
- The three new levels showed up in the lobby as "Closed" and lost their start position on the map every time the list refreshed. Both fixed. Easy is slow and brave. Steady saves its damaged units. Medium expands on its own. Hard counters your build. Brutal masses and commits. Merciless is the ceiling - everything on, no hesitation.
+- The ladder reads as one ladder wherever a seat is listed. Half of it was named in EA's old words - "Easy Army", "Medium Army" - and half in ours, in the same drop-down, because four separate lists answered "what is this seat called" and no two of them agreed. It is Easy, Steady, Medium, Hard, Brutal, Merciless now, in the lobby, on the seat, in the game info panel and in the online browser alike.
- All six are in the network and online lobbies too, not just skirmish. Those two only ever offered three, and a seat set to anything above Medium was sent to the other machines as Brutal - so a game meant to be played against Steady was played against Brutal by everyone at the table, host included. The seat list also drops down far enough to reach the bottom of it - it was still sized for the five entries the game shipped with, so the last levels were off the end of the list.
- Making Easy easier means giving it worse decisions, never less money. That is the whole promise.
- The computer also picks a personality each match and keeps it: one plays for the attack, the other for the base. Same resources, spent differently.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h
index c60226aac..5001276cc 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h
@@ -303,6 +303,7 @@ Bool ParseAsciiStringToGameInfo( GameInfo *game, AsciiString options );
Bool IsAISlotState( SlotState state );
char SlotStateToOptionsChar( SlotState state );
Bool OptionsCharToSlotState( char c, SlotState *state );
+UnicodeString SlotStateName( SlotState state );
/**
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp
index 8795f5479..0ff15b87c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/GameInfoWindow.cpp
@@ -159,42 +159,7 @@ void RefreshGameInfoWindow(GameInfo *gameInfo, UnicodeString gameName)
}
if(slot->isAI())
{
- switch(slot->getState())
- {
- case SLOT_EASY_AI:
- {
- addedRow = GadgetListBoxAddEntryText(listBoxPlayers,TheGameText->fetch("GUI:EasyAI"),playerColor,-1, 1);
- break;
- }
- case SLOT_MED_AI:
- {
- addedRow = GadgetListBoxAddEntryText(listBoxPlayers,TheGameText->fetch("GUI:MediumAI"),playerColor,-1, 1);
- break;
- }
- case SLOT_HARD_AI:
- {
- addedRow = GadgetListBoxAddEntryText(listBoxPlayers,TheGameText->fetch("GUI:HardAI"),playerColor,-1, 1);
- break;
- }
- // the rungs the ladder added have no shipped string; plain English rather than MISSING:
- case SLOT_STEADY_AI:
- {
- addedRow = GadgetListBoxAddEntryText(listBoxPlayers,UnicodeString(L"Steady AI"),playerColor,-1, 1);
- break;
- }
- case SLOT_BRUTAL_AI:
- {
- addedRow = GadgetListBoxAddEntryText(listBoxPlayers,UnicodeString(L"Brutal AI"),playerColor,-1, 1);
- break;
- }
- case SLOT_MERCILESS_AI:
- {
- addedRow = GadgetListBoxAddEntryText(listBoxPlayers,UnicodeString(L"Merciless AI"),playerColor,-1, 1);
- break;
- }
- default:
- break;
- }
+ addedRow = GadgetListBoxAddEntryText(listBoxPlayers,SlotStateName(slot->getState()),playerColor,-1, 1);
}
else if(slot->isHuman())
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
index 202d89b9c..3f9dec400 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
@@ -198,19 +198,18 @@ void PopulatePlayerSlotComboBox(GameWindow *comboBox, Int color, Bool allowTakeo
if (!comboBox)
return;
- // Three of the six rungs have no shipped string, so they read as plain English rather than as
- // a MISSING:, and EA's "HardAI" string is left on the seat the lobby calls Brutal.
- static const struct { const char *key; const WideChar *plainEnglish; SlotState state; } seats[] =
+ // the order the ladder climbs in; what each one is called is SlotStateName's business
+ static const SlotState seats[] =
{
- { "GUI:Open", NULL, SLOT_OPEN },
- { "GUI:Closed", NULL, SLOT_CLOSED },
- { "GUI:HumanSlot", NULL, SLOT_TAKEOVER },
- { "GUI:EasyAI", NULL, SLOT_EASY_AI },
- { NULL, L"Steady AI", SLOT_STEADY_AI },
- { "GUI:MediumAI", NULL, SLOT_MED_AI },
- { NULL, L"Hard AI", SLOT_HARD_AI },
- { NULL, L"Brutal AI", SLOT_BRUTAL_AI },
- { NULL, L"Merciless AI", SLOT_MERCILESS_AI },
+ SLOT_OPEN,
+ SLOT_CLOSED,
+ SLOT_TAKEOVER,
+ SLOT_EASY_AI,
+ SLOT_STEADY_AI,
+ SLOT_MED_AI,
+ SLOT_HARD_AI,
+ SLOT_BRUTAL_AI,
+ SLOT_MERCILESS_AI,
};
// The combo box only grows its listbox when an add crosses the current length, and both
@@ -231,11 +230,10 @@ void PopulatePlayerSlotComboBox(GameWindow *comboBox, Int color, Bool allowTakeo
Int shown = 0;
for (Int i = 0; i < (Int)(sizeof(seats)/sizeof(seats[0])); ++i)
{
- if (seats[i].state == SLOT_TAKEOVER && !allowTakeover)
+ if (seats[i] == SLOT_TAKEOVER && !allowTakeover)
continue;
- UnicodeString label = seats[i].key ? TheGameText->fetch(seats[i].key) : UnicodeString(seats[i].plainEnglish);
- GadgetComboBoxAddEntry(comboBox, label, color);
- GadgetComboBoxSetItemData(comboBox, shown, (void *)seats[i].state);
+ GadgetComboBoxAddEntry(comboBox, SlotStateName(seats[i]), color);
+ GadgetComboBoxSetItemData(comboBox, shown, (void *)seats[i]);
++shown;
}
GadgetComboBoxSetSelectedPos(comboBox, 0);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp
index df8b6c6cd..61e89826b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp
@@ -1,4 +1,4 @@
-/*
+/*
** Command & Conquer Generals Zero Hour(tm)
** Copyright 2025 Electronic Arts Inc.
**
@@ -269,6 +269,33 @@ Bool OptionsCharToSlotState( char c, SlotState *state )
return FALSE;
}
+/** What a seat is called wherever one is listed: the lobby's drop-down, the seat itself, the game
+ * info panel, the online browser's tooltip. Four switch statements used to answer this and no
+ * two of them agreed - EA's shipped strings read "Easy Army" and "Medium Army" next to the
+ * ladder's own "Steady AI" and "Merciless AI", so one drop-down offered both namings at once,
+ * and "GUI:HardAI" sat on the Brutal rung in one file and on the Hard rung in another.
+ *
+ * So the six rungs are named here, in one style, and none of them goes through the shipped
+ * strings any more: three of the six never had one, and a ladder that reads half in EA's words
+ * and half in ours reads like two different lists. Open, Closed and the takeover seat are not
+ * rungs and keep their localised strings. */
+UnicodeString SlotStateName( SlotState state )
+{
+ switch( state )
+ {
+ case SLOT_OPEN: return TheGameText->fetch("GUI:Open");
+ case SLOT_TAKEOVER: return TheGameText->fetch("GUI:HumanSlot");
+ case SLOT_EASY_AI: return UnicodeString( L"Easy AI" );
+ case SLOT_STEADY_AI: return UnicodeString( L"Steady AI" );
+ case SLOT_MED_AI: return UnicodeString( L"Medium AI" );
+ case SLOT_HARD_AI: return UnicodeString( L"Hard AI" );
+ case SLOT_BRUTAL_AI: return UnicodeString( L"Brutal AI" );
+ case SLOT_MERCILESS_AI: return UnicodeString( L"Merciless AI" );
+ case SLOT_CLOSED:
+ default: return TheGameText->fetch("GUI:Closed");
+ }
+}
+
void GameSlot::setState( SlotState state, UnicodeString name, UnsignedInt IP )
{
// An opponent seat keeps its colour, faction, team and start spot while it stays an opponent
@@ -297,42 +324,7 @@ void GameSlot::setState( SlotState state, UnicodeString name, UnsignedInt IP )
m_state = state;
m_isAccepted = true;
m_hasMap = true;
- switch(state)
- {
- case SLOT_OPEN:
- m_name = TheGameText->fetch("GUI:Open");
- break;
- case SLOT_EASY_AI:
- m_name = TheGameText->fetch("GUI:EasyAI");
- break;
- case SLOT_MED_AI:
- m_name = TheGameText->fetch("GUI:MediumAI");
- break;
- case SLOT_BRUTAL_AI:
- m_name = TheGameText->fetch("GUI:HardAI");
- break;
- case SLOT_TAKEOVER:
- m_name = TheGameText->fetch("GUI:HumanSlot");
- break;
- //
- // The three rungs the ladder added. No shipped string for them, so plain English rather
- // than a MISSING: - and, before these cases existed, they fell through to the default and
- // every one of them appeared in the lobby as "Closed".
- //
- case SLOT_STEADY_AI:
- m_name = UnicodeString(L"Steady AI");
- break;
- case SLOT_HARD_AI:
- m_name = UnicodeString(L"Hard AI");
- break;
- case SLOT_MERCILESS_AI:
- m_name = UnicodeString(L"Merciless AI");
- break;
- case SLOT_CLOSED:
- default:
- m_name = TheGameText->fetch("GUI:Closed");
- break;
- }
+ m_name = SlotStateName( state );
}
m_IP = IP;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp
index 72ce6bd64..41522faae 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp
@@ -324,33 +324,8 @@ static void gameTooltip(GameWindow *window,
else if (slot && slot->isAI())
{
++numPlayers;
- switch(slot->getState())
- {
- case SLOT_EASY_AI:
- tooltip.concat(L'\n');
- tooltip.concat(TheGameText->fetch("GUI:EasyAI"));
- break;
- case SLOT_MED_AI:
- tooltip.concat(L'\n');
- tooltip.concat(TheGameText->fetch("GUI:MediumAI"));
- break;
- case SLOT_HARD_AI:
- tooltip.concat(L'\n');
- tooltip.concat(TheGameText->fetch("GUI:HardAI"));
- break;
- case SLOT_STEADY_AI:
- tooltip.concat(L'\n');
- tooltip.concat(UnicodeString(L"Steady AI"));
- break;
- case SLOT_BRUTAL_AI:
- tooltip.concat(L'\n');
- tooltip.concat(UnicodeString(L"Brutal AI"));
- break;
- case SLOT_MERCILESS_AI:
- tooltip.concat(L'\n');
- tooltip.concat(UnicodeString(L"Merciless AI"));
- break;
- }
+ tooltip.concat(L'\n');
+ tooltip.concat(SlotStateName(slot->getState()));
}
}
DEBUG_ASSERTCRASH(numPlayers, ("Tooltipping a 0-player game!\n"));
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index 950b3c56c..7a509c9f0 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -6326,4 +6326,35 @@ TEST(text_keeps_growing_with_the_screen_instead_of_stopping_at_twice)
previous = size;
}
}
+/* The lobby, the seat itself, the game info panel and the online browser's tooltip each carried
+ their own switch over the slot states, and no two agreed: EA's shipped strings read "Easy Army"
+ and "Medium Army" while the rungs the ladder added were written "Steady AI" and "Merciless AI",
+ so one drop-down offered a ladder named half one way and half the other - and "GUI:HardAI" sat
+ on the Brutal rung in one file and on the Hard rung in another. SlotStateName is the only list
+ now. (Only the AI rungs are checked here: Open, Closed and the takeover seat go through
+ TheGameText, which no test has.) */
+TEST(every_ai_rung_is_named_the_same_way_as_every_other)
+{
+ static const SlotState rungs[] =
+ {
+ SLOT_EASY_AI, SLOT_STEADY_AI, SLOT_MED_AI, SLOT_HARD_AI, SLOT_BRUTAL_AI, SLOT_MERCILESS_AI
+ };
+ const Int numRungs = sizeof(rungs)/sizeof(rungs[0]);
+
+ for (Int i = 0; i < numRungs; ++i)
+ {
+ UnicodeString name = SlotStateName( rungs[i] );
+ // a rung with no case of its own used to come back named "Closed"
+ CHECK( name.getLength() > 3 );
+
+ // and one style for the lot: "Easy Army" beside "Steady AI" is what this is here to stop
+ // (CHECK_STR is narrow-char, and casting a WideChar* into it compares one byte and passes)
+ CHECK( wcscmp( name.str() + name.getLength() - 3, L" AI" ) == 0 );
+ }
+
+ // no two rungs share a name, or the drop-down cannot say which one you picked
+ for (Int a = 0; a < numRungs; ++a)
+ for (Int b = a + 1; b < numRungs; ++b)
+ CHECK( wcscmp( SlotStateName( rungs[a] ).str(), SlotStateName( rungs[b] ).str() ) != 0 );
+}