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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): a mod's armies always stand beside retail's
Olcay Seygan1680072ed5f0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4df847816..505413088 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -345,15 +345,15 @@ found and fixed, EA's own, not port damage.**## Mods-- A mod is a folder now. Start the game with `-mod` and the folder, and the archives in it replace Zero Hour's files, as before, and so do the plain files under its `Data` and `Art` folders, which the game used to ignore. A modder can drop in one changed file without packing an archive first.-- Several mods run at once. Give `-mod` once for each, and where two of them change the same file, the one named later wins.-- Reforged stays on top of every mod. This build's balance, its fixes to EA's data, its AI and its menus load after the mod and win where they touch the same unit, weapon or button, so a mod plays with Reforged's rules. A change that names something the mod renamed or removed is passed over instead of stopping the game, which is how ShockWave starts and plays. A mod's own copy of a file Reforged ships, the skirmish setup screen among them, is ignored, and so are any upscaled art archives it carries. The one exception is the skirmish AI's scripts: a mod's are written for its own generals, so they replace Reforged's, and Reforged's smarter AI plays them.+- A mod is a folder now. Start the game with `-mod` and the folder, and its archives count, and so do the plain files under its `Data` and `Art` folders, which the game used to ignore. A modder can drop in one changed file without packing an archive first.+- A mod's armies always stand beside Zero Hour's, never over them, one mod or five. Contra alone used to swap every USA, China and GLA in the room for its own and leave you nothing else to play. Now the list holds Zero Hour's armies and under them "Contra - Tank General" and the rest, so a Contra general can fight a plain Zero Hour China in one match. No switch asks for this and none turns it off. A plain Random stays with Zero Hour's armies; a mod's army plays when somebody picks it or ticks it into a Custom Selection. On the army screen each mod's generals gather under one heading a country, "Contra - USA", where Contra's twelve used to make twelve headings and run off the screen. Playing a mod's army you hear that mod's music tracks, so the Enhanced Music pack for Contra plays in the match.+- Reforged stays on top of every mod. This build's balance, its fixes to EA's data, its AI and its menus load after the mod and win where they touch the same unit, weapon or button, on Zero Hour's armies; a mod's army keeps its own numbers and buttons. A change that names something the mod renamed or removed is passed over instead of stopping the game, which is how ShockWave starts and plays. A mod's own copy of a file Reforged ships, the skirmish setup screen among them, is ignored, and so are any upscaled art archives it carries. The one exception is the skirmish AI's scripts: a mod's are written for its own generals, so they replace Reforged's, and Reforged's smarter AI plays them.- A mod no longer repaints the game around it. Shockwave Chaos set the whole skirmish lobby in Comic Sans, with its own yellow-edged boxes, loading bars, main menu backdrop and score screens, because its archives replaced the font list, the shell's image sheets and the pictures they are cut from. Every menu and lobby layout, the fonts, the shell's colours and frames and the in-match screens are ours now under any mod. The mod's units, their build pictures and its generals with their portraits still come from the mod, and its new generals still appear in the lobby's faction list.- The maps stay Zero Hour's under every mod. A mod that carries its own maps, Contra among them, used to fill the skirmish and LAN map lists with them, and its edited copies of the stock maps replaced ours under the same names: picking Twilight Flame started Contra's Twilight Flame. The map list and every map you start are Zero Hour's and Reforged's now, whatever mods are loaded, so everyone in a lobby plays the same map.- A `mod.json` in the folder names the mod and its version. The names stand beside the version number in the options menu, in the order the mods were given, and go into every replay you record, so a replay made with mods says which ones, and the replay list marks it as another version when the game is running without them.- Joining a LAN game that runs different mods used to end in a box about a mismatch and nothing else. It names the host's mods now, or tells you the host plays without any.-- Two total conversions in one match. Add `-modfactions` to the mods you give, and each mod's armies join Zero Hour's own instead of replacing them: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. The End of Days' Russian command center, its Tor-M1 and some sixty other models used to come out bright pink; they wear the mod's own paint now. Playing a mod's faction, your buttons, build pictures, unit names and tooltips are that mod's, set in our command bar for that general's country: a mod's Chinese general gets the Chinese bar, a GLA one the GLA bar, and a nation Zero Hour never had, Russia among them, the American one. Every mod general used to get the American bar. The End of Days' Russia is in the list under its own name. Each mod general's promotion screen holds that mod's own powers, with the mod's pictures, and they unlock with your rank. They sit together with no holes between them, and each power's upgrades stand in the column under it, Paradrop 1 over 2 over 3, the way Zero Hour lays out its own. A mod's faction climbs that mod's own ranks: The End of Days' eight, with its own experience steps and points, where Zero Hour's five used to apply to everyone. ShockWave's and The End of Days' screens used to open empty, because a rank granted only Zero Hour's own rank marks and the mod's powers asked for the mod's. Menus, lobby and colours stay ours whatever mods you load. A computer player on a mod's faction plays that mod's own skirmish AI: the mod's base layout, base defences, harvester counts, generals' powers and the teams its scripts train, run by Reforged's AI. It used to lay out the base from the mod's buildings and then train the army it knew from Zero Hour, and a nation Zero Hour never had did nothing at all. A mod that ships no skirmish AI of its own still gets Zero Hour's, read with the mod's buildings.-- A patch for a mod stays with that mod. Give it with `-modpatch` right after the mod it changes, and its files replace that mod's one for one, even beside a second total conversion: a ShockWave balance patch reaches ShockWave's armies and leaves The End of Days alone. Given first, a patch changes Zero Hour's own files. The launcher's MODS page marks each mod a patch or a full mod, and a `mod.json` can say `"patch": true`. With two full mods switched on the launcher now plays them side by side; before, ShockWave and The End of Days together stopped the game at startup.+- Two total conversions in one match. Give both, and each mod's armies join Zero Hour's own: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. The End of Days' Russian command center, its Tor-M1 and some sixty other models used to come out bright pink; they wear the mod's own paint now. Playing a mod's faction, your buttons, build pictures, unit names and tooltips are that mod's, set in our command bar for that general's country: a mod's Chinese general gets the Chinese bar, a GLA one the GLA bar, and a nation Zero Hour never had, Russia among them, the American one. Every mod general used to get the American bar. The End of Days' Russia is in the list under its own name. Each mod general's promotion screen holds that mod's own powers, with the mod's pictures, and they unlock with your rank. They sit together with no holes between them, and each power's upgrades stand in the column under it, Paradrop 1 over 2 over 3, the way Zero Hour lays out its own. A mod's faction climbs that mod's own ranks: The End of Days' eight, with its own experience steps and points, where Zero Hour's five used to apply to everyone. ShockWave's and The End of Days' screens used to open empty, because a rank granted only Zero Hour's own rank marks and the mod's powers asked for the mod's. Menus, lobby and colours stay ours whatever mods you load. A computer player on a mod's faction plays that mod's own skirmish AI: the mod's base layout, base defences, harvester counts, generals' powers and the teams its scripts train, run by Reforged's AI. It used to lay out the base from the mod's buildings and then train the army it knew from Zero Hour, and a nation Zero Hour never had did nothing at all. A mod that ships no skirmish AI of its own still gets Zero Hour's, read with the mod's buildings.+- A patch for a mod stays with that mod. Give it with `-modpatch` right after the mod it changes, and its files replace that mod's one for one, even beside a second total conversion: a ShockWave balance patch reaches ShockWave's armies and leaves The End of Days alone. Given first, a patch changes Zero Hour's own files. The launcher's MODS page marks each mod a patch or a full mod, and a `mod.json` can say `"patch": true`. ShockWave and The End of Days together used to stop the game at startup.- Contra and The Power of the West start and play now, The Power of the West beside ShockWave too; every one of those used to crash while loading. Contra's China base fell over the carpet bombers it never had, and one misspelt armour line in The Power of the West stopped the game where Zero Hour itself had shrugged it off. A mod's patch archive named to sort first, like Contra's `!!` one, wins over the rest of the mod again, as it always did in Zero Hour.- No empty slots in a mod general's power tray. Mods give unrelated powers the same few types, Contra's small Scud Storm counting as a carpet bomb, so a Contra Cybernetic player's tray picked up another faction's button for a power he only held one of the same type as, then hid it, and an empty frame stood where it had been. The tray offers a button now only for the very power you hold, and a slot whose button goes away takes its frame with it.- A Paladin under Contra no longer crashes the game. Reforged gives every Paladin a second laser for infantry, and that laser borrowed a Zero Hour weapon nothing else fires. Contra deleted it, so the laser had no gun, and the game went down a moment after the first Paladin rolled out. The laser is Reforged's own weapon now and is there whatever mod you load. The same kind of gap took the guns off Contra's Toxin Tunnel Defender and Toxin Stinger soldier, the Chemical Suits off its Rangers, and the death blast off its Demolition Scud Launcher, Toxin demo trap and Toxin Tractors (ShockWave's trap too). Where Reforged names a weapon or armour the mod dropped, the unit now keeps the mod's own, and the death blasts carry Zero Hour's charge.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex f3e9f839d..1f632695d 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -944,10 +944,10 @@ public:std::vector<AsciiString> m_mods; ///< every -mod in command-line order, later wins: a folder ends in '\', anything else is a .bigAsciiString m_modName; ///< UTF-8, each mod's "<name> <version>" from its mod.json (else the folder or archive name), joined by ", " in m_mods order; empty without -modstd::vector<AsciiString> m_modNames; ///< UTF-8, each mod's mod.json "name" (else the folder or archive name), in m_mods order- std::vector<Bool> m_modIsPatch; ///< -modpatch: TRUE for each m_mods entry given as a patch; without -modfactions a patch is a plain -mod+ std::vector<Bool> m_modIsPatch; ///< -modpatch: TRUE for each m_mods entry given as a patch; with no full -mod the patches stack as plain modsstd::vector< std::vector<AsciiString> > m_modPatches; ///< -modfactions: the -modpatch folders over each m_mods[n], later winsstd::vector<AsciiString> m_retailPatches; ///< -modfactions: the -modpatch folders given before any -mod, over retail's files- Bool m_modFactions; ///< -modfactions: every mod's factions load beside retail's under "M<n>~" names (ModNamespace)+ Bool m_modFactions; ///< any full -mod given: every mod's factions load beside retail's under "M<n>~" names (ModNamespace). "-modfactions" in a comment is this; the switch is gone//-allAdvice feature//Bool m_allAdvice;diff --git a/GeneralsMD/Code/GameEngine/Include/Common/PlayerTemplate.h b/GeneralsMD/Code/GameEngine/Include/Common/PlayerTemplate.hindex 9ed0909b8..9127c1516 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/PlayerTemplate.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/PlayerTemplate.h@@ -141,8 +141,9 @@ public:AsciiString getScoreScreenMusic() const { return m_scoreScreenMusic; }inline Bool isOldFaction( void ) const { return m_oldFaction; }- /// a plain Random never draws it; a lobby's own pick of the Random pool may still tick it in- inline Bool isRandomExcluded( void ) const { return m_randomExcluded; }+ /// a plain Random never draws it; a lobby's own pick of the Random pool may still tick it in. A mod's+ /// faction is always out of a plain Random: it plays only when somebody picks it.+ inline Bool isRandomExcluded( void ) const { return m_randomExcluded || m_modIndex >= 0; }static const FieldParse* getFieldParse();diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex 9f2eb33e0..cbe398276 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -2828,13 +2828,13 @@ Int parseMod(char *args[], Int num)}/** -modpatch <folder>: a mod that changes the one given before it file by file rather than bringing- * armies of its own, or retail's files when it comes first. Without -modfactions it is a plain -mod. */+ * armies of its own, or retail's files when it comes first. With no full -mod at all it is a plain -mod. */Int parseModPatch(char *args[], Int num){return addMod( args, num, TRUE );}-/** -modfactions keeps each full mod's files apart, so a patch joins the full mod before it (retail's+/** A mod's factions load beside retail's, each full mod's files apart, so a patch joins the full mod before it (retail's* files when none is) and the full mods alone are the faction sets, M1, M2 and so on. */static void foldModPatches(){@@ -2860,15 +2860,6 @@ static void foldModPatches()data->m_modNames = names;}-Int parseModFactions(char *args[], Int)-{- if (TheWritableGlobalData)- {- TheWritableGlobalData->m_modFactions = TRUE;- }- return 1;-}-static CommandLineParam params[] ={{ "-noshellmap", parseNoShellMap },@@ -2882,7 +2873,6 @@ static CommandLineParam params[] ={ "-scriptDebug", parseScriptDebug },{ "-playStats", parsePlayStats },{ "-mod", parseMod },- { "-modfactions", parseModFactions },{ "-modpatch", parseModPatch },{ "-noshaders", parseNoShaders },{ "-particlebounce", parseParticleBounce },@@ -3118,11 +3108,11 @@ void parseCommandLine(int argc, char *argv[])}}- // with no full -mod there is nothing to keep apart, and the retail focus would have no tree to read;- // patches alone then stack as plain mods+ // Any full -mod's factions stand beside retail's, one mod or five; never merged over them. With no+ // full -mod there is nothing to keep apart, and the retail focus would have no tree to read; patches+ // alone then stack as plain mods.const std::vector<Bool> &isPatch = TheGlobalData->m_modIsPatch;- if (std::find( isPatch.begin(), isPatch.end(), FALSE ) == isPatch.end())- TheWritableGlobalData->m_modFactions = FALSE;+ TheWritableGlobalData->m_modFactions = std::find( isPatch.begin(), isPatch.end(), FALSE ) != isPatch.end();if (TheGlobalData->m_modFactions)foldModPatches();TheArchiveFileSystem->loadMods();diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex 9238a12cf..e804ef0f4 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -207,7 +207,7 @@ void initSubsystem(SUBSYSTEM*& sysref, AsciiString name, SUBSYSTEM* sys, Xfer *p//-------------------------------------------------------------------------------------------------/** A store a faction is made of. With -modfactions the plain load sees retail's files only, and* then each mod's load under that mod's names (INI::loadModPasses); a mod's Default\ file never- * loads. Without it this is initSubsystem. */+ * loads. With no full -mod this is initSubsystem. *///-------------------------------------------------------------------------------------------------template<class SUBSYSTEM>void initFactionSubsystem(SUBSYSTEM*& sysref, AsciiString name, SUBSYSTEM* sys, Xfer *pXfer, const char* path1,diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cppindex ba828431b..3ba5018d2 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp@@ -507,7 +507,7 @@ void INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer )//-------------------------------------------------------------------------------------------------/** -modfactions: one pass of path per -mod, each seeing only its own files and reading its own names- * with the mod's prefix. Without the switch this does nothing. */+ * with the mod's prefix. With no full -mod this does nothing. *///-------------------------------------------------------------------------------------------------void INI::loadModPasses( const char *path, Xfer *pXfer, Bool directory ){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cppindex f16b95907..491c026b2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp@@ -1109,8 +1109,8 @@ ControlBarScheme *ControlBarSchemeManager::findSchemeForSide( const AsciiString&//-----------------------------------------------------------------------------/** The owner's call: a mod's faction gets our American power tray, whatever .wnd the mod names. Its- * buttons, cameos and portrait are still the mod's. Under -modfactions that- * is a faction with a mod index; under a single -mod every faction is the mod's. The observer is+ * buttons, cameos and portrait are still the mod's. That is a faction with a mod index, or any+ * faction under patches with no full -mod. The observer is* none. *///-----------------------------------------------------------------------------Bool ControlBarIsModFaction( const PlayerTemplate *pt )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/FactionPicker.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/FactionPicker.cppindex 4d021f8e1..fe88c4539 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/FactionPicker.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/FactionPicker.cpp@@ -100,6 +100,7 @@ struct PickerCellstruct PickerGroup{AsciiString leadSide;+ AsciiString baseSide; ///< a mod's groups onlyInt mod;UnicodeString name;DisplayString *heading;@@ -299,6 +300,30 @@ static Bool canConfirm( void )return s_focus >= 0 || !s_custom || tickedCount() > 0;}+/// "Contra - USA": EA's own word for a country where there is one, the mod's BaseSide as written otherwise+static UnicodeString modGroupName( Int mod, const AsciiString &baseSide )+{+ WideChar modName[ 128 ];+ WideCharFromUtf8( TheGlobalData->m_modNames[ mod ].str(), modName, ARRAY_SIZE( modName ) );+ UnicodeString name( modName );+ name.concat( u" - " );+ AsciiString label;+ label.format( "SIDE:%s", baseSide == "USA" ? "America" : baseSide.str() );+ Bool exists = FALSE;+ const UnicodeString country = TheGameText->fetch( label, &exists );+ if( exists )+ {+ name.concat( country );+ }+ else+ {+ UnicodeString written;+ written.translate( baseSide );+ name.concat( written );+ }+ return name;+}+//-------------------------------------------------------------------------------------------------/** The armies in the box, each under the first army of its side: a general's Side begins with his* side's ("AmericaLaserGeneral" under "America"), so Turkiye, on America's BaseSide but a side of its@@ -325,6 +350,7 @@ static void buildCells( void )cell.label = NULL;AsciiString side = "Observer";+ AsciiString baseSide;Int mod = -1;if( pick == PLAYERTEMPLATE_OBSERVER ){@@ -353,7 +379,9 @@ static void buildCells( void )cell.strategy = TheGameText->fetch( pt->getTooltip() );if( !pt->getGeneralFeatures().isEmpty() )cell.features = TheGameText->fetch( pt->getGeneralFeatures() );- if( pt->isRandomExcluded() )+ baseSide = pt->getBaseSide();+ // every mod faction stays out of a plain Random, too many to name; the list of who it draws says so+ if( pt->isRandomExcluded() && mod < 0 ){if( !s_leftOut.isEmpty() )s_leftOut.concat( u", " );@@ -366,19 +394,23 @@ static void buildCells( void )cell.label->setWordWrapCentered( TRUE );}+ // A mod lists its generals in any order and its plain side last (Contra), so its groups go by+ // BaseSide: one heading a country, and the screen fits however many generals it brings.size_t group = 0;for( ; group < s_groups.size(); group++ ){- if( s_groups[ group ].mod == mod && side.startsWith( s_groups[ group ].leadSide ) )+ const PickerGroup &g = s_groups[ group ];+ if( g.mod == mod && ( mod >= 0 ? g.baseSide == baseSide : side.startsWith( g.leadSide ) ) )break;}if( group == s_groups.size() ){PickerGroup lead;lead.leadSide = side;+ lead.baseSide = baseSide;lead.mod = mod;- lead.name = cell.name;- lead.heading = newText( cell.name, UIStyle::font( UIStyle::TEXT_HEADING ) );+ lead.name = mod >= 0 ? modGroupName( mod, baseSide ) : cell.name;+ lead.heading = newText( lead.name, UIStyle::font( UIStyle::TEXT_HEADING ) );lead.mask = 0;s_groups.push_back( lead );}@@ -518,6 +550,16 @@ static void refresh( void )UnicodeString confirm;confirm.format( TheGameText->fetch( "GUI:FactionPickConfirm" ), name.str() );s_confirmText->setText( UIStyle::capitals( confirm ) );+ // "Contra - USA Air Force General" is wider than the button in the heading's letters+ const UIStyle::TextSize sizes[] = { UIStyle::TEXT_HEADING, UIStyle::TEXT_STRONG, UIStyle::TEXT_BODY };+ for( size_t each = 0; each < ARRAY_SIZE( sizes ); each++ )+ {+ s_confirmText->setFont( UIStyle::titleFont( sizes[ each ] ) );+ Int width, height;+ s_confirmText->getSize( &width, &height );+ if( width <= boxWidth( s_confirmBox ) - UIStyle::px( PAD ) )+ break;+ }}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cppindex 01694f14b..22d75f268 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameText.cpp@@ -175,7 +175,7 @@ class GameTextManager : public GameTextInterfaceprotected:- /// -modfactions: each mod's own labels (English CSF and STR), by mod index; empty without the switch+ /// -modfactions: each mod's own labels (English CSF and STR), by mod index; empty with no full -modstd::vector< ModStringTable > m_modStrings;/// each mod's CSF in the player's language, text only: never consulted for the label setstd::vector< ModStringTable > m_modLangStrings;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cppindex 96127976c..3ee028002 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp@@ -38,6 +38,7 @@#include "Common/AudioHandleSpecialValues.h"#include "Common/GameAudio.h"#include "Common/GameEngine.h"+#include "Common/INI.h"#include "Common/LogicThread.h"#include "Common/MapObject.h" // For MAP_XY_FACTOR#include "Common/PartitionSolver.h"@@ -3410,12 +3411,19 @@ void ScriptActions::doMusicTrackChange(const AsciiString& newTrackName, Bool fadTheAudio->removeAudioEvent(AHSV_StopTheMusic);}- AudioEventRTS event(newTrackName);+ // The scripts a human runs are retail's and name retail's tracks; on a mod's faction he hears that+ // mod's track of the name. Only this machine's music player reads the answer.+ const PlayerTemplate *localFaction = ThePlayerList->getLocalPlayer()->getPlayerTemplate();+ const AsciiString track = localFaction != NULL && localFaction->getModIndex() >= 0+ ? TheModNamespace.modName(localFaction->getModIndex(), MODNAME_AUDIOEVENT, newTrackName) : newTrackName;+ DEBUG_LOG(("MUSIC track %s\n", track.str()));++ AudioEventRTS event(track);event.setShouldFade(fadein);event.setPlayerIndex(ThePlayerList->getLocalPlayer()->getPlayerIndex());TheAudio->addAudioEvent(&event);- TheScriptEngine->setCurrentTrackName(newTrackName);+ TheScriptEngine->setCurrentTrackName(track);}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/RankInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/RankInfo.cppindex b43d77dcb..5b3e21206 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/RankInfo.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/RankInfo.cpp@@ -176,7 +176,7 @@ void RankInfoStore::friend_parseRankDefinition( INI* ini )}else{- // -modfactions: a mod's pass fills that mod's own table, its sciences already under its names+ // a mod's pass fills that mod's own table, its sciences already under its namesconst Int mod = TheModNamespace.getActive();if (mod >= 0 && (Int)TheRankInfoStore->m_modRankInfos.size() <= mod)TheRankInfoStore->m_modRankInfos.resize(mod + 1);diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cppindex 514981899..016fa4813 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp@@ -44,6 +44,8 @@#include "GameClient/GadgetPushButton.h"#include "GameClient/GameText.h"#include "GameClient/Display.h"+#include "GameClient/DisplayStringManager.h"+#include "GameClient/GameFont.h"#include "GameClient/Image.h"#include "GameClient/Mouse.h"#include "GameClient/UIStyle.h"@@ -311,6 +313,34 @@ void PopulateColorComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myG// -----------------------------------------------------------------------------+// a seat's Army field was cut for "China Tank General"; a mod's name in front of that runs into the arrow+static void shrinkComboToFit(GameWindow *combo, const UnicodeString &label)+{+ static const Int FIELD_MARGIN = 6;+ static const Int SMALLEST_POINT_SIZE = 8;++ GameWindow *field = GadgetComboBoxGetEditBox(combo);+ Int fieldWidth, fieldHeight;+ field->winGetSize(&fieldWidth, &fieldHeight);++ GameFont *fieldFont = field->winGetFont();+ GameFont *font = fieldFont;+ DisplayString *measured = TheDisplayStringManager->newDisplayString();+ measured->setFont(font);+ measured->setText(label);+ while (measured->getWidth() > fieldWidth - FIELD_MARGIN && font->pointSize > SMALLEST_POINT_SIZE)+ {+ font = TheFontLibrary->getFont(font->nameString, font->pointSize - 1, font->bold);+ measured->setFont(font);+ }+ TheDisplayStringManager->freeDisplayString(measured);++ if (font != fieldFont)+ GadgetComboBoxSetFont(combo, font);+}++// -----------------------------------------------------------------------------+void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], GameInfo *myGame, Bool allowObservers){Int numPlayerTemplates = ThePlayerTemplateStore->getPlayerTemplateCount();@@ -324,8 +354,18 @@ void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], Gamestd::set<AsciiString> seenSides;+ // retail's armies, then each mod's own block; the fork's own factions load after the mods' and still+ // belong with retail's+ std::vector<Int> order(numPlayerTemplates);for (Int c=0; c<numPlayerTemplates; ++c)+ order[c] = c;+ std::stable_sort(order.begin(), order.end(), [](Int a, Int b) {+ return ThePlayerTemplateStore->getNthPlayerTemplate(a)->getModIndex() < ThePlayerTemplateStore->getNthPlayerTemplate(b)->getModIndex();+ });++ for (Int n=0; n<numPlayerTemplates; ++n){+ const Int c = order[n];const PlayerTemplate *fac = ThePlayerTemplateStore->getNthPlayerTemplate(c);if (!fac)continue;@@ -348,7 +388,7 @@ void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], GameAsciiString side;side.format("SIDE:%s", fac->getSide().str());- // -modfactions: each mod's America is a side of its own, "<mod name> - USA"+ // each mod's America is a side of its own, "<mod name> - USA"AsciiString seenKey;seenKey.format("%d:%s", fac->getModIndex(), side.str());if (seenSides.find(seenKey) != seenSides.end())@@ -375,6 +415,7 @@ void PopulatePlayerTemplateComboBox(Int comboBox, GameWindow *comboArray[], Gamelabel = UnicodeString(modName);label.concat(UnicodeString(u" - "));label.concat(sideLabel);+ shrinkComboToFit(comboArray[comboBox], label);}newIndex = GadgetComboBoxAddEntry(comboArray[comboBox], label, def->getColor());GadgetComboBoxSetItemData(comboArray[comboBox], newIndex, (void *)(intptr_t)c);diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cppindex d1c2c8d90..261b05cc3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp@@ -266,7 +266,10 @@ Bool LANAPI::StartAutomatedGame( AsciiString mapName, Int seed, const UnsignedInslot.setState( (SlotState)TheGlobalData->m_autoSkirmishAIState );slot.setAIPersonality( TheGlobalData->autoSkirmishPersona( i ) );}- slot.setPlayerTemplate( PLAYERTEMPLATE_RANDOM );+ // -side names a seat's army here too, the same words on every machine; a name nobody knows is a+ // random draw, which then shows in the run's own log+ const Int named = TheGlobalData->m_autoSkirmishSide[ i ].isEmpty() ? -1 : ThePlayerTemplateStore->getTemplateNumByName( TheGlobalData->m_autoSkirmishSide[ i ] );+ slot.setPlayerTemplate( named >= 0 ? named : PLAYERTEMPLATE_RANDOM );slot.setColor( -1 ); // -1 is "random" to populateRandomSideAndColorslot.setStartPos( -1 ); // and to populateRandomStartPositionslot.setTeamNumber( teamNumber );diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.hindex d85fa60dd..25869ce55 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DModelDraw.h@@ -364,7 +364,7 @@ public:virtual void doDrawModule(const Matrix3D* transformMtx);virtual void buildRenderObjects( Bool madeInTick );- /// the name the render object was made from; under -modfactions it keeps the "M<n>~" its Get_Name drops+ /// the name the render object was made from; under a mod it keeps the "M<n>~" its Get_Name dropsconst AsciiString& getCurrentModelName() const { return m_curState->m_modelName; }/// Hands the frame's lit headlights to the Direct3D 11 frame, nearest the camera first. Once a/// frame, after the smooth motion has placed every model and before anything is drawn.diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex ae2086e3f..1858de719 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -20504,6 +20504,15 @@ TEST(modfactions_ai_side_lookups_take_the_mods_own_first)CHECK( data.findBuildList( AsciiString( "Russia" ), -1 ) == NULL );}+// A plain Random stays with retail's armies under any mod: a mod's faction plays only when it is picked+TEST(modfactions_stay_out_of_a_plain_random)+{+ PlayerTemplate faction;+ CHECK( !faction.isRandomExcluded() );+ faction.setModIndex( 0 );+ CHECK( faction.isRandomExcluded() );+}+// -modfactions: which skirmish player's scripts a computer player runs. Its own mod's of its side// beats retail's, retail's stands in for a mod without any, and another mod's never fitsTEST(modfactions_skirmish_side_fit)diff --git a/README.md b/README.mdindex 048dc52eb..60df5c3d9 100644--- a/README.md+++ b/README.md@@ -170,7 +170,7 @@ own date-and-time name.| What | Since ||:--|:--|-| `-mod <folder>` loads a mod's archives and its loose `Data` and `Art` files; give it once per mod, and the one named later wins | 3.0.0 |+| `-mod <folder>` loads a mod's archives and its loose `Data` and `Art` files; give it once per mod, and each mod's armies stand beside Zero Hour's | 3.0.0 || `-modfactions` puts two total conversions in one match, each army building from its own mod's units | 3.0.0 || `-modpatch <folder>` after a mod changes that mod and leaves the others alone | 3.0.0 || A `mod.json` names the mod and its version, and the names go into every replay | 3.0.0 |@@ -259,7 +259,7 @@ Discs carry 1.00 and the engine is 1.04's, so files from a 1.04 install (Steam,| `-xres <w>` `-yres <h>` | the resolution for this run || `-msaa [N]` | multisampling; bare is 4x, a number asks for N from 2 to 16 || `-language english\|turkish\|german` | the language for this run, over the one Options saved |-| `-mod <folder>` | loads a mod; repeat it for several, the later one wins |+| `-mod <folder>` | loads a mod's armies beside Zero Hour's as their own lobby entries; repeat it for several || `-modpatch <folder>` | a patch for the mod given before it, or for Zero Hour's files when it comes first || `-modfactions` | each mod's armies join Zero Hour's instead of replacing them || `-replay <name>` | opens a replay from the replay folder, extension optional |