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(gameclient): let the client pick what colour each player wears
Olcay Seygan28c4c38b83e5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 603bafc0c..bb658da79 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -444,10 +444,19 @@ found and fixed — EA's own, not port damage.**- The second copy also used to be thrown out on the way in. It arrived carrying the same player name, which a host refuses, and the same serial number, which a host refuses harder - a rule written against two people sharing one bought copy, and two windows on one desk are not that. Both copies get their own name now, and the serial rule is waived only between two addresses on the same machine. Anything that could be a second computer still answers to it.- `lan-play.ps1` starts as many copies as you ask for, gives each its own name, address and log, opens each on the LAN screen instead of the main menu, and lays the windows out side by side so they are not stacked on top of one another.+## Whose side is that++- Player colours can say who is on your side. The original game hands out eight colours picked for being different from each other, and none of them means anything: in a four-player fight, working out whether the tanks coming over the ridge are your ally's or the other team's is a memory exercise done at speed, and getting it wrong costs you the fight.+- You, allies, enemies paints you blue, everyone fighting alongside you green and everyone shooting at you red. Members of the same side get different shades of the one colour, so four allied armies are still four armies and not one green blob.+- By team gives each alliance its own colour and each of its members a shade of it. That is the one to use as an observer, watching a 4v4 where nobody is yours.+- The colour reaches everything: the tint on the models, the radar, health bars, selection rings, the score screen, the money that floats up from a supply drop.+- Your screen only. Nobody else in the match sees your choice, nothing about the game itself changes, and two people in the same game can run different settings. Original is the default and nothing changes until you pick something else.+- Switch it mid-match and the map repaints itself. So does the picture when an alliance is made or broken by a map script.+## The options screen has pages- Display, audio, controls, gameplay and network, behind five buttons across the top. The original screen was one panel with everything on it at once, and it was already full the day it shipped: the language filter, the keyboard button and four camera checkboxes are all still in there, parked off the right edge where nobody can reach them, because there was nowhere left to put them.-- Five settings that used to need a text editor have a control now: window mode, antialiasing and the two glow settings on display, and who wears a health bar on gameplay.+- Six settings that used to need a text editor have a control now: window mode, antialiasing and the two glow settings on display, and who wears a health bar and which colours the players wear on gameplay.- Twelve more are decided for you instead of asked about. Grid placement, nudging a blocked building, 45 degree building rotation, the placement range ring, workers going back to supply, detailed build tooltips, the HUD overlay and archived replays are simply on - every one of them is the version of the game people were choosing anyway, and a page of eight checkboxes nobody unticks is a page of eight decisions nobody wanted to make. Middle-mouse panning, zoom to cursor, edge scrolling in a window and 45 degree camera steps left the screen too; those four are still yours by name in `Options.ini` if the defaults are wrong for your setup.- A page no longer says its own name twice. Every tab used to open onto a heading repeating the word already written on the button you just pressed, with a rule under it dividing nothing from nothing.- An open dropdown covers what is under it instead of the other way round. The list of resolutions grew downwards behind the labels below it, so half the entries were readable and half were words on top of words.diff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 5c1ed3951..ca6e08e44 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -560,6 +560,26 @@ TOOLTIP:HealthBars"Smart shows a bar over anything hurt, plus the selection and whatever is under the cursor. Selection only is what retail did."END+GUI:PlayerColors+"Player Colors"+END++GUI:PlayerColors0+"Original"+END++GUI:PlayerColors1+"You, Allies, Enemies"+END++GUI:PlayerColors2+"By Team"+END++TOOLTIP:PlayerColors+"You, allies, enemies paints you blue, everyone on your side green and everyone shooting at you red. By team gives each alliance its own color and each member of it a shade. Your own screen only, so it changes nothing for anyone else in the game."+END+// Peace time - the lobby combo box, its tooltip, the corner countdown and the three things the game// says while the clock runs. Tools/peacetime_layout.py selfcheck fails if any of these goes missing.diff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wndindex 174572488..437341638 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenu.wnd@@ -4477,6 +4477,294 @@ WINDOWIMAGE: 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 = STATICTEXT;+ SCREENRECT = UPPERLEFT: 160 160, BOTTOMRIGHT: 390 184, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:LabelPlayerColors";+ TOOLTIPTEXT = "TOOLTIP:PlayerColors";+ STATUS = ENABLED;+ STYLE = STATICTEXT+MOUSETRACK;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 14, BOLD: 0;+ HEADERTEMPLATE = "MinorTitle";+ TOOLTIPDELAY = -1;+ TEXT = "GUI:PlayerColors";+ TEXTCOLOR = ENABLED: 255 255 255 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 255, DISABLEDBORDER: 64 64 64 255,+ HILITE: 128 128 255 255, HILITEBORDER: 0 0 128 255;+ ENABLEDDRAWDATA = IMAGE: NoImage, COLOR: 0 0 0 0, BORDERCOLOR: 0 0 0 0,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255;+ DISABLEDDRAWDATA = IMAGE: NoImage, COLOR: 64 64 64 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 128 0 255, BORDERCOLOR: 128 255 128 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255,+ IMAGE: NoImage, COLOR: 255 255 255 255, BORDERCOLOR: 255 255 255 255;+ STATICTEXTDATA = CENTERED: 0;+ END+ CHILD+ WINDOW+ WINDOWTYPE = COMBOBOX;+ SCREENRECT = UPPERLEFT: 160 184, BOTTOMRIGHT: 360 208, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:ComboBoxPlayerColors";+ TOOLTIPTEXT = "TOOLTIP:PlayerColors";+ STATUS = ENABLED+IMAGE;+ STYLE = MOUSETRACK+COMBOBOX;+ SYSTEMCALLBACK = "[None]";+ INPUTCALLBACK = "[None]";+ TOOLTIPCALLBACK = "[None]";+ DRAWCALLBACK = "[None]";+ FONT = NAME: "Arial", SIZE: 10, BOLD: 0;+ HEADERTEMPLATE = "ComboBoxEntry";+ TOOLTIPDELAY = -1;+ TEXTCOLOR = ENABLED: 254 254 254 255, ENABLEDBORDER: 0 0 0 255,+ DISABLED: 192 192 192 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: NoImage, COLOR: 47 55 168 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,+ 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: NoImage, COLOR: 192 192 192 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ HILITEDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ListBoxHiliteSelectedItemLeftEnd, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ListBoxHiliteSelectedItemRightEnd, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemSmallRepeatingCenter, 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;+ COMBOBOXDATA = ISEDITABLE: 0,+ MAXCHARS: 16,+ MAXDISPLAY: 5,+ ASCIIONLY: 0,+ LETTERSANDNUMBERS: 0;+ COMBOBOXDROPDOWNBUTTONENABLEDDRAWDATA = IMAGE: VSliderDownButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: VSliderDownButtonHiliteSelected, 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ COMBOBOXDROPDOWNBUTTONDISABLEDDRAWDATA = IMAGE: VSliderDownButtonDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 255, BORDERCOLOR: 128 128 128 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ COMBOBOXDROPDOWNBUTTONHILITEDRAWDATA = IMAGE: VSliderDownButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: VSliderDownButtonHiliteSelected, 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ COMBOBOXEDITBOXENABLEDDRAWDATA = IMAGE: TextEntryEnabledLeftEnd, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: TextEntryEnabledRightEnd, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: TextEntryEnabledRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: TextEntryEnabledSmallRepeatingCenter, 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;+ COMBOBOXEDITBOXDISABLEDDRAWDATA = IMAGE: TextEntryDisabledLeftEnd, COLOR: 128 128 128 255, BORDERCOLOR: 0 0 0 255,+ IMAGE: TextEntryDisabledRightEnd, COLOR: 192 192 192 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: TextEntryDisabledRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: TextEntryDisabledSmallRepeatingCenter, 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;+ COMBOBOXEDITBOXHILITEDRAWDATA = IMAGE: TextEntryHiliteLeftEnd, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: TextEntryHiliteRightEnd, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: TextEntryHiliteRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: TextEntryHiliteSmallRepeatingCenter, 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;+ COMBOBOXLISTBOXENABLEDDRAWDATA = IMAGE: BlackSquare, COLOR: 0 0 0 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: ListBoxHiliteItemLeftEnd, COLOR: 255 255 0 255, BORDERCOLOR: 254 254 254 255,+ IMAGE: ListBoxHiliteItemRightEnd, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteItemRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteItemSmallRepeatingCenter, 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;+ COMBOBOXLISTBOXDISABLEDDRAWDATA = IMAGE: BlackSquare, COLOR: 0 0 0 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: NoImage, COLOR: 192 192 192 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ COMBOBOXLISTBOXHILITEDRAWDATA = IMAGE: BlackSquare, COLOR: 0 0 0 255, BORDERCOLOR: 49 55 168 255,+ IMAGE: ListBoxHiliteSelectedItemLeftEnd, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ListBoxHiliteSelectedItemRightEnd, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemRepeatingCenter, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: ListBoxHiliteSelectedItemSmallRepeatingCenter, 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;+ LISTBOXENABLEDUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: VSliderUpButtonHiliteSelected, 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXDISABLEDUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXHILITEUPBUTTONDRAWDATA = IMAGE: VSliderUpButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: VSliderUpButtonHiliteSelected, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXENABLEDDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonEnabled, COLOR: 255 0 0 255, BORDERCOLOR: 255 128 128 255,+ IMAGE: VSliderDownButtonHiliteSelected, 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXDISABLEDDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXHILITEDOWNBUTTONDRAWDATA = IMAGE: VSliderDownButtonHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: VSliderDownButtonHiliteSelected, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXENABLEDSLIDERDRAWDATA = IMAGE: NoImage, COLOR: 168 255 12 0, BORDERCOLOR: 47 55 168 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXDISABLEDSLIDERDRAWDATA = IMAGE: NoImage, COLOR: 128 128 128 0, BORDERCOLOR: 148 112 0 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ LISTBOXHILITESLIDERDRAWDATA = IMAGE: NoImage, COLOR: 0 255 0 0, BORDERCOLOR: 49 55 168 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ SLIDERTHUMBENABLEDDRAWDATA = IMAGE: ScrollBarThumbEnabled, COLOR: 255 4 0 0, BORDERCOLOR: 255 243 28 255,+ IMAGE: ScrollBarThumbHiliteSelected, 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ SLIDERTHUMBDISABLEDDRAWDATA = IMAGE: ScrollBarThumbDisabled, COLOR: 128 128 128 255, BORDERCOLOR: 192 192 192 255,+ IMAGE: NoImage, COLOR: 192 192 192 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ SLIDERTHUMBHILITEDRAWDATA = IMAGE: ScrollBarThumbHilite, COLOR: 0 255 0 255, BORDERCOLOR: 0 128 0 255,+ IMAGE: ScrollBarThumbHiliteSelected, COLOR: 254 254 254 255, BORDERCOLOR: 0 128 0 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,+ IMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;+ ENDENDALLCHILDRENENDCHILDdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex 6ca632eb5..f793c8181 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -280,6 +280,7 @@ public:Bool m_debugAIObstacles; ///< Used to display AI obstacle debug informationBool m_showObjectHealth; ///< debug display object healthInt m_healthBarMode; ///< HealthBarModeType: which units wear a bar at all+ Int m_playerColorScheme; ///< PlayerColorSchemeType: whose colour the client draws (client only)Bool m_scriptDebug; ///< Should we attempt to load the script debugger window (.DLL)Bool m_particleEdit; ///< Should we attempt to load the particle editor (.DLL)Bool m_displayDebug; ///< Used to display display debug infodiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.hindex a560fd054..6ffd68bf9 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h@@ -324,6 +324,7 @@ public:void friend_bindToObject( Object *obj ); ///< bind this drawable to an object ID. for use ONLY by GameLogic!void setIndicatorColor(Color color);+ void refreshIndicatorColor( void ); ///< re-apply the last colour asked for, under whatever scheme is on nowvoid setTintStatus( TintStatus statusBits ) { BitSet( m_tintStatus, statusBits ); };void clearTintStatus( TintStatus statusBits ) { BitClear( m_tintStatus, statusBits ); };@@ -716,6 +717,12 @@ private:Int m_flashCount; ///< number of times to flash the drawableColor m_flashColor; ///< color to flash the drawable+ // the last colour setIndicatorColor was asked for, before the player's scheme was applied to it.+ // A model bakes its tint into its render object, so when the scheme moves the only way back to+ // the right colour is the one that was asked for - a garrisoned building is wearing the+ // occupier's, not its owner's, and re-deriving it from the object would lose that.+ Color m_indicatorColorAsked;+Matrix3D m_instance; ///< The instance matrix that holds the initial/default position & orientationReal m_instanceScale; ///< the uniform scale factor applied to the instance matrix before it is sent to W3D.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/PlayerColorScheme.h b/GeneralsMD/Code/GameEngine/Include/GameClient/PlayerColorScheme.hnew file mode 100644index 000000000..2608f9148--- /dev/null+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/PlayerColorScheme.h@@ -0,0 +1,109 @@+/*+** Command & Conquer Generals Zero Hour(tm)+** Copyright 2025 Electronic Arts Inc.+**+** This program is free software: you can redistribute it and/or modify+** it under the terms of the GNU General Public License as published by+** the Free Software Foundation, either version 3 of the License, or+** (at your option) any later version.+**+** This program is distributed in the hope that it will be useful,+** but WITHOUT ANY WARRANTY; without even the implied warranty of+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+** GNU General Public License for more details.+**+** You should have received a copy of the GNU General Public License+** along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++#pragma once++// PlayerColorScheme.h+//+// Who gets which colour on this screen.+//+// Retail hands every player the colour their lobby slot picked and draws it everywhere: the model's+// house tint, the radar blip, the health bar, the selection ring, the score screen. Eight of them+// at once, chosen for being distinguishable from each other and not for saying whose side anything+// is on, so telling friend from foe in a four-player fight is a memory exercise done at speed.+//+// So the colour a player is drawn in becomes a client setting. This is a translation layer and+// nothing more: Player::getPlayerColor() keeps returning the colour the lobby agreed on, the+// simulation keeps reading that one, and only the code about to put pixels on the screen asks here.+//+// That distinction is not cosmetic. OCLUpdate asks whether a building changed hands by comparing+// the owner's colour against the one it stored last frame (OCLUpdate.cpp, m_currentPlayerColor,+// which is xfered), so a scheme that paints two enemies the same red would make a capture invisible+// to it and spawn units on different frames on different machines. Nothing in here is ever+// reachable from GameLogic, which is why that cannot happen. Two people in the same match may run+// different schemes and neither will know.+//+// The table is rebuilt at most once a frame and only when something it depends on moved - the+// setting, the local player, the roster, an alliance. With PLAYER_COLORS_ORIGINAL every entry is+// the identity and every call here returns before touching it.++#ifndef __PLAYERCOLORSCHEME_H_+#define __PLAYERCOLORSCHEME_H_++#include "Lib/BaseType.h"+#include "GameClient/Color.h"++class Player;++//-----------------------------------------------------------------------------+/** What the player asked for in the options screen. */+enum PlayerColorSchemeType+{+ PLAYER_COLORS_ORIGINAL = 0, ///< the lobby's own colours, which is what retail draws+ PLAYER_COLORS_RELATION = 1, ///< you blue, your allies green, everyone shooting at you red+ PLAYER_COLORS_TEAM = 2, ///< a hue per alliance, a shade per member of it++ PLAYER_COLOR_SCHEME_COUNT = 3,+};++//-----------------------------------------------------------------------------+// The colour families. Each is four shades that read as the same colour across a battlefield and+// still tell four units apart at arm's length, which is the whole job: a flat red for every enemy+// answers "whose is that" and destroys "which of them is that".+enum+{+ PLAYER_COLOR_FAMILY_BLUE = 0,+ PLAYER_COLOR_FAMILY_RED = 1,+ PLAYER_COLOR_FAMILY_GREEN = 2,+ PLAYER_COLOR_FAMILY_YELLOW = 3,+ PLAYER_COLOR_FAMILY_PURPLE = 4,+ PLAYER_COLOR_FAMILY_ORANGE = 5,+ PLAYER_COLOR_FAMILY_CYAN = 6,+ PLAYER_COLOR_FAMILY_GREY = 7,++ PLAYER_COLOR_FAMILY_COUNT = 8,+ PLAYER_COLOR_SHADE_COUNT = 4,+};++/** One shade of one family, opaque. A shade past the fourth is the same four darkened again, so a+ * seven-player alliance still gets seven telltale colours instead of running out at four. */+extern Color playerSchemeColor( Int family, Int shade );++/** The night version of a scheme colour. The shipped palette carries a hand-tuned night colour per+ * slot because dark blue on a night map is a black unit on black ground; ours are generated, so+ * they get the same treatment by rule - a quarter of the way to white. */+extern Color playerSchemeNightColor( Color dayColor );++//-----------------------------------------------------------------------------+/** The colour to draw this player in, day and night. */+extern Color clientPlayerColor( const Player *player );+extern Color clientPlayerNightColor( const Player *player );++/** The colour to draw, for code that was handed a colour rather than a player. A colour that is+ * not any player's passes through untouched, which is what makes it safe to put this in front of+ * the floating text and the indicator colour, where civilians and script colours also arrive. */+extern Color clientColor( Color logicColor );++/** Rebuild if anything moved. TRUE when a colour actually changed, which is the client's cue that+ * every model is carrying a stale tint baked into its render object. */+extern Bool updatePlayerColorScheme( void );++/** Throw the table away; the next query rebuilds it. Called when a game starts. */+extern void invalidatePlayerColorScheme( void );++#endif // __PLAYERCOLORSCHEME_H_diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex f3660bc30..a3bb84dce 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -55,6 +55,7 @@#include "GameClient/Color.h"#include "GameClient/Drawable.h" // PLACEMENT_SILHOUETTE_OPACITY, the default for BuildPlacementOpacity+#include "GameClient/PlayerColorScheme.h" // PLAYER_COLORS_ORIGINAL, the default for PlayerColors#include "GameClient/TerrainVisual.h"#include "GameNetwork/FirewallHelper.h"@@ -365,6 +366,7 @@ GlobalData* GlobalData::m_theOriginal = NULL;{ "ShowTerrainNormals", INI::parseBool, NULL, offsetof( GlobalData, m_showTerrainNormals ) },{ "ShowObjectHealth", INI::parseBool, NULL, offsetof( GlobalData, m_showObjectHealth ) },{ "HealthBars", INI::parseInt, NULL, offsetof( GlobalData, m_healthBarMode ) },+ { "PlayerColors", INI::parseInt, NULL, offsetof( GlobalData, m_playerColorScheme ) },{ "ParticleScale", INI::parseReal, NULL, offsetof( GlobalData, m_particleScale ) },{ "AutoFireParticleSmallPrefix", INI::parseAsciiString, NULL, offsetof( GlobalData, m_autoFireParticleSmallPrefix ) },@@ -894,6 +896,8 @@ GlobalData::GlobalData()m_showObjectHealth = FALSE;// what this fork has always done, so nobody's game changes until they say som_healthBarMode = HEALTH_BAR_ALWAYS;+ // the lobby's own colours until somebody asks for something else+ m_playerColorScheme = PLAYER_COLORS_ORIGINAL;m_particleEdit = FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cppindex 1b9cc21aa..3289eef2f 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp@@ -25,6 +25,7 @@#include "Common/OptionsCatalog.h"#include "Common/GlobalData.h"#include "Common/UserPreferences.h"+#include "GameClient/PlayerColorScheme.h"//-----------------------------------------------------------------------------// The accessors. Each is two lines and exists only because a member pointer cannot span Bool and@@ -51,6 +52,7 @@ OPTION_INT_ACCESSORS( m_anisotropyLevel )OPTION_INT_ACCESSORS( m_windowMode )OPTION_INT_ACCESSORS( m_msaaLevel )OPTION_INT_ACCESSORS( m_healthBarMode )+OPTION_INT_ACCESSORS( m_playerColorScheme )//-----------------------------------------------------------------------------static const unsigned TheMsaaSamples[ OPTION_MSAA_LEVEL_COUNT ] = { 0, 2, 4, 8, 16 };@@ -243,6 +245,13 @@ const OptionDef TheOptionCatalog[] =OPTION_ENUM, APPLY_LIVE, 0, HEALTH_BAR_MODE_COUNT - 1,get_m_healthBarMode, set_m_healthBarMode },+ // Whose colour a player is drawn in. Purely local: the match still agrees on the lobby's+ // colours and this only changes what this screen puts on top of them, so two people in the same+ // game can run different schemes.+ { "PlayerColors", OPT_WND( "ComboBoxPlayerColors" ), "GUI:PlayerColors",+ OPTION_ENUM, APPLY_LIVE, 0, PLAYER_COLOR_SCHEME_COUNT - 1,+ get_m_playerColorScheme, set_m_playerColorScheme },+{ NULL, NULL, NULL, OPTION_BOOL, APPLY_LIVE, 0, 0, NULL, NULL }};diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cppindex ecfe2e307..ab9c706a1 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp@@ -45,6 +45,7 @@#include "GameClient/GameWindowManager.h"#include "GameClient/InGameUI.h"#include "GameClient/ControlBar.h"+#include "GameClient/PlayerColorScheme.h"#include "GameLogic/GameLogic.h"#include "GameLogic/Object.h"@@ -459,11 +460,11 @@ void Radar::addObject( Object *obj )if( useIndicatorColor || (player == NULL) ){- newObj->setColor( obj->getIndicatorColor() );+ newObj->setColor( clientColor( obj->getIndicatorColor() ) );}else- {- newObj->setColor( player->getPlayerColor() );+ {+ newObj->setColor( clientPlayerColor( player ) );}// set a chunk of radar data in the object@@ -1083,7 +1084,7 @@ void Radar::createPlayerEvent( Player *player, const Coord3D *world,RGBAColorInt color[ 2 ];// color 1- c = player->getPlayerColor();+ c = clientPlayerColor( player );GameGetColorComponents( c, &r, &g, &b, &a );color[ 0 ].red = r;color[ 0 ].green = g;diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cppindex 0b5c5fb1d..a382eb555 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/Drawable.cpp@@ -82,6 +82,7 @@#include "GameClient/InGameUI.h"#include "GameClient/Image.h"#include "GameClient/ParticleSys.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/LanguageFilter.h"#include "GameClient/Shadow.h"#include "GameClient/GameText.h"@@ -485,6 +486,7 @@ Drawable::Drawable( const ThingTemplate *thingTemplate, DrawableStatus statusBit// Added By Sadullah Nader// Initialization missing and neededm_flashColor = 0;+ m_indicatorColorAsked = 0;m_selected = '\0';//@@ -3345,7 +3347,7 @@ void Drawable::drawUIText()Player *owner = obj->getControllingPlayer();Int groupNum = owner->getSquadNumberForObject(obj);- Color color = TheDrawGroupInfo->m_usePlayerColor ? owner->getPlayerColor() : TheDrawGroupInfo->m_colorForText;+ Color color = TheDrawGroupInfo->m_usePlayerColor ? clientPlayerColor( owner ) : TheDrawGroupInfo->m_colorForText;if (groupNum > NO_HOTKEY_SQUAD && groupNum < NUM_HOTKEY_SQUADS ){@@ -4245,7 +4247,7 @@ void Drawable::drawHealthBar(const IRegion2D* healthBarRegion)// disabled blue above keeps its own colour: that is a state nothing else signals.//UnsignedByte r, g, b, a;- GameGetColorComponents( obj->getControllingPlayer()->getPlayerColor(), &r, &g, &b, &a );+ GameGetColorComponents( clientPlayerColor( obj->getControllingPlayer() ), &r, &g, &b, &a );color = GameMakeColor( r, g, b, 255 ); // the stored colour's alpha is not ours to trustoutlineColor = GameDarkenColor( color, 60 );@@ -4725,6 +4727,14 @@ void Drawable::replaceModelConditionFlags( const ModelConditionFlags &flags, Boo//-------------------------------------------------------------------------------------------------void Drawable::setIndicatorColor(Color color){+ // The one gate the model tint goes through, whoever asked for it. Garrison, cave, stealth and+ // the disguise code all live in GameLogic and hand a player colour straight down here, so the+ // scheme is applied on this side of the fence rather than in any of them: they keep passing the+ // colour the match agreed on and only the picture changes. A colour that belongs to no player+ // comes back untouched.+ m_indicatorColorAsked = color;+ color = clientColor( color );+for (DrawModule** dm = getDrawModules(); *dm; ++dm){ObjectDrawInterface* di = (*dm)->getObjectDrawInterface();@@ -4733,6 +4743,26 @@ void Drawable::setIndicatorColor(Color color)}}+//-------------------------------------------------------------------------------------------------+void Drawable::refreshIndicatorColor( void )+{+ if( m_indicatorColorAsked != 0 )+ {+ setIndicatorColor( m_indicatorColorAsked );+ return;+ }++ // nobody has ever set one, so the model built itself from the object's own colour+ const Object *obj = getObject();+ if( obj != NULL )+ {+ setIndicatorColor( TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT+ ? obj->getNightIndicatorColor()+ : obj->getIndicatorColor() );+ m_indicatorColorAsked = 0; // still nothing anybody asked for, so keep following the object+ }+}+// ------------------------------------------------------------------------------------------------const GeometryInfo& Drawable::getDrawableGeometryInfo() const{diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cppindex 1c0066bef..12bb49255 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp@@ -59,6 +59,7 @@#include "Common/KindOf.h"#include "Common/Recorder.h"#include "GameClient/ControlBar.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/GameWindowManager.h"#include "GameClient/GadgetPushButton.h"#include "GameClient/GadgetStaticText.h"@@ -236,7 +237,7 @@ void ControlBar::populateObserverList( void )// counts the players put on the bar so far, so one empty slot or one observer earlier// in the list shifted every player after it onto somebody else's team.const GameSlot *slot = TheGameInfo ? TheGameInfo->getConstSlot(i) : NULL;- Color playerColor = p->getPlayerColor();+ Color playerColor = clientPlayerColor( p );Color backColor = GameMakeColor(0, 0, 0, 255);staticTextPlayer[currentButton]->winSetEnabledTextColors( playerColor, backColor );staticTextPlayer[currentButton]->winHide(FALSE);@@ -280,7 +281,7 @@ void ControlBar::populateObserverList( void )buttonPlayer[currentButton]->winHide(FALSE);buttonPlayer[currentButton]->winSetStatus( WIN_STATUS_USE_OVERLAY_STATES );- Color playerColor = p->getPlayerColor();+ Color playerColor = clientPlayerColor( p );Color backColor = GameMakeColor(0, 0, 0, 255);staticTextPlayer[currentButton]->winSetEnabledTextColors( playerColor, backColor );staticTextPlayer[currentButton]->winHide(FALSE);@@ -340,7 +341,7 @@ void ControlBar::populateObserverInfoWindow ( void )uString.format(L"%d",m_observerLookAtPlayer->getScoreKeeper()->getTotalUnitsLost());GadgetStaticTextSetText(staticTextNumberOfUnitsLost, uString);GadgetStaticTextSetText(staticTextPlayerName, m_observerLookAtPlayer->getPlayerDisplayName());- Color color = m_observerLookAtPlayer->getPlayerColor();+ Color color = clientPlayerColor( m_observerLookAtPlayer );staticTextPlayerName->winSetEnabledTextColors(color, GameMakeColor(0,0,0,255));winFlag->winSetEnabledImage(0, m_observerLookAtPlayer->getPlayerTemplate()->getFlagWaterMarkImage());winGeneralPortrait->winHide(FALSE);diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cppindex fb81b99b7..5b1b05ac7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp@@ -76,6 +76,7 @@#include "GameLogic/ScriptEngine.h"#include "GameLogic/VictoryConditions.h"#include "GameClient/CDCheck.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/Display.h"#include "GameClient/GUICallbacks.h"#include "GameClient/WindowLayout.h"@@ -1398,7 +1399,7 @@ void populatePlayerInfo( Player *player, Int pos){if(!player || pos > MAX_SLOTS)return;- Color color = player->getPlayerColor();+ Color color = clientPlayerColor( player );ScoreKeeper *scoreKpr = player->getScoreKeeper();if(!scoreKpr){@@ -2200,7 +2201,7 @@ void grabSinglePlayerInfo( void )sg.m_totalUnitsDestroyed += sk->getTotalUnitsDestroyed();sg.m_totalUnitsLost += sk->getTotalUnitsLost();sg.m_sideImage = player->getPlayerTemplate()->getSideIconImage();- color = player->getPlayerColor();+ color = clientPlayerColor( player );populate = TRUE;}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cppindex c1ce97f16..15a1d51b4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp@@ -54,6 +54,7 @@#include "GameClient/Drawable.h"#include "GameClient/DrawGroupInfo.h"#include "GameClient/Eva.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/GameWindowManager.h"#include "GameClient/GlobalLanguage.h"#include "GameClient/GraphDraw.h"@@ -499,6 +500,10 @@ void GameClient::reset( void )// last frame's health bars belong to the map we are leavingm_healthBarPickList.clear();+ // and so does the colour table: it is built out of a roster and a set of alliances that the+ // next map will not have+ invalidatePlayerColorScheme();+// need to reset the in game UI to clear drawables before they are destroyedTheInGameUI->reset();@@ -697,6 +702,17 @@ void GameClient::update( void )TheVideoPlayer->UPDATE();}+ // Who is drawn in which colour can move while a match runs: the options screen is reachable+ // from inside a game, and a script can make or break an alliance. A model's tint is baked into+ // its render object when the model is built and nothing repaints itself, so when the table+ // actually changes every drawable is handed its colour again. The draw module compares before+ // rebuilding, so the ones whose colour did not move cost a comparison.+ if( updatePlayerColorScheme() )+ {+ for( Drawable *draw = m_drawableList; draw; draw = draw->getNextDrawable() )+ draw->refreshIndicatorColor();+ }+Bool freezeTime = TheTacticalView->isTimeFrozen() && !TheTacticalView->isCameraMovementFinished();freezeTime = freezeTime || TheScriptEngine->isTimeFrozenDebug();freezeTime = freezeTime || TheScriptEngine->isTimeFrozenScript();diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 14caf714f..7d787e783 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -64,6 +64,7 @@#include "GameClient/GUICallbacks.h"#include "GameClient/Image.h"#include "GameClient/InGameUI.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/VideoPlayer.h"#include "GameClient/Mouse.h"#include "GameClient/Keyboard.h"@@ -442,7 +443,7 @@ void SuperweaponInfo::drawBackdrop(Int x, Int y)void SuperweaponInfo::drawName(Int x, Int y, Color color, Color dropColor){if (color == 0)- color = m_color;+ color = clientColor( m_color ); // the owner's colour was stored when the timer startedm_nameDisplayString->draw(x - m_nameDisplayString->getWidth(), y, color, dropColor);}@@ -450,7 +451,7 @@ void SuperweaponInfo::drawName(Int x, Int y, Color color, Color dropColor)void SuperweaponInfo::drawTime(Int x, Int y, Color color, Color dropColor){if (color == 0)- color = m_color;+ color = clientColor( m_color );m_timeDisplayString->draw(x, y, color, dropColor);}@@ -2888,11 +2889,11 @@ void InGameUI::createMouseoverHint( const GameMessage *msg )RGBColor rgb;if( disguised ){- rgb.setFromInt( player->getPlayerColor() );+ rgb.setFromInt( clientPlayerColor( player ) );}else{- rgb.setFromInt(draw->getObject()->getIndicatorColor());+ rgb.setFromInt( clientColor( draw->getObject()->getIndicatorColor() ) );// Unless this is a stealth garrisoned building,// Let's not use the contained's housecolor@@ -2904,7 +2905,7 @@ void InGameUI::createMouseoverHint( const GameMessage *msg ){const Player *play = contain->getApparentControllingPlayer( ThePlayerList->getLocalPlayer() );if ( play )- rgb.setFromInt( play->getPlayerColor() );+ rgb.setFromInt( clientPlayerColor( play ) );}}@@ -5728,7 +5729,9 @@ void InGameUI::addFloatingText(const UnicodeString& text,const Coord3D *pos, Col{FloatingTextData *newFTD = newInstance( FloatingTextData );newFTD->m_frameCount = 0;- newFTD->m_color = color;+ // the money a supply drop pays is drawn in its owner's colour, and the code that raises it+ // is in GameLogic, where the scheme does not exist+ newFTD->m_color = clientColor( color );newFTD->m_pos3D.x = pos->x;newFTD->m_pos3D.z = pos->z;newFTD->m_pos3D.y = pos->y;@@ -5773,7 +5776,7 @@ try_again:}FloatingTextData *newFTD = newInstance( FloatingTextData );- newFTD->m_color = color;+ newFTD->m_color = clientColor( color );newFTD->m_pos3D.x = posToUse.x;newFTD->m_pos3D.y = posToUse.y;newFTD->m_pos3D.z = posToUse.z;@@ -7119,7 +7122,7 @@ void InGameUI::drawProductionStrip( void )if( m_productionStripCount[ row ] > 0 ){- m_productionStripRowColor[ row ] = p->getPlayerColor();+ m_productionStripRowColor[ row ] = clientPlayerColor( p );row++; // a player with nothing queued gets no row rather than an empty one}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/PlayerColorScheme.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/PlayerColorScheme.cppnew file mode 100644index 000000000..59d1aa3dd--- /dev/null+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/PlayerColorScheme.cpp@@ -0,0 +1,460 @@+/*+** Command & Conquer Generals Zero Hour(tm)+** Copyright 2025 Electronic Arts Inc.+**+** This program is free software: you can redistribute it and/or modify+** it under the terms of the GNU General Public License as published by+** the Free Software Foundation, either version 3 of the License, or+** (at your option) any later version.+**+** This program is distributed in the hope that it will be useful,+** but WITHOUT ANY WARRANTY; without even the implied warranty of+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+** GNU General Public License for more details.+**+** You should have received a copy of the GNU General Public License+** along with this program. If not, see <http://www.gnu.org/licenses/>.+*/++// PlayerColorScheme.cpp+//+// The client's answer to "what colour is that player". See PlayerColorScheme.h for why this is not+// a field on Player.++#include "PreRTS.h"++#include "Common/GameCommon.h"+#include "Common/GlobalData.h"+#include "Common/Player.h"+#include "Common/PlayerList.h"+#include "Common/Team.h"+#include "GameClient/GameClient.h"+#include "GameClient/PlayerColorScheme.h"++// ------------------------------------------------------------------------------------------------+// The palette.+//+// Four shades a family, picked by eye rather than by rotating a value in HSV: a hue walked down in+// brightness alone goes muddy at the third step, and the third and fourth entries here lean the+// other way instead - one lighter and desaturated, one pushed towards the neighbouring hue. All+// four still read as "the blue one" at the distance a minimap is looked at.+//+// The order the families are handed out in matters more than which colours they are. Blue is+// always yours; red is always the first side that is not.+// ------------------------------------------------------------------------------------------------+static const Color TheFamilyShades[ PLAYER_COLOR_FAMILY_COUNT ][ PLAYER_COLOR_SHADE_COUNT ] =+{+ { 0x4C8CFF, 0x1E46B4, 0x9EC4FF, 0x0096C8 }, // blue+ { 0xFF3232, 0xA51414, 0xFF9678, 0xD25000 }, // red+ { 0x3CD23C, 0x1E7D28, 0xA0F08C, 0x6EB400 }, // green+ { 0xFFD22D, 0xBE8C00, 0xFFF096, 0xD2A03C }, // yellow+ { 0xB45AFF, 0x6E1EC8, 0xDCA0FF, 0x9646D2 }, // purple+ { 0xFF8219, 0xBE5000, 0xFFB478, 0xD26E2D }, // orange+ { 0x2DD2D2, 0x0F7D7D, 0x96F0F0, 0x3CA5B4 }, // cyan+ { 0xE1E1E1, 0x969696, 0xFAFAFA, 0xBEBEBE }, // grey+};++// Blue is spoken for - it is the side the person holding the mouse is on - so the other alliances+// are dealt from here, in an order that keeps two adjacent teams far apart on the wheel.+static const Int TheTeamFamilyOrder[] =+{+ PLAYER_COLOR_FAMILY_RED,+ PLAYER_COLOR_FAMILY_GREEN,+ PLAYER_COLOR_FAMILY_YELLOW,+ PLAYER_COLOR_FAMILY_PURPLE,+ PLAYER_COLOR_FAMILY_ORANGE,+ PLAYER_COLOR_FAMILY_CYAN,+ PLAYER_COLOR_FAMILY_GREY,+};++static const Int TheTeamFamilyCount = sizeof( TheTeamFamilyOrder ) / sizeof( TheTeamFamilyOrder[ 0 ] );++// ------------------------------------------------------------------------------------------------+// The table, and what it was built from.+// ------------------------------------------------------------------------------------------------+struct PlayerColorEntry+{+ Color trueDay; ///< what the lobby agreed on, which is what the simulation reads+ Color trueNight;+ Color day; ///< what this screen draws+ Color night;+};++static PlayerColorEntry theEntries[ MAX_PLAYER_COUNT ];+static Int theEntryCount = 0;+static Bool theTableValid = FALSE;+static Bool theTableChanged = FALSE;+static UnsignedInt theTableStamp = 0;+static UnsignedInt theTableFrame = 0;+static Bool theTableHasFrame = FALSE;++// ------------------------------------------------------------------------------------------------+static Color opaque( Color rgb )+{+ return (Color)(0xFF000000 | (rgb & 0x00FFFFFF));+}++// ------------------------------------------------------------------------------------------------+Color playerSchemeColor( Int family, Int shade )+{+ if( family < 0 )+ family = 0;+ family %= PLAYER_COLOR_FAMILY_COUNT;++ if( shade < 0 )+ shade = 0;++ // past the fourth member of one alliance the same four come round again, a quarter darker each+ // time. Seven allies is not a case anybody plays, but it is a case the lobby allows.+ const Int ring = shade / PLAYER_COLOR_SHADE_COUNT;+ Color base = TheFamilyShades[ family ][ shade % PLAYER_COLOR_SHADE_COUNT ];++ Int red = (base >> 16) & 0xFF;+ Int green = (base >> 8) & 0xFF;+ Int blue = base & 0xFF;++ for( Int i = 0; i < ring; ++i )+ {+ red = red * 3 / 4;+ green = green * 3 / 4;+ blue = blue * 3 / 4;+ }++ // a unit nobody can see on the ground is worse than two units the same colour+ if( red < 32 && green < 32 && blue < 32 )+ {+ red += 32;+ green += 32;+ blue += 32;+ }++ return opaque( (red << 16) | (green << 8) | blue );+}++// ------------------------------------------------------------------------------------------------+Color playerSchemeNightColor( Color dayColor )+{+ const Int red = (dayColor >> 16) & 0xFF;+ const Int green = (dayColor >> 8) & 0xFF;+ const Int blue = dayColor & 0xFF;++ // a quarter of the way to white. The shipped palette does this by hand, per slot, and the+ // reason is dark blue: at night the terrain is already dark and a dark unit on it is a hole.+ const Int lit_r = red + (255 - red) / 4;+ const Int lit_g = green + (255 - green) / 4;+ const Int lit_b = blue + (255 - blue) / 4;++ return opaque( (lit_r << 16) | (lit_g << 8) | lit_b );+}++// ------------------------------------------------------------------------------------------------+/** The playable players, in roster order. Civilians and the neutral player are not on anybody's+ * side, so they keep the colour the map gave them. */+static Int collectPlayableSides( Player **out )+{+ Int count = 0;++ if( ThePlayerList == NULL )+ return 0;++ const Int rosterSize = ThePlayerList->getPlayerCount();+ for( Int i = 0; i < rosterSize && count < MAX_PLAYER_COUNT; ++i )+ {+ Player *player = ThePlayerList->getNthPlayer( i );+ if( player != NULL && player->isPlayableSide() )+ out[ count++ ] = player;+ }++ return count;+}++// ------------------------------------------------------------------------------------------------+/** Everything the table is derived from, in one number. Rebuilding costs nothing, but asking the+ * relationship map eight times squared for every health bar on the screen would, so the answer is+ * kept until one of these moves: the setting, the roster, the local player, an alliance. */+static UnsignedInt computeStamp( void )+{+ UnsignedInt stamp = (UnsignedInt)TheGlobalData->m_playerColorScheme * 2654435761u;++ Player *playable[ MAX_PLAYER_COUNT ];+ const Int count = collectPlayableSides( playable );++ stamp = stamp * 31 + (UnsignedInt)count;++ Player *local = (ThePlayerList != NULL) ? ThePlayerList->getLocalPlayer() : NULL;+ stamp = stamp * 31 + (UnsignedInt)(local != NULL ? local->getPlayerIndex() + 1 : 0);++ for( Int a = 0; a < count; ++a )+ {+ stamp = stamp * 31 + (UnsignedInt)playable[ a ]->getPlayerIndex();+ stamp = stamp * 31 + (UnsignedInt)playable[ a ]->getPlayerColor();++ // the whole relationship matrix, not just the row the local player is in: the team scheme+ // groups players by who is allied with whom, and two of them making peace with each other+ // changes the grouping without changing anything about the local player at all+ for( Int b = 0; b < count; ++b )+ stamp = stamp * 3 + (UnsignedInt)playable[ a ]->getRelationship( playable[ b ]->getDefaultTeam() );+ }++ return stamp;+}++// ------------------------------------------------------------------------------------------------+static void assignScheme( Player *player, Int family, Int shade )+{+ const Int index = player->getPlayerIndex();+ if( index < 0 || index >= MAX_PLAYER_COUNT )+ return;++ theEntries[ index ].day = playerSchemeColor( family, shade );+ theEntries[ index ].night = playerSchemeNightColor( theEntries[ index ].day );+}++// ------------------------------------------------------------------------------------------------+/** You, your allies, and everybody shooting at you. Anyone the local player is neutral towards+ * keeps their own colour: a truce is not a side. */+static void applyRelationScheme( Player *local, Player **playable, Int count )+{+ Int allyShade = 0;+ Int enemyShade = 0;++ for( Int i = 0; i < count; ++i )+ {+ Player *player = playable[ i ];++ if( player == local )+ {+ assignScheme( player, PLAYER_COLOR_FAMILY_BLUE, 0 );+ continue;+ }++ switch( local->getRelationship( player->getDefaultTeam() ) )+ {+ case ALLIES:+ assignScheme( player, PLAYER_COLOR_FAMILY_GREEN, allyShade++ );+ break;++ case ENEMIES:+ assignScheme( player, PLAYER_COLOR_FAMILY_RED, enemyShade++ );+ break;++ default:+ break;+ }+ }+}++// ------------------------------------------------------------------------------------------------+/** A hue per alliance. Alliances are read off the relationship map rather than the lobby's team+ * numbers, because a script can make and break them mid-match and the lobby cannot. */+static void applyTeamScheme( Player *local, Player **playable, Int count )+{+ Int group[ MAX_PLAYER_COUNT ];+ Int groupSize[ MAX_PLAYER_COUNT ];+ Int groupCount = 0;+ Int i;++ for( i = 0; i < count; ++i )+ {+ group[ i ] = -1;+ groupSize[ i ] = 0;+ }++ for( i = 0; i < count; ++i )+ {+ if( group[ i ] >= 0 )+ continue;++ const Int mine = groupCount++;+ group[ i ] = mine;++ for( Int j = i + 1; j < count; ++j )+ {+ if( group[ j ] < 0 && playable[ i ]->getRelationship( playable[ j ]->getDefaultTeam() ) == ALLIES )+ group[ j ] = mine;+ }+ }++ // which group is drawn blue. An observer is on nobody's side, so the first group on the roster+ // takes it - the picture still has to distinguish the sides from each other.+ Int localGroup = 0;+ for( i = 0; i < count; ++i )+ {+ if( playable[ i ] == local )+ {+ localGroup = group[ i ];+ break;+ }+ }++ Int familyOfGroup[ MAX_PLAYER_COUNT ];+ Int nextFamily = 0;+ for( i = 0; i < groupCount; ++i )+ {+ if( i == localGroup )+ familyOfGroup[ i ] = PLAYER_COLOR_FAMILY_BLUE;+ else+ familyOfGroup[ i ] = TheTeamFamilyOrder[ nextFamily++ % TheTeamFamilyCount ];+ }++ for( i = 0; i < count; ++i )+ {+ const Int mine = group[ i ];+ assignScheme( playable[ i ], familyOfGroup[ mine ], groupSize[ mine ]++ );+ }+}++// ------------------------------------------------------------------------------------------------+static void rebuildTable( void )+{+ Color wasDay[ MAX_PLAYER_COUNT ];+ Int i;++ for( i = 0; i < MAX_PLAYER_COUNT; ++i )+ wasDay[ i ] = theTableValid ? theEntries[ i ].day : 0;++ theEntryCount = (ThePlayerList != NULL) ? ThePlayerList->getPlayerCount() : 0;+ if( theEntryCount > MAX_PLAYER_COUNT )+ theEntryCount = MAX_PLAYER_COUNT;++ // start from the identity: every player wears the colour the lobby gave them+ for( i = 0; i < MAX_PLAYER_COUNT; ++i )+ {+ Player *player = (ThePlayerList != NULL && i < theEntryCount) ? ThePlayerList->getNthPlayer( i ) : NULL;++ theEntries[ i ].trueDay = (player != NULL) ? player->getPlayerColor() : 0;+ theEntries[ i ].trueNight = (player != NULL) ? player->getPlayerNightColor() : 0;+ theEntries[ i ].day = theEntries[ i ].trueDay;+ theEntries[ i ].night = theEntries[ i ].trueNight;+ }++ const Int scheme = TheGlobalData->m_playerColorScheme;++ if( scheme != PLAYER_COLORS_ORIGINAL && ThePlayerList != NULL )+ {+ Player *playable[ MAX_PLAYER_COUNT ];+ const Int count = collectPlayableSides( playable );+ Player *local = ThePlayerList->getLocalPlayer();++ // an observer has no side, so there is no "you" and no "them"; the team scheme is the one+ // that still says something, and it is what the relation scheme falls back to+ if( scheme == PLAYER_COLORS_RELATION && local != NULL && local->isPlayableSide() )+ applyRelationScheme( local, playable, count );+ else+ applyTeamScheme( local, playable, count );+ }++ theTableChanged = FALSE;+ for( i = 0; i < MAX_PLAYER_COUNT; ++i )+ {+ if( wasDay[ i ] != theEntries[ i ].day )+ theTableChanged = TRUE;+ }++ theTableValid = TRUE;+}++// ------------------------------------------------------------------------------------------------+static void ensureTable( void )+{+ if( TheGlobalData == NULL )+ return;++ // at most one rebuild a frame; the shell has no frame counter running, and does not need one+ if( TheGameClient != NULL )+ {+ const UnsignedInt frame = TheGameClient->getFrame();+ if( theTableValid && theTableHasFrame && theTableFrame == frame )+ return;++ theTableFrame = frame;+ theTableHasFrame = TRUE;+ }++ const UnsignedInt stamp = computeStamp();+ if( theTableValid && stamp == theTableStamp )+ return;++ theTableStamp = stamp;+ rebuildTable();+}++// ------------------------------------------------------------------------------------------------+void invalidatePlayerColorScheme( void )+{+ theTableValid = FALSE;+ theTableHasFrame = FALSE;+ theTableChanged = FALSE;+ theEntryCount = 0;+}++// ------------------------------------------------------------------------------------------------+Bool updatePlayerColorScheme( void )+{+ ensureTable();++ const Bool changed = theTableChanged;+ theTableChanged = FALSE;+ return changed;+}++// ------------------------------------------------------------------------------------------------+Color clientPlayerColor( const Player *player )+{+ if( player == NULL )+ return 0;++ if( TheGlobalData == NULL || TheGlobalData->m_playerColorScheme == PLAYER_COLORS_ORIGINAL )+ return player->getPlayerColor();++ ensureTable();++ const Int index = player->getPlayerIndex();+ if( index < 0 || index >= MAX_PLAYER_COUNT )+ return player->getPlayerColor();++ return theEntries[ index ].day;+}++// ------------------------------------------------------------------------------------------------+Color clientPlayerNightColor( const Player *player )+{+ if( player == NULL )+ return 0;++ if( TheGlobalData == NULL || TheGlobalData->m_playerColorScheme == PLAYER_COLORS_ORIGINAL )+ return player->getPlayerNightColor();++ ensureTable();++ const Int index = player->getPlayerIndex();+ if( index < 0 || index >= MAX_PLAYER_COUNT )+ return player->getPlayerNightColor();++ return theEntries[ index ].night;+}++// ------------------------------------------------------------------------------------------------+Color clientColor( Color logicColor )+{+ if( TheGlobalData == NULL || TheGlobalData->m_playerColorScheme == PLAYER_COLORS_ORIGINAL )+ return logicColor;++ ensureTable();++ // the alpha is the caller's - a floating text draws its owner's colour at the transparency it+ // chose - so only the three colour bytes are matched and replaced+ const Color rgb = logicColor & 0x00FFFFFF;+ const Color alpha = logicColor & 0xFF000000;++ for( Int i = 0; i < theEntryCount; ++i )+ {+ if( (theEntries[ i ].trueDay & 0x00FFFFFF) == rgb )+ return alpha | (theEntries[ i ].day & 0x00FFFFFF);++ if( (theEntries[ i ].trueNight & 0x00FFFFFF) == rgb )+ return alpha | (theEntries[ i ].night & 0x00FFFFFF);+ }++ return logicColor;+}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cppindex bf700306d..3b848a0c1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/RadiusDecal.cpp@@ -32,6 +32,7 @@#include "Common/Player.h"#include "Common/PlayerList.h"#include "Common/Xfer.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/RadiusDecal.h"#include "GameClient/Shadow.h"#include "GameLogic/GameLogic.h"@@ -86,7 +87,7 @@ void RadiusDecalTemplate::createRadiusDecal(const Coord3D& pos, Real radius, conif (result.m_decal){result.m_decal->setAngle(0.0f);- result.m_decal->setColor(m_color == 0 ? owningPlayer->getPlayerColor() : m_color);+ result.m_decal->setColor(m_color == 0 ? clientPlayerColor(owningPlayer) : m_color);result.m_decal->setPosition(pos.x, pos.y, pos.z);result.m_template = this;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cppindex b1d77fba7..d95843149 100644--- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp@@ -39,6 +39,7 @@#include "Common/Recorder.h"#include "GameClient/Diplomacy.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/GameText.h"#include "GameClient/MessageBox.h"#include "GameNetwork/ConnectionManager.h"@@ -706,7 +707,7 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg)if ( ((1<<m_localSlot) & msg->getPlayerMask() ) && canSeeChat ){RGBColor rgb;- rgb.setFromInt(player->getPlayerColor());+ rgb.setFromInt(clientPlayerColor(player));TheInGameUI->messageColor(&rgb, UnicodeString(L"%ls"), unitext.str());// feedback for received chat messages in-gamediff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cppindex 7637c854e..f4fdb5e99 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp@@ -47,6 +47,7 @@#include "Common/QuickTrig.h"#include "GameClient/Drawable.h"#include "GameClient/FXList.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/Shadow.h"#include "GameLogic/GameLogic.h" // for real-time frame#include "Common/Player.h"@@ -1765,10 +1766,12 @@ W3DModelDraw::W3DModelDraw(Thing *thing, const ModuleData* moduleData) : DrawModObject* obj = draw->getObject();if (obj){+ // this is the one path that reads the indicator colour straight off the object rather+ // than being handed it by Drawable::setIndicatorColor, so the scheme is applied here tooif (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT)- m_hexColor = obj->getNightIndicatorColor();+ m_hexColor = clientColor( obj->getNightIndicatorColor() );else- m_hexColor = obj->getIndicatorColor();+ m_hexColor = clientColor( obj->getIndicatorColor() );}// THE VAST MAJORITY OF THESE SHOULD BE TRUEdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cppindex 79ba666cd..d9d5bf87f 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp@@ -45,6 +45,7 @@#include "GameClient/Drawable.h"#include "GameClient/ParticleSys.h"#include "GameClient/Color.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/View.h"#include "W3DDevice/GameClient/HeightMap.h"#include "W3DDevice/GameClient/W3DScene.h"@@ -955,7 +956,7 @@ void RTS3DScene::updatePlayerColorPasses(void){ Player *player=ThePlayerList->getNthPlayer(i);Int playerIndex=player->getPlayerIndex();Real red,green,blue,alpha;- GameGetColorComponentsReal(player->getPlayerColor(),&red,&green,&blue,&alpha);+ GameGetColorComponentsReal(clientPlayerColor(player),&red,&green,&blue,&alpha);RGB_To_HSV(hsv,Vector3(red,green,blue));hsv.Z*=TheGlobalData->m_occludedLuminanceScale;HSV_To_RGB(rgb,hsv);@@ -1421,7 +1422,7 @@ void RTS3DScene::flushOccludedObjectsIntoStencil(RenderInfoClass & rinfo)draw = ((DrawableInfo *)playerObjects[i][0]->Get_User_Data())->m_drawable;Object *object=draw->getObject();- Int color=object->getControllingPlayer()->getPlayerColor();+ Int color=clientPlayerColor(object->getControllingPlayer());RGB_To_HSV(hsv,Vector3(((color>>16)&0xff)/255.0f,((color>>8)&0xff)/255.0f,(color &0xff)/255.0f));hsv.Z*=TheGlobalData->m_occludedLuminanceScale;HSV_To_RGB(rgb,hsv);diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex f9d208029..ce6edb4c5 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -62,6 +62,7 @@#include "Common/RadarShroudCache.h"#include "GameClient/Gadget.h"#include "GameClient/GadgetTabControl.h"+#include "GameClient/PlayerColorScheme.h"#include "GameClient/Image.h"#include "GameNetwork/NetworkUtil.h"#include "GameNetwork/NetCommandList.h"@@ -5946,6 +5947,125 @@ TEST(health_bar_mode_round_trips_through_options_ini)TheWritableGlobalData = saved;}+TEST(player_color_scheme_round_trips_through_options_ini)+{+ const OptionDef *def = findOptionDef( "PlayerColors" );+ CHECK( def != NULL );+ CHECK_EQ( (Int)def->kind, (Int)OPTION_ENUM );+ CHECK_EQ( (Int)def->apply, (Int)APPLY_LIVE );+ CHECK_EQ( def->lo, 0 );+ CHECK_EQ( def->hi, PLAYER_COLOR_SCHEME_COUNT - 1 );++ GlobalData *saved = TheWritableGlobalData;+ TheWritableGlobalData = NEW GlobalData;++ // nobody's colours change until they ask+ CHECK_EQ( TheGlobalData->m_playerColorScheme, (Int)PLAYER_COLORS_ORIGINAL );++ TheWritableGlobalData->m_playerColorScheme = PLAYER_COLORS_RELATION;++ UserPreferences pref;+ saveOptionsToPreferences( pref );+ CHECK_STR( pref[ AsciiString( "PlayerColors" ) ].str(), "1" );++ TheWritableGlobalData->m_playerColorScheme = PLAYER_COLORS_ORIGINAL;+ loadOptionsFromPreferences( pref );+ CHECK_EQ( TheGlobalData->m_playerColorScheme, (Int)PLAYER_COLORS_RELATION );++ pref[ AsciiString( "PlayerColors" ) ] = AsciiString( "99" );+ loadOptionsFromPreferences( pref );+ CHECK_EQ( TheGlobalData->m_playerColorScheme, (Int)PLAYER_COLOR_SCHEME_COUNT - 1 );++ TheWritableGlobalData->m_playerColorScheme = PLAYER_COLORS_ORIGINAL;+ invalidatePlayerColorScheme();++ delete TheWritableGlobalData;+ TheWritableGlobalData = saved;+}++/** Every colour the scheme can hand out has to be opaque and has to be visible: an alpha of zero+ draws nothing at all, and a member of an alliance past the fourth is a darkened repeat that must+ not reach black. */+TEST(scheme_colors_are_opaque_and_never_black)+{+ for( Int family = 0; family < PLAYER_COLOR_FAMILY_COUNT; ++family )+ {+ for( Int shade = 0; shade < PLAYER_COLOR_SHADE_COUNT * 3; ++shade )+ {+ const Color c = playerSchemeColor( family, shade );++ CHECK_EQ( (Int)((c >> 24) & 0xFF), 255 );+ CHECK( (c & 0x00FFFFFF) != 0 );++ const Int red = (c >> 16) & 0xFF;+ const Int green = (c >> 8) & 0xFF;+ const Int blue = c & 0xFF;+ CHECK( red + green + blue >= 96 );+ }+ }++ // four members of one alliance are four different colours, which is the whole point of shades+ for( Int a = 0; a < PLAYER_COLOR_SHADE_COUNT; ++a )+ for( Int b = a + 1; b < PLAYER_COLOR_SHADE_COUNT; ++b )+ CHECK( playerSchemeColor( PLAYER_COLOR_FAMILY_RED, a ) != playerSchemeColor( PLAYER_COLOR_FAMILY_RED, b ) );++ // and the first shade of two families is never the same colour+ for( Int f1 = 0; f1 < PLAYER_COLOR_FAMILY_COUNT; ++f1 )+ for( Int f2 = f1 + 1; f2 < PLAYER_COLOR_FAMILY_COUNT; ++f2 )+ CHECK( playerSchemeColor( f1, 0 ) != playerSchemeColor( f2, 0 ) );+}++/** Night is the day colour a quarter of the way to white, and never darker: the reason the shipped+ palette carries a separate night colour at all is that a dark unit on a night map is a hole. */+TEST(scheme_night_colors_are_lighter_than_their_day)+{+ for( Int family = 0; family < PLAYER_COLOR_FAMILY_COUNT; ++family )+ {+ const Color day = playerSchemeColor( family, 0 );+ const Color night = playerSchemeNightColor( day );++ CHECK_EQ( (Int)((night >> 24) & 0xFF), 255 );+ CHECK( (Int)((night >> 16) & 0xFF) >= (Int)((day >> 16) & 0xFF) );+ CHECK( (Int)((night >> 8) & 0xFF) >= (Int)((day >> 8) & 0xFF) );+ CHECK( (Int)( night & 0xFF) >= (Int)( day & 0xFF) );+ }++ // white has nowhere lighter to go+ CHECK_EQ( (Int)(playerSchemeNightColor( 0xFFFFFFFF ) & 0x00FFFFFF), 0x00FFFFFF );+}++/** The scheme is a translation and nothing more, so the setting nobody changed has to leave every+ colour exactly as it arrived, and a colour that belongs to no player has to pass through under+ any setting - a crate's floating text and a script's own colour both come through here. */+TEST(original_scheme_and_unknown_colors_pass_through_untouched)+{+ GlobalData *saved = TheWritableGlobalData;+ TheWritableGlobalData = NEW GlobalData;+ invalidatePlayerColorScheme();++ const Color sample[] = { 0xFF102030, 0xE6FF0000, 0x00000000, 0xFFFFFFFF };++ for( Int i = 0; i < 4; ++i )+ CHECK_EQ( (Int)clientColor( sample[ i ] ), (Int)sample[ i ] );++ TheWritableGlobalData->m_playerColorScheme = PLAYER_COLORS_TEAM;+ invalidatePlayerColorScheme();++ // there is no player list in a test, so no colour is anybody's and all four still come back+ for( Int i = 0; i < 4; ++i )+ CHECK_EQ( (Int)clientColor( sample[ i ] ), (Int)sample[ i ] );++ // nothing to draw for nobody+ CHECK_EQ( (Int)clientPlayerColor( NULL ), 0 );+ CHECK_EQ( (Int)clientPlayerNightColor( NULL ), 0 );++ TheWritableGlobalData->m_playerColorScheme = PLAYER_COLORS_ORIGINAL;+ invalidatePlayerColorScheme();++ delete TheWritableGlobalData;+ TheWritableGlobalData = saved;+}+/** The bar is a 2D overlay drawn after the scene, so the pick ray knows nothing about it and aclick that lands on one used to hit bare ground. Every bar is on in this fork, which makes itthe one part of a unit that is never behind a building - and at full zoom out a rifleman is adiff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.pyindex 8799085e0..214e5add7 100644--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py@@ -97,6 +97,8 @@ CONTROLS = [# with their checkboxes; the four camera habits that used to be on Controls went the same way.("PageGameplay", LABEL, "LabelHealthBars", "GUI:HealthBars", 160, 104, 230, 24),("PageGameplay", COMBO, "ComboBoxHealthBars", None, 160, 128, 200, 24),+ ("PageGameplay", LABEL, "LabelPlayerColors", "GUI:PlayerColors", 160, 160, 230, 24),+ ("PageGameplay", COMBO, "ComboBoxPlayerColors", None, 160, 184, 200, 24),]# What is left of EA's own controls, page by page, at the rhythm the display page's right column