Skip to content

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

feat(gameengine): port a batch of upstream fixes and their settings

Olcay Seyganf42dea42164d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 97021b286..ba99e4546 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -194,6 +194,21 @@ found and fixed — EA's own, not port damage.**
- Replay archiving saves each match under its own date-and-time name.
- Long lists scroll the whole way, past two thousand rows.
- Map, skirmish and replay menus read the catalogue once instead of rebuilding it.
+- The replay list's date column shows the date. It only ever held the clock time, so a folder of
+ games recorded over months all read as the same handful of afternoons.
+- Dates in the replay and save lists are written the way your own Region settings ask for. Both
+ lists were formatting against the locale the machine was installed with rather than the one the
+ person using it picked, which on any machine set up in one country and used in another is not the
+ same thing.
+- A save game can be opened straight from the command line: `-loadsave <name>`, the same way
+ `-replay` opens a replay. The only route in was the Load menu, so there was no way to put a
+ machine back into a known world without clicking through to it.
+- A map with an accented character in its name survives the map cache. The name is encoded before it
+ goes in, and the encoder stopped dead at the first byte over 127 - so anything past it was simply
+ gone, and nothing could read the name back.
+- A replay whose header the game cannot read warns you instead of starting anyway. It used to
+ report the file as compatible and go straight into playback on something it had already failed to
+ parse.
## Placing a building, then changing your mind
@@ -345,6 +360,12 @@ found and fixed — EA's own, not port damage.**
- Hackers show how far off the next payout is. So do the black market and the oil derricks.
- A hacker working from inside an Internet Center shows what it earns. The green figure floats over the building on every payout, the way it does over one sitting in the field. It never appeared, because the game asked the hacker whether it could be seen and a garrisoned unit is not drawn at all - which is the one place a hacker is meant to work.
- Factories take a hundred units in the queue, not nine. The build queue only ever had nine buttons and that had become the limit.
+- A match can pay everyone a wage. `MoneyPerMinute` in `GameData.ini` drops the same sum into every
+ living player's account on the minute, on top of whatever they are mining, which is the knob a
+ mod or a map needs to run a game that is not about holding the supply piles. Zero, and therefore
+ absent, unless somebody asks for it: on a stock install nothing changes. Measured on one seed with
+ four brutal computers at 7,777 a minute, three of the four spent between 3,400 and 6,200 more in
+ the first three minutes and put the difference on the map.
## Health bars
@@ -418,6 +439,12 @@ found and fixed — EA's own, not port damage.**
- The writing on a build button keeps its size against the button. The hotkey letter, the price, the build time and the queue count were sized off how wide your monitor is while the bar they sit on is sized off the smaller of its width and its height, so the wider the screen the further the lettering grew away from the cameo underneath it. One size for both now, and it is the bar's.
- Every key the game answers to is in the options screen, and you can move any of them. The keyboard screen has been in the game since 2003 - the code for it, anyway; the layout it needed was never shipped in any data file, which is why the button that opens it was authored hidden and parked off the right edge, and why its Assign button had an empty body with a comment where the work should be. It is built now: every command in one list with the key it answers to beside it, click a row and press the key you want. A key can only mean one thing, so whatever was on it gives it up. Your changes go in `Keybinds.ini` next to `Options.ini` and hold only what you moved, so a patch that adds commands does not wipe them - and none of it is in the multiplayer checksum, so two players in one match can hold completely different keyboards.
- Minimising the command bar sends the radar and the whole middle off the bottom of the screen, and they slide back up when you bring them back. The old minimise dropped the bar a tenth of the screen and left a strip of metal, a readable money box and the top of the radar dish lying along the bottom edge, which is neither the bar nor out of the way. The selection panel stays where it is, because that is where the button that puts the rest back lives.
+- Menu panels slide in at the same speed whatever your monitor is. They travel the width of the
+ screen but moved at a fixed forty pixels a step, so the wider the screen the longer every
+ transition took: twenty steps at 800 wide, sixty-four at 2560.
+- A screenshot no longer takes the game down when the window is bigger than the desktop. Asking for
+ a 1600x1200 window on a 1080-tall monitor puts part of it off the screen, and the capture read
+ the whole client area out of a buffer that stops at the desktop's edge.
- The arrow on a dropdown is square at every resolution. It was drawn into a slot of a fixed 21 pixels wide however tall the box around it was stretched, so the bigger the screen the more the arrow was squeezed.
- The promotion screen closes when you press its key again, however fast you press it. The screen fades in, and the fade drives the window itself for several frames either way - so a second press during the fade read the screen as still shut and opened it again, and a press just after it was closed was undone by the fade's next frame.
- The command bar stops changing under you while you are using it. With nothing selected the bar shows one of your builders so you can place a structure without picking a dozer first, and it showed whichever one happened to be idle - so a dozer finishing a building on the far side of the base took the bar over, dropping a half-typed build hotkey and taking the structure off your cursor. The builder you are working with keeps the bar.
@@ -427,8 +454,16 @@ found and fixed — EA's own, not port damage.**
- Borderless fullscreen: start with `-borderless` and the game fills the screen at your desktop resolution with no frame and no display mode change, so alt-tab is instant, nothing on the desktop gets shuffled around behind it, and a second monitor stays usable. Screen-edge scrolling works there, the way it does in fullscreen. The loading picture still opens as its own small window with your desktop around it, and the game only takes the screen once it has something to draw.
- Fullscreen, borderless and windowed are one saved setting now, so borderless no longer means adding a switch to your shortcut every time. `WindowMode` in `Options.ini` takes 0, 1 or 2 in that order; a switch on the command line still wins for that one run. Picking a different one applies when you press Accept instead of the next time you start the game: the window loses or gains its frame and the display device is rebuilt on the spot. Borderless takes your desktop resolution and nothing else, so while it is selected the resolution list greys out and the other two modes hand it straight back.
- Antialiasing is a saved setting as well: `MSAA` in `Options.ini`, 0 for off through 4 for sixteen samples. `-msaa 4` still works and still wins for that run. Whatever your card will not give is stepped down instead of refused, so asking for six samples gets you four rather than nothing.
+- Texture filtering is yours to set. `TextureFilter` in `Options.ini` takes 0 for bilinear, 1 for
+ trilinear and 2 for anisotropic, and `Anisotropy` takes the sample count, 0 meaning whatever your
+ card offers. The default is anisotropic at the card's maximum: retail shipped bilinear with point
+ mip selection, which was a 2003 fill-rate budget and is why distant ground shimmered.
- Picking High detail gives you high resolution textures. The setting was ignored: the resolution came from a machine benchmark that answers 'low' on anything modern, so there was no way to ask for better.
- The main menu plays its battle again instead of showing one still picture. The game asks Windows how much memory the machine has and compares the answer against a 256MB minimum, and on a machine with more than 4GB installed that answer arrived as minus one - so the better the machine, the more certain the game was that it did not meet the 2003 minimum. It switched off the animated menu, forced textures down and, at the preset detail levels, took the trees out. It reads the real figure now.
+- A setting you typed into `Options.ini` by hand survives opening the options screen. A value the
+ matching slider could not reach was thrown away rather than clamped, and the slider then sat on
+ its minimum - which is what got written back when you pressed Accept. Whatever the slider cannot
+ show now reads as the nearest end of its track instead of the bottom of it.
- The Default button in the options menu no longer throws away your resolution. It reset the display along with everything else, dropping you to 800x600 with no undo.
- Text does not vanish at large sizes. Any font over 100 points simply failed to load, which on a 4K screen is a missing line of interface.
- Zoom further out, with the whole map drawn instead of black corners.
@@ -448,6 +483,19 @@ found and fixed — EA's own, not port damage.**
- Snapping now uses the true cell offset and the building's concrete apron.
- A building faces the way you drag it, read at the moment you release.
- The mouse pointer stays visible for the whole placement.
+- How see-through the structure on your cursor is, and whether it drops a shadow, are yours to set:
+ `BuildPlacementOpacity` and `BuildPlacementShadows` in `GameData.ini`. The defaults are what the
+ game always did.
+- The menus move at whatever speed you want them to. `MenuTransitionSpeed` in `Options.ini` is a
+ percentage: 100 is the pace the slides and fades were drawn at, 400 gets you from the main menu to
+ a skirmish setup in a quarter of the time, 25 is for looking at them.
+- The right mouse button can stop dragging the camera. With the alternate mouse layout it is the
+ selection button, so every selection drag was also a camera drag; `RightMouseScroll = no` in
+ `Options.ini` hands it back and leaves the middle button and the screen edge to scroll with.
+- Alt+F4 and the window's close button quit the game. Both have always sent the message that means
+ "leave now", and nothing was listening for it: the handler was switched off in 2003 and never
+ switched back on, so the X in the corner did nothing and the only way out was the menus. A match
+ in progress stops recording its replay first.
## Soldiers cast real shadows
@@ -464,6 +512,17 @@ found and fixed — EA's own, not port damage.**
- `Bloom = 60` in `Options.ini` makes bright things bleed light into the air.
- Off until you add that line; `BloomThreshold` sets how much of the picture joins in.
+- Scorch marks follow the texture quality setting like everything else. The terrain and the trees
+ dropped to the resolution you asked for and the burn marks did not, so on Low the ground went soft
+ underneath craters that stayed sharp.
+- The craters a map ships with stay on the ground. Scorch marks live in a list of 500 and the list
+ makes room by throwing away its oldest entry - which is always one the level designer placed, so a
+ long battle rubbed out the map's own burn marks one at a time. Only marks the fighting made are
+ thrown away now.
+- Units stop going see-through for no reason. The game marks a unit that is standing behind a
+ building so you can still make it out, and the flag that says "yes, something is in front of this
+ one" was set once and never cleared - so the first unit genuinely behind a wall made every unit
+ checked after it see-through too, wall or no wall. On a busy screen that was most of them.
- Bloom and antialiasing work together. Turning bloom on with antialiasing on gave you a black battlefield under a live interface: the glow pass draws the world into its own picture first, and that picture came with a depth buffer nobody had cleared, so every triangle in the scene was rejected as being behind something that was not there.
- A switch you write in `Options.ini` by hand takes `yes`, `true`, `on` or `1` for on. Only the
exact word `yes` used to count, so a line spelled any other way read as off and looked like a
@@ -471,6 +530,13 @@ found and fixed — EA's own, not port damage.**
- Explosions light what is around them: 89 of them, from a tank shell to the Scud Storm,
throw a warm flash that fades over a third of a second. A night fight used to be muzzle
smoke over unlit ground.
+- Heat haze bends the picture as far up and down as it does side to side. The vertical pull was
+ half the horizontal one, which nobody could see while the haze was reading its sideways figure
+ for both directions, and became a visible lean the moment that was fixed.
+- Cutscenes and briefings play at the colour depth your card actually offers. Every video but the
+ EA logo was dropped to sixteen bit on the way in, on any machine - the test that was meant to
+ limit that to a 2003 low-memory PC is commented out in the same line - and it was dropped there
+ even on a device that had just reported it could not do sixteen bit at all.
## It does not crash
@@ -496,6 +562,14 @@ found and fixed — EA's own, not port damage.**
- A transport told to load into something it cannot enter - or into itself, which happens when it is part of the group you gave the order to - ignores the order instead of flying over and hovering beside it.
- A pilot ejecting from a wreck no longer plays a promotion sound and animation somewhere out in the map.
- A sound finishing does not take the game with it. Every sound carries a description of itself, and that description can be gone by the time the sound ends - it is dropped when the sound is renamed, cleared by hand when what it points at is about to be deleted, and absent on a sound that was queued to repeat after a delay. The 2003 code checked for that in two places and then read straight through it in fifteen others, one of which is where every finished sound goes. It crashed mid-match with a stack that is all audio and names nothing that caused it. A sound with no description is now simply not music and not speech, which is what all fifteen questions were asking; the channel it was using is still handed back, because losing one leaks a voice for the rest of the match and enough of them go quiet.
+- A vehicle that gives off dirt but no dust no longer takes the game down when it lands. The landing
+ puff belongs to the dust effect, and the code reached for it after checking that the dirt effect
+ existed - so any vehicle whose data has one and not the other faulted the moment its wheels came
+ back down.
+- A file that appears after the game has already looked for it is found. The answer to "is this
+ file there" was remembered forever, and nothing cleared it when a mod archive was mounted or the
+ patch content was layered on top - so a file the game had asked about a moment too early stayed
+ invisible for the rest of the session.
- A guard posted at a tunnel network no longer takes the game down when its target stops existing.
EA's own copy of that function, the one for units guarding anywhere else, tests for it on its first
line; the tunnel copy read straight through the missing pointer and crashed mid-match.
@@ -516,6 +590,30 @@ found and fixed — EA's own, not port damage.**
- The game says so in the log when the graphics device is lost, which is what happens when you
alt-tab out. The recovery after that is the riskiest thing the renderer does, and until now it
left no trace at all in a shipping build.
+- Wreckage no longer drops a shadow request full of whatever was on the stack. A shadow is asked
+ for by filling in a small form, and the form has a slot for a texture name that the wreckage code
+ never filled in at all. The shadow system reads that slot the moment its first byte is not zero,
+ so it was measuring and copying a name nobody wrote. The form now starts blank.
+- A battle thick with smoke, fire and glass draws instead of falling over. Everything see-through
+ is collected, sorted back to front and drawn in one go, and the list it goes into can only count
+ to 65,535 - which nothing checked. Past that the game asked for a buffer that cannot exist and
+ wrote into it anyway. What does not fit now waits for the next pass.
+- A map stored somewhere with a long name no longer overruns on the way in. The wave marks a map
+ carries are looked up by swapping the map's own extension, and the name was copied into a fixed
+ 256-byte buffer first, with no check at either end.
+- Saves, replays and settings find your Documents folder even when it has been moved. The shell call
+ the game used writes into a fixed buffer and fails outright on a path longer than that, which is
+ what a redirected folder on a network share or a long OneDrive path is. Everything then went
+ somewhere else without a word.
+- The game reads its own registry settings from your account before the machine-wide ones. Writing
+ the machine-wide half needs administrator rights, so a per-user or Steam install only ever writes
+ yours - and a stale entry left by some other copy of the game was winning, pointing this one at
+ another install's language and data folder.
+- Quitting no longer stops on a dialog nobody can see. An internal warning raised while the game is
+ tearing down used to put a box up over a graphics device that was already going away.
+- A log that could not be rotated says so, in the log. Rotation fails when a second copy of the game
+ has the file open, and the ".prev" file next to it then holds some older run than the one before -
+ which is a bug report read wrong.
- Something going wrong now writes a readable crash report.
## Units take corners wide, and drive round a jam instead of into it
@@ -686,8 +784,13 @@ found and fixed — EA's own, not port damage.**
## Sound, video, and getting it to start at all
- Audio is real, through the audio library the retail game ships with.
+- A sound at the edge of its range can fade out instead of stopping dead. The volume curve never
+ actually reaches zero, so a sound you are walking away from was cut off mid-note at the maximum
+ range. `RangeVolumeFade = Yes` in `AudioSettings.ini` uses a fade that reaches zero exactly where
+ the cut is. Off by default, because it changes how every positional sound in the game carries.
- The videos play: the intro, the sizzle reel, the mission briefings, the general portraits.
- The pointer is on screen over them. It used to appear only once the main menu did, so clicking through the logos was done blind.
+- Escape skips the opening logo, not just everything after it. The key has always skipped movies; the gate it asks was raised only once the logo had played itself out, so the one film you see on every single launch was the one you could not get past.
- About 5,600 graphics calls are translated to a modern path, none of them touched.
- No disc, no registry keys, no retail installer — a normal install works.
- The startup screen is this build's own, so you can see which one you launched before the menu loads.
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h b/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h
index 0a3bfe2ef..40dfa8c64 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/AudioSettings.h
@@ -37,6 +37,11 @@ enum { MAX_HW_PROVIDERS = 4 };
struct AudioSettings
{
+ // Every field below is filled in by AudioSettings.ini and nothing gives them a value before
+ // that, so a key the shipped file does not carry arrives as whatever was on the heap. New
+ // fields get their default here.
+ AudioSettings() : m_rangeVolumeFade( FALSE ) {}
+
AsciiString m_audioRoot;
AsciiString m_soundsFolder;
AsciiString m_musicFolder;
@@ -52,6 +57,14 @@ struct AudioSettings
Int m_streamCount;
Int m_globalMinRange;
Int m_globalMaxRange;
+ /** How a 3D sound loses volume with distance.
+ *
+ * No, the default, is what the game has always done: a 1/distance curve past the minimum range
+ * and then a hard cut to silence at the maximum, so a sound you are walking away from stops
+ * dead rather than fading out. Yes uses the linear fade between the two ranges that EA left
+ * commented out next to it, which reaches zero exactly where the cut is.
+ * `RangeVolumeFade` in AudioSettings.ini. */
+ Bool m_rangeVolumeFade;
Int m_drawableAmbientFrames;
Int m_fadeAudioFrames;
UnsignedInt m_maxCacheSize;
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/EarlyOptions.h b/GeneralsMD/Code/GameEngine/Include/Common/EarlyOptions.h
index 51be526fc..acef7e82f 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/EarlyOptions.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/EarlyOptions.h
@@ -41,6 +41,62 @@
#include <stdlib.h>
#include <string.h>
+/** Where this user's Documents folder is.
+ *
+ * SHGetSpecialFolderPath writes into a MAX_PATH buffer and fails outright when the folder has
+ * been redirected somewhere longer than that - a network share, or the long OneDrive path a lot
+ * of machines have now. The whole user data directory then comes back empty and the saves, the
+ * replays, Options.ini and the crash log all go somewhere else without a word.
+ * SHGetKnownFolderPath has no such limit. It is Vista and later, so it is bound at run time and
+ * the old call is still the fallback. The GUID is spelled out here rather than taken from
+ * KnownFolders.h so that nothing has to link another lib for one constant. */
+inline bool findDocumentsFolderA( char *out, size_t outSize )
+{
+ if (out == NULL || outSize == 0)
+ return false;
+ out[0] = 0;
+
+ // FOLDERID_Documents {FDD39AD0-238F-46AF-ADB4-6C85480369C7}
+ static const GUID kFolderIdDocuments =
+ { 0xFDD39AD0, 0x238F, 0x46AF, { 0xAD, 0xB4, 0x6C, 0x85, 0x48, 0x03, 0x69, 0xC7 } };
+
+ typedef HRESULT (WINAPI *GetKnownFolderPathFn)( const GUID &, DWORD, HANDLE, PWSTR * );
+
+ HMODULE shell = ::GetModuleHandleA( "shell32.dll" );
+ if (shell == NULL)
+ shell = ::LoadLibraryA( "shell32.dll" );
+
+ if (shell != NULL)
+ {
+ GetKnownFolderPathFn getKnownFolderPath =
+ (GetKnownFolderPathFn)::GetProcAddress( shell, "SHGetKnownFolderPath" );
+
+ if (getKnownFolderPath != NULL)
+ {
+ PWSTR wide = NULL;
+ if (SUCCEEDED( getKnownFolderPath( kFolderIdDocuments, 0, NULL, &wide ) ) && wide != NULL)
+ {
+ const int written = ::WideCharToMultiByte( CP_ACP, 0, wide, -1,
+ out, (int)outSize, NULL, NULL );
+ ::CoTaskMemFree( wide );
+ if (written > 0)
+ return true;
+ out[0] = 0; // the path did not fit this buffer; fall through and try the old way
+ }
+ }
+ }
+
+ char documents[MAX_PATH];
+ if (!::SHGetSpecialFolderPathA( NULL, documents, CSIDL_PERSONAL, TRUE ))
+ return false;
+
+ if (strlen( documents ) + 1 > outSize)
+ return false;
+
+ strcpy( out, documents );
+ return true;
+}
+
/** The directory the game keeps Options.ini, replays and save games in.
*
* GlobalData works this out the same way at startup (Documents plus a leaf name the installer
@@ -53,15 +109,16 @@ inline bool findUserDataDirectory( char *out, size_t outSize )
out[0] = 0;
char documents[MAX_PATH];
- if (!::SHGetSpecialFolderPathA( NULL, documents, CSIDL_PERSONAL, TRUE ))
+ if (!findDocumentsFolderA( documents, sizeof( documents ) ))
return false;
char leaf[MAX_PATH] = "Command and Conquer Generals Zero Hour Data";
- // HKLM first, then HKCU: the same two hives in the same order that GetStringFromRegistry walks.
+ // HKCU first, then HKLM: the same two hives in the same order that GetStringFromRegistry walks.
// A localized install renames the folder here, and reading only one hive would send this at the
- // English folder while the engine writes to the translated one.
- const HKEY hives[2] = { HKEY_LOCAL_MACHINE, HKEY_CURRENT_USER };
+ // English folder while the engine writes to the translated one. The order has to match the
+ // engine's or these two read different directories.
+ const HKEY hives[2] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
for (int hive = 0; hive < 2; ++hive)
{
HKEY key;
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
index 7499f9865..97344c347 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/GlobalData.h
@@ -355,8 +355,15 @@ public:
Bool m_snapCameraRotateTo45; ///< quantize the camera heading to 45 degrees when a middle-drag rotate ends
Bool m_gridBuildPlacement; ///< quantize structure placement to the pathfinder's build grid
Bool m_nudgeBuildPlacement; ///< slide a blocked structure to the nearest spot it does fit
+ Int m_moneyPerMinute; ///< income every player gets once a minute regardless of supply lines; 0 = off
+ Real m_buildPlacementOpacity; ///< how solid the structure riding the cursor is drawn, 0..1
+ Bool m_buildPlacementShadows; ///< whether that structure casts a shadow while it rides the cursor
Bool m_middleMousePans; ///< middle-button drag pans the camera instead of rotating it
Bool m_zoomToCursor; ///< the mouse wheel zooms toward whatever the cursor is over
+ Bool m_rightMouseScroll; ///< holding the right button drags the camera; off frees it for alternate mouse mode
+ Int m_menuTransitionSpeed; ///< percent of the authored speed the menus slide and fade at; 100 = as drawn
+ Int m_textureFilterMode; ///< 0 bilinear, 1 trilinear, 2 anisotropic
+ Int m_anisotropyLevel; ///< samples anisotropic filtering may take; 0 = whatever the card offers
Bool m_showHudOverlay; ///< draw the fps / elapsed time / income line in the corner
Bool m_showPlacementRangeRing; ///< while placing a structure, ring its weapon range
Bool m_workersReturnToSupply; ///< a worker that finishes a build job goes back to the dock it left
@@ -374,6 +381,7 @@ public:
Int m_autoSkirmishAIStateOdd; ///< -aidiff2 <name>: rung for the odd-numbered slots (0 = same as -aidiff)
Int m_autoSkirmishTeams; ///< -teams <n>: split the auto-skirmish slots into n allied teams (0 or 1 = free-for-all)
Int m_maxGameFrames; ///< -maxframes <n>: quit after n logic frames however the match is going (0 = no limit)
+ Int m_screenShotFrame; ///< -screenshot <n>: save one picture when the run reaches logic frame n (0 = never)
Int m_autoCameraSeconds; ///< -autocamera <n>: every n seconds, move the camera to wherever the fighting is (0 = off)
Int m_traceMoveID; ///< -tracemove [id]: log one movement line a frame for this object (0 = off, -1 = the first unit that gets blocked)
Real m_slowFrameMS; ///< -slowframe <ms>: a logic frame over this long logs its own breakdown (default 20)
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
index 25e8b90ab..d473a047b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ParticleSys.h
@@ -640,7 +640,18 @@ public:
Bool isUsingDrawables( void ) { return (m_particleType == DRAWABLE) ? true : false; }
Bool isUsingStreak( void ) { return (m_particleType == STREAK) ? true : false; }
Bool isUsingSmudge( void ) { return (m_particleType == SMUDGE) ? true : false; }
- UnsignedInt getVolumeParticleDepth( void ) { return ( m_particleType == VOLUME_PARTICLE ) ? OPTIMUM_VOLUME_PARTICLE_DEPTH : 0; }
+ /// How many layers deep a volume particle is drawn. `VolumeParticleDepth` in the template sets
+ /// it; left at zero the engine picks its own figure, which is what every system did before the
+ /// field existed. Only VOLUME_PARTICLE draws layers at all.
+ UnsignedInt getVolumeParticleDepth( void )
+ {
+ if( m_particleType != VOLUME_PARTICLE )
+ return 0;
+ if( m_volumeParticleDepth == 0 )
+ return OPTIMUM_VOLUME_PARTICLE_DEPTH;
+ return ( m_volumeParticleDepth > MAX_VOLUME_PARTICLE_DEPTH )
+ ? MAX_VOLUME_PARTICLE_DEPTH : m_volumeParticleDepth;
+ }
Bool shouldBillboard( void ) { return !m_isGroundAligned; }
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h
index e8f7efe1a..da604f84b 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/Shadow.h
@@ -75,7 +75,18 @@ class Shadow
public:
struct ShadowTypeInfo
- {
+ {
+ // Every caller fills in only the fields it cares about. W3DDebrisDraw never
+ // touched m_ShadowName at all, and addShadow reads it as a texture name the
+ // moment its first byte is not zero - so a debris shadow was strlen'ing and
+ // copying whatever happened to be on the stack. Start every field known.
+ ShadowTypeInfo()
+ : m_type( SHADOW_NONE ), allowUpdates( FALSE ), allowWorldAlign( FALSE ),
+ m_sizeX( 0.0f ), m_sizeY( 0.0f ), m_offsetX( 0.0f ), m_offsetY( 0.0f )
+ {
+ m_ShadowName[ 0 ] = '\0';
+ }
+
char m_ShadowName[64]; //when set, overrides the default model shadow (used mostly for Decals).
ShadowType m_type; //type of shadow
Bool allowUpdates; //whether to update the shadow image when object/light moves.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/UiAnimClock.h b/GeneralsMD/Code/GameEngine/Include/GameClient/UiAnimClock.h
index 8cfcf366f..c1f2b85f0 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameClient/UiAnimClock.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/UiAnimClock.h
@@ -63,4 +63,10 @@ Bool GameClient_isUiAnimStepDue( UnsignedInt &lastMs, Real &accumMs, UnsignedInt
/// what the menus were authored against, and what everything using the helper above steps at
const Real UI_ANIM_STEPS_PER_SEC = 30.0f;
+/** The same rate with the player's `MenuTransitionSpeed` percent applied. Menu slides and fades ask
+ * for this; the control bar and the shader manager keep the authored rate, because those are the
+ * game's own animations rather than the shell's ceremony. Kept out of the pure helper above so
+ * that stays testable without a GlobalData. */
+Real GameClient_menuAnimStepsPerSec( void );
+
#endif // __UIANIMCLOCK_H_
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CrateCollide.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CrateCollide.h
index 0155c93eb..b37cb1ee3 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CrateCollide.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CrateCollide.h
@@ -50,6 +50,7 @@ public:
Bool m_isForbidOwnerPlayer; ///< This crate cannot be picked up by the player of the dead thing that made it.
Bool m_isBuildingPickup; ///< This crate can be picked up by a Building (bypassing AI requirement)
Bool m_isHumanOnlyPickup; ///< Can this crate only be picked up by a human player? (Mission thing)
+ Bool m_allowMultiplePickup; ///< let every unit touching it in one frame collect it, the way it used to work
ScienceType m_pickupScience; ///< Can only be picked up by a unit whose player has this science
FXList *m_executeFX; ///< FXList to play when activated
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CreateObjectDie.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CreateObjectDie.h
index 63c390d83..a48bd43eb 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CreateObjectDie.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CreateObjectDie.h
@@ -48,6 +48,7 @@ public:
const ObjectCreationList* m_ocl; ///< object creaton list to make
Bool m_transferPreviousHealth; ///< Transfers previous health before death to the new object created.
+ Bool m_transferSelection; ///< If the dying object was selected, select what replaces it.
CreateObjectDieModuleData();
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h
index 6e930681a..ca84bcd57 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h
@@ -89,6 +89,7 @@ public:
AudioEventRTS m_initiateSound;
Bool m_updateModuleStartsAttack; ///< update module determines when the special power actually starts! If true, update module is required.
Bool m_startsPaused; ///< Paused on creation, someone else will have to unpause (like upgrade module, or script)
+ Bool m_startsReady; ///< Skip the first reload: available the moment the object exists
Bool m_scriptedSpecialPowerOnly;
};
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
index 765826c3c..755ae4e74 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Audio/GameAudio.cpp
@@ -121,6 +121,7 @@ static const FieldParse audioSettingsFieldParseTable[] =
{ "Default3DSpeakerType", parseSpeakerType, NULL, offsetof( AudioSettings, m_defaultSpeakerType3D) },
{ "MinSampleVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_minVolume) },
+ { "RangeVolumeFade", INI::parseBool, NULL, offsetof( AudioSettings, m_rangeVolumeFade) },
{ "GlobalMinRange", INI::parseInt, NULL, offsetof( AudioSettings, m_globalMinRange) },
{ "GlobalMaxRange", INI::parseInt, NULL, offsetof( AudioSettings, m_globalMaxRange) },
{ "TimeBetweenDrawableSounds", INI::parseDurationUnsignedInt, NULL, offsetof( AudioSettings, m_drawableAmbientFrames) },
@@ -451,6 +452,14 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
}
+ // Whether this event is for the local player at all depends on nothing the copy below
+ // adds - only on the event info and the owning player, both of which are already here.
+ // It used to be asked after a pool allocation, a filename pick and a play-info pass, so
+ // in a four-player match most of that work was done for sounds nobody could hear.
+ if (!eventToAdd->getUninterruptable() && !shouldPlayLocally(eventToAdd)) {
+ return AHSV_NotForLocal;
+ }
+
AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(*eventToAdd); // poolify
audioEvent->setPlayingHandle( allocateNewHandle() );
audioEvent->generateFilename(); // which file are we actually going to play?
@@ -465,13 +474,6 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd)
}
}
- if (!audioEvent->getUninterruptable()) {
- if (!shouldPlayLocally(audioEvent)) {
- releaseAudioEventRTS(audioEvent);
- return AHSV_NotForLocal;
- }
- }
-
// cull muted audio
if (audioEvent->getVolume() < TheAudio->getAudioSettings()->m_minVolume) {
#ifdef INTENSIVE_AUDIO_DEBUG
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
index efc1e4572..8e5c32a12 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/CommandLine.cpp
@@ -1283,6 +1283,25 @@ Int parseMaxGameFrames(char *args[], int num)
return 2;
}
+/* -screenshot <n>: save one picture of the running game at logic frame n.
+ *
+ * F12 has always taken one, and a key is no use to anything that runs on its own. A renderer
+ * change with no picture to compare against can only be argued about, which is why a row of
+ * graphics work in the upstream ledger sits unclosed - not because the code is hard, because
+ * nobody could see the result. Combine with -autoskirmish, -map and -maxframes; -headless draws
+ * nothing and says so. The file goes next to the save games, as sshotNNN.bmp. */
+Int parseScreenShot(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1)
+ {
+ Int frame = atoi(args[1]);
+ if (frame < 1)
+ frame = 1;
+ TheWritableGlobalData->m_screenShotFrame = frame;
+ }
+ return 2;
+}
+
/* -autocamera [seconds]: every so often, put the camera wherever the fighting is.
*
* A soak run watches from a free camera that never moves, and a camera that never moves is the
@@ -1573,6 +1592,22 @@ Int parseReplay(char *args[], int num)
return 2;
}
+/* -loadsave <file> opens a save game without the menus, the same way -replay opens a replay. The
+ only route into a save was the Load menu, so there was no way to get a machine straight back
+ into a known world - which is what a bug that only shows up ten minutes into a mission needs.
+ The name is resolved against the save directory; the extension is optional. */
+Int parseLoadSave(char *args[], int num)
+{
+ if (TheWritableGlobalData && num > 1)
+ {
+ AsciiString name = args[1];
+ if (!name.endsWithNoCase(".sav"))
+ name.concat(".sav");
+ TheWritableGlobalData->m_initialFile = name;
+ }
+ return 2;
+}
+
Int parseDumpAssetUsage(char *args[], int num)
{
if (TheWritableGlobalData)
@@ -1765,6 +1800,7 @@ static CommandLineParam params[] =
{ "-observer", parseObserver },
{ "-headless", parseHeadless },
{ "-maxframes", parseMaxGameFrames },
+ { "-screenshot", parseScreenShot },
{ "-msaa", parseMSAA },
{ "-autocamera", parseAutoCamera },
{ "-tracemove", parseTraceMove },
@@ -1778,6 +1814,7 @@ static CommandLineParam params[] =
{ "-crowd", parseCrowdModel },
{ "-groupdrill", parseGroupDrill },
{ "-replay", parseReplay },
+ { "-loadsave", parseLoadSave },
{ "-netgame", parseNetGame },
{ "-netslot", parseNetSlot },
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
index 8f4d9e96f..cb08241c7 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
@@ -206,6 +206,13 @@ GameEngine::~GameEngine()
//extern std::vector<std::string> preloadTextureNamesGlobalHack;
//preloadTextureNamesGlobalHack.clear();
+ // Debug.cpp puts an assertion up as a modal dialog only while the game is windowed, because a
+ // dialog over a fullscreen device deadlocks. Teardown is neither: the device is on its way out
+ // under us, and a dialog raised here hangs the process on exit with nothing on screen. Say we
+ // are not windowed and every assertion from here on goes to the log instead.
+ extern bool DX8Wrapper_IsWindowed;
+ DX8Wrapper_IsWindowed = false;
+
delete TheMapCache;
TheMapCache = NULL;
@@ -270,6 +277,59 @@ void GameEngine::setFramesPerSecondLimit( Int fps )
the .rep branch in init() for why it cannot be opened where it is parsed. */
static AsciiString thePendingReplayFile;
+/* -loadsave <file>: same deferral, same reason. A save game rebuilds the whole world, and doing
+ that before init()'s resetAll() would have resetAll tear it straight back down again. */
+static AsciiString thePendingSaveFile;
+
+/** Open the save game -loadsave named, once every subsystem has been reset.
+ *
+ * This is doLoadGame() in PopupSaveLoad.cpp without the menu: prepare a single player game, load,
+ * and fall back to the shell if the load fails. */
+static void startPendingSaveGame( void )
+{
+ AvailableGameInfo gameInfo;
+ gameInfo.next = NULL;
+ gameInfo.prev = NULL;
+ // A leaf name, not a path: everything downstream calls getFilePathInSaveDirectory on it, so a
+ // full path here gets the save directory glued in front of it a second time and loadGame then
+ // answers SC_FILE_NOT_FOUND for a file that is plainly there.
+ gameInfo.filename = thePendingSaveFile;
+
+ /* Ask first. Neither getSaveGameInfoFromFile nor loadGame survives a name that is not there -
+ the first reads out of an xfer that never opened - and a file name typed on a command line is
+ exactly the sort of thing that is not there. Without this the switch faulted on a typo. */
+ if (!TheGameState->doesSaveGameExist( thePendingSaveFile ))
+ {
+ DEBUG_LOG(("-loadsave: '%s' does not exist\n", gameInfo.filename.str()));
+ // A run driven entirely from the command line has nobody at the keyboard, so dropping it
+ // into the main menu means a process that never ends. Say what went wrong and stop.
+ if (TheGlobalData->m_headless)
+ TheGameEngine->setQuitting( TRUE );
+ else
+ TheWritableGlobalData->m_shellMapOn = TRUE;
+ return;
+ }
+
+ // getSaveGameInfoFromFile opens the name it is handed as-is - the menu path gets away with a
+ // leaf only because it is called from inside iterateSaveFiles, which has chdir'd into the save
+ // directory first. Give it the path.
+ TheGameState->getSaveGameInfoFromFile(
+ TheGameState->getFilePathInSaveDirectory( thePendingSaveFile ), &gameInfo.saveGameInfo );
+
+ TheGameLogic->prepareNewGame( GAME_SINGLE_PLAYER, DIFFICULTY_NORMAL, 0 );
+
+ if (TheGameState->loadGame( gameInfo ) != SC_OK)
+ {
+ DEBUG_LOG(("-loadsave: '%s' could not be loaded\n", gameInfo.filename.str()));
+ if (TheGameLogic->isInGame())
+ TheGameLogic->clearGameData( FALSE );
+ if (TheGlobalData->m_headless)
+ TheGameEngine->setQuitting( TRUE );
+ else
+ TheWritableGlobalData->m_shellMapOn = TRUE;
+ }
+}
+
/** -----------------------------------------------------------------------------------------------
* -autoskirmish <n>: build a skirmish slot list from the command line and launch it without going
* through the menus. This is reallyDoStart() in SkirmishGameOptionsMenu.cpp minus the GUI: the
@@ -898,6 +958,12 @@ void GameEngine::init( int argc, char *argv[] )
TheWritableGlobalData->m_playIntro = FALSE;
thePendingReplayFile = fname;
}
+ else if (fname.endsWithNoCase(".sav"))
+ {
+ TheWritableGlobalData->m_shellMapOn = FALSE;
+ TheWritableGlobalData->m_playIntro = FALSE;
+ thePendingSaveFile = TheGlobalData->m_initialFile; // the name as given, not lowercased
+ }
}
else if (TheGlobalData->m_netGameHosts.isNotEmpty())
{
@@ -980,6 +1046,15 @@ void GameEngine::init( int argc, char *argv[] )
thePendingReplayFile.clear();
}
+ /* Same point in the sequence, same reason: the world a save builds has to survive resetAll().
+ The menu path (doLoadGame in PopupSaveLoad.cpp) prepares a single player game first and falls
+ back to the shell if the load fails; do both here. */
+ if (thePendingSaveFile.isNotEmpty())
+ {
+ startPendingSaveGame();
+ thePendingSaveFile.clear();
+ }
+
if (TheGlobalData->m_netGameHosts.isNotEmpty() && TheGlobalData->m_initialFile.isEmpty())
{
startAutoNetGame();
@@ -1431,6 +1506,28 @@ static void updateHeadlessRun( void )
const UnsignedInt frame = TheGameLogic->getFrame();
+ /* -screenshot <n>: hand the renderer a shot request as the run passes frame n. W3DDisplay only
+ sets a pending flag here and writes the file out of the back buffer on its next draw, so this
+ does something only in a run that is drawing - -autoskirmish without -headless. It is the
+ only way to see what a renderer change did without somebody sitting in front of the machine,
+ which is what half the remaining graphics work needs. The file lands next to the save games
+ as sshotNNN.bmp. */
+ static UnsignedInt screenShotRequestedOn = 0;
+ if (TheGlobalData->m_screenShotFrame > 0 && screenShotRequestedOn == 0 &&
+ frame >= (UnsignedInt)TheGlobalData->m_screenShotFrame)
+ {
+ screenShotRequestedOn = frame;
+ if (TheGlobalData->m_headless)
+ {
+ DEBUG_LOG(("-screenshot: -headless draws nothing, so there is no picture to save\n"));
+ }
+ else if (TheDisplay != NULL)
+ {
+ TheDisplay->takeScreenShot();
+ DEBUG_LOG(("-screenshot: asked for one at frame %d\n", frame));
+ }
+ }
+
/* The frame times start a second in, not at frame 0. The first counted pass carries the tail
of the map load and came out at two full seconds, which then *is* the worst frame of the
match and buries the 60ms hitch that somebody could actually do something about. */
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
index 3e5fbdeb4..0be5cb3cf 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp
@@ -39,6 +39,7 @@
#define DEFINE_PANNING_NAMES
#include "Common/CRC.h"
+#include "Common/EarlyOptions.h" // findDocumentsFolderA
#include "Common/File.h"
#include "Common/FileSystem.h"
#include "Common/GameAudio.h"
@@ -53,6 +54,7 @@
#include "GameLogic/Module/BodyModule.h"
#include "GameClient/Color.h"
+#include "GameClient/Drawable.h" // PLACEMENT_SILHOUETTE_OPACITY, the default for BuildPlacementOpacity
#include "GameClient/TerrainVisual.h"
#include "GameNetwork/FirewallHelper.h"
@@ -192,8 +194,12 @@ GlobalData* GlobalData::m_theOriginal = NULL;
{ "SnapCameraRotateTo45", INI::parseBool, NULL, offsetof( GlobalData, m_snapCameraRotateTo45 ) },
{ "GridBuildPlacement", INI::parseBool, NULL, offsetof( GlobalData, m_gridBuildPlacement ) },
{ "NudgeBuildPlacement", INI::parseBool, NULL, offsetof( GlobalData, m_nudgeBuildPlacement ) },
+ { "MoneyPerMinute", INI::parseInt, NULL, offsetof( GlobalData, m_moneyPerMinute ) },
+ { "BuildPlacementOpacity", INI::parseReal, NULL, offsetof( GlobalData, m_buildPlacementOpacity ) },
+ { "BuildPlacementShadows", INI::parseBool, NULL, offsetof( GlobalData, m_buildPlacementShadows ) },
{ "MiddleMousePans", INI::parseBool, NULL, offsetof( GlobalData, m_middleMousePans ) },
{ "ZoomToCursor", INI::parseBool, NULL, offsetof( GlobalData, m_zoomToCursor ) },
+ { "RightMouseScroll", INI::parseBool, NULL, offsetof( GlobalData, m_rightMouseScroll ) },
{ "ShowHudOverlay", INI::parseBool, NULL, offsetof( GlobalData, m_showHudOverlay ) },
{ "ShowPlacementRangeRing", INI::parseBool, NULL, offsetof( GlobalData, m_showPlacementRangeRing ) },
{ "WorkersReturnToSupply", INI::parseBool, NULL, offsetof( GlobalData, m_workersReturnToSupply ) },
@@ -679,6 +685,7 @@ GlobalData::GlobalData()
m_autoSkirmishObserver = FALSE;
m_headless = FALSE;
m_maxGameFrames = 0; // run until the match ends
+ m_screenShotFrame = 0; // take no picture unless -screenshot asks for one
m_autoCameraSeconds = 0; // the camera stays where it was put
m_traceMoveID = 0; // no movement trace
m_slowFrameMS = 20.0f; // a frame worth a line in the log; -slowframe lowers it for a hunt
@@ -1059,10 +1066,17 @@ GlobalData::GlobalData()
// middle-drag stays a rotate by default (it snaps to 45 degrees on release); pan is opt-in
m_middleMousePans = FALSE;
m_zoomToCursor = TRUE;
+ m_rightMouseScroll = TRUE;
+ m_menuTransitionSpeed = 100;
+ m_textureFilterMode = 2; // anisotropic; retail shipped bilinear on a 2003 fill-rate budget
+ m_anisotropyLevel = 0; // whatever the card offers, capped at 16 in _Init_Filters
m_snapBuildPlacementTo45 = TRUE;
m_gridBuildPlacement = TRUE;
m_nudgeBuildPlacement = TRUE;
+ m_moneyPerMinute = 0;
+ m_buildPlacementOpacity = PLACEMENT_SILHOUETTE_OPACITY;
+ m_buildPlacementShadows = TRUE;
m_showHudOverlay = TRUE;
m_showPlacementRangeRing = TRUE;
m_workersReturnToSupply = TRUE;
@@ -1148,8 +1162,11 @@ GlobalData::GlobalData()
// Set user data directory based on registry settings instead of INI parameters. This allows us to
// localize the leaf name.
- char temp[_MAX_PATH + 1];
- if (::SHGetSpecialFolderPath(NULL, temp, CSIDL_PERSONAL, true))
+ // A redirected Documents folder can sit at a path longer than MAX_PATH, and the shell call this
+ // used to make simply fails there - see findDocumentsFolderA. The buffer is generous for the same
+ // reason.
+ char temp[1024];
+ if (findDocumentsFolderA(temp, sizeof(temp)))
{
AsciiString myDocumentsDirectory = temp;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
index 31883775b..3cb7d910d 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp
@@ -44,6 +44,10 @@ OPTION_BOOL_ACCESSORS( m_edgeScrollInWindowedMode )
OPTION_BOOL_ACCESSORS( m_snapCameraRotateTo45 )
OPTION_BOOL_ACCESSORS( m_middleMousePans )
OPTION_BOOL_ACCESSORS( m_zoomToCursor )
+OPTION_BOOL_ACCESSORS( m_rightMouseScroll )
+OPTION_INT_ACCESSORS( m_menuTransitionSpeed )
+OPTION_INT_ACCESSORS( m_textureFilterMode )
+OPTION_INT_ACCESSORS( m_anisotropyLevel )
OPTION_INT_ACCESSORS( m_bloomIntensity )
OPTION_INT_ACCESSORS( m_bloomThreshold )
OPTION_INT_ACCESSORS( m_windowMode )
@@ -112,6 +116,34 @@ const OptionDef TheOptionCatalog[] =
OPTION_BOOL, APPLY_LIVE, 0, 1,
get_m_zoomToCursor, set_m_zoomToCursor },
+ // Alternate mouse mode moves commands onto the left button and selection onto the right, and
+ // then the right button is doing two jobs at once - every command drag also drags the camera.
+ // Turning this off leaves the middle button and the screen edge to scroll with.
+ { "RightMouseScroll", "", "",
+ OPTION_BOOL, APPLY_LIVE, 0, 1,
+ get_m_rightMouseScroll, set_m_rightMouseScroll },
+
+ // Percent of the speed the menu slides and fades were authored at. 100 is what the artists
+ // drew; higher gets you through the shell faster, and nothing about a menu animation is worth
+ // waiting for on the four hundredth launch.
+ { "MenuTransitionSpeed", "", "",
+ OPTION_INT, APPLY_LIVE, 25, 400,
+ get_m_menuTransitionSpeed, set_m_menuTransitionSpeed },
+
+ // 0 bilinear, 1 trilinear, 2 anisotropic. Retail shipped bilinear with point mip selection,
+ // which is a 2003 fill-rate budget and is why distant ground used to shimmer; 2 is the default
+ // here. The filter table is built when the device is made, so this needs a device reset.
+ { "TextureFilter", "", "",
+ OPTION_INT, APPLY_DEVICE_RESET, 0, 2,
+ get_m_textureFilterMode, set_m_textureFilterMode },
+
+ // Samples anisotropic filtering may take. 0 means whatever the card offers, capped at 16, and
+ // asking for more than the card has still gets you the card's answer. Only read when the filter
+ // above is anisotropic.
+ { "Anisotropy", "", "",
+ OPTION_INT, APPLY_DEVICE_RESET, 0, 16,
+ get_m_anisotropyLevel, set_m_anisotropyLevel },
+
// Eight rows used to sit here: grid and nudge build placement, snap-to-45 building rotation, the
// placement range ring, workers returning to supply, detailed build tooltips, the HUD overlay
// and replay archiving. Every one of them is now on for everybody, decided in GlobalData's
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index 142944fea..d34617664 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -737,6 +737,19 @@ void Player::update()
if( m_tunnelSystem )
m_tunnelSystem->healObjects();
+ // A trickle of income that does not come from a supply line. `MoneyPerMinute` in GameData.ini,
+ // zero and therefore absent unless somebody asks for it. Paid on the minute rather than spread
+ // over the frames so that the figure in the readout is the figure that was asked for, and only
+ // to players who are still in the match - the neutral slot and a defeated player get nothing.
+ if( TheGlobalData->m_moneyPerMinute > 0 && isPlayableSide() && isPlayerActive() )
+ {
+ const UnsignedInt now = TheGameLogic->getFrame();
+ const UnsignedInt minute = LOGICFRAMES_PER_SECOND * 60;
+
+ if( now > 0 && (now % minute) == 0 )
+ m_money.deposit( (UnsignedInt)TheGlobalData->m_moneyPerMinute, FALSE );
+ }
+
//Update the academy stats (this only checks applicable things that require a polling method)
getAcademyStats()->update();
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp
index 75bb0dae7..e5b26a47f 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp
@@ -1059,7 +1059,10 @@ Bool RecorderClass::testVersionPlayback(AsciiString filename)
Bool success = readReplayHeader( header );
if (!success)
{
- return FALSE;
+ // A header we cannot read used to answer "compatible", and the caller then went straight
+ // into playback on a file it had already failed to parse. Warn instead: the prompt is the
+ // same one a version difference gets, which is at least true - we do not know what this is.
+ return TRUE;
}
Bool versionStringDiff = header.versionString != TheVersion->getUnicodeVersion();
Bool versionTimeStringDiff = header.versionTimeString != TheVersion->getUnicodeBuildTime();
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp
index 201072625..799c9dcc0 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/Debug.cpp
@@ -393,12 +393,25 @@ void DebugInit(int flags)
strcat(curbuf, DEBUG_FILE_NAME);
remove(prevbuf);
- rename(curbuf, prevbuf);
+ // A failed rotate is not fatal - the log still opens - but it means the ".prev" file holds
+ // some older run than the one before this, and a bug report read on that assumption is read
+ // wrong. It fails when the previous log is still open somewhere, which is what a second copy
+ // of the game without -logPrefix does.
+ // A first run under a new -logPrefix has nothing to rotate, and rename fails for that too -
+ // so ask whether the file was there before deciding anything went wrong.
+ FILE *existing = fopen(curbuf, "r");
+ const bool hadPreviousLog = (existing != NULL);
+ if (existing != NULL)
+ fclose(existing);
+
+ const int rotated = rename(curbuf, prevbuf);
theLogFile = fopen(curbuf, "w");
if (theLogFile != NULL)
{
DebugLog("Log %s opened: %s\n", curbuf, getCurrentTimeString());
- }
+ if (hadPreviousLog && rotated != 0)
+ DebugLog("Could not rotate the previous log to %s: it holds an older run than this one.\n", prevbuf);
+ }
#endif
}
@@ -708,12 +721,20 @@ void ReleaseCrash(const char *reason)
strcat(curbuf, RELEASECRASH_FILE_NAME);
remove(prevbuf);
- rename(curbuf, prevbuf);
+ FILE *existingCrashLog = fopen(curbuf, "r");
+ const bool hadPreviousCrashLog = (existingCrashLog != NULL);
+ if (existingCrashLog != NULL)
+ fclose(existingCrashLog);
+ const int rotated = rename(curbuf, prevbuf);
theReleaseCrashLogFile = fopen(curbuf, "w");
if (theReleaseCrashLogFile)
{
fprintf(theReleaseCrashLogFile, "Release Crash at %s; Reason %s\n", getCurrentTimeString(), reason);
+ // Two crashes in a row and this is the report anybody reads. If the older one could not be
+ // moved aside it is gone, and the file next to this one is not the crash before it.
+ if (hadPreviousCrashLog && rotated != 0)
+ fprintf(theReleaseCrashLogFile, "(the previous crash report could not be rotated aside; %s is older than it looks)\n", prevbuf);
fprintf(theReleaseCrashLogFile, "\nLast error:\n%s\n\nCurrent stack:\n", g_LastErrorDump.str());
const int STACKTRACE_SIZE = 12;
// 1, not 6: FillStackAddresses drops its own frame itself now, so 6 skipped
@@ -809,12 +830,18 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m)
strcat(curbuf, RELEASECRASH_FILE_NAME);
remove(prevbuf);
- rename(curbuf, prevbuf);
+ FILE *existingCrashLog = fopen(curbuf, "r");
+ const bool hadPreviousCrashLog = (existingCrashLog != NULL);
+ if (existingCrashLog != NULL)
+ fclose(existingCrashLog);
+ const int rotated = rename(curbuf, prevbuf);
theReleaseCrashLogFile = fopen(curbuf, "w");
if (theReleaseCrashLogFile)
{
fprintf(theReleaseCrashLogFile, "Release Crash at %s; Reason %s\n", getCurrentTimeString(), mesg.str());
+ if (hadPreviousCrashLog && rotated != 0)
+ fprintf(theReleaseCrashLogFile, "(the previous crash report could not be rotated aside; %s is older than it looks)\n", prevbuf);
const int STACKTRACE_SIZE = 12;
// 1, not 6: FillStackAddresses drops its own frame itself now, so 6 skipped
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp
index 23253b496..e84c816f0 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp
@@ -141,6 +141,7 @@ FileSystem::~FileSystem()
void FileSystem::init( void )
{
+ m_fileExist.clear(); // see reset(): the cache outlives whatever it was an answer about
TheLocalFileSystem->init();
TheArchiveFileSystem->init();
}
@@ -163,6 +164,14 @@ void FileSystem::update( void )
void FileSystem::reset( void )
{
USE_PERF_TIMER(FileSystem)
+
+ // doesFileExist remembers its answer for the life of the process and this is the only place
+ // that ever gets told the world underneath it changed. A "no" cached before a mod archive was
+ // mounted, or before Win32BIGFileSystem::init re-loaded the Patch*.big over the plain pass, made
+ // that file invisible for the rest of the run - and the cache is keyed by name, so nothing else
+ // would ever ask again.
+ m_fileExist.clear();
+
TheLocalFileSystem->reset();
TheArchiveFileSystem->reset();
}
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp
index c8841883c..17dd0e2d5 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/QuotedPrintable.cpp
@@ -52,6 +52,19 @@ static int hexDigitToInt(char c)
return 0;
}
+// A char is signed here, and every byte over 127 - which is every accented letter in a map name,
+// and every second byte of a wide character in the unicode version below - therefore arrives as a
+// negative number. Two things went wrong with that, at all three encoders.
+//
+// isalnum takes a value representable as unsigned char or EOF, so a negative one is undefined and
+// the CRT's own check fires: that assert during map cache generation was one map name with a
+// non-ASCII character in it.
+//
+// Worse, and silent: `(*src)>>4` on a negative char sign-extends, intToHexDigit answers '\0' for
+// anything outside 0..15, and the AsciiString built from that buffer therefore ended at the first
+// high byte. A map whose name carried one encoded to nothing from that point on, and the round
+// trip back could not possibly return it.
+
// Convert unicode strings into ascii quoted-printable strings
AsciiString UnicodeStringToQuotedPrintable(UnicodeString original)
{
@@ -60,21 +73,21 @@ AsciiString UnicodeStringToQuotedPrintable(UnicodeString original)
int i=0;
while ( !(src[0]=='\0' && src[1]=='\0') && i<1021 )
{
- if (!isalnum(*src))
+ if (!isalnum((unsigned char)*src))
{
dest[i++] = MAGIC_CHAR;
- dest[i++] = intToHexDigit((*src)>>4);
- dest[i++] = intToHexDigit((*src)&0xf);
+ dest[i++] = intToHexDigit(((unsigned char)*src)>>4);
+ dest[i++] = intToHexDigit(((unsigned char)*src)&0xf);
} else
{
dest[i++] = *src;
}
src ++;
- if (!isalnum(*src))
+ if (!isalnum((unsigned char)*src))
{
dest[i++] = MAGIC_CHAR;
- dest[i++] = intToHexDigit((*src)>>4);
- dest[i++] = intToHexDigit((*src)&0xf);
+ dest[i++] = intToHexDigit(((unsigned char)*src)>>4);
+ dest[i++] = intToHexDigit(((unsigned char)*src)&0xf);
}
else
{
@@ -95,11 +108,11 @@ AsciiString AsciiStringToQuotedPrintable(AsciiString original)
int i=0;
while ( src[0]!='\0' && i<1021 )
{
- if (!isalnum(*src))
+ if (!isalnum((unsigned char)*src))
{
dest[i++] = MAGIC_CHAR;
- dest[i++] = intToHexDigit((*src)>>4);
- dest[i++] = intToHexDigit((*src)&0xf);
+ dest[i++] = intToHexDigit(((unsigned char)*src)>>4);
+ dest[i++] = intToHexDigit(((unsigned char)*src)&0xf);
} else
{
dest[i++] = *src;
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
index a388bccaf..248619c0e 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp
@@ -210,7 +210,12 @@ GameState::SnapshotBlock *GameState::findBlockInfoByToken( AsciiString token, Sn
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////
-UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
+/* LOCALE_USER_DEFAULT, not LOCALE_SYSTEM_DEFAULT, in both of these: the system locale is the one
+ the machine was installed with and is what non-Unicode programs get, while the user locale is the
+ one the person sitting there picked in Region settings. On a machine set up in one country and
+ used in another - which is most machines that run this game now - the dates in the replay and
+ save lists came out in a format the owner never chose. */
+UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
{
// setup date buffer for local region date format
#define DATE_BUFFER_SIZE 256
@@ -222,7 +227,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
char dateBuffer[ DATE_BUFFER_SIZE ];
- GetDateFormat( LOCALE_SYSTEM_DEFAULT,
+ GetDateFormat( LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&timeVal,
NULL,
@@ -232,7 +237,7 @@ UnicodeString getUnicodeDateBuffer(SYSTEMTIME timeVal)
}
}
wchar_t dateBuffer[ DATE_BUFFER_SIZE ];
- GetDateFormatW( LOCALE_SYSTEM_DEFAULT,
+ GetDateFormatW( LOCALE_USER_DEFAULT,
DATE_SHORTDATE,
&timeVal,
NULL,
@@ -253,7 +258,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
if (osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
{
char timeBuffer[ DATE_BUFFER_SIZE ];
- GetTimeFormat( LOCALE_SYSTEM_DEFAULT,
+ GetTimeFormat( LOCALE_USER_DEFAULT,
TIME_NOSECONDS|TIME_FORCE24HOURFORMAT|TIME_NOTIMEMARKER,
&timeVal,
NULL,
@@ -265,7 +270,7 @@ UnicodeString getUnicodeTimeBuffer(SYSTEMTIME timeVal)
// setup time buffer for local region time format
#define TIME_BUFFER_SIZE 256
wchar_t timeBuffer[ TIME_BUFFER_SIZE ];
- GetTimeFormatW( LOCALE_SYSTEM_DEFAULT,
+ GetTimeFormatW( LOCALE_USER_DEFAULT,
TIME_NOSECONDS,
&timeVal,
NULL,
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp
index 19eaf99bf..32c9497e9 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/registry.cpp
@@ -124,12 +124,12 @@ Bool GetStringFromGeneralsRegistry(AsciiString path, AsciiString key, AsciiStrin
fullPath.concat(path);
DEBUG_LOG(("GetStringFromRegistry - looking in %s for key %s\n", fullPath.str(), key.str()));
- if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val))
+ if (getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val))
{
return TRUE;
}
- return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val);
+ return getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val);
}
Bool GetStringFromRegistry(AsciiString path, AsciiString key, AsciiString& val)
@@ -137,13 +137,16 @@ Bool GetStringFromRegistry(AsciiString path, AsciiString key, AsciiString& val)
AsciiString fullPath = "SOFTWARE\\Electronic Arts\\EA Games\\Command and Conquer Generals Zero Hour";
fullPath.concat(path);
+ // HKCU first, HKLM second. The machine-wide hive needs administrator rights to write, so a
+ // per-user or Steam install writes only HKCU - and a stale HKLM entry left by some other copy of
+ // the game used to win, sending this one at another install's language or data folder.
DEBUG_LOG(("GetStringFromRegistry - looking in %s for key %s\n", fullPath.str(), key.str()));
- if (getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val))
+ if (getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val))
{
return TRUE;
}
- return getStringFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val);
+ return getStringFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val);
}
Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt& val)
@@ -152,12 +155,12 @@ Bool GetUnsignedIntFromRegistry(AsciiString path, AsciiString key, UnsignedInt&
fullPath.concat(path);
DEBUG_LOG(("GetUnsignedIntFromRegistry - looking in %s for key %s\n", fullPath.str(), key.str()));
- if (getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val))
+ if (getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val))
{
return TRUE;
}
- return getUnsignedIntFromRegistry(HKEY_CURRENT_USER, fullPath.str(), key.str(), val);
+ return getUnsignedIntFromRegistry(HKEY_LOCAL_MACHINE, fullPath.str(), key.str(), val);
}
AsciiString GetRegistryLanguage(void)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp
index e4431be12..e0d40eefb 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/AnimateWindowManager.cpp
@@ -53,6 +53,7 @@
//-----------------------------------------------------------------------------
#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
+#include "Common/GlobalData.h"
#include "GameClient/AnimateWindowManager.h"
#include "GameClient/UiAnimClock.h"
#include "GameClient/GameWindow.h"
@@ -206,6 +207,19 @@ Bool GameClient_isUiAnimStepDue( UnsignedInt &lastMs, Real &accumMs, UnsignedInt
return TRUE;
}
+//-----------------------------------------------------------------------------
+Real GameClient_menuAnimStepsPerSec( void )
+{
+ Int percent = TheGlobalData ? TheGlobalData->m_menuTransitionSpeed : 100;
+
+ if (percent < 25)
+ percent = 25; // the catalog clamps this too; a zero here would divide by nothing
+ else if (percent > 400)
+ percent = 400;
+
+ return UI_ANIM_STEPS_PER_SEC * (Real)percent / 100.0f;
+}
+
void AnimateWindowManager::update( void )
{
//
@@ -215,7 +229,7 @@ void AnimateWindowManager::update( void )
// travel in a handful of milliseconds and appears to snap into place.
//
if (!GameClient_isUiAnimStepDue(m_lastStepMs, m_stepAccumMs, timeGetTime(),
- UI_ANIM_STEPS_PER_SEC))
+ GameClient_menuAnimStepsPerSec()))
return;
ProcessAnimateWindow *processAnim = NULL;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp
index 327de8971..1c0066bef 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarObserver.cpp
@@ -232,15 +232,21 @@ void ControlBar::populateObserverList( void )
buttonPlayer[currentButton]->winHide(FALSE);
buttonPlayer[currentButton]->winSetStatus( WIN_STATUS_USE_OVERLAY_STATES );
- const GameSlot *slot = TheGameInfo->getConstSlot(currentButton);
+ // The slot this player actually sits in is i, not currentButton - currentButton only
+ // 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 backColor = GameMakeColor(0, 0, 0, 255);
staticTextPlayer[currentButton]->winSetEnabledTextColors( playerColor, backColor );
staticTextPlayer[currentButton]->winHide(FALSE);
AsciiString teamStr;
- teamStr.format("Team:%d", slot->getTeamNumber() + 1);
- if (slot->isAI() && slot->getTeamNumber() == -1)
+ if (slot == NULL)
teamStr = "Team:AI";
+ else if (slot->isAI() && slot->getTeamNumber() == -1)
+ teamStr = "Team:AI";
+ else
+ teamStr.format("Team:%d", slot->getTeamNumber() + 1);
UnicodeString text;
text.format(TheGameText->fetch("CONTROLBAR:ObsPlayerLabel"), p->getPlayerDisplayName().str(),
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
index f58b17d57..edb06ec81 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
@@ -170,9 +170,13 @@ void PopulateReplayFileListbox(GameWindow *listbox)
if (lastReplayFName.compareNoCase(asciistr) == 0)
replayNameToShow = TheGameText->fetch("GUI:LastReplay");
- UnicodeString displayTimeBuffer = getUnicodeTimeBuffer(header.timeVal);
-
- //displayTimeBuffer.format( L"%ls", timeBuffer);
+ // The column is headed "date" and only ever held the clock time, so a folder of
+ // replays recorded over months all read as the same handful of afternoons and there
+ // was no way to tell last night's game from one in April. Date first, then the time,
+ // both in whatever format the player's own Region settings ask for.
+ UnicodeString displayTimeBuffer = getUnicodeDateBuffer(header.timeVal);
+ displayTimeBuffer.concat( L" " );
+ displayTimeBuffer.concat( getUnicodeTimeBuffer(header.timeVal) );
// version (no-op)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp
index c676ea0ab..06b2b120c 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetHorizontalSlider.cpp
@@ -396,11 +396,17 @@ WindowMsgHandledType GadgetHorizontalSliderSystem( GameWindow *window, UnsignedI
// ------------------------------------------------------------------------
case GSM_SET_SLIDER:
{
- Int newPos = (Int)mData1;
+ Int newPos = (Int)mData1;
GameWindow *child = window->winGetChild();
- if( newPos < s->minVal || newPos > s->maxVal )
- break;
+ // A value outside the track used to be dropped on the floor, which left the slider
+ // holding whatever it had before - the minimum, freshly written by GSM_SET_MIN_MAX -
+ // and the options screen then saved that back over a setting somebody had typed into
+ // Options.ini by hand. Take the nearest end of the track instead.
+ if( newPos < s->minVal )
+ newPos = s->minVal;
+ else if( newPos > s->maxVal )
+ newPos = s->maxVal;
s->position = newPos;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp
index b99c779b6..e952415f7 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/Gadget/GadgetVerticalSlider.cpp
@@ -383,8 +383,12 @@ WindowMsgHandledType GadgetVerticalSliderSystem( GameWindow *window, UnsignedInt
Int newPos = (Int)mData1;
GameWindow *child = window->winGetChild();
- if (newPos < s->minVal || newPos > s->maxVal)
- break;
+ // See the horizontal slider: an out-of-range value used to be ignored outright,
+ // leaving the thumb wherever it already was. Clamp to the track instead.
+ if( newPos < s->minVal )
+ newPos = s->minVal;
+ else if( newPos > s->maxVal )
+ newPos = s->maxVal;
s->position = newPos;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp
index 3d1807dba..b707a714f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GameWindowTransitions.cpp
@@ -273,8 +273,9 @@ void TransitionGroup::update( void )
// uncapped now, so a whole menu transition would otherwise play out in a few milliseconds.
// Step off the wall clock at the rate the .ini frame counts were authored against instead.
//
+ // `MenuTransitionSpeed` in Options.ini scales this; 100 is the authored rate.
if (!GameClient_isUiAnimStepDue(m_lastStepMs, m_stepAccumMs, timeGetTime(),
- UI_ANIM_STEPS_PER_SEC))
+ GameClient_menuAnimStepsPerSec()))
return;
m_currentFrame += m_directionMultiplier; // we go forward or backwards depending.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp
index 2eef0bfea..d8b82af83 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ProcessAnimateWindow.cpp
@@ -56,6 +56,41 @@
#include "GameClient/AnimateWindowManager.h"
#include "GameClient/GameWindow.h"
#include "GameClient/Display.h"
+
+/** How far off the authored 800-wide screen this one is.
+ *
+ * A window slides in from off the edge, so the distance it covers is the screen's own width or
+ * height. The speed it covers it at, and the distance over which it slows down, are flat pixel
+ * counts written for 800x600 - so the wider the monitor the longer every menu animation took:
+ * 800/40 is twenty steps, 2560/40 is sixty-four. Scaling both with the screen keeps the animation
+ * the same length whatever it is drawn on.
+ *
+ * ponytail: read once, when AnimateWindowManager::init builds these objects. Changing resolution
+ * mid-session leaves the old scale until the next start; move this to a per-frame refresh if that
+ * ever matters. */
+static Real animateWindowDisplayScale( void )
+{
+ const Real AUTHORED_WIDTH = 800.0f;
+
+ if (TheDisplay == NULL || TheDisplay->getWidth() <= 0)
+ return 1.0f;
+
+ Real scale = (Real)TheDisplay->getWidth() / AUTHORED_WIDTH;
+ return (scale < 1.0f) ? 1.0f : scale; // never slower than it was authored to be
+}
+
+/// The same thing for the windows that slide up and down: their travel is the screen's height.
+static Real animateWindowDisplayScaleY( void )
+{
+ const Real AUTHORED_HEIGHT = 600.0f;
+
+ if (TheDisplay == NULL || TheDisplay->getHeight() <= 0)
+ return 1.0f;
+
+ Real scale = (Real)TheDisplay->getHeight() / AUTHORED_HEIGHT;
+ return (scale < 1.0f) ? 1.0f : scale;
+}
+
//-----------------------------------------------------------------------------
// DEFINES ////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------------
@@ -75,9 +110,9 @@
ProcessAnimateWindowSlideFromRight::ProcessAnimateWindowSlideFromRight( void )
{
- m_maxVel.x = -40.0f; // top speed windows travel in x and y
+ m_maxVel.x = -40.0f * animateWindowDisplayScale(); // top speed windows travel in x and y
m_maxVel.y = 0.0f;
- m_slowDownThreshold = 80; // when widnows get this close to their resting
+ m_slowDownThreshold = (Int)(80 * animateWindowDisplayScale()); // when widnows get this close to their resting
// positions they start to slow down
m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker)
m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up
@@ -261,9 +296,9 @@ Bool ProcessAnimateWindowSlideFromRight::reverseAnimateWindow( AnimateWindow *an
ProcessAnimateWindowSlideFromLeft::ProcessAnimateWindowSlideFromLeft( void )
{
- m_maxVel.x = 40.0f; // top speed windows travel in x and y
+ m_maxVel.x = 40.0f * animateWindowDisplayScale(); // top speed windows travel in x and y
m_maxVel.y = 0.0f;
- m_slowDownThreshold = 80; // when widnows get this close to their resting
+ m_slowDownThreshold = (Int)(80 * animateWindowDisplayScale()); // when widnows get this close to their resting
// positions they start to slow down
m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker)
m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up
@@ -439,9 +474,9 @@ Bool ProcessAnimateWindowSlideFromLeft::reverseAnimateWindow( AnimateWindow *ani
ProcessAnimateWindowSlideFromTop::ProcessAnimateWindowSlideFromTop( void )
{
- m_maxVel.y = 40.0f; // top speed windows travel in x and y
+ m_maxVel.y = 40.0f * animateWindowDisplayScaleY(); // top speed windows travel in x and y
m_maxVel.x = 0.0f;
- m_slowDownThreshold = 80; // when widnows get this close to their resting
+ m_slowDownThreshold = (Int)(80 * animateWindowDisplayScaleY()); // when widnows get this close to their resting
// positions they start to slow down
m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker)
m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up
@@ -618,9 +653,9 @@ Bool ProcessAnimateWindowSlideFromTop::reverseAnimateWindow( AnimateWindow *anim
ProcessAnimateWindowSlideFromBottom::ProcessAnimateWindowSlideFromBottom( void )
{
- m_maxVel.y = -40.0f; // top speed windows travel in x and y
+ m_maxVel.y = -40.0f * animateWindowDisplayScaleY(); // top speed windows travel in x and y
m_maxVel.x = 0.0f;
- m_slowDownThreshold = 80; // when widnows get this close to their resting
+ m_slowDownThreshold = (Int)(80 * animateWindowDisplayScaleY()); // when widnows get this close to their resting
// positions they start to slow down
m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker)
m_speedUpRatio = 2.0f - m_slowDownRatio; // how fast the windows speed up
@@ -1132,9 +1167,9 @@ Bool ProcessAnimateWindowSpiral::reverseAnimateWindow( AnimateWindow *animWin )
ProcessAnimateWindowSlideFromTopFast::ProcessAnimateWindowSlideFromTopFast( void )
{
- m_maxVel.y = 60.0f; // top speed windows travel in x and y
+ m_maxVel.y = 60.0f * animateWindowDisplayScaleY(); // top speed windows travel in x and y
m_maxVel.x = 0.0f;
- m_slowDownThreshold = 40; // when widnows get this close to their resting
+ m_slowDownThreshold = (Int)(40 * animateWindowDisplayScaleY()); // when widnows get this close to their resting
// positions they start to slow down
m_slowDownRatio = 0.67f; // how fast the windows slow down (smaller slows quicker)
m_speedUpRatio = 4.0f - m_slowDownRatio; // how fast the windows speed up
@@ -1315,9 +1350,9 @@ Bool ProcessAnimateWindowSlideFromTopFast::reverseAnimateWindow( AnimateWindow *
ProcessAnimateWindowSlideFromRightFast::ProcessAnimateWindowSlideFromRightFast( void )
{
- m_maxVel.x = -80.0f; // top speed windows travel in x and y
+ m_maxVel.x = -80.0f * animateWindowDisplayScale(); // top speed windows travel in x and y
m_maxVel.y = 0.0f;
- m_slowDownThreshold = 60; // when widnows get this close to their resting
+ m_slowDownThreshold = (Int)(60 * animateWindowDisplayScale()); // when widnows get this close to their resting
// positions they start to slow down
m_slowDownRatio = 0.77f; // how fast the windows slow down (smaller slows quicker)
m_speedUpRatio = 3.0f - m_slowDownRatio; // how fast the windows speed up
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
index 67857ed3b..c1ce97f16 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameClient.cpp
@@ -567,6 +567,10 @@ void GameClient::update( void )
TheDisplay->playLogoMovie("EALogoMovie", 5000, 3000);
else
TheDisplay->playLogoMovie("EALogoMovie640", 5000, 3000);
+ // Escape gets you out of this one too. The flag is what the key handler asks, and it was
+ // only ever raised once the logo had finished playing itself out, so the one movie you see
+ // on every single launch was the one you could not skip.
+ TheWritableGlobalData->m_allowExitOutOfMovies = TRUE;
TheWritableGlobalData->m_playIntro = FALSE;
TheWritableGlobalData->m_afterIntro = TRUE;
playSizzle = TRUE;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
index 7805e6454..83eabafdb 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp
@@ -103,7 +103,16 @@
// ------------------------------------------------------------------------------------------------
-static const Real placementOpacity = PLACEMENT_SILHOUETTE_OPACITY;
+/** How the structure riding the cursor is drawn. `BuildPlacementOpacity` and
+ * `BuildPlacementShadows` in GameData.ini; the defaults are what the game always did. */
+static void dressPlacementPreview( Drawable *draw )
+{
+ if( draw == NULL )
+ return;
+
+ draw->setDrawableOpacity( TheGlobalData->m_buildPlacementOpacity );
+ draw->setShadowsEnabled( TheGlobalData->m_buildPlacementShadows );
+}
static const RGBColor illegalBuildColor = { 1.0, 0.0, 0.0 };
// ------------------------------------------------------------------------------------------------
@@ -1894,8 +1903,8 @@ void InGameUI::handleBuildPlacements( void )
// set the drawble position
m_placeIcon[ i ]->setPosition( &tileBuildInfo->positions[ i ] );
- // set opacity for the drawble
- m_placeIcon[ i ]->setDrawableOpacity( placementOpacity );
+ // set opacity and shadowing for the drawble
+ dressPlacementPreview( m_placeIcon[ i ] );
// set the drawable angle
m_placeIcon[ i ]->setOrientation( angle );
@@ -3531,7 +3540,7 @@ void InGameUI::placeBuildAvailable( const ThingTemplate *build, Drawable *buildD
draw->setOrientation( angle );
// set the build icon attached to the cursor to be "see-thru"
- draw->setDrawableOpacity( placementOpacity );
+ dressPlacementPreview( draw );
// set the "icon" in the icon array at the first index
DEBUG_ASSERTCRASH( m_placeIcon[ 0 ] == NULL, ("placeBuildAvailable, build icon array is not empty!") );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index d861af71d..1bee84399 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -94,7 +94,10 @@
-#define dont_ALLOW_ALT_F4
+// Alt+F4 and the window's close button both end up as MSG_META_DEMO_INSTANT_QUIT
+// (WinMain's WM_CLOSE posts it). With this off, that message had no handler at all:
+// the title bar's X and Alt+F4 did nothing, and the only way out was the menus.
+#define ALLOW_ALT_F4
//-------------------------------------------------------------------------------------------------
/**
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
index ff1f694bb..ded5d5044 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/LookAtXlat.cpp
@@ -292,7 +292,9 @@ GameMessageDisposition LookAtTranslator::translateGameMessage(const GameMessage
m_anchor = msg->getArgument( 0 )->pixel;
m_currentPos = msg->getArgument( 0 )->pixel;
- if (!TheInGameUI->isSelecting() && !m_isScrolling)
+ // `RightMouseScroll = no` in Options.ini frees the right button. In alternate mouse
+ // mode it is the selection button, so every selection drag was also a camera drag.
+ if (TheGlobalData->m_rightMouseScroll && !TheInGameUI->isSelecting() && !m_isScrolling)
{
setScrolling(SCROLL_RMB);
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
index 2daedc9aa..35a5f6aeb 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp
@@ -1201,8 +1201,11 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate,
m_slavePosOffset = sysTemplate->m_slavePosOffset;
- ///@todo: further formalize this parameter with an UnsignedInt field in the editor
- m_volumeParticleDepth = DEFAULT_VOLUME_PARTICLE_DEPTH;
+ // EA's own todo here was "further formalize this parameter with an UnsignedInt field in the
+ // editor": the member existed, was reset to zero on every system built from a template, and
+ // the getter ignored it and returned a hard-coded 6 for anything typed VOLUME_PARTICLE.
+ // It is a template field now, and zero still means "whatever the engine thinks best".
+ m_volumeParticleDepth = sysTemplate->m_volumeParticleDepth;
m_driftVelocity = sysTemplate->m_driftVelocity;
@@ -2861,6 +2864,7 @@ const FieldParse ParticleSystemTemplate::m_fieldParseTable[] =
{ "IsOneShot", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_isOneShot ) },
{ "Shader", INI::parseIndexList, ParticleShaderTypeNames, offsetof( ParticleSystemTemplate, m_shaderType ) },
{ "Type", INI::parseIndexList, ParticleTypeNames, offsetof( ParticleSystemTemplate, m_particleType ) },
+ { "VolumeParticleDepth", INI::parseUnsignedInt, NULL, offsetof( ParticleSystemTemplate, m_volumeParticleDepth ) },
{ "ParticleName", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_particleTypeName ) },
{ "AngleZ", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_angleZ ) },
{ "AngularRateZ", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_angularRateZ ) },
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp
index c6f0de4a6..27657b1aa 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/CrateCollide.cpp
@@ -58,6 +58,7 @@ CrateCollideModuleData::CrateCollideModuleData()
m_executeAnimationFades = TRUE;
m_isBuildingPickup = FALSE;
m_isHumanOnlyPickup = FALSE;
+ m_allowMultiplePickup = FALSE;
m_executeFX = NULL;
m_pickupScience = SCIENCE_INVALID;
@@ -82,6 +83,7 @@ void CrateCollideModuleData::buildFieldParse(MultiIniFieldParse& p)
{ "ForbidOwnerPlayer", INI::parseBool, NULL, offsetof( CrateCollideModuleData, m_isForbidOwnerPlayer ) },
{ "BuildingPickup", INI::parseBool, NULL, offsetof( CrateCollideModuleData, m_isBuildingPickup ) },
{ "HumanOnly", INI::parseBool, NULL, offsetof( CrateCollideModuleData, m_isHumanOnlyPickup ) },
+ { "AllowMultiplePickup", INI::parseBool, NULL, offsetof( CrateCollideModuleData, m_allowMultiplePickup ) },
{ "PickupScience", INI::parseScience, NULL, offsetof( CrateCollideModuleData, m_pickupScience ) },
{ "ExecuteFX", INI::parseFXList, NULL, offsetof( CrateCollideModuleData, m_executeFX ) },
{ "ExecuteAnimation", INI::parseAsciiString, NULL, offsetof( CrateCollideModuleData, m_executionAnimationTemplate ) },
@@ -178,7 +180,9 @@ Bool CrateCollide::isValidToExecute( const Object *other ) const
// every unit that touches the crate in the same frame used to collect it: the crate is marked
// destroyed by the first one, but destruction does not happen until the end of the frame.
- if( getObject()->isDestroyed() )
+ // `AllowMultiplePickup = Yes` asks for that back, for a crate that is meant to pay a whole
+ // group at once.
+ if( !md->m_allowMultiplePickup && getObject()->isDestroyed() )
return FALSE;
if( md->m_isForbidOwnerPlayer && (getObject()->getControllingPlayer() == other->getControllingPlayer()) )
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp
index 4763a3e3c..49b28bc34 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/CreateObjectDie.cpp
@@ -38,6 +38,8 @@
#include "GameLogic/Object.h"
#include "GameLogic/ObjectCreationList.h"
#include "GameLogic/Module/BodyModule.h"
+#include "GameClient/Drawable.h"
+#include "GameClient/InGameUI.h"
#ifdef _INTERNAL
// for occasional debugging...
@@ -52,6 +54,7 @@ CreateObjectDieModuleData::CreateObjectDieModuleData()
m_ocl = NULL;
m_transferPreviousHealth = FALSE;
+ m_transferSelection = FALSE;
}
@@ -65,6 +68,7 @@ CreateObjectDieModuleData::CreateObjectDieModuleData()
{
{ "CreationList", INI::parseObjectCreationList, NULL, offsetof( CreateObjectDieModuleData, m_ocl ) },
{ "TransferPreviousHealth", INI::parseBool, NULL ,offsetof( CreateObjectDieModuleData, m_transferPreviousHealth ) },
+ { "TransferSelection", INI::parseBool, NULL ,offsetof( CreateObjectDieModuleData, m_transferSelection ) },
{ 0, 0, 0, 0 }
};
p.add(dataFieldParse);
@@ -101,6 +105,23 @@ void CreateObjectDie::onDie( const DamageInfo * damageInfo )
Object *newObject = ObjectCreationList::create( data->m_ocl, getObject(), damageDealer );
+ // A unit that turns into something else on death - a bus into a wreck that still fights, a
+ // hull into its crew - used to drop out of your selection the moment it changed, so a mid-fight
+ // transformation cost you the order you were about to give. `TransferSelection = Yes` hands the
+ // selection on. Selection is the local player's own business, so this touches nothing the other
+ // machines in a network game have to agree about.
+ if( newObject && data->m_transferSelection && TheInGameUI )
+ {
+ Drawable *oldDraw = getObject()->getDrawable();
+ Drawable *newDraw = newObject->getDrawable();
+
+ if( oldDraw && newDraw && oldDraw->isSelected() && !newDraw->isSelected() )
+ {
+ TheInGameUI->selectDrawable( newDraw );
+ TheInGameUI->deselectDrawable( oldDraw );
+ }
+ }
+
//If we're transferring previous health, we're transfering the last known
//health before we died. In the case of the sneak attack tunnel network, it
//is killed after the lifetime update expires.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
index a4420a0ad..edbc45e5e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
@@ -68,6 +68,7 @@ SpecialPowerModuleData::SpecialPowerModuleData()
m_specialPowerTemplate = NULL;
m_updateModuleStartsAttack = false;
m_startsPaused = FALSE;
+ m_startsReady = FALSE;
m_scriptedSpecialPowerOnly = FALSE;
} // end SpecialPowerModuleData
@@ -83,6 +84,7 @@ SpecialPowerModuleData::SpecialPowerModuleData()
{ "SpecialPowerTemplate", INI::parseSpecialPowerTemplate, NULL, offsetof( SpecialPowerModuleData, m_specialPowerTemplate ) },
{ "UpdateModuleStartsAttack", INI::parseBool, NULL, offsetof( SpecialPowerModuleData, m_updateModuleStartsAttack ) },
{ "StartsPaused", INI::parseBool, NULL, offsetof( SpecialPowerModuleData, m_startsPaused ) },
+ { "StartsReady", INI::parseBool, NULL, offsetof( SpecialPowerModuleData, m_startsReady ) },
{ "InitiateSound", INI::parseAudioEventRTS, NULL, offsetof( SpecialPowerModuleData, m_initiateSound ) },
{ "ScriptedSpecialPowerOnly", INI::parseBool, NULL, offsetof( SpecialPowerModuleData, m_scriptedSpecialPowerOnly ) },
{ 0, 0, 0, 0 }
@@ -427,8 +429,15 @@ void SpecialPowerModule::startPowerRecharge()
}
else
{
- // set the frame we will be 100% available on now
- m_availableOnFrame = TheGameLogic->getFrame() + getSpecialPowerTemplate()->getReloadTime();
+ //
+ // StartsReady = Yes means the first use costs no wait: the object is built and the power is
+ // there. Every reload after it is the normal one, because this only runs when the recharge
+ // is started and the first start is the one at creation.
+ //
+ if( modData->m_startsReady && m_availableOnFrame == 0 )
+ m_availableOnFrame = TheGameLogic->getFrame();
+ else
+ m_availableOnFrame = TheGameLogic->getFrame() + getSpecialPowerTemplate()->getReloadTime();
}
}
diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h
index babb880c3..ff733a529 100644
--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h
+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h
@@ -168,11 +168,14 @@ public:
/// Update the macro texture (pass 3).
void setTextureLOD(Int lod); ///<change the maximum mip-level sent to the hardware.
+ void applyScorchTextureLOD(void); ///<re-apply that level to the scorch texture (it is rebuilt on a device reset)
void updateMacroTexture(AsciiString textureName);
void doTextures(Bool flag) {m_disableTextures = !flag;};
/// Update the diffuse value from static light info for one vertex.
void doTheLight(VERTEX_FORMAT *vb, Vector3*light, Vector3*normal, RefRenderObjListIterator *pLightsIterator, UnsignedByte alpha);
void addScorch(Vector3 location, Real radius, Scorches type);
+ /// Everything added so far came with the map and is not to be thrown away to make room.
+ void markScorchesStatic(void);
void addTree(DrawableID id, Coord3D location, Real scale, Real angle,
Real randomScaleAmount, const W3DTreeDrawModuleData *data);
void removeAllTrees(void);
@@ -265,6 +268,13 @@ protected:
Int m_curNumScorchIndices; ///<number of indices used in m_indexScorch.
TScorch m_scorches[MAX_SCORCH_MARKS];
Int m_numScorches;
+ /** How many of the scorches at the front of that list came with the map.
+ *
+ * The list is full-up on any long match and the oldest entry is thrown away to make room.
+ * The oldest entries are the map's own authored scorch marks, so an hour of fighting quietly
+ * erased everything the level designer put down. These are never evicted. */
+ Int m_numStaticScorches;
+ Int m_currentTextureLOD; ///< last value setTextureLOD was given; re-applied to textures rebuilt after a device reset
Int m_scorchesInBuffer; ///< how many are in the buffers. If less than numScorches, we need to update
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
index 7d531698f..6932da298 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp
@@ -2774,18 +2774,28 @@ Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const
}
Real objDistance = distance.length();
- if( objDistance > objMinDistance )
+
+ // `RangeVolumeFade = Yes` in AudioSettings.ini uses the linear fade EA left
+ // commented out right here. The default curve is 1/distance, which never reaches
+ // zero, so the hard cut at the maximum range makes a sound you are walking away
+ // from stop dead instead of fading out. The linear one reaches zero exactly where
+ // the cut is. Off by default: it changes how every 3D sound in the game attenuates,
+ // and that is a listening decision, not a bug fix.
+ if( TheAudio->getAudioSettings()->m_rangeVolumeFade &&
+ objMaxDistance > objMinDistance )
+ {
+ if( objDistance > objMinDistance )
+ volume *= 1.0f - (objDistance - objMinDistance) / (objMaxDistance - objMinDistance);
+ }
+ else if( objDistance > objMinDistance )
{
volume *= 1 / (objDistance / objMinDistance);
}
- if( objDistance >= objMaxDistance )
+
+ if( objDistance >= objMaxDistance )
{
volume = 0.0f;
}
- //else if( objDistance > objMinDistance )
- //{
- // volume *= 1.0f - (objDistance - objMinDistance) / (objMaxDistance - objMinDistance);
- //}
}
}
else
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
index b74c71f85..7b953ff35 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
@@ -313,6 +313,7 @@ BaseHeightMapRenderObjClass::BaseHeightMapRenderObjClass(void)
m_vertexScorch = NULL;
m_indexScorch = NULL;
m_scorchTexture = NULL;
+ m_currentTextureLOD = 0;
clearAllScorches();
#endif
#if defined(_DEBUG) || defined(_INTERNAL)
@@ -328,10 +329,32 @@ BaseHeightMapRenderObjClass::BaseHeightMapRenderObjClass(void)
void BaseHeightMapRenderObjClass::setTextureLOD(Int lod)
{
+ // Remembered because the scorch texture is thrown away and rebuilt on a device reset, and the
+ // rebuilt one has to come back at the quality the player asked for rather than at full size.
+ m_currentTextureLOD = lod;
+
if (m_treeBuffer)
m_treeBuffer->setTextureLOD(lod);
if (m_map)
m_map->setTextureLOD(lod);
+#ifdef DO_SCORCH
+ // The terrain and the trees followed the texture quality setting and the scorch marks did not,
+ // so on Low the ground went soft underneath craters that stayed sharp.
+ applyScorchTextureLOD();
+#endif
+}
+
+//=============================================================================
+// BaseHeightMapRenderObjClass::applyScorchTextureLOD
+//=============================================================================
+/** Push the current texture quality into the scorch texture, whenever there is one. */
+//=============================================================================
+void BaseHeightMapRenderObjClass::applyScorchTextureLOD(void)
+{
+#ifdef DO_SCORCH
+ if (m_scorchTexture && m_scorchTexture->Peek_D3D_Texture())
+ m_scorchTexture->Peek_D3D_Texture()->SetLOD((DWORD)m_currentTextureLOD);
+#endif
}
//=============================================================================
@@ -1895,6 +1918,7 @@ void BaseHeightMapRenderObjClass::allocateScorchBuffers(void)
m_vertexScorch=NEW_REF(DX8VertexBufferClass,(DX8_FVF_XYZDUV1,MAX_SCORCH_VERTEX,DX8VertexBufferClass::USAGE_DEFAULT));
m_indexScorch=NEW_REF(DX8IndexBufferClass,(MAX_SCORCH_INDEX));
m_scorchTexture=NEW ScorchTextureClass;
+ applyScorchTextureLOD(); // a fresh texture starts at full size; the player may have asked for less
m_scorchesInBuffer = 0; // If we just allocated the buffers, we got no scorches in the buffer.
m_curNumScorchVertices=0;
m_curNumScorchIndices=0;
@@ -2058,8 +2082,22 @@ void BaseHeightMapRenderObjClass::clearAllScorches(void)
{
#ifdef DO_SCORCH
m_numScorches=0;
- m_scorchesInBuffer=0;
-#endif
+ m_numStaticScorches=0;
+ m_scorchesInBuffer=0;
+#endif
+}
+
+//=============================================================================
+// BaseHeightMapRenderObjClass::markScorchesStatic
+//=============================================================================
+/** Everything on the list right now came out of the map file. Say so, so that combat never
+ * evicts it. Called once, when the terrain has finished loading the map's own scorch objects. */
+//=============================================================================
+void BaseHeightMapRenderObjClass::markScorchesStatic(void)
+{
+#ifdef DO_SCORCH
+ m_numStaticScorches = m_numScorches;
+#endif
}
//=============================================================================
@@ -2088,7 +2126,14 @@ void BaseHeightMapRenderObjClass::addScorch(Vector3 location, Real radius, Scorc
}
if (m_numScorches >= MAX_SCORCH_MARKS) {
- for (i=0; i<MAX_SCORCH_MARKS-1; i++) {
+ // Make room by dropping the oldest scorch the fighting made, not the oldest scorch there is.
+ // The front of this list is whatever the map file put down, and shifting from index 0 ate
+ // one of those every time the list filled up - so a long match wiped the level designer's
+ // craters off the ground one by one.
+ if (m_numStaticScorches >= MAX_SCORCH_MARKS)
+ return; // nothing but map scorches: keep them all and drop this one instead
+
+ for (i=m_numStaticScorches; i<MAX_SCORCH_MARKS-1; i++) {
m_scorches[i] = m_scorches[i+1];
}
m_numScorches--;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp
index 0a2687eb9..bad663f86 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp
@@ -634,16 +634,17 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx)
}
if (m_dirtEffect) {
if (wheelInfo && wheelInfo->m_framesAirborne>3) {
- Real factor = 1 + wheelInfo->m_framesAirborne/16;
- if (factor>2.0) factor = 2.0;
- m_dustEffect->setSizeMultiplier(factor*SIZE_CAP);
- m_dustEffect->trigger();
+ // See W3DTruckDraw: the landing puff is the dust system's, and this branch reached
+ // it while guarded on the dirt system - a null dereference for anything with a
+ // DirtSpray and no Dust.
+ if (m_dustEffect) {
+ Real factor = 1 + wheelInfo->m_framesAirborne/16;
+ if (factor>2.0) factor = 2.0;
+ m_dustEffect->setSizeMultiplier(factor*SIZE_CAP);
+ m_dustEffect->trigger();
+ }
m_landingSound.setPosition(obj->getPosition());
TheAudio->addAudioEvent(&m_landingSound);
- } else {
- if (!accelerating || speed>2.0f) {
- m_dirtEffect->stop();
- }
}
}
if (m_powerslideEffect) {
@@ -654,10 +655,9 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx)
m_powerslideEffect->start();
}
}
- if (m_dirtEffect) {
- if (!accelerating || speed>2.0f) {
- m_dirtEffect->stop();
- }
+ // once, not twice: the else of the airborne branch above said exactly this
+ if (m_dirtEffect && (!accelerating || speed>2.0f)) {
+ m_dirtEffect->stop();
}
}
else
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp
index 2a7a10278..eab4d6d38 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp
@@ -598,16 +598,17 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx)
}
if (m_dirtEffect) {
if (wheelInfo && wheelInfo->m_framesAirborne>3) {
- Real factor = 1 + wheelInfo->m_framesAirborne/16;
- if (factor>2.0) factor = 2.0;
- m_dustEffect->setSizeMultiplier(factor*SIZE_CAP);
- m_dustEffect->trigger();
+ // The landing puff belongs to the dust system, not the dirt system. This branch was
+ // guarded on m_dirtEffect and then went straight through m_dustEffect, which is a
+ // null dereference for any vehicle whose INI gives it a DirtSpray and no Dust.
+ if (m_dustEffect) {
+ Real factor = 1 + wheelInfo->m_framesAirborne/16;
+ if (factor>2.0) factor = 2.0;
+ m_dustEffect->setSizeMultiplier(factor*SIZE_CAP);
+ m_dustEffect->trigger();
+ }
m_landingSound.setObjectID(obj->getID());
TheAudio->addAudioEvent(&m_landingSound);
- } else {
- if (!accelerating || speed>2.0f) {
- m_dirtEffect->stop();
- }
}
}
if (m_powerslideEffect) {
@@ -618,10 +619,10 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx)
m_powerslideEffect->start();
}
}
- if (m_dirtEffect) {
- if (!accelerating || speed>2.0f) {
- m_dirtEffect->stop();
- }
+ // The same test was written out twice - once as the else of the airborne branch above and
+ // once again down here - so the else was doing nothing the second copy did not already do.
+ if (m_dirtEffect && (!accelerating || speed>2.0f)) {
+ m_dirtEffect->stop();
}
}
else
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
index 09b297cf4..a65ac5472 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp
@@ -1928,7 +1928,10 @@ W3DProjectedShadow* W3DProjectedShadowManager::addShadow(RenderObjClass *robj, S
switch (shadow->m_type)
{
+ // same three kinds the two addDecal paths count, so that adding and removing agree
case SHADOW_DECAL:
+ case SHADOW_ALPHA_DECAL:
+ case SHADOW_ADDITIVE_DECAL:
m_numDecalShadows++;
break;
case SHADOW_PROJECTION:
@@ -2062,7 +2065,12 @@ void W3DProjectedShadowManager::removeShadow (W3DProjectedShadow *shadow)
m_decalList=shadow->m_next;
switch (shadow->m_type)
{
+ // addDecal counts all three decal kinds; this only ever counted one of them
+ // back down, and this loop is entered only for the other two - so the decal
+ // count climbed for the whole match and never came back.
case SHADOW_DECAL:
+ case SHADOW_ALPHA_DECAL:
+ case SHADOW_ADDITIVE_DECAL:
m_numDecalShadows--;
break;
case SHADOW_PROJECTION:
@@ -2088,6 +2096,8 @@ void W3DProjectedShadowManager::removeShadow (W3DProjectedShadow *shadow)
switch (shadow->m_type)
{
case SHADOW_DECAL:
+ case SHADOW_ALPHA_DECAL:
+ case SHADOW_ADDITIVE_DECAL:
m_numDecalShadows--;
break;
case SHADOW_PROJECTION:
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
index 7c4d36cf4..fd01d26c4 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp
@@ -919,6 +919,12 @@ void W3DDisplay::init( void )
// 4, 8 or 16; the device degrades an unsupported one on its own.
DX8Wrapper::Set_Requested_MultiSample_Level( msaaSamplesForLevel( TheGlobalData->m_msaaLevel ) );
+ // Same problem, same answer: the filter table is built the moment the device exists and WW3D2
+ // cannot see GlobalData, so the player's texture filtering goes in here. Nothing in the game
+ // ever called Set_Texture_Filter, so before this the mode was whatever the WW3D2 default was.
+ WW3D::Set_Requested_Texture_Filter( TheGlobalData->m_textureFilterMode );
+ TextureFilterClass::_Set_Requested_Anisotropy( (unsigned int)TheGlobalData->m_anisotropyLevel );
+
if( WW3D::Set_Render_Device( 0,
getWidth(),
getHeight(),
@@ -3219,8 +3225,12 @@ VideoBuffer* W3DDisplay::createVideoBuffer( void )
return NULL;
}
}
- // on low mem machines, render every video in 16bit except for the EA Logo movie
- if(!TheGlobalData->m_playIntro )//&& TheGameLODManager && (!TheGameLODManager->didMemPass() || W3DShaderManager::getChipset() == DC_GEFORCE2))
+ // on low mem machines, render every video in 16bit except for the EA Logo movie.
+ // The low-memory half of that test is commented out right there, so this fires on
+ // every machine - and it used to fire even when the device had just told us it does
+ // not support R5G6B5, handing the video player a format it cannot create.
+ if( !TheGlobalData->m_playIntro//&& TheGameLODManager && (!TheGameLODManager->didMemPass() || W3DShaderManager::getChipset() == DC_GEFORCE2))
+ && DX8Wrapper::Get_Current_Caps()->Support_Texture_Format( WW3D_FORMAT_R5G6B5 ) )
format = VideoBuffer::TYPE_R5G6B5;
W3DVideoBuffer *buffer = NEW W3DVideoBuffer( format );
@@ -3449,6 +3459,28 @@ static void saveScreenShot(void)
bounds.right=point.x; bounds.bottom=point.y;
}
+ // The front-buffer path above turns the window's client area into desktop coordinates, and a
+ // window can hang off the edge of the desktop - ask for a 1600x1200 window on a 1080-tall
+ // monitor and it does. Reading that rectangle walks off the end of the front buffer and faults
+ // inside the copy loop below, which is a screenshot taking the game down. Clamp to the surface.
+ {
+ D3DSURFACE_DESC fbDesc;
+ if (fb != NULL && SUCCEEDED(fb->GetDesc(&fbDesc)))
+ {
+ if (bounds.left < 0) bounds.left = 0;
+ if (bounds.top < 0) bounds.top = 0;
+ if (bounds.right > (LONG)fbDesc.Width) bounds.right = (LONG)fbDesc.Width;
+ if (bounds.bottom > (LONG)fbDesc.Height) bounds.bottom = (LONG)fbDesc.Height;
+ }
+
+ if (fb == NULL || bounds.right <= bounds.left || bounds.bottom <= bounds.top)
+ {
+ if (fb != NULL)
+ fb->Release();
+ return; // nothing to save; better than a fault
+ }
+ }
+
D3DLOCKED_RECT lrect;
DX8_ErrorCode(fb->LockRect(&lrect,&bounds,D3DLOCK_READONLY));
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
index 9e66208a9..70f4667f0 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DParticleSys.cpp
@@ -187,7 +187,10 @@ void W3DParticleSystemManager::doParticles(RenderInfoClass &rinfo)
Smudge *smudge = set->addSmudgeToSet();
smudge->m_pos.Set( pos->x, pos->y, pos->z );
- smudge->m_offset.Set( GameClientRandomValueReal(-0.06f,0.06f), GameClientRandomValueReal(-0.03f,0.03f) );
+ // Same range on both axes. The vertical one was half the horizontal, which
+ // nobody could see while the centre vertex was reading the horizontal offset
+ // for both - now that it reads .Y, a heat smudge pulled twice as far sideways.
+ smudge->m_offset.Set( GameClientRandomValueReal(-0.06f,0.06f), GameClientRandomValueReal(-0.06f,0.06f) );
smudge->m_size = psize;
smudge->m_opacity = p->getAlpha();
visibleSmudgeCount++;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
index 94e59031b..79ba666cd 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp
@@ -266,7 +266,15 @@ void RTS3DScene::flagOccludedObjects(CameraClass * camera)
m_occludedObjectsCount=0;
for (Int i=0; i<m_numPotentialOccludees; i++,occludee++)
- {
+ {
+ // Per occludee. This was declared once outside the loop and never cleared, so the first
+ // object found to be behind a building made every object after it in the list "occluded"
+ // too - whatever was actually in front of it, and with no occluder to point at. On a busy
+ // screen that is most of the list drawn through the see-through path for nothing.
+ hit=FALSE;
+ result.StartBad = false;
+ result.Fraction = 1.0f;
+
raytest.Ray.Set(camPosition,(*occludee)->Get_Position());
RenderObjClass **occluder=m_potentialOccluders;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp
index 4364a4944..f8d59de96 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp
@@ -704,6 +704,11 @@ Bool W3DTerrainVisual::load( AsciiString filename )
pMapObj = pMapObj->getNext();
}
+ // Everything on the scorch list came out of the map file. Say so: the list has a fixed size and
+ // makes room by dropping its oldest entry, and the oldest entries are these - so a long match
+ // used to rub out the map's own craters one at a time.
+ m_terrainRenderObject->markScorchesStatic();
+
// reset water render object if present
if( m_waterRenderObject )
{
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp
index 79876c7d6..59f85a9d1 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp
@@ -999,11 +999,17 @@ void WaterTracksRenderSystem::saveTracks(void)
return;
AsciiString fileName=TheTerrainLogic->getSourceFilename();
- char path[256];
+ char path[_MAX_PATH];
+
+ // The map name is whatever the player's Maps folder is called, so it is not
+ // bounded by anything this code owns: the old fixed 256 byte copy overran on a
+ // long path, and a name shorter than ".map" wrote the new extension in front of
+ // the buffer.
+ Int len=fileName.getLength();
+ if (len < 4 || len >= (Int)sizeof(path))
+ return;
strcpy(path,fileName.str());
- Int len=strlen(path);
-
strcpy(path+len-4,".wak");
WaterTracksObj *umod;
@@ -1037,11 +1043,13 @@ void WaterTracksRenderSystem::loadTracks(void)
return;
AsciiString fileName=TheTerrainLogic->getSourceFilename();
- char path[256];
+ char path[_MAX_PATH];
- strcpy(path,fileName.str());
- Int len=strlen(path);
+ Int len=fileName.getLength();
+ if (len < 4 || len >= (Int)sizeof(path))
+ return;
+ strcpy(path,fileName.str());
strcpy(path+len-4,".wak");
File *file = TheFileSystem->openFile(path, File::READ | File::BINARY);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
index 128f2ec64..8786116d8 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/sortingrenderer.cpp
@@ -336,6 +336,9 @@ static unsigned overlapping_node_count;
static unsigned overlapping_polygon_count;
static unsigned overlapping_vertex_count;
static const unsigned MAX_OVERLAPPING_NODES=4096;
+// 16 bit indices: 65535 is the last index a triangle can name, and three of them per polygon.
+static const unsigned MAX_SORTING_VERTICES=65535;
+static const unsigned MAX_SORTING_POLYGONS=65535/3;
static SortingNodeStruct* overlapping_nodes[MAX_OVERLAPPING_NODES];
// ----------------------------------------------------------------------------
@@ -348,6 +351,17 @@ void SortingRendererClass::Insert_To_Sorting_Pool(SortingNodeStruct* state)
return;
}
+ // The pool feeds one dynamic index buffer and one dynamic vertex buffer, and both
+ // are 16 bit. Past 65535 indices Flush_Sorting_Pool asks for a buffer that cannot
+ // exist and writes the triangles into it anyway; past 65535 vertices the per-node
+ // vertex offset stored in each triangle wraps and the geometry comes out as noise.
+ // Refuse the node instead, the way an over-full node list already does.
+ if (overlapping_polygon_count+state->polygon_count>MAX_SORTING_POLYGONS ||
+ overlapping_vertex_count+state->vertex_count>MAX_SORTING_VERTICES) {
+ Release_Refs(state);
+ return;
+ }
+
overlapping_nodes[overlapping_node_count]=state;
overlapping_vertex_count+=state->vertex_count;
overlapping_polygon_count+=state->polygon_count;
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp
index 3af9b8e57..d3dfbfe54 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp
@@ -40,6 +40,20 @@
#include "texturefilter.h"
#include "dx8wrapper.h"
+/// 0 = take whatever the device offers; see _Set_Requested_Anisotropy
+static unsigned int _RequestedAnisotropy = 0;
+
+void TextureFilterClass::_Set_Requested_Anisotropy(unsigned int level)
+{
+ if (level > 16) level = 16;
+ _RequestedAnisotropy = level;
+}
+
+unsigned int TextureFilterClass::_Get_Requested_Anisotropy(void)
+{
+ return _RequestedAnisotropy;
+}
+
unsigned _MinTextureFilters[MAX_TEXTURE_STAGES][TextureFilterClass::FILTER_TYPE_COUNT];
unsigned _MagTextureFilters[MAX_TEXTURE_STAGES][TextureFilterClass::FILTER_TYPE_COUNT];
unsigned _MipMapFilters[MAX_TEXTURE_STAGES][TextureFilterClass::FILTER_TYPE_COUNT];
@@ -194,6 +208,10 @@ void TextureFilterClass::_Init_Filters(TextureFilterMode filter_type)
if (filter_type==TEXTURE_FILTER_ANISOTROPIC) {
maxAnisotropy = dx8caps.MaxAnisotropy;
if (maxAnisotropy > 16) maxAnisotropy = 16;
+ // The player may ask for less than the device can do; asking for more than it can do is
+ // still the device's answer, because there is nothing to be gained by lying to it.
+ if (_RequestedAnisotropy != 0 && _RequestedAnisotropy < maxAnisotropy)
+ maxAnisotropy = _RequestedAnisotropy;
if (maxAnisotropy < 1) maxAnisotropy = 1;
}
for (i=0;i<MAX_TEXTURE_STAGES;++i) {
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h
index 6bee63ba6..8b8e4e564 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h
@@ -117,6 +117,13 @@ public:
// This needs to be called after device has been created
static void _Init_Filters(TextureFilterMode texture_filter);
+ /** How many samples anisotropic filtering may take. Zero, the default, means whatever the
+ * device says it can do (capped at 16). WW3D2 cannot read the game's settings, so the player's
+ * choice is pushed in from W3DDisplay::init before the device is made, the way the
+ * multisample level is. */
+ static void _Set_Requested_Anisotropy(unsigned int level);
+ static unsigned int _Get_Requested_Anisotropy(void);
+
static void _Set_Default_Min_Filter(FilterType filter);
static void _Set_Default_Mag_Filter(FilterType filter);
static void _Set_Default_Mip_Filter(FilterType filter);
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
index 2e11dede3..8b24e25dc 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.cpp
@@ -771,11 +771,16 @@ void WW3D::_Invalidate_Textures()
}
}
-void WW3D::Set_Texture_Filter(int texture_filter)
+void WW3D::Set_Requested_Texture_Filter(int texture_filter)
{
if (texture_filter<0) texture_filter=0;
if (texture_filter>TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC) texture_filter=TextureFilterClass::TEXTURE_FILTER_ANISOTROPIC;
TextureFilter=texture_filter;
+}
+
+void WW3D::Set_Texture_Filter(int texture_filter)
+{
+ Set_Requested_Texture_Filter(texture_filter);
TextureFilterClass::_Init_Filters((TextureFilterClass::TextureFilterMode)TextureFilter);
}
diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.h
index d462688be..23ffee92b 100644
--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.h
+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ww3d.h
@@ -142,6 +142,11 @@ public:
static void Set_Texture_Filter(int filter);
static int Get_Texture_Filter() { return TextureFilter; }
+ /** Record the mode without rebuilding the filter table. Set_Texture_Filter rebuilds it there and
+ * then, and the table is read out of the device caps - so it can only be called once a device
+ * exists. This one is for before that, which is when the player's setting arrives. */
+ static void Set_Requested_Texture_Filter(int filter);
+
/*
** Rendering functions
** Each frame should be bracketed by a Begin_Render and End_Render call. Between these two calls you will
diff --git a/GeneralsMD/Code/Main/WinMain.cpp b/GeneralsMD/Code/Main/WinMain.cpp
index 2b1f7bf61..44962553a 100644
--- a/GeneralsMD/Code/Main/WinMain.cpp
+++ b/GeneralsMD/Code/Main/WinMain.cpp
@@ -419,6 +419,9 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT message,
//_exit(EXIT_SUCCESS);
return 0;
}
+ // No engine to ask, or it is already on its way out: let DefWindowProc take
+ // the window down. Falling through into WM_SETFOCUS is what used to happen.
+ break;
// ------------------------------------------------------------------------
case WM_SETFOCUS:
diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cpp
index f0db605a8..9dc870052 100644
--- a/GeneralsMD/Code/Tests/test_gameengine.cpp
+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp
@@ -70,6 +70,9 @@
#include "GameNetwork/GameInfo.h"
#include <float.h>
#include "GameClient/Water.h"
+#include "GameClient/Shadow.h"
+#include "GameClient/UiAnimClock.h"
+#include "Common/QuotedPrintable.h"
#include "GameLogic/Module/PhysicsUpdate.h"
#include "GameClient/GameClient.h"
#include "Common/GameEngine.h"
@@ -9162,3 +9165,116 @@ TEST(crowd_brake_only_reads_closing_time)
// a zero window is the rule switched off, not a division by zero
CHECK_NEAR( Crowd_brakeSpeed( full, 0.0f, 0.0f, 0 ), full, 0.0001f );
}
+
+//-------------------------------------------------------------------------------------------------
+// A shadow request is filled in field by field by whoever makes it, and the debris draw module
+// never touched the name at all. The shadow manager reads that name the moment its first byte is
+// not zero, so an uninitialised stack was being strlen'd and copied as a texture name.
+//-------------------------------------------------------------------------------------------------
+TEST(a_shadow_request_starts_with_no_texture_name)
+{
+ // Build the request on top of a scribbled buffer, default-initialised the way a local
+ // variable is. Without a constructor on the struct that leaves the pattern in place -
+ // which is the whole failure - so this check cannot pass by accident.
+ char raw[ sizeof(Shadow::ShadowTypeInfo) ];
+ memset( raw, 0x7F, sizeof(raw) );
+
+ Shadow::ShadowTypeInfo *info = ::new ( (void *)raw ) Shadow::ShadowTypeInfo;
+
+ CHECK_EQ( info->m_ShadowName[ 0 ], '\0' );
+ CHECK_EQ( (Int)strlen( info->m_ShadowName ), 0 );
+ CHECK_EQ( (Int)info->m_type, (Int)SHADOW_NONE );
+ CHECK_NEAR( info->m_sizeX, 0.0f, 0.0001f );
+ CHECK_NEAR( info->m_sizeY, 0.0f, 0.0001f );
+ CHECK_NEAR( info->m_offsetX, 0.0f, 0.0001f );
+ CHECK_NEAR( info->m_offsetY, 0.0f, 0.0001f );
+ CHECK( !info->allowUpdates );
+ CHECK( !info->allowWorldAlign );
+}
+
+//-------------------------------------------------------------------------------------------------
+// MenuTransitionSpeed scales the rate the shell's slides and fades step at. The catalog clamps the
+// setting, but the function is what the menus actually call and a zero reaching it would be a
+// division by nothing, so it clamps again on its own.
+//-------------------------------------------------------------------------------------------------
+TEST(menu_transition_speed_scales_the_step_rate_and_never_reaches_zero)
+{
+ GlobalData *saved = TheWritableGlobalData;
+ GlobalData *scratch = NEW GlobalData;
+ TheWritableGlobalData = scratch;
+
+ // the default is the rate the menus were drawn at, unchanged
+ CHECK_EQ( scratch->m_menuTransitionSpeed, 100 );
+ CHECK_NEAR( GameClient_menuAnimStepsPerSec(), UI_ANIM_STEPS_PER_SEC, 0.0001f );
+
+ scratch->m_menuTransitionSpeed = 200;
+ CHECK_NEAR( GameClient_menuAnimStepsPerSec(), UI_ANIM_STEPS_PER_SEC * 2.0f, 0.0001f );
+
+ scratch->m_menuTransitionSpeed = 50;
+ CHECK_NEAR( GameClient_menuAnimStepsPerSec(), UI_ANIM_STEPS_PER_SEC * 0.5f, 0.0001f );
+
+ // out of range on either side lands on the range, and nothing ever comes back at or below zero
+ scratch->m_menuTransitionSpeed = 0;
+ CHECK_NEAR( GameClient_menuAnimStepsPerSec(), UI_ANIM_STEPS_PER_SEC * 0.25f, 0.0001f );
+
+ scratch->m_menuTransitionSpeed = -1000;
+ CHECK( GameClient_menuAnimStepsPerSec() > 0.0f );
+
+ scratch->m_menuTransitionSpeed = 100000;
+ CHECK_NEAR( GameClient_menuAnimStepsPerSec(), UI_ANIM_STEPS_PER_SEC * 4.0f, 0.0001f );
+
+ TheWritableGlobalData = saved;
+ delete scratch;
+}
+
+//-------------------------------------------------------------------------------------------------
+// The structure riding the cursor is drawn at BuildPlacementOpacity and casts a shadow or not
+// according to BuildPlacementShadows. Both defaults have to be what the game always did, or every
+// player who never touches GameData.ini gets a different picture than they had.
+//-------------------------------------------------------------------------------------------------
+TEST(build_placement_preview_defaults_are_the_ones_the_game_always_used)
+{
+ GlobalData *scratch = NEW GlobalData;
+
+ CHECK_NEAR( scratch->m_buildPlacementOpacity, PLACEMENT_SILHOUETTE_OPACITY, 0.0001f );
+ CHECK( scratch->m_buildPlacementShadows );
+
+ // and the income trickle is off unless somebody asks for it
+ CHECK_EQ( scratch->m_moneyPerMinute, 0 );
+
+ // the right button still scrolls unless somebody turns it off
+ CHECK( scratch->m_rightMouseScroll );
+
+ delete scratch;
+}
+
+//-------------------------------------------------------------------------------------------------
+// A map name with a non-ASCII byte in it reaches isalnum as a negative number, which is undefined
+// and is what the CRT asserted on while building the map cache. Every byte over 127 has to encode,
+// and the round trip has to bring it back.
+//-------------------------------------------------------------------------------------------------
+TEST(quoted_printable_survives_bytes_over_127)
+{
+ // every high byte, one after another - this is what an accented map name looks like
+ char highBytes[ 130 ];
+ Int n = 0;
+ for( Int b = 128; b <= 255; ++b )
+ highBytes[ n++ ] = (char)b;
+ highBytes[ n ] = '\0';
+
+ AsciiString original( highBytes );
+ AsciiString encoded = AsciiStringToQuotedPrintable( original );
+
+ // nothing high survives into the encoded form: it is all MAGIC_CHAR plus two hex digits
+ for( Int i = 0; i < encoded.getLength(); ++i )
+ CHECK( (unsigned char)encoded.getCharAt( i ) < 128 );
+
+ CHECK_EQ( encoded.getLength(), original.getLength() * 3 );
+
+ // and it comes back
+ AsciiString decoded = QuotedPrintableToAsciiString( encoded );
+ CHECK_STR( decoded.str(), original.str() );
+
+ // a plain name is left alone, which is what makes the encoding readable in a cache file
+ CHECK_STR( AsciiStringToQuotedPrintable( AsciiString( "Alpine" ) ).str(), "Alpine" );
+}