Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix: player reports, mod faults and skirmish speed range
Olcay Seygandd96c288b2a8
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4637d7aa9..dd5ba833e 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -11,7 +11,8 @@ found and fixed — EA's own, not port damage.**## The battle runs at 60 steps a second- The game now works out the battle 60 times a second, double the 30 Zero Hour has run at since 2003. Each step is 17 milliseconds where it was 33, so an order you give waits half as long for the step that carries it out, and a unit turning, braking or firing moves in steps half the size.-- The match plays at the speed it always did. Every speed, delay, reload and build time in the game's data was converted to the shorter step, so a Crusader still fires every two seconds and the game speed setting means what it did. The balance is the one you know.+- The match plays at the speed it always did. Every speed, delay, reload and build time in the game's data was converted to the shorter step, so a Crusader still fires every two seconds. The balance is the one you know.+- Normal speed is now the fastest a skirmish or a mission runs. The game speed choice in the skirmish lobby offers x0.5, x0.75 and x1, and x1 is 60 steps a second; the x1.5 and x2 it used to have are gone. A lobby left on one of them, or a saved game made at one, comes back at x1, and the speed console command and a mission's own script stay between half speed and normal as well. Replays still play as fast as you ask, and network games are untouched.- Replays and saved games from earlier versions will not load in this one. A player on an earlier version cannot join a match with a player on this version, whichever of them hosts, so a LAN party needs everyone on the same build.## Zero Hour on a Mac, on Linux and on the Steam Deck@@ -33,10 +34,11 @@ found and fixed — EA's own, not port damage.**- Reforged stays on top of every mod. This build's balance, its fixes to EA's data, its AI and its menus load after the mod and win where they touch the same unit, weapon or button, so a mod plays with Reforged's rules. A change that names something the mod renamed or removed is passed over instead of stopping the game, which is how ShockWave starts and plays. A mod's own copy of a file Reforged ships, the skirmish setup screen among them, is ignored, and so are any upscaled art archives it carries. The one exception is the skirmish AI's scripts: a mod's are written for its own generals, so they replace Reforged's, and Reforged's smarter AI plays them.- A `mod.json` in the folder names the mod and its version. The names stand beside the version number in the options menu, in the order the mods were given, and go into every replay you record, so a replay made with mods says which ones, and the replay list marks it as another version when the game is running without them.- Joining a LAN game that runs different mods used to end in a box about a mismatch and nothing else. It names the host's mods now, or tells you the host plays without any.-- Two total conversions in one match. Add `-modfactions` to the mods you give, and each mod's armies join Zero Hour's own instead of replacing them: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. The End of Days' Russian command center, its Tor-M1 and some sixty other models used to come out bright pink; they wear the mod's own paint now. Playing a mod's faction, your buttons, build pictures, unit names and tooltips are that mod's, set in our command bar for that general's country: a mod's Chinese general gets the Chinese bar, a GLA one the GLA bar, and a nation Zero Hour never had, Russia among them, the American one. Every mod general used to get the American bar. The End of Days' Russia is in the list under its own name. Each mod general's promotion screen holds that mod's own powers, with the mod's pictures, and they unlock with your rank. They sit together with no holes between them, and each power's upgrades stand in the column under it, Paradrop 1 over 2 over 3, the way Zero Hour lays out its own. A mod's faction climbs that mod's own ranks: The End of Days' eight, with its own experience steps and points, where Zero Hour's five used to apply to everyone. ShockWave's and The End of Days' screens used to open empty, because a rank granted only Zero Hour's own rank marks and the mod's powers asked for the mod's. Menus, lobby and colours stay ours whatever mods you load. The skirmish AI lays out a mod's base from the mod's own buildings, but it still trains the army it knows from Zero Hour.+- Two total conversions in one match. Add `-modfactions` to the mods you give, and each mod's armies join Zero Hour's own instead of replacing them: the faction list reads "ShockWave - USA" and "The End of Days - USA" under plain "USA", and a ShockWave army can fight an End of Days one. Each side builds from its own mod's units, weapons, upgrades and generals' powers, and each looks and sounds like its own mod: a ShockWave tank wears ShockWave's model and textures even where The End of Days replaces the same file, and speaks with ShockWave's voice. The End of Days' Russian command center, its Tor-M1 and some sixty other models used to come out bright pink; they wear the mod's own paint now. Playing a mod's faction, your buttons, build pictures, unit names and tooltips are that mod's, set in our command bar for that general's country: a mod's Chinese general gets the Chinese bar, a GLA one the GLA bar, and a nation Zero Hour never had, Russia among them, the American one. Every mod general used to get the American bar. The End of Days' Russia is in the list under its own name. Each mod general's promotion screen holds that mod's own powers, with the mod's pictures, and they unlock with your rank. They sit together with no holes between them, and each power's upgrades stand in the column under it, Paradrop 1 over 2 over 3, the way Zero Hour lays out its own. A mod's faction climbs that mod's own ranks: The End of Days' eight, with its own experience steps and points, where Zero Hour's five used to apply to everyone. ShockWave's and The End of Days' screens used to open empty, because a rank granted only Zero Hour's own rank marks and the mod's powers asked for the mod's. Menus, lobby and colours stay ours whatever mods you load. A computer player on a mod's faction plays that mod's own skirmish AI: the mod's base layout, base defences, harvester counts, generals' powers and the teams its scripts train, run by Reforged's AI. It used to lay out the base from the mod's buildings and then train the army it knew from Zero Hour, and a nation Zero Hour never had did nothing at all. A mod that ships no skirmish AI of its own still gets Zero Hour's, read with the mod's buildings.- A patch for a mod stays with that mod. Give it with `-modpatch` right after the mod it changes, and its files replace that mod's one for one, even beside a second total conversion: a ShockWave balance patch reaches ShockWave's armies and leaves The End of Days alone. Given first, a patch changes Zero Hour's own files. The launcher's MODS page marks each mod a patch or a full mod, and a `mod.json` can say `"patch": true`. With two full mods switched on the launcher now plays them side by side; before, ShockWave and The End of Days together stopped the game at startup.- Contra and The Power of the West start and play now, The Power of the West beside ShockWave too; every one of those used to crash while loading. Contra's China base fell over the carpet bombers it never had, and one misspelt armour line in The Power of the West stopped the game where Zero Hour itself had shrugged it off. A mod's patch archive named to sort first, like Contra's `!!` one, wins over the rest of the mod again, as it always did in Zero Hour.- No empty slots in a mod general's power tray. Mods give unrelated powers the same few types, Contra's small Scud Storm counting as a carpet bomb, so a Contra Cybernetic player's tray picked up another faction's button for a power he only held one of the same type as, then hid it, and an empty frame stood where it had been. The tray offers a button now only for the very power you hold, and a slot whose button goes away takes its frame with it.+- A Paladin under Contra no longer crashes the game. Reforged gives every Paladin a second laser for infantry, and that laser borrowed a Zero Hour weapon nothing else fires. Contra deleted it, so the laser had no gun, and the game went down a moment after the first Paladin rolled out. The laser is Reforged's own weapon now and is there whatever mod you load. The same kind of gap took the guns off Contra's Toxin Tunnel Defender and Toxin Stinger soldier, the Chemical Suits off its Rangers, and the death blast off its Demolition Scud Launcher, Toxin demo trap and Toxin Tractors (ShockWave's trap too). Where Reforged names a weapon or armour the mod dropped, the unit now keeps the mod's own, and the death blasts carry Zero Hour's charge.- Contra's units have their attack move, guard and stop buttons again, and A, G and S press them. Contra draws its command bar with eighteen buttons and keeps those three in the last row, which our fourteen-button bar does not have, so they went missing on every Contra unit, the Cybernetic general's cyborgs among them. A button a mod puts past the end of our bar now moves to an empty one, the three orders to the places Zero Hour gives them.- Contra's cyborgs no longer stand on black squares. Their little ground shadow is drawn the way Zero Hour draws it again, darkening the ground by the shape painted in the picture, so it comes out as a soft patch under the feet. We had been reading the shape from the picture's transparency instead, and Contra's shadow picture has none: it filled its whole square. Zero Hour's own shadows look as they did.@@ -242,6 +244,7 @@ found and fixed — EA's own, not port damage.**- The USA computer stops flooding the field with Ambulances. Each lost one used to be bought again every minute and a half, and two USA computers put eight on the road in one sixteen-minute match. Hard now buys six in a whole match at most and Medium three, and Medium keeps only one at a time and waits three minutes to replace it. An Ambulance under fire backs out of reach before it heads for the War Factory to be repaired: sent straight there, it took the shortest road, often through the guns that had hurt it, and 20 of 31 lost Ambulances died on that drive. It no longer drives ahead of the army to wash a toxin pool, which is where three of the four lost in one Hard match died. The wounded men who never came back out are accounted for too. Of 23 called in over six test matches, 17 died within three seconds of the call, still in the fight that hurt them, and the other six all reached an Ambulance and walked out whole. Replays recorded before this change play out differently.- The USA computer stops calling its wounded out of a firefight. A soldier still being shot at stays put, and one who has had two seconds' peace walks over from up to twice as far as before, since the hurt men who live through a fight end up well behind the Ambulance's old reach. In six Hard and six Medium matches between two USA computers on Twilight Flame, 14 were called in and none died within three seconds of the call, where 17 of 23 had; six were healed and walked out whole, three died on the walk four to nine seconds later, and four gave up the walk. Two of those four were the computer's own doing: ten seconds into the walk its fight logic saw a hurt soldier and pulled him back towards home, or sent him back to his squad, or its retreat order took him home with the squad he had left. A soldier walking to an Ambulance now gets no other order until he is inside. The same six matches now lose two on the walk where they lost four; those two stood still at the door of an Ambulance they could not reach and gave up, which is still open. Replays recorded before this change play out differently.- The computer's Ambulance only cleans the spills it is sent to. Parked behind the army, it used to notice a toxin pool by itself up to 300 ahead and drive into the fight to wash it, past the line the computer keeps it behind. Over twelve Hard against Medium matches between the USA and GLA on Twilight Flame, 7 of 25 lost Ambulances had died within half a minute of a cleanup they started on their own, 650 to 1,350 from home. With the same matches played again, none started one by itself, and 21 were lost. Replays recorded before this change play out differently.+- Its Ambulances keep a distance from your guns that fits the map. They used to wait just outside the reach of the guns they knew about and back off only once inside one, so a tank rolling forward a second had them in range before they looked again. Now they back off before that: on a big map up to 200 clear on Hard and 160 on Medium, on a small one less, since there the computer's own base can stand that close to your guns. They only ever back off to ground clearer than where they stand; with none to go to they hold still instead of driving back and forth between the army and home. After a hit they stay back 8 seconds on Hard and 6 on Medium, not 4. Not measured yet. Replays recorded before this change play out differently.- It comes at you from two sides. An attack big enough to be two sends a third of its strength down the second-quietest road, so you cannot meet the whole thing in one place.- It holds ground between attacks. Hard gathers its next wave a third of the way along the road to you, not in front of its own base, as long as nothing it has seen can shoot at that spot; otherwise it gathers at home.- It builds its economy before it comes for you. No attack leaves a computer base in the opening minutes: six on Easy, five on Medium, four on Hard, and on Medium and Hard not before its first supply drop zone or black market stands, when it can build one. Medium and Easy now put that drop zone or black market up in the opening too, where only Hard did before. And it stops sending you two tanks at a time. A group too small to matter waits at home until enough has gathered to be an attack, about two tanks' worth on Easy, two and a half on Medium and five on Hard, even when the computer thinks it is winning. In one Hard against Hard match on Twilight Flame, the USA side's first attack left at six minutes instead of three and a quarter, after its drop zone, and the two sides sent 24 attacks instead of 47, 12 of them one to four units where 43 had been. Medium sent 9 instead of 19. Replays recorded before this change play out differently.@@ -360,7 +363,7 @@ found and fixed — EA's own, not port damage.**- Campaign reinforcements flown in by Chinook land again. That one-at-a-time unloading sent a mission's scripted Chinooks home with their cargo still aboard, so on the second American mission the dozers announced at the docks never got off, and neither did the next one.- A guarding unit no longer fights itself between returning to post and shooting back.- Every unit of yours on guard carries a small steel shield over its head, selected or not, in place of the blocky "G" it used to wear. The shield has smooth edges and a lit and a shaded half, and it shrinks as you zoom out the way the health bars do: at 1080p it was 24 pixels tall over every unit at every zoom, and it is now 18 up close and 11 from the opening camera, about the height of an infantryman's head.-- An Ambulance cleans up the toxins around it without being told. Its hose reaches 100, and that was all it ever looked at, so one parked a truck's length from a toxin pool sat and watched it. Standing idle or on guard, it now notices a pool, an anthrax cloud or a radiation field up to 300 away, drives over, washes off every one in that circle, and goes back to where it stood; one that was on guard is back on guard. A unit you are moving is never pulled off its order, and any order you give while it is cleaning ends the cleanup. Put down 150 to 250 from two Ambulances, one idle and one guarding, three poison fields were gone inside 16 seconds, both trucks were back on their spots, and a third Ambulance driving past a fourth field went straight on to where it was sent. The Cleanup Area button works better for it too: an Ambulance sent to clean an area used to shoot only at what was already in reach once it got there and stood still in front of the rest, and once the area was clean it never counted as idle again, so it ignored the next spill. An Ambulance guarding a tank goes back to guarding the tank after a cleanup, not the patch of ground it left from, so it follows the tank again: with the tank driven 600 away after the cleanup, the Ambulance reached it 17 seconds later. One that gives up on a spill it cannot drive up to no longer goes back for the same spill every time it stands idle; telling it to clean the area yourself still sends it. Replays recorded before this change play out differently.+- An Ambulance cleans up the toxins around it without being told. Its hose reaches 100, and that was all it ever looked at, so one parked a truck's length from a toxin pool sat and watched it. Standing idle or on guard, it now notices a pool, an anthrax cloud or a radiation field up to 300 away, drives over, washes off every one in that circle, and goes back to where it stood; one that was on guard is back on guard. A unit you are moving is never pulled off its order, and any order you give while it is cleaning ends the cleanup. Put down 150 to 250 from two Ambulances, one idle and one guarding, three poison fields were gone inside 16 seconds, both trucks were back on their spots, and a third Ambulance driving past a fourth field went straight on to where it was sent. The Cleanup Area button works better for it too: an Ambulance sent to clean an area used to shoot only at what was already in reach once it got there and stood still in front of the rest, and once the area was clean it never counted as idle again, so it ignored the next spill. An Ambulance guarding a tank goes back to guarding the tank after a cleanup, not the patch of ground it left from, so it follows the tank again: with the tank driven 600 away after the cleanup, the Ambulance reached it 17 seconds later. One that gives up on a spill it cannot drive up to no longer goes back for the same spill every time it stands idle; telling it to clean the area yourself still sends it. Giving up never actually happened, though: it counted only the looks that found it standing still, and it ordered the drive again every time it stopped, so a look nearly always caught it moving. It now gives up after eight looks in a row that find it parked no nearer the spill, and leaves the whole patch round it alone, since a toxin field is many spills and the next one in the same field drew it straight back. One still driving, round a river say, is left to get there. The computer's Ambulances keep to that too, and one the computer pulls off a cleanup under fire leaves that patch alone afterwards instead of being sent straight back to it. Replays recorded before this change play out differently.- Jets on guard attack what is inside the circle you drew. A plane on guard flies to its post and circles it, and since guards stopped shooting at enemies hidden in fog it only went after what that loop brought into its own sight: a Raptor guarding a circle of 700 hung over the post for the whole 80 seconds of the test with a power plant 550 out, and an Aurora circled for ten seconds before it found the same one. Aircraft are back on the original rule and take anything in the circle, fog or not. The Raptor's first missiles now land 11 seconds after the order and the Aurora's bomb after 9, and neither flies over the post first. Ground units still leave alone what they cannot see. A replay recorded before this change plays back differently.- H now sets a stance for the group. Defensive is how your units have always behaved: they fire on what comes into range and stay put. Aggressive lets them go after anything they can see, the way the computer's own units do, so a group left on aggressive clears the ground around it without being told. The button shows the stance the selection holds.- A queued attack move finishes its fights before the next order on the list goes out. The first enemy it met used to count as arriving, so a list of attack moves round a town skipped ahead a step at every skirmish and the group was off to the last point while the first was still contested. Replays recorded before this version play back differently.@@ -584,6 +587,8 @@ found and fixed — EA's own, not port damage.**## Weapons and units that were quietly wrong+- The Aurora's bomb goes off like the strike it is. It hits for 400 where a Scud Launcher's missile hits for 300, and buildings take one and a half to three times that, yet it blew up with one carpet bomb's puff, smaller than the missile's. The blast is now two to two and a half times the Scud's across: arms of fire flung twice as far, four big napalm fireballs, a shock ring 210 wide where the carpet bomb's stops near 90, a rolling dust ring, fourteen clods of dirt and a column of smoke, with a hard shake, a wide scorch and a bend in the picture on Direct3D 11. It is over in about two seconds. Its damage is unchanged. This is the Aurora of every American general; the Alpha Aurora keeps its fuel-air blast.+- The Dragon Tank's Fire Wall burns where you put it again. An earlier change in this build handed each patch of the wall the full speed of the flame that lit it, so the fire slid off across the map: in one test the patches came to rest anywhere from 155 to 1,050 away from the tank, 800 on average, setting fire to whatever stood in the way. They now stop 120 to 180 from the tank, a little past where the flames land, as they did in the original game. Napalm bombs and the wrecks of shot-down planes and drones keep their original drift too. Replays recorded before this change play out differently.- A bunker buster shot down on the way in no longer clears out the building it was aimed at. It emptied the bunker from wherever it happened to be destroyed - a Point Defence Laser did not save you, it just moved the explosion.- A Battle Bus in its wrecked form takes attack orders again. Every order you gave it was dropped on the way, because the crew inside are 'held' and held units were skipped.@@ -603,6 +608,7 @@ found and fixed — EA's own, not port damage.**- A unit lifts the fog only half as far again as its guns reach: enough to spot what it is about to fight, not enough to scout. A rifleman used to see well past the range of his rifle, so any cheap soldier was a scout. Artillery that outshoots its own eyes still needs a spotter, and units with no weapon at all, like bulldozers and supply trucks, keep the sight they had. Buildings are unchanged.- Workers and bulldozers can see again. Each one carries a mine-clearing tool a few feet long, and the rule above took it for a gun, so a builder saw no further than the end of its own blade and walked into the fog blind. They keep their full sight now, armed or not.- Hills and buildings block sight. A tank at the foot of a ridge used to see straight through it to the far side, and a squad in a city saw through every block around it. Now the fog stays on whatever a ridge, a building or a tree hides, yours, the enemy's or a civilian's, and a unit on high ground looks down over everything below it. Aircraft fly above it all and see past. Soldiers garrisoned in a building still see out of it; its own walls do not blind them.+- A Comanche can no longer hide behind a hill or over a building and shoot your army to pieces. The hill hid the ground behind it, and the helicopter hovering over that ground went into the fog with it, while from up there it saw your tanks and fired down on them; your Gattling tanks and Stingers could neither see it nor shoot back. A ridge or a roof now hides only the ground. Anything flying within a unit's sight is seen and can be shot at, whatever stands between them, the same in skirmish and online. Not yet measured in a staged fight. Replays recorded before this change play out differently.- A bridge is ground you can see, not a wall. Sight judged a bridge by the valley floor under it, so a bridge over a gorge sat hidden behind the gorge's own edge and a tank on the bank could not see the deck it was about to cross. A standing deck counts at its own height now; a bridge knocked down to rubble goes back to the ground beneath it.- The spy satellite, the radar van scan and the spy drone see everything in their circle again. They were blocked by hills and buildings like a tank on the ground, so a scan dropped on an enemy base came back with holes behind every building in it.- High ground pays. A tank on a ridge now shoots, sees and picks its targets further down the slope than it could on the flat: three steps of range for every step of height over its target, up to twice its usual reach. Firing uphill costs nothing, and aircraft get no bonus from flying. Defences count too, and the range ring you see while placing one bends outward wherever the ground falls away, so you can site a Gattling Cannon on a hill and see exactly what it covers.@@ -765,6 +771,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- Click a unit with several factories selected and it takes the shortest queue.- A plane stays buildable while any selected airfield still has a free spot. One full airfield used to grey the button out for the whole group, even with three empty runways in the same selection.- A general's upgrade spreads across the selected buildings instead of hitting one.+- A building still going up or being sold takes no upgrades. Select a finished Cold Fusion Reactor together with ones still under construction and the control rods were bought for all of them, and researched before the walls were up. The bar now offers upgrades only to finished buildings, and the game refuses the order for an unfinished one whoever sends it. Replays that did this play back differently.- A clicked upgrade darkens immediately and uncovers as it progresses.- The production strip dims fresh orders the same way.- A second worker can take over a half-built building.@@ -1007,6 +1014,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- Burning trees, a crashing helicopter, a nuclear silo's open doors and a Hacker or Black Lotus at work make their sound again after you load a save.- Loading a save keeps a Search and Destroy sight bonus, a pending order's origin, a script's next check and a dock's approach path, all of which came back wrong. Older saves still load.- A garrison entered while the map's playable edge was still closed can no longer be cleared by any blast that lands on the building.+- Fallen Empire's great wall takes no garrison again. Its towers have room for ten soldiers, but the map makes the wall indestructible and switches it off for clicking, so in Zero Hour nobody could ever send a man in. The computer's habit of filling map buildings near a fight found them anyway, and its soldiers sat in a wall nothing could damage, out of reach of everything but a flash-bang or a toxin or flame shot. A building the map has switched off for clicking now refuses a garrison from you and from the computer; a mission's own script can still put men in one, as it always could. Replays recorded before this change play out differently.- Burning infantry run in every direction, not always north-east.- A player name long enough to fill the LAN game room no longer hangs the lobby, changing settings there no longer crashes it, and the list of LAN games keeps its place instead of jumping back to the top every time it refreshes.- Holding Ctrl while the beacon text box was open no longer leaves force-attack armed after you let go.@@ -1188,6 +1196,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same## The options screen has pages- On Windows every setting lives in the launcher now, where you set it before the game starts. Options is back in its old place on the main menu, between Load and Credits, and it opens the same page Esc and then Options opens in a match: the sound, music, effects, voices and ambience, nothing else. Accept there saves those four and leaves the rest of your settings file alone, so the resolution or detail preset you picked in the launcher stays exactly as you left it. On a Mac and on Linux, which have no launcher, the options screen is the whole of what follows.+- Cloud shadows have a switch of their own in the launcher, at any detail preset. They used to follow the preset alone: Low took them away, and every other preset kept them on with no way to say no. The preset leaves them alone now, so they stay on until you turn them off, and the change shows the moment the game starts on either renderer.- Display, graphics, effects, audio, controls, interface and network, behind seven buttons across the top. The original screen was one panel with everything on it at once, and it was already full the day it shipped: the language filter, the keyboard button and four camera checkboxes are all still in there, parked off the right edge where nobody can reach them, because there was nowhere left to put them.- Every setting sits with the ones that do the same kind of job. Display is the screen and its brightness. Graphics is what the picture costs and how sharp it is, with the glow and the lighting in a group of their own instead of mixed in with the anti-aliasing. Effects is what stands in the world: all seven shadow boxes together, cloud shadows included, then the scenery, then smoke. Controls splits the camera, the orders, building placement and the mouse into four groups, and Interface holds the command bar size, the income readout, the health bars, the colours, the order lines and the language. In Classic the screen leaves out the few boxes Classic ignores anyway, from smooth motion to the HUD size and the order lines, and closes the gaps they leave, so a box on that screen always does something.- Classic Graphics, on the Graphics page, puts the game back the way it looked in 2003 in one click: its own textures and ground in place of the upscaled ones, the old hard shadows, the round dark patch under every tree where Reforged lays the tree's own outline on the ground, and no glow or sharpening over the picture. Leave it off and you have Reforged. The rest of the options stay yours either way, and the box takes effect the next time the game starts.@@ -1362,6 +1371,12 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the samelies well outside it, so buildings, trees and tanks up there stood on bright ground with nothingunder them. The square now opens to whatever the camera sees, up to two and a half times as wide.At a map's normal playing height nothing changes.+- Shadow edges hold still while you scroll. The sun's view was meant to move across the map a whole+ shadow pixel at a time, and the rounding that did it measured the camera from itself, so it always+ came out at zero and every scroll slid the shadows' grain under the world: edges crawled and+ sparkled. And on a map with a low sun, the far end of a zoomed-out view lay past the depth the+ sun's view covers, so the ground up there lost its shadows and buildings nearest the sun dropped+ out of the map. The depth now grows with the view.- A shadow stays on the ground when the thing casting it is just off the edge of the screen. A treestanding past the edge was dropped along with its shadow, so scrolling made shadows on the groundin view go out all at once; on Tournament Desert about eleven trees at a time were missing thatdiff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 11f9d5167..ff2152cc2 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -29,6 +29,7 @@ Data/Art/Textures/ReforgedMineLedRed.tgaData/Art/Textures/ReforgedSignalAttack.tgaData/Art/Textures/ReforgedSignalDefend.tgaData/Art/Textures/ReforgedSignalLook.tga+Data/Cinema/aurorablast.txtData/Cinema/aurorafog.txtData/Cinema/blastcheck.txtData/Cinema/demo.txt@@ -109,6 +110,9 @@ Data/Cinema/s240_snow.txtData/Cinema/s240_tank.txtData/Cinema/s240_town.txtData/Cinema/scudlaunch_film.txt+Data/Cinema/shadowfar.txt+Data/Cinema/shadowpan.txt+Data/Cinema/spectre_reshoot.txtData/Cinema/swpair_nuke.txtData/Cinema/swpair_scud.txtData/Cinema/thumb_chaos_a.txt@@ -152,6 +156,7 @@ Data/INI/ParticleSystemReforged.iniData/INI/ScienceReforged.iniData/INI/SpecialPowerReforged.iniData/INI/UpgradeReforged.ini+Data/INI/WeaponReforged.iniData/Install_Final.bmpData/Patch.strData/Scenarios/airbelow.txt@@ -159,6 +164,7 @@ Data/Scenarios/airbelowfar.txtData/Scenarios/alphaaurora.txtData/Scenarios/ambulanceclean.txtData/Scenarios/ambulanceguard.txt+Data/Scenarios/aurorablast.txtData/Scenarios/aurorafog.txtData/Scenarios/avengerlasers.txtData/Scenarios/beambase.txt@@ -168,6 +174,7 @@ Data/Scenarios/bridgecross.txtData/Scenarios/bridgelong.txtData/Scenarios/broadcastend.txtData/Scenarios/chokeprobe.txt+Data/Scenarios/comanchehill.txtData/Scenarios/comanchepods.txtData/Scenarios/comturret.txtData/Scenarios/crowdbattle.txt@@ -279,6 +286,7 @@ Data/Scenarios/shellpaths.txtData/Scenarios/shiftorders.txtData/Scenarios/shiftqueue.txtData/Scenarios/spectre_reaim.txt+Data/Scenarios/spectre_reshoot.txtData/Scenarios/squad30.txtData/Scenarios/stance.txtData/Scenarios/standinbuild.txt@@ -312,6 +320,7 @@ Data/Scenarios/vehicleaccel.txtData/Scenarios/vehiclelean.txtData/Scenarios/vehicleturn.txtData/Scenarios/vision.txt+Data/Scenarios/wallgarrison.txtData/Scenarios/wreckcheck.txtData/Scripts/SkirmishScripts.scbData/Turkish/Generals.strdiff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txtindex ad6bb746e..81b59255d 100644--- a/GeneralsMD/Code/CMakeLists.txt+++ b/GeneralsMD/Code/CMakeLists.txt@@ -2301,11 +2301,13 @@ set_tests_properties(test_gameengine PROPERTIES TIMEOUT 2700)# simulation_uses_no_runtime_trig reads the engine's own sources back off disk to prove nothing in# GameLogic or Common has gone back to calling sinf().# fxlist_reforged_ini_parses_and_keeps_its_light runs the fork's own FXList file through the real-# INI parser, so it needs the tracked master rather than whatever sits in Run/.+# INI parser, so it needs the tracked master rather than whatever sits in Run/; the WeaponReforged+# test the same.# the_options_menu_buttons_all_wear_one_font reads the tracked layout master, not Run/'s copy.target_compile_definitions(test_gameengine PRIVATEGAMEENGINE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/GameEngine"FXLIST_REFORGED_INI="${CMAKE_CURRENT_SOURCE_DIR}/Data/INI/FXListReforged.ini"+ WEAPON_REFORGED_INI="${CMAKE_CURRENT_SOURCE_DIR}/Data/INI/WeaponReforged.ini"OPTIONS_MENU_WND="${CMAKE_CURRENT_SOURCE_DIR}/Data/Window/Menus/OptionsMenuClassic.wnd"PLATE_TEXTURE_DIR="${CMAKE_CURRENT_SOURCE_DIR}/Data/Art/Textures")diff --git a/GeneralsMD/Code/Data/Cinema/aurorablast.txt b/GeneralsMD/Code/Data/Cinema/aurorablast.txtnew file mode 100644index 000000000..8c129cf2c--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/aurorablast.txt@@ -0,0 +1,12 @@+# Scenarios/aurorablast.txt: the same zoom, heading and tilt on each of the three blasts, so the+# Aurora's bomb on a vehicle, on a building and the Scud Launcher's missile on a vehicle read at+# one size. Zoom 0.9 logs about 1.23 here.++0 cut 1420 3830 0.9 -45 8+1 cut 1420 3830 0.9 -45 8+6 shot+10 cut 1250 3800 0.9 -45 8+16 shot+20 cut 1510 3690 0.9 -45 8+27 shot+33 enddiff --git a/GeneralsMD/Code/Data/Cinema/shadowfar.txt b/GeneralsMD/Code/Data/Cinema/shadowfar.txtnew file mode 100644index 000000000..a08e03849--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/shadowfar.txt@@ -0,0 +1,16 @@+# Low sun at full zoom-out: the Heartland Shield village under its morning sun at the player's own+# farthest zoom (factor 1 is the StartAtMaxZoom opening, logs 1.34), looking both ways, to see+# whether the shadow map's depth range carries the long shadows to the top of the screen. Plain+# map, nothing spawned. Factor 2.5 (logs 3.3) puts the horizon and black sky in the top half and+# factor 5 draws nothing at all, so neither says anything about the shadows.+#+# generals.exe -win -xres 1280 -yres 720 -msaa 0 -fps 120 -noFPSLimit -quickstart -noshellmap+# -multiInstance -observer -map "Maps\Heartland Shield\Heartland Shield.map" -autoskirmish 2+# -takeover -seed 1 -cinema shadowfar -maxframes 450++0 cut 950 1950 1 0 0+2 cut 950 1950 1 0 0+4 shot+4.5 cut 950 1950 1 180 0+6 shot+6.5 enddiff --git a/GeneralsMD/Code/Data/Cinema/shadowpan.txt b/GeneralsMD/Code/Data/Cinema/shadowpan.txtnew file mode 100644index 000000000..61a5fb914--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/shadowpan.txt@@ -0,0 +1,25 @@+# Shadow map texel snap on a scroll, over Scenarios/shadowbase.txt (a USA base on the open scrub+# of Golden Oasis, no water in frame): held still, then panned slowly sideways, so a shadow edge+# that crawls or flickers while the camera moves shows against the same edge held still. Heading+# 45 has the sun behind the camera and the lit walls facing it. Then a close look at those walls+# for shadow acne and a wide view both ways round (factor 5 logged 5.81 and drew an all-black+# frame on both builds, so the wide view is 1.4; Cinema/shadowfar.txt has the real far test).+# Shoot it with TreeSway = no and UseCloudMap = no in Options.ini, so the held part changes only+# where something animates. Measured 2026-10-14 against generals_new60.exe (before the snap fix).+#+# generals.exe -win -xres 1280 -yres 720 -msaa 0 -fps 120 -noFPSLimit -quickstart -noshellmap+# -multiInstance -observer -map "Maps\Golden Oasis\Golden Oasis.map" -autoskirmish 2 -takeover+# -side 0 FactionAmerica -side 1 FactionChina -seed 1 -scenario shadowbase -cinema shadowpan+# -video 60 1040 shadowpan -maxframes 1100++0 cut 2200 3540 0.8 45 0+1 cut 2200 3540 0.8 45 0+3 shot+4 move 2300 3540 6+11 cut 2250 3540 0.35 45 10+12.5 shot+13 cut 2250 3540 1.4 45 0+14.5 shot+15 cut 2250 3540 1.4 -45 0+16.5 shot+17.5 enddiff --git a/GeneralsMD/Code/Data/Cinema/spectre_reshoot.txt b/GeneralsMD/Code/Data/Cinema/spectre_reshoot.txtnew file mode 100644index 000000000..7b4cd8d6b--- /dev/null+++ b/GeneralsMD/Code/Data/Cinema/spectre_reshoot.txt@@ -0,0 +1,10 @@+# Scenarios/spectre_reshoot.txt: the Spectre's whole circle over the Alpine Assault town, from+# heading 135. Heading -45 (spectre_reaim.txt) put the map edge in the top left of the frame;+# a 2026-10-14 probe at zoom 2.6 or 2.2 found a straight black band across the top at headings 45,+# -135 and 135 alike, thinnest at 135 pitch -16, so this one sits closer and steeper.++0 cut 1300 1290 1.9 135 -20+1 cut 1300 1290 1.9 135 -20+12 shot+18 shot+23 enddiff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.iniindex 0fd260aa1..babfef650 100644--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini@@ -896,10 +896,11 @@ End;; The Paladin's laser also burns down infantry that come within 65. A second laser with its own clip; does that, so a Tank Hunter's missile and the Tank Hunter himself do not share one gun. That needs-; a second weapon and a MULTIFILE file cannot add one. It used to borrow AirF_RaptorPointDefenseLaser,-; which the King Raptor fires again now, so it takes WatchTowerMachineGun, a weapon in EA's-; Weapon.ini that no object names: every field that matters is set here, with the Paladin's beam-; from its LASER bone and no burst.+; a second weapon and a MULTIFILE file cannot add one. It borrowed AirF_RaptorPointDefenseLaser,+; which the King Raptor fires again now, then EA's WatchTowerMachineGun, which Contra's Weapon.ini+; leaves out, so under that mod the module had no weapon and the game crashed. It is+; Reforged_PaladinInfantryLaser in WeaponReforged.ini now, the Paladin's beam from its LASER bone+; and no burst.;; The Paladin's laser had already been slowed to one shot in two seconds, because at EA's one a; second it shot down every Patriot missile: Paladins killed a Patriot four times of four for 0.28@@ -915,23 +916,6 @@ Weapon PaladinPointDefenseLaserProjectileDetonationFX = FX_PointDefenseLaserBurstEnd-Weapon WatchTowerMachineGun ; the Paladin's anti-personnel laser, see above- PrimaryDamage = 100.0- PrimaryDamageRadius = 0.0- AttackRange = 65.0- DamageType = LASER- DeathType = LASERED- WeaponSpeed = 999999.0- DelayBetweenShots = 250- ClipSize = 2- ClipReloadTime = 4000- AcceptableAimDelta = 180- LaserName = PointDefenseLaserBeam- LaserBoneName = LASER- FireFX = WeaponFX_PaladinPointDefenseLaser- VeterancyFireFX = HEROIC WeaponFX_PaladinPointDefenseLaser-End-Weapon AvengerPointDefenseLaserOneDelayBetweenShots = 250 ; EA: 500ClipSize = 4 ; EA: 0@@ -970,7 +954,7 @@ Object AmericaTankPaladinEndAddModuleBehavior = PointDefenseLaserUpdate ModuleTag_07_Infantry- WeaponTemplate = WatchTowerMachineGun+ WeaponTemplate = Reforged_PaladinInfantryLaserPrimaryTargetTypes = INFANTRYScanRate = 500ScanRange = 120.0@@ -991,7 +975,7 @@ Object Boss_TankPaladinEndAddModuleBehavior = PointDefenseLaserUpdate ModuleTag_07_Infantry- WeaponTemplate = WatchTowerMachineGun+ WeaponTemplate = Reforged_PaladinInfantryLaserPrimaryTargetTypes = INFANTRYScanRate = 500ScanRange = 120.0@@ -1012,7 +996,7 @@ Object Lazr_AmericaTankPaladinEndAddModuleBehavior = PointDefenseLaserUpdate ModuleTag_07_Infantry- WeaponTemplate = WatchTowerMachineGun+ WeaponTemplate = Reforged_PaladinInfantryLaserPrimaryTargetTypes = INFANTRYScanRate = 500ScanRange = 120.0@@ -1033,7 +1017,7 @@ Object SupW_AmericaTankPaladinEndAddModuleBehavior = PointDefenseLaserUpdate ModuleTag_07_Infantry- WeaponTemplate = WatchTowerMachineGun+ WeaponTemplate = Reforged_PaladinInfantryLaserPrimaryTargetTypes = INFANTRYScanRate = 500ScanRange = 120.0diff --git a/GeneralsMD/Code/Data/INI/FXListReforged.ini b/GeneralsMD/Code/Data/INI/FXListReforged.iniindex aadd23d55..01d0bc660 100644--- a/GeneralsMD/Code/Data/INI/FXListReforged.ini+++ b/GeneralsMD/Code/Data/INI/FXListReforged.ini@@ -3773,33 +3773,77 @@ ParticleSystemEnd; ----------------------------------------------+; The Aurora's bomb hits for 400, against the Scud Launcher missile's 300, and EA's building+; armours take 150 to 300% of it, yet EA gave it one carpet bomb's fireball, smaller than the+; missile's. The ReforgedAurora* systems in ParticleSystemReforged.ini are EA's carpet bomb, Scud+; Launcher and Artillery Barrage systems grown so the blast reads two to two and a half times the+; Scud's across: fire arms flung twice as far, four big napalm puffs, a 210-wide shock ring, a dust+; ring, fourteen clods and a smoke column, all gone in about two seconds. Only this weapon plays+; it: the plain Aurora of every American general.FXList FX_AuroraBombDetonate+ ; the picture bends as far as a Scud Storm missile's (Direct3D 11 post chain only)+ ScreenDistortion+ Radius = 180+ PullTime = 150+ WaveTime = 1000+ PullStrength = 10%+ WaveStrength = 11%+ WaveWidth = 16%+ EndParticleSystem- Name = CarpetBombExplosion- InitialDelay = 0 0 UNIFORM ;In milliseconds+ Name = ReforgedAuroraNapalmCoreOffset = X:0.0 Y:0.0 Z:0.0EndParticleSystem- Name = CarpetBombWave- InitialDelay = 0 0 UNIFORM ;In milliseconds- Offset = X:0.0 Y:0.0 Z:0.0+ Name = ReforgedAuroraNapalmCore+ Count = 3+ Radius = 15 35 UNIFORM+ Height = 0 0 UNIFORM+ InitialDelay = 0 150 UNIFORMEndParticleSystem- Name = CarpetBombExplosionPuff- InitialDelay = 0 0 UNIFORM ;In milliseconds- Offset = X:0.0 Y:0.0 Z:0.0+ Name = ReforgedAuroraFireArms+ Offset = X:0.0 Y:0.0 Z:2.0EndParticleSystem- Name = ReforgedHotCoreLarge- Offset = X:0.0 Y:0.0 Z:8.0+ Name = ScudMissleLauncherLenzFlare+ Offset = X:0.0 Y:0.0 Z:10.0EndParticleSystem- Name = ReforgedHeatRingLarge+ Name = ScudMissleLauncherExplosionTrailArms+ Offset = X:0.0 Y:0.0 Z:15.0+ End++ ParticleSystem+ Name = ReforgedAuroraColumn+ Offset = X:0.0 Y:0.0 Z:10.0+ End++ ParticleSystem+ Name = ReforgedAuroraDebris+ End++ ParticleSystem+ Name = ReforgedAuroraDust+ End++ ParticleSystem+ Name = ReforgedAuroraShockwave+ Offset = X:0 Y:0 Z:2+ End++ ParticleSystem+ Name = ReforgedHotCoreHuge+ Offset = X:0.0 Y:0.0 Z:12.0+ End++ ParticleSystem+ Name = ReforgedHeatRingHugeOffset = X:0.0 Y:0.0 Z:4.0End@@ -3807,20 +3851,24 @@ FXList FX_AuroraBombDetonateName = ExplosionCarpetBombEnd+ Sound+ Name = ExplosionScudExplosive+ End+ViewShake- Type = STRONG+ Type = SEVEREEndTerrainScorchType = RANDOM- Radius = 45+ Radius = 80EndLightPulseColor = R:255 G:135 B:55- Radius = 160+ Radius = 260IncreaseTime = 0- DecreaseTime = 800+ DecreaseTime = 1200EndEnddiff --git a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.iniindex 555d970a8..e79f1fc21 100644--- a/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini+++ b/GeneralsMD/Code/Data/INI/ParticleSystemReforged.ini@@ -4514,3 +4514,420 @@ ParticleSystem ReforgedTankShellTracerIsEmitAboveGroundOnly = NoIsParticleUpTowardsEmitter = NoEnd++; The Aurora's bomb, FX_AuroraBombDetonate in FXListReforged.ini. It hits for 400 against a Scud+; Launcher missile's 300 and went off smaller than the missile; built from EA's carpet bomb and Scud+; Launcher systems, the blast now reads two to two and a half times the Scud's across and is gone in+; two seconds. Retail 30 Hz units, as every block here.++; EA's ScudMissleLauncherExplosionArms, flung nearly twice as far and with more arms, each dropping+; the fireball below.+ParticleSystem ReforgedAuroraFireArms+ Priority = WEAPON_EXPLOSION+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXFireEmbr.tga+ AngleZ = 0.00 0.00+ AngularRateZ = 0.00 0.00+ AngularDamping = 0.99 0.99+ VelocityDamping = 0.90 0.85+ Gravity = 1.00+ PerParticleAttachedSystem = ReforgedAuroraFireball+ Lifetime = 10.00 10.00+ SystemLifetime = 10+ Size = 1.00 1.00+ StartSizeRate = 0.00 0.00+ SizeRate = 0.00 0.00+ SizeRateDamping = 1.00 1.00+ Alpha1 = 0.00 0.00 0+ Alpha2 = 0.00 0.00 0+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:255 G:128 B:64 0+ Color2 = R:0 G:0 B:0 0+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 10.00 10.00+ BurstCount = 4.00 7.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.00+ VelocityType = ORTHO+ VelOrthoX = -9.00 9.00+ VelOrthoY = -9.00 9.00+ VelOrthoZ = 0.60 3.00+ VolumeType = CYLINDER+ VolCylinderRadius = 0.00+ VolCylinderLength = 0.00+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+End++; EA's ScudMissleLauncherExplosion at about one and a half to two times its grown size, faded by+; 60 frames instead of 100. EA's points at a ScudMissleLauncherSmoke that does not exist; this one+; trails the napalm smoke.+ParticleSystem ReforgedAuroraFireball+ Priority = WEAPON_EXPLOSION+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXexplo03.tga+ AngleZ = -15.00 15.00+ AngularRateZ = -0.02 0.02+ AngularDamping = 1.00 1.00+ VelocityDamping = 0.30 0.40+ Gravity = 0.50+ PerParticleAttachedSystem = NapalmExplosionSmoke+ Lifetime = 60.00 60.00+ SystemLifetime = 10+ Size = 8.00 16.00+ StartSizeRate = 0.00 0.00+ SizeRate = 6.00 10.00+ SizeRateDamping = 0.90 0.85+ Alpha1 = 1.00 1.00 0+ Alpha2 = 0.00 0.00 0+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:0 G:0 B:0 0+ Color2 = R:255 G:128 B:0 10+ Color3 = R:0 G:0 B:0 60+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 0.00 0.00+ BurstCount = 1.00 1.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.10+ VelocityType = SPHERICAL+ VelSpherical = 10.00 20.00+ VolumeType = SPHERE+ VolSphereRadius = 10.00+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = Yes+ IsParticleUpTowardsEmitter = No+End++; EA's CarpetBombExplosion, carrying the bigger napalm puff below.+ParticleSystem ReforgedAuroraNapalmCore+ Priority = CRITICAL+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXFireEmbr.tga+ AngleZ = 0.00 0.00+ AngularRateZ = 0.00 0.00+ AngularDamping = 0.00 0.00+ VelocityDamping = 0.85 0.90+ Gravity = 0.00+ PerParticleAttachedSystem = ReforgedAuroraNapalm+ Lifetime = 15.00 15.00+ SystemLifetime = 1+ Size = 2.00 2.00+ StartSizeRate = 0.00 0.00+ SizeRate = 2.00 2.00+ SizeRateDamping = 1.00 1.00+ Alpha1 = 0.00 0.00 0+ Alpha2 = 0.00 0.00 0+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:255 G:128 B:64 0+ Color2 = R:0 G:0 B:0 0+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 0.00 0.00+ BurstCount = 1.00 1.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.75+ VelocityType = SPHERICAL+ VelSpherical = 0.00 0.00+ VolumeType = SPHERE+ VolSphereRadius = 0.00+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = Yes+ IsParticleUpTowardsEmitter = No+End++; EA's NapalmExplosion starting at 45 to 70 where EA's starts at 20 to 40, thrown wider.+ParticleSystem ReforgedAuroraNapalm+ Priority = WEAPON_EXPLOSION+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXexplo03.tga+ AngleZ = -15.00 15.00+ AngularRateZ = 0.00 0.05+ AngularDamping = 0.99 0.99+ VelocityDamping = 0.30 0.40+ Gravity = 1.00+ PerParticleAttachedSystem = NapalmExplosionSmoke+ Lifetime = 60.00 60.00+ SystemLifetime = 5+ Size = 45.00 70.00+ StartSizeRate = 0.00 0.00+ SizeRate = 0.50 4.00+ SizeRateDamping = 0.98 0.95+ Alpha1 = 1.00 1.00 0+ Alpha2 = 0.00 0.00 0+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:0 G:0 B:0 0+ Color2 = R:254 G:188 B:99 10+ Color3 = R:0 G:0 B:0 60+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = -1.00 -1.00+ BurstDelay = 0.00 0.00+ BurstCount = 1.00 1.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.00+ VelocityType = SPHERICAL+ VelSpherical = 40.00 70.00+ VolumeType = SPHERE+ VolSphereRadius = 12.00+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = Yes+ IsParticleUpTowardsEmitter = No+End++; EA's CarpetBombWave grown to about 210 across, where EA's stops near 90.+ParticleSystem ReforgedAuroraShockwave+ Priority = CRITICAL+ IsOneShot = No+ Shader = ADDITIVE+ Type = PARTICLE+ ParticleName = EXShockWav.tga+ AngleZ = -20.00 20.00+ AngularRateZ = 0.00 0.00+ AngularDamping = 0.00 0.00+ VelocityDamping = 0.20 0.20+ Gravity = 0.00+ Lifetime = 20.00 20.00+ SystemLifetime = 1+ Size = 1.00 1.00+ StartSizeRate = 0.00 0.00+ SizeRate = 12.00 16.00+ SizeRateDamping = 0.97 0.97+ Alpha1 = 0.00 0.00 0+ Alpha2 = 0.00 0.00 0+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:0 G:0 B:0 0+ Color2 = R:255 G:255 B:255 2+ Color3 = R:0 G:0 B:0 20+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 1.00 1.00+ BurstCount = 2.00 2.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.40+ VelocityType = OUTWARD+ VelOutward = 0.00 0.00+ VelOutwardOther = 0.00 0.00+ VolumeType = CYLINDER+ VolCylinderRadius = 0.00+ VolCylinderLength = 0.00+ IsHollow = No+ IsGroundAligned = Yes+ IsEmitAboveGroundOnly = Yes+ IsParticleUpTowardsEmitter = No+End++; EA's ArtilleryBarrageDebris: fourteen clods where EA throws five, bigger and thrown higher.+ParticleSystem ReforgedAuroraDebris+ Priority = CRITICAL+ IsOneShot = No+ Shader = ALPHA+ Type = PARTICLE+ ParticleName = EXDrtExp01.tga+ AngleZ = -15.00 15.00+ AngularRateZ = 0.00 0.05+ AngularDamping = 0.99 0.99+ VelocityDamping = 1.00 1.00+ Gravity = -0.15+ Lifetime = 50.00 50.00+ SystemLifetime = 1+ Size = 16.00 16.00+ StartSizeRate = 0.00 0.00+ SizeRate = 0.70 3.00+ SizeRateDamping = 0.98 0.95+ Alpha1 = 1.00 1.00 0+ Alpha2 = 0.00 0.00 50+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:249 G:220 B:132 0+ Color2 = R:0 G:0 B:0 0+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 0.00 0.00+ BurstCount = 14.00 14.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.00+ VelocityType = CYLINDRICAL+ VelCylindricalRadial = 0.50 2.20+ VelCylindricalNormal = 1.50 3.20+ VolumeType = CYLINDER+ VolCylinderRadius = 4.00+ VolCylinderLength = 2.50+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+End++; EA's CarpetBombExplosionPuff as a wider, quicker dust ring: forty puffs where EA has thirty,+; rolling out about twice as far and gone in two seconds instead of three.+ParticleSystem ReforgedAuroraDust+ Priority = CRITICAL+ IsOneShot = No+ Shader = ALPHA+ Type = PARTICLE+ ParticleName = EXSmokePuf07.tga+ AngleZ = 0.00 7.00+ AngularRateZ = -0.01 0.01+ AngularDamping = 1.00 1.00+ VelocityDamping = 0.70 0.70+ Gravity = 0.00+ Lifetime = 60.00 60.00+ SystemLifetime = 200+ Size = 20.00 20.00+ StartSizeRate = 1.00 1.00+ SizeRate = 9.00 9.00+ SizeRateDamping = 0.60 0.60+ Alpha1 = 0.50 0.50 0+ Alpha2 = -2.00 0.00 60+ Alpha3 = 0.00 0.00 0+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:230 G:186 B:128 0+ Color2 = R:0 G:0 B:0 0+ Color3 = R:0 G:0 B:0 0+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = 0.00 0.00+ BurstDelay = 99999.00 99999.00+ BurstCount = 40.00 40.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.04 Y:0.08 Z:0.00+ VelocityType = OUTWARD+ VelOutward = 13.00 13.00+ VelOutwardOther = 0.00 0.00+ VolumeType = CYLINDER+ VolCylinderRadius = 8.00+ VolCylinderLength = 0.00+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = Yes+ IsParticleUpTowardsEmitter = No+End++; EA's NapalmExplosionSmoke turned into a column: eighteen puffs rising about a hundred units over+; the blast, lit orange at the bottom and grey by the time they fade at two seconds.+ParticleSystem ReforgedAuroraColumn+ Priority = WEAPON_EXPLOSION+ IsOneShot = No+ Shader = ALPHA+ Type = PARTICLE+ ParticleName = EXSmokNew1.tga+ AngleZ = -0.50 0.50+ AngularRateZ = -0.02 0.02+ AngularDamping = 0.90 0.95+ VelocityDamping = 0.97 0.98+ Gravity = 0.00+ Lifetime = 60.00 60.00+ SystemLifetime = 18+ Size = 18.00 26.00+ StartSizeRate = 0.00 0.00+ SizeRate = 1.20 2.00+ SizeRateDamping = 0.98 0.95+ Alpha1 = 0.00 0.00 0+ Alpha2 = 0.75 0.75 20+ Alpha3 = 0.00 0.00 60+ Alpha4 = 0.00 0.00 0+ Alpha5 = 0.00 0.00 0+ Alpha6 = 0.00 0.00 0+ Alpha7 = 0.00 0.00 0+ Alpha8 = 0.00 0.00 0+ Color1 = R:0 G:0 B:0 0+ Color2 = R:255 G:128 B:0 10+ Color3 = R:160 G:150 B:140 60+ Color4 = R:0 G:0 B:0 0+ Color5 = R:0 G:0 B:0 0+ Color6 = R:0 G:0 B:0 0+ Color7 = R:0 G:0 B:0 0+ Color8 = R:0 G:0 B:0 0+ ColorScale = -1.00 -1.00+ BurstDelay = 2.00 2.00+ BurstCount = 2.00 2.00+ InitialDelay = 0.00 0.00+ DriftVelocity = X:0.00 Y:0.00 Z:0.00+ VelocityType = ORTHO+ VelOrthoX = -0.40 0.40+ VelOrthoY = -0.40 0.40+ VelOrthoZ = 2.20 3.20+ VolumeType = SPHERE+ VolSphereRadius = 3.00+ IsHollow = No+ IsGroundAligned = No+ IsEmitAboveGroundOnly = No+ IsParticleUpTowardsEmitter = No+Enddiff --git a/GeneralsMD/Code/Data/INI/WeaponReforged.ini b/GeneralsMD/Code/Data/INI/WeaponReforged.ininew file mode 100644index 000000000..6f597c9b8--- /dev/null+++ b/GeneralsMD/Code/Data/INI/WeaponReforged.ini@@ -0,0 +1,152 @@+; Zero Hour Reforged's own weapons, loaded right after Weapon.ini and before any object names one.+;+; BalanceReforged.ini and FixesReforged.ini edit weapons in place and cannot add one: a block for a+; name nobody defined is read and dropped. A weapon they hand to an object therefore has to exist+; whatever Weapon.ini a mod brings, and this file makes sure it does. A block for a name the loaded+; data already has is read and dropped, so the data's own definition always stands.+;+; This file lands in the multiplayer INI checksum.++; The Paladin's anti-personnel laser, the second PointDefenseLaserUpdate that BalanceReforged.ini+; gives every Paladin. It borrowed EA's WatchTowerMachineGun, which nothing else fires, and Contra's+; Weapon.ini leaves that one out: the module got no weapon and the Paladin crashed the game at the+; first infantry in reach. These are EA's fields with BalanceReforged's changes on them.+Weapon Reforged_PaladinInfantryLaser+ PrimaryDamage = 100.0+ PrimaryDamageRadius = 0.0+ AttackRange = 65.0+ DamageType = LASER+ DeathType = LASERED+ WeaponSpeed = 999999.0+ ProjectileObject = NONE+ RadiusDamageAffects = ALLIES ENEMIES NEUTRALS+ DelayBetweenShots = 250+ ClipSize = 2+ ClipReloadTime = 4000+ AcceptableAimDelta = 180+ LaserName = PointDefenseLaserBeam+ LaserBoneName = LASER+ FireFX = WeaponFX_PaladinPointDefenseLaser+ VeterancyFireFX = HEROIC WeaponFX_PaladinPointDefenseLaser+End++; ---- EA's own, for a mod that dropped them ---------------------------------------------------------+;+; FixesReforged.ini replaces death modules on the GLA's Demolition and Toxin vehicles and traps with+; ones that fire these. Contra keeps every one of those objects and drops all six weapons from its+; Weapon.ini (ShockWave drops the two trap charges), so the replaced modules fired nothing: no Gamma+; puddle from a Toxin Tractor, no blast from a Demolition Scud Launcher or a Toxin demo trap. Under+; retail Zero Hour, ShockWave and The End of Days each block below is dropped unread, since the+; weapon is already defined. The fields are EA's, copied from Weapon.ini of Zero Hour 1.04.++Weapon Demo_DestroyedWeapon+ PrimaryDamage = 50.0+ PrimaryDamageRadius = 60.0+ SecondaryDamage = 10.0+ SecondaryDamageRadius = 70.0+ AttackRange = 5.0+ DamageType = EXPLOSION+ DeathType = NORMAL+ WeaponSpeed = 99999.0+ ProjectileObject = NONE+ DamageDealtAtSelfPosition = Yes+ RadiusDamageAffects = SELF SUICIDE ENEMIES NEUTRALS NOT_SIMILAR+ DelayBetweenShots = 0+ ClipSize = 1+ ClipReloadTime = 0+ AutoReloadsClip = No+ FireFX = WeaponFX_DemoSuicideDynamitePackDetonationPlusFire+ FireSound = CarBomberDie+End++Weapon Demo_TerroristOnCombatBikeSuicideDynamitePack+ PrimaryDamage = 800.0+ PrimaryDamageRadius = 18.0+ SecondaryDamage = 500.0+ SecondaryDamageRadius = 50.0+ AttackRange = 5.0+ DamageType = EXPLOSION+ DeathType = SUICIDED+ WeaponSpeed = 99999.0+ ProjectileObject = NONE+ DamageDealtAtSelfPosition = Yes+ RadiusDamageAffects = SELF SUICIDE ENEMIES NEUTRALS NOT_SIMILAR+ DelayBetweenShots = 0+ ClipSize = 1+ ClipReloadTime = 0+ AutoReloadsClip = No+ FireFX = WeaponFX_SuicideDynamitePackDetonation+ FireSound = CarBomberDie+End++Weapon Chem_DemoTrapDetonationWeaponBeta+ PrimaryDamage = 250.0+ PrimaryDamageRadius = 25.0+ SecondaryDamage = 100.0+ SecondaryDamageRadius = 50.0+ DamageType = EXPLOSION+ DeathType = EXPLODED+ WeaponSpeed = 99999.0+ FireFX = WeaponFX_DemoTrapDetonation+ FireOCL = OCL_PoisonFieldUpgradedMedium+ PlayFXWhenStealthed = Yes+ RadiusDamageAffects = SELF ALLIES ENEMIES NEUTRALS+ DelayBetweenShots = 0+ ClipSize = 1+ ClipReloadTime = 0+ AutoReloadsClip = No+End++Weapon Chem_DemoTrapDetonationWeaponGamma+ PrimaryDamage = 250.0+ PrimaryDamageRadius = 25.0+ SecondaryDamage = 100.0+ SecondaryDamageRadius = 50.0+ DamageType = EXPLOSION+ DeathType = EXPLODED+ WeaponSpeed = 99999.0+ FireFX = WeaponFX_DemoTrapDetonation+ FireOCL = OCL_PoisonFieldGammaMedium+ PlayFXWhenStealthed = Yes+ RadiusDamageAffects = SELF ALLIES ENEMIES NEUTRALS+ DelayBetweenShots = 0+ ClipSize = 1+ ClipReloadTime = 0+ AutoReloadsClip = No+End++Weapon Chem_ToxinShellWeaponGamma+ PrimaryDamage = 0.0+ PrimaryDamageRadius = 1.0+ AttackRange = 100.0+ DamageType = EXPLOSION+ DeathType = EXPLODED+ WeaponSpeed = 99999.0+ ProjectileObject = NONE+ FireOCL = OCL_PoisonFieldGammaSmall+ RadiusDamageAffects = ALLIES ENEMIES NEUTRALS+ DelayBetweenShots = 0+ ClipSize = 1+ ClipReloadTime = 0+ AutoReloadsClip = No+ AntiGround = Yes+ DamageDealtAtSelfPosition = Yes+End++Weapon ToxinShellWeaponUpgraded+ PrimaryDamage = 0.0+ PrimaryDamageRadius = 1.0+ AttackRange = 100.0+ DamageType = EXPLOSION+ DeathType = EXPLODED+ WeaponSpeed = 99999.0+ ProjectileObject = NONE+ FireOCL = OCL_PoisonFieldUpgradedSmall+ RadiusDamageAffects = ALLIES ENEMIES NEUTRALS+ DelayBetweenShots = 0+ ClipSize = 1+ ClipReloadTime = 0+ AutoReloadsClip = No+ AntiGround = Yes+ DamageDealtAtSelfPosition = Yes+Enddiff --git a/GeneralsMD/Code/Data/Scenarios/aurorablast.txt b/GeneralsMD/Code/Data/Scenarios/aurorablast.txtnew file mode 100644index 000000000..47050ad93--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/aurorablast.txt@@ -0,0 +1,38 @@+# The plain Aurora's bomb against a Scud Launcher's missile, for FX_AuroraBombDetonate+# (FXListReforged.ini). Three blasts on Twilight Flame, one after another, each filmed at the same+# zoom, heading and tilt by Cinema/aurorablast.txt: an Aurora on a Battlemaster column setting off+# from 1400,3860 (blast about 5.8 s), an Aurora on a War Factory at 1250,3800 (from 11 s) and two+# Scud Launchers on the Battlemasters, reinforced, driving on through 1500,3700 (from 21 s).+# Seat 1 owns every vehicle target and seat 0 the base; seat 2 shoots the second and third, so+# the second Aurora's order cannot reach the first. Since structures get the placement check,+# 1100,3700 refuses a War Factory (LBC_RESTRICTED_TERRAIN) and 1250,3800, 1600,3800, 1350,3950+# and 1050,3500 take one. 1580,3640 to 1760,3460 is a cliff top, a poor frame for a blast.+#+# generals.exe -win -xres 1280 -yres 720 -msaa 0 -particlecap 2500 -fps 120 -noFPSLimit+# -quickstart -noshellmap -observer -multiInstance -map "Maps\Twilight Flame\Twilight Flame.map"+# -autoskirmish 3 -takeover -side 0 FactionAmerica -side 1 FactionChina -side 2 FactionGLA+# -seed 7 -scenario aurorablast -cinema aurorablast -video 60 1980 aurorablast -maxframes 2000++# the base the second Aurora bombs, standing from the start+20 spawn 0 AmericaWarFactory 1 1250 3800+20 spawn 0 AmericaPowerPlant 1 1230 3640++# 1: Aurora on a Battlemaster column driving north-east+30 spawn 1 ChinaTankBattleMaster 3 1400 3860 45+31 move 1 ChinaTankBattleMaster 1500 3700+30 spawn 0 AmericaJetAurora 1 700 3780+32 attack 0 AmericaJetAurora 1 ChinaTankBattleMaster++# 2: Aurora on the War Factory, two Humvees driving past it+290 spawn 0 AmericaVehicleHumvee 2 1430 3700 40+291 move 0 AmericaVehicleHumvee 1000 3640+300 spawn 2 AmericaJetAurora 1 400 3700+302 attack 2 AmericaJetAurora 0 AmericaWarFactory++# 3: Scud Launchers on the Battlemasters, two more joining, all driving on+590 spawn 1 ChinaTankBattleMaster 2 1460 3880 45+600 move 1 ChinaTankBattleMaster 1540 3640+600 spawn 2 GLAVehicleScudLauncher 2 1150 3950 40+602 attack 2 GLAVehicleScudLauncher 1 ChinaTankBattleMaster++990 tally 1 *diff --git a/GeneralsMD/Code/Data/Scenarios/comanchehill.txt b/GeneralsMD/Code/Data/Scenarios/comanchehill.txtnew file mode 100644index 000000000..e42e3b851--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/comanchehill.txt@@ -0,0 +1,35 @@+# A Comanche over the edge of a plateau firing down on a tank column below it, the way a player+# reported losing armies: the Comanche saw and shot the tanks, and the tanks could neither see nor+# shoot it, because the plateau hid the ground cells it hovered over from anything below them and+# the attack states ran the terrain line of sight to a flyer. Two Gattling tanks are the anti-air+# that should take it down; the Battlemasters are what it kills meanwhile.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -map "Maps\Twilight Flame\Twilight Flame.map" -autoskirmish 2 -takeover+# -side 0 FactionAmerica -side 1 FactionChina -seed 7 -maxframes 2400+# -scenario comanchehill -logPrefix comanchehill_+#+# Seat 0's base plateau on this map ends at x 1100 (UI-MAP.md, the looks4 row); the Comanche spawns+# 150 back from the edge over it and the column 200 out from the edge on the low ground. Read the+# Comanche's tally against the Gattlings': before the fix the Comanche ends at full health with the+# Battlemasters dead and the Gattlings never firing; after it the Gattlings shoot it down. If the+# spawns refuse as cliff or the Comanche closes out over the low ground, move the two x values+# along the edge before trusting either result.++30 spawn 1 ChinaTankBattleMaster 3 1300 3200 40+30 spawn 1 ChinaTankGattling 2 1300 3300 40+30 spawn 0 AmericaVehicleComanche 1 950 3250+31 stance 1 * aggressive+60 attack 0 AmericaVehicleComanche 1 ChinaTankBattleMaster+60 tally 0 AmericaVehicleComanche+60 tally 1 ChinaTankBattleMaster+60 tally 1 ChinaTankGattling+300 tally 0 AmericaVehicleComanche+300 tally 1 ChinaTankBattleMaster+300 tally 1 ChinaTankGattling+600 tally 0 AmericaVehicleComanche+600 tally 1 ChinaTankBattleMaster+600 tally 1 ChinaTankGattling+1150 tally 0 AmericaVehicleComanche+1150 tally 1 ChinaTankBattleMaster+1150 tally 1 ChinaTankGattlingdiff --git a/GeneralsMD/Code/Data/Scenarios/spectre_reshoot.txt b/GeneralsMD/Code/Data/Scenarios/spectre_reshoot.txtnew file mode 100644index 000000000..fa5c50d3b--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/spectre_reshoot.txt@@ -0,0 +1,20 @@+# spectre_reaim.txt staged for footage: the same Spectre Gunship called on the Alpine Assault+# crossroads (1310,1290) and re-aimed inside its circle, but the four Battlemasters drive through+# the town instead of parking, and each re-aim follows them. Cinema/spectre_reshoot.txt films it+# from heading 135, which keeps the map's far edge and the sky out of the top of the frame.+#+# set ZH_USER_DATA_DIR to a folder on D: (the -video frames land under its Videos\)+# generals.exe -win -xres 1920 -yres 1080 -msaa 0 -fps 120 -noFPSLimit -quickstart -noshellmap+# -multiInstance -particlecap 2500 -map "Maps\Alpine Assault\Alpine Assault.map"+# -autoskirmish 2 -takeover -observer -side 0 FactionAmerica -side 1 FactionChina -seed 1+# -scenario spectre_reshoot -cinema spectre_reshoot -video 660 1380 spectre_reshoot+# -maxframes 1400+10 spawn 0 AmericaCommandCenter 1 start0:240:60+10 spawn 1 ChinaTankBattleMaster 4 1190 1210 30+20 power 0 AmericaCommandCenter 1310 1290 SuperweaponSpectreGunship+200 move 1 ChinaTankBattleMaster 1260 1250+360 reaim 0 AmericaJetSpectreGunship 1250 1250+400 move 1 ChinaTankBattleMaster 1420 1380+480 reaim 0 AmericaJetSpectreGunship 1380 1350+600 reaim 0 AmericaJetSpectreGunship 1420 1380+690 tally 1 ChinaTankBattleMasterdiff --git a/GeneralsMD/Code/Data/Scenarios/wallgarrison.txt b/GeneralsMD/Code/Data/Scenarios/wallgarrison.txtnew file mode 100644index 000000000..047500886--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/wallgarrison.txt@@ -0,0 +1,32 @@+# Rangers are ordered into a tower of Fallen Empire's great wall, and the tower takes nobody.+#+# The towers (FortressWallBuilding) carry a ten-man garrison, but the map switches every wall piece+# off for selection, so in 1.04 no click could land on one and no player ever got a man inside. The+# skirmish computer's garrison pass picks buildings by position instead and filled them, and since+# the map also makes the wall indestructible, nothing could shoot those men out. A garrison order on+# an unselectable structure is now refused for a player, the computer and, outside a mission or the+# shell map, a script too: the skirmish scripts were still putting GLA men into a tower.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -map "Maps\Fallen Empire\Fallen Empire.map" -autoskirmish 2 -takeover+# -side 0 FactionChina -side 1 FactionAmerica -seed 1 -maxframes 2400+# -scenario wallgarrison -logPrefix wallgarrison_+#+# Read the HEADLESS TALLY lines. At 600, after the player's click: seat 1 owns no FortressWallBuilding+# and all 5 Rangers stand outside. At 1100, after a script's enter (this is a skirmish): the same,+# no tower, 5 Rangers outside. A SCENARIO line naming the tower's id under each order proves the+# order went out and was refused, not that no tower was found.+# "civilian" as the target seat is what the map's neutral or civilian player owns (or owned at an+# earlier lookup), nearest the group.++30 spawn 1 AmericaInfantryRanger 5 1500 1150 20++60 clickenter 1 AmericaInfantryRanger civilian FortressWallBuilding++600 tally 1 FortressWallBuilding+600 tally 1 AmericaInfantryRanger++700 enter 1 AmericaInfantryRanger civilian FortressWallBuilding++1100 tally 1 FortressWallBuilding+1100 tally 1 AmericaInfantryRangerdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h b/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.hindex 6ba54d93d..7bf0464d3 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h@@ -107,6 +107,22 @@ constexpr Real ConvertRetailPerFrameRate( Real perFrame ) { return perFrame * 0.constexpr Real ConvertRetailPerFrameSquared( Real perFrameSqr ) { return perFrameSqr * 0.25f; }inline Real ConvertRetailPerFrameFactor( Real factor ) { return sqrtf( factor > 0.0f ? factor : 0.0f ); }+// ----------------------------------------------------------------------------------------------+// The speeds a skirmish or single-player match may run at: half speed to normal, never faster. The+// menu, the console, a saved game and a map script all pass through this; -fps, -turbo and a network+// game do not.+enum+{+ PLAYER_GAME_SPEED_MIN_FPS = LOGICFRAMES_PER_SECOND / 2,+ PLAYER_GAME_SPEED_MAX_FPS = LOGICFRAMES_PER_SECOND+};+constexpr Int ClampPlayerGameSpeed( Int fps )+{+ if( fps < PLAYER_GAME_SPEED_MIN_FPS ) return PLAYER_GAME_SPEED_MIN_FPS;+ if( fps > PLAYER_GAME_SPEED_MAX_FPS ) return PLAYER_GAME_SPEED_MAX_FPS;+ return fps;+}+// ----------------------------------------------------------------------------------------------// note that this returns a REAL value, not an int... most callers will want to// call ceil() on the result, so that partial frames get converted to full frames!diff --git a/GeneralsMD/Code/GameEngine/Include/Common/INI.h b/GeneralsMD/Code/GameEngine/Include/Common/INI.hindex 3127d6b8b..09f63b091 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/INI.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/INI.h@@ -207,6 +207,12 @@ public:/// set. Finders ask this on a miss, so a definition of the mod's own X never falls through to retail's.Bool findRetailName( const AsciiString &name, ModNameType type, AsciiString *retailName ) const;Bool findRetailKey( NameKeyType key, ModNameType type, NameKeyType *retailKey ) const;+ /// "M<n>~name" when mod n defines a `type` called name, else name: how a mod's own data that is not INI+ /// (its SkirmishScripts.scb) names its things+ AsciiString modName( Int mod, ModNameType type, const AsciiString &name ) const;+ /// where the file name in a path-shaped word starts, past its last '\\' or '/': "Sub\\x.mp3" gives 4.+ /// The prefix goes there, since FileSystem::splitModName reads it on the last part only+ static size_t lastPathPart( const std::string &word );static const char *const FactionFiles[]; ///< what scanMods reads and the mod passes load, NULL-ended; no ".ini" is a directorydiff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.hindex a7302afd4..6cbee11ea 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBarScheme.h@@ -141,7 +141,8 @@ public:AsciiString m_name; ///< it's nameICoord2D m_ScreenCreationRes; ///< Used to determine what screen res this will look the best on- AsciiString m_side; ///< contain what faction type this command bar was made for (used when selecting command bar by template+ AsciiString m_side; ///< contain what faction type this command bar was made for (used when selecting command bar by template+ Bool m_controlBarPro; ///< read from ControlBarProReforged.ini, the bar every side wearsImage *m_buttonQueueImage; ///< We'll probably want each one to have it's own image.Image *m_rightHUDImage; ///< We'll probably want each one to have it's own right HUD image.Color m_buildUpClockColor; ///< we can setup the color for the buildup clock if we want@@ -291,10 +292,11 @@ public:void preloadAssets( TimeOfDay timeOfDay ); ///< preload the assetsprivate:- ControlBarScheme *findSchemeForSide( const AsciiString& side ) const; ///< the widest of that side's schemes the screen can wear- ControlBarScheme *findSchemeForFaction( const AsciiString& side ) const; ///< the side's own, else its country's, else America's+ ControlBarScheme *findSchemeForSide( const AsciiString& side, Bool controlBarProOnly = FALSE ) const; ///< the widest of that side's schemes the screen can wear+ ControlBarScheme *findSchemeForFaction( const AsciiString& side ) const; ///< the side's own ControlBar Pro scheme, else its country's, else America'sControlBarScheme *m_currentScheme; ///< the current scheme that everythign uses+ Bool m_loadingControlBarPro; ///< newControlBarScheme marks what it makes as ControlBar Pro'sCoord2D m_multiplyer;typedef std::list< ControlBarScheme* > ControlBarSchemeList; ///< list of control bar schemesdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.hindex 8fa6a821b..42fe3f20a 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AI.h@@ -619,6 +619,14 @@ public:void addSideInfo(AISideInfo *info);void addFactionBuildList(AISideBuildList *buildList);+ /** A side's resource, defence and skill set entry, and its skirmish build list. Under -modfactions a+ * mod faction's own mod's AIData.ini is loaded under "M<n>~<side>" (AI::parseAiDataDefinition), so+ * modIndex asks for that first and falls back on retail's entry of the side when the mod has none.+ * NULL when neither has one. */+ const AISideInfo *findSideInfo( const AsciiString &side, Int modIndex ) const;+ const AISideBuildList *findBuildList( const AsciiString &side, Int modIndex ) const;+ const AISideInfo *findSideInfo( const Player *player ) const; ///< by the player's side and template's mod+// --------------- inherited from Snapshot interface --------------void crc( Xfer *xfer );void xfer( Xfer *xfer );@@ -775,6 +783,8 @@ public:enum FormationID getNextFormationID(void);static void parseAiDataDefinition( INI* ini );+ /// the key a mod's AIData entries are filed under: "M<n>~America" for mod index n-1, the side itself for retail (-1)+ static AsciiString modSideKey( const AsciiString &side, Int modIndex );static Int s_enemyScans; ///< see getEnemyScanCountThisFramestatic Real s_lastPathfindMS; ///< see getLastPathfindMSdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.hindex c6f3ee3ad..4dfa4655d 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/AIPlayer.h@@ -412,7 +412,7 @@ protected:void steerHealer(Int slot, const std::vector<AIKnownGun> &guns); ///< a healer over our hurt behind the line, clear of every known gunvoid flyRaid(Int slot, const std::vector<AIKnownGun> &guns); ///< a raider's bomb run on an enemy building, in and out the quiet sideBool pickRaidTarget(const Object *raider, const std::vector<AIKnownGun> &guns, Object **target, Coord3D *entry, Int *gunsOnRun) const;- Coord3D rearOf(const Coord3D *from, const std::vector<AIKnownGun> &guns) const; ///< the nearest point toward home no known gun reaches+ Coord3D rearOf(const Coord3D *from, const std::vector<AIKnownGun> &guns, Real margin) const; ///< the nearest point toward home no known gun reaches by marginBool isGunshipRider(const Object *obj) const; ///< infantry loadGunships may put in a transportvoid sendIdleAttackTeams(void); ///< attack teams standing at home join the next wave instead of waiting for the script's signalReal addHomeStrays(AIGroup *wave) const; ///< the default team's fighters idle at home go with the wave@@ -573,6 +573,8 @@ protected:Coord3D seen; ///< for the log only, not saved: where it stood on the last passReal seenHealth; ///< for the log only, not saved: its health share on the last passReal seenReach; ///< for the log only, not saved: how deep inside a known gun's reach it stood, negative when clear+ Int pullbacks; ///< for the log only, not saved: pull-back orders this one was given+ Int holds; ///< for the log only, not saved: looks it wanted to pull back and found no clearer ground};enum { MAX_DUTY_AMBULANCES = 2 };DutyAmbulance m_ambulance[ MAX_DUTY_AMBULANCES ];diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ArmorSet.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ArmorSet.hindex a86ab2dc0..7d64b4ebc 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ArmorSet.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ArmorSet.h@@ -70,6 +70,9 @@ private:ArmorSetFlags m_types;const ArmorTemplate* m_template;const DamageFX* m_fx;+ Bool m_namesMissingArmor; ///< the Armor line named an armor the store does not have++ static void parseArmor( INI* ini, void *instance, void *store, const void* userData );public:inline ArmorTemplateSet()@@ -82,9 +85,11 @@ public:m_types.clear();m_template = NULL;m_fx = NULL;+ m_namesMissingArmor = FALSE;}- inline const ArmorTemplate* getArmorTemplate() const { return m_template; }+ inline const ArmorTemplate* getArmorTemplate() const { return m_template; }+ inline Bool namesMissingArmor() const { return m_namesMissingArmor; }inline const DamageFX* getDamageFX() const { return m_fx; }inline Int getConditionsYesCount() const { return 1; }diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CleanupHazardUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CleanupHazardUpdate.hindex 1a488b255..3eb7e887f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CleanupHazardUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/CleanupHazardUpdate.h@@ -77,8 +77,12 @@ public:Object* scanClosestTarget();void fireWhenReady();- void setCleanupAreaParameters( const Coord3D *pos, Real range ); //This allows the unit to cleanup an area until clean, then the AI goes idle.+ /// This allows the unit to cleanup an area until clean, then the AI goes idle. forgetGivenUp: a player's+ /// order, which tries the ground it gave up on again; the computer's leaves it given up+ void setCleanupAreaParameters( const Coord3D *pos, Real range, Bool forgetGivenUp );Bool isCleaningArea() const { return m_moveRange > 0.0f; } ///< out cleaning an area, the cleanup ability's or one it noticed by itself+ Object *closestHazard( const Coord3D *from, Real range ) const; ///< the nearest hazard within range, none on the ground it gave up on+ void giveUpArea(); ///< leave the ground round the hazard it is after alone from now on, as if it could not reach itprotected:@@ -99,9 +103,14 @@ protected:Bool m_resumeGuard;Int m_resumeGuardMode; ///< a GuardModeBool m_returning; ///< the area is clean and the walk back to m_pos has been ordered- Int m_approaches; ///< scans in a row standing out of reach of the hazard it is after+ Int m_approaches; ///< scans in a row out of reach of its hazard, standing about, and no nearer to it+ Bool m_approaching; ///< m_approachPos holds the ground m_approaches counts for+ Coord3D m_approachPos; ///< where the hazard it is after stood when the count began; any within GIVEN_UP_RADIUS is the same ground+ Coord3D m_lastScanPos; ///< where it stood on the last scan that counted+ Real m_closestApproach; ///< the nearest it has come to a hazard on that groundObjectID m_resumeGuardObject; ///< the object it was guarding when a cleanup took it off guard, or INVALID_ID for a spot- ObjectID m_givenUpID; ///< the last hazard it gave up on as out of reach, never gone for again+ Bool m_hasGivenUp; ///< m_givenUpPos holds ground it gave up on+ Coord3D m_givenUpPos; ///< where the last hazard it gave up on as out of reach stood; none near it is gone for again};diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.hindex d571dfb0f..3addc7a7b 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h@@ -147,6 +147,13 @@ public://-------------------------------------------------------------------------------------------------enum CanMakeType : Int;+/** A building still going up or being sold researches nothing. Its own command bar never offers an+ * upgrade then, but a multi-selection that mixes it with finished ones did, and the logic took it. */+inline Bool canResearchWithStatus( const ObjectStatusMaskType &status )+{+ return !status.testForAny( MAKE_OBJECT_STATUS_MASK2( OBJECT_STATUS_UNDER_CONSTRUCTION, OBJECT_STATUS_SOLD ) );+}+// ------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------class ProductionUpdateInterfacediff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.hindex 7c5848f20..79399990c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/PartitionManager.h@@ -295,6 +295,13 @@ protected:extern void PartitionManager_findSightMargins( const Real *heights, Int cellRadius, Real cellSize, Real eyeZ,Real *sightMargin );+/** What a hill-blocked sighting records for one cell: SIGHT_CELL_GROUND when the ground there is in+ sight, SIGHT_CELL_AIR when the air over it is. The air is in sight anywhere within the looker's flat+ range, whatever hill or roof stands between: an aircraft behind a ridge sees down over it, so the+ units it shoots at must see it back. */+enum { SIGHT_CELL_GROUND = 0x01, SIGHT_CELL_AIR = 0x02 };+extern UnsignedByte PartitionManager_sightCellFlags( Bool groundRevealed, Int offsetX, Int offsetY, Int flatCellRadius );+//=====================================/**We sometimes need to save whether or not an area was fogged or permanently revealed through a@@ -324,7 +331,8 @@ class PartitionCell : public Snapshot // not MPO: allocated in an array{private:CellAndObjectIntersection* m_firstCoiInCell; ///< list of COIs in this cell (may be null).- ShroudLevel m_shroudLevel[MAX_PLAYER_COUNT];+ ShroudLevel m_shroudLevel[MAX_PLAYER_COUNT];+ Short m_airLookers[MAX_PLAYER_COUNT]; ///< lookers whose circle takes in the air over this cell, hills and roofs or not#ifdef PM_CACHE_TERRAIN_HEIGHTReal m_loTerrainZ; ///< lowest terrain-pt in this cellReal m_hiTerrainZ; ///< highest terrain-pt in this cell@@ -360,6 +368,9 @@ public:void addShrouder( Int playerIndex );void removeShrouder( Int playerIndex );CellShroudStatus getShroudStatusForPlayer( Int playerIndex ) const;+ void addAirLooker( Int playerIndex );+ void removeAirLooker( Int playerIndex );+ Bool isAirSeenByPlayer( Int playerIndex ) const { return m_airLookers[playerIndex] > 0; }// @todo: All of these are inline candidatesUnsignedInt getThreatValue( Int playerIndex );diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex 642ecd03f..397d522ef 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -85,6 +85,7 @@ enum ScenarioActionTypeSCENARIO_ACTION_CONSTRUCT, ///< construct <slot> <template> <position>; the local player's placement click, whatever is selected, as a message that is recorded and crosses the networkSCENARIO_ACTION_STANCE, ///< stance <slot> <selector> aggressive|defensive; the stance key, as MSG_SET_STANCESCENARIO_ACTION_FORCEATTACK, ///< forceattack <slot> <selector> <targetSlot> <targetSelector>; the attack key's click on one unit, as MSG_DO_FORCE_ATTACK_OBJECT+ SCENARIO_ACTION_CLICKENTER, ///< clickenter <slot> <selector> <targetSlot> <targetSelector>; a player's click into a building or transport, as MSG_ENTERSCENARIO_ACTION_WEAPONAT, ///< weaponat <slot> <selector> <position> [primary|secondary|tertiary]; a FIRE_WEAPON button's click on the ground, as MSG_DO_WEAPON_AT_LOCATION; tertiary when left outSCENARIO_ACTION_FORCEGROUND, ///< forceground <slot> <selector> <position>; the attack key's click on the ground, as MSG_DO_FORCE_ATTACK_GROUNDSCENARIO_ACTION_REAIM, ///< reaim <slot> <selector> <position>; a right click that moves a running power's aim (the Spectre Gunship's), as MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATIONdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.hindex 94db2afd1..f899a3bf5 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/SidesList.h@@ -43,6 +43,7 @@ class DataChunkInput;struct DataChunkInfo;class DataChunkOutput;class BuildListInfo;+class PlayerTemplate;class RenderObjClass;class ScriptList;class Shadow;@@ -162,6 +163,15 @@ public:void prepareForMP_or_Skirmish(void); // After a map is loaded, save & clear any players.+ /** The skirmish side a computer player on pt copies its scripts from, and in *teams (when asked) the+ * record its teams are in. Under -modfactions a mod faction takes its own mod's side of the same+ * Side (that mod's SkirmishScripts.scb, loadModSkirmishScripts) and retail's when the mod ships+ * none; a retail faction takes retail's. NULL when there is none. */+ SidesInfo *findSkirmishSideFor(const PlayerTemplate *pt, TeamsInfoRec **teams);+ /// how well a skirmish side of candidateSide from candidateMod (-1 retail) fits a player of side from+ /// mod: 2 the player's own, 1 retail's standing in for a mod faction, 0 not at all+ static Int skirmishSideFit(const AsciiString& candidateSide, Int candidateMod, const AsciiString& side, Int mod);+Int getNumTeams() { return m_teamrec.getNumTeams(); }void emptyTeams();void addTeam(const Dict* d);@@ -202,6 +212,12 @@ protected:TeamsInfoRec m_teamrec;TeamsInfoRec m_skirmishTeamrec;+ /// -modfactions: each mod's SkirmishScripts.scb players and teams, kept out of m_skirmishSides, which+ /// a map's own sides nearly fill+ std::vector<SidesInfo> m_modSkirmishSides;+ TeamsInfoRec m_modSkirmishTeamrec;+ void loadModSkirmishScripts(void);+Bool validateAllyEnemyList(const AsciiString& tname, AsciiString& allies);};diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/WeaponSet.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/WeaponSet.hindex 7dbf2af1f..6d6bab99f 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/WeaponSet.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/WeaponSet.h@@ -133,6 +133,7 @@ private:KindOfMaskType m_preferredAgainst[WEAPONSLOT_COUNT];Bool m_isReloadTimeShared;Bool m_isWeaponLockSharedAcrossSets; ///< A weapon set so similar that it is safe to hold locks across+ Bool m_namesMissingWeapon; ///< a Weapon line named a weapon the store does not havestatic void parseWeapon(INI* ini, void *instance, void *store, const void* userData);static void parseAutoChoose(INI* ini, void *instance, void *store, const void* userData);@@ -152,6 +153,7 @@ public:Bool testWeaponSetFlag( WeaponSetType wst ) const;Bool isSharedReloadTime( void ) const { return m_isReloadTimeShared; }Bool isWeaponLockSharedAcrossSets() const {return m_isWeaponLockSharedAcrossSets; }+ Bool namesMissingWeapon() const { return m_namesMissingWeapon; }Bool hasAnyWeapons() const;inline const WeaponTemplate* getNth(WeaponSlotType n) const { return m_template[n]; }diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cppindex 80a60dda9..1e60e305d 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp@@ -1168,6 +1168,10 @@ void GameEngine::init( int argc, char *argv[] )it silently refuses every multiplayer join from a machine that does not have the same one. */ini.load( AsciiString( "Data\\INI\\FXListReforged.ini" ), INI_LOAD_OVERWRITE, &xferCRC );initFactionSubsystem(TheWeaponStore,"TheWeaponStore", MSGNEW("GameEngineSubsystem") WeaponStore(), &xferCRC, NULL, "Data\\INI\\Weapon.ini");+ /* Weapons of the fork's own that BalanceReforged.ini hands out. It cannot add one, and borrowing+ one of EA's that nothing fires broke under a mod whose Weapon.ini leaves it out (Contra's Paladin+ found no infantry laser and crashed); a new name here exists whatever Weapon.ini loaded. */+ ini.load( AsciiString( "Data\\INI\\WeaponReforged.ini" ), INI_LOAD_OVERWRITE, &xferCRC );initFactionSubsystem(TheObjectCreationListStore,"TheObjectCreationListStore", MSGNEW("GameEngineSubsystem") ObjectCreationListStore(), &xferCRC, "Data\\INI\\Default\\ObjectCreationList.ini", "Data\\INI\\ObjectCreationList.ini");/* Lists EA left out or got wrong, before any object names one: a list parsed again is clearedand replaced whole, and a new name is simply added. */@@ -1224,6 +1228,11 @@ void GameEngine::init( int argc, char *argv[] )initSubsystem(TheAI,"TheAI", MSGNEW("GameEngineSubsystem") AI(), &xferCRC, "Data\\INI\\Default\\AIData.ini", "Data\\INI\\AIData.ini");+ /* -modfactions: each mod's sides' build lists and skill sets, under "M<n>~<side>". Unlike the+ other faction files this one reads the mod's Default\ copy too: ShockWave and The End of Days+ keep their whole AIData there, as retail does, and End of Days' AIData.ini is an empty block. */+ INI::loadModPasses( "Data\\INI\\Default\\AIData.ini", &xferCRC );+ INI::loadModPasses( "Data\\INI\\AIData.ini", &xferCRC );initSubsystem(TheGameLogic,"TheGameLogic", createGameLogic(), NULL);initSubsystem(TheTeamFactory,"TheTeamFactory", MSGNEW("GameEngineSubsystem") TeamFactory(), NULL);initSubsystem(TheCrateSystem,"TheCrateSystem", MSGNEW("GameEngineSubsystem") CrateSystem(), &xferCRC, "Data\\INI\\Default\\Crate.ini", "Data\\INI\\Crate.ini");diff --git a/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cppindex 17e47616f..56fdc2f50 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GameLOD.cpp@@ -360,7 +360,6 @@ void GameLODManager::init(void)TheWritableGlobalData->m_enableDynamicLOD = optionPref.getDynamicLODEnabled();TheWritableGlobalData->m_useFpsLimit = optionPref.getFPSLimitEnabled();TheWritableGlobalData->m_useLightMap = optionPref.getLightmapEnabled();- TheWritableGlobalData->m_useCloudMap = optionPref.getCloudShadowsEnabled();TheWritableGlobalData->m_showSoftWaterEdge = optionPref.getSmoothWaterEnabled();TheWritableGlobalData->m_useHeatEffects = optionPref.getUseHeatEffects();TheWritableGlobalData->m_useDrawModuleLOD = optionPref.getExtraAnimationsDisabled();@@ -585,7 +584,7 @@ void GameLODManager::applyStaticLODLevel(StaticGameLODLevel level)}}- TheWritableGlobalData->m_useCloudMap=lodInfo->m_useCloudMap;+ // m_useCloudMap is not the preset's: cloud shadows are a catalog option of their own (OptionsCatalog.cpp)TheWritableGlobalData->m_useLightMap=lodInfo->m_useLightMap;TheWritableGlobalData->m_showSoftWaterEdge=lodInfo->m_showSoftWaterEdge;//Check if shoreline blending mode has changeddiff --git a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cppindex ce65ab45b..7bb2d7eda 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/GlobalData.cpp@@ -1419,10 +1419,26 @@ void GlobalData::computeExeCRC( void )exeCRC.computeCRC( &version, sizeof(UnsignedInt) );}// Add in MP scripts to the EXE CRC, since the game will go out of sync if they change- const char *scripts[] = { "Data\\Scripts\\SkirmishScripts.scb", "Data\\Scripts\\MultiplayerScripts.scb" };- for (Int s = 0; s < 2; ++s)+ // -modfactions: then each mod's own SkirmishScripts.scb, which its factions' computer players run+ // (SidesList::loadModSkirmishScripts)+ std::vector<Int> focus( 2, FILE_FOCUS_ALL );+ for (Int mod = 0; m_modFactions && mod < (Int)m_mods.size(); ++mod)+ focus.push_back( mod );+ for (size_t s = 0; s < focus.size(); ++s){- File *fp = TheFileSystem->openFile(scripts[s], File::READ | File::BINARY);+ const char *script = s == 1 ? "Data\\Scripts\\MultiplayerScripts.scb" : "Data\\Scripts\\SkirmishScripts.scb";+ File *fp = NULL;+ if (focus[s] == FILE_FOCUS_ALL)+ {+ fp = TheFileSystem->openFile( script, File::READ | File::BINARY );+ }+ else+ {+ TheFileSystem->setFocus( focus[s] );+ if (TheFileSystem->doesFileExist( script ))+ fp = TheFileSystem->openFile( script, File::READ | File::BINARY );+ TheFileSystem->setFocus( FILE_FOCUS_ALL );+ }if (fp == NULL)continue;unsigned char crcBlock[blockSize];diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cppindex df548f67e..6f1c92366 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp@@ -643,8 +643,14 @@ void ModNamespace::addAsset( Int mod, const char *fileName )m_mods.resize( mod + 1 );std::set<std::string> &assets = m_mods[ mod ].assets;// INI names a model or a sound without its extension, and a texture as .tga when the file is a .dds- if (extension == "w3d" || extension == "wav" || extension == "mp3")+ if (extension == "w3d")assets.insert( base );+ else if (extension == "wav" || extension == "mp3")+ {+ // Sounds names the base, a MusicTrack or streamed event's Filename the whole file name+ assets.insert( base );+ assets.insert( name );+ }else if (extension == "dds" || extension == "tga"){assets.insert( base + ".tga" );@@ -737,9 +743,12 @@ Bool ModNamespace::prefixWords( char *line, size_t capacity, WordTest test ) confirst = FALSE;continue;}- if ((this->*test)( word, assetField ))+ // a file field may name a subfolder ("Sub\x.mp3"); the file is its last part+ const size_t at = assetField ? lastPathPart( word ) : 0;+ out.append( word, 0, at );+ if ((this->*test)( word.substr( at ), assetField ))out += prefix;- out += word;+ out.append( word, at, std::string::npos );}if (out.size() >= capacity)return FALSE;@@ -747,6 +756,12 @@ Bool ModNamespace::prefixWords( char *line, size_t capacity, WordTest test ) conreturn TRUE;}+size_t ModNamespace::lastPathPart( const std::string &word )+{+ const size_t slash = word.find_last_of( "\\/" );+ return slash == std::string::npos ? 0 : slash + 1;+}+Bool ModNamespace::findRetailName( const AsciiString &name, ModNameType type, AsciiString *retailName ) const{const char *text = name.str();@@ -772,6 +787,15 @@ Bool ModNamespace::findRetailKey( NameKeyType key, ModNameType type, NameKeyTypereturn TRUE;}+AsciiString ModNamespace::modName( Int mod, ModNameType type, const AsciiString &name ) const+{+ if (mod >= (Int)m_mods.size() || m_mods[ mod ].byType[ type ].count( name.str() ) == 0)+ return name;+ AsciiString prefixed;+ prefixed.format( "M%d~%s", mod + 1, name.str() );+ return prefixed;+}+//-------------------------------------------------------------------------------------------------/** Read a line from the already open file. Any comments will be remved and* therefore ignored from any given line */diff --git a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cppindex 9cd62693e..5aeba38ce 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/OptionsCatalog.cpp@@ -109,6 +109,7 @@ OPTION_BOOL_ACCESSORS( m_shadowsForProps )OPTION_BOOL_ACCESSORS( m_shadowsForParticles )OPTION_BOOL_ACCESSORS( m_particleGroundBounce )OPTION_BOOL_ACCESSORS( m_volumetricSmokeShadows )+OPTION_BOOL_ACCESSORS( m_useCloudMap )OPTION_BOOL_ACCESSORS( m_smokeFireLighting )OPTION_INT_ACCESSORS( m_shadowQuality )@@ -464,6 +465,14 @@ const OptionDef TheOptionCatalog[] =OPTION_BOOL, APPLY_LIVE, 0, 1,get_m_volumetricSmokeShadows, set_m_volumetricSmokeShadows },+ // The shadows of passing clouds scrolled over the terrain. It used to belong to the detail+ // preset, which turned it off at Low and gave no other way to; now the preset leaves it alone and+ // GameData.ini's Yes holds until Options.ini says otherwise. The terrain asks every frame. No+ // control in the game's menu; the launcher writes it.+ { "UseCloudMap", "", "",+ OPTION_BOOL, APPLY_LIVE, 0, 1,+ get_m_useCloudMap, set_m_useCloudMap },+// Classic or Reforged light. Reforged rebalances each map's lights as the map loads (so a change// shows on the next map), deepens the sun's shadow to match and grades the Direct3D 11 picture,// which follows the setting every frame. ClassicGraphics forces Classic. No control in thediff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cppindex 94bb9f1fa..9ae9ae784 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ActionManager.cpp@@ -656,6 +656,21 @@ Bool ActionManager::canResumeConstructionOf( const Object *obj,// ------------------------------------------------------------------------------------------------// ------------------------------------------------------------------------------------------------+/** A structure the map made unselectable (Fallen Empire's great wall: its towers carry a garrison+ * module, but the map switches them off for selection) never took a garrison in 1.04, because no+ * click can land on it. The skirmish computer's own garrison pass goes by position, not by click,+ * and filled the towers with soldiers nothing could shoot out of an indestructible wall. With that+ * pass refused, a Hard GLA still put men into a tower in a Hard match on Fallen Empire through the+ * skirmish scripts (CMD_FROM_SCRIPT, logged by nothing). So only a mission's or the shell map's own script+ * may still send men into one; in a skirmish, a network game and its replays nobody can. */+static Bool canGarrisonMapStructure( const Object *structure, CommandSourceType commandSource )+{+ const Int mode = TheGameLogic->getGameMode();+ const Bool missionScript = commandSource == CMD_FROM_SCRIPT && (mode == GAME_SINGLE_PLAYER || mode == GAME_SHELL);+ return missionScript || !structure->isKindOf( KINDOF_STRUCTURE )+ || structure->getContain() == NULL || !structure->getContain()->isGarrisonable() || structure->isSelectable();+}+Bool ActionManager::canEnterObject( const Object *obj, const Object *objectToEnter, CommandSourceType commandSource, CanEnterType mode ){@@ -699,6 +714,9 @@ Bool ActionManager::canEnterObject( const Object *obj, const Object *objectToEntif (objectToEnter->isDisabledByType( DISABLED_SUBDUED ))return FALSE; // a microwave tank has soldered the doors shut+ if( !canGarrisonMapStructure( objectToEnter, commandSource ) )+ return FALSE;+if( obj->isKindOf( KINDOF_STRUCTURE ) || obj->isKindOf( KINDOF_IMMOBILE ) ){@@ -2253,6 +2271,9 @@ Bool ActionManager::canPlayerGarrison( const Player *player, const Object *targeif (cmi->isGarrisonable() == false)return false;+ if (!canGarrisonMapStructure( target, commandSource ))+ return false;+if (player == target->getControllingPlayer()){return true;diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cppindex b1d29f00c..9db433047 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp@@ -900,16 +900,8 @@ void Player::initFromDict(const Dict* d)// poorly-formed user maps might not, which would be bad, and could crash us later. so if it doesn't// actually have a skirmish player defined for this side, declare it nonskirmish... the player won't// really work, but it's better than crashing.- for (Int spIdx = 0; spIdx < TheSidesList->getNumSkirmishSides(); ++spIdx)- {- AsciiString spTemplateName = TheSidesList->getSkirmishSideInfo(spIdx)->getDict()->getAsciiString(TheKey_playerFaction);- const PlayerTemplate* spt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(spTemplateName));- if (spt && spt->getSide() == getSide())- {- skirmish = true;- break;- }- }+ // -modfactions: a mod faction may have a skirmish player of its own mod's scripts, or retail's of its side+ skirmish = pt != NULL && TheSidesList->findSkirmishSideFor(pt, NULL) != NULL;DEBUG_ASSERTCRASH(skirmish, ("Could not find skirmish player for side %s... quietly making into nonskirmish.", getSide().str()));if (!skirmish)@@ -965,17 +957,14 @@ void Player::initFromDict(const Dict* d)// Copy and qualify scripts, and teams.AsciiString mySide = getSide();- Int i, skirmishNdx;- Bool found = false;+ Int i;AsciiString qualTemplatePlayerName;- for (skirmishNdx=0; skirmishNdx<TheSidesList->getNumSkirmishSides(); skirmishNdx++) {- AsciiString templateName = TheSidesList->getSkirmishSideInfo(skirmishNdx)->getDict()->getAsciiString(TheKey_playerFaction);- pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(templateName));- if (pt && pt->getSide() == mySide) {- qualTemplatePlayerName.format("%s%d", TheSidesList->getSkirmishSideInfo(skirmishNdx)->getDict()->getAsciiString(TheKey_playerName).str(), m_mpStartIndex);- found = true;- break;- }+ // -modfactions: a mod faction runs its own mod's skirmish scripts and teams when the mod ships them+ TeamsInfoRec *skirmishTeams = NULL;+ SidesInfo *skirmishSide = TheSidesList->findSkirmishSideFor(getPlayerTemplate(), &skirmishTeams);+ const Bool found = skirmishSide != NULL;+ if (found) {+ qualTemplatePlayerName.format("%s%d", skirmishSide->getDict()->getAsciiString(TheKey_playerName).str(), m_mpStartIndex);}Int diffInt = d->getInt(TheKey_skirmishDifficulty, &exists);GameDifficulty difficulty = TheScriptEngine->getGlobalDifficulty();@@ -1006,7 +995,7 @@ void Player::initFromDict(const Dict* d)m_playerName = qualTemplatePlayerName;AsciiString qualifier;qualifier.format("%d", m_mpStartIndex);- ScriptList *scripts = TheSidesList->getSkirmishSideInfo(skirmishNdx)->getScriptList()->duplicateAndQualify(+ ScriptList *scripts = skirmishSide->getScriptList()->duplicateAndQualify(qualifier, qualTemplatePlayerName, pname);ScriptList* slist = TheSidesList->getSideInfo(getPlayerIndex())->getScriptList();if (slist)@@ -1024,11 +1013,11 @@ void Player::initFromDict(const Dict* d)}// Now add teams.- AsciiString originalPlayerName = TheSidesList->getSkirmishSideInfo(skirmishNdx)->getDict()->getAsciiString(TheKey_playerName);- for (i=0; i<TheSidesList->getNumSkirmishTeams(); i++) {- if (TheSidesList->getSkirmishTeamInfo(i)->getDict()->getAsciiString(TheKey_teamOwner) == originalPlayerName)+ AsciiString originalPlayerName = skirmishSide->getDict()->getAsciiString(TheKey_playerName);+ for (i=0; i<skirmishTeams->getNumTeams(); i++) {+ if (skirmishTeams->getTeamInfo(i)->getDict()->getAsciiString(TheKey_teamOwner) == originalPlayerName){- Dict teamDict(*TheSidesList->getSkirmishTeamInfo(i)->getDict());+ Dict teamDict(*skirmishTeams->getTeamInfo(i)->getDict());AsciiString teamName = teamDict.getAsciiString(TheKey_teamName);AsciiString newName;newName.format("%s%d", teamDict.getAsciiString(TheKey_teamName).str(), m_mpStartIndex);diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cppindex deaef7c6a..d0561c5d6 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/SaveGame/GameState.cpp@@ -844,9 +844,10 @@ SaveCode GameState::loadGame( AvailableGameInfo gameInfo )} // end if// A loaded match played at the default 30 whatever speed it was saved at: the reset during the- // load puts the default back, and nothing kept the speed. A mission save starts its map afresh.+ // load puts the default back, and nothing kept the speed. A mission save starts its map afresh. A+ // save from when the speed went past normal comes back at normal.if( getSaveGameInfo()->saveFileType != SAVE_FILE_TYPE_MISSION && getSaveGameInfo()->framesPerSecond > 0 )- TheGameEngine->setFramesPerSecondLimit( getSaveGameInfo()->framesPerSecond );+ TheGameEngine->setFramesPerSecondLimit( ClampPlayerGameSpeed( getSaveGameInfo()->framesPerSecond ) );//// when loading a mission save, we want to do as much normal loading stuff as wediff --git a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cppindex 6134665a1..676157791 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/Thing/ThingTemplate.cpp@@ -951,14 +951,29 @@ Bool ThingTemplate::removeModuleInfo(const AsciiString& moduleToRemove, AsciiStrreturn removed;}+//-------------------------------------------------------------------------------------------------+void ArmorTemplateSet::parseArmor( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ )+{+ ArmorTemplateSet* self = (ArmorTemplateSet*)instance;+ const char *name = ini->getNextToken();+ if (strcasecmp(name, "None") == 0)+ {+ self->m_template = NULL;+ return;+ }+ self->m_template = TheArmorStore->findArmorTemplate(name);+ // ThingTemplate::parseArmorTemplateSet passes over a patch file's set that names an armor a mod dropped+ self->m_namesMissingArmor = (self->m_template == NULL);+}+//-------------------------------------------------------------------------------------------------/// @todo srj -- move this to another filevoid ArmorTemplateSet::parseArmorTemplateSet( INI* ini ){- static const FieldParse myFieldParse[] =+ static const FieldParse myFieldParse[] ={{ "Conditions", ArmorSetFlags::parseFromINI, NULL, offsetof( ArmorTemplateSet, m_types ) },- { "Armor", INI::parseArmorTemplate, NULL, offsetof( ArmorTemplateSet, m_template ) },+ { "Armor", ArmorTemplateSet::parseArmor, NULL, 0 },{ "DamageFX", INI::parseDamageFX, NULL, offsetof( ArmorTemplateSet, m_fx ) },{ 0, 0, 0, 0 }};@@ -970,14 +985,26 @@ void ArmorTemplateSet::parseArmorTemplateSet( INI* ini )void ThingTemplate::parseArmorTemplateSet( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ ){ThingTemplate* self = (ThingTemplate*)instance;+ ArmorTemplateSet ws;+ ws.parseArmorTemplateSet(ini);++ /* A patch file's set naming an armor the loaded data lacks would leave the object with no armor+ at all under those conditions, every hit at full damage: Contra has no ChemSuitHumanArmor, so+ FixesReforged.ini stripped its Rangers' Chemical Suits. The object keeps the set it had. */+ if (ini->getLoadType() == INI_LOAD_MULTIFILE && ws.namesMissingArmor())+ {+ // a nameless template is ThingFactory's scratch for a patch of a missing object, logged there+ if (self->getName().isNotEmpty())+ DEBUG_LOG(("[LINE: %d - FILE: '%s'] ArmorSet on %s names an armor that is not defined; the set is skipped.\n",+ ini->getLineNum(), ini->getFilename().str(), self->getName().str()));+ return;+ }+if (self->m_armorCopiedFromDefault == TRUE){self->m_armorCopiedFromDefault = FALSE;self->m_armorTemplateSets.clear();}-- ArmorTemplateSet ws;- ws.parseArmorTemplateSet(ini);self->m_armorTemplateSetFinder.clear();if (ini->getLoadType() == INI_LOAD_MULTIFILE){@@ -1010,14 +1037,28 @@ void ThingTemplate::parseArmorTemplateSet( INI* ini, void *instance, void * /*stvoid ThingTemplate::parseWeaponTemplateSet( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ ){ThingTemplate* self = (ThingTemplate*)instance;+ WeaponTemplateSet ws;+ ws.parseWeaponTemplateSet(ini, self);++ /* A patch file's set naming a weapon the loaded data lacks would arm the object with nothing in+ that slot: FixesReforged.ini's Toxin Tunnel Defender and Stinger sets name EA's Chem_ rockets,+ which Contra's Weapon.ini leaves out, so Contra's own two went unarmed. The object keeps the+ set it had, as a patch naming a missing object or module is passed over. */+ if (ini->getLoadType() == INI_LOAD_MULTIFILE && ws.namesMissingWeapon())+ {+ // a nameless template is ThingFactory's scratch for a patch of a missing object, already logged+ // there and thrown away with everything in it (GC_Chem_GLAScudStorm under Contra)+ if (self->getName().isNotEmpty())+ DEBUG_LOG(("[LINE: %d - FILE: '%s'] WeaponSet on %s names a weapon that is not defined; the set is skipped.\n",+ ini->getLineNum(), ini->getFilename().str(), self->getName().str()));+ return;+ }+if (self->m_weaponsCopiedFromDefault == TRUE){self->m_weaponsCopiedFromDefault = FALSE;self->m_weaponTemplateSets.clear();}-- WeaponTemplateSet ws;- ws.parseWeaponTemplateSet(ini, self);self->m_weaponTemplateSetFinder.clear();if (ini->getLoadType() == INI_LOAD_MULTIFILE){diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cppindex 7b9b98083..c76e579d2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp@@ -1425,7 +1425,7 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *comcase GUI_COMMAND_PLAYER_UPGRADE:{- if( queueMaxed )+ if( queueMaxed || !canResearchWithStatus( obj->getStatusBits() ) ){return COMMAND_RESTRICTED;}@@ -1451,7 +1451,7 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *comcase GUI_COMMAND_OBJECT_UPGRADE:{- if( queueMaxed )+ if( queueMaxed || !canResearchWithStatus( obj->getStatusBits() ) ){return COMMAND_RESTRICTED;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cppindex 678a9c22e..09f171d9d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarMultiSelect.cpp@@ -123,6 +123,12 @@ void ControlBar::populateMultiSelectUnitList( void )m_multiSelectGroupFirst[ g ] = draw->getID();m_multiSelectGroupCount++;}+ else if( !obj->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) &&+ TheGameClient->findDrawableByID( m_multiSelectGroupFirst[ g ] )->getObject()->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )+ {+ // a finished building speaks for its type, so the bar shows the upgrades it can take+ m_multiSelectGroupFirst[ g ] = draw->getID();+ }m_multiSelectGroupSize[ g ]++;} // end for, selected drawablesdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cppindex 37364de38..e65125b30 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarScheme.cpp@@ -308,6 +308,7 @@ ControlBarScheme::ControlBarScheme(void)m_name.clear();m_ScreenCreationRes.x = m_ScreenCreationRes.y = 0;m_side.clear();+ m_controlBarPro = FALSE;m_buttonQueueImage = NULL;m_rightHUDImage = NULL;m_buildUpClockColor = GameMakeColor(0,0,0,100);@@ -735,6 +736,7 @@ void ControlBarScheme::drawBackground( Coord2D multi, ICoord2D offset )ControlBarSchemeManager::ControlBarSchemeManager( void ){m_currentScheme = NULL;+ m_loadingControlBarPro = FALSE;m_schemeList.clear();m_multiplyer.x = m_multiplyer.y = 1;}@@ -834,7 +836,8 @@ ControlBarScheme *ControlBarSchemeManager::newControlBarScheme( AsciiString namecbScheme->reset();cbScheme->m_name.set( name );cbScheme->m_name.toLower();- return cbScheme;+ cbScheme->m_controlBarPro = m_loadingControlBarPro;+ return cbScheme;}cbScheme = NEW ControlBarScheme;@@ -847,6 +850,7 @@ ControlBarScheme *ControlBarSchemeManager::newControlBarScheme( AsciiString namecbScheme->m_name.set( name );cbScheme->m_name.toLower();+ cbScheme->m_controlBarPro = m_loadingControlBarPro;m_schemeList.push_back(cbScheme);@@ -936,7 +940,11 @@ void ControlBarSchemeManager::init( void )// ControlBar Pro's schemes, the bar every side wears: each replaces EA's of the same name whole,// and under a single -mod the mod's of that name, so nothing above reaches it (a Debug build// asserts once a scheme, newControlBarScheme). -modfactions loads no mod's schemes at all.+ // A scheme of a name it does not have (a mod's ChinaSpecialWeaponsGeneral) stays the mod's, so the+ // ones read here are marked and findSchemeForFaction picks among them only.+ m_loadingControlBarPro = TRUE;ini.load( AsciiString( "Data\\INI\\ControlBarProReforged.ini" ), INI_LOAD_OVERWRITE, NULL );+ m_loadingControlBarPro = FALSE;// //Load the user modified control bar schemes// WIN32_FIND_DATA findData;@@ -1046,13 +1054,13 @@ AsciiString ControlBarSchemeManager::getCurrentArtTwinSide( void ) const/** The side's widest scheme, as EA picked. Neither interface draws a scheme's painting; the plates* stand in for it (ControlBarPlateForSide), and the scheme only places the bar's own windows. *///------------------------------------------------------------------------------ControlBarScheme *ControlBarSchemeManager::findSchemeForSide( const AsciiString& side ) const+ControlBarScheme *ControlBarSchemeManager::findSchemeForSide( const AsciiString& side, Bool controlBarProOnly ) const{ControlBarScheme *best = NULL;for( ControlBarSchemeList::const_iterator it = m_schemeList.begin(); it != m_schemeList.end(); ++it ){ControlBarScheme *scheme = *it;- if( scheme->m_side.compareNoCase( side ) != 0 )+ if( scheme->m_side.compareNoCase( side ) != 0 || ( controlBarProOnly && !scheme->m_controlBarPro ) )continue;if( best == NULL || scheme->m_ScreenCreationRes.x > best->m_ScreenCreationRes.x )best = scheme;@@ -1074,22 +1082,24 @@ Bool ControlBarIsModFaction( const PlayerTemplate *pt )}//------------------------------------------------------------------------------/** The bar follows the country. A side with a scheme of its own (Boss and Observer among them) wears- * it; any other wears its country's by name, the way ControlBarPlateForSide reads a side, so a mod's- * ChinaCyberGeneral gets China's and its AmericaCyberneticGeneral America's. A side of no country we- * know (Russia, ECA, the civilians) wears America's. The squished bar does not come here. */+/** The bar follows the country, and is always ControlBar Pro's. A side with a ControlBar Pro scheme of+ * its own (Boss and Observer among them) wears it; any other wears its country's by name, the way+ * ControlBarPlateForSide reads a side, so a mod's ChinaCyberGeneral gets China's and its+ * AmericaCyberneticGeneral America's, whatever scheme the mod itself ships for that side (ShockWave's+ * ChinaSpecialWeaponsGeneral is EA's red China bar). A side of no country we know (Russia, ECA, the+ * civilians) wears America's. The squished bar does not come here. *///-----------------------------------------------------------------------------ControlBarScheme *ControlBarSchemeManager::findSchemeForFaction( const AsciiString& side ) const{- ControlBarScheme *scheme = findSchemeForSide( side );+ ControlBarScheme *scheme = findSchemeForSide( side, TRUE );if( scheme != NULL )return scheme;if( side.startsWithNoCase( "China" ) )- return findSchemeForSide( AsciiString( "China" ) );+ return findSchemeForSide( AsciiString( "China" ), TRUE );if( side.startsWithNoCase( "GLA" ) )- return findSchemeForSide( AsciiString( "GLA" ) );- return findSchemeForSide( AsciiString( "America" ) );+ return findSchemeForSide( AsciiString( "GLA" ), TRUE );+ return findSchemeForSide( AsciiString( "America" ), TRUE );}Bool ControlBarSchemeManager::isCurrentSchemePainted( void ) constdiff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cppindex 74f47af8e..c61d399c1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp@@ -169,11 +169,12 @@ static Bool stillNeedsToSetOptions = FALSE;void skirmishUpdateSlotList( void );static void populateSkirmishBattleHonors( void );// The game speed dropdown, as logic frames a second against the normal LOGICFRAMES_PER_SECOND. Half-// speed to double. The preference keeps the frame rate in retail 30 Hz frames, as it always did, so-// one saved by an older build or by the old 15 to 60 slider lands on the nearest entry.-static const Int SKIRMISH_GAME_SPEEDS[] = { LOGICFRAMES_PER_SECOND / 2, LOGICFRAMES_PER_SECOND * 3 / 4,- LOGICFRAMES_PER_SECOND, LOGICFRAMES_PER_SECOND * 3 / 2, LOGICFRAMES_PER_SECOND * 2 };-static const WideChar *SKIRMISH_GAME_SPEED_CAPTIONS[] = { u"x0.5", u"x0.75", u"x1", u"x1.5", u"x2" };+// speed to normal (ClampPlayerGameSpeed), nothing faster. The preference keeps the frame rate in+// retail 30 Hz frames, as it always did, so one saved by an older build, the old 15 to 60 slider or+// the x1.5 and x2 entries this list used to have, lands on the nearest entry.+static const Int SKIRMISH_GAME_SPEEDS[] = { PLAYER_GAME_SPEED_MIN_FPS, LOGICFRAMES_PER_SECOND * 3 / 4,+ PLAYER_GAME_SPEED_MAX_FPS };+static const WideChar *SKIRMISH_GAME_SPEED_CAPTIONS[] = { u"x0.5", u"x0.75", u"x1" };static const Int SKIRMISH_GAME_SPEED_COUNT = sizeof( SKIRMISH_GAME_SPEEDS ) / sizeof( SKIRMISH_GAME_SPEEDS[ 0 ] );static Int nearestGameSpeedIndex( Int framesPerSecond )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GameConsole.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GameConsole.cppindex c3da8f3ca..d05e834b7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GameConsole.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GameConsole.cpp@@ -146,7 +146,7 @@ static AsciiString runCheat( const ConsoleCheat &cheat, AsciiString arguments )}//--------------------------------------------------------------------------------------------------/** The game speed as a share of normal, the same thing numpad plus and minus move. It changes how+/** The game speed as a share of normal, 50 to 100 in a skirmish or mission, 17 to 666 in a replay. It changes how* often a logic frame runs and nothing inside one, so a network game, which runs at the pace the* whole room agrees on, is the one place it is refused. *///-------------------------------------------------------------------------------------------------@@ -168,7 +168,12 @@ static AsciiString runSpeed( AsciiString arguments )Int percent = arguments.compareNoCase( "reset" ) == 0 ? SPEED_NORMAL_PERCENT : atoi( arguments.str() );if( percent < SPEED_MIN_PERCENT ) percent = SPEED_MIN_PERCENT;if( percent > SPEED_MAX_PERCENT ) percent = SPEED_MAX_PERCENT;- TheGameEngine->setFramesPerSecondLimit( percent * LOGICFRAMES_PER_SECOND / SPEED_NORMAL_PERCENT );+ Int fps = percent * LOGICFRAMES_PER_SECOND / SPEED_NORMAL_PERCENT;+ // a match someone plays goes no faster than normal and no slower than half; a replay keeps the+ // whole range+ if( TheGameLogic->isInSkirmishGame() || TheGameLogic->isInSinglePlayerGame() )+ fps = ClampPlayerGameSpeed( fps );+ TheGameEngine->setFramesPerSecondLimit( fps );}result.format( "speed %d%%", TheGameEngine->getFramesPerSecondLimit() * SPEED_NORMAL_PERCENT / LOGICFRAMES_PER_SECOND );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cppindex b6ed86532..86211bd84 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AI.cpp@@ -35,6 +35,7 @@#include "Common/PerfTimer.h"#include "Common/Player.h"#include "Common/PlayerList.h"+#include "Common/PlayerTemplate.h"#include "Common/ThingTemplate.h"#include "Common/Xfer.h"#include "Common/XferCRC.h"@@ -88,6 +89,35 @@ void TAiData::addFactionBuildList(AISideBuildList *buildList)m_sideBuildLists = buildList;}+const AISideInfo *TAiData::findSideInfo( const AsciiString &side, Int modIndex ) const+{+ const AsciiString own = AI::modSideKey( side, modIndex );+ for (const AISideInfo *info = m_sideInfo; info != NULL; info = info->m_next)+ {+ if (info->m_side == own)+ return info;+ }+ return modIndex >= 0 ? findSideInfo( side, -1 ) : NULL;+}++const AISideBuildList *TAiData::findBuildList( const AsciiString &side, Int modIndex ) const+{+ const AsciiString own = AI::modSideKey( side, modIndex );+ for (const AISideBuildList *build = m_sideBuildLists; build != NULL; build = build->m_next)+ {+ if (build->m_side == own)+ return build;+ }+ return modIndex >= 0 ? findBuildList( side, -1 ) : NULL;+}++const AISideInfo *TAiData::findSideInfo( const Player *player ) const+{+ // a map player whose faction is gone (an obsolete map) has no template, and plays retail's side+ const PlayerTemplate *pt = player->getPlayerTemplate();+ return findSideInfo( player->getSide(), pt != NULL ? pt->getModIndex() : -1 );+}+TAiData::~TAiData(){AISideInfo *info = m_sideInfo;@@ -479,11 +509,67 @@ void AI::parseAiDataDefinition( INI* ini )} // end if+ /* -modfactions: a mod's pass (INI::loadModPasses) takes only its sides' entries, filed under+ "M<n>~<side>" with its names already prefixed, so its factions build and train its own things.+ The tuning in the rest of the block stays the fork's, mods fit the fork. */+ const Int mod = TheModNamespace.getActive();+ if (mod >= 0)+ {+ TAiData *modData = NEW TAiData;+ // the mod's AIData.ini goes over its Default\AIData.ini: what the first filed seeds this parse, so a+ // SideInfo field the second leaves out keeps the first's value, as retail's two files merge+ const AsciiString prefix = modSideKey( AsciiString::TheEmptyString, mod );+ for (AISideInfo **link = &TheAI->m_aiData->m_sideInfo; *link != NULL; )+ {+ AISideInfo *info = *link;+ if (!info->m_side.startsWith( prefix ))+ {+ link = &info->m_next;+ continue;+ }+ *link = info->m_next;+ const AsciiString side( info->m_side.str() + prefix.getLength() );+ info->m_side = side;+ modData->addSideInfo( info );+ }+ ini->initFromINI( modData, TheAIFieldParseTable );+ Int sides = 0;+ while (modData->m_sideInfo != NULL)+ {+ AISideInfo *info = modData->m_sideInfo;+ modData->m_sideInfo = info->m_next;+ info->m_side = modSideKey( info->m_side, mod );+ TheAI->m_aiData->addSideInfo( info );+ ++sides;+ }+ Int buildLists = 0;+ while (modData->m_sideBuildLists != NULL)+ {+ AISideBuildList *build = modData->m_sideBuildLists;+ modData->m_sideBuildLists = build->m_next;+ build->m_side = modSideKey( build->m_side, mod );+ TheAI->m_aiData->addFactionBuildList( build );+ ++buildLists;+ }+ delete modData;+ DEBUG_LOG(( "MODNS M%d~ AIData from %s: %d sides, %d skirmish build lists\n", mod + 1, ini->getFilename().str(), sides, buildLists ));+ return;+ }+// parse the ini weapon definitionini->initFromINI( TheAI->m_aiData, TheAIFieldParseTable );}+AsciiString AI::modSideKey( const AsciiString &side, Int modIndex )+{+ if (modIndex < 0)+ return side;+ AsciiString key;+ key.format( "M%d~%s", modIndex + 1, side.str() );+ return key;+}+diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cppindex 12913f845..b05e843a3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPathfind.cpp@@ -11416,6 +11416,12 @@ Bool Pathfinder::isAttackViewBlockedByObstacle(const Object* attacker, const Cooreturn false;}+ // An aircraft needs no line of sight and shoots down over the hill or the roof it hides behind, so+ // whatever it shoots at may shoot back the same way. isViewBlockedByObstacle let flyers through+ // already; the attack states call this directly and stood behind the hill instead of firing.+ if (victim && victim->isSignificantlyAboveTerrain())+ return false;+// srj sez: this is a good start at taking terrain into account for attacks, but findAttackPath needs to be smartened also#define LOS_TERRAIN#ifdef LOS_TERRAINdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex bc8eee51c..c3e506165 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -383,6 +383,8 @@ m_role(AIROLE_AGGRESSIVE)m_ambulance[ slot ].seen.zero();m_ambulance[ slot ].seenHealth = 1.0f;m_ambulance[ slot ].seenReach = 0.0f;+ m_ambulance[ slot ].pullbacks = 0;+ m_ambulance[ slot ].holds = 0;}m_ambulanceLost = 0;m_ambulancesBought = 0;@@ -579,21 +581,18 @@ void AIPlayer::checkForSupplyCenter( BuildListInfo *info, Object *bldg ){info->setSupplyBuilding(true);Int desiredGatherers = 0;- const AISideInfo *resInfo = TheAI->getAiData()->m_sideInfo;- while (resInfo) {- if (resInfo->m_side == m_player->getSide()) {- GameDifficulty difficulty = m_difficulty;- if (difficulty == DIFFICULTY_EASY) {- desiredGatherers = resInfo->m_easy;- }- if (difficulty == DIFFICULTY_NORMAL) {- desiredGatherers = resInfo->m_normal;- }- if (difficulty == DIFFICULTY_HARD) {- desiredGatherers = resInfo->m_hard;- }+ const AISideInfo *resInfo = TheAI->getAiData()->findSideInfo( m_player );+ if (resInfo) {+ GameDifficulty difficulty = m_difficulty;+ if (difficulty == DIFFICULTY_EASY) {+ desiredGatherers = resInfo->m_easy;+ }+ if (difficulty == DIFFICULTY_NORMAL) {+ desiredGatherers = resInfo->m_normal;+ }+ if (difficulty == DIFFICULTY_HARD) {+ desiredGatherers = resInfo->m_hard;}- resInfo = resInfo->m_next;}//// Adaptive harvesters (B6): the three INI numbers do not know how much supply is actually@@ -1817,6 +1816,8 @@ void AIPlayer::onUnitProduced( Object *factory, Object *unit )m_ambulance[slot].seen = *unit->getPosition();m_ambulance[slot].seenHealth = 1.0f;m_ambulance[slot].seenReach = 0.0f;+ m_ambulance[slot].pullbacks = 0;+ m_ambulance[slot].holds = 0;++m_ambulancesBought;DEBUG_LOG(("AI AMBULANCE frame %d player %d '%s' %d comes out, %d bought this match\n", TheGameLogic->getFrame(),m_player->getPlayerIndex(), unit->getTemplate()->getName().str(), unit->getID(), m_ambulancesBought));@@ -2867,8 +2868,11 @@ void AIPlayer::onUnitLost( const Object *obj )killer = killer->getContainedBy();if( isSkirmishAI() && !obj->isKindOf( KINDOF_STRUCTURE ) && killer && killer->isKindOf( KINDOF_STRUCTURE ) &&m_player->getRelationship( killer->getTeam() ) == ENEMIES )- DEBUG_LOG(("AI DEFLOSS frame %d player %d '%s' worth %.0f to '%s'\n", TheGameLogic->getFrame(), m_player->getPlayerIndex(),- obj->getTemplate()->getName().str(), aiCombatPower( obj ), killer->getTemplate()->getName().str()));+ DEBUG_LOG(("AI DEFLOSS frame %d player %d '%s' worth %.0f to '%s'; team '%s' state %d source %d, %.0f from home\n", TheGameLogic->getFrame(),+ m_player->getPlayerIndex(), obj->getTemplate()->getName().str(), aiCombatPower( obj ), killer->getTemplate()->getName().str(),+ team ? team->getName().str() : "", obj->getAI() ? (Int)obj->getAI()->getCurrentStateID() : -1,+ obj->getAI() ? (Int)obj->getAI()->getLastCommandSource() : -1,+ (Real)sqrt( sqr( obj->getPosition()->x - m_baseCenter.x ) + sqr( obj->getPosition()->y - m_baseCenter.y ) )));if( isSkirmishAI() && obj->isKindOf( KINDOF_STRUCTURE ) && aiCombatPower( obj ) > 0.0f )DEBUG_LOG(("AI DEFDEAD frame %d player %d '%s' worth %.0f\n", TheGameLogic->getFrame(), m_player->getPlayerIndex(),obj->getTemplate()->getName().str(), aiCombatPower( obj )));@@ -4689,13 +4693,7 @@ void AIPlayer::doUpgradesAndSkills( void )if (!checkScience) {return;}- const AISideInfo *sideInfo = TheAI->getAiData()->m_sideInfo;- while (sideInfo) {- if (sideInfo->m_side == m_player->getSide()) {- break;- }- sideInfo = sideInfo->m_next;- }+ const AISideInfo *sideInfo = TheAI->getAiData()->findSideInfo( m_player );if (sideInfo == NULL) return;if (m_skillsetSelector == INVALID_SKILLSET_SELECTION) {@@ -5153,10 +5151,9 @@ void AIPlayer::doExpansion( void )* on the build list and this player can build it. */Bool AIPlayer::buildExpansionDefense( void ){- for( const AISideInfo *resInfo = TheAI->getAiData()->m_sideInfo; resInfo; resInfo = resInfo->m_next )+ const AISideInfo *resInfo = TheAI->getAiData()->findSideInfo( m_player );+ if( resInfo != NULL ){- if( resInfo->m_side != m_player->getSide() )- continue;const ThingTemplate *defense = TheThingFactory->findTemplate( resInfo->m_baseDefenseStructure1, FALSE );if( defense == NULL )return FALSE;@@ -10402,7 +10399,7 @@ void AIPlayer::upgradeHelix( Object *helix, Int role, AIEnemyComposition *enemy,enemy->m_infantry * 100.0f, (enemy->m_armour - enemy->m_air) * 100.0f));}-Coord3D AIPlayer::rearOf( const Coord3D *from, const std::vector<AIKnownGun> &guns ) const+Coord3D AIPlayer::rearOf( const Coord3D *from, const std::vector<AIKnownGun> &guns, Real margin ) const{const Real dx = m_baseCenter.x - from->x;const Real dy = m_baseCenter.y - from->y;@@ -10413,7 +10410,7 @@ Coord3D AIPlayer::rearOf( const Coord3D *from, const std::vector<AIKnownGun> &gu{const Real x = from->x + dx * along / length;const Real y = from->y + dy * along / length;- if( deepestReach( guns, x, y, FALSE ) < -HELIX_GUN_MARGIN )+ if( deepestReach( guns, x, y, FALSE ) < -margin ){spot.set( x, y, TheTerrainLogic->getGroundHeight( x, y ) );return spot;@@ -10430,7 +10427,7 @@ Coord3D AIPlayer::rearOf( const Coord3D *from, const std::vector<AIKnownGun> &guconst Real x = from->x + RAID_SIDE[ side ][ 0 ] * reach;const Real y = from->y + RAID_SIDE[ side ][ 1 ] * reach;if( x >= extent.lo.x && x <= extent.hi.x && y >= extent.lo.y && y <= extent.hi.y &&- deepestReach( guns, x, y, FALSE ) < -HELIX_GUN_MARGIN )+ deepestReach( guns, x, y, FALSE ) < -margin ){spot.set( x, y, TheTerrainLogic->getGroundHeight( x, y ) );return spot;@@ -10496,7 +10493,7 @@ void AIPlayer::steerHealer( Int slot, const std::vector<AIKnownGun> &guns )if( hit || antiAirNear || inReach ){phase = HEAL_PULLBACK;- spot = rearOf( pos, guns );+ spot = rearOf( pos, guns, HELIX_GUN_MARGIN );}else if( helix->hasUpgrade( tower ) ){@@ -10557,7 +10554,7 @@ void AIPlayer::steerHealer( Int slot, const std::vector<AIKnownGun> &guns )phase = HEAL_REAR;middle.x /= out;middle.y /= out;- spot = rearOf( &middle, guns );+ spot = rearOf( &middle, guns, HELIX_GUN_MARGIN );// sideways, alternately right and left, by a tower's reach plus the slack a lower slot's spot// keeps before it is re-ordered, so a step always clears the spot it stepped away fromconst Real dx = m_baseCenter.x - middle.x;@@ -10678,7 +10675,7 @@ void AIPlayer::flyRaid( Int slot, const std::vector<AIKnownGun> &guns )const UnsignedInt lastHit = body->getLastDamageTimestamp();if( (lastHit != 0 && now - lastHit < HEALER_HIT_FRAMES) || deepestReach( guns, pos->x, pos->y, TRUE ) > -HELIX_GUN_MARGIN ){- const Coord3D clear = rearOf( pos, guns );+ const Coord3D clear = rearOf( pos, guns, HELIX_GUN_MARGIN );ai->aiMoveToPosition( &clear, CMD_FROM_AI );break;}@@ -10879,9 +10876,11 @@ void AIPlayer::doHelixes( void )* on our side of the map that no known gun covers; one beside it it notices by itself* (CleanupHazardUpdate::startAutoCleanup).*- * It is a 240-health truck with no gun. Hit in the last AMBULANCE_HIT_FRAMES or inside a known gun's- * reach, it drops whatever it was doing, the cleanup included, and drives AMBULANCE_PULLBACK toward- * home to the first ground no known gun reaches; under AMBULANCE_REPAIR_HEALTH it goes to be repaired.+ * It is a 240-health truck with no gun. Hit in the last AMBULANCE_HIT_FRAMES or within the margin of a+ * known gun's reach (AIAmbulance_gunMargin, scaled to the map), it drops whatever it was doing, the+ * cleanup included, and drives AMBULANCE_PULLBACK toward home to the first ground the margin clears,+ * but only when that ground is clearer than where it stands; otherwise it holds. Under+ * AMBULANCE_REPAIR_HEALTH it goes to be repaired.* Before that it parked 150 from the middle of the army and kept cleaning the toxins of the fight it* stood in: 90 of 112 bought in eight 2v2 matches died, each bought again once the bank allowed.* A lost one is now replaced after AMBULANCE_REBUY_FRAMES.@@ -10903,7 +10902,19 @@ static const Real AMBULANCE_HAZARD_REACH = 1500.0f;/** The cleanup ability's MaxMoveDistanceFromLocation in retail AmericaVehicle.ini. */static const Real AMBULANCE_CLEANUP_RANGE = 300.0f;static const Real AMBULANCE_REORDER_DISTANCE = 100.0f;-static const UnsignedInt AMBULANCE_HIT_FRAMES = 4 * LOGICFRAMES_PER_SECOND;+/** By rung (Easy, Medium, Hard; Easy fields none, its values keep the table whole). How long after a+ * hit it stays back. How far clear of every known gun it keeps: a share of the distance between the+ * two bases, held between a floor and a cap. A fixed 160 or 200 broke on the small generated maps,+ * where its own base stood that close to known enemy guns: no ground was clear, and on 32 such matches+ * the Hard USA pulled back 312 times against 116, at full health and unhit for minutes, cycling between+ * its wait spot and its base. On Twilight Flame the share reaches the cap. */+static const UnsignedInt AMBULANCE_HIT_FRAMES[ AISKILL_COUNT ] = { 4 * LOGICFRAMES_PER_SECOND, 6 * LOGICFRAMES_PER_SECOND, 8 * LOGICFRAMES_PER_SECOND };+static const Real AMBULANCE_MARGIN_SHARE[ AISKILL_COUNT ] = { 0.04f, 0.06f, 0.08f };+static const Real AMBULANCE_MARGIN_MIN[ AISKILL_COUNT ] = { 40.0f, 60.0f, 80.0f };+static const Real AMBULANCE_MARGIN_MAX[ AISKILL_COUNT ] = { 120.0f, 160.0f, 200.0f };+/** A spot it waits at stands this share of the margin farther clear again, so a gun a step closer does+ * not send it back the moment it gets there. */+static const Real AMBULANCE_WAIT_SLACK = 0.5f;static const Real AMBULANCE_PULLBACK = 400.0f;static const Real AMBULANCE_REPAIR_HEALTH = 0.5f;static const UnsignedInt AMBULANCE_REBUY_FRAMES = 90 * LOGICFRAMES_PER_SECOND;@@ -10932,9 +10943,33 @@ Bool AIAmbulance_mayBuyMore( Int bought, Int skill )return bought < AMBULANCE_MATCH_CAP[ skill ];}-Bool AIAmbulance_pullsBack( UnsignedInt now, UnsignedInt lastHit, Bool inGunReach )+/** How far clear of every known gun it keeps, for bases baseDistance apart. */+Real AIAmbulance_gunMargin( Real baseDistance, Int skill ){- return inGunReach || (lastHit != 0 && now - lastHit < AMBULANCE_HIT_FRAMES);+ return clamp( AMBULANCE_MARGIN_MIN[ skill ], AMBULANCE_MARGIN_SHARE[ skill ] * baseDistance, AMBULANCE_MARGIN_MAX[ skill ] );+}++/** Hit lately, or a known gun within the margin. clear is how far outside the reach of the gun that+ * reaches deepest it stands, below zero when inside it. */+Bool AIAmbulance_pullsBack( UnsignedInt now, UnsignedInt lastHit, Real clear, Real margin, Int skill )+{+ return clear < margin || (lastHit != 0 && now - lastHit < AMBULANCE_HIT_FRAMES[ skill ]);+}++/** Whether a pull-back moves it to ground clear by spotClear from where it stands clear by hereClear.+ * Only to ground clearer by a reorder step: on ground no clearer, it holds where it is, which is what+ * stops the cycle. Hit since its last look by something it does not know of, it goes back regardless,+ * since the known guns cannot say where the fire came from. */+Bool AIAmbulance_movesBack( Real hereClear, Real spotClear, Bool hitSinceLook )+{+ return hitSinceLook || spotClear >= hereClear + AMBULANCE_REORDER_DISTANCE;+}++/** Whether it goes forward to a wait spot clear by spotClear: clear by the margin and the slack, or at+ * least clearer than where it stands; otherwise it stays put. */+Bool AIAmbulance_waitsAt( Real hereClear, Real spotClear, Real margin )+{+ return spotClear >= margin * (1.0f + AMBULANCE_WAIT_SLACK) || spotClear >= hereClear + AMBULANCE_REORDER_DISTANCE;}/** What becomes of each one called is in the AI PATIENT lines. In one Hard and one Medium match (ambC,@@ -11057,10 +11092,10 @@ void AIPlayer::doAmbulances( void )++owned;continue;}- DEBUG_LOG(("AI AMBULANCE frame %d player %d loses %d at (%.0f,%.0f), %.0f from home, last seen at %.0f%% health %s a known gun's reach by %.0f, last sent to (%.0f,%.0f)\n",+ DEBUG_LOG(("AI AMBULANCE frame %d player %d loses %d at (%.0f,%.0f), %.0f from home, last seen at %.0f%% health %s a known gun's reach by %.0f, last sent to (%.0f,%.0f), %d pull-backs %d holds\n",TheGameLogic->getFrame(), m_player->getPlayerIndex(), duty.id, duty.seen.x, duty.seen.y,(Real)sqrt( sqr( duty.seen.x - m_baseCenter.x ) + sqr( duty.seen.y - m_baseCenter.y ) ), duty.seenHealth * 100.0f,- duty.seenReach > 0.0f ? "inside" : "clear of", fabs( duty.seenReach ), duty.spot.x, duty.spot.y));+ duty.seenReach > 0.0f ? "inside" : "clear of", fabs( duty.seenReach ), duty.spot.x, duty.spot.y, duty.pullbacks, duty.holds));duty.id = INVALID_ID;m_ambulanceLost = TheGameLogic->getFrame();}@@ -11150,8 +11185,26 @@ void AIPlayer::steerAmbulance( Int slot, const std::vector<AIKnownGun> &guns )// doing, a trip to be repaired included. Sent to be repaired first, it drove the pathfinder's way to// the War Factory, through whatever reached that way: 20 of 31 lost in eight matches (ambA4) died on// that trip, most within a few seconds of the order and inside a known gun's reach- if( AIAmbulance_pullsBack( now, body->getLastDamageTimestamp(), reach > 0.0f ) )- {+ //+ // How clear it keeps scales with the map (AIAmbulance_gunMargin), and it only ever moves to clearer+ // ground: with no clearer ground to go to it holds where it is, and it goes forward again only to a+ // spot clear by the margin and a slack, or clearer than where it stands (AIAmbulance_waitsAt)+ Player *enemy = getAiEnemy();+ Coord3D enemyPos;+ const Bool enemyPlaced = enemy && enemyStartGuess( enemy->getPlayerIndex(), &enemyPos );+ const Real margin = enemyPlaced ?+ AIAmbulance_gunMargin( (Real)sqrt( sqr( enemyPos.x - m_baseCenter.x ) + sqr( enemyPos.y - m_baseCenter.y ) ), m_skillLevel ) :+ AMBULANCE_MARGIN_MAX[ m_skillLevel ];+ const Real spotMargin = margin * (1.0f + AMBULANCE_WAIT_SLACK);+ const Real hereClear = -reach;+ const UnsignedInt lastHit = body->getLastDamageTimestamp();+ if( AIAmbulance_pullsBack( now, lastHit, hereClear, margin, m_skillLevel ) )+ {+ const Bool hitSinceLook = lastHit != 0 && now - lastHit < (UnsignedInt)AMBULANCE_CHECK_RATE;+ const Real sentClear = -deepestReach( guns, duty.spot.x, duty.spot.y, FALSE );+ // on its way to clearer ground already, a repair trip included, and not hit since: it keeps going+ if( !hitSinceLook && !cleaner->isCleaningArea() && ai->isMoving() && AIAmbulance_movesBack( hereClear, sentClear, FALSE ) )+ return;Coord3D back = *pos;const Real dx = m_baseCenter.x - pos->x;const Real dy = m_baseCenter.y - pos->y;@@ -11163,16 +11216,35 @@ void AIPlayer::steerAmbulance( Int slot, const std::vector<AIKnownGun> &guns )}elseback = m_baseCenter;- Coord3D spot = rearOf( &back, guns );- const Bool goingThere = ai->isMoving() && sqr( spot.x - duty.spot.x ) + sqr( spot.y - duty.spot.y ) <= sqr( AMBULANCE_REORDER_DISTANCE );- if( !goingThere )+ Coord3D spot = rearOf( &back, guns, spotMargin );+ const Real spotClear = -deepestReach( guns, spot.x, spot.y, FALSE );+ if( !AIAmbulance_movesBack( hereClear, spotClear, hitSinceLook ) ){- DEBUG_LOG(("AI AMBULANCE frame %d player %d '%s' %d pulls back to (%.0f,%.0f) at %.0f%% health%s\n", now, m_player->getPlayerIndex(),- ambulance->getTemplate()->getName().str(), duty.id, spot.x, spot.y, body->getHealth() * 100.0f / body->getMaxHealth(),- cleaner->isCleaningArea() ? ", off its cleanup" : ""));- ai->aiMoveToPosition( &spot, CMD_FROM_SCRIPT ); // not CMD_FROM_AI, which a cleanup under way would keep- duty.spot = spot;+ // no clearer ground than this: it holds here. Driving on into worse, or cleaning, it stops+ ++duty.holds;+ if( cleaner->isCleaningArea() || (ai->isMoving() && !AIAmbulance_movesBack( hereClear, sentClear, FALSE )) )+ {+ DEBUG_LOG(("AI AMBULANCE frame %d player %d '%s' %d holds at (%.0f,%.0f), %.0f clear against a margin of %.0f, no clearer ground; %d holds\n",+ now, m_player->getPlayerIndex(), ambulance->getTemplate()->getName().str(), duty.id, pos->x, pos->y, hereClear, margin, duty.holds));+ if( cleaner->isCleaningArea() )+ cleaner->giveUpArea();+ const Coord3D stop = *pos;+ ai->aiMoveToPosition( &stop, CMD_FROM_SCRIPT );+ duty.spot = stop;+ }+ return;}+ ++duty.pullbacks;+ DEBUG_LOG(("AI AMBULANCE frame %d player %d '%s' %d pulls back to (%.0f,%.0f) at %.0f%% health, %.0f clear against a margin of %.0f, to %.0f clear, hit %d s ago%s; %d pull-backs\n",+ now, m_player->getPlayerIndex(), ambulance->getTemplate()->getName().str(), duty.id, spot.x, spot.y,+ body->getHealth() * 100.0f / body->getMaxHealth(), hereClear, margin, spotClear,+ lastHit != 0 ? (Int)((now - lastHit) / LOGICFRAMES_PER_SECOND) : -1, cleaner->isCleaningArea() ? ", off its cleanup" : "", duty.pullbacks));+ // pulled off a cleanup, it leaves that ground alone from now on: the spill it was sent to was+ // picked again the next look, and the cleanup drove it back after the same hazard under the guns+ if( cleaner->isCleaningArea() )+ cleaner->giveUpArea();+ ai->aiMoveToPosition( &spot, CMD_FROM_SCRIPT ); // not CMD_FROM_AI, which a cleanup under way would keep+ duty.spot = spot;return;}@@ -11255,11 +11327,9 @@ void AIPlayer::steerAmbulance( Int slot, const std::vector<AIKnownGun> &guns )if( called > 0 || boarding.found )return; // no new spot while they walk over- // the nearest hazard, if it is on our side and clear of every known gun's reach by the healer's margin- PartitionFilterAcceptByKindOf kindFilter( MAKE_KINDOF_MASK( KINDOF_CLEANUP_HAZARD ), KINDOFMASK_NONE );- PartitionFilterSameMapStatus filterMapStatus( ambulance );- PartitionFilter *filters[] = { &kindFilter, &filterMapStatus, NULL };- Object *hazard = ThePartitionManager->getClosestObject( pos, AMBULANCE_HAZARD_REACH, FROM_CENTER_2D, filters );+ // the nearest hazard, if it is on our side and clear of every known gun's reach by the healer's margin,+ // and not on ground it gave up on+ Object *hazard = cleaner->closestHazard( pos, AMBULANCE_HAZARD_REACH );// and no farther from home than where it waits behind the army, or at home with nobody out. Three of// four lost in one Hard match (ambD) died on or after a cleanup 1,400 out, 2,100 to 2,800 from homeReal hazardLimit = 0.0f;@@ -11268,13 +11338,13 @@ void AIPlayer::steerAmbulance( Int slot, const std::vector<AIKnownGun> &guns )if( hazard && isOurSideOfMap( hazard->getPosition() ) &&(isAtHome( hazard->getPosition() ) ||sqr( hazard->getPosition()->x - m_baseCenter.x ) + sqr( hazard->getPosition()->y - m_baseCenter.y ) <= sqr( max( hazardLimit, 0.0f ) )) &&- deepestReach( guns, hazard->getPosition()->x, hazard->getPosition()->y, FALSE ) < -HELIX_GUN_MARGIN )+ deepestReach( guns, hazard->getPosition()->x, hazard->getPosition()->y, FALSE ) < -spotMargin ){DEBUG_LOG(("AI AMBULANCE frame %d player %d '%s' %d goes to clean '%s' %d at (%.0f,%.0f), %.0f away\n", now, m_player->getPlayerIndex(),ambulance->getTemplate()->getName().str(), duty.id, hazard->getTemplate()->getName().str(), hazard->getID(),hazard->getPosition()->x, hazard->getPosition()->y,(Real)sqrt( sqr( hazard->getPosition()->x - pos->x ) + sqr( hazard->getPosition()->y - pos->y ) )));- cleaner->setCleanupAreaParameters( hazard->getPosition(), AMBULANCE_CLEANUP_RANGE );+ cleaner->setCleanupAreaParameters( hazard->getPosition(), AMBULANCE_CLEANUP_RANGE, FALSE );duty.spot = *hazard->getPosition();return;}@@ -11292,7 +11362,7 @@ void AIPlayer::steerAmbulance( Int slot, const std::vector<AIKnownGun> &guns ){middle.x += dx * AMBULANCE_BEHIND / length;middle.y += dy * AMBULANCE_BEHIND / length;- spot = rearOf( &middle, guns );+ spot = rearOf( &middle, guns, spotMargin );}}else if( isAtHome( pos ) )@@ -11302,6 +11372,10 @@ void AIPlayer::steerAmbulance( Int slot, const std::vector<AIKnownGun> &guns )const Bool away = sqr( spot.x - pos->x ) + sqr( spot.y - pos->y ) > sqr( AMBULANCE_REORDER_DISTANCE );if( !moved && !(ai->isIdle() && away) )return;+ // not forward onto ground the margin does not clear: rearOf falls back to the base center when nothing+ // is clear, and on a small map that sent it back and forth between there and its pull-back spot+ if( !AIAmbulance_waitsAt( hereClear, -deepestReach( guns, spot.x, spot.y, FALSE ), margin ) )+ return;if( moved )DEBUG_LOG(("AI AMBULANCE frame %d player %d '%s' %d waits at (%.0f,%.0f), %d units out\n", now, m_player->getPlayerIndex(),ambulance->getTemplate()->getName().str(), duty.id, spot.x, spot.y, out));diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cppindex b64c91fb6..d930bbda9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AISkirmishPlayer.cpp@@ -686,14 +686,10 @@ Player *AISkirmishPlayer::getAiEnemy(void)*/void AISkirmishPlayer::buildAIBaseDefense(Bool flank){- const AISideInfo *resInfo = TheAI->getAiData()->m_sideInfo;+ const AISideInfo *resInfo = TheAI->getAiData()->findSideInfo( m_player );AsciiString defenseTemplateName;- while (resInfo) {- if (resInfo->m_side == m_player->getSide()) {- defenseTemplateName = resInfo->m_baseDefenseStructure1;- break;- }- resInfo = resInfo->m_next;+ if (resInfo) {+ defenseTemplateName = resInfo->m_baseDefenseStructure1;}// the data names one defence per side, so a script asking for ten got ten of it: the side's mix// comes off a dozer's buttons instead, and the data's choice stands in when no dozer is left@@ -1235,28 +1231,28 @@ void AISkirmishPlayer::newMap( void )/* Get our proper build list. */AsciiString mySide = m_player->getSide();DEBUG_LOG(("AI Player side is %s\n", mySide.str()));- const AISideBuildList *build = TheAI->getAiData()->m_sideBuildLists;- while (build) {- if (build->m_side == mySide) {- BuildListInfo *buildList = build->m_buildList->duplicate();- // -modfactions: the build lists are retail's and keyed by side, so a mod's player builds the- // mod's own building of each name, and retail's where the mod has none. Before this its- // command center was torn down below and put back as retail's.- const Int mod = m_player->getPlayerTemplate()->getModIndex();- for (BuildListInfo *info = buildList; mod >= 0 && info != NULL; info = info->getNext())- {- AsciiString modName;- modName.format("M%d~%s", mod + 1, info->getTemplateName().str());- const ThingTemplate *modPlan = TheThingFactory->findTemplate( modName );- if (modPlan != NULL)- info->setTemplateName( modPlan->getName() );- }- adjustBuildList(buildList); // adjust to our start position.- m_player->setBuildList(buildList);- computeCenterAndRadiusOfBase(&m_baseCenter, &m_baseRadius);- break;+ // -modfactions: a mod faction's own mod's list ("M<n>~America", its AIData.ini), retail's of the side without one+ const PlayerTemplate *pt = m_player->getPlayerTemplate();+ const Int mod = pt != NULL ? pt->getModIndex() : -1; // no template: a map whose faction is gone+ const AISideBuildList *build = TheAI->getAiData()->findBuildList( mySide, mod );+ if (build) {+ BuildListInfo *buildList = build->m_buildList->duplicate();+ // a mod without a list of its own gets retail's, read as the mod's own building of each name+ // where the mod has one. Before this its command center was torn down below and put back as+ // retail's.+ const Bool retailList = mod >= 0 && build->m_side == mySide;+ for (BuildListInfo *info = buildList; retailList && info != NULL; info = info->getNext())+ {+ AsciiString modName;+ modName.format("M%d~%s", mod + 1, info->getTemplateName().str());+ const ThingTemplate *modPlan = TheThingFactory->findTemplate( modName );+ if (modPlan != NULL)+ info->setTemplateName( modPlan->getName() );}- build = build->m_next;+ adjustBuildList(buildList); // adjust to our start position.+ m_player->setBuildList(buildList);+ computeCenterAndRadiusOfBase(&m_baseCenter, &m_baseRadius);+ DEBUG_LOG(("AI Player build list is %s's\n", build->m_side.str()));}DEBUG_ASSERTLOG(build!=NULL, ("Couldn't find build list for skirmish player.\n"));diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cppindex 49b44e96c..03eb43b9d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/SidesList.cpp@@ -46,7 +46,10 @@#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine+#include <algorithm>+#include "Common/DataChunk.h"+#include "Common/FileSystem.h"#include "Common/GameState.h"#include "Common/PlayerTemplate.h"#include "Common/WellKnownKeys.h"@@ -422,6 +425,8 @@ SidesInfo *SidesList::findSkirmishSideInfo(AsciiString name, Int* index /*= NULL}static AsciiString static_readPlayerNames[MAX_PLAYER_COUNT];+static Dict static_readPlayerDicts[MAX_PLAYER_COUNT]; ///< beside the names, for a mod's scripts (loadModSkirmishScripts)+static TeamsInfoRec static_readModTeams; ///< a mod's ScriptTeams, before its players are renamed/*** ParsePlayersDataChunk - read players names data chunk.@@ -443,8 +448,9 @@ static Bool ParsePlayersDataChunk(DataChunkInput &file, DataChunkInfo *info, voifor (i=0; i<numNames; i++) {if (i>=MAX_PLAYER_COUNT) break;static_readPlayerNames[i] = file.readAsciiString();+ static_readPlayerDicts[i].clear();if (readDicts) {- Dict sideDict = file.readDict();+ static_readPlayerDicts[i] = file.readDict();}}DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over."));@@ -476,6 +482,227 @@ static Bool ParseTeamsDataChunk(DataChunkInput &file, DataChunkInfo *info, voidreturn true;}+/// a mod's ScriptTeams, kept whole until its players are known (loadModSkirmishScripts)+static Bool ParseModTeamsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData)+{+ while (!file.atEndOfChunk()) {+ Dict teamDict = file.readDict();+ static_readModTeams.addTeam(&teamDict);+ }+ return true;+}++/** What a mod's skirmish scripts call its own: its kept players and their default teams under+ * "M<n>~", and what they build, upgrade, research, fire or press read as the mod's where it defines+ * one. Script, flag and counter names stay, Player::initFromDict qualifies those per player. */+struct ModScriptNames+{+ Int mod;+ AsciiString prefix;+ std::vector<AsciiString> players;++ Bool isPlayer(const AsciiString& name) const+ {+ return std::find(players.begin(), players.end(), name) != players.end();+ }+ AsciiString player(const AsciiString& name) const+ {+ if (!isPlayer(name))+ return name;+ AsciiString renamed = prefix;+ renamed.concat(name);+ return renamed;+ }+ /// a player's default team is "team<player>" (Player::setDefaultTeam), so it follows the player+ AsciiString team(const AsciiString& name) const+ {+ if (!name.startsWith("team") || !isPlayer(AsciiString(name.str() + 4)))+ return name;+ AsciiString renamed = "team";+ renamed.concat(player(AsciiString(name.str() + 4)));+ return renamed;+ }+ void parameter(Parameter *parm) const+ {+ ModNameType type;+ switch (parm->getParameterType())+ {+ case Parameter::SIDE: parm->friend_setString(player(parm->getString())); return;+ case Parameter::TEAM: parm->friend_setString(team(parm->getString())); return;+ case Parameter::OBJECT_TYPE: type = MODNAME_OBJECT; break;+ case Parameter::UPGRADE: type = MODNAME_UPGRADE; break;+ case Parameter::SCIENCE: type = MODNAME_SCIENCE; break;+ case Parameter::SPECIAL_POWER: type = MODNAME_SPECIALPOWER; break;+ case Parameter::COMMAND_BUTTON: type = MODNAME_COMMANDBUTTON; break;+ default: return;+ }+ parm->friend_setString(TheModNamespace.modName(mod, type, parm->getString()));+ }+ void script(Script *s) const+ {+ for (OrCondition *orCondition = s->getOrCondition(); orCondition; orCondition = orCondition->getNextOrCondition())+ {+ for (Condition *condition = orCondition->getFirstAndCondition(); condition; condition = condition->getNext())+ {+ for (Int i = 0; i < condition->getNumParameters(); ++i)+ parameter(condition->getParameter(i));+ }+ }+ ScriptAction *const actions[] = { s->getAction(), s->getFalseAction() };+ for (Int list = 0; list < 2; ++list)+ {+ for (ScriptAction *action = actions[list]; action; action = action->getNext())+ {+ for (Int i = 0; i < action->getNumParameters(); ++i)+ parameter(action->getParameter(i));+ }+ }+ }+ void scripts(ScriptList *list) const+ {+ for (Script *s = list->getScript(); s; s = s->getNext())+ script(s);+ for (ScriptGroup *group = list->getScriptGroup(); group; group = group->getNext())+ {+ for (Script *s = group->getScript(); s; s = s->getNext())+ script(s);+ }+ }+};++/** -modfactions: each mod's own SkirmishScripts.scb, for its factions' computer players. A player of+ * the file whose faction the mod defines (FactionAmerica read as M<n>~FactionAmerica) is kept with+ * its scripts and teams, renamed so it never meets retail's player of the same name. */+void SidesList::loadModSkirmishScripts(void)+{+ m_modSkirmishSides.clear();+ m_modSkirmishTeamrec.clear();+ if (TheGlobalData == NULL || !TheGlobalData->m_modFactions)+ return;++ const AsciiString path = "data\\Scripts\\SkirmishScripts.scb";+ for (Int mod = 0; mod < (Int)TheGlobalData->m_mods.size(); ++mod)+ {+ // the stream reads the whole file as it opens, so the focus is back before the parse+ TheFileSystem->setFocus(mod);+ CachedFileInputStream theInputStream;+ const Bool opened = TheFileSystem->doesFileExist(path.str()) && theInputStream.open(path);+ TheFileSystem->setFocus(FILE_FOCUS_ALL);+ if (!opened)+ continue;++ DataChunkInput file(&theInputStream);+ file.registerParser( AsciiString("PlayerScriptsList"), AsciiString::TheEmptyString, ScriptList::ParseScriptsDataChunk );+ file.registerParser( AsciiString("ScriptsPlayers"), AsciiString::TheEmptyString, ParsePlayersDataChunk );+ file.registerParser( AsciiString("ScriptTeams"), AsciiString::TheEmptyString, ParseModTeamsDataChunk );+ const Bool parsed = file.parse(this);+ ScriptList *scripts[MAX_PLAYER_COUNT];+ const Int count = ScriptList::getReadScripts(scripts);++ ModScriptNames names;+ names.mod = mod;+ names.prefix.format("M%d~", mod + 1);+ const size_t firstSide = m_modSkirmishSides.size();+ for (Int i = 0; i < count; ++i)+ {+ // a file written without the players' dicts names its factions only through the map's player of that name+ AsciiString fileFaction = static_readPlayerDicts[i].getAsciiString(TheKey_playerFaction);+ SidesInfo *mapSide = findSkirmishSideInfo(static_readPlayerNames[i]);+ if (fileFaction.isEmpty() && mapSide != NULL)+ fileFaction = mapSide->getDict()->getAsciiString(TheKey_playerFaction);+ const AsciiString faction = TheModNamespace.modName(mod, MODNAME_PLAYERTEMPLATE, fileFaction);+ const PlayerTemplate *pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(faction));+ if (!parsed || scripts[i] == NULL || pt == NULL || pt->getModIndex() != mod || !pt->isPlayableSide())+ {+ if (scripts[i])+ scripts[i]->deleteInstance();+ continue;+ }+ names.players.push_back(static_readPlayerNames[i]);+ Dict sideDict(static_readPlayerDicts[i]);+ sideDict.setAsciiString(TheKey_playerName, names.player(static_readPlayerNames[i]));+ sideDict.setAsciiString(TheKey_playerFaction, pt->getName());+ m_modSkirmishSides.push_back(SidesInfo());+ m_modSkirmishSides.back().init(&sideDict);+ m_modSkirmishSides.back().setScriptList(scripts[i]);+ }+ for (size_t s = firstSide; s < m_modSkirmishSides.size(); ++s)+ names.scripts(m_modSkirmishSides[s].getScriptList());++ const NameKeyType unitKeys[] = { TheKey_teamUnitType1, TheKey_teamUnitType2, TheKey_teamUnitType3,+ TheKey_teamUnitType4, TheKey_teamUnitType5, TheKey_teamUnitType6, TheKey_teamUnitType7, TheKey_teamTransport };+ Int teams = 0;+ for (Int t = 0; t < static_readModTeams.getNumTeams(); ++t)+ {+ Dict teamDict(*static_readModTeams.getTeamInfo(t)->getDict());+ const AsciiString owner = teamDict.getAsciiString(TheKey_teamOwner);+ if (!names.isPlayer(owner))+ continue;+ teamDict.setAsciiString(TheKey_teamOwner, names.player(owner));+ teamDict.setAsciiString(TheKey_teamName, names.team(teamDict.getAsciiString(TheKey_teamName)));+ for (size_t k = 0; k < ARRAY_SIZE(unitKeys); ++k)+ {+ Bool exists = FALSE;+ const AsciiString unit = teamDict.getAsciiString(unitKeys[k], &exists);+ if (exists)+ teamDict.setAsciiString(unitKeys[k], TheModNamespace.modName(mod, MODNAME_OBJECT, unit));+ }+ m_modSkirmishTeamrec.addTeam(&teamDict);+ ++teams;+ }+ DEBUG_LOG(("MODNS M%d~ SkirmishScripts.scb: %d of %d players kept, %d teams%s\n", mod + 1,+ (Int)(m_modSkirmishSides.size() - firstSide), count, teams, parsed ? "" : ", unreadable"));++ static_readModTeams.clear();+ for (Int i = 0; i < MAX_PLAYER_COUNT; ++i)+ {+ static_readPlayerNames[i].clear();+ static_readPlayerDicts[i].clear();+ }+ }+}++Int SidesList::skirmishSideFit(const AsciiString& candidateSide, Int candidateMod, const AsciiString& side, Int mod)+{+ if (candidateSide != side)+ return 0;+ if (candidateMod == mod)+ return 2;+ return candidateMod < 0 ? 1 : 0;+}++SidesInfo *SidesList::findSkirmishSideFor(const PlayerTemplate *pt, TeamsInfoRec **teams)+{+ const AsciiString side = pt->getSide();+ const Int mod = pt->getModIndex();+ SidesInfo *best = NULL;+ Int bestFit = 0;+ for (size_t i = 0; i < m_modSkirmishSides.size() && bestFit < 2; ++i)+ {+ const PlayerTemplate *spt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(m_modSkirmishSides[i].getDict()->getAsciiString(TheKey_playerFaction)));+ if (skirmishSideFit(spt->getSide(), spt->getModIndex(), side, mod) == 2)+ {+ best = &m_modSkirmishSides[i];+ bestFit = 2;+ if (teams)+ *teams = &m_modSkirmishTeamrec;+ }+ }+ for (Int i = 0; i < m_numSkirmishSides && bestFit < 2; ++i)+ {+ const PlayerTemplate *spt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(m_skirmishSides[i].getDict()->getAsciiString(TheKey_playerFaction)));+ const Int fit = spt ? skirmishSideFit(spt->getSide(), spt->getModIndex(), side, mod) : 0;+ if (fit > bestFit)+ {+ best = &m_skirmishSides[i];+ bestFit = fit;+ if (teams)+ *teams = &m_skirmishTeamrec;+ }+ }+ return best;+}+void SidesList::prepareForMP_or_Skirmish(void){m_skirmishTeamrec.clear();@@ -516,6 +743,7 @@ void SidesList::prepareForMP_or_Skirmish(void)gotScripts = true;}}+ loadModSkirmishScripts();if (!gotScripts) {AsciiString path = "data\\Scripts\\SkirmishScripts.scb";DEBUG_LOG(("Skirmish map using standard scripts\n"));@@ -555,6 +783,7 @@ void SidesList::prepareForMP_or_Skirmish(void)}for (i=0; i<MAX_PLAYER_COUNT; i++) {static_readPlayerNames[i].clear();+ static_readPlayerDicts[i].clear();}}@@ -586,18 +815,20 @@ void SidesList::emptySides(){Int i;- m_numSides = 0;- m_numSkirmishSides = 0;+ m_numSides = 0;+ m_numSkirmishSides = 0;for (i = 0; i < MAX_PLAYER_COUNT; i++) {- m_sides[i].clear();+ m_sides[i].clear();m_skirmishSides[i].clear();}+ m_modSkirmishSides.clear();}-void SidesList::emptyTeams()-{+void SidesList::emptyTeams()+{m_teamrec.clear();m_skirmishTeamrec.clear();+ m_modSkirmishTeamrec.clear();}void SidesList::addSide(const Dict* d)diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cppindex d606c2fea..26b40c675 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp@@ -1078,6 +1078,11 @@ void Object::setStatus( ObjectStatusMaskType objectStatus, Bool set )}+ // a hill hides the ground under an aircraft, not the aircraft, so taking off or landing in place+ // changes who sees it without touching a cell+ if( m_partitionData && m_status.test( OBJECT_STATUS_AIRBORNE_TARGET ) != oldStatus.test( OBJECT_STATUS_AIRBORNE_TARGET ) )+ m_partitionData->invalidateShroudedStatusForAllPlayers();+// when an object's construction status changes, it needs to have its partition data updated,// in order to maintain the shroud correctly.if( m_status.test( OBJECT_STATUS_UNDER_CONSTRUCTION ) != oldStatus.test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cppindex 370a466f1..1d60570fa 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/PartitionManager.cpp@@ -1262,6 +1262,7 @@ PartitionCell::PartitionCell()// Default is "passive shroud". 1,0.m_shroudLevel[i].m_currentShroud = 1;m_shroudLevel[i].m_activeShroudLevel = 0;+ m_airLookers[i] = 0;// default cash value is 0m_cashValue[i] = 0;@@ -1418,6 +1419,23 @@ void PartitionCell::removeShrouder( Int playerIndex )DEBUG_ASSERTCRASH( m_shroudLevel[playerIndex].m_activeShroudLevel >= 0, ("Shroud generation has gone negative. This can't happen.") );}+//-----------------------------------------------------------------------------+/** Only an aircraft reads the air count, and only where the ground is not in sight; the objects here+ think again whenever the air over a cell comes into sight or goes out of it. */+void PartitionCell::addAirLooker( Int playerIndex )+{+ if( m_airLookers[playerIndex]++ == 0 )+ invalidateShroudedStatusForAllCois( playerIndex );+}++//-----------------------------------------------------------------------------+void PartitionCell::removeAirLooker( Int playerIndex )+{+ DEBUG_ASSERTCRASH( m_airLookers[playerIndex] > 0, ("removeAirLooker on a cell nobody looks over") );+ if( --m_airLookers[playerIndex] == 0 )+ invalidateShroudedStatusForAllCois( playerIndex );+}+//-----------------------------------------------------------------------------//Bool PartitionCell::isShroudedForPlayer( Int playerIndex ) const//{@@ -1565,13 +1583,17 @@ void PartitionCell::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ // 2: m_airLookers+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );// xfer shroud dataxfer->xferUser( &m_shroudLevel, sizeof( ShroudLevel ) * MAX_PLAYER_COUNT );+ if( version >= 2 )+ xfer->xferUser( &m_airLookers, sizeof( m_airLookers ) );+} // end xfer// ------------------------------------------------------------------------------------------------@@ -1713,9 +1735,14 @@ ObjectShroudStatus PartitionData::getShroudedStatus(Int playerIndex)#endifInt shroudedCells = 0;Int foggedCells = 0;+ // a hill or a roof hides the ground behind it, not the aircraft flying over it: whoever it can+ // see and shoot at sees it back+ const Bool inTheAir = m_object && m_object->isAirborneTarget();CellAndObjectIntersection* coi = m_coiArray;for (Int i = m_coiInUseCount; i; --i, ++coi){+ if( inTheAir && coi->getCell()->isAirSeenByPlayer(playerIndex) )+ continue;if( coi->getCell()->getShroudStatusForPlayer(playerIndex) == CELLSHROUD_SHROUDED )++shroudedCells;else if( coi->getCell()->getShroudStatusForPlayer(playerIndex) == CELLSHROUD_FOGGED )@@ -4327,13 +4354,33 @@ static void hLineRecordedLooker( Int x1, Int x2, Int y, void *lookersVoid )continue;PartitionCell *cell = ThePartitionManager->getCellAt( x, y );- if( lookers->m_reveal )- cell->addLooker( lookers->m_playerIndex );- else- cell->removeLooker( lookers->m_playerIndex );+ if( revealed[ x ] & SIGHT_CELL_GROUND )+ {+ if( lookers->m_reveal )+ cell->addLooker( lookers->m_playerIndex );+ else+ cell->removeLooker( lookers->m_playerIndex );+ }+ if( revealed[ x ] & SIGHT_CELL_AIR )+ {+ if( lookers->m_reveal )+ cell->addAirLooker( lookers->m_playerIndex );+ else+ cell->removeAirLooker( lookers->m_playerIndex );+ }}}+//-----------------------------------------------------------------------------+UnsignedByte PartitionManager_sightCellFlags( Bool groundRevealed, Int offsetX, Int offsetY, Int flatCellRadius )+{+ // r * ( r + 1 ) rather than r squared, as for the ground: the Bresenham circle keeps every cell of it+ UnsignedByte flags = groundRevealed ? SIGHT_CELL_GROUND : 0;+ if( offsetX * offsetX + offsetY * offsetY <= flatCellRadius * ( flatCellRadius + 1 ) )+ flags |= SIGHT_CELL_AIR;+ return flags;+}+//-----------------------------------------------------------------------------static Int sightCellRadius( Real radius ){@@ -4454,18 +4501,19 @@ void PartitionManager::doBlockedShroudReveal( SightingInfo *sighting, const Obje// r * ( r + 1 ) rather than r squared: the circle the reveal is drawn with is a Bresenham one,// and on flat ground this has to keep every cell of itconst Bool stretched = sighting->m_howFar > flatRange;+ const Int flatCellRadius = sightCellRadius( flatRange );sighting->m_revealedCells.resize( side * side );for( Int cell = 0; cell < side * side; ++cell ){+ const Int offsetX = cell % side - cellRadius;+ const Int offsetY = cell / side - cellRadius;Bool revealed = sightMargin[ cell ] >= 0.0f;if( revealed && stretched ){- const Int offsetX = cell % side - cellRadius;- const Int offsetY = cell / side - cellRadius;const Int reachCells = sightCellRadius( Weapon_elevatedRange( looker, flatRange, heights[ cell ] ) );revealed = offsetX * offsetX + offsetY * offsetY <= reachCells * ( reachCells + 1 );}- sighting->m_revealedCells[ cell ] = revealed;+ sighting->m_revealedCells[ cell ] = PartitionManager_sightCellFlags( revealed, offsetX, offsetY, flatCellRadius );}applyRecordedReveal( sighting, TRUE );@@ -5806,6 +5854,10 @@ Bool PartitionFilterLineOfSight::allow(Object *objOther){// objOther is guaranteed to be non-null, so we don't need to check (srj)+ // a hill or a roof does not hide what flies over it (see Pathfinder::isAttackViewBlockedByObstacle)+ if (objOther->isSignificantlyAboveTerrain())+ return true;+if (!ThePartitionManager->isClearLineOfSightTerrain(m_obj, *m_obj->getPosition(), objOther, *objOther->getPosition()))return false;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/CleanupAreaPower.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/CleanupAreaPower.cppindex ded01c247..0f61985fa 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/CleanupAreaPower.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/CleanupAreaPower.cpp@@ -96,7 +96,7 @@ void CleanupAreaPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle,CleanupHazardUpdate *update = (CleanupHazardUpdate*)obj->findUpdateModule( key_CleanupHazardUpdate );if( update ){- update->setCleanupAreaParameters( loc, data->m_cleanupMoveRange );+ update->setCleanupAreaParameters( loc, data->m_cleanupMoveRange, TRUE );}else{diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cppindex 968952fde..8d4db3dbd 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cpp@@ -55,16 +55,46 @@//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")#endif-/** Scans in a row an area cleaner stands out of reach of its hazard before it gives the area up. */-static const Int MAX_CLEANUP_APPROACHES = 5;+/** Scans in a row an area cleaner stays out of reach of its hazard, standing about and getting no nearer+ to it, before it gives the area up. */+static const Int MAX_CLEANUP_APPROACHES = 8;++/** How much nearer to its hazard a scan has to find it to count as getting there, and how far it has to+ have driven since the last scan to count as on its way. */+static const Real CLEANUP_PROGRESS = 10.0f;+static const Real CLEANUP_DRIVEN = 20.0f;++/** How far round the hazard it gave up on it leaves the ground alone: a toxin field is many hazards, and+ remembering the one it gave up on, the next in the same field was gone for at once. The same reach+ makes the hazards of one field one target for the give-up count. */+static const Real GIVEN_UP_RADIUS = 150.0f;++/** One scan of an area cleaner out of reach of its hazard: whether it counts toward giving up. It does+ when the cleaner stands no CLEANUP_PROGRESS nearer than the nearest it had come and has driven under+ CLEANUP_DRIVEN since the last scan. One driving round a river or a cliff gets no nearer for a while+ but keeps moving; one at the pathfinder's nearest point to a hazard it cannot reach stands there.+ A nearer reading becomes the new nearest. Split out for the tests. */+Bool CleanupHazard_stalls( Real distance, Real driven, Real *closest )+{+ if( distance <= *closest - CLEANUP_PROGRESS )+ {+ *closest = distance;+ return FALSE;+ }+ return driven < CLEANUP_DRIVEN;+}-/** Every hazard but the one given up on. */+/** Every hazard but those on the ground given up on. */class PartitionFilterRejectGivenUp : public PartitionFilter{- ObjectID m_id;+ Bool m_any;+ Coord3D m_pos;public:- PartitionFilterRejectGivenUp( ObjectID id ) : m_id( id ) {}- virtual Bool allow( Object *objOther ) { return objOther->getID() != m_id; }+ PartitionFilterRejectGivenUp( Bool any, const Coord3D &pos ) : m_any( any ), m_pos( pos ) {}+ virtual Bool allow( Object *objOther )+ {+ return !m_any || sqr( objOther->getPosition()->x - m_pos.x ) + sqr( objOther->getPosition()->y - m_pos.y ) > sqr( GIVEN_UP_RADIUS );+ }#if defined(_DEBUG) || defined(_INTERNAL)virtual const char* debugGetName() { return "PartitionFilterRejectGivenUp"; }#endif@@ -108,8 +138,13 @@ CleanupHazardUpdate::CleanupHazardUpdate( Thing *thing, const ModuleData* modulem_resumeGuardMode = GUARDMODE_NORMAL;m_returning = FALSE;m_approaches = 0;+ m_approaching = FALSE;+ m_approachPos.zero();+ m_lastScanPos.zero();+ m_closestApproach = 0.0f;m_resumeGuardObject = INVALID_ID;- m_givenUpID = INVALID_ID;+ m_hasGivenUp = FALSE;+ m_givenUpPos.zero();}@@ -177,6 +212,7 @@ UpdateSleepTime CleanupHazardUpdate::update()m_resumeGuard = FALSE;m_returning = FALSE;m_approaches = 0;+ m_approaching = FALSE;return UPDATE_SLEEP_NONE;}}@@ -199,25 +235,43 @@ UpdateSleepTime CleanupHazardUpdate::update()if( found ){m_returning = FALSE;- // Cleaning an area: standing still out of the weapon's reach on a scan, scan after scan, is a hazard- // it cannot drive up to. It gives the area up rather than order the same drive for good, and does- // not go for that hazard again: noticed from home, it drove the same way for the hazard's lifetime.- // ponytail: one hazard remembered; two out of reach side by side would take turns- AIUpdateInterface *ai = obj->getAI();+ // Cleaning an area: out of the weapon's reach scan after scan, and no nearer, is a hazard it cannot+ // drive up to. It gives the area up rather than order the same drive for good, and does not go for+ // the ground round that hazard again: noticed from home, it drove the same way for the hazard's+ // lifetime. Counted by distance and by how far it drove since the last scan, not by the AI state:+ // fireWhenReady orders the drive again whenever it stops, so a scan nearly always found it moving+ // and the count never got anywhere. Counted for the ground, not the one hazard: the nearest of a+ // toxin field changes as it drives, and each change started the count overWeaponBonus bonus;bonus.clear();- if( m_moveRange > 0.0f && ai && (ai->isIdle() || ai->isBusy()) &&- ThePartitionManager->getDistanceSquared( obj, found, FROM_CENTER_2D ) > sqr( m_weaponTemplate->getAttackRange( bonus ) ) )+ const Real distance = (Real)sqrt( ThePartitionManager->getDistanceSquared( obj, found, FROM_CENTER_2D ) );+ if( m_moveRange > 0.0f && distance > m_weaponTemplate->getAttackRange( bonus ) ){- if( ++m_approaches > MAX_CLEANUP_APPROACHES )+ const Coord3D *at = found->getPosition();+ const Coord3D *here = obj->getPosition();+ if( !m_approaching || sqr( at->x - m_approachPos.x ) + sqr( at->y - m_approachPos.y ) > sqr( GIVEN_UP_RADIUS ) ){- m_givenUpID = found->getID();+ m_approaching = TRUE;+ m_approachPos = *at;+ m_closestApproach = distance;+ m_approaches = 0;+ }+ else if( !CleanupHazard_stalls( distance, (Real)sqrt( sqr( here->x - m_lastScanPos.x ) + sqr( here->y - m_lastScanPos.y ) ), &m_closestApproach ) )+ m_approaches = 0;+ else if( ++m_approaches > MAX_CLEANUP_APPROACHES )+ {+ m_hasGivenUp = TRUE;+ m_givenUpPos = *at;finishArea( "gave up on a hazard it cannot reach", TRUE );return UPDATE_SLEEP_NONE;}+ m_lastScanPos = *here;}else+ {m_approaches = 0;+ m_approaching = FALSE;+ }//1 frame can make a big difference so fire ASAP!fireWhenReady();}@@ -336,21 +390,16 @@ Object* CleanupHazardUpdate::scanClosestTarget()Object *bestTargetInRange = NULL;m_bestTargetID = INVALID_ID;- PartitionFilterAcceptByKindOf kindFilter(MAKE_KINDOF_MASK(KINDOF_CLEANUP_HAZARD), KINDOFMASK_NONE);- PartitionFilterSameMapStatus filterMapStatus(getObject());- PartitionFilterRejectGivenUp givenUpFilter( m_givenUpID );- PartitionFilter* filters[] = { &kindFilter, &filterMapStatus, &givenUpFilter, NULL };-if( m_moveRange > 0.0f ){//Look for targets around the target position only (but add scan range and move range).//This case only happens when we are performing a cleanup area command.- bestTargetInRange = ThePartitionManager->getClosestObject( &m_pos, data->m_scanRange + m_moveRange, FROM_CENTER_2D, filters );+ bestTargetInRange = closestHazard( &m_pos, data->m_scanRange + m_moveRange );}else{//Look for targets near me -- passive default.- bestTargetInRange = ThePartitionManager->getClosestObject( me->getPosition(), data->m_scanRange, FROM_CENTER_2D, filters );+ bestTargetInRange = closestHazard( me->getPosition(), data->m_scanRange );}if( bestTargetInRange )@@ -360,6 +409,25 @@ Object* CleanupHazardUpdate::scanClosestTarget()return bestTargetInRange;}+//-------------------------------------------------------------------------------------------------+Object* CleanupHazardUpdate::closestHazard( const Coord3D *from, Real range ) const+{+ PartitionFilterAcceptByKindOf kindFilter(MAKE_KINDOF_MASK(KINDOF_CLEANUP_HAZARD), KINDOFMASK_NONE);+ PartitionFilterSameMapStatus filterMapStatus(getObject());+ PartitionFilterRejectGivenUp givenUpFilter( m_hasGivenUp, m_givenUpPos );+ PartitionFilter* filters[] = { &kindFilter, &filterMapStatus, &givenUpFilter, NULL };+ return ThePartitionManager->getClosestObject( from, range, FROM_CENTER_2D, filters );+}++//-------------------------------------------------------------------------------------------------+/** The hazard it is shooting or driving at, or the middle of the area when it has none yet. */+void CleanupHazardUpdate::giveUpArea()+{+ const Object *target = TheGameLogic->findObjectByID( m_bestTargetID );+ m_givenUpPos = target ? *target->getPosition() : m_pos;+ m_hasGivenUp = TRUE;+}+//-------------------------------------------------------------------------------------------------/** The area is done with: back on guard if a cleanup it started took it off guard, otherwise out ofthe busy state the area kept it in, which has no way out of its own. Left busy, it never read as@@ -374,6 +442,7 @@ void CleanupHazardUpdate::finishArea( const char *why, Bool goHome )m_moveRange = 0.0f;m_returning = FALSE;m_approaches = 0;+ m_approaching = FALSE;if( m_resumeGuard ){m_resumeGuard = FALSE;@@ -418,11 +487,7 @@ void CleanupHazardUpdate::startAutoCleanup()if( obj->getControllingPlayer() && obj->getControllingPlayer()->isAIDutyAmbulance( obj ) )return;- PartitionFilterAcceptByKindOf kindFilter(MAKE_KINDOF_MASK(KINDOF_CLEANUP_HAZARD), KINDOFMASK_NONE);- PartitionFilterSameMapStatus filterMapStatus(obj);- PartitionFilterRejectGivenUp givenUpFilter( m_givenUpID );- PartitionFilter* filters[] = { &kindFilter, &filterMapStatus, &givenUpFilter, NULL };- if( !ThePartitionManager->getClosestObject( obj->getPosition(), data->m_scanRange + AUTO_CLEANUP_MOVE_RANGE, FROM_CENTER_2D, filters ) )+ if( !closestHazard( obj->getPosition(), data->m_scanRange + AUTO_CLEANUP_MOVE_RANGE ) )return;m_pos = *obj->getPosition();@@ -440,7 +505,7 @@ void CleanupHazardUpdate::startAutoCleanup()//-------------------------------------------------------------------------------------------------//This allows the unit to cleanup an area until clean, then the AI goes idle.//--------------------------------------------------------------------------------------------------void CleanupHazardUpdate::setCleanupAreaParameters( const Coord3D *pos, Real range )+void CleanupHazardUpdate::setCleanupAreaParameters( const Coord3D *pos, Real range, Bool forgetGivenUp ){Object *obj = getObject();AIUpdateInterface *ai = obj->getAI();@@ -452,7 +517,11 @@ void CleanupHazardUpdate::setCleanupAreaParameters( const Coord3D *pos, Real ranm_resumeGuard = FALSE;m_returning = FALSE;m_approaches = 0;- m_givenUpID = INVALID_ID; // sent on purpose, it tries every hazard there again+ m_approaching = FALSE;+ // a player sending it on purpose has it try every hazard there again; the computer's own orders pick+ // round the ground given up on (closestHazard), and forgetting it here walked the next one back to it+ if( forgetGivenUp )+ m_hasGivenUp = FALSE;if( ai ){@@ -479,13 +548,14 @@ void CleanupHazardUpdate::crc( Xfer *xfer )* Version Info:* 1: Initial version* 2: the guard a cleanup it started by itself gives back, the walk back, the drives toward a hazard- * 3: the object that guard was on, the hazard given up on */+ * 3: the object that guard was on, the hazard given up on+ * 4: the ground given up on instead of the one hazard, and the ground it is after with how near it has come */// ------------------------------------------------------------------------------------------------void CleanupHazardUpdate::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 3;+ XferVersion currentVersion = 4;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -521,9 +591,20 @@ void CleanupHazardUpdate::xfer( Xfer *xfer )xfer->xferInt( &m_approaches );}if( version >= 3 )- {xfer->xferObjectID( &m_resumeGuardObject );- xfer->xferObjectID( &m_givenUpID );+ if( version == 3 )+ {+ ObjectID givenUpID = INVALID_ID; // the one hazard version 3 remembered; its ground is not known+ xfer->xferObjectID( &givenUpID );+ }+ if( version >= 4 )+ {+ xfer->xferBool( &m_hasGivenUp );+ xfer->xferCoord3D( &m_givenUpPos );+ xfer->xferBool( &m_approaching );+ xfer->xferCoord3D( &m_approachPos );+ xfer->xferCoord3D( &m_lastScanPos );+ xfer->xferReal( &m_closestApproach );}} // end xferdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cppindex 08e7419f0..a8528b24c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp@@ -233,6 +233,9 @@ ProductionUpdate::~ProductionUpdate( void )//-------------------------------------------------------------------------------------------------CanMakeType ProductionUpdate::canQueueUpgrade( const UpgradeTemplate *upgrade ) const{+ if( !canResearchWithStatus( getObject()->getStatusBits() ) )+ return CANMAKE_FACTORY_IS_DISABLED;+if (m_productionCount >= getProductionUpdateModuleData()->m_maxQueueEntries)return CANMAKE_QUEUE_FULL;@@ -273,6 +276,10 @@ Bool ProductionUpdate::queueUpgrade( const UpgradeTemplate *upgrade )if( upgrade == NULL )return FALSE;+ // every path lands here (command bar, scripts, AI, a forged message), so refuse it here+ if( !canResearchWithStatus( getObject()->getStatusBits() ) )+ return FALSE;+// get the playerPlayer *player = getObject()->getControllingPlayer();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cppindex 6117aaa43..095c566ac 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp@@ -1933,7 +1933,14 @@ void WeaponStore::postProcessLoad()}else{- DEBUG_CRASH(("Weapon '%s' already exists, but OVERRIDE not specified", c));+ /* The first definition stands and the block is read and dropped. WeaponReforged.ini keeps+ copies of EA weapons FixesReforged.ini hands out, for a mod whose Weapon.ini leaves them out+ (Contra has no Demo_DestroyedWeapon); where the loaded data has the weapon, its own wins.+ This used to return mid-block, and the next field line stopped the load as an unknown block. */+ DEBUG_LOG(("[LINE: %d in '%s'] Weapon '%s' is already defined; the block is skipped.\n", ini->getLineNum(), ini->getFilename().str(), c));+ WeaponTemplate *scratch = newInstance(WeaponTemplate);+ ini->initFromINI(scratch, scratch->getFieldParse());+ scratch->deleteInstance();return;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cppindex 02d9b0dcd..1d6809b31 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/WeaponSet.cpp@@ -105,6 +105,7 @@ void WeaponTemplateSet::clear(){m_isReloadTimeShared = false;m_isWeaponLockSharedAcrossSets = FALSE;+ m_namesMissingWeapon = FALSE;m_types.clear();for (int i = 0; i < WEAPONSLOT_COUNT; ++i){@@ -130,7 +131,11 @@ void WeaponTemplateSet::parseWeapon(INI* ini, void *instance, void * /*store*/,{WeaponTemplateSet* self = (WeaponTemplateSet*)instance;WeaponSlotType wslot = (WeaponSlotType)INI::scanIndexList(ini->getNextToken(), TheWeaponSlotTypeNames);- INI::parseWeaponTemplate(ini, instance, &self->m_template[wslot], NULL);+ const char *name = ini->getNextToken();+ self->m_template[wslot] = TheWeaponStore->findWeaponTemplate(name);+ // ThingTemplate::parseWeaponTemplateSet passes over a patch file's set that names a weapon a mod dropped+ if (self->m_template[wslot] == NULL && strcasecmp(name, "None") != 0)+ self->m_namesMissingWeapon = TRUE;}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cppindex e8633ff32..04d0be4ca 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/ScriptActions.cpp@@ -7049,8 +7049,12 @@ void ScriptActions::executeAction( ScriptAction *pAction )}else{- // the map asks for a 30 Hz logic rate; 30 is normal speed- TheGameEngine->setFramesPerSecondLimit(ConvertRetailFrames(pAction->getParameter(0)->getInt()));+ // the map asks for a 30 Hz logic rate; 30 is normal speed. A mission or skirmish map gets+ // half speed to normal like the player does, never faster+ Int fps = ConvertRetailFrames(pAction->getParameter(0)->getInt());+ if (TheGameLogic->isInSkirmishGame() || TheGameLogic->isInSinglePlayerGame())+ fps = ClampPlayerGameSpeed(fps);+ TheGameEngine->setFramesPerSecondLimit(fps);}// Setting the fps limit doesn't do much good if we don't use it. jba.TheWritableGlobalData->m_useFpsLimit = true;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 4c134278a..d2c7811ef 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -56,6 +56,7 @@#include <algorithm>#include <map>+#include <set>#include <vector>// ------------------------------------------------------------------------------------------------@@ -66,6 +67,16 @@ static const Int SCENARIO_MAX_TOKENS = 10;static const char SCENARIO_COMMENT_CHAR = '#';static const char *SCENARIO_SELECTOR_ALL = "*";+/// a target seat written "civilian": the map's own buildings, which no -side seat owns. The match+/// nearest the ordered group is taken, since a map has many of each (Fallen Empire's wall towers).+static const char *SCENARIO_CIVILIAN_TOKEN = "civilian";+static const Int SCENARIO_CIVILIAN_SLOT = -1;++/// every object a civilian-seat lookup has seen owned by the map (the neutral or the civilian+/// player): a garrisoned building changes hands to its occupants, so "owned by the map now" would+/// lose a wall tower the moment it fills+static std::set<ObjectID> theCivilianObjects;+/// how far apart spawned units stand, when the line does not saystatic const Real SCENARIO_DEFAULT_SPACING = 30.0f;@@ -216,6 +227,8 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio*action = SCENARIO_ACTION_STANCE;else if (token == "forceattack")*action = SCENARIO_ACTION_FORCEATTACK;+ else if (token == "clickenter")+ *action = SCENARIO_ACTION_CLICKENTER;else if (token == "weaponat")*action = SCENARIO_ACTION_WEAPONAT;else if (token == "forceground")@@ -315,6 +328,7 @@ static Int tokensNeededFor( ScenarioActionType action )case SCENARIO_ACTION_STANCE: return SCENARIO_TOKENS_STANCE;case SCENARIO_ACTION_SHIFTATTACK: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_FORCEATTACK: return SCENARIO_TOKENS_ATTACK;+ case SCENARIO_ACTION_CLICKENTER: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_SHIFTPOWER: return SCENARIO_TOKENS_SHIFTPOWER;case SCENARIO_ACTION_SHIFTUPGRADE: return SCENARIO_TOKENS_SHIFTUPGRADE;case SCENARIO_ACTION_ATTACK: return SCENARIO_TOKENS_ATTACK;@@ -425,9 +439,12 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *acase SCENARIO_ACTION_GUARD:case SCENARIO_ACTION_SHIFTATTACK:case SCENARIO_ACTION_FORCEATTACK:+ case SCENARIO_ACTION_CLICKENTER:case SCENARIO_ACTION_SHIFTPOWER:{- if (!parseWholeNumber( tokens[ 4 ], &action->targetSlot ))+ if (tokens[ 4 ] == SCENARIO_CIVILIAN_TOKEN)+ action->targetSlot = SCENARIO_CIVILIAN_SLOT;+ else if (!parseWholeNumber( tokens[ 4 ], &action->targetSlot ))return SCENARIO_PARSE_BAD_SLOT;action->targetSelector = tokens[ 5 ];if (actionType == SCENARIO_ACTION_SHIFTPOWER)@@ -558,6 +575,7 @@ static void resetScenario( void )theScenarioActionsRun = 0;theScenarioActionsFailed = 0;theScenarioUnitsSpawned = 0;+ theCivilianObjects.clear();}/** Sorted by frame, and stable so two actions on the same frame keep the order the file wrote@@ -645,6 +663,9 @@ static void loadScenario( void )when the game started, so ask it rather than carrying an offset around. */static Player *findPlayerForSlot( Int slot ){+ if (slot == SCENARIO_CIVILIAN_SLOT)+ return ThePlayerList->findPlayerWithNameKey( NAMEKEY( "PlyrCivilian" ) );+for( Int i = 0; i < ThePlayerList->getPlayerCount(); ++i ){if (ThePlayerList->getSlotIndex( i ) == slot)@@ -729,6 +750,37 @@ static Object *findFirstMatching( Player *player, const AsciiString &selector )return NULL;}+/** Of the objects the map owns now or owned at an earlier lookup, the living match nearest the+ point, whoever holds it now. A skirmish has no PlyrCivilian seat everywhere, and the map's+ buildings can sit with the neutral player instead, so both count. */+static Object *findNearestCivilian( const AsciiString &selector, const Coord3D *point )+{+ const Player *neutral = ThePlayerList->getNeutralPlayer();+ const Player *civilian = findPlayerForSlot( SCENARIO_CIVILIAN_SLOT );+ for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() )+ {+ const Player *owner = obj->getControllingPlayer();+ if (owner != NULL && (owner == neutral || owner == civilian))+ theCivilianObjects.insert( obj->getID() );+ }++ Object *nearest = NULL;+ Real best = 0.0f;+ for( std::set<ObjectID>::const_iterator it = theCivilianObjects.begin(); it != theCivilianObjects.end(); ++it )+ {+ Object *obj = TheGameLogic->findObjectByID( *it );+ if (obj == NULL || obj->isEffectivelyDead() || !selectorMatches( selector, obj ))+ continue;+ const Real distance = ThePartitionManager->getDistanceSquared( obj, point, FROM_CENTER_2D );+ if (nearest == NULL || distance < best)+ {+ nearest = obj;+ best = distance;+ }+ }+ return nearest;+}+/** The recipe the debug spawn path uses (GameLogic.cpp's unitTimings): a template's onCreate ran inthe constructor, but a unit that was never built still has to be told it is finished, or halfits modules never start. The team has to be activated too, or it counts as an empty team.@@ -1281,8 +1333,10 @@ static Bool executePower( const ScenarioAction &action, Player *player, const Coif (obj->isDisabled()){- DEBUG_LOG(("SCENARIO: frame %d power: '%s' is disabled (no power?)\n",- action.frame, action.selector.str()));+ // the seat's whole grid, since one building that draws more than its plants make is the usual cause+ DEBUG_LOG(("SCENARIO: frame %d power: '%s' is disabled (underpowered %d: seat makes %d, draws %d)\n",+ action.frame, action.selector.str(), (Int)obj->isDisabledByType( DISABLED_UNDERPOWERED ),+ player->getEnergy()->getProduction(), player->getEnergy()->getConsumption()));return FALSE;}@@ -1536,6 +1590,44 @@ static Bool executeForceAttack( const ScenarioAction &action, Player *player, AIreturn TRUE;}+/** A player's click on a building or transport with the matching units selected: MSG_ENTER handed to+ the dispatcher, so the order carries CMD_FROM_PLAYER and meets the checks a human's does, where+ enter is a script's order. */+static Bool executeClickEnter( const ScenarioAction &action, Player *player, AIGroup *group, Int taken )+{+ Object *target = NULL;+ if (action.targetSlot == SCENARIO_CIVILIAN_SLOT)+ {+ Coord3D center;+ group->getCenter( ¢er );+ target = findNearestCivilian( action.targetSelector, ¢er );+ }+ else+ {+ Player *targetPlayer = findPlayerForSlot( action.targetSlot );+ target = (targetPlayer != NULL) ? findFirstMatching( targetPlayer, action.targetSelector ) : NULL;+ }+ if (target == NULL)+ {+ DEBUG_LOG(("SCENARIO: frame %d clickenter: slot %d owns nothing matching '%s'\n",+ action.frame, action.targetSlot, action.targetSelector.str()));+ TheAI->destroyGroup( group );+ return FALSE;+ }++ GameMessage *msg = newInstance( GameMessage )( GameMessage::MSG_ENTER );+ msg->friend_setPlayerIndex( player->getPlayerIndex() );+ msg->appendObjectIDArgument( INVALID_ID ); // the selection, as the click sends it+ msg->appendObjectIDArgument( target->getID() );+ TheGameLogic->logicMessageDispatcher( msg, group );+ msg->deleteInstance();++ DEBUG_LOG(("SCENARIO: frame %d clickenter slot %d '%s' x%d -> slot %d '%s' %d\n",+ action.frame, action.slot, action.selector.str(), taken, action.targetSlot,+ action.targetSelector.str(), target->getID()));+ return TRUE;+}+/** A FIRE_WEAPON button with NEED_TARGET_POS, clicked on the ground (the Comanche's rocket pods): thearguments GUICommandTranslator gives MSG_DO_WEAPON_AT_LOCATION, the button's default shot count andnothing under the cursor, handed to the dispatcher with the matching units as the selection. The@@ -1609,10 +1701,18 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Coconst char *verb = (action.action == SCENARIO_ACTION_ATTACK) ? "attack": (action.action == SCENARIO_ACTION_DOCK) ? "dock": (action.action == SCENARIO_ACTION_GUARD) ? "guard" : "enter";- Player *targetPlayer = findPlayerForSlot( action.targetSlot );- Object *target = (targetPlayer != NULL)- ? findFirstMatching( targetPlayer, action.targetSelector )- : NULL;+ Object *target = NULL;+ if (action.targetSlot == SCENARIO_CIVILIAN_SLOT)+ {+ Coord3D center;+ group->getCenter( ¢er );+ target = findNearestCivilian( action.targetSelector, ¢er );+ }+ else+ {+ Player *targetPlayer = findPlayerForSlot( action.targetSlot );+ target = (targetPlayer != NULL) ? findFirstMatching( targetPlayer, action.targetSelector ) : NULL;+ }if (target == NULL){DEBUG_LOG(("SCENARIO: frame %d %s: slot %d owns nothing matching '%s'\n",@@ -1649,6 +1749,9 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Cocase SCENARIO_ACTION_FORCEATTACK:return executeForceAttack( action, player, group, taken ); // so does this, or it does itself+ case SCENARIO_ACTION_CLICKENTER:+ return executeClickEnter( action, player, group, taken ); // the dispatcher again+case SCENARIO_ACTION_WEAPONAT:return executeWeaponAt( action, player, dest, group, taken ); // the dispatcher againdiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cppindex 4dcefd47b..a225ed3f1 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp@@ -4263,6 +4263,19 @@ void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera )transform.Look_At( focus + toSun * sunDistance, focus, 0.0f );halfWidth = shadowMapHalfWidth( sceneCamera, transform, lowestReceiver,TheTerrainRenderObject->getMaxHeight() );+ /* The box's depth has to hold the ground its width holds. Level ground a distance across the+ box toward or away from the sun sits that distance times the sun's cotangent nearer or further+ along the ray, so a box opened for the zoom with a low sun put the top of the screen past the+ far plane, lit, and clipped the casters at the near one. The usual depth stays wherever it+ already covers that. Aircraft above the highest ground count, as in wholeMapSunBox, and the+ sun is held where the frame's caster cull stops sweeping, so a very low sun deepens the box+ rather than cutting it short. */+ const Real horizontal = WWMath::Sqrt( toSun.X * toSun.X + toSun.Y * toSun.Y );+ const Real along = (halfWidth * horizontal + TheTerrainRenderObject->getMaxHeight()+ + SHADOW_MAP_WHOLE_MAP_HEADROOM - lowestReceiver) / WWMath::Max( toSun.Z, 0.01f )+ + SHADOW_MAP_WHOLE_MAP_DEPTH_MARGIN;+ sunDistance = WWMath::Max( SHADOW_MAP_SUN_DISTANCE, along + SHADOW_MAP_NEAR_CLIP );+ farClip = sunDistance + WWMath::Max( SHADOW_MAP_FAR_CLIP - SHADOW_MAP_SUN_DISTANCE, along );}CameraClass sun;@@ -4273,14 +4286,20 @@ void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera )/* The box has to sit on whole texels of its own map, or every scroll of the camera slides thegrid under the world by a fraction of a texel and every shadow edge crawls and sparkles. Thelook point is taken into the sun's own frame, rounded to the texel it lands in, and taken back- out: the box then moves in texel steps and a shadow that did not move does not shimmer. */+ out: the box then moves in texel steps and a shadow that did not move does not shimmer. The+ frame it is rounded in has to stay put in the world. Rounded in the box's own frame, which is+ centred on the look point, the look point is always at zero and rounds to itself: the grid+ slid on every scroll all the same. The sun's frame on the world's origin turns the same way,+ since only the sun's direction decides that, and holds still. */const Real texelWidth = (2.0f * halfWidth) / (Real)texels;+ Matrix3D sunAtOrigin;+ sunAtOrigin.Look_At( toSun, Vector3( 0.0f, 0.0f, 0.0f ), 0.0f );Vector3 focusInSun;- Matrix3D::Inverse_Transform_Vector( transform, focus, &focusInSun );+ Matrix3D::Inverse_Transform_Vector( sunAtOrigin, focus, &focusInSun );focusInSun.X = WWMath::Floor( focusInSun.X / texelWidth + 0.5f ) * texelWidth;focusInSun.Y = WWMath::Floor( focusInSun.Y / texelWidth + 0.5f ) * texelWidth;Vector3 snapped;- Matrix3D::Transform_Vector( transform, focusInSun, &snapped );+ Matrix3D::Transform_Vector( sunAtOrigin, focusInSun, &snapped );transform.Look_At( snapped + toSun * sunDistance, snapped, 0.0f );sun.Set_Transform( transform );@@ -4439,12 +4458,10 @@ void W3DVolumetricShadowManager::renderShadowMap( CameraClass &sceneCamera )an orthographic projection puts depth on a straight line. */const Real worldPerTexel = texelWidth;const Real unitsPerUnitOfDepth = farClip - SHADOW_MAP_NEAR_CLIP;- /* The bias is a share of that range, picked for the usual 3990 units. The freecam's deeper box- would stretch it to tens of units and lift every shadow off its caster, so it is held at the- same distance in the world: six units. */- const Real depthBias = wholeMap- ? SHADOW_MAP_DEPTH_BIAS * (SHADOW_MAP_FAR_CLIP - SHADOW_MAP_NEAR_CLIP) / unitsPerUnitOfDepth- : SHADOW_MAP_DEPTH_BIAS;+ /* The bias is a share of that range, picked for the usual 3990 units. The freecam's deeper box,+ or the usual one deepened for a low sun, would stretch it to tens of units and lift every+ shadow off its caster, so it is held at the same distance in the world: six units. */+ const Real depthBias = SHADOW_MAP_DEPTH_BIAS * (SHADOW_MAP_FAR_CLIP - SHADOW_MAP_NEAR_CLIP) / unitsPerUnitOfDepth;// -shadowtune overrules any of the four that it was given; a zero leaves the build's own.const Real penumbra = (TheGlobalData->m_shadowMapPenumbra > 0.0f)diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cppindex 162c426fa..cdb5f319f 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameLogic/W3DGhostObject.cpp@@ -376,7 +376,7 @@ void W3DGhostObject::snapShot(int playerIndex)m_parentSnapshots[playerIndex]=snap;}else- m_parentSnapshots[playerIndex]->update(robj, &m_drawableInfo);+ snap->update(robj, &m_drawableInfo);// the model name keeps the mod prefix the robj's name drops, so a save reloads the mod's artcopyModPrefix(snap->m_modPrefix, w3dDraw->getCurrentModelName().str());diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.hindex 5ba8c986e..ebde6d3cd 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/ffshader.h@@ -171,7 +171,7 @@ const unsigned NORMAL_MAPPED_LIGHTS = 4;" keeps only what the slope across one pixel needs. Pull the camera back and that slope\n" \" grows, which is the case a fixed bias cannot cover. */\n" \" float3 surface = normalize(cross(ddx(sun.xyz), ddy(sun.xyz)));\n" \- " map += surface.xy * texel * ShadowParameters.y * 400.0;\n" \+ " map += surface.xy * texel * 0.6;\n" \" float slope = max(abs(ddx(sun.z)), abs(ddy(sun.z)));\n" \" float bias = ShadowParameters.y * 0.35 + slope * 1.5;\n" \" float widest = ShadowParameters.w;\n" \diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 640ab5756..07c58c0ea 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -678,6 +678,206 @@ TEST(balance_patch_edits_a_weapon_in_place)remove( TEST_INI );}+#include "../Stubs/NullAudioManager.h"++/* The Paladin's infantry laser, the second point defense module BalanceReforged.ini gives it, once+ borrowed EA's WatchTowerMachineGun. Contra's Weapon.ini leaves that weapon out, the MULTIFILE+ block for it was dropped as the test above wants, the module got a null template and+ PointDefenseLaserUpdate::scanClosestTarget crashed on it. The weapon is the fork's own now, in+ WeaponReforged.ini, loaded the way GameEngine::init loads it: it has to come out whole from a+ store that holds none of EA's weapons, which is what a mod's Weapon.ini can leave. */+TEST(weapon_reforged_ini_makes_the_paladin_infantry_laser_without_eas_weapons)+{+ CHECK( bootOnce() );++ if( TheWeaponStore == NULL )+ TheWeaponStore = NEW WeaponStore;+ if( TheFXListStore == NULL )+ TheFXListStore = NEW FXListStore;++ /* the fire FX the weapon names; retail has it, Contra does not, and a missing one reads as none */+ writeFile( TEST_INI,+ "FXList WeaponFX_PaladinPointDefenseLaser\r\n"+ "End\r\n" );+ CHECK( loadIni( TEST_INI ) );+ remove( TEST_INI );++ CHECK( TheWeaponStore->findWeaponTemplate( "WatchTowerMachineGun" ) == NULL );++ /* EA's death weapons in the file carry a FireSound, which the parser looks up in TheAudio: the+ silent device answers with an empty event table, as the game's would for a sound it lacks */+ AudioManager *savedAudio = TheAudio;+ if( savedAudio == NULL )+ TheAudio = NEW NullAudioManager;++ Bool threw = FALSE;+ try+ {+ INI ini;+ ini.load( AsciiString( WEAPON_REFORGED_INI ), INI_LOAD_OVERWRITE, NULL );+ }+ catch( ... )+ {+ threw = TRUE;+ }+ CHECK( threw == FALSE );++ if( savedAudio == NULL )+ {+ delete TheAudio;+ TheAudio = NULL;+ }++ const WeaponTemplate *laser = TheWeaponStore->findWeaponTemplate( "Reforged_PaladinInfantryLaser" );+ CHECK( laser != NULL );+ if( laser == NULL )+ return;+ WeaponBonus noBonus;+ CHECK_NEAR( laser->getPrimaryDamage( noBonus ), 100.0f, 0.01f );+ CHECK_NEAR( laser->getUnmodifiedAttackRange(), 65.0f, 0.01f );+ CHECK_EQ( laser->getClipSize(), 2 );+ CHECK_STR( laser->getLaserName().str(), "PointDefenseLaserBeam" );+}++/* WeaponReforged.ini also keeps copies of EA weapons FixesReforged.ini hands out, under EA's names,+ for a mod whose Weapon.ini dropped them. Where the weapon is already defined the copy is read and+ dropped and the first definition stands; this used to return mid-block, and the next field line+ threw as an unknown block. */+TEST(weapon_defined_twice_keeps_the_first_and_reads_on)+{+ CHECK( bootOnce() );++ if( TheWeaponStore == NULL )+ TheWeaponStore = NEW WeaponStore;++ writeFile( TEST_INI,+ "Weapon TwiceDefinedProbeGun\r\n"+ " PrimaryDamage = 60.0\r\n"+ "End\r\n" );+ CHECK( loadIni( TEST_INI ) );++ writeFile( TEST_INI,+ "Weapon TwiceDefinedProbeGun\r\n"+ " PrimaryDamage = 5.0\r\n"+ " AttackRange = 999.0\r\n"+ "End\r\n"+ "Weapon TwiceDefinedProbeGunAfter\r\n"+ " PrimaryDamage = 7.0\r\n"+ "End\r\n" );+ CHECK( loadIni( TEST_INI ) );++ WeaponBonus noBonus;+ const WeaponTemplate *first = TheWeaponStore->findWeaponTemplate( "TwiceDefinedProbeGun" );+ CHECK( first != NULL );+ if( first != NULL )+ CHECK_NEAR( first->getPrimaryDamage( noBonus ), 60.0f, 0.01f );+ const WeaponTemplate *after = TheWeaponStore->findWeaponTemplate( "TwiceDefinedProbeGunAfter" );+ CHECK( after != NULL );+ if( after != NULL )+ CHECK_NEAR( after->getPrimaryDamage( noBonus ), 7.0f, 0.01f );++ remove( TEST_INI );+}++#include "GameLogic/ArmorSet.h"++/* FixesReforged.ini's Toxin Tunnel Defender and Stinger sets name EA's Chem_ rockets and its Ranger+ armor set names ChemSuitHumanArmor; Contra keeps those objects and drops the weapons and the armor.+ Applied anyway, the set left a null in each slot: Contra's two went unarmed and its Rangers took+ every hit at full damage after Chemical Suits. A patch set naming a missing weapon or armor is+ skipped now and the object keeps its own; a set that names what exists still applies. */+TEST(patch_set_naming_a_missing_weapon_or_armor_is_skipped)+{+ CHECK( bootOnce() );++ GlobalData *savedGlobals = TheWritableGlobalData;+ if( savedGlobals == NULL )+ TheWritableGlobalData = NEW GlobalData;+ if( TheModuleFactory == NULL )+ {+ TheModuleFactory = NEW ModuleFactory;+ TheModuleFactory->init();+ }+ if( TheThingFactory == NULL )+ TheThingFactory = NEW ThingFactory;+ if( TheWeaponStore == NULL )+ TheWeaponStore = NEW WeaponStore;+ if( TheArmorStore == NULL )+ TheArmorStore = NEW ArmorStore;++ writeFile( TEST_INI,+ "Weapon MissingSetProbeGunA\r\n"+ " PrimaryDamage = 10.0\r\n"+ "End\r\n"+ "Weapon MissingSetProbeGunB\r\n"+ " PrimaryDamage = 20.0\r\n"+ "End\r\n"+ "Armor MissingSetProbeArmor\r\n"+ " Armor = SMALL_ARMS 50%\r\n"+ "End\r\n"+ "Object MissingSetProbe\r\n"+ " WeaponSet\r\n"+ " Conditions = None\r\n"+ " Weapon = PRIMARY MissingSetProbeGunA\r\n"+ " End\r\n"+ " ArmorSet\r\n"+ " Conditions = None\r\n"+ " Armor = MissingSetProbeArmor\r\n"+ " End\r\n"+ "End\r\n" );+ CHECK( loadIni( TEST_INI ) );++ writeFile( TEST_INI,+ "Object MissingSetProbe\r\n"+ " WeaponSet\r\n"+ " Conditions = None\r\n"+ " Weapon = PRIMARY MissingSetProbeGunNotDefined\r\n"+ " End\r\n"+ " WeaponSet\r\n"+ " Conditions = PLAYER_UPGRADE\r\n"+ " Weapon = PRIMARY MissingSetProbeGunB\r\n"+ " End\r\n"+ " ArmorSet\r\n"+ " Conditions = None\r\n"+ " Armor = MissingSetProbeArmorNotDefined\r\n"+ " End\r\n"+ "End\r\n" );+ Bool threw = FALSE;+ try+ {+ INI patch;+ patch.load( AsciiString( TEST_INI ), INI_LOAD_MULTIFILE, NULL );+ }+ catch( ... )+ {+ threw = TRUE;+ }+ CHECK( threw == FALSE );++ const ThingTemplate *probe = TheThingFactory->findTemplate( "MissingSetProbe" );+ CHECK( probe != NULL );+ if( probe != NULL )+ {+ const WeaponTemplateSetVector &sets = probe->getWeaponTemplateSets();+ CHECK_EQ( (Int)sets.size(), 2 );+ CHECK( sets[ 0 ].getNth( PRIMARY_WEAPON ) == TheWeaponStore->findWeaponTemplate( "MissingSetProbeGunA" ) );+ CHECK( sets[ 1 ].getNth( PRIMARY_WEAPON ) == TheWeaponStore->findWeaponTemplate( "MissingSetProbeGunB" ) );++ ArmorSetFlags none;+ const ArmorTemplateSet *armor = probe->findArmorTemplateSet( none );+ CHECK( armor != NULL );+ if( armor != NULL )+ CHECK( armor->getArmorTemplate() == TheArmorStore->findArmorTemplate( "MissingSetProbeArmor" ) );+ }++ remove( TEST_INI );+ if( savedGlobals == NULL )+ {+ delete TheWritableGlobalData;+ TheWritableGlobalData = NULL;+ }+}+/* BalanceReforged.ini replaces Tank_ChinaBunker's ModuleTag_05 with a StructureBody. Under theShockwave mod that tag holds another module, and the type check in ThingTemplate::parseModuleNamethrew and stopped the game at start. The block is skipped now: the template keeps the module it@@ -2221,6 +2421,23 @@ TEST(bitflags_types_keep_their_own_name_tables)CHECK_EQ( ModelConditionFlags::getSingleBitFromName("RUBBLE"), (Int)MODELCONDITION_RUBBLE );}+/* Selecting a finished Cold Fusion Reactor with ones still going up let the control rods be+ bought on the unfinished ones too. ProductionUpdate now refuses research on a building that+ is under construction or being sold, and the command bar greys the button the same way. */+TEST(no_upgrade_research_on_unfinished_or_sold_buildings)+{+ ObjectStatusMaskType status;+ CHECK( canResearchWithStatus( status ) );+ status.set( OBJECT_STATUS_UNDER_CONSTRUCTION );+ CHECK( !canResearchWithStatus( status ) );+ status.set( OBJECT_STATUS_UNDER_CONSTRUCTION, 0 );+ status.set( OBJECT_STATUS_SOLD );+ CHECK( !canResearchWithStatus( status ) );+ status.set( OBJECT_STATUS_SOLD, 0 );+ status.set( OBJECT_STATUS_RECONSTRUCTING );+ CHECK( canResearchWithStatus( status ) );+}+/* GameWindowManager.cpp: destroying a modal window that is not the top of the modal stackused to leave its entry behind, holding a pointer to freed memory. */#include "GameClient/GameWindow.h"@@ -4037,6 +4254,18 @@ TEST(controlbar_seconds_round_up_and_never_reach_zero_early)CHECK_EQ( ControlBar_secondsFromFrames( 1.0f ), 1 );}+TEST(player_game_speed_is_half_to_normal)+{+ /* A skirmish or mission runs from half speed to normal and never faster: the menu, the console,+ a saved game and a map script all clamp to this. An old x2 preference or save comes back at x1. */+ CHECK_EQ( ClampPlayerGameSpeed( LOGICFRAMES_PER_SECOND * 2 ), LOGICFRAMES_PER_SECOND );+ CHECK_EQ( ClampPlayerGameSpeed( LOGICFRAMES_PER_SECOND * 3 / 2 ), LOGICFRAMES_PER_SECOND );+ CHECK_EQ( ClampPlayerGameSpeed( LOGICFRAMES_PER_SECOND ), LOGICFRAMES_PER_SECOND );+ CHECK_EQ( ClampPlayerGameSpeed( LOGICFRAMES_PER_SECOND * 3 / 4 ), LOGICFRAMES_PER_SECOND * 3 / 4 );+ CHECK_EQ( ClampPlayerGameSpeed( LOGICFRAMES_PER_SECOND / 2 ), LOGICFRAMES_PER_SECOND / 2 );+ CHECK_EQ( ClampPlayerGameSpeed( ConvertRetailFrames( 5 ) ), LOGICFRAMES_PER_SECOND / 2 );+}+TEST(controlbar_seconds_are_real_seconds_at_the_current_game_speed){/* The number on a build button is a promise about how long you will be waiting, and the logic@@ -7769,6 +7998,20 @@ TEST(a_unit_does_not_see_over_a_hill)CHECK( sightMargin[ middleRow + side - 1 ] >= 0.0f );}+/** A Comanche hovering behind a hill shot at tanks that could not see it. The hill hides the ground+ behind it, never the air over it: inside the looker's flat range the air is in sight wherever the+ ground is not, and past that range neither is. */+TEST(a_hill_hides_the_ground_behind_it_not_the_aircraft_over_it)+{+ CHECK( PartitionManager_sightCellFlags( FALSE, 3, 0, 4 ) == SIGHT_CELL_AIR );+ CHECK( PartitionManager_sightCellFlags( TRUE, 3, 0, 4 ) == ( SIGHT_CELL_GROUND | SIGHT_CELL_AIR ) );+ CHECK( PartitionManager_sightCellFlags( FALSE, 4, 2, 4 ) == SIGHT_CELL_AIR );+ CHECK( PartitionManager_sightCellFlags( FALSE, 5, 0, 4 ) == 0 );++ // high ground stretches the ground sight past the flat range; the air stays at the flat range+ CHECK( PartitionManager_sightCellFlags( TRUE, 6, 0, 4 ) == SIGHT_CELL_GROUND );+}+/** Since the plan reveals nothing, the fog it was placed in would swallow it - and there would benothing left on screen to click on and cancel. Your own plan is drawn through the fog; anythingelse fogged, including an enemy's, is still hidden. */@@ -11197,21 +11440,48 @@ TEST(the_ai_buys_ambulances_by_army_and_calls_in_the_hurt_nearby)CHECK( !AIAmbulance_callsPatient( 0.3f, 100.0f, quiet - 1 ) );}-/** AIPlayer.cpp: an Ambulance pulls back when shot at or inside a known gun's reach, and a lost one is- replaced only after a wait. */-extern Bool AIAmbulance_pullsBack( UnsignedInt now, UnsignedInt lastHit, Bool inGunReach );+/** AIPlayer.cpp: an Ambulance keeps clear of known guns by a margin scaled to the map, pulls back when+ shot at or within it, only ever to clearer ground, and a lost one is replaced only after a wait. */+extern Real AIAmbulance_gunMargin( Real baseDistance, Int skill );+extern Bool AIAmbulance_pullsBack( UnsignedInt now, UnsignedInt lastHit, Real clear, Real margin, Int skill );+extern Bool AIAmbulance_movesBack( Real hereClear, Real spotClear, Bool hitSinceLook );+extern Bool AIAmbulance_waitsAt( Real hereClear, Real spotClear, Real margin );extern Bool AIAmbulance_rebuyWaits( UnsignedInt now, UnsignedInt lost, Int skill );TEST(the_ai_ambulance_pulls_back_when_hit_and_is_not_rebought_at_once){- CHECK( AIAmbulance_pullsBack( 1000, 0, TRUE ) );- CHECK( AIAmbulance_pullsBack( 1000, 990, FALSE ) );- // never hit, or hit long ago, and clear of every gun: it stays on the job- CHECK( !AIAmbulance_pullsBack( 1000, 0, FALSE ) );- CHECK( !AIAmbulance_pullsBack( 1000, 500, FALSE ) );+ const UnsignedInt second = LOGICFRAMES_PER_SECOND;+ // the margin: Hard 8% of the base distance between 80 and 200, Medium 6% between 60 and 160+ CHECK_NEAR( 80.0f, AIAmbulance_gunMargin( 700.0f, AISKILL_BRUTAL ), 0.01f );+ CHECK_NEAR( 120.0f, AIAmbulance_gunMargin( 1500.0f, AISKILL_BRUTAL ), 0.01f );+ CHECK_NEAR( 200.0f, AIAmbulance_gunMargin( 4000.0f, AISKILL_BRUTAL ), 0.01f );+ CHECK_NEAR( 60.0f, AIAmbulance_gunMargin( 700.0f, AISKILL_MEDIUM ), 0.01f );+ CHECK_NEAR( 160.0f, AIAmbulance_gunMargin( 4000.0f, AISKILL_MEDIUM ), 0.01f );+ CHECK( AIAmbulance_gunMargin( 4000.0f, AISKILL_MEDIUM ) < AIAmbulance_gunMargin( 4000.0f, AISKILL_BRUTAL ) );++ // within the margin, or inside the reach+ CHECK( AIAmbulance_pullsBack( 1000, 0, 50.0f, 80.0f, AISKILL_BRUTAL ) );+ CHECK( AIAmbulance_pullsBack( 1000, 0, -10.0f, 80.0f, AISKILL_BRUTAL ) );+ CHECK( !AIAmbulance_pullsBack( 1000, 0, 90.0f, 80.0f, AISKILL_BRUTAL ) );+ // hit lately: Hard stays back 8 s, Medium 6+ CHECK( AIAmbulance_pullsBack( 1000 + 7 * second, 1000, 1.0e9f, 80.0f, AISKILL_BRUTAL ) );+ CHECK( !AIAmbulance_pullsBack( 1000 + 8 * second, 1000, 1.0e9f, 80.0f, AISKILL_BRUTAL ) );+ CHECK( !AIAmbulance_pullsBack( 1000 + 6 * second, 1000, 1.0e9f, 80.0f, AISKILL_MEDIUM ) );+ CHECK( !AIAmbulance_pullsBack( 1000, 0, 1.0e9f, 80.0f, AISKILL_BRUTAL ) );++ // only to ground a reorder step clearer: none such, it holds, which is what stops the cycle+ CHECK( AIAmbulance_movesBack( 20.0f, 200.0f, FALSE ) );+ CHECK( !AIAmbulance_movesBack( 20.0f, 60.0f, FALSE ) );+ CHECK( !AIAmbulance_movesBack( 20.0f, -30.0f, FALSE ) );+ // fire from something it does not know of: back regardless+ CHECK( AIAmbulance_movesBack( 1.0e9f, 1.0e9f, TRUE ) );++ // forward to a wait spot clear by one and a half margins, or clearer than here; else it stays put+ CHECK( AIAmbulance_waitsAt( 50.0f, 120.0f, 80.0f ) );+ CHECK( !AIAmbulance_waitsAt( 50.0f, 110.0f, 80.0f ) );+ CHECK( AIAmbulance_waitsAt( -20.0f, 90.0f, 80.0f ) );// Hard waits a minute and a half, Medium twice as long- const UnsignedInt second = LOGICFRAMES_PER_SECOND;CHECK( !AIAmbulance_rebuyWaits( 1000, 0, AISKILL_BRUTAL ) );CHECK( AIAmbulance_rebuyWaits( 1000, 900, AISKILL_BRUTAL ) );CHECK( !AIAmbulance_rebuyWaits( 900 + 90 * second, 900, AISKILL_BRUTAL ) );@@ -11219,6 +11489,27 @@ TEST(the_ai_ambulance_pulls_back_when_hit_and_is_not_rebought_at_once)CHECK( !AIAmbulance_rebuyWaits( 900 + 180 * second, 900, AISKILL_MEDIUM ) );}+/** CleanupHazardUpdate.cpp: an area cleaner out of reach of its hazard counts a scan against it only when+ it got no nearer and stood about, so a long drive or a detour is not given up and a stalled one is. */+extern Bool CleanupHazard_stalls( Real distance, Real driven, Real *closest );++TEST(a_cleaner_counts_only_scans_that_find_it_stuck_short_of_its_hazard)+{+ Real closest = 500.0f;+ // nearer: not stuck, and the new nearest+ CHECK( !CleanupHazard_stalls( 450.0f, 0.0f, &closest ) );+ CHECK_NEAR( 450.0f, closest, 0.001f );+ // stuck at the pathfinder's nearest point, or a step either way: counts+ CHECK( CleanupHazard_stalls( 450.0f, 0.0f, &closest ) );+ CHECK( CleanupHazard_stalls( 445.0f, 5.0f, &closest ) );+ // driving round a river, farther off for now: does not count+ CHECK( !CleanupHazard_stalls( 600.0f, 80.0f, &closest ) );+ CHECK_NEAR( 450.0f, closest, 0.001f );+ // and once round, nearer than before+ CHECK( !CleanupHazard_stalls( 430.0f, 80.0f, &closest ) );+ CHECK_NEAR( 430.0f, closest, 0.001f );+}+/** AI.cpp: a team that loses a fight stops at the first ground on its way home that none of thefight's guns reach, a step past it, rather than walking the whole map back to its base. */@@ -16768,6 +17059,62 @@ TEST(modfactions_split_a_mod_file_name)TheWritableGlobalData = saved;}+// -modfactions: a mod's skirmish scripts name its things as the mod's only where the mod defines that+// kind of thing under that name+TEST(modfactions_mod_name_by_type)+{+ bootOnce();+ ModNamespace names;+ names.scanLine( 0, "Object AmericaTankCrusader" );+ names.scanLine( 0, "Upgrade Upgrade_AmericaTOWMissile" );+ names.finishScan( 0 );+ CHECK_STR( names.modName( 0, MODNAME_OBJECT, AsciiString( "AmericaTankCrusader" ) ).str(), "M1~AmericaTankCrusader" );+ CHECK_STR( names.modName( 0, MODNAME_UPGRADE, AsciiString( "Upgrade_AmericaTOWMissile" ) ).str(), "M1~Upgrade_AmericaTOWMissile" );+ CHECK_STR( names.modName( 0, MODNAME_UPGRADE, AsciiString( "AmericaTankCrusader" ) ).str(), "AmericaTankCrusader" ); // not an upgrade+ CHECK_STR( names.modName( 0, MODNAME_OBJECT, AsciiString( "ChinaTankOverlord" ) ).str(), "ChinaTankOverlord" ); // retail's+ CHECK_STR( names.modName( 1, MODNAME_OBJECT, AsciiString( "AmericaTankCrusader" ) ).str(), "AmericaTankCrusader" ); // no second mod+}++// -modfactions: an AI on a mod faction reads its own mod's AIData side, under "M<n>~<side>", and+// retail's of the side when the mod has none; a retail AI never reads a mod's+TEST(modfactions_ai_side_lookups_take_the_mods_own_first)+{+ bootOnce();+ CHECK_STR( AI::modSideKey( AsciiString( "America" ), -1 ).str(), "America" );+ CHECK_STR( AI::modSideKey( AsciiString( "America" ), 1 ).str(), "M2~America" );++ TAiData data;+ AISideInfo *retail = newInstance(AISideInfo);+ retail->m_side = "America";+ data.addSideInfo( retail );+ AISideInfo *shockwave = newInstance(AISideInfo);+ shockwave->m_side = AI::modSideKey( AsciiString( "America" ), 0 );+ data.addSideInfo( shockwave );+ CHECK( data.findSideInfo( AsciiString( "America" ), -1 ) == retail );+ CHECK( data.findSideInfo( AsciiString( "America" ), 0 ) == shockwave );+ CHECK( data.findSideInfo( AsciiString( "America" ), 1 ) == retail ); // a mod without its own entry+ CHECK( data.findSideInfo( AsciiString( "Russia" ), 1 ) == NULL );++ AISideBuildList *russia = newInstance(AISideBuildList)( AI::modSideKey( AsciiString( "Russia" ), 1 ) );+ data.addFactionBuildList( russia );+ CHECK( data.findBuildList( AsciiString( "Russia" ), 1 ) == russia );+ CHECK( data.findBuildList( AsciiString( "Russia" ), 0 ) == NULL ); // another mod's+ CHECK( data.findBuildList( AsciiString( "Russia" ), -1 ) == NULL );+}++// -modfactions: which skirmish player's scripts a computer player runs. Its own mod's of its side+// beats retail's, retail's stands in for a mod without any, and another mod's never fits+TEST(modfactions_skirmish_side_fit)+{+ const AsciiString america( "America" );+ CHECK_EQ( SidesList::skirmishSideFit( america, -1, america, -1 ), 2 );+ CHECK_EQ( SidesList::skirmishSideFit( america, 0, america, 0 ), 2 );+ CHECK_EQ( SidesList::skirmishSideFit( america, -1, america, 0 ), 1 );+ CHECK_EQ( SidesList::skirmishSideFit( america, 1, america, 0 ), 0 );+ CHECK_EQ( SidesList::skirmishSideFit( america, 0, america, -1 ), 0 );+ CHECK_EQ( SidesList::skirmishSideFit( AsciiString( "China" ), -1, america, -1 ), 0 );+}+// -modfactions: a word naming a model, texture or sound the mod ships gets its prefix, so WW3D and the// FileSystem serve the mod's copy; art it does not ship stays retail'sTEST(modfactions_prefix_the_mods_own_art)@@ -16805,6 +17152,58 @@ TEST(modfactions_prefix_the_mods_own_art)CHECK_STR( line, " ShowSubObject = AVRanger" );}+// -modfactions: the file in a path-shaped word is its last part, past either slash+TEST(modfactions_last_path_part)+{+ CHECK_EQ( (Int)ModNamespace::lastPathPart( "x.mp3" ), 0 );+ CHECK_EQ( (Int)ModNamespace::lastPathPart( "Sub\\x.mp3" ), 4 );+ CHECK_EQ( (Int)ModNamespace::lastPathPart( "A\\B/x.mp3" ), 4 );+ CHECK_EQ( (Int)ModNamespace::lastPathPart( "Sub\\" ), 4 );+ CHECK_EQ( (Int)ModNamespace::lastPathPart( "" ), 0 );+}++// -modfactions: a MusicTrack Filename names the whole file, maybe in a subfolder; the prefix goes on the+// last part, where FileSystem::splitModName looks for it+TEST(modfactions_prefix_the_last_part_of_a_file_path)+{+ bootOnce();+ ModNamespace names;+ names.addAsset( 0, "Data\\Audio\\Tracks\\Sub\\Score01.mp3" );+ names.addAsset( 0, "Data\\Audio\\Tracks\\Score02.mp3" );+ names.finishScan( 0 );+ names.setActive( 0 );++ char line[ 96 ];+ strcpy( line, " Filename = Sub\\Score01.mp3" );+ CHECK( names.rewriteLine( line, sizeof( line ) ) );+ CHECK_STR( line, " Filename = Sub\\M1~Score01.mp3" );+ strcpy( line, " Filename = Score02.mp3" );+ CHECK( names.rewriteLine( line, sizeof( line ) ) );+ CHECK_STR( line, " Filename = M1~Score02.mp3" );+ strcpy( line, " Filename = Sub/Score02.mp3" );+ CHECK( names.rewriteLine( line, sizeof( line ) ) );+ CHECK_STR( line, " Filename = Sub/M1~Score02.mp3" );+ strcpy( line, " Filename = Sub\\Retail.mp3" ); // not the mod's: untouched+ CHECK( names.rewriteLine( line, sizeof( line ) ) );+ CHECK_STR( line, " Filename = Sub\\Retail.mp3" );+ strcpy( line, " Sounds = Score01" ); // a sound event still names the base+ CHECK( names.rewriteLine( line, sizeof( line ) ) );+ CHECK_STR( line, " Sounds = M1~Score01" );++ // and the file system takes the prefix back off that part+ GlobalData *saved = TheWritableGlobalData;+ TheWritableGlobalData = NEW GlobalData;+ TheWritableGlobalData->m_mods.assign( 1, AsciiString( "Mods\\X" ) );+ TheWritableGlobalData->m_modFactions = TRUE;+ Int mod = -1;+ AsciiString bare;+ CHECK( FileSystem::splitModName( AsciiString( "Data\\Audio\\Tracks\\Sub\\M1~Score01.mp3" ), &mod, &bare ) );+ CHECK_EQ( mod, 0 );+ CHECK_STR( bare.str(), "Data\\Audio\\Tracks\\Sub\\Score01.mp3" );+ delete TheWritableGlobalData;+ TheWritableGlobalData = saved;+}+#include "test_minimap_input.inc"#include "test_selection_priority.inc"#include "test_widechar_width.inc"diff --git a/Tools/Balance/unitmatrix.py b/Tools/Balance/unitmatrix.pyindex 270a17e38..35e2d61b2 100644--- a/Tools/Balance/unitmatrix.py+++ b/Tools/Balance/unitmatrix.py@@ -434,10 +434,12 @@ class GameData:self.things = {}self.skipped = [] # patch blocks naming what this data does not have- for keyword, args, children in ini_blocks(files.text("Data/INI/Weapon.ini")):- if keyword.lower() == "weapon" and args[0].lower() not in self.weapons:- self.weapons[args[0].lower()] = new_weapon(args[0])- apply_weapon(self.weapons[args[0].lower()], children)+ # WeaponReforged.ini right after Weapon.ini, as GameEngine::init loads it: the fork's own names+ for path in ("Data/INI/Weapon.ini", "Data/INI/WeaponReforged.ini"):+ for keyword, args, children in ini_blocks(files.text(path)):+ if keyword.lower() == "weapon" and args[0].lower() not in self.weapons:+ self.weapons[args[0].lower()] = new_weapon(args[0])+ apply_weapon(self.weapons[args[0].lower()], children)for keyword, args, children in ini_blocks(files.text("Data/INI/Locomotor.ini")):if keyword.lower() == "locomotor":speeds = [real(value[0]) for key, value in (field(line) for line, _ in children) if key == "speed"]