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.

feat(gameengine): pro rules 1 to 11 behind a lobby check box

Olcay Seygancc7b7b305ec6
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e0be34135..e3b229599 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -479,6 +479,19 @@ found and fixed — EA's own, not port damage.**
- The USA Superweapon General is the exception to both, because the rule that reads as a handicap to everyone else reads as a deletion to him: three superweapons of his own are what he pays for weaker tanks, weaker infantry and a worse air force with. Under Limit he keeps four of each of his. Under No he keeps one. Play him against a lobby that has banned superweapons and you are playing the army you paid for, not an empty base.
- The tick box was one number for everybody, which is why it could only ever say yes or no. A ticked box in a settings file from an older build reads back as No Superweapons.
+## Pro Rules, in every skirmish and network game
+
+- A fixed list of units, upgrades and tricks is out of every skirmish, LAN and online match. There is no warning and no penalty after the fact: the button is grey and it stays grey. The campaign and the Generals Challenge play the way they always did.
+- It is one box on the lobby settings page, Pro Rules, ticked unless the host clears it. The host's choice goes to everyone in the room and into the replay, and the lobby remembers it for next time. A host on an older build has no box to send, so that game plays without the list.
+- No Particle Cannon and no SCUD Storm. The USA Superweapon General keeps one Particle Cannon, because a general who paid for his superweapons with a weaker army and then may not build any is playing half a faction.
+- The Nuclear Missile silo still goes up, since it is where China buys Nuclear Tanks and Uranium Shells. The missile inside it never launches, and nobody's screen counts down to it.
+- No Aurora Bomber, the Air Force General's Alpha Aurora included, and no Tactical Nuke upgrade for the Nuke General's MiGs.
+- No demo bike. A terrorist cannot climb onto a Combat Cycle any more; a rebel, a worker, a hijacker or Jarmen Kell still can.
+- A Microwave Tank cannot freeze a building that is still going up. There is nothing for it to fire at until the scaffold is finished, so parking one beside a half-built base no longer keeps it half built.
+- No foundation goes down closer to an enemy building than 300, a margin past the 225 a Patriot battery or a Stinger Site reaches on the ground. That ends walling somebody's base in with scaffolds nobody means to finish, and it ends building a tower in their yard too. The placement ghost says why it is red.
+- The computer opponent is held to the same list, because it asks the same question your build buttons ask before it spends a dollar.
+- With these rules on, the superweapon dropdown above decides one thing: how many Nuclear Missile silos a player may have standing.
+
## Two windows, one machine, a real LAN game
- You can start the game twice on one computer and play the two copies against each other over the LAN screen, the ordinary way: one hosts, picks a map and starts, the other finds the game in the list and joins. Faction, colour and team per slot as always. It is how a network change gets tested here, and it is how two people sharing a desk can play a match without a second machine.
diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.str
index 35a250448..e3b65ccc8 100644
--- a/GeneralsMD/Code/Data/Patch.str
+++ b/GeneralsMD/Code/Data/Patch.str
@@ -828,3 +828,16 @@ END
TOOLTIP:UnitLimit
"840 units shared out evenly between the players: two players get 420 each, eight get 105. Units standing and units waiting in a queue both count, buildings do not. Your own count and your share are in the top right corner during the match."
END
+
+GUI:ProRules
+"Pro Rules"
+END
+
+TOOLTIP:ProRules
+"The tournament list. No Particle Cannon or SCUD Storm, except the Superweapon General's one cannon. The Nuclear Missile silo goes up but never fires. No Aurora, no Tactical Nuke MiGs, no demo bike. A Microwave Tank cannot freeze a building still going up, and nobody builds within 300 of an enemy building."
+END
+
+// Pro Rules, rule 9: no foundation within reach of an enemy building
+GUI:CantBuildTooCloseToEnemy
+"Can't build this close to an enemy building."
+END
diff --git a/GeneralsMD/Code/Data/Window/Menus/GameSpyGameOptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/GameSpyGameOptionsMenu.wnd
index f08e53c94..8fc3d2f61 100644
--- a/GeneralsMD/Code/Data/Window/Menus/GameSpyGameOptionsMenu.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/GameSpyGameOptionsMenu.wnd
@@ -11122,7 +11122,7 @@ WINDOW
CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
- SCREENRECT = UPPERLEFT: 500 356, BOTTOMRIGHT: 660 380, CREATIONRESOLUTION: 800 600;
+ SCREENRECT = UPPERLEFT: 500 352, BOTTOMRIGHT: 660 376, CREATIONRESOLUTION: 800 600;
NAME = "GameSpyGameOptionsMenu.wnd:CheckBoxUseStats";
STATUS = ENABLED+IMAGE+BORDER;
STYLE = CHECKBOX+MOUSETRACK;
@@ -11169,7 +11169,7 @@ WINDOW
CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
- SCREENRECT = UPPERLEFT: 500 388, BOTTOMRIGHT: 660 412, CREATIONRESOLUTION: 800 600;
+ SCREENRECT = UPPERLEFT: 500 380, BOTTOMRIGHT: 660 404, CREATIONRESOLUTION: 800 600;
NAME = "GameSpyGameOptionsMenu.wnd:CheckBoxLimitArmies";
STATUS = ENABLED+IMAGE;
STYLE = CHECKBOX+MOUSETRACK;
@@ -11216,7 +11216,54 @@ WINDOW
CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
- SCREENRECT = UPPERLEFT: 500 420, BOTTOMRIGHT: 660 444, CREATIONRESOLUTION: 800 600;
+ SCREENRECT = UPPERLEFT: 500 436, BOTTOMRIGHT: 660 460, CREATIONRESOLUTION: 800 600;
+ NAME = "GameSpyGameOptionsMenu.wnd:CheckBoxProRules";
+ STATUS = ENABLED+IMAGE;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;
+ HEADERTEMPLATE = "TextEntry";
+ TOOLTIPTEXT = "TOOLTIP:ProRules";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:ProRules";
+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 140 138 138 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 128 128 255 255, HILITEBORDER: 0 0 128 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 500 408, BOTTOMRIGHT: 660 432, CREATIONRESOLUTION: 800 600;
NAME = "GameSpyGameOptionsMenu.wnd:CheckBoxUnitLimit";
STATUS = ENABLED+IMAGE;
STYLE = CHECKBOX+MOUSETRACK;
diff --git a/GeneralsMD/Code/Data/Window/Menus/LanGameOptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/LanGameOptionsMenu.wnd
index fc21083bd..f993f42bd 100644
--- a/GeneralsMD/Code/Data/Window/Menus/LanGameOptionsMenu.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/LanGameOptionsMenu.wnd
@@ -10201,6 +10201,53 @@ WINDOW
IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
END
CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 600 404, BOTTOMRIGHT: 728 428, CREATIONRESOLUTION: 800 600;
+ NAME = "LanGameOptionsMenu.wnd:CheckBoxProRules";
+ STATUS = ENABLED+IMAGE;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;
+ HEADERTEMPLATE = "TextEntry";
+ TOOLTIPTEXT = "TOOLTIP:ProRules";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:ProRules";
+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 140 138 138 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 128 128 255 255, HILITEBORDER: 0 0 128 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
SCREENRECT = UPPERLEFT: 336 436, BOTTOMRIGHT: 584 460, CREATIONRESOLUTION: 800 600;
diff --git a/GeneralsMD/Code/Data/Window/Menus/SkirmishGameOptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/SkirmishGameOptionsMenu.wnd
index 17cc2fbe2..0b1e50fbb 100644
--- a/GeneralsMD/Code/Data/Window/Menus/SkirmishGameOptionsMenu.wnd
+++ b/GeneralsMD/Code/Data/Window/Menus/SkirmishGameOptionsMenu.wnd
@@ -9899,6 +9899,53 @@ WINDOW
IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
END
CHILD
+ WINDOW
+ WINDOWTYPE = CHECKBOX;
+ SCREENRECT = UPPERLEFT: 336 468, BOTTOMRIGHT: 536 492, CREATIONRESOLUTION: 800 600;
+ NAME = "SkirmishGameOptionsMenu.wnd:CheckBoxProRules";
+ STATUS = ENABLED+IMAGE;
+ STYLE = CHECKBOX+MOUSETRACK;
+ SYSTEMCALLBACK = "[None]";
+ INPUTCALLBACK = "[None]";
+ TOOLTIPCALLBACK = "[None]";
+ DRAWCALLBACK = "[None]";
+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;
+ HEADERTEMPLATE = "TextEntry";
+ TOOLTIPTEXT = "TOOLTIP:ProRules";
+ TOOLTIPDELAY = -1;
+ TEXT = "GUI:ProRules";
+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,
+ DISABLED: 140 138 138 255, DISABLEDBORDER: 64 64 64 255,
+ HILITE: 128 128 255 255, HILITEBORDER: 0 0 128 255;
+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,
+ IMAGE: Active-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 0 0 255 255, BORDERCOLOR: 128 128 255 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Unchecked, COLOR: 255 255 255 0, BORDERCOLOR: 192 192 192 255,
+ IMAGE: Disabled-Checked, COLOR: 64 64 64 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 128 255 128 255,
+ IMAGE: Active-HiLighted, COLOR: 255 255 255 0, BORDERCOLOR: 128 128 255 255,
+ IMAGE: Active-Checked, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,
+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;
+ END
+ CHILD
WINDOW
WINDOWTYPE = CHECKBOX;
SCREENRECT = UPPERLEFT: 336 436, BOTTOMRIGHT: 536 460, CREATIONRESOLUTION: 800 600;
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/BuildAssistant.h b/GeneralsMD/Code/GameEngine/Include/Common/BuildAssistant.h
index 35a0eb0a7..ef0e84ff5 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/BuildAssistant.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/BuildAssistant.h
@@ -96,6 +96,7 @@ enum LegalBuildCode
LBC_SHROUD,
LBC_TOO_CLOSE_TO_SUPPLIES,
LBC_GENERIC_FAILURE,
+ LBC_TOO_CLOSE_TO_ENEMY, ///< Pro Rules: within PRO_RULES_ENEMY_STRUCTURE_CLEARANCE of an enemy building
};
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Player.h b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
index d3972b58f..1fb9f51c8 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/Player.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/Player.h
@@ -126,6 +126,21 @@ Int SuperweaponBuildCap( Int restriction, const AsciiString &playerTemplateName
enum { UNIT_LIMIT_TOTAL = 840 };
Int UnitLimitPerPlayer( Int nonObserverPlayers );
+// Pro Rules, PRO-RULES.md: what every skirmish and network match refuses whoever plays it.
+// GameLogic::isProRules() says whether a match is under them; these say what they cover, by name
+// or by type, so a test can ask them without a match.
+enum SpecialPowerType;
+Bool ProRulesBanThing( const AsciiString &templateName );
+Bool ProRulesExemptSuperweapon( const AsciiString &templateName );
+Bool ProRulesBanUpgrade( const AsciiString &upgradeName );
+Bool ProRulesBanSpecialPower( SpecialPowerType specialPowerType );
+Bool ProRulesBanRider( const AsciiString &riderTemplateName );
+
+// Rule 9: no foundation this close to an enemy building, edge to edge. The same 300 world units
+// the derrick cluster rules measure with, which is also more than a Patriot or a Stinger Site
+// reaches on the ground, so a scaffold wall cannot be laid under an enemy's own defences.
+enum { PRO_RULES_ENEMY_STRUCTURE_CLEARANCE = 300 };
+
static const Int NUM_HOTKEY_SQUADS = 10;
enum { NO_HOTKEY_SQUAD = -1 };
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h
index 5925e9d6b..16a0c5884 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/GameLogic.h
@@ -262,6 +262,11 @@ public:
limit is off, which is every campaign mission and every game it was not ticked for. */
UnsignedInt getUnitCap( void ) const { return m_unitCap; }
+ /** Whether this match is played under Pro Rules (PRO-RULES.md): a skirmish, LAN or online game
+ whose lobby box is ticked, never a campaign mission or a Generals Challenge. Fixed when the match starts and
+ carried by a save, so a loaded game agrees with the one that was saved. */
+ Bool isProRules( void ) const { return m_proRules; }
+
#ifdef DUMP_PERF_STATS
void getAIMetricsStatistics( UnsignedInt *numAI, UnsignedInt *numMoving, UnsignedInt *numAttacking, UnsignedInt *numWaitingForPath, UnsignedInt *overallFailedPathfinds );
void resetOverallFailedPathfinds() { m_overallFailedPathfinds = 0; }
@@ -379,6 +384,7 @@ private:
UnsignedShort m_superweaponRestriction;
UnsignedInt m_peaceTimeEndFrame; ///< logic frame the lobby's peace time runs out on, 0 = no peace time
UnsignedInt m_unitCap; ///< units each player may have standing and queued, 0 = no limit
+ Bool m_proRules; ///< this match refuses what PRO-RULES.md bans
LoadScreen *getLoadScreen( Bool loadSaveGame );
LoadScreen *m_loadScreen;
diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h
index f2b40a1cb..c8817bbfe 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GUIUtil.h
@@ -84,6 +84,8 @@ Int SuperweaponRestrictionFromComboBox(GameWindow *comboBox);
// UpdateUnitLimitCheckBox puts the box on what the game says and greys it out for anyone who may not
// touch it, and it only sets the box when the box is wrong.
void UpdateUnitLimitCheckBox(GameWindow *checkBox, GameInfo *myGame, Bool hostMayEdit);
+// The Pro Rules check box, the same thing for PR.
+void UpdateProRulesCheckBox(GameWindow *checkBox, GameInfo *myGame, Bool hostMayEdit);
// The lobby's own tab strip: one page of host settings, and the window that page covers - the chat
// log in the two network lobbies, the map info list in the skirmish one. All three screens share
diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h
index 062e02f63..d3d3d5fb0 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h
@@ -250,6 +250,11 @@ public:
inline Bool getUnitLimit( void ) const;
void setUnitLimit( Bool unitLimit );
+ // The lobby's Pro Rules check box (PRO-RULES.md, the list ProRulesBanThing and its neighbours in
+ // Player.h hold). On is the default for a lobby this build made; a host too old to send it is off.
+ inline Bool getProRules( void ) const;
+ void setProRules( Bool proRules );
+
Bool hasAIPlayers( void ) const; ///< is any slot held by a computer player?
protected:
@@ -275,6 +280,7 @@ protected:
Bool m_oldFactionsOnly; // Only USA, China, GLA -- not USA Air Force General, GLA Toxic General, et al
Int m_peaceTime; // minutes of enforced peace at the start of the match, 0 = off
Bool m_unitLimit; // the lobby's unit limit is on
+ Bool m_proRules; // the lobby's Pro Rules are on
};
extern GameInfo *TheGameInfo;
@@ -304,6 +310,7 @@ void GameInfo::setOldFactionsOnly( Bool oldFactionsOnly ) { m_oldFactions
bot back out and it is still there. */
Int GameInfo::getPeaceTime( void ) const { return hasAIPlayers() ? 0 : m_peaceTime; }
Bool GameInfo::getUnitLimit( void ) const { return m_unitLimit; }
+Bool GameInfo::getProRules( void ) const { return m_proRules; }
AsciiString GameInfoToAsciiString( const GameInfo *game );
Bool ParseAsciiStringToGameInfo( GameInfo *game, AsciiString options );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index fea0545dd..857347d2d 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -2997,6 +2997,48 @@ Int UnitLimitPerPlayer( Int nonObserverPlayers )
return nonObserverPlayers > 1 ? UNIT_LIMIT_TOTAL / nonObserverPlayers : UNIT_LIMIT_TOTAL;
}
+//=============================================================================
+/* Pro Rules. A general's copy of a unit is the faction's name with a prefix (SupW_, AirF_,
+ Lazr_, Demo_), so a rule names the ending every copy shares. The Air Force General's Alpha
+ Aurora is AirF_AmericaJetAurora, which is why rules 4 and 5 are one ending. */
+static const char theProRulesAuroraSuffix[] = "JetAurora";
+static const char theProRulesNukeSiloSuffix[] = "NuclearMissileLauncher";
+static const char theProRulesTacticalNukeMigUpgrade[] = "Upgrade_ChinaTacticalNukeMig";
+static const char theProRulesTerroristSuffix[] = "InfantryTerrorist";
+
+// rules 4 and 5
+Bool ProRulesBanThing( const AsciiString &templateName )
+{
+ return templateName.endsWithNoCase( theProRulesAuroraSuffix );
+}
+
+// Rule 11: the silo is built for the Nuclear Tanks and Uranium Shells upgrades it sells, so the
+// building keeps the lobby's superweapon rule and only its missile is refused.
+Bool ProRulesExemptSuperweapon( const AsciiString &templateName )
+{
+ return templateName.endsWithNoCase( theProRulesNukeSiloSuffix );
+}
+
+// rule 6
+Bool ProRulesBanUpgrade( const AsciiString &upgradeName )
+{
+ return upgradeName.compareNoCase( theProRulesTacticalNukeMigUpgrade ) == 0;
+}
+
+// rule 2, the silo's missile, which each China general and the Superweapon General fire as a type of their own
+Bool ProRulesBanSpecialPower( SpecialPowerType specialPowerType )
+{
+ return specialPowerType == SPECIAL_NEUTRON_MISSILE
+ || specialPowerType == NUKE_SPECIAL_NEUTRON_MISSILE
+ || specialPowerType == SUPW_SPECIAL_NEUTRON_MISSILE;
+}
+
+// rule 7, the demo bike: a combat cycle with a terrorist in the saddle
+Bool ProRulesBanRider( const AsciiString &riderTemplateName )
+{
+ return riderTemplateName.endsWithNoCase( theProRulesTerroristSuffix );
+}
+
//=============================================================================
/* What the unit limit counts: infantry, vehicles and aircraft. A structure is not a unit, and
neither is a drone or a projectile - those arrive with their owner or out of a weapon, nobody
@@ -3045,13 +3087,23 @@ Bool Player::canBuildMoreOfType( const ThingTemplate *whatToBuild ) const
if ( unitCap > 0 && isUnitTowardCap( whatToBuild ) && (UnsignedInt)countUnitsTowardCap() >= unitCap )
return false;
+ // Pro Rules refuse a banned unit outright, through the same door
+ const Bool proRules = TheGameLogic && TheGameLogic->isProRules();
+ if ( proRules && ProRulesBanThing( whatToBuild->getName() ) )
+ return false;
+
// make sure we're not maxed out for this type of unit.
UnsignedInt maxSimultaneousOfType = whatToBuild->getMaxSimultaneousOfType();
if ( whatToBuild->isMaxSimultaneousFromSuperweaponRestriction() )
{
- const Int restriction = TheGameLogic ? (Int)TheGameLogic->getSuperweaponRestriction()
- : (Int)SUPERWEAPONS_ALLOW;
+ Int restriction = TheGameLogic ? (Int)TheGameLogic->getSuperweaponRestriction()
+ : (Int)SUPERWEAPONS_ALLOW;
+ // Rules 1, 3 and 10: under Pro Rules the Particle Cannon and the SCUD Storm are No Superweapons
+ // whatever the lobby picked, which leaves the Superweapon General his one cannon and nobody
+ // else anything. The silo is rule 11's and keeps the lobby's pick.
+ if ( proRules && !ProRulesExemptSuperweapon( whatToBuild->getName() ) )
+ restriction = SUPERWEAPONS_NONE;
const AsciiString templateName =
getPlayerTemplate() ? getPlayerTemplate()->getName() : AsciiString::TheEmptyString;
const Int cap = SuperweaponBuildCap( restriction, templateName );
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
index 5b5cd3741..2d3a9c17f 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
@@ -45,6 +45,7 @@
#include "GameClient/InGameUI.h"
#include "GameClient/TerrainVisual.h"
#include "GameLogic/AI.h"
+#include "GameLogic/GameLogic.h"
#include "GameLogic/PartitionManager.h"
#include "GameLogic/TerrainLogic.h"
#include "GameLogic/AIPathfind.h"
@@ -1083,6 +1084,30 @@ LegalBuildCode BuildAssistant::isLocationLegalToBuild( const Coord3D *worldPos,
} // end if
+ //
+ // Rule 9 of Pro Rules: no foundation within reach of an enemy building, which is what a scaffold
+ // wall across somebody's base is made of. Last, because the computer player tries thousands of
+ // spots a frame and only the ones every other check passed should pay for a range query.
+ //
+ const Player *owner = builderObject ? builderObject->getControllingPlayer() : player;
+ if( TheGameLogic->isProRules() && owner && build->isKindOf( KINDOF_STRUCTURE ) )
+ {
+ PartitionFilterAcceptByKindOf structures( MAKE_KINDOF_MASK( KINDOF_STRUCTURE ), KINDOFMASK_NONE );
+ PartitionFilter *filters[] = { &structures, NULL };
+
+ Real range = build->getTemplateGeometryInfo().getBoundingCircleRadius() + PRO_RULES_ENEMY_STRUCTURE_CLEARANCE;
+ ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange( worldPos, range, FROM_BOUNDINGSPHERE_2D, filters );
+ MemoryPoolObjectHolder hold( iter );
+ for( Object *them = iter->first(); them; them = iter->next() )
+ {
+ // The relationship is asked here rather than through PartitionFilterPlayerAffiliation, which
+ // lets a player's own objects through whatever it is asked for - and the first building near
+ // any spot in a base is that base's own command center, so every base refused itself.
+ if( owner->getRelationship( them->getTeam() ) == ENEMIES )
+ return LBC_TOO_CLOSE_TO_ENEMY;
+ }
+ }
+
// we passed all the checks
return LBC_OK;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
index 40d1953a0..78f3ec993 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Upgrade.cpp
@@ -34,6 +34,7 @@
#include "Common/Upgrade.h"
#include "Common/Player.h"
#include "Common/Xfer.h"
+#include "GameLogic/GameLogic.h"
#include "GameClient/InGameUI.h"
#include "GameClient/Image.h"
@@ -437,6 +438,11 @@ Bool UpgradeCenter::canAffordUpgrade( Player *player, const UpgradeTemplate *upg
if( player == NULL || upgradeTemplate == NULL )
return FALSE;
+ // Pro Rules: a banned upgrade is off the table whatever it costs. The command bar, the queue and
+ // the computer player's build list all ask here before they buy
+ if( TheGameLogic->isProRules() && ProRulesBanUpgrade( upgradeTemplate->getUpgradeName() ) )
+ return FALSE;
+
// money check
Money *money = player->getMoney();
if( money->countMoney() < upgradeTemplate->calcCostToBuild( player ) )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
index 56eb60965..3747c71a1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
@@ -1633,6 +1633,10 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *com
GadgetButtonSetSeconds( applyToWin, ControlBar_secondsFromFrames( frames ) );
}
+ // Pro Rules: the power is there and the button stays dead
+ if( TheGameLogic->isProRules() && ProRulesBanSpecialPower( command->getSpecialPowerTemplate()->getSpecialPowerType() ) )
+ return COMMAND_RESTRICTED;
+
if( mod->isReady() == FALSE )
{
Int percent = mod->getPercentReady() * 100;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp
index 2be400b5e..858c8b620 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/LanGameOptionsMenu.cpp
@@ -122,6 +122,7 @@ static NameKeyType comboBoxSuperweaponsID = NAMEKEY_INVALID;
static NameKeyType comboBoxStartingCashID = NAMEKEY_INVALID;
static NameKeyType comboBoxPeaceTimeID = NAMEKEY_INVALID;
static NameKeyType checkBoxUnitLimitID = NAMEKEY_INVALID;
+static NameKeyType checkBoxProRulesID = NAMEKEY_INVALID;
static NameKeyType windowMapID = NAMEKEY_INVALID;
// Window Pointers ------------------------------------------------------------------------
static GameWindow *parentLanGameOptions = NULL;
@@ -135,6 +136,7 @@ static GameWindow *comboBoxSuperweapons = NULL;
static GameWindow *comboBoxStartingCash = NULL;
static GameWindow *comboBoxPeaceTime = NULL;
static GameWindow *checkBoxUnitLimit = NULL;
+static GameWindow *checkBoxProRules = NULL;
static GameWindow *windowMap = NULL;
static GameWindow *comboBoxPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL,
@@ -663,6 +665,24 @@ static void handlePeaceTimeSelection()
}
}
+static void handleProRulesSelection()
+{
+ LANGameInfo *myGame = TheLAN->GetMyGame();
+
+ // the same guard as the unit limit box below
+ if (myGame == NULL || checkBoxProRules == NULL || myGame->getProRules() == GadgetCheckBoxIsChecked( checkBoxProRules ))
+ return;
+
+ myGame->setProRules( GadgetCheckBoxIsChecked( checkBoxProRules ) );
+ myGame->resetAccepted();
+
+ if (myGame->amIHost() && !s_isIniting)
+ {
+ TheLAN->RequestGameOptions(GenerateGameOptionsString(), true);
+ lanUpdateSlotList(); // Update the accepted button UI
+ }
+}
+
static void handleUnitLimitSelection()
{
LANGameInfo *myGame = TheLAN->GetMyGame();
@@ -730,6 +750,7 @@ void InitLanGameGadgets( void )
comboBoxStartingCashID = TheNameKeyGenerator->nameToKey( AsciiString( "LanGameOptionsMenu.wnd:ComboBoxStartingCash" ) );
comboBoxPeaceTimeID = TheNameKeyGenerator->nameToKey( AsciiString( "LanGameOptionsMenu.wnd:ComboBoxPeaceTime" ) );
checkBoxUnitLimitID = TheNameKeyGenerator->nameToKey( AsciiString( "LanGameOptionsMenu.wnd:CheckBoxUnitLimit" ) );
+ checkBoxProRulesID = TheNameKeyGenerator->nameToKey( AsciiString( "LanGameOptionsMenu.wnd:CheckBoxProRules" ) );
windowMapID = TheNameKeyGenerator->nameToKey( AsciiString( "LanGameOptionsMenu.wnd:MapWindow" ) );
// Initialize the pointers to our gadgets
@@ -768,6 +789,10 @@ void InitLanGameGadgets( void )
DEBUG_ASSERTCRASH(checkBoxUnitLimit, ("Could not find the checkBoxUnitLimit"));
if (checkBoxUnitLimit)
UpdateUnitLimitCheckBox(checkBoxUnitLimit, TheLAN->GetMyGame(), TheLAN->AmIHost());
+ checkBoxProRules = TheWindowManager->winGetWindowFromId( parentLanGameOptions, checkBoxProRulesID );
+ DEBUG_ASSERTCRASH(checkBoxProRules, ("Could not find the checkBoxProRules"));
+ if (checkBoxProRules)
+ UpdateProRulesCheckBox(checkBoxProRules, TheLAN->GetMyGame(), TheLAN->AmIHost());
windowMap = TheWindowManager->winGetWindowFromId( parentLanGameOptions,windowMapID );
DEBUG_ASSERTCRASH(windowMap, ("Could not find the LanGameOptionsMenu.wnd:MapWindow" ));
@@ -871,6 +896,7 @@ void DeinitLanGameGadgets( void )
comboBoxStartingCash = NULL;
comboBoxPeaceTime = NULL;
checkBoxUnitLimit = NULL;
+ checkBoxProRules = NULL;
windowMap = NULL;
for (Int i = 0; i < MAX_SLOTS; i++)
{
@@ -927,6 +953,7 @@ void LanGameOptionsMenuInit( WindowLayout *layout, void *userData )
game->setStartingCash( pref.getStartingCash() );
game->setSuperweaponRestriction( pref.getSuperweaponRestriction() );
game->setUnitLimit( pref.getInt( "UnitLimit", 0 ) != 0 );
+ game->setProRules( pref.getInt( "ProRules", 1 ) != 0 );
AsciiString lowerMap = pref.getPreferredMap();
lowerMap.toLower();
std::map<AsciiString, MapMetaData>::iterator it = TheMapCache->find(lowerMap);
@@ -1048,6 +1075,8 @@ void updateGameOptions( void )
UpdatePeaceTimeComboBox( comboBoxPeaceTime, theGame, TheLAN->AmIHost() );
if (checkBoxUnitLimit)
UpdateUnitLimitCheckBox( checkBoxUnitLimit, theGame, TheLAN->AmIHost() );
+ if (checkBoxProRules)
+ UpdateProRulesCheckBox( checkBoxProRules, theGame, TheLAN->AmIHost() );
}
}
@@ -1284,6 +1313,12 @@ WindowMsgHandledType LanGameOptionsMenuSystem( GameWindow *window, UnsignedInt m
break;
}
+ if ( controlID == checkBoxProRulesID )
+ {
+ handleProRulesSelection();
+ break;
+ }
+
if ( LobbyTabClicked( (NameKeyType)controlID ) )
break;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp
index 4ca45c5ee..b692e12ec 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp
@@ -121,6 +121,7 @@ static NameKeyType staticTextGameSpeedID = NAMEKEY_INVALID;
static NameKeyType comboBoxSuperweaponsID = NAMEKEY_INVALID;
static NameKeyType comboBoxStartingCashID = NAMEKEY_INVALID;
static NameKeyType checkBoxUnitLimitID = NAMEKEY_INVALID;
+static NameKeyType checkBoxProRulesID = NAMEKEY_INVALID;
// Window Pointers ------------------------------------------------------------------------
static GameWindow *staticTextGameSpeed = NULL;
@@ -135,6 +136,7 @@ static GameWindow *textEntryPlayerName = NULL;
static GameWindow *comboBoxSuperweapons = NULL;
static GameWindow *comboBoxStartingCash = NULL;
static GameWindow *checkBoxUnitLimit = NULL;
+static GameWindow *checkBoxProRules = NULL;
static GameWindow *comboBoxPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL };
@@ -366,6 +368,7 @@ Bool SkirmishPreferences::write(void)
setStartingCash( TheSkirmishGameInfo->getStartingCash() );
setSuperweaponRestriction( TheSkirmishGameInfo->getSuperweaponRestriction() );
setInt( "UnitLimit", TheSkirmishGameInfo->getUnitLimit() ? 1 : 0 );
+ setInt( "ProRules", TheSkirmishGameInfo->getProRules() ? 1 : 0 );
setSlotList();
@@ -1085,6 +1088,7 @@ void InitSkirmishGameGadgets( void )
comboBoxSuperweaponsID = TheNameKeyGenerator->nameToKey( AsciiString( "SkirmishGameOptionsMenu.wnd:ComboBoxSuperweapons" ) );
comboBoxStartingCashID = TheNameKeyGenerator->nameToKey( AsciiString( "SkirmishGameOptionsMenu.wnd:ComboBoxStartingCash" ) );
checkBoxUnitLimitID = TheNameKeyGenerator->nameToKey( AsciiString( "SkirmishGameOptionsMenu.wnd:CheckBoxUnitLimit" ) );
+ checkBoxProRulesID = TheNameKeyGenerator->nameToKey( AsciiString( "SkirmishGameOptionsMenu.wnd:CheckBoxProRules" ) );
// Initialize the pointers to our gadgets
parentSkirmishGameOptions = TheWindowManager->winGetWindowFromId( NULL, parentSkirmishGameOptionsID );
@@ -1113,6 +1117,10 @@ void InitSkirmishGameGadgets( void )
DEBUG_ASSERTCRASH(checkBoxUnitLimit, ("Could not find the checkBoxUnitLimit"));
if ( checkBoxUnitLimit )
UpdateUnitLimitCheckBox( checkBoxUnitLimit, TheSkirmishGameInfo, TRUE );
+ checkBoxProRules = TheWindowManager->winGetWindowFromId( parentSkirmishGameOptions, checkBoxProRulesID );
+ DEBUG_ASSERTCRASH(checkBoxProRules, ("Could not find the checkBoxProRules"));
+ if ( checkBoxProRules )
+ UpdateProRulesCheckBox( checkBoxProRules, TheSkirmishGameInfo, TRUE );
textEntryPlayerNameID = TheNameKeyGenerator->nameToKey( AsciiString( "SkirmishGameOptionsMenu.wnd:TextEntryPlayerName" ) );
textEntryPlayerName = TheWindowManager->winGetWindowFromId( NULL, textEntryPlayerNameID );
@@ -1287,6 +1295,8 @@ void updateSkirmishGameOptions( void )
UpdateSuperweaponComboBox( comboBoxSuperweapons, TheSkirmishGameInfo, TRUE );
if ( checkBoxUnitLimit )
UpdateUnitLimitCheckBox( checkBoxUnitLimit, TheSkirmishGameInfo, TRUE );
+ if ( checkBoxProRules )
+ UpdateProRulesCheckBox( checkBoxProRules, TheSkirmishGameInfo, TRUE );
Int itemCount = GadgetComboBoxGetLength(comboBoxStartingCash);
for ( Int index = 0; index < itemCount; index++ )
{
@@ -1371,6 +1381,7 @@ void SkirmishGameOptionsMenuInit( WindowLayout *layout, void *userData )
TheSkirmishGameInfo->setStartingCash( prefs.getStartingCash() );
TheSkirmishGameInfo->setSuperweaponRestriction( prefs.getSuperweaponRestriction() );
TheSkirmishGameInfo->setUnitLimit( prefs.getInt( "UnitLimit", 0 ) != 0 );
+ TheSkirmishGameInfo->setProRules( prefs.getInt( "ProRules", 1 ) != 0 );
TheSkirmishGameInfo->setMap(prefs.getPreferredMap());
const MapMetaData *md = TheMapCache->findMap(TheSkirmishGameInfo->getMap());
@@ -1658,6 +1669,11 @@ WindowMsgHandledType SkirmishGameOptionsMenuSystem( GameWindow *window, Unsigned
TheSkirmishGameInfo->setUnitLimit( GadgetCheckBoxIsChecked( control ) );
break;
}
+ if ( controlID == checkBoxProRulesID )
+ {
+ TheSkirmishGameInfo->setProRules( GadgetCheckBoxIsChecked( control ) );
+ break;
+ }
if ( LobbyTabClicked( (NameKeyType)controlID ) )
break;
if ( controlID == buttonExitID )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp
index 340cbc459..70bb269f4 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/WOLGameSetupMenu.cpp
@@ -205,6 +205,7 @@ static NameKeyType comboBoxStartingCashID = NAMEKEY_INVALID;
static NameKeyType comboBoxPeaceTimeID = NAMEKEY_INVALID;
static NameKeyType checkBoxLimitArmiesID = NAMEKEY_INVALID;
static NameKeyType checkBoxUnitLimitID = NAMEKEY_INVALID;
+static NameKeyType checkBoxProRulesID = NAMEKEY_INVALID;
// Window Pointers ------------------------------------------------------------------------
static GameWindow *parentWOLGameSetup = NULL;
@@ -221,6 +222,7 @@ static GameWindow *comboBoxStartingCash = NULL;
static GameWindow *comboBoxPeaceTime = NULL;
static GameWindow *checkBoxLimitArmies = NULL;
static GameWindow *checkBoxUnitLimit = NULL;
+static GameWindow *checkBoxProRules = NULL;
static GameWindow *comboBoxPlayer[MAX_SLOTS] = {NULL,NULL,NULL,NULL,
NULL,NULL,NULL,NULL };
@@ -339,6 +341,7 @@ static void savePlayerInfo( void )
pref.setStartingCash( TheGameSpyGame->getStartingCash() );
pref.setInt( "PeaceTime", TheGameSpyGame->getPeaceTime() );
pref.setInt( "UnitLimit", TheGameSpyGame->getUnitLimit() ? 1 : 0 );
+ pref.setInt( "ProRules", TheGameSpyGame->getProRules() ? 1 : 0 );
}
pref.write();
}
@@ -809,6 +812,24 @@ static Bool superweaponIsTheHostsToPick( void )
return TheGameSpyGame && TheGameSpyGame->amIHost() && !TheGameSpyGame->getUseStats();
}
+static void handleProRulesSelection()
+{
+ GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom();
+
+ // the same guard as the unit limit box below
+ if (myGame == NULL || checkBoxProRules == NULL || myGame->getProRules() == GadgetCheckBoxIsChecked( checkBoxProRules ))
+ return;
+
+ myGame->setProRules( GadgetCheckBoxIsChecked( checkBoxProRules ) );
+ myGame->resetAccepted();
+
+ if (myGame->amIHost())
+ {
+ TheGameSpyInfo->setGameOptions();
+ WOLDisplaySlotList();// Update the accepted button UI
+ }
+}
+
static void handleUnitLimitSelection()
{
GameInfo *myGame = TheGameSpyInfo->getCurrentStagingRoom();
@@ -1098,6 +1119,8 @@ void WOLDisplayGameOptions( void )
UpdatePeaceTimeComboBox( comboBoxPeaceTime, theGame, peaceTimeIsTheHostsToPick() );
if ( checkBoxUnitLimit )
UpdateUnitLimitCheckBox( checkBoxUnitLimit, theGame, superweaponIsTheHostsToPick() );
+ if ( checkBoxProRules )
+ UpdateProRulesCheckBox( checkBoxProRules, theGame, superweaponIsTheHostsToPick() );
}
@@ -1186,6 +1209,7 @@ void InitWOLGameGadgets( void )
comboBoxPeaceTimeID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:ComboBoxPeaceTime"));
checkBoxLimitArmiesID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:CheckBoxLimitArmies"));
checkBoxUnitLimitID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:CheckBoxUnitLimit"));
+ checkBoxProRulesID = TheNameKeyGenerator->nameToKey(AsciiString("GameSpyGameOptionsMenu.wnd:CheckBoxProRules"));
windowMapSelectMapID = TheNameKeyGenerator->nameToKey(AsciiString("WOLMapSelectMenu.wnd:WinMapPreview"));
NameKeyType staticTextTitleID = NAMEKEY("GameSpyGameOptionsMenu.wnd:StaticTextGameName");
@@ -1220,6 +1244,10 @@ void InitWOLGameGadgets( void )
DEBUG_ASSERTCRASH(checkBoxUnitLimit, ("Could not find the GameSpyGameOptionsMenu.wnd:CheckBoxUnitLimit" ));
if ( checkBoxUnitLimit )
UpdateUnitLimitCheckBox( checkBoxUnitLimit, TheGameSpyGame, superweaponIsTheHostsToPick() );
+ checkBoxProRules = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, checkBoxProRulesID );
+ DEBUG_ASSERTCRASH(checkBoxProRules, ("Could not find the GameSpyGameOptionsMenu.wnd:CheckBoxProRules" ));
+ if ( checkBoxProRules )
+ UpdateProRulesCheckBox( checkBoxProRules, TheGameSpyGame, superweaponIsTheHostsToPick() );
checkBoxLimitArmies = TheWindowManager->winGetWindowFromId( parentWOLGameSetup, checkBoxLimitArmiesID );
DEBUG_ASSERTCRASH(windowMap, ("Could not find the GameSpyGameOptionsMenu.wnd:CheckBoxLimitArmies" ));
@@ -1375,7 +1403,8 @@ void DeinitWOLGameGadgets( void )
comboBoxStartingCash = NULL;
comboBoxPeaceTime = NULL;
checkBoxUnitLimit = NULL;
-
+ checkBoxProRules = NULL;
+
// GameWindow *staticTextTitle = NULL;
for (Int i = 0; i < MAX_SLOTS; i++)
{
@@ -1472,6 +1501,8 @@ void WOLGameSetupMenuInit( WindowLayout *layout, void *userData )
game->setSuperweaponRestriction( isUsingStats? 0 : customPref.getSuperweaponRestriction() );
game->setPeaceTime( isUsingStats? 0 : customPref.getInt( "PeaceTime", 0 ) );
game->setUnitLimit( !isUsingStats && customPref.getInt( "UnitLimit", 0 ) != 0 );
+ // a recorded stats game is the ranked one, so it plays the tournament list
+ game->setProRules( isUsingStats || customPref.getInt( "ProRules", 1 ) != 0 );
if (isUsingStats)
game->setOldFactionsOnly( 0 );
@@ -2782,6 +2813,12 @@ WindowMsgHandledType WOLGameSetupMenuSystem( GameWindow *window, UnsignedInt msg
break;
}
+ if ( controlID == checkBoxProRulesID )
+ {
+ handleProRulesSelection();
+ break;
+ }
+
if ( LobbyTabClicked( (NameKeyType)controlID ) )
break;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 836ea91a8..e927b047d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -699,6 +699,10 @@ void InGameUI::addSuperweapon(Int playerIndex, const AsciiString& powerName, Obj
if (powerTemplate == NULL)
return;
+ // Pro Rules: a silo nobody may fire gets no countdown on everybody's screen and no "missile ready"
+ if (TheGameLogic->isProRules() && ProRulesBanSpecialPower(powerTemplate->getSpecialPowerType()))
+ return;
+
// srj sez: don't allow adding the same superweapon more than once. it can happen. not sure how. (srj)
SuperweaponInfo* swInfo = findSWInfo(playerIndex, powerName, id, powerTemplate);
if (swInfo != NULL)
@@ -5963,6 +5967,11 @@ void InGameUI::displayCantBuildMessage( LegalBuildCode lbc )
TheInGameUI->message( "GUI:CantBuildTooCloseToSupplies" );
break;
+ //---------------------------------------------------------------------------------------------
+ case LBC_TOO_CLOSE_TO_ENEMY:
+ TheInGameUI->message( "GUI:CantBuildTooCloseToEnemy" );
+ break;
+
//---------------------------------------------------------------------------------------------
case LBC_NO_CLEAR_PATH:
TheInGameUI->message( "GUI:CantBuildNoClearPath" );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
index 4bc759bfa..3e0ea512a 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
@@ -1319,6 +1319,14 @@ void ActiveBody::internalAddSubdualDamage( Real delta )
//-------------------------------------------------------------------------------------------------
Bool ActiveBody::canBeSubdued() const
{
+ // Rule 8 of Pro Rules, the microwave bug: a building still going up cannot be subdued, so a
+ // Microwave Tank has nothing to gain by firing at it and does not, and a scaffold is not frozen
+ // half built while the tank sits on it.
+ const Object *me = getObject();
+ if( TheGameLogic->isProRules() && me->isKindOf( KINDOF_STRUCTURE ) &&
+ me->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
+ return FALSE;
+
// Any body with subdue listings can be subdued.
return getActiveBodyModuleData()->m_subdualDamageCap > 0;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp
index 21173ecd6..bc4f70c74 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp
@@ -45,6 +45,7 @@
#include "GameLogic/AI.h"
#include "GameLogic/AIPathfind.h"
#include "GameLogic/ExperienceTracker.h"
+#include "GameLogic/GameLogic.h"
#include "GameLogic/Object.h"
#include "GameLogic/Locomotor.h"
@@ -177,8 +178,8 @@ Bool RiderChangeContain::isValidContainerFor(const Object* rider, Bool checkCapa
const ThingTemplate *thing = TheThingFactory->findTemplate( data->m_riders[ i ].m_templateName );
if( thing->isEquivalentTo( rider->getTemplate() ) )
{
- //We found a valid rider, so return success.
- return TRUE;
+ //We found a valid rider, so return success - unless Pro Rules refuse this one the saddle.
+ return !( TheGameLogic->isProRules() && ProRulesBanRider( thing->getName() ) );
}
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
index ff734030a..63717fdf1 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
@@ -60,6 +60,15 @@
//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
#endif
+//-------------------------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------------------------
+/** Rule 2 of Pro Rules: the silo stands and charges, and firing it is refused. Every route to
+ * firing - the button, a hotkey, a script, a computer player - ends in one of the four do calls. */
+static Bool proRulesRefuse( const SpecialPowerTemplate *specialPowerTemplate )
+{
+ return TheGameLogic->isProRules() && ProRulesBanSpecialPower( specialPowerTemplate->getSpecialPowerType() );
+}
+
//-------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
SpecialPowerModuleData::SpecialPowerModuleData()
@@ -690,7 +699,7 @@ void SpecialPowerModule::aboutToDoSpecialPower( const Coord3D *location )
//-------------------------------------------------------------------------------------------------
void SpecialPowerModule::doSpecialPower( UnsignedInt commandOptions )
{
- if (m_pausedCount > 0 || getObject()->isDisabled()) {
+ if (m_pausedCount > 0 || getObject()->isDisabled() || proRulesRefuse( getSpecialPowerTemplate() )) {
return;
}
@@ -712,7 +721,7 @@ void SpecialPowerModule::doSpecialPower( UnsignedInt commandOptions )
//-------------------------------------------------------------------------------------------------
void SpecialPowerModule::doSpecialPowerAtObject( Object *obj, UnsignedInt commandOptions )
{
- if (m_pausedCount > 0 || getObject()->isDisabled()) {
+ if (m_pausedCount > 0 || getObject()->isDisabled() || proRulesRefuse( getSpecialPowerTemplate() )) {
return;
}
@@ -734,7 +743,7 @@ void SpecialPowerModule::doSpecialPowerAtObject( Object *obj, UnsignedInt comman
//-------------------------------------------------------------------------------------------------
void SpecialPowerModule::doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions )
{
- if (m_pausedCount > 0 || getObject()->isDisabled()) {
+ if (m_pausedCount > 0 || getObject()->isDisabled() || proRulesRefuse( getSpecialPowerTemplate() )) {
return;
}
@@ -756,7 +765,7 @@ void SpecialPowerModule::doSpecialPowerAtLocation( const Coord3D *loc, Real angl
//-------------------------------------------------------------------------------------------------
void SpecialPowerModule::doSpecialPowerUsingWaypoints( const Waypoint *way, UnsignedInt commandOptions )
{
- if (m_pausedCount > 0 || getObject()->isDisabled()) {
+ if (m_pausedCount > 0 || getObject()->isDisabled() || proRulesRefuse( getSpecialPowerTemplate() )) {
return;
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
index 68ca6dfd3..d3926c3e3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
@@ -237,6 +237,7 @@ GameLogic::GameLogic( void )
m_rankLevelLimit = 1000;
m_peaceTimeEndFrame = 0;
m_unitCap = 0;
+ m_proRules = FALSE;
m_gamePaused = FALSE;
m_inputEnabledMemory = TRUE;
m_mouseVisibleMemory = TRUE;
@@ -1240,6 +1241,13 @@ void GameLogic::startNewGame( Bool loadingSaveGame )
m_unitCap = 0;
}
+ /* Pro Rules hold in the modes people play each other in, when the lobby's check box is ticked.
+ A replay asks the mode it was recorded in, or a skirmish that refused an Aurora would play
+ back one that built it; the box itself travels in the replay's options string as PR. */
+ const Int proRulesMode = (TheRecorder && TheRecorder->getMode() == RECORDERMODETYPE_PLAYBACK)
+ ? TheRecorder->getGameMode() : m_gameMode;
+ m_proRules = (proRulesMode == GAME_SKIRMISH || proRulesMode == GAME_LAN || proRulesMode == GAME_INTERNET)
+ && TheGameInfo && TheGameInfo->getProRules();
/* -unitlimit is the lobby's check box for an -autoskirmish run, which has no lobby to tick it
in. A network game reads the host's options string instead, and the switch is cleared for
one above. */
@@ -5544,13 +5552,14 @@ void GameLogic::prepareLogicForObjectLoad( void )
* the list in the order it was saved in. Version 10 and earlier are reversed on load.
* 12: xfer m_peaceTimeEndFrame
* 13: xfer m_unitCap
+ * 14: xfer m_proRules
*/
// ------------------------------------------------------------------------------------------------
void GameLogic::xfer( Xfer *xfer )
{
// version
- const XferVersion currentVersion = 13;
+ const XferVersion currentVersion = 14;
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -5915,6 +5924,15 @@ void GameLogic::xfer( Xfer *xfer )
{
m_unitCap = 0;
}
+
+ if ( version >= 14 )
+ {
+ xfer->xferBool( &m_proRules );
+ }
+ else if ( xfer->getXferMode() == XFER_LOAD )
+ {
+ m_proRules = FALSE;
+ }
} // end xfer
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
index fce5f16e4..ee915f3fe 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GUIUtil.cpp
@@ -543,6 +543,15 @@ void UpdateUnitLimitCheckBox(GameWindow *checkBox, GameInfo *myGame, Bool hostMa
GadgetCheckBoxSetChecked( checkBox, unitLimit );
}
+void UpdateProRulesCheckBox(GameWindow *checkBox, GameInfo *myGame, Bool hostMayEdit)
+{
+ checkBox->winEnable( hostMayEdit );
+
+ const Bool proRules = myGame->getProRules();
+ if ( GadgetCheckBoxIsChecked( checkBox ) != proRules )
+ GadgetCheckBoxSetChecked( checkBox, proRules );
+}
+
// -----------------------------------------------------------------------------
// The lobby tab strip.
static GameWindow *theLobbySettingsPage = NULL;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp
index 87c20902c..7ea39d076 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp
@@ -395,7 +395,8 @@ void GameInfo::reset( void )
m_startingCash = TheGlobalData->m_defaultStartingCash;
m_peaceTime = 0;
m_unitLimit = FALSE;
-
+ m_proRules = TRUE;
+
//
for (Int i=0; i<MAX_SLOTS; ++i)
@@ -811,6 +812,11 @@ void GameInfo::setUnitLimit( Bool unitLimit )
m_unitLimit = unitLimit;
}
+void GameInfo::setProRules( Bool proRules )
+{
+ m_proRules = proRules;
+}
+
Bool GameInfo::isColorTaken(Int colorIdx, Int slotToIgnore ) const
{
for (Int i=0; i<MAX_SLOTS; ++i)
@@ -1030,10 +1036,10 @@ AsciiString GameInfoToAsciiString( const GameInfo *game )
}
AsciiString optionsString;
- optionsString.format("US=%d;M=%2.2x%s;MC=%X;MS=%d;SD=%d;C=%d;SR=%u;SC=%u;O=%c;PT=%d;UL=%d;", game->getUseStats(), game->getMapContentsMask(), newMapName.str(),
+ optionsString.format("US=%d;M=%2.2x%s;MC=%X;MS=%d;SD=%d;C=%d;SR=%u;SC=%u;O=%c;PT=%d;UL=%d;PR=%d;", game->getUseStats(), game->getMapContentsMask(), newMapName.str(),
game->getMapCRC(), game->getMapSize(), game->getSeed(), game->getCRCInterval(), game->getSuperweaponRestriction(),
game->getStartingCash().countMoney(), game->oldFactionsOnly() ? 'Y' : 'N', game->getPeaceTime(),
- game->getUnitLimit() ? 1 : 0 );
+ game->getUnitLimit() ? 1 : 0, game->getProRules() ? 1 : 0 );
//add player info for each slot
optionsString.concat(slotListID);
@@ -1121,7 +1127,8 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options)
UnsignedShort restriction = 0; // Always the default
Int peaceTime = 0; // absent from the string = off, so an older host is still joinable
Bool unitLimit = FALSE; // the same
-
+ Bool proRules = FALSE; // the same
+
Bool sawMap, sawMapCRC, sawMapSize, sawSeed, sawSlotlist, sawUseStats, sawSuperweaponRestriction, sawStartingCash, sawOldFactions;
sawMap = sawMapCRC = sawMapSize = sawSeed = sawSlotlist = sawUseStats = sawSuperweaponRestriction = sawStartingCash = sawOldFactions = FALSE;
@@ -1230,6 +1237,10 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options)
else if (key.compare("UL") == 0 )
{
unitLimit = atoi(val.str()) != 0;
+ }
+ else if (key.compare("PR") == 0 )
+ {
+ proRules = atoi(val.str()) != 0;
}
else if (key.getLength() == 1 && *key.str() == slotListID)
{
@@ -1578,6 +1589,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options)
game->setOldFactionsOnly( oldFactionsOnly );
game->setPeaceTime( peaceTime );
game->setUnitLimit( unitLimit );
+ game->setProRules( proRules );
return true;
}
@@ -1604,7 +1616,7 @@ void SkirmishGameInfo::crc( Xfer *xfer )
// ------------------------------------------------------------------------------------------------
void SkirmishGameInfo::xfer( Xfer *xfer )
{
- const XferVersion currentVersion = 6; // 5 adds m_peaceTime, 6 m_unitLimit
+ const XferVersion currentVersion = 7; // 5 adds m_peaceTime, 6 m_unitLimit, 7 m_proRules
XferVersion version = currentVersion;
xfer->xferVersion( &version, currentVersion );
@@ -1720,6 +1732,15 @@ void SkirmishGameInfo::xfer( Xfer *xfer )
m_unitLimit = FALSE;
}
+ if ( version >= 7 )
+ {
+ xfer->xferBool( &m_proRules );
+ }
+ else if ( xfer->getXferMode() == XFER_LOAD )
+ {
+ m_proRules = FALSE;
+ }
+
} // end xfer
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp
index ad91b61a5..83b26ac2e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp
@@ -341,6 +341,7 @@ void LANAPI::OnGameStart( void )
pref["Map"] = AsciiStringToQuotedPrintable(m_currentGame->getMap());
pref.setSuperweaponRestriction( m_currentGame->getSuperweaponRestriction() );
pref.setInt( "UnitLimit", m_currentGame->getUnitLimit() ? 1 : 0 );
+ pref.setInt( "ProRules", m_currentGame->getProRules() ? 1 : 0 );
pref.setStartingCash( m_currentGame->getStartingCash() );
}
pref.write();
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index c8c119b58..11bbe0c4d 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -11317,6 +11317,80 @@ TEST(the_superweapon_rule_is_a_mode_with_one_exception)
TheWritableGlobalData = saved;
}
+/* The lobby's Pro Rules box starts ticked, so a lobby nobody touched plays the tournament list the
+ way every match did before the box existed. The wire half, PR= in the options string, needs
+ TheGameState and TheMapCache to build a string at all; replay-check carries that one. */
+TEST(pro_rules_box_starts_ticked_and_clears)
+{
+ GlobalData *saved = TheWritableGlobalData;
+ TheWritableGlobalData = NEW GlobalData;
+
+ SkirmishGameInfo game;
+ game.init();
+ CHECK( game.getProRules() );
+ game.setProRules( FALSE );
+ CHECK( !game.getProRules() );
+ game.reset();
+ CHECK( game.getProRules() );
+
+ delete TheWritableGlobalData;
+ TheWritableGlobalData = saved;
+}
+
+#include "Common/SpecialPowerType.h"
+
+/* Pro Rules name what they ban by the ending every general's copy shares, so each check below
+ is a template name out of the game's own INI, and each near miss is the thing next to it on the
+ same build menu that must stay buildable. */
+TEST(pro_rules_ban_the_listed_things_and_nothing_beside_them)
+{
+ // rules 4 and 5: every faction's Aurora, the Alpha Aurora being the Air Force General's copy
+ CHECK( ProRulesBanThing( AsciiString( "AmericaJetAurora" ) ) );
+ CHECK( ProRulesBanThing( AsciiString( "AirF_AmericaJetAurora" ) ) );
+ CHECK( ProRulesBanThing( AsciiString( "Lazr_AmericaJetAurora" ) ) );
+ CHECK( ProRulesBanThing( AsciiString( "SupW_AmericaJetAurora" ) ) );
+ CHECK( !ProRulesBanThing( AsciiString( "AmericaJetRaptor" ) ) );
+ CHECK( !ProRulesBanThing( AsciiString( "AmericaJetAuroraHulk" ) ) );
+ CHECK( !ProRulesBanThing( AsciiString( "AmericaParticleCannonUplink" ) ) );
+
+ // rule 11: the silo keeps the lobby's rule, every other superweapon is rule 1 and 3's
+ CHECK( ProRulesExemptSuperweapon( AsciiString( "ChinaNuclearMissileLauncher" ) ) );
+ CHECK( ProRulesExemptSuperweapon( AsciiString( "Nuke_ChinaNuclearMissileLauncher" ) ) );
+ CHECK( !ProRulesExemptSuperweapon( AsciiString( "AmericaParticleCannonUplink" ) ) );
+ CHECK( !ProRulesExemptSuperweapon( AsciiString( "SupW_AmericaParticleCannonUplink" ) ) );
+ CHECK( !ProRulesExemptSuperweapon( AsciiString( "GLAScudStorm" ) ) );
+ CHECK( !ProRulesExemptSuperweapon( AsciiString( "Demo_GLAScudStorm" ) ) );
+
+ // rules 1, 3 and 10 are No Superweapons for everyone but one general
+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, AsciiString( "FactionAmericaSuperWeaponGeneral" ) ), 1 );
+ CHECK_EQ( SuperweaponBuildCap( SUPERWEAPONS_NONE, AsciiString( "FactionAmericaAirForceGeneral" ) ), (Int)SUPERWEAPON_CAP_BANNED );
+
+ // rule 6, and the Nuke General's other upgrades
+ CHECK( ProRulesBanUpgrade( AsciiString( "Upgrade_ChinaTacticalNukeMig" ) ) );
+ CHECK( !ProRulesBanUpgrade( AsciiString( "Nuke_Upgrade_HelixNukeBomb" ) ) );
+ CHECK( !ProRulesBanUpgrade( AsciiString( "Nuke_Upgrade_ChinaWGUraniumShells" ) ) );
+
+ // rule 2: the missile, for each general that fires one, and not the other superweapons' powers
+ CHECK( ProRulesBanSpecialPower( SPECIAL_NEUTRON_MISSILE ) );
+ CHECK( ProRulesBanSpecialPower( NUKE_SPECIAL_NEUTRON_MISSILE ) );
+ CHECK( ProRulesBanSpecialPower( SUPW_SPECIAL_NEUTRON_MISSILE ) );
+ CHECK( !ProRulesBanSpecialPower( SPECIAL_SCUD_STORM ) );
+ CHECK( !ProRulesBanSpecialPower( SPECIAL_PARTICLE_UPLINK_CANNON ) );
+ CHECK( !ProRulesBanSpecialPower( SPECIAL_CLUSTER_MINES ) );
+
+ // rule 7: a terrorist on a combat cycle, and every other rider still rides
+ CHECK( ProRulesBanRider( AsciiString( "GLAInfantryTerrorist" ) ) );
+ CHECK( ProRulesBanRider( AsciiString( "Demo_GLAInfantryTerrorist" ) ) );
+ CHECK( ProRulesBanRider( AsciiString( "GC_Slth_GLAInfantryTerrorist" ) ) );
+ CHECK( !ProRulesBanRider( AsciiString( "Demo_GLAInfantryRebel" ) ) );
+ CHECK( !ProRulesBanRider( AsciiString( "GLAInfantryWorker" ) ) );
+ CHECK( !ProRulesBanRider( AsciiString( "Demo_GLAInfantryHijacker" ) ) );
+
+ // rule 9: the clearance is past a Patriot's and a Stinger Site's ground reach, 225 in Weapon.ini,
+ // so no foundation goes down inside an enemy's own defensive cover
+ CHECK( (Int)PRO_RULES_ENEMY_STRUCTURE_CLEARANCE > 225 );
+}
+
/* -scenario's line parser.
*
* A scenario file that gets half-read still plays a match and still writes a frame time table, so
diff --git a/GeneralsMD/Code/Tools/lobbyroom_layout.py b/GeneralsMD/Code/Tools/lobbyroom_layout.py
index ebbcd2c0c..7b74e06bf 100644
--- a/GeneralsMD/Code/Tools/lobbyroom_layout.py
+++ b/GeneralsMD/Code/Tools/lobbyroom_layout.py
@@ -91,11 +91,14 @@ LAN_COLUMNS = [
# "Allow Superweapons" needs 152 at 800x600.
SKIRMISH_SETTINGS = [
(96, 152, [("StartingCashLabel", "ComboBoxStartingCash"), ("LabelSuperweapons", "ComboBoxSuperweapons")]),
- (88, 112, [("LabelGameSpeed", "SliderGameSpeed", "StaticTextGameSpeed"), ("CheckBoxUnitLimit",)]),
+ (88, 112, [("LabelGameSpeed", "SliderGameSpeed", "StaticTextGameSpeed"), ("CheckBoxUnitLimit",),
+ ("CheckBoxProRules",)]),
]
+# The LAN page is 84 high over the chat entry, two rows, so Pro Rules takes a third column instead.
LAN_SETTINGS = [
(96, 152, [("StartingCashLabel", "ComboBoxStartingCash"), ("LabelSuperweapons", "ComboBoxSuperweapons")]),
(96, 152, [("LabelPeaceTime", "ComboBoxPeaceTime"), ("CheckBoxUnitLimit",)]),
+ (0, 128, [("CheckBoxProRules",)]),
]
STAT_ROWS = [
diff --git a/GeneralsMD/Code/Tools/lobbysettings_layout.py b/GeneralsMD/Code/Tools/lobbysettings_layout.py
index 7774f82d5..7a757bb5d 100644
--- a/GeneralsMD/Code/Tools/lobbysettings_layout.py
+++ b/GeneralsMD/Code/Tools/lobbysettings_layout.py
@@ -87,8 +87,10 @@ LOBBIES = {
("ComboBoxPeaceTime", 273, 388, 180, 24),
("LabelSuperweapons", 97, 420, 170, 24),
("ComboBoxSuperweapons", 273, 420, 220, 24),
- ("CheckBoxUseStats", 500, 356, 160, 24),
- ("CheckBoxLimitArmies", 500, 388, 160, 24),
+ # 28 apart rather than 32: the unit limit and Pro Rules boxes go under these two by
+ # hand, and four rows at 32 do not fit in a page 124 high
+ ("CheckBoxUseStats", 500, 352, 160, 24),
+ ("CheckBoxLimitArmies", 500, 380, 160, 24),
],
),
"SkirmishGameOptionsMenu": dict(
@@ -119,10 +121,10 @@ PAGE = "PageLobbySettings"
# in the LAN layout than in the other two.
SUPERWEAPON_CHECKBOX = ("CheckboxLimitSuperweapons", "CheckBoxLimitSuperweapons")
-# The unit limit check box was put on all three pages by hand after the pages were generated, so
-# build() does not make it; the selfcheck still wants it on every page, because the menu code names it
-# and a missing control is as silent as the rest.
-UNIT_LIMIT_CHECKBOX = "CheckBoxUnitLimit"
+# The unit limit and Pro Rules check boxes were put on all three pages by hand after the pages were
+# generated, so build() does not make them; the selfcheck still wants them on every page, because the
+# menu code names them and a missing control is as silent as the rest.
+HAND_PLACED_CHECKBOXES = ("CheckBoxUnitLimit", "CheckBoxProRules")
# Cloned from a control that is already on the screen, so they inherit its images and font. A
# layout gets the ones its own page has a row for: the skirmish lobby has no peace time, because a
@@ -146,6 +148,8 @@ STRINGS = [
"TOOLTIP:Superweapons",
"GUI:UnitLimit",
"TOOLTIP:UnitLimit",
+ "GUI:ProRules",
+ "TOOLTIP:ProRules",
]
@@ -284,11 +288,12 @@ def selfcheck():
elif page is not None and control not in list(page.walk()):
problems.append("%s.wnd: %s is not on the settings page" % (menu, name))
- unit_limit = layout.find(UNIT_LIMIT_CHECKBOX)
- if unit_limit is None:
- problems.append("%s.wnd has no %s" % (menu, UNIT_LIMIT_CHECKBOX))
- elif page is not None and unit_limit not in list(page.walk()):
- problems.append("%s.wnd: %s is not on the settings page" % (menu, UNIT_LIMIT_CHECKBOX))
+ for name in HAND_PLACED_CHECKBOXES:
+ checkbox = layout.find(name)
+ if checkbox is None:
+ problems.append("%s.wnd has no %s" % (menu, name))
+ elif page is not None and checkbox not in list(page.walk()):
+ problems.append("%s.wnd: %s is not on the settings page" % (menu, name))
for name in SUPERWEAPON_CHECKBOX:
if layout.find(name) is not None: