Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): frame rate limit option and a 60 fps shell cap
Olcay Seygan56303cbfa953
diff --git a/GeneralsMD/Code/Data/French/Generals.str b/GeneralsMD/Code/Data/French/Generals.strindex d55fe9a5b..2fcd8747a 100644--- a/GeneralsMD/Code/Data/French/Generals.str+++ b/GeneralsMD/Code/Data/French/Generals.str@@ -16045,6 +16045,34 @@ TOOLTIP:VSync"Cale l'image sur le moniteur pour qu'elle ne se déchire pas. Désactivé, l'image va aussi vite que la machine la dessine. Appliqué quand vous cliquez sur Accepter."END+GUI:FrameRateLimit+"Limite d'images par seconde"+END++GUI:FrameRateLimit0+"Désactivée"+END++GUI:FrameRateLimit1+"240 FPS"+END++GUI:FrameRateLimit2+"144 FPS"+END++GUI:FrameRateLimit3+"120 FPS"+END++GUI:FrameRateLimit4+"60 FPS"+END++TOOLTIP:FrameRateLimit+"Le nombre maximal d'images par seconde que le jeu dessine en partie. Une limite plus basse garde la carte graphique plus fraîche et plus silencieuse, sans ralentir le jeu. Les menus s'arrêtent toujours à 60."+END+GUI:ClassicGraphics"Graphismes classiques"ENDdiff --git a/GeneralsMD/Code/Data/German/Generals.str b/GeneralsMD/Code/Data/German/Generals.strindex fae9bb1c5..c54a5b713 100644--- a/GeneralsMD/Code/Data/German/Generals.str+++ b/GeneralsMD/Code/Data/German/Generals.str@@ -14353,6 +14353,34 @@ TOOLTIP:VSync"Hält das Bild am Monitor fest, damit es nicht reißt. Aus läuft das Bild so schnell, wie der Rechner zeichnet. Gilt nach Annehmen."END+GUI:FrameRateLimit+"Bildratenbegrenzung"+END++GUI:FrameRateLimit0+"Aus"+END++GUI:FrameRateLimit1+"240 FPS"+END++GUI:FrameRateLimit2+"144 FPS"+END++GUI:FrameRateLimit3+"120 FPS"+END++GUI:FrameRateLimit4+"60 FPS"+END++TOOLTIP:FrameRateLimit+"Wie viele Bilder pro Sekunde das Spiel in einer Partie höchstens zeichnet. Ein niedrigeres Limit hält die Grafikkarte kühler und leiser und bremst das Spiel nicht. Die Menüs halten immer bei 60."+END+GUI:ClassicGraphics"Klassische Grafik"ENDdiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex 3352c0fa4..431ec44a7 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -519,6 +519,34 @@ TOOLTIP:VSync"Holds the picture to the monitor so it does not tear. Off, the picture runs as fast as the machine draws. Applied when you Accept."END+GUI:FrameRateLimit+"Frame Rate Limit"+END++GUI:FrameRateLimit0+"Off"+END++GUI:FrameRateLimit1+"240 FPS"+END++GUI:FrameRateLimit2+"144 FPS"+END++GUI:FrameRateLimit3+"120 FPS"+END++GUI:FrameRateLimit4+"60 FPS"+END++TOOLTIP:FrameRateLimit+"The most pictures a second the game draws in a match. A lower limit keeps the graphics card cooler and quieter and does not slow the game down. The menus always stop at 60."+END+GUI:ClassicGraphics"Classic Graphics"ENDdiff --git a/GeneralsMD/Code/Data/Russian/Generals.str b/GeneralsMD/Code/Data/Russian/Generals.strindex 10dd04705..90236a586 100644--- a/GeneralsMD/Code/Data/Russian/Generals.str+++ b/GeneralsMD/Code/Data/Russian/Generals.str@@ -16073,6 +16073,34 @@ TOOLTIP:VSync"Привязывает картинку к частоте монитора, чтобы не было разрывов. Выключено: картинка рисуется так быстро, как может компьютер. Применяется при нажатии «Принять»."END+GUI:FrameRateLimit+"Ограничение FPS"+END++GUI:FrameRateLimit0+"Выкл."+END++GUI:FrameRateLimit1+"240 FPS"+END++GUI:FrameRateLimit2+"144 FPS"+END++GUI:FrameRateLimit3+"120 FPS"+END++GUI:FrameRateLimit4+"60 FPS"+END++TOOLTIP:FrameRateLimit+"Сколько кадров в секунду игра рисует в матче, не больше. С меньшим пределом видеокарта греется и шумит меньше, а игра не замедляется. В меню всегда не больше 60."+END+GUI:ClassicGraphics"Классическая графика"ENDdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 8901829e8..f7808c257 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -15033,6 +15033,34 @@ TOOLTIP:VSync"Görüntüyü monitöre eşler, böylece ekran yırtılmaz. Kapalıyken görüntü, bilgisayarın çizebildiği kadar hızlı akar. Kabul Et'e bastığınızda uygulanır."END+GUI:FrameRateLimit+"FPS Sınırı"+END++GUI:FrameRateLimit0+"Kapalı"+END++GUI:FrameRateLimit1+"240 FPS"+END++GUI:FrameRateLimit2+"144 FPS"+END++GUI:FrameRateLimit3+"120 FPS"+END++GUI:FrameRateLimit4+"60 FPS"+END++TOOLTIP:FrameRateLimit+"Maçta saniyede en fazla kaç kare çizileceği. Sınırı düşürürsen ekran kartın daha serin ve sessiz çalışır, oyun da yavaşlamaz. Menüler zaten 60'ta durur."+END+GUI:ClassicGraphics"Klasik Grafikler"ENDdiff --git a/GeneralsMD/Code/Data/Ukrainian/Generals.str b/GeneralsMD/Code/Data/Ukrainian/Generals.strindex 699d60cc5..dea23fff0 100644--- a/GeneralsMD/Code/Data/Ukrainian/Generals.str+++ b/GeneralsMD/Code/Data/Ukrainian/Generals.str@@ -16073,6 +16073,34 @@ TOOLTIP:VSync"Прив'язує картинку до монітора, щоб вона не рвалася. Вимкнена — картинка йде так швидко, як малює комп'ютер. Застосовується після Прийняти."END+GUI:FrameRateLimit+"Обмеження FPS"+END++GUI:FrameRateLimit0+"Вимк."+END++GUI:FrameRateLimit1+"240 FPS"+END++GUI:FrameRateLimit2+"144 FPS"+END++GUI:FrameRateLimit3+"120 FPS"+END++GUI:FrameRateLimit4+"60 FPS"+END++TOOLTIP:FrameRateLimit+"Скільки кадрів на секунду гра малює в матчі, не більше. З меншою межею відеокарта гріється й шумить менше, а гра не сповільнюється. У меню завжди не більше 60."+END+GUI:ClassicGraphics"Класична графіка"ENDdiff --git a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wndindex 02a5348ec..2c51d7788 100644--- a/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd+++ b/GeneralsMD/Code/Data/Window/Menus/OptionsMenuClassic.wnd@@ -2652,6 +2652,294 @@ WINDOWIMAGE: NoImage, COLOR: 255 255 255 0, BORDERCOLOR: 255 255 255 0;ENDCHILD+ WINDOW+ WINDOWTYPE = STATICTEXT;+ SCREENRECT = UPPERLEFT: 282 294, BOTTOMRIGHT: 506 318, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:LabelFrameRateLimit";+ TOOLTIPTEXT = "TOOLTIP:FrameRateLimit";+ 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:FrameRateLimit";+ 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: 288 318, BOTTOMRIGHT: 512 342, CREATIONRESOLUTION: 800 600;+ NAME = "OptionsMenu.wnd:ComboBoxFrameRateLimit";+ TOOLTIPTEXT = "TOOLTIP:FrameRateLimit";+ 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;+ END+ CHILDWINDOWWINDOWTYPE = STATICTEXT;SCREENRECT = UPPERLEFT: 536 182, BOTTOMRIGHT: 760 206, CREATIONRESOLUTION: 800 600;diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.hindex b2d236792..46afbadc4 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h@@ -180,6 +180,8 @@ public:///< empty is the primary. See Common/Monitors.h.Int m_msaaLevel; ///< multisampling, as an index into the levels the options menu offersBool m_vsync; ///< wait for the monitor; off is the uncapped picture the frame-rate cap removal shipped+ Int m_frameRateLimit; ///< "FrameRateLimit": the player's picture cap as a level, frameRateLimitForLevel gives the rate+ Bool m_noFrameRateCap; ///< -noFPSLimit: no picture cap at all, the shell's 60 includedBool m_direct3D11; ///< draw and present through the Direct3D 11 backend; -d3d9 and -headless turn it offAsciiString m_direct3D11DumpPath; ///< -dx11dump: where to write each generated programAsciiString m_direct3D11PostChain; ///< -dx11post: the effects run over the finished D3D11 framediff --git a/GeneralsMD/Code/GameEngine/Include/Common/OptionsCatalog.h b/GeneralsMD/Code/GameEngine/Include/Common/OptionsCatalog.hindex 77723af5d..4ad04c88e 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/OptionsCatalog.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/OptionsCatalog.h@@ -155,6 +155,12 @@ enum { SHADOW_QUALITY_COUNT = 3 };// What colours a health bar: 0 the health, green through red, 1 the owner's player colour.enum { HEALTH_BAR_COLORS_COUNT = 2 };+// The picture cap: off, 240, 144, 120 or 60 pictures a second. Options.ini stores the level.+enum { FRAME_RATE_LIMIT_COUNT = 5 };++/** Pictures a second for a stored FrameRateLimit level. 0 is no cap. */+extern Int frameRateLimitForLevel( Int level );+//-----------------------------------------------------------------------------// The Performance / Quality slider on the Graphics page. One row per graphics setting the Graphics// and Effects pages carry, holding what that setting's control shows at each step of the slider:diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cppindex 4afec4fd8..1112ec69a 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp@@ -1518,12 +1518,15 @@ Int parseFPSLimit(char *args[], int num)and GameEngine::execute() never sleeps for a frame budget, so rendering is already uncappedunconditionally and m_framesPerSecondLimit means game speed and nothing else. Raising it herewould just run the match in fast-forward: superweapon and build timers count real seconds off a- clock ticking a thousand times too fast. Use -fps to ask for that on purpose. */+ clock ticking a thousand times too fast. Use -fps to ask for that on purpose. Since GitHub #149+ there is a picture cap again, the player's FrameRateLimit and 60 in the shell, and this switch lifts+ both for the run: the measuring harnesses pass it to time a frame, not a wait. */Int parseNoFPSLimit(char *args[], int num){if (TheWritableGlobalData){TheWritableGlobalData->m_useFpsLimit = false;+ TheWritableGlobalData->m_noFrameRateCap = TRUE;}return 1;}diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex dfe520199..1b5c26770 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -38,6 +38,7 @@#endif#include "Lib/Clock.h"#include <exception>+#include <thread> // the picture cap spins its last millisecond on std::this_thread::yield#include "Lib/WideCharFns.h"@@ -66,6 +67,7 @@#include "Common/LocalFileSystem.h"#include "Common/CDManager.h"#include "Common/GlobalData.h"+#include "Common/OptionsCatalog.h" // frameRateLimitForLevel, the picture cap's rate#include "Common/PerfTimer.h"#include "Common/JobSystem.h"#include "Common/LogicThread.h"@@ -2887,6 +2889,7 @@ static void updateHeadlessRun( void )static Real s_logicAccumMs = 0.0f;static Bool s_passPlanned = FALSE;static GameEngine::LogicPassPlan s_passPlan;+static Bool s_passWasFast = FALSE; ///< the last pass ran a logic frame a pass (headless, -turbo, fast-forward, -video): no picture capstatic UnsignedInt s_frameBeforeOverlap = 0;static UnsignedInt s_planTimeMs = 0; ///< when the pacer last spent the time since the one beforestatic Int64 s_planTimeTicks = 0; ///< the same moment on the fine clock, for smooth motion@@ -3170,6 +3173,7 @@ void GameEngine::update( void )planLogicPass( plan );s_passPlanned = FALSE;const Bool fastMode = plan.fastMode;+ s_passWasFast = fastMode;const Bool networkPaced = plan.networkPaced;const Bool mayCatchUp = plan.mayCatchUp;// LOGIC-THREAD.md phase 3, step 3b: this pass's first tick ran beside the render and was flushed@@ -3425,8 +3429,91 @@ extern bool DX8Wrapper_IsWindowed;extern HWND ApplicationHWnd;#endif+/* The picture cap (GitHub #149, #153): the rate a pass may present at, 0 for none. An uncapped+ picture held a card at 100% and 86 C, and the main menu, which draws next to nothing, ran it+ hottest. The shell holds 60 whatever the player picked; a match holds the FrameRateLimit row.+ Never under the logic's own rate, so a pass a tick is always there to be had; the pacer runs+ the ticks on the wall clock and catches up in a pass, and a wait outside it moves none of them.+ None at all for -noFPSLimit and for a pass that ran a logic frame a pass (-headless, -turbo, a+ replay's fast-forward, -video): those want every pass they can get. */+static const Int SHELL_FRAME_RATE_CAP = 60;++static Int renderCapFramesPerSecond( Int logicFps )+{+ if (TheGlobalData->m_noFrameRateCap || TheGlobalData->m_headless || TheGlobalData->m_turbo || s_passWasFast)+ return 0;+ Int fps = frameRateLimitForLevel( TheGlobalData->m_frameRateLimit );+ if (!TheGameLogic->isInGame() || TheGameLogic->isInShellGame())+ {+ if (fps == 0 || fps > SHELL_FRAME_RATE_CAP)+ fps = SHELL_FRAME_RATE_CAP;+ }+ if (fps > 0 && fps < logicFps)+ fps = logicFps;+ return fps;+}++/* Hold the thread until the tick clock reads `deadline`. A sleep cannot hit a point in time: Sleep(1)+ under a 1 ms timer period still ends anywhere up to 2 ms late, a whole eighth of a 144 Hz picture.+ So the wait sleeps to a millisecond short of it on a high resolution waitable timer (Windows 10+ 1803 on; an older Windows gets the plain one), then yields the thread until the clock gets there. */+#if defined(_WIN32) && !defined(CREATE_WAITABLE_TIMER_HIGH_RESOLUTION)+#define CREATE_WAITABLE_TIMER_HIGH_RESOLUTION 0x00000002+#endif++static void waitForTicks( Int64 deadline )+{+ const Int64 perSecond = Clock_Ticks_Per_Second();+ const Int64 sleepTicks = deadline - Clock_Ticks() - perSecond / 1000;+ if (sleepTicks > 0)+ {+#if defined(_WIN32)+ static HANDLE timer = NULL;+ if (timer == NULL)+ timer = CreateWaitableTimerExW( NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS );+ if (timer == NULL)+ timer = CreateWaitableTimerW( NULL, TRUE, NULL );+ LARGE_INTEGER due;+ due.QuadPart = -(LONGLONG)( sleepTicks * 10000000 / perSecond ); // relative, in 100 ns+ SetWaitableTimer( timer, &due, 0, NULL, NULL, FALSE );+ WaitForSingleObject( timer, INFINITE );+#else+ std::this_thread::sleep_for( std::chrono::nanoseconds( sleepTicks * 1000000000 / perSecond ) );+#endif+ }+ while (Clock_Ticks() < deadline)+ std::this_thread::yield();+}++/** Wait out what is left of this picture's share of a second, after the present and before the next+ * pass reads the input. The next deadline steps on from the last, so a picture that ran late is+ * paid back by the next one's shorter wait; one more than a whole picture late starts the count again. */+static void waitForRenderCap( Int logicFps )+{+ static Int64 s_nextPicture = 0;+ static Int s_loggedCap = -1;+ const Int fps = renderCapFramesPerSecond( logicFps );+ if (fps != s_loggedCap)+ {+ DEBUG_LOG(( "RENDER CAP %d pictures a second%s\n", fps, fps == 0 ? " (none)" : "" ));+ s_loggedCap = fps;+ }+ if (fps <= 0)+ {+ s_nextPicture = 0;+ return;+ }+ const Int64 period = Clock_Ticks_Per_Second() / fps;+ const Int64 now = Clock_Ticks();+ if (s_nextPicture == 0 || now - s_nextPicture > period)+ s_nextPicture = now;+ else if (now < s_nextPicture)+ waitForTicks( s_nextPicture );+ s_nextPicture += period;+}+/** ------------------------------------------------------------------------------------------------ * The "main loop" of the game engine. It will not return until the game exits.+ * The "main loop" of the game engine. It will not return until the game exits.*/void GameEngine::execute( void ){@@ -3545,11 +3632,12 @@ void GameEngine::execute( void )} // perf{- // Rendering runs uncapped everywhere now, menus included. Game speed stays- // constant because the logic tick is paced by wall clock inside update(), and the- // menus no longer need a capped loop either: AnimateWindowManager::update paces- // its own stepping off the wall clock, so the window animations keep the cadence- // they were tuned for however fast the loop runs.+ // Game speed stays constant because the logic tick is paced by wall clock inside+ // update(), whatever the picture rate, and AnimateWindowManager::update paces the+ // menus' animations off the wall clock too. So the only wait in the loop is the+ // picture cap's, outside the pass: the logic thread is idle by now, the overlapped+ // tick having been flushed at the end of the draw.+ waitForRenderCap( m_maxFPS );prevLoopTime = Clock_Milliseconds();#if defined(_DEBUG) || defined(_INTERNAL)diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex b50ef0d83..5e58f0742 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -664,6 +664,8 @@ GlobalData::GlobalData()m_fullscreenScaling = FULLSCREEN_SCALING_STRETCH; // what EA's fullscreen mode change gave on most monitorsm_msaaLevel = 0;m_vsync = FALSE;+ m_frameRateLimit = 0;+ m_noFrameRateCap = FALSE;m_direct3D11 = TRUE;m_direct3D11DumpPath.clear();// The Direct3D 11 frame gets every effect the backend has unless -dx11post names a chain of itsdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cppindex 8df1b0f2a..f50becae0 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp@@ -119,6 +119,7 @@ OPTION_INT_ACCESSORS( m_windowMode )OPTION_INT_ACCESSORS( m_fullscreenScaling )OPTION_INT_ACCESSORS( m_msaaLevel )OPTION_BOOL_ACCESSORS( m_vsync )+OPTION_INT_ACCESSORS( m_frameRateLimit )OPTION_INT_ACCESSORS( m_waterStyle )OPTION_INT_ACCESSORS( m_cloudStyle )OPTION_BOOL_ACCESSORS( m_classicGraphics )@@ -166,6 +167,16 @@ unsigned msaaSamplesForLevel( Int level )return TheMsaaSamples[ level ];}+//-----------------------------------------------------------------------------+static const Int TheFrameRateLimits[ FRAME_RATE_LIMIT_COUNT ] = { 0, 240, 144, 120, 60 };++Int frameRateLimitForLevel( Int level )+{+ if( level <= 0 || level >= FRAME_RATE_LIMIT_COUNT )+ return 0;+ return TheFrameRateLimits[ level ];+}+//-----------------------------------------------------------------------------Int msaaLevelForSamples( unsigned samples ){@@ -475,6 +486,14 @@ const OptionDef TheOptionCatalog[] =OPTION_BOOL, APPLY_DEVICE_RESET, 0, 1,get_m_vsync, set_m_vsync },+ // A ceiling on the pictures a second, for a card that runs hot drawing hundreds of them (GitHub+ // #149). GameEngine::execute waits out the rest of each picture's time after the present; the+ // logic is paced by its own clock and the cap never goes under the logic's rate. Off is the+ // uncapped picture. The shell and its menus hold 60 whatever this says (#153).+ { "FrameRateLimit", OPT_WND( "ComboBoxFrameRateLimit" ), "GUI:FrameRateLimit",+ OPTION_ENUM, APPLY_LIVE, 0, FRAME_RATE_LIMIT_COUNT - 1,+ get_m_frameRateLimit, set_m_frameRateLimit },+// Water selects a complete surface path, including geometry and reflections. The water// object applies it at the next frame boundary, including while the options menu is paused.{ "WaterStyle", OPT_WND( "ComboBoxWaterStyle" ), "GUI:WaterStyle",diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 717e415ef..06d851fc5 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -9912,6 +9912,42 @@ TEST(health_bar_colors_round_trip_through_options_ini)TheWritableGlobalData = saved;}+/** The picture cap (GitHub #149): off with no line, so Classic draws as fast as it always did, and+ each level the rate the combo box names. */+TEST(frame_rate_limit_round_trips_through_options_ini)+{+ const OptionDef *def = findOptionDef( "FrameRateLimit" );+ CHECK( def != NULL );+ CHECK_EQ( (Int)def->kind, (Int)OPTION_ENUM );+ CHECK_EQ( (Int)def->apply, (Int)APPLY_LIVE );+ CHECK_EQ( def->hi, FRAME_RATE_LIMIT_COUNT - 1 );++ CHECK_EQ( frameRateLimitForLevel( 0 ), 0 );+ CHECK_EQ( frameRateLimitForLevel( 1 ), 240 );+ CHECK_EQ( frameRateLimitForLevel( 2 ), 144 );+ CHECK_EQ( frameRateLimitForLevel( 3 ), 120 );+ CHECK_EQ( frameRateLimitForLevel( 4 ), 60 );+ CHECK_EQ( frameRateLimitForLevel( FRAME_RATE_LIMIT_COUNT ), 0 );++ GlobalData *saved = TheWritableGlobalData;+ TheWritableGlobalData = NEW GlobalData;++ CHECK_EQ( TheGlobalData->m_frameRateLimit, 0 );+ CHECK_EQ( optionDefaultValue( *def ), 0 );++ UserPreferences pref;+ pref[ AsciiString( "FrameRateLimit" ) ] = AsciiString( "4" );+ loadOptionsFromPreferences( pref );+ CHECK_EQ( frameRateLimitForLevel( TheGlobalData->m_frameRateLimit ), 60 );++ pref[ AsciiString( "FrameRateLimit" ) ] = AsciiString( "9" );+ loadOptionsFromPreferences( pref );+ CHECK_EQ( TheGlobalData->m_frameRateLimit, FRAME_RATE_LIMIT_COUNT - 1 );++ delete TheWritableGlobalData;+ TheWritableGlobalData = saved;+}+TEST(player_color_scheme_round_trips_through_options_ini){const OptionDef *def = findOptionDef( "PlayerColors" );diff --git a/GeneralsMD/Code/Tools/optionsmenu_layout.py b/GeneralsMD/Code/Tools/optionsmenu_layout.pyindex 267650955..d23e2a465 100644--- a/GeneralsMD/Code/Tools/optionsmenu_layout.py+++ b/GeneralsMD/Code/Tools/optionsmenu_layout.py@@ -165,6 +165,8 @@ NEW_CONTROLS = [(LABEL, "LabelFullscreenScaling", "GUI:FullscreenScaling"),(COMBO, "ComboBoxFullscreenScaling", None),(CHECK, "CheckVSync", "GUI:VSync"),+ (LABEL, "LabelFrameRateLimit", "GUI:FrameRateLimit"),+ (COMBO, "ComboBoxFrameRateLimit", None),(CHECK, "CheckClassicGraphics", "GUI:ClassicGraphics"),(LABEL, "LabelWaterStyle", "GUI:WaterStyle"),(COMBO, "ComboBoxWaterStyle", None),@@ -356,7 +358,9 @@ GROUP_LAYOUT = [setting("GammaLabel", "SliderGamma", "ValueGamma"),# every column of Graphics and Effects is full("check", "CheckStructureCollapse"),- ("check", "CheckSmoothMotion")])]),+ ("check", "CheckSmoothMotion"),+ # the Screen column is full with the monitor and the resolution note+ setting("LabelFrameRateLimit", "ComboBoxFrameRateLimit")])]),("PageGraphics", [# the particle limit went to Effects' Particles group to make room for the quality slider