Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
feat(gameengine): scout, search and destroy and stance keys on the grid
Olcay Seygan50b883881be7
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0e9dd864b..6df852b17 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -256,6 +256,9 @@ 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.- Guard covers the circle you choose. How far a guard reached used to come from each unit's own eyesight, so Rangers and Missile Defenders posted on the same spot held circles of 180 and 270 and a raider standing between the two was only shot by half the group. Now one guard order gives the whole group one circle, the widest any of them had. Roll the mouse wheel while the guard key or the guard button is armed and the circle grows or shrinks before you click, drawn on the ground under the pointer as you go. Select a guarding group and its circle is drawn round the post, and every unit of yours on guard carries the guard badge over its head, selected or not.+- Two new orders on the command bar. Search and destroy, on F, sends the group round a circle you pick with the wheel, fighting everything it meets on the way, and leaves it guarding that circle when the lap is done. Scout, on G, walks the same lap without stopping to fight and brings the group back to the middle. The lap starts on the side the group is coming from and skips ground you can already see. Scout is offered to the units built to look around: Humvees, Pathfinders, Listening Outposts, Technicals, Combat Bikes and Radar Vans. Where those letters are taken by a unit's own buttons the keys move to the next free place, and a card says which is which when you point at them.+- 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.- A unit sent out to answer a shot, whose target then died, is supposed to walk home. When that walk cannot start, because the unit cannot move or the pathfinder has no way back, the failure was taken to mean someone was still in range, and the unit went back into the attack on a target that was already gone. Both ends of that attack find nobody and hand it back to the walk, which fails again, so the loop runs out inside the same step and starts over on the next one. One match wrote 67,416 lines about it, and every line is pushed out to disk as it is written. The failed walk now counts as the walk being over. The unit looks once more, and with nobody there it goes back to what it was doing. A save that caught the chase dropped it on load; it picks the target back up. A soldier whose tunnel is gone did the same thing, and a computer match wrote 80 of those lines. With no tunnel he waits and looks. A replay recorded before this change plays back differently.- Engineers can clear mines and booby traps they cannot see.- A helicopter no longer boards a transport from the air.diff --git a/GeneralsMD/Code/BuildFingerprint.manifest b/GeneralsMD/Code/BuildFingerprint.manifestindex 3ebaa5639..dbd77e492 100644--- a/GeneralsMD/Code/BuildFingerprint.manifest+++ b/GeneralsMD/Code/BuildFingerprint.manifest@@ -65,6 +65,7 @@ Data/Scenarios/mobclose.txtData/Scenarios/mobopen.txtData/Scenarios/mobstress.txtData/Scenarios/mobwin.txt+Data/Scenarios/netstance.txtData/Scenarios/overlordbridge.txtData/Scenarios/overlordlong.txtData/Scenarios/parade.txt@@ -74,10 +75,12 @@ Data/Scenarios/scudstorm.txtData/Scenarios/shiftorders.txtData/Scenarios/shiftqueue.txtData/Scenarios/squad30.txt+Data/Scenarios/stance.txtData/Scenarios/standinbuild.txtData/Scenarios/standinfake.txtData/Scenarios/stashbeside.txtData/Scenarios/statues.txt+Data/Scenarios/sweep.txtData/Scenarios/techrespawn.txtData/Scenarios/towncross.txtData/Scenarios/trailer_arrival.txtdiff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txtindex e4ab3df1d..24a17e693 100644--- a/GeneralsMD/Code/CMakeLists.txt+++ b/GeneralsMD/Code/CMakeLists.txt@@ -2616,8 +2616,8 @@ if(Python3_Interpreter_FOUND)# synthetic one and checks the block parser did not eat an End or duplicate a key.add_test(NAME vfx_tune_selfcheckCOMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Tools/vfx_tune.py selfcheck)- # Tools/order_cameos.py paints the command bar's attack, hold position and move cameos: three- # whole pictures in the places the mapped images name, told apart by colour, the same every run.+ # Tools/order_cameos.py paints the command bar's order key cameos: seven whole pictures in the+ # places the mapped images name, told apart by colour, the same every run.add_test(NAME order_cameos_selfcheckCOMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/Tools/run_with_modules.py numpy,PIL${CMAKE_CURRENT_SOURCE_DIR}/Tools/order_cameos.py selfcheck)diff --git a/GeneralsMD/Code/Data/Art/Textures/ReforgedOrders.tga b/GeneralsMD/Code/Data/Art/Textures/ReforgedOrders.tgaindex 38bb8ffa8..d8786864b 100644Binary files a/GeneralsMD/Code/Data/Art/Textures/ReforgedOrders.tga and b/GeneralsMD/Code/Data/Art/Textures/ReforgedOrders.tga differdiff --git a/GeneralsMD/Code/Data/INI/BalanceReforged.ini b/GeneralsMD/Code/Data/INI/BalanceReforged.iniindex d236d087f..0a345dcfa 100644--- a/GeneralsMD/Code/Data/INI/BalanceReforged.ini+++ b/GeneralsMD/Code/Data/INI/BalanceReforged.ini@@ -418,3 +418,166 @@ Object SupW_AmericaVehicleComancheEndEndEnd++; ---- scouts ------------------------------------------------------------------------------------+; The command bar offers the scout key to a selection with one of these in it. SCOUT changes+; nothing else about the unit.++Object AmericaVehicleHumvee+ KindOf = +SCOUT+End++Object AirF_AmericaVehicleHumvee+ KindOf = +SCOUT+End++Object Lazr_AmericaVehicleHumvee+ KindOf = +SCOUT+End++Object SupW_AmericaVehicleHumvee+ KindOf = +SCOUT+End++Object AmericaInfantryPathfinder+ KindOf = +SCOUT+End++Object AirF_AmericaInfantryPathfinder+ KindOf = +SCOUT+End++Object Lazr_AmericaInfantryPathfinder+ KindOf = +SCOUT+End++Object SupW_AmericaInfantryPathfinder+ KindOf = +SCOUT+End++Object Boss_InfantryPathfinder+ KindOf = +SCOUT+End++Object ChinaVehicleListeningOutpost+ KindOf = +SCOUT+End++Object Infa_ChinaVehicleListeningOutpost+ KindOf = +SCOUT+End++Object Nuke_ChinaVehicleListeningOutpost+ KindOf = +SCOUT+End++Object Tank_ChinaVehicleListeningOutpost+ KindOf = +SCOUT+End++; A Technical is built as one of three chassis, and the second and third are copies of the first+; made before this file loads, so each chassis takes the line itself.++Object GLAVehicleTechnicalChassisOne+ KindOf = +SCOUT+End++Object GLAVehicleTechnicalChassisTwo+ KindOf = +SCOUT+End++Object GLAVehicleTechnicalChassisThree+ KindOf = +SCOUT+End++Object Chem_GLAVehicleTechnicalChassisOne+ KindOf = +SCOUT+End++Object Chem_GLAVehicleTechnicalChassisTwo+ KindOf = +SCOUT+End++Object Chem_GLAVehicleTechnicalChassisThree+ KindOf = +SCOUT+End++Object Demo_GLAVehicleTechnicalChassisOne+ KindOf = +SCOUT+End++Object Demo_GLAVehicleTechnicalChassisTwo+ KindOf = +SCOUT+End++Object Demo_GLAVehicleTechnicalChassisThree+ KindOf = +SCOUT+End++Object Slth_GLAVehicleTechnicalChassisOne+ KindOf = +SCOUT+End++Object Slth_GLAVehicleTechnicalChassisTwo+ KindOf = +SCOUT+End++Object Slth_GLAVehicleTechnicalChassisThree+ KindOf = +SCOUT+End++Object GC_Slth_GLAVehicleTechnicalChassisOne+ KindOf = +SCOUT+End++Object GC_Slth_GLAVehicleTechnicalChassisTwo+ KindOf = +SCOUT+End++Object GC_Slth_GLAVehicleTechnicalChassisThree+ KindOf = +SCOUT+End++Object GLAVehicleCombatBike+ KindOf = +SCOUT+End++Object Chem_GLAVehicleCombatBike+ KindOf = +SCOUT+End++Object Demo_GLAVehicleCombatBike+ KindOf = +SCOUT+End++Object Slth_GLAVehicleCombatBike+ KindOf = +SCOUT+End++Object GC_Slth_GLAVehicleCombatBike+ KindOf = +SCOUT+End++Object GLAVehicleRadarVan+ KindOf = +SCOUT+End++Object Chem_GLAVehicleRadarVan+ KindOf = +SCOUT+End++Object Demo_GLAVehicleRadarVan+ KindOf = +SCOUT+End++Object Slth_GLAVehicleRadarVan+ KindOf = +SCOUT+End++Object GC_Chem_GLAVehicleRadarVan+ KindOf = +SCOUT+End++Object GC_Slth_GLAVehicleRadarVan+ KindOf = +SCOUT+Enddiff --git a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedOrders.ini b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedOrders.iniindex f5fb77199..67727a38f 100644--- a/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedOrders.ini+++ b/GeneralsMD/Code/Data/INI/MappedImages/HandCreated/ReforgedOrders.ini@@ -1,10 +1,10 @@-; The command bar's attack, hold position and move cameos, painted by Tools/order_cameos.py into-; Art/Textures/ReforgedOrders.tga. ControlBar.html draws them on the page's three order keys.-; Mapped images are not in the multiplayer INI checksum.+; The command bar's attack, hold position, move, scout, search and destroy and stance cameos, painted+; by Tools/order_cameos.py into Art/Textures/ReforgedOrders.tga. ControlBar.html draws them on the+; page's order keys. Mapped images are not in the multiplayer INI checksum.MappedImage ReforgedOrderAttackTexture = ReforgedOrders.tga- TextureWidth = 128+ TextureWidth = 256TextureHeight = 128Coords = Left:0 Top:0 Right:60 Bottom:48Status = NONE@@ -12,7 +12,7 @@ EndMappedImage ReforgedOrderHoldTexture = ReforgedOrders.tga- TextureWidth = 128+ TextureWidth = 256TextureHeight = 128Coords = Left:64 Top:0 Right:124 Bottom:48Status = NONE@@ -20,8 +20,40 @@ EndMappedImage ReforgedOrderMoveTexture = ReforgedOrders.tga- TextureWidth = 128+ TextureWidth = 256TextureHeight = 128Coords = Left:0 Top:64 Right:60 Bottom:112Status = NONEEnd++MappedImage ReforgedOrderScout+ Texture = ReforgedOrders.tga+ TextureWidth = 256+ TextureHeight = 128+ Coords = Left:64 Top:64 Right:124 Bottom:112+ Status = NONE+End++MappedImage ReforgedOrderHunt+ Texture = ReforgedOrders.tga+ TextureWidth = 256+ TextureHeight = 128+ Coords = Left:128 Top:0 Right:188 Bottom:48+ Status = NONE+End++MappedImage ReforgedOrderAggressive+ Texture = ReforgedOrders.tga+ TextureWidth = 256+ TextureHeight = 128+ Coords = Left:192 Top:0 Right:252 Bottom:48+ Status = NONE+End++MappedImage ReforgedOrderDefensive+ Texture = ReforgedOrders.tga+ TextureWidth = 256+ TextureHeight = 128+ Coords = Left:128 Top:64 Right:188 Bottom:112+ Status = NONE+Enddiff --git a/GeneralsMD/Code/Data/Patch.str b/GeneralsMD/Code/Data/Patch.strindex a5f35e04c..266042227 100644--- a/GeneralsMD/Code/Data/Patch.str+++ b/GeneralsMD/Code/Data/Patch.str@@ -220,6 +220,38 @@ GUI:OrderMoveDescription"The next click on the ground sends the selected units there. Drag instead and they spread out along the line you draw."END+GUI:OrderScout+"Scout"+END++GUI:OrderScoutDescription+"Click a spot and the selected units walk a circle round it, looking at every part of it you cannot see yet, then come back to the middle. Roll the mouse wheel before you click to make the circle bigger or smaller."+END++GUI:OrderSearchAndDestroy+"Search and Destroy"+END++GUI:OrderSearchAndDestroyDescription+"Click a spot and the selected units attack move round it, fighting whatever they run into, then stay and guard the whole circle. Roll the mouse wheel before you click to size the circle."+END++GUI:OrderStanceDefensive+"Stance: Defensive"+END++GUI:OrderStanceDefensiveDescription+"The selected units shoot what comes into range and hold the ground you put them on. Click to make them aggressive: they go after any enemy they see."+END++GUI:OrderStanceAggressive+"Stance: Aggressive"+END++GUI:OrderStanceAggressiveDescription+"The selected units go after any enemy they see and chase it. Click to make them defensive again: they only shoot what comes into range and stay where they are."+END+// Smoke signals. The three ...Placed lines are what an ally reads; %s is the sender's name. The// ...Label words are written over the smoke, which is in the sender's colour.GUI:SignalAttackdiff --git a/GeneralsMD/Code/Data/Scenarios/netstance.txt b/GeneralsMD/Code/Data/Scenarios/netstance.txtnew file mode 100644index 000000000..8286eaf9d--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/netstance.txt@@ -0,0 +1,12 @@+# The stance key across a network match. Every copy of a -netgame match plays the same file on the+# same frame, so each seat gets three Crusaders beside its base; net_check.py then presses Ctrl+A and+# H, the stance key's place for a selection that attack moves, on every copy, which sends+# MSG_SET_STANCE through the network both ways. Each copy's log carries a STANCE line for every+# seat that pressed it, and the CRC covers the stance.+#+# python net_check.py --each "-scenario netstance" --keys "KEY_A CTRL,KEY_H" --tag netstance+#+# See mobstress.txt for the line grammar.++30 spawn 0 AmericaTankCrusader 3 start0:250:0 30+30 spawn 1 AmericaTankCrusader 3 start1:250:0 30diff --git a/GeneralsMD/Code/Data/Scenarios/shiftqueue.txt b/GeneralsMD/Code/Data/Scenarios/shiftqueue.txtindex 8f7322a26..0973e2266 100644--- a/GeneralsMD/Code/Data/Scenarios/shiftqueue.txt+++ b/GeneralsMD/Code/Data/Scenarios/shiftqueue.txt@@ -9,9 +9,12 @@## generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit# -map "Maps\Alpine Assault\Alpine Assault.map" -autoskirmish 2 -takeover-# -side 0 FactionGLA -side 1 FactionAmerica -seed 1 -maxframes 2400+# -side 0 FactionGLA -side 1 FactionAmerica -seed 1 -maxframes 3000# -scenario shiftqueue -logPrefix shiftqueue_#+# The attack move holds the list until it gets to 1400,1400, fighting on the way, so the Crusader+# dies in that fight and the named attack on it is skipped; the guard goes out on frame 2646.+## See mobstress.txt for the line grammar.30 spawn 0 GLATankScorpion 6 760 920 30diff --git a/GeneralsMD/Code/Data/Scenarios/stance.txt b/GeneralsMD/Code/Data/Scenarios/stance.txtnew file mode 100644index 000000000..00a4c5c5a--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/stance.txt@@ -0,0 +1,30 @@+# Does the aggressive stance go after what it sees, and the defensive one leave it?+#+# Two posts of two Crusaders, 600 apart on the open middle of the small generated map, each with an+# unarmed worker standing 230 east of it. A Crusader's gun reaches 150, so neither post can shoot+# its worker from where it stands, but both can see it: a player's unit looks out to its vision+# times GuardOuterModifierHuman, 330 for a Crusader, and the post clears the shroud to 300. The+# north post is put on the defensive stance and the south one on the aggressive stance, both with+# the stance key's own message. The north worker should still be standing at the end and the+# south one dead.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -randommap 1 2 small -autoskirmish 2 -takeover+# -side 0 FactionAmerica -side 1 FactionGLA -seed 1 -maxframes 900+# -scenario stance -logPrefix stance_+#+# See mobstress.txt for the line grammar.++30 spawn 0 AmericaTankCrusader 2 900 600 30+30 spawn 1 GLAInfantryWorker 1 1130 600++30 spawn 0 SupW_AmericaTankCrusader 2 900 1200 30+30 spawn 1 Chem_GLAInfantryWorker 1 1130 1200++40 stance 0 AmericaTankCrusader defensive+40 stance 0 SupW_AmericaTankCrusader aggressive++41 tally 1 GLAInfantryWorker+41 tally 1 Chem_GLAInfantryWorker+880 tally 1 GLAInfantryWorker+880 tally 1 Chem_GLAInfantryWorkerdiff --git a/GeneralsMD/Code/Data/Scenarios/sweep.txt b/GeneralsMD/Code/Data/Scenarios/sweep.txtnew file mode 100644index 000000000..7f34fbdd9--- /dev/null+++ b/GeneralsMD/Code/Data/Scenarios/sweep.txt@@ -0,0 +1,38 @@+# Do the scout and search and destroy keys cover the circle they are given?+#+# Search and destroy: two Crusaders west of a circle of 450 round 900,700, with an unarmed worker on+# the circle's ring at its north and its south. The verb hands the order queue the messages the key+# sends, an attack move to each point of the ring and a guard of the circle at the end, so both+# workers should die. Beside it, two more Crusaders given a plain attack move to the middle of the+# same kind of circle round 1450,1300 stop there: the ring is 315 out, past the 225 an attack move+# looks, so both of their workers should still be standing.+#+# Scout: a Humvee walks a circle of 400 round 1500,300 and comes back to its middle, which the arrive+# line times. The log names every point it was given.+#+# generals.exe -headless -quickstart -noshellmap -observer -multiInstance -noFPSLimit+# -randommap 1 2 small -autoskirmish 2 -takeover+# -side 0 FactionAmerica -side 1 FactionGLA -seed 1 -maxframes 6000+# -scenario sweep -logPrefix sweep_+#+# See mobstress.txt for the line grammar.++30 spawn 0 AmericaTankCrusader 2 500 700 30+30 spawn 1 GLAInfantryWorker 1 900 385+30 spawn 1 GLAInfantryWorker 1 900 1015++30 spawn 0 SupW_AmericaTankCrusader 2 1100 1300 30+30 spawn 1 Chem_GLAInfantryWorker 1 1450 985+30 spawn 1 Chem_GLAInfantryWorker 1 1450 1615++30 spawn 0 AmericaVehicleHumvee 1 1200 500++60 hunt 0 AmericaTankCrusader 900 700 450+60 playerattackmove 0 SupW_AmericaTankCrusader 1450 1300+60 scout 0 AmericaVehicleHumvee 1500 300 400+61 arrive 0 AmericaVehicleHumvee 1500 300 60++61 tally 1 GLAInfantryWorker+61 tally 1 Chem_GLAInfantryWorker+5980 tally 1 GLAInfantryWorker+5980 tally 1 Chem_GLAInfantryWorkerdiff --git a/GeneralsMD/Code/Data/Turkish/Generals.str b/GeneralsMD/Code/Data/Turkish/Generals.strindex 57437321e..026a1ff79 100644--- a/GeneralsMD/Code/Data/Turkish/Generals.str+++ b/GeneralsMD/Code/Data/Turkish/Generals.str@@ -14825,6 +14825,38 @@ GUI:OrderMoveDescription"Zemine bir sonraki tıklama seçili birlikleri oraya gönderir. Bunun yerine sürüklerseniz birlikler çizdiğiniz çizgi boyunca dizilir."END+GUI:OrderScout+"Keşif"+END++GUI:OrderScoutDescription+"Bir noktaya tıklayın; seçili birlikler çevresinde bir daire boyunca dolaşıp dairenin henüz göremediğiniz her yerine bakar, sonra ortaya döner. Daireyi büyütmek ya da küçültmek için tıklamadan önce fare tekerleğini çevirin."+END++GUI:OrderSearchAndDestroy+"Ara ve Yok Et"+END++GUI:OrderSearchAndDestroyDescription+"Bir noktaya tıklayın; seçili birlikler çevresinde saldırarak ilerler, karşılarına çıkanla savaşır, sonra kalıp bütün daireyi korur. Daireyi boyutlandırmak için tıklamadan önce fare tekerleğini çevirin."+END++GUI:OrderStanceDefensive+"Tutum: Savunmacı"+END++GUI:OrderStanceDefensiveDescription+"Seçili birlikler menzile gireni vurur ve koyduğunuz yeri tutar. Saldırgan yapmak için tıklayın: gördükleri her düşmanın peşine düşerler."+END++GUI:OrderStanceAggressive+"Tutum: Saldırgan"+END++GUI:OrderStanceAggressiveDescription+"Seçili birlikler gördükleri her düşmanın peşine düşer ve onu kovalar. Yeniden savunmacı yapmak için tıklayın: yalnızca menzile gireni vururlar ve yerlerinde kalırlar."+END+GUI:SignalAttack"Sinyal: Saldır"ENDdiff --git a/GeneralsMD/Code/Data/Window/Html/ControlBar.html b/GeneralsMD/Code/Data/Window/Html/ControlBar.htmlindex 063616cf4..2b48b53c6 100644--- a/GeneralsMD/Code/Data/Window/Html/ControlBar.html+++ b/GeneralsMD/Code/Data/Window/Html/ControlBar.html@@ -51,6 +51,9 @@{{holdkey.x}} ... stand, data-click="order:attack", "order:hold" and "order:move", for a{{movekey.x}} ... selection that attack moves; no command set has a button for any ofthem. The game letters each with the key bound to its place+ {{scoutkey.x}} ... the scout, search and destroy and stance keys, data-click="order:scout",+ {{huntkey.x}} ... "order:hunt" and "order:stance", wherever the grid has room for them;+ {{stancekey.x}} ... {{stance}} is "aggressive" or "defensive", the first selected unit'sdata-each="portraitcells" the selection's cells, the portrait's first and then only what itholds, each {{cell.x}} .y .w .h{{selinfo.x}} ... beside a lone unit's portrait: {{sel.name}}, data-each="selstars" a star@@ -298,6 +301,10 @@.order.attack { background-image: url(ReforgedOrderAttack); }.order.hold { background-image: url(ReforgedOrderHold); }.order.move { background-image: url(ReforgedOrderMove); }+ .order.scout { background-image: url(ReforgedOrderScout); }+ .order.hunt { background-image: url(ReforgedOrderHunt); }+ .order.aggressive { background-image: url(ReforgedOrderAggressive); }+ .order.defensive { background-image: url(ReforgedOrderDefensive); }.order .glow { position: absolute; left: 0; top: 0; right: 0; bottom: 0; background-size: 100% 100%; background-repeat: no-repeat; }.order:hover .glow { background-image: url(Cameo_hilited); }.held .order:hover .glow { background-image: url(Cameo_push); }@@ -438,6 +445,9 @@<div class="piece order attack {{attackkey.shown}}" data-click="order:attack" style="left: {{attackkey.x}}px; top: {{attackkey.y}}px; width: {{attackkey.w}}px; height: {{attackkey.h}}px"><div class="glow"></div></div><div class="piece order hold {{holdkey.shown}}" data-click="order:hold" style="left: {{holdkey.x}}px; top: {{holdkey.y}}px; width: {{holdkey.w}}px; height: {{holdkey.h}}px"><div class="glow"></div></div><div class="piece order move {{movekey.shown}}" data-click="order:move" style="left: {{movekey.x}}px; top: {{movekey.y}}px; width: {{movekey.w}}px; height: {{movekey.h}}px"><div class="glow"></div></div>+ <div class="piece order scout {{scoutkey.shown}}" data-click="order:scout" style="left: {{scoutkey.x}}px; top: {{scoutkey.y}}px; width: {{scoutkey.w}}px; height: {{scoutkey.h}}px"><div class="glow"></div></div>+ <div class="piece order hunt {{huntkey.shown}}" data-click="order:hunt" style="left: {{huntkey.x}}px; top: {{huntkey.y}}px; width: {{huntkey.w}}px; height: {{huntkey.h}}px"><div class="glow"></div></div>+ <div class="piece order {{stance}} {{stancekey.shown}}" data-click="order:stance" style="left: {{stancekey.x}}px; top: {{stancekey.y}}px; width: {{stancekey.w}}px; height: {{stancekey.h}}px"><div class="glow"></div></div><div class="piece commandcell" data-each="skillcells" style="left: {{cell.x}}px; top: {{cell.y}}px; width: {{cell.w}}px; height: {{cell.h}}px"><div class="edge" style="left: -{{ring}}px; top: -{{ring}}px; right: -{{ring}}px; bottom: -{{ring}}px; border-width: {{ring}}px"></div><div class="bevel"></div></div>diff --git a/GeneralsMD/Code/GameEngine/Include/Common/DrawnPath.h b/GeneralsMD/Code/GameEngine/Include/Common/DrawnPath.hindex e40df666c..671db5ed2 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/DrawnPath.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/DrawnPath.h@@ -93,4 +93,16 @@ extern void orderAroundPoint( std::vector<AttackAssignSlot>& slots, Real centerX/// Either side empty writes nothing.extern void assignAttacks( Int attackerCount, Int targetCount, std::vector<AttackAssignPair>& pairs );+/// The points the scout and search and destroy keys walk round the circle the player put down:+/// on a ring at seven tenths of the radius, four on a small circle and up to eight on a wide one,+/// the first the one facing (fromX, fromY), where the selection stands, and the rest going round+/// clockwise. Each is held inside lo..hi. The ground height is not filled in.+extern void sweepPoints( Real centerX, Real centerY, Real radius, Real fromX, Real fromY,+ Real loX, Real loY, Real hiX, Real hiY, std::vector<Coord3D>& out );++/// The same ring for one player on the map being played, on the ground, less the points that player+/// sees clear already; all of them when there is nothing left to look at.+extern void sweepRoute( Int playerIndex, const Coord3D& center, Real radius, const Coord3D& from,+ std::vector<Coord3D>& route );+#endif // _H_DrawnPathdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/KindOf.h b/GeneralsMD/Code/GameEngine/Include/Common/KindOf.hindex f37356585..5b7d17662 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/KindOf.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/KindOf.h@@ -173,6 +173,7 @@ enum KindOfType : intKINDOF_CONSERVATIVE_BUILDING, ///< Conservative structures aren't considered part of your base for sneak attack boundary calculations...KINDOF_IGNORE_DOCKING_BONES, ///< Structure will not look up docking bones. Patch 1.03 hack.KINDOF_NO_ATTACK_WARNING, ///< Damage to this raises no "under attack" alarm, ping or EVA line.+ KINDOF_SCOUT, ///< A reconnaissance unit: the command bar offers it the scout key (fork)KINDOF_COUNT // total number of kindofsdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.hindex dfe08065b..cae1782f4 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h@@ -658,6 +658,7 @@ public:MSG_CHEAT, ///< (Int CheatKind, Int amount) a console cheat, refused in a network game (fork)MSG_QUEUE_NEXT_ORDER, ///< (Int OrderQueueMode) the order right after this one is a shift-queued one (fork)MSG_CLEAR_RALLY_POINT, ///< (objectID) the building forgets its rally point (fork)+ MSG_SET_STANCE, ///< (Int 0 defensive, 1 aggressive) how far the selected units go after what they see (fork)MSG_BEGIN_DEBUG_NETWORK_MESSAGES = 1900, ///< network messages that exist only in debug/internal builds. all grouped separately.diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.hindex 48ea8aa8c..f5a6b0356 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/ControlBar.h@@ -491,6 +491,22 @@ Int ControlBar_commandGroup( const class CommandButton *command );* abilities along Q, or along A under a set's production. A row fills left to right in slot order;* what does not fit goes on in the next row down with room, then in the rows above. */Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *pinned, Int count, Int *places );++/** The page's keys past attack, hold position and move, which no command set has a button for either. */+enum OrderKeyExtra+{+ ORDER_KEY_SCOUT = 0, ///< walk a circle, for a selection with a scout in it+ ORDER_KEY_HUNT, ///< search and destroy: attack move round a circle and guard it, for one that attack moves+ ORDER_KEY_STANCE, ///< aggressive or defensive, for one that attack moves+ ORDER_KEY_EXTRAS+};++/** Where the ORDER_KEY_EXTRAS keys stand once `count` slots are at `places` (ControlBar_commandPlaces'+ * answer, `fights` its return), or -1 for a key that is not offered or finds no room. They come+ * after every button, so none of them moves one. Each has its own place, scout G, search and+ * destroy F and the stance H; one that finds its own taken goes on B, then N, then the first free+ * place in reading order. */+void ControlBar_orderKeyPlaces( const Int *places, Int count, Bool fights, Bool scouts, Int *keys );enum { MAX_RIGHT_HUD_UPGRADE_CAMEOS = 5};enum { MAX_MULTI_SELECT_GROUPS = 36 }; ///< unit types a multi-selection tells apart (6x6 grid, Tab focus)enum {@@ -843,6 +859,10 @@ public:attack and hold places hold the page's two orders. `places` has MAX_COMMANDS_PER_SET. */Bool getCommandPlaces( Int *places ) const;+ /** Where the page's scout, search and destroy and stance keys stand for what is selected now,+ ORDER_KEY_EXTRAS of them, -1 for one that is not offered. See ControlBar_orderKeyPlaces. */+ void getOrderKeyPlaces( Int *keys ) const;+/** paint each command window's key, its place's, in its top left corner; `places` as above */void labelCommandPlaces( const Int *places );diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.hindex 32b3903d9..41c275d47 100644--- a/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h+++ b/GeneralsMD/Code/GameEngine/Include/GameClient/InGameUI.h@@ -1232,9 +1232,9 @@ public: // ********************************************************************void setForceAttackMode( Bool enabled ) { m_forceAttackMode = enabled; }void setPreferSelectionMode( Bool enabled ) { m_preferSelection = enabled; }- void toggleAttackMoveToMode( void ) { m_attackMoveToMode = !m_attackMoveToMode; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; m_moveArmed = FALSE; }+ void toggleAttackMoveToMode( void ) { m_attackMoveToMode = !m_attackMoveToMode; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; m_moveArmed = FALSE; m_areaOrder = AREA_ORDER_NONE; }Bool isInAttackMoveToMode( void ) const { return m_attackMoveToMode; }- void clearAttackMoveToMode( void ) { m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; m_moveArmed = FALSE; m_orderKeyKeptByShift = FALSE; }+ void clearAttackMoveToMode( void ) { m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; m_moveArmed = FALSE; m_areaOrder = AREA_ORDER_NONE; m_orderKeyKeptByShift = FALSE; }// an order click with one of the three keys armed spends the key, unless shift is down: then it// stays armed for the next click, so a row of targets is one key and a row of clicks, and it drops@@ -1244,17 +1244,31 @@ public: // ********************************************************************// the attack key arms force fire the way the attack move key arms an attack move: the next// order click shoots whatever is under it, ground included, and the mode drops again with the// same call that drops attack move- void toggleForceAttackArmed( void ) { m_forceAttackArmed = !m_forceAttackArmed; m_attackMoveToMode = FALSE; m_guardArmed = FALSE; m_moveArmed = FALSE; }+ void toggleForceAttackArmed( void ) { m_forceAttackArmed = !m_forceAttackArmed; m_attackMoveToMode = FALSE; m_guardArmed = FALSE; m_moveArmed = FALSE; m_areaOrder = AREA_ORDER_NONE; }Bool isForceAttackArmed( void ) const { return m_forceAttackArmed; }- Bool isOrderKeyArmed( void ) const { return m_forceAttackArmed || m_attackMoveToMode || m_guardArmed || m_moveArmed; } ///< the next left click is an attack, an attack move, a guard or a move+ Bool isOrderKeyArmed( void ) const { return m_forceAttackArmed || m_attackMoveToMode || m_guardArmed || m_moveArmed || m_areaOrder != AREA_ORDER_NONE; } ///< the next left click is an attack, an attack move, a guard, a move or a sweepBool isForceFireOn( void ) const; ///< the next order click force fires: the attack key armed it// and the guard key arms guard the same way: the next order click posts the selection on that// spot, or on that object, and a drag posts them along the line instead of stacking them all// on one point. All the armed keys are one mode at a time- void toggleGuardArmed( void ) { m_guardArmed = !m_guardArmed; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_moveArmed = FALSE; }+ void toggleGuardArmed( void ) { m_guardArmed = !m_guardArmed; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_moveArmed = FALSE; m_areaOrder = AREA_ORDER_NONE; }Bool isGuardArmed( void ) const { return m_guardArmed; }+ // The scout and search and destroy keys (fork) arm a sweep the same way: the next order click is+ // the centre of a circle, sized with the wheel like a guard's, and the selection goes round it.+ // Scout walks the ring and comes back to the centre; search and destroy attack moves round it and+ // then guards the whole circle. Both skip the ring's points the player already sees+ enum AreaOrder { AREA_ORDER_NONE, AREA_ORDER_SCOUT, AREA_ORDER_HUNT };+ void toggleAreaOrderArmed( AreaOrder order );+ AreaOrder getAreaOrderArmed( void ) const { return m_areaOrder; }+ void issueAreaSweep( const Coord3D ¢er ); ///< the armed sweep's messages, round `center`++ /** One of the page's keys past attack, hold position and move, an OrderKeyExtra (ControlBar.h),+ * pressed with the mouse or its grid key: scout and search and destroy arm their sweep, the+ * stance key puts the selection on the other stance from the first unit's */+ void pressOrderKey( Int key );+// An order that covers a circle around the point it is given on (the guard key, EA's guard// buttons) is armed with a radius: the wheel grows and shrinks it instead of zooming, a ring// under the cursor shows it, and the order carries it. The scale drops back to 1 when nothing@@ -1265,7 +1279,7 @@ public: // ********************************************************************// the move key arms the order a right click gives, for the left button: the next order click is// that move, and a left drag draws the formation line- void toggleMoveArmed( void ) { m_moveArmed = !m_moveArmed; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; }+ void toggleMoveArmed( void ) { m_moveArmed = !m_moveArmed; m_attackMoveToMode = FALSE; m_forceAttackArmed = FALSE; m_guardArmed = FALSE; m_areaOrder = AREA_ORDER_NONE; }Bool isMoveArmed( void ) const { return m_moveArmed; }Bool isLineOrderArmed( void ) const { return m_attackMoveToMode || m_guardArmed || m_moveArmed; } ///< a left drag draws a move, attack move or guard line; force fire's left drag is the attack circle@@ -1599,9 +1613,9 @@ protected:HtmlOverlay * m_promotionFrontOverlay; ///< the grid's frames, drawn over the promotionsHtmlOverlay * m_cellFrontOverlay[ CELL_GRID_COUNT ];std::vector< HtmlValues > m_cellFrontCells[ CELL_GRID_COUNT ]; ///< each grid's cells as the bar's page last placed them- enum { ORDER_KEYS = 3 }; ///< the page's attack, hold position and move keys+ enum { ORDER_KEYS = 6 }; ///< the page's attack, hold position and move keys, then the OrderKeyExtra onesIRegion2D m_orderKeyCell[ ORDER_KEYS ]; ///< where the page last put each, screen pixels- Bool m_orderKeysShown;+ Int m_orderKeyPlace[ ORDER_KEYS ]; ///< the CommandPlace each stands on, -1 while it is not shownDisplayString * m_orderKeyString[ ORDER_KEYS ]; ///< each one's letter, on the command buttons' plateInt m_orderKeyPoints; ///< the size those were last lettered at: HUD Size changes in a matchBool m_promotionPageLoaded;@@ -1857,6 +1871,7 @@ protected:Bool m_attackMoveToMode; ///< are we in attack move mode?Bool m_forceAttackArmed; ///< is the attack key holding force fire for the next click?Bool m_guardArmed; ///< is the guard key holding a guard order for the next click?+ AreaOrder m_areaOrder; ///< the sweep the scout or search and destroy key holds for the next clickReal m_areaPickScale; ///< what the wheel has made of the armed area order's default radiusBool m_moveArmed; ///< is the move key holding a move for the next click?Bool m_orderKeyKeptByShift; ///< an armed key was clicked with under shift, and drops when shift comes updiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.hindex b4ea0939e..f870a68bb 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h@@ -379,6 +379,10 @@ public:// the radius a player's guard order gave this unit; 0 leaves it on its own vision-based rangeReal getGuardRadius() const { return m_guardRadius; }void setGuardRadius( Real radius ) { m_guardRadius = radius; }+ // A player's unit on the aggressive stance takes what it sees, not only what it can already+ // shoot, and goes after it the way a computer player's unit does. Defensive is EA's rule+ Bool hasAggressiveStance() const { return m_aggressiveStance; }+ void setAggressiveStance( Bool aggressive ) { m_aggressiveStance = aggressive; }virtual Object* construct( const ThingTemplate *what,const Coord3D *pos, Real angle,@@ -855,6 +859,7 @@ private:GuardMode m_guardMode;Real m_guardRadius; ///< set by a player's guard order; 0 for the vision-based range+ Bool m_aggressiveStance; ///< set by MSG_SET_STANCE; FALSE is the defensive stance, EA'sGuardTargetType m_guardTargetType[2];Coord3D m_locationToGuard;ObjectID m_objectToGuard;diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.hindex c0d5ef10c..8d2cf568d 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/ScenarioDrill.h@@ -82,7 +82,10 @@ enum ScenarioActionTypeSCENARIO_ACTION_SHIFTPOWER, ///< shiftpower <slot> <selector> <targetSlot> <targetSelector> <power>; the same with a special power armed, on one objectSCENARIO_ACTION_SHIFTUPGRADE, ///< shiftupgrade <slot> <selector> <upgrade>; shift on an object upgrade button, bought by every unit that matchesSCENARIO_ACTION_DOCK, ///< dock <slot> <selector> <targetSlot> <targetSelector>; a right click on a supply point or a dock- SCENARIO_ACTION_CONSTRUCT ///< construct <slot> <template> <position>; the local player's placement click, whatever is selected, as a message that is recorded and crosses the network+ SCENARIO_ACTION_CONSTRUCT, ///< construct <slot> <template> <position>; the local player's placement click, whatever is selected, as a message that is recorded and crosses the network+ SCENARIO_ACTION_STANCE, ///< stance <slot> <selector> aggressive|defensive; the stance key, as MSG_SET_STANCE+ SCENARIO_ACTION_SCOUT, ///< scout <slot> <selector> <position> [radius]; the scout key's sweep, through the order queue as its messages arrive+ SCENARIO_ACTION_HUNT ///< hunt <slot> <selector> <position> [radius]; the same with search and destroy};/// ScenarioAction::atStart when the position is plain numbersdiff --git a/GeneralsMD/Code/GameEngine/Source/Common/DrawnPath.cpp b/GeneralsMD/Code/GameEngine/Source/Common/DrawnPath.cppindex b6aae36c9..da586b674 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/DrawnPath.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/DrawnPath.cpp@@ -22,6 +22,9 @@#include "Common/DrawnPath.h"#include "GameLogic/Object.h"+#include "GameLogic/PartitionManager.h"+#include "GameLogic/TerrainLogic.h"+#include "Lib/Trig.h"//-------------------------------------------------------------------------------------------------void buildPathArcLengths( const std::vector<Coord3D>& path, std::vector<Real>& arc )@@ -269,3 +272,68 @@ void assignAttacks( Int attackerCount, Int targetCount, std::vector<AttackAssign}}}++static const Real SWEEP_RING_SHARE = 0.7f; ///< the ring's radius as a share of the circle's+static const Real SWEEP_SPACING = 300.0f; ///< about how far apart two points stand along the ring+enum { SWEEP_POINTS_LEAST = 4, SWEEP_POINTS_MOST = 8 };++//-------------------------------------------------------------------------------------------------+void sweepPoints( Real centerX, Real centerY, Real radius, Real fromX, Real fromY,+ Real loX, Real loY, Real hiX, Real hiY, std::vector<Coord3D>& out )+{+ out.clear();+ const Real ring = radius * SWEEP_RING_SHARE;+ const Int count = min( max( (Int)REAL_TO_INT_CEIL( TWO_PI * ring / SWEEP_SPACING ), (Int)SWEEP_POINTS_LEAST ),+ (Int)SWEEP_POINTS_MOST );++ // a unit vector from the centre towards the selection, turned by one step for each point. A+ // selection standing on the centre starts east+ Real dx = fromX - centerX;+ Real dy = fromY - centerY;+ const Real length = sqrtf( dx * dx + dy * dy );+ if( length < 1.0f )+ {+ dx = 1.0f;+ dy = 0.0f;+ }+ else+ {+ dx /= length;+ dy /= length;+ }+ const Real step = -TWO_PI / count;+ const Real c = Cos( step );+ const Real s = Sin( step );+ for( Int i = 0; i < count; i++ )+ {+ Coord3D point;+ point.x = min( max( centerX + dx * ring, loX ), hiX );+ point.y = min( max( centerY + dy * ring, loY ), hiY );+ point.z = 0.0f;+ out.push_back( point );++ const Real turnedX = dx * c - dy * s;+ dy = dx * s + dy * c;+ dx = turnedX;+ }+}++//-------------------------------------------------------------------------------------------------+void sweepRoute( Int playerIndex, const Coord3D& center, Real radius, const Coord3D& from,+ std::vector<Coord3D>& route )+{+ Region3D extent;+ TheTerrainLogic->getExtent( &extent );+ std::vector<Coord3D> ring;+ sweepPoints( center.x, center.y, radius, from.x, from.y, extent.lo.x, extent.lo.y, extent.hi.x, extent.hi.y, ring );++ route.clear();+ for( std::vector<Coord3D>::iterator it = ring.begin(); it != ring.end(); ++it )+ {+ it->z = TheTerrainLogic->getGroundHeight( it->x, it->y );+ if( ThePartitionManager->getShroudStatusForPlayer( playerIndex, &(*it) ) != CELLSHROUD_CLEAR )+ route.push_back( *it );+ }+ if( route.empty() )+ route = ring;+}diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cppindex a42dc1960..3a1525630 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp@@ -664,6 +664,7 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)CHECK_IF(MSG_CHEAT)CHECK_IF(MSG_QUEUE_NEXT_ORDER)CHECK_IF(MSG_CLEAR_RALLY_POINT)+ CHECK_IF(MSG_SET_STANCE)CHECK_IF(MSG_DO_GUARD_OBJECT)CHECK_IF(MSG_DO_STOP)CHECK_IF(MSG_DO_SCATTER)diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/KindOf.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/KindOf.cppindex f3eeaf2d3..8739e934e 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/System/KindOf.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/KindOf.cpp@@ -160,6 +160,7 @@ template<> const char* KindOfMaskType::s_bitNameList[] ="CONSERVATIVE_BUILDING","IGNORE_DOCKING_BONES","NO_ATTACK_WARNING",+ "SCOUT",NULL};diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cppindex 4d7ab34c6..68c194f19 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBar.cpp@@ -378,6 +378,60 @@ Bool ControlBar_commandPlaces( const Int *types, const Int *groups, const Int *preturn fights;}+//-------------------------------------------------------------------------------------------------+void ControlBar_orderKeyPlaces( const Int *places, Int count, Bool fights, Bool scouts, Int *keys )+{+ Bool taken[ COMMAND_PLACE_COUNT ] = { FALSE };+ for( Int slot = 0; slot < count; slot++ )+ if( places[ slot ] >= 0 )+ taken[ places[ slot ] ] = TRUE;+ if( fights )+ taken[ COMMAND_PLACE_ATTACK ] = taken[ COMMAND_PLACE_HOLD ] = taken[ COMMAND_PLACE_MOVE ] = TRUE;++ static const Int OWN[ ORDER_KEY_EXTRAS ] = { COMMAND_PLACE_G, COMMAND_PLACE_F, COMMAND_PLACE_H };+ const Bool offered[ ORDER_KEY_EXTRAS ] = { scouts, fights, fights };+ for( Int key = 0; key < ORDER_KEY_EXTRAS; key++ )+ {+ keys[ key ] = -1;+ if( offered[ key ] && !taken[ OWN[ key ] ] )+ keys[ key ] = OWN[ key ];+ }+ for( Int key = 0; key < ORDER_KEY_EXTRAS; key++ )+ if( keys[ key ] >= 0 )+ taken[ keys[ key ] ] = TRUE;++ for( Int key = 0; key < ORDER_KEY_EXTRAS; key++ )+ {+ if( !offered[ key ] || keys[ key ] >= 0 )+ continue;+ static const Int SPARE[] = { COMMAND_PLACE_B, COMMAND_PLACE_N };+ for( Int each = 0; each < (Int)ARRAY_SIZE( SPARE ) && keys[ key ] < 0; each++ )+ if( !taken[ SPARE[ each ] ] )+ keys[ key ] = SPARE[ each ];+ for( Int place = 0; place < COMMAND_PLACE_COUNT && keys[ key ] < 0; place++ )+ if( !taken[ place ] )+ keys[ key ] = place;+ if( keys[ key ] >= 0 )+ taken[ keys[ key ] ] = TRUE;+ }+}++//-------------------------------------------------------------------------------------------------+void ControlBar::getOrderKeyPlaces( Int *keys ) const+{+ Int places[ MAX_COMMANDS_PER_SET ];+ const Bool fights = getCommandPlaces( places );+ // no keys at all for a selection whose command group is hidden, as getCommandPlaces has no buttons+ Bool scouts = FALSE;+ if( !m_contextParent[ CP_COMMAND ]->winIsHidden() )+ {+ const DrawableList *selected = TheInGameUI->getAllSelectedLocalDrawables();+ for( DrawableListCIt it = selected->begin(); it != selected->end() && !scouts; ++it )+ scouts = (*it)->getObject() && (*it)->getObject()->isKindOf( KINDOF_SCOUT );+ }+ ControlBar_orderKeyPlaces( places, MAX_COMMANDS_PER_SET, fights, scouts, keys );+}+//-------------------------------------------------------------------------------------------------Bool ControlBar::getCommandPlaces( Int *places ) const{@@ -438,6 +492,18 @@ void ControlBar::pressCommandButton( Int place )if( place < 0 || place >= COMMAND_PLACE_COUNT )return;+ // the page's scout, search and destroy and stance keys stand where no button does+ Int keys[ ORDER_KEY_EXTRAS ];+ getOrderKeyPlaces( keys );+ for( Int key = 0; key < ORDER_KEY_EXTRAS; key++ )+ {+ if( keys[ key ] == place )+ {+ TheInGameUI->pressOrderKey( key );+ return;+ }+ }+const Int slot = resolveCommandSlot( place );GameWindow *win = ( slot == SLOT_NOTHING ) ? NULL : m_commandWindows[ slot ];if( win == NULL )diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cppindex 9af795550..13ac8703e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/InGameUI.cpp@@ -64,6 +64,7 @@#include "Common/SpecialPower.h"#include "GameClient/Anim2D.h"+#include "GameClient/CommandXlat.h"#include "GameClient/ControlBar.h"#include "GameClient/ControlBarScheme.h"#include "GameClient/MetaEvent.h"@@ -1255,10 +1256,12 @@ InGameUI::InGameUI()m_promotionFrontOverlay = NULL;for( Int grid = 0; grid < CELL_GRID_COUNT; grid++ )m_cellFrontOverlay[ grid ] = NULL;- m_orderKeysShown = FALSE;m_orderKeyPoints = 0;for( Int orderKey = 0; orderKey < ORDER_KEYS; orderKey++ )+ {m_orderKeyString[ orderKey ] = NULL;+ m_orderKeyPlace[ orderKey ] = -1;+ }m_promotionPageLoaded = FALSE;m_promotionShownMs = 0;m_promotionDrawnAt = 0;@@ -1334,6 +1337,7 @@ InGameUI::InGameUI()m_attackMoveToMode = false;m_forceAttackArmed = false;m_guardArmed = false;+ m_areaOrder = AREA_ORDER_NONE;m_areaPickScale = 1.0f;m_moveArmed = false;m_orderKeyKeptByShift = false;@@ -4232,6 +4236,7 @@ void InGameUI::reset( void )m_attackMoveToMode = false;m_forceAttackArmed = false;m_guardArmed = false;+ m_areaOrder = AREA_ORDER_NONE;m_areaPickScale = 1.0f;m_moveArmed = false;m_orderKeyKeptByShift = false;@@ -6619,7 +6624,7 @@ void InGameUI::createCommandHint( const GameMessage *msg )(TheRadar->isRadarHidden() ||ThePlayerList->getLocalPlayer()->hasRadar() == FALSE) )setMouseCursor( Mouse::ARROW );- else if( isGuardArmed() )+ else if( isGuardArmed() || m_areaOrder != AREA_ORDER_NONE )setMouseCursor( Mouse::CROSS ); // the targeting cross, the cursor EA's own guard button armselsesetMouseCursor( Mouse::MOVETO );@@ -7358,13 +7363,15 @@ void InGameUI::adjustPlacementRowGap( Real spin )static const Real AREA_PICK_RADIUS_MIN = 50.0f;static const Real AREA_PICK_STEP = 1.15f; ///< what one notch of the wheel multiplies the radius by+static const Real AREA_SWEEP_RADIUS = 300.0f; ///< a scout's or a search and destroy's circle before the wheel//--------------------------------------------------------------------------------------------------/** The guard key, or one of EA's guard buttons waiting for its click. */+/** The guard key, the scout and search and destroy keys, or one of EA's guard buttons waiting for+ * its click. *///-------------------------------------------------------------------------------------------------Bool InGameUI::isAreaPicking( void ) const{- if( m_guardArmed )+ if( m_guardArmed || m_areaOrder != AREA_ORDER_NONE )return TRUE;const CommandButton *command = m_pendingGUICommand;@@ -7376,10 +7383,14 @@ Bool InGameUI::isAreaPicking( void ) const//-------------------------------------------------------------------------------------------------/** The radius the armed order starts from before the wheel touches it. A guard used to cover* each unit's own vision, so riflemen and rocket troops on one spot held two different circles;- * the whole selection now takes the widest of them. */+ * the whole selection now takes the widest of them. A sweep's circle is the ground to cover, which+ * has nothing to do with how far its units see, so it starts the same for every selection. *///--------------------------------------------------------------------------------------------------static Real areaPickBaseRadius( const DrawableList& selected )+static Real areaPickBaseRadius( const DrawableList& selected, Bool sweeping ){+ if( sweeping )+ return AREA_SWEEP_RADIUS;+Real widest = 0.0f;for( DrawableList::const_iterator it = selected.begin(); it != selected.end(); ++it ){@@ -7393,7 +7404,7 @@ static Real areaPickBaseRadius( const DrawableList& selected )//-------------------------------------------------------------------------------------------------Real InGameUI::getAreaPickRadius( void ) const{- const Real radius = areaPickBaseRadius( m_selectedDrawables ) * m_areaPickScale;+ const Real radius = areaPickBaseRadius( m_selectedDrawables, m_areaOrder != AREA_ORDER_NONE ) * m_areaPickScale;return min( max( radius, AREA_PICK_RADIUS_MIN ), GUARD_RADIUS_MAX );}@@ -7404,7 +7415,7 @@ Real InGameUI::getAreaPickRadius( void ) const//-------------------------------------------------------------------------------------------------void InGameUI::adjustAreaPickRadius( Real notches ){- const Real base = areaPickBaseRadius( m_selectedDrawables );+ const Real base = areaPickBaseRadius( m_selectedDrawables, m_areaOrder != AREA_ORDER_NONE );if( base <= 0.0f )return;@@ -7412,6 +7423,100 @@ void InGameUI::adjustAreaPickRadius( Real notches )m_areaPickScale = min( max( m_areaPickScale, AREA_PICK_RADIUS_MIN / base ), GUARD_RADIUS_MAX / base );}+//-------------------------------------------------------------------------------------------------+void InGameUI::toggleAreaOrderArmed( AreaOrder order )+{+ m_areaOrder = ( m_areaOrder == order ) ? AREA_ORDER_NONE : order;+ m_areaPickScale = 1.0f;+ m_attackMoveToMode = FALSE;+ m_forceAttackArmed = FALSE;+ m_guardArmed = FALSE;+ m_moveArmed = FALSE;+}++//-------------------------------------------------------------------------------------------------+/** The first unit of the player's in the selection with a stance to read, for the stance key's face+ * and for which stance a press switches the selection to. */+//-------------------------------------------------------------------------------------------------+static Bool isSelectionAggressive( void )+{+ const DrawableList *selected = TheInGameUI->getAllSelectedLocalDrawables();+ for( DrawableListCIt it = selected->begin(); it != selected->end(); ++it )+ {+ const Object *obj = (*it)->getObject();+ if( obj && obj->getAI() )+ return obj->getAI()->hasAggressiveStance();+ }+ return FALSE;+}++//-------------------------------------------------------------------------------------------------+void InGameUI::pressOrderKey( Int key )+{+ if( key == ORDER_KEY_SCOUT )+ toggleAreaOrderArmed( AREA_ORDER_SCOUT );+ else if( key == ORDER_KEY_HUNT )+ toggleAreaOrderArmed( AREA_ORDER_HUNT );+ else if( key == ORDER_KEY_STANCE && getSelectCount() > 0 )+ {+ GameMessage *stance = TheMessageStream->appendMessage( GameMessage::MSG_SET_STANCE );+ stance->appendIntegerArgument( isSelectionAggressive() ? 0 : 1 );+ }+}++//-------------------------------------------------------------------------------------------------+/** The ring is walked from the point nearest the selection, each point an order of its own on the+ * units' list (OrderQueue.h): the first replaces what they were doing, unless shift puts the whole+ * sweep behind it. A scout comes back to the centre; a search and destroy attack moves the ring,+ * so it fights what it meets, and ends guarding the circle it was given. */+//-------------------------------------------------------------------------------------------------+void InGameUI::issueAreaSweep( const Coord3D ¢er )+{+ const DrawableList *selected = getAllSelectedLocalDrawables();+ Coord3D from;+ from.zero();+ Int count = 0;+ for( DrawableListCIt it = selected->begin(); it != selected->end(); ++it )+ {+ const Object *obj = (*it)->getObject();+ if( obj == NULL )+ continue;+ from.x += obj->getPosition()->x;+ from.y += obj->getPosition()->y;+ count++;+ }+ if( count == 0 )+ return;+ from.x /= count;+ from.y /= count;++ const Bool hunt = m_areaOrder == AREA_ORDER_HUNT;+ const Real radius = getAreaPickRadius();+ std::vector<Coord3D> route;+ sweepRoute( ThePlayerList->getLocalPlayer()->getPlayerIndex(), center, radius, from, route );++ const GameMessage::Type step = hunt ? GameMessage::MSG_DO_ATTACKMOVETO : GameMessage::MSG_DO_MOVETO;+ for( size_t i = 0; i < route.size(); i++ )+ {+ markNextOrderQueued( ( i == 0 && !isInWaypointMode() ) ? ORDER_QUEUE_FRESH : ORDER_QUEUE_APPEND );+ TheMessageStream->appendMessage( step )->appendLocationArgument( route[ i ] );+ }+ markNextOrderQueued( ORDER_QUEUE_APPEND );+ if( hunt )+ {+ GameMessage *guard = TheMessageStream->appendMessage( GameMessage::MSG_DO_GUARD_POSITION );+ guard->appendLocationArgument( center );+ guard->appendIntegerArgument( GUARDMODE_NORMAL );+ guard->appendRealArgument( radius );+ }+ else+ TheMessageStream->appendMessage( GameMessage::MSG_DO_MOVETO )->appendLocationArgument( center );++ pickAndPlayUnitVoiceResponse( selected, step );+ DEBUG_LOG(( "area sweep: %s round (%.0f,%.0f) radius %.0f, %d points, %d units\n", hunt ? "hunt" : "scout",+ center.x, center.y, radius, (Int)route.size(), count ));+}+//-------------------------------------------------------------------------------------------------/** Every piece faces 'angle', the heading on the ghost before the drag began: the drag is spent on* the row, so it cannot aim as well. The row stops where the money does, which is what the logic@@ -11475,7 +11580,8 @@ static void armSignalFromPage( const std::string &kind )//-------------------------------------------------------------------------------------------------/** data-click="order:attack", "order:hold" or "order:move", the command panel's orders no command set* has a button for: what the A, C and V keys do, force fire armed for the next click, hold position,- * and a move armed for the next click. */+ * and a move armed for the next click. "order:scout", "order:hunt" and "order:stance" are the+ * keys after them, pressOrderKey's. *///-------------------------------------------------------------------------------------------------static void orderFromPage( const std::string &order ){@@ -11483,6 +11589,12 @@ static void orderFromPage( const std::string &order )TheInGameUI->toggleForceAttackArmed();else if( order == "move" )TheInGameUI->toggleMoveArmed();+ else if( order == "scout" )+ TheInGameUI->pressOrderKey( ORDER_KEY_SCOUT );+ else if( order == "hunt" )+ TheInGameUI->pressOrderKey( ORDER_KEY_HUNT );+ else if( order == "stance" )+ TheInGameUI->pressOrderKey( ORDER_KEY_STANCE );else if( order == "hold" && TheInGameUI->getSelectCount() > 0 ){GameMessage *hold = TheMessageStream->appendMessage( GameMessage::MSG_DO_HOLD_POSITION );@@ -12071,20 +12183,22 @@ void InGameUI::drawCellGridFront( Int grid )// once, in a box with no width of its own, which this layout engine gives no background: the// letter stood bare on the picture in a lighter face than its neighbours'.//- if( grid == CELL_GRID_COMMAND && m_orderKeysShown )+ if( grid == CELL_GRID_COMMAND ){- static const Int ORDER_KEY_PLACES[ ORDER_KEYS ] = { COMMAND_PLACE_ATTACK, COMMAND_PLACE_HOLD, COMMAND_PLACE_MOVE };enum { ORDER_KEY_POINTS = 7 }; // W3DPushButton.cpp's BADGE_DESIGN_POINTS, the buttons' corner markingsconst AsciiString fontName = numberedWindow( "ButtonCommand", 1 )->winGetFont()->nameString;const Int points = max( (Int)HUD_READOUT_POINTS_LEAST, (Int)REAL_TO_INT_FLOOR( ORDER_KEY_POINTS * ControlBarHudScale() ) );for( Int key = 0; key < ORDER_KEYS; key++ ){+ if( m_orderKeyPlace[ key ] < 0 )+ continue;+// a letter never changes by itself, so a new HUD Size is what letters it againif( points != m_orderKeyPoints && m_orderKeyString[ key ] != NULL )m_orderKeyString[ key ]->setText( UnicodeString::TheEmptyString );UnicodeString letter;- letter.translate( AsciiString( commandSlotKey( ORDER_KEY_PLACES[ key ] ).c_str() ) );+ letter.translate( AsciiString( commandSlotKey( m_orderKeyPlace[ key ] ).c_str() ) );HudReadout_draw( fitReadoutString( m_orderKeyString[ key ], letter, fontName, points, m_orderKeyCell[ key ] ),m_orderKeyCell[ key ], HUD_READOUT_TOP_LEFT, GameMakeColor( 255, 255, 255, 255 ) );}@@ -12279,6 +12393,12 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, I// attack, hold position and move have no button in any command set: the page's keys do what A, C// and V do, for anything that attack movestaken[ COMMAND_PLACE_ATTACK ] = taken[ COMMAND_PLACE_HOLD ] = taken[ COMMAND_PLACE_MOVE ] = fights;+ // and scout, search and destroy and the stance key wherever there is room for them+ Int extraKeys[ ORDER_KEY_EXTRAS ];+ TheControlBar->getOrderKeyPlaces( extraKeys );+ for( Int key = 0; key < ORDER_KEY_EXTRAS; key++ )+ if( extraKeys[ key ] >= 0 )+ taken[ extraKeys[ key ] ] = TRUE;// The power bar lies in the command grid's header strip, as long as the strip less a margin each endconst IRegion2D gridHeader = wellHeader( gridWell, scale );@@ -12409,14 +12529,17 @@ Bool InGameUI::drawControlBarPage( const IRegion2D *panels, const Bool *shown, Ifor( Int button = 0; button < COMMAND_BUTTONS; button++ )if( where[ button ] >= 0 )TheControlBar->placeWindowAt( numberedWindow( "ButtonCommand", button + 1 ), place[ where[ button ] ] );- putPageRect( values, "attackkey", place[ COMMAND_PLACE_ATTACK ], centreShown && fights, scale );- putPageRect( values, "holdkey", place[ COMMAND_PLACE_HOLD ], centreShown && fights, scale );- putPageRect( values, "movekey", place[ COMMAND_PLACE_MOVE ], centreShown && fights, scale );- // their letters are drawCellGridFront's, on the command buttons' own plate- m_orderKeysShown = centreShown && fights;- m_orderKeyCell[ 0 ] = place[ COMMAND_PLACE_ATTACK ];- m_orderKeyCell[ 1 ] = place[ COMMAND_PLACE_HOLD ];- m_orderKeyCell[ 2 ] = place[ COMMAND_PLACE_MOVE ];+ // the page's own keys; their letters are drawCellGridFront's, on the command buttons' own plate+ static const char *const ORDER_KEY_NAMES[ ORDER_KEYS ] = { "attackkey", "holdkey", "movekey", "scoutkey", "huntkey", "stancekey" };+ const Int orderKeyPlaces[ ORDER_KEYS ] = { fights ? COMMAND_PLACE_ATTACK : -1, fights ? COMMAND_PLACE_HOLD : -1,+ fights ? COMMAND_PLACE_MOVE : -1, extraKeys[ ORDER_KEY_SCOUT ], extraKeys[ ORDER_KEY_HUNT ], extraKeys[ ORDER_KEY_STANCE ] };+ for( Int key = 0; key < ORDER_KEYS; key++ )+ {+ m_orderKeyPlace[ key ] = centreShown ? orderKeyPlaces[ key ] : -1;+ m_orderKeyCell[ key ] = place[ max( m_orderKeyPlace[ key ], 0 ) ];+ putPageRect( values, ORDER_KEY_NAMES[ key ], m_orderKeyCell[ key ], m_orderKeyPlace[ key ] >= 0, scale );+ }+ values[ "stance" ] = isSelectionAggressive() ? "aggressive" : "defensive";// the selection's well left of the grid: a lone unit's portrait and upgrades, or a group's types,// the owner's rule. A watcher has no command panel and keeps the portrait of what he clicked@@ -14880,18 +15003,20 @@ Bool InGameUI::drawTooltipPage( const UnicodeString &cursorText, const RGBColorconst ICoord2D &mouse = TheMouse->getMouseStatus()->pos;const BuildTooltipCard *card = TheControlBar->getBuildTooltipCard();- // the attack, hold position and move keys are the page's own, with no window behind them for the- // bar's tooltip to find, so their cards are made here and stand on the console as a button's does- static const char *const ORDER_KEY_LABELS[ ORDER_KEYS ] = { "GUI:OrderForceAttack", "GUI:OrderHoldPosition", "GUI:OrderMove" };+ // the attack, hold position and move keys and the three after them are the page's own, with no+ // window behind them for the bar's tooltip to find, so their cards are made here and stand on the+ // console as a button's does. The stance key's card names the stance the selection is on+ static const char *const ORDER_KEY_LABELS[ ORDER_KEYS ] = { "GUI:OrderForceAttack", "GUI:OrderHoldPosition", "GUI:OrderMove",+ "GUI:OrderScout", "GUI:OrderSearchAndDestroy", "GUI:OrderStanceDefensive" };BuildTooltipCard orderCard = BuildTooltipCard();- if( m_controlBarPageShown && m_orderKeysShown && !areTooltipsDisabled() && !isQuitMenuVisible() )+ if( m_controlBarPageShown && !areTooltipsDisabled() && !isQuitMenuVisible() ){for( Int key = 0; key < ORDER_KEYS; key++ ){const IRegion2D &cell = m_orderKeyCell[ key ];- if( mouse.x < cell.lo.x || mouse.x >= cell.hi.x || mouse.y < cell.lo.y || mouse.y >= cell.hi.y )+ if( m_orderKeyPlace[ key ] < 0 || mouse.x < cell.lo.x || mouse.x >= cell.hi.x || mouse.y < cell.lo.y || mouse.y >= cell.hi.y )continue;- AsciiString label = ORDER_KEY_LABELS[ key ];+ AsciiString label = ( key == ORDER_KEYS - 1 && isSelectionAggressive() ) ? "GUI:OrderStanceAggressive" : ORDER_KEY_LABELS[ key ];orderCard.name = TheGameText->fetch( label );label.concat( "Description" );orderCard.description = TheGameText->fetch( label );diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cppindex e03dd9b7e..e7fbfcc7d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp@@ -1610,6 +1610,16 @@ GameMessage::Type CommandTranslator::evaluateContextCommand( Drawable *draw,const Coord3D *pos,CommandEvaluateType type ){+ // the scout and search and destroy keys sweep a circle round the point, whatever stands on it+ if( TheInGameUI->getAreaOrderArmed() != InGameUI::AREA_ORDER_NONE && TheInGameUI->areSelectedObjectsControllable() )+ {+ if( type == DO_COMMAND )+ TheInGameUI->issueAreaSweep( *pos );+ else if( type == DO_HINT )+ TheMessageStream->appendMessage( GameMessage::MSG_DO_MOVETO_HINT )->appendLocationArgument( *pos );+ return type == DO_COMMAND ? GameMessage::MSG_DO_MOVETO : GameMessage::MSG_DO_MOVETO_HINT;+ }+Object *obj = draw ? draw->getObject() : NULL;Drawable *drawableInWay = draw;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cppindex bfd79a9b9..921c8c27a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIStates.cpp@@ -2674,11 +2674,12 @@ StateReturnType AIAttackApproachTargetState::onEnter()// Check here: If we are a player, and we got to this state via an ai command (ie we auto-acquired),// we don't want to chase the unit. isAllowedToChase is set when we are in a deploy and attack state (troop crawler).// Kris (July 2003): If we are retaliating... don't fail out!+ // A player's unit on the aggressive stance chases by the computer player's rule.if( ai->getCurrentStateID() != AI_GUARD_RETALIATE ){- if (source->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN)+ if (source->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN && !ai->hasAggressiveStance()){- if (ai->getLastCommandSource() == CMD_FROM_AI && !ai->isAllowedToChase() )+ if (ai->getLastCommandSource() == CMD_FROM_AI && !ai->isAllowedToChase() ){if (!weapon->isContactWeapon()){@@ -3046,11 +3047,12 @@ StateReturnType AIAttackPursueTargetState::onEnter()// Check here: If we are a player, and we got to this state via an ai command (ie we auto-acquired),// we don't want to chase the unit.// Kris (July 2003): If we are retaliating... don't succeed out!+ // The aggressive stance chases, as above.if( ai->getCurrentStateID() != AI_GUARD_RETALIATE ){- if (source->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN)+ if (source->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN && !ai->hasAggressiveStance()){- if (ai->getLastCommandSource() == CMD_FROM_AI)+ if (ai->getLastCommandSource() == CMD_FROM_AI){return STATE_SUCCESS;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cppindex 112595223..50f28d4c0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/OrderQueue.cpp@@ -213,14 +213,22 @@ static Bool OrderQueue_isUsingAbility( const Object *obj )//-------------------------------------------------------------------------------------------------/** Is this unit busy with an order the player gave? A fight it picked for itself while standing* about is not one: the group is done, and the next order takes it off that fight. Nor is a- * guard, which never ends. */+ * guard, which never ends. A fight an attack move stopped for is the order itself, though it+ * marks itself the AI's while it lasts: without this a queued attack move ended the moment it met+ * anybody, and a search and destroy skipped the rest of its ring at the first enemy. *///-------------------------------------------------------------------------------------------------static Bool OrderQueue_isWorking( const Object *obj, const AIUpdateInterface *ai ){if( OrderQueue_isUsingAbility( obj ) )return TRUE;- if( ai->isIdle() || ai->getLastCommandSource() != CMD_FROM_PLAYER )+ if( ai->isIdle() )+ return FALSE;++ if( ai->getCurrentStateID() == AI_ATTACK_MOVE_TO )+ return TRUE;++ if( ai->getLastCommandSource() != CMD_FROM_PLAYER )return FALSE;switch( ai->getCurrentStateID() )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 065210ef0..5868c5e4d 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -291,6 +291,7 @@ AIUpdateInterface::AIUpdateInterface( Thing *thing, const ModuleData* moduleDatam_lastCommandSource = CMD_FROM_AI;m_guardMode = GUARDMODE_NORMAL;m_guardRadius = 0.0f;+ m_aggressiveStance = FALSE;m_guardTargetType[0] = m_guardTargetType[1] = GUARDTARGET_NONE;m_locationToGuard.zero();m_objectToGuard = INVALID_ID;@@ -6858,8 +6859,10 @@ Object* AIUpdateInterface::getNextMoodTarget( Bool calledByAI, Bool calledDuring// allow us to pursue the target. therefore, we should ensure that we only// look for targets that are already within attack range (as opposed to vision range).// The caller can lift that restriction (attack move does) when it will actually close- // with what it finds instead of driving past it.- if (calledByAI && !allowOutOfWeaponRangeTargets && obj->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN)+ // with what it finds instead of driving past it, and so does a unit the player has put on the+ // aggressive stance, which goes after what it sees (AIAttackApproachTargetState lets it).+ if (calledByAI && !allowOutOfWeaponRangeTargets && !m_aggressiveStance+ && obj->getControllingPlayer()->getPlayerType() == PLAYER_HUMAN){flags |= AI::WITHIN_ATTACK_RANGE;}@@ -7317,12 +7320,13 @@ void AIUpdateInterface::crc( Xfer *x )* 16: the tunnel trip's goal and its flag* 17: how the tunnel trip's last leg is walked* 18: the target a helicopter keeps shooting while it moves away- * 19: the radius a player's guard order set */+ * 19: the radius a player's guard order set+ * 20: the aggressive stance */// ------------------------------------------------------------------------------------------------void AIUpdateInterface::xfer( Xfer *xfer ){// version- const XferVersion currentVersion = 19;+ const XferVersion currentVersion = 20;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -7664,6 +7668,9 @@ void AIUpdateInterface::xfer( Xfer *xfer )if (version >= 19)xfer->xferReal(&m_guardRadius);+ if (version >= 20)+ xfer->xferBool(&m_aggressiveStance);+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cppindex 7dfbcf2e1..756bc1bfa 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogicDispatch.cpp@@ -756,6 +756,30 @@ void GameLogic::logicMessageDispatcher( GameMessage *msg, AIGroup *orderedGroup}+ //---------------------------------------------------------------------------------------------+ // The stance key (fork): every selected unit of the sender's takes the stance. The number came+ // over the network, so only 0 and 1 mean anything+ case GameMessage::MSG_SET_STANCE:+ {+ if( currentlySelectedGroup == NULL || msg->getArgumentCount() < 1+ || msg->getArgumentDataType( 0 ) != ARGUMENTDATATYPE_INTEGER )+ break;+ const Int stance = msg->getArgument( 0 )->integer;+ if( stance != 0 && stance != 1 )+ break;++ const VecObjectID& ids = currentlySelectedGroup->getAllIDs();+ for( VecObjectID::const_iterator it = ids.begin(); it != ids.end(); ++it )+ {+ Object *obj = TheGameLogic->findObjectByID( *it );+ if( obj && obj->getControllingPlayer() == thisPlayer && obj->getAIUpdateInterface() )+ obj->getAIUpdateInterface()->setAggressiveStance( stance == 1 );+ }+ DEBUG_LOG(( "STANCE: frame %d player %d %s, %d selected\n", TheGameLogic->getFrame(),+ msg->getPlayerIndex(), stance == 1 ? "aggressive" : "defensive", (Int)ids.size() ));+ break;+ }+//---------------------------------------------------------------------------------------------case GameMessage::MSG_DO_WEAPON:{diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cppindex 8b75f69d7..26c1ce051 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/ScenarioDrill.cpp@@ -26,6 +26,7 @@#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine#include "Common/BuildAssistant.h"+#include "Common/DrawnPath.h"#include "Common/file.h"#include "Common/FileSystem.h"#include "Common/GlobalData.h"@@ -87,10 +88,15 @@ static const Int SCENARIO_TOKENS_SPAWN = 6;static const Int SCENARIO_TOKENS_ARRIVE = 5;static const Int SCENARIO_TOKENS_SHIFTPOWER = 7;static const Int SCENARIO_TOKENS_SHIFTUPGRADE = 5;+static const Int SCENARIO_TOKENS_STANCE = 5;// where the name sits in the lines that carry onestatic const Int SCENARIO_SHIFTPOWER_NAME_TOKEN = 6;static const Int SCENARIO_SHIFTUPGRADE_NAME_TOKEN = 4;+static const Int SCENARIO_STANCE_NAME_TOKEN = 4;++/// a scout's or a hunt's circle when the line does not say, the keys' own before the wheel+static const Real SCENARIO_DEFAULT_SWEEP_RADIUS = 300.0f;// where the position starts in each line that has onestatic const Int SCENARIO_SPAWN_POSITION_TOKEN = 5;@@ -209,6 +215,12 @@ static Bool parseActionType( const AsciiString &token, ScenarioActionType *actio*action = SCENARIO_ACTION_SHIFTUPGRADE;else if (token == "construct")*action = SCENARIO_ACTION_CONSTRUCT;+ else if (token == "stance")+ *action = SCENARIO_ACTION_STANCE;+ else if (token == "scout")+ *action = SCENARIO_ACTION_SCOUT;+ else if (token == "hunt")+ *action = SCENARIO_ACTION_HUNT;elsereturn FALSE;@@ -291,6 +303,9 @@ static Int tokensNeededFor( ScenarioActionType action )case SCENARIO_ACTION_SHIFTATTACKMOVE: return SCENARIO_TOKENS_MOVE;case SCENARIO_ACTION_SHIFTGUARD: return SCENARIO_TOKENS_MOVE;case SCENARIO_ACTION_CONSTRUCT: return SCENARIO_TOKENS_MOVE;+ case SCENARIO_ACTION_SCOUT: return SCENARIO_TOKENS_MOVE;+ case SCENARIO_ACTION_HUNT: return SCENARIO_TOKENS_MOVE;+ case SCENARIO_ACTION_STANCE: return SCENARIO_TOKENS_STANCE;case SCENARIO_ACTION_SHIFTATTACK: return SCENARIO_TOKENS_ATTACK;case SCENARIO_ACTION_SHIFTPOWER: return SCENARIO_TOKENS_SHIFTPOWER;case SCENARIO_ACTION_SHIFTUPGRADE: return SCENARIO_TOKENS_SHIFTUPGRADE;@@ -371,11 +386,15 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *acase SCENARIO_ACTION_SHIFTATTACKMOVE:case SCENARIO_ACTION_SHIFTGUARD:case SCENARIO_ACTION_CONSTRUCT:+ case SCENARIO_ACTION_SCOUT:+ case SCENARIO_ACTION_HUNT:{Int next = SCENARIO_ORDER_POSITION_TOKEN;const ScenarioParseResult position = parseScenarioPosition( tokens, count, &next, action );if (position != SCENARIO_PARSE_OK)return position;+ if (actionType == SCENARIO_ACTION_SCOUT || actionType == SCENARIO_ACTION_HUNT)+ action->radius = (count > next) ? (Real)atof( tokens[ next ].str() ) : SCENARIO_DEFAULT_SWEEP_RADIUS;if (actionType == SCENARIO_ACTION_ARRIVE && count > next)action->radius = (Real)atof( tokens[ next ].str() );if (actionType == SCENARIO_ACTION_SHIFTGUARD)@@ -403,6 +422,12 @@ ScenarioParseResult ScenarioDrill_parseLine( const char *line, ScenarioAction *aaction->name = tokens[ SCENARIO_SHIFTUPGRADE_NAME_TOKEN ];break;+ case SCENARIO_ACTION_STANCE:+ action->name = tokens[ SCENARIO_STANCE_NAME_TOKEN ];+ if (action->name != "aggressive" && action->name != "defensive")+ return SCENARIO_PARSE_BAD_ACTION;+ break;+case SCENARIO_ACTION_PRODUCE:{action->targetSelector = tokens[ 4 ]; // what to make@@ -1286,6 +1311,75 @@ static Bool executeShiftUpgrade( const ScenarioAction &action, Player *player )return TRUE;}+/** The stance key: MSG_SET_STANCE handed to the dispatcher with the matching units as the selection,+ which is how it arrives from a player. The dispatcher destroys the group. */+static Bool executeStance( const ScenarioAction &action, Player *player, AIGroup *group, Int taken )+{+ GameMessage *msg = newInstance( GameMessage )( GameMessage::MSG_SET_STANCE );+ msg->friend_setPlayerIndex( player->getPlayerIndex() );+ msg->appendIntegerArgument( action.name == "aggressive" ? 1 : 0 );+ TheGameLogic->logicMessageDispatcher( msg, group );+ msg->deleteInstance();++ DEBUG_LOG(("SCENARIO: frame %d stance slot %d '%s' x%d %s\n",+ action.frame, action.slot, action.selector.str(), taken, action.name.str()));+ return TRUE;+}++/** The scout and search and destroy keys: the ring sweepRoute gives this seat round the point, from+ where the units stand, each point handed to the order queue the way the key's messages arrive -+ the first fresh, the rest behind it - and then the centre, or a guard of the whole circle. Each+ message gets a group of its own, because the queue destroys the one it takes. */+static Bool executeSweep( const ScenarioAction &action, Player *player, const Coord3D ¢er, AIGroup *group, Int taken )+{+ Coord3D from;+ from.zero();+ const VecObjectID ids = group->getAllIDs();+ for( VecObjectID::const_iterator it = ids.begin(); it != ids.end(); ++it )+ {+ const Object *obj = TheGameLogic->findObjectByID( *it );+ from.x += obj->getPosition()->x;+ from.y += obj->getPosition()->y;+ }+ from.x /= taken;+ from.y /= taken;+ TheAI->destroyGroup( group );++ const Bool hunt = action.action == SCENARIO_ACTION_HUNT;+ std::vector<Coord3D> route;+ sweepRoute( player->getPlayerIndex(), center, action.radius, from, route );+ route.push_back( center );++ for( size_t i = 0; i < route.size(); i++ )+ {+ const Bool last = i + 1 == route.size();+ GameMessage::Type type = hunt ? GameMessage::MSG_DO_ATTACKMOVETO : GameMessage::MSG_DO_MOVETO;+ if( last && hunt )+ type = GameMessage::MSG_DO_GUARD_POSITION;+ GameMessage *msg = newInstance( GameMessage )( type );+ msg->friend_setPlayerIndex( player->getPlayerIndex() );+ msg->appendLocationArgument( route[ i ] );+ if( type == GameMessage::MSG_DO_GUARD_POSITION )+ {+ msg->appendIntegerArgument( GUARDMODE_NORMAL );+ msg->appendRealArgument( action.radius );+ }++ AIGroup *members = TheAI->createGroup();+ gatherIntoGroup( player, action.selector, members );+ player->getOrderQueue()->setNextOrderMode( i == 0 ? ORDER_QUEUE_FRESH : ORDER_QUEUE_APPEND );+ player->getOrderQueue()->takeMessage( msg, members, player );+ msg->deleteInstance();++ DEBUG_LOG(("SCENARIO: frame %d %s slot %d '%s' step %d of %d at (%.0f,%.0f)\n", action.frame, hunt ? "hunt" : "scout",+ action.slot, action.selector.str(), (Int)i + 1, (Int)route.size(), route[ i ].x, route[ i ].y));+ }++ DEBUG_LOG(("SCENARIO: frame %d %s slot %d '%s' x%d round (%.0f,%.0f) radius %.0f\n", action.frame, hunt ? "hunt" : "scout",+ action.slot, action.selector.str(), taken, center.x, center.y, action.radius));+ return TRUE;+}+static Bool executeOrder( const ScenarioAction &action, Player *player, const Coord3D &dest ){if (action.action == SCENARIO_ACTION_SHIFTUPGRADE)@@ -1367,6 +1461,13 @@ static Bool executeOrder( const ScenarioAction &action, Player *player, const Cocase SCENARIO_ACTION_SHIFTPOWER:return executeShiftOrder( action, player, dest, group, taken ); // the group is gone either way+ case SCENARIO_ACTION_STANCE:+ return executeStance( action, player, group, taken ); // the dispatcher destroys the group++ case SCENARIO_ACTION_SCOUT:+ case SCENARIO_ACTION_HUNT:+ return executeSweep( action, player, dest, group, taken ); // and so does this+case SCENARIO_ACTION_STOP:{group->groupIdle( CMD_FROM_SCRIPT );diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cppindex 2f46c36ad..d59fa35f7 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DInGameUI.cpp@@ -447,12 +447,16 @@ void W3DInGameUI::draw( void )drawGuardMarkers();// the circle an armed guard will hold, under the cursor, at the size the wheel left it. A drag- // is drawing a guard line instead, where every unit holds its own station+ // is drawing a guard line instead, where every unit holds its own station. A scout's circle is+ // the move green and a search and destroy's the attack move colour, as their hints areif( isAreaPicking() && !m_isFormationDragging ){Coord3D center;TheTacticalView->screenToTerrain( &TheMouse->getMouseStatus()->pos, ¢er );- drawGroundRing( center, getAreaPickRadius(), 0xCC55CCFF, 2.0f ); // the guard blue the hints use+ const UnsignedInt color = getAreaOrderArmed() == AREA_ORDER_SCOUT ? 0xCC33FF33+ : getAreaOrderArmed() == AREA_ORDER_HUNT ? 0xCCFF66CC+ : 0xCC55CCFF; // the guard blue the hints use+ drawGroundRing( center, getAreaPickRadius(), color, 2.0f );}// for each view draw hintsdiff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex 4fee03b7b..ff6dd2f2a 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -3525,6 +3525,90 @@ TEST(controlbar_command_places_go_in_rows_by_what_they_are_for)CHECK_EQ( places[ slot ], manyPlaces[ slot ] );}+TEST(controlbar_scout_hunt_and_stance_keys_take_what_the_buttons_leave)+{+ enum { SLOTS = 14 };+ Int places[ SLOTS ];+ Int keys[ ORDER_KEY_EXTRAS ];+ const Int N = GUI_COMMAND_NONE, ab = COMMAND_GROUP_ABILITY, pa = COMMAND_GROUP_PASSENGER;+ const Int nothingPinned[ SLOTS ] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };++ /* a Ranger: two abilities, attack move, guard, stop. Search and destroy on F and the stance on H,+ their own places; no scout in the selection, so no scout key */+ const Int ranger[ SLOTS ] = { GUI_COMMAND_FIRE_WEAPON, GUI_COMMAND_SPECIAL_POWER, N, N, N, N, N, N, N, N,+ GUI_COMMAND_ATTACK_MOVE, N, GUI_COMMAND_GUARD, GUI_COMMAND_STOP };+ const Int rangerGroups[ SLOTS ] = { ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab, ab };+ Bool fights = ControlBar_commandPlaces( ranger, rangerGroups, nothingPinned, SLOTS, places );+ CHECK( fights );+ ControlBar_orderKeyPlaces( places, SLOTS, fights, FALSE, keys );+ CHECK_EQ( keys[ ORDER_KEY_SCOUT ], -1 );+ CHECK_EQ( keys[ ORDER_KEY_HUNT ], (Int)COMMAND_PLACE_F );+ CHECK_EQ( keys[ ORDER_KEY_STANCE ], (Int)COMMAND_PLACE_H );+ // the same with a Pathfinder in the selection puts scout on G between them+ ControlBar_orderKeyPlaces( places, SLOTS, fights, TRUE, keys );+ CHECK_EQ( keys[ ORDER_KEY_SCOUT ], (Int)COMMAND_PLACE_G );+ CHECK_EQ( keys[ ORDER_KEY_HUNT ], (Int)COMMAND_PLACE_F );+ CHECK_EQ( keys[ ORDER_KEY_STANCE ], (Int)COMMAND_PLACE_H );++ /* the Humvee's set, as in the test above: passengers hold F G H B N and the drones Q W E, so the+ three go on in reading order, R T Y, and never move a button */+ const Int humvee[ SLOTS ] = { GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_OBJECT_UPGRADE, GUI_COMMAND_OBJECT_UPGRADE,+ GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EXIT_CONTAINER,+ GUI_COMMAND_EXIT_CONTAINER, GUI_COMMAND_EVACUATE, N, GUI_COMMAND_ATTACK_MOVE, N, GUI_COMMAND_GUARD, GUI_COMMAND_STOP };+ const Int humveeGroups[ SLOTS ] = { ab, ab, ab, pa, pa, pa, pa, pa, ab, ab, ab, ab, ab, ab };+ fights = ControlBar_commandPlaces( humvee, humveeGroups, nothingPinned, SLOTS, places );+ ControlBar_orderKeyPlaces( places, SLOTS, fights, TRUE, keys );+ CHECK_EQ( keys[ ORDER_KEY_SCOUT ], (Int)COMMAND_PLACE_R );+ CHECK_EQ( keys[ ORDER_KEY_HUNT ], (Int)COMMAND_PLACE_T );+ CHECK_EQ( keys[ ORDER_KEY_STANCE ], (Int)COMMAND_PLACE_Y );++ /* a Radar Van: a scan and an upgrade, nothing to attack move with. Scout alone */+ const Int van[ SLOTS ] = { GUI_COMMAND_SPECIAL_POWER, GUI_COMMAND_OBJECT_UPGRADE, N, N, N, N, N, N, N, N, N, N, N, GUI_COMMAND_STOP };+ fights = ControlBar_commandPlaces( van, rangerGroups, nothingPinned, SLOTS, places );+ CHECK( !fights );+ ControlBar_orderKeyPlaces( places, SLOTS, fights, TRUE, keys );+ CHECK_EQ( keys[ ORDER_KEY_SCOUT ], (Int)COMMAND_PLACE_G );+ CHECK_EQ( keys[ ORDER_KEY_HUNT ], -1 );+ CHECK_EQ( keys[ ORDER_KEY_STANCE ], -1 );++ /* a grid with no room: every key stays off it */+ Int full[ SLOTS + 4 ];+ for( Int place = 0; place < COMMAND_PLACE_COUNT; place++ )+ full[ place ] = place;+ ControlBar_orderKeyPlaces( full, COMMAND_PLACE_COUNT, TRUE, TRUE, keys );+ for( Int key = 0; key < ORDER_KEY_EXTRAS; key++ )+ CHECK_EQ( keys[ key ], -1 );+}++/* The scout and search and destroy keys walk a ring at seven tenths of the circle, starting on the+ side the selection stands and going round clockwise, four to eight points by size, never off the map. */+TEST(sweep_points_go_round_the_ring_from_the_selection_side)+{+ std::vector<Coord3D> points;+ sweepPoints( 1000.0f, 1000.0f, 300.0f, 1000.0f, 0.0f, 0.0f, 0.0f, 4000.0f, 4000.0f, points );+ CHECK_EQ( (Int)points.size(), 5 ); // 2 pi 210 / 300 is 4.4+ CHECK_NEAR( points[ 0 ].x, 1000.0f, 0.01f );+ CHECK_NEAR( points[ 0 ].y, 790.0f, 0.01f );+ // clockwise from six o'clock is towards nine+ CHECK( points[ 1 ].x < 1000.0f - 150.0f );+ for( size_t i = 0; i < points.size(); i++ )+ {+ const Real dx = points[ i ].x - 1000.0f, dy = points[ i ].y - 1000.0f;+ CHECK_NEAR( (Real)sqrt( dx * dx + dy * dy ), 210.0f, 0.5f );+ }++ sweepPoints( 1000.0f, 1000.0f, 50.0f, 1000.0f, 1000.0f, 0.0f, 0.0f, 4000.0f, 4000.0f, points );+ CHECK_EQ( (Int)points.size(), 4 );+ CHECK_NEAR( points[ 0 ].x, 1035.0f, 0.01f ); // standing on the centre starts east+ sweepPoints( 1000.0f, 1000.0f, 800.0f, 0.0f, 0.0f, 0.0f, 0.0f, 4000.0f, 4000.0f, points );+ CHECK_EQ( (Int)points.size(), 8 );++ // a circle on the map's corner keeps every point on the map+ sweepPoints( 50.0f, 50.0f, 400.0f, 500.0f, 500.0f, 0.0f, 0.0f, 4000.0f, 4000.0f, points );+ for( size_t i = 0; i < points.size(); i++ )+ CHECK( points[ i ].x >= 0.0f && points[ i ].y >= 0.0f );+}+/* The money plate follows its figure's width: wider at once, narrower only once the narrower figurehas held for MONEY_SHRINK_HOLD_MS, and then eased down over MONEY_SHRINK_EASE_MS. */TEST(the_money_plate_grows_at_once_and_shrinks_only_after_a_hold)@@ -14762,6 +14846,19 @@ TEST(scenario_parses_the_order_lines)CHECK_STR( action.selector.str(), "ChinaGattlingCannon" );CHECK_EQ( (Int)ScenarioDrill_parseLine( "1800 tally 1", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );+ // the stance key, and the two sweeps with the keys' own circle unless the line sizes it+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "60 stance 0 AmericaTankCrusader aggressive", &action ), (Int)SCENARIO_PARSE_OK );+ CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_STANCE );+ CHECK_STR( action.name.str(), "aggressive" );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "60 stance 0 * bold", &action ), (Int)SCENARIO_PARSE_BAD_ACTION );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "60 stance 0 *", &action ), (Int)SCENARIO_PARSE_MISSING_ARGS );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "60 scout 0 * 900 700", &action ), (Int)SCENARIO_PARSE_OK );+ CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_SCOUT );+ CHECK( action.radius == 300.0f );+ CHECK_EQ( (Int)ScenarioDrill_parseLine( "60 hunt 0 * 900 700 450", &action ), (Int)SCENARIO_PARSE_OK );+ CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_HUNT );+ CHECK( action.radius == 450.0f );+CHECK_EQ( (Int)ScenarioDrill_parseLine( "700 power 1 GLAScudStorm start0:0:300", &action ),(Int)SCENARIO_PARSE_OK );CHECK_EQ( (Int)action.action, (Int)SCENARIO_ACTION_POWER );diff --git a/GeneralsMD/Code/Tools/net_check.py b/GeneralsMD/Code/Tools/net_check.pyindex b3951e870..b2f9265b5 100644--- a/GeneralsMD/Code/Tools/net_check.py+++ b/GeneralsMD/Code/Tools/net_check.py@@ -11,6 +11,7 @@ desync and show the check is looking.python net_check.py --each "-latAvg 120 -latNoise 60 -packetloss 5"python net_check.py --slot-args 1 "-drawdelay 100" # one slow rendererpython net_check.py --prove # must report a mismatch+ python net_check.py --each "-scenario netstance" --keys "KEY_A CTRL,KEY_H" # the stance key, both waysIt prints one line per copy and exits 1 when any log holds "CRC Mismatch" (0 with --prove means thedetector did not fire, which is the failure then). docs: the multiplayer reference in the wrapper.@@ -52,6 +53,8 @@ def parse_arguments() -> argparse.Namespace:parser.add_argument("--tag", default="net", help="log prefix; copy n logs to Run/<tag><n>_DebugLogFile.txt")parser.add_argument("--prove", action="store_true", help="spawn on copy 0 alone at frame 300")parser.add_argument("--prove-at", default="2192 3537", help="map position for --prove")+ parser.add_argument("--keys", default=",".join(PRESSES),+ help="the presses, comma separated, each as the control socket's key command takes it")return parser.parse_args()@@ -104,10 +107,11 @@ def play(arguments: argparse.Namespace, games: list) -> list:frames = list(start)proved = Falsepress = 0+ presses = arguments.keys.split(",")try:while min(frames) < arguments.frames:for game in games:- game.send("key " + PRESSES[press % len(PRESSES)])+ game.send("key " + presses[press % len(presses)])press += 1if arguments.prove and not proved and frames[0] >= PROVE_FRAME:games[0].send(PROVE_SPAWN % arguments.prove_at)diff --git a/GeneralsMD/Code/Tools/order_cameos.py b/GeneralsMD/Code/Tools/order_cameos.pyindex 60b1fc1a5..86bd9cdbd 100644--- a/GeneralsMD/Code/Tools/order_cameos.py+++ b/GeneralsMD/Code/Tools/order_cameos.py@@ -1,10 +1,14 @@-"""The command bar's attack, hold position and move cameos, painted in the manner of EA's command-cameos (SSStop, SSGuard): a sign with a bevelled steel rim and four bolts standing over a painted-backdrop. No command set has a button for any of these orders, so the game has no picture for them.+"""The command bar's attack, hold position, move, scout, search and destroy and stance cameos,+painted in the manner of EA's command cameos (SSStop, SSGuard): a sign with a bevelled steel rim and+four bolts standing over a painted backdrop. No command set has a button for any of these orders,+so the game has no picture for them.Attack is a red plate with a white crosshair over a burning sky, hold position a blue plate with a-raised palm over a blue one, move a green diamond with a white arrow over an overcast field. Each-is painted at four times its size and brought down, which is+raised palm over a blue one, move a green diamond with a white arrow over an overcast field. Scout+is an amber disc with an open eye over a dawn sky, search and destroy an orange plate with a+magnifying glass over a dusk one, the aggressive stance a red pennant of two chevrons pointing ahead+and the defensive one a steel blue shield. Each is painted at four times its size and brought down,+which iswhat softens the edges into the look of the shipped art. The noise is seeded, so the file comesout the same every time.@@ -22,8 +26,9 @@ from PIL import Image, ImageDraw, ImageFilterCAMEO_W, CAMEO_H = 60, 48 # every command cameo in the shipped mapped imagesSUPER = 4 # painted at this many times the size-TEXTURE_W, TEXTURE_H = 128, 128-CAMEO_PLACES = {"attack": (0, 0), "hold": (64, 0), "move": (0, 64)}+TEXTURE_W, TEXTURE_H = 256, 128+CAMEO_PLACES = {"attack": (0, 0), "hold": (64, 0), "move": (0, 64), "scout": (64, 64), "hunt": (128, 0),+ "aggressive": (192, 0), "defensive": (128, 64)}SEED = 20260928OUT_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "Data", "Art", "Textures", "ReforgedOrders.tga")@@ -181,6 +186,95 @@ def move(rng):return image+def corner_bolts(cx, cy, reach):+ return [(cx - reach, cy - reach), (cx + reach, cy - reach), (cx - reach, cy + reach), (cx + reach, cy + reach)]+++def octagon(left, top, right, bottom, cut):+ return [(left + cut, top), (right - cut, top), (right, top + cut), (right, bottom - cut),+ (right - cut, bottom), (left + cut, bottom), (left, bottom - cut), (left, top + cut)]+++def scout(rng):+ image = backdrop(rng, (60, 70, 112), (232, 172, 112), (240, 222, 200), (40, 36, 30))+ cx, cy, radius = W / 2, H / 2 - SUPER, H * 0.44+ plate(image, circle_points(cx, cy, radius), (222, 160, 28), corner_bolts(cx, cy, radius * 0.62))+ # an open eye: the white of it, a dark iris and a glint+ draw = ImageDraw.Draw(image)+ white = (248, 246, 240)+ across, tall = radius * 0.6, radius * 0.32+ eye = [(cx + across * math.cos(t), cy + tall * math.sin(t) * abs(math.sin(t)) ** 0.2)+ for t in np.linspace(0, 2 * math.pi, 64, endpoint=False)]+ draw.polygon(eye, fill=white)+ iris = tall * 0.95+ draw.ellipse((cx - iris, cy - iris, cx + iris, cy + iris), fill=(44, 40, 34))+ glint = iris * 0.32+ draw.ellipse((cx - glint - iris * 0.3, cy - glint - iris * 0.3, cx + glint - iris * 0.3, cy + glint - iris * 0.3),+ fill=white)+ return image+++def hunt(rng):+ image = backdrop(rng, (44, 32, 62), (200, 104, 62), (150, 122, 120), (30, 24, 22), glow=(255, 120, 40))+ left, top, right, bottom = W * 0.2, SUPER * 2, W * 0.8, H - SUPER * 5+ inset = SUPER * 5+ cx, cy = plate(image, octagon(left, top, right, bottom, SUPER * 6), (226, 112, 20),+ [(left + inset, top + inset), (right - inset, top + inset),+ (left + inset, bottom - inset), (right - inset, bottom - inset)])+ # a magnifying glass with a crosshair in its lens+ draw = ImageDraw.Draw(image)+ white = (248, 246, 240)+ scale = (bottom - top) / 125.0+ lx, ly, lens = cx - 8 * scale, cy - 8 * scale, 26 * scale+ thick = SUPER * 3+ draw.ellipse((lx - lens, ly - lens, lx + lens, ly + lens), outline=white, width=thick)+ reach = lens * 0.7+ for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):+ draw.line((lx + dx * reach * 0.35, ly + dy * reach * 0.35, lx + dx * reach, ly + dy * reach), fill=white, width=SUPER * 2)+ along = lens / math.sqrt(2)+ draw.line((lx + along, ly + along, lx + along + 26 * scale, ly + along + 26 * scale), fill=white, width=SUPER * 5)+ return image+++def aggressive(rng):+ image = backdrop(rng, (80, 34, 30), (196, 84, 44), (130, 104, 96), (34, 24, 20), glow=(255, 140, 40))+ cx, top, bottom, half = W / 2, SUPER * 2, H - SUPER * 5, W * 0.3+ inset = SUPER * 6+ plate(image, [(cx, top), (cx + half, bottom), (cx - half, bottom)], (200, 28, 26),+ [(cx, top + inset * 1.8), (cx + half - inset * 1.6, bottom - inset * 0.7), (cx - half + inset * 1.6, bottom - inset * 0.7)])+ # two chevrons pointing ahead+ draw = ImageDraw.Draw(image)+ white = (248, 246, 240)+ scale = (bottom - top) / 125.0+ mid = (top + bottom) / 2 + 14 * scale+ for lift in (0, 26):+ apex = mid - lift * scale - 14 * scale+ draw.line([(cx - 22 * scale, apex + 20 * scale), (cx, apex), (cx + 22 * scale, apex + 20 * scale)],+ fill=white, width=SUPER * 3, joint="curve")+ return image+++def defensive(rng):+ image = backdrop(rng, (58, 84, 120), (150, 172, 190), (220, 228, 236), (44, 46, 42))+ cx, top, bottom, half = W / 2, SUPER * 2, H - SUPER * 3, W * 0.27+ shoulder = top + (bottom - top) * 0.5+ inset = SUPER * 5+ plate(image, [(cx - half, top), (cx + half, top), (cx + half, shoulder), (cx, bottom), (cx - half, shoulder)],+ (54, 104, 168),+ [(cx - half + inset, top + inset), (cx + half - inset, top + inset),+ (cx - half + inset, shoulder - SUPER), (cx + half - inset, shoulder - SUPER)])+ # a smaller shield inside, outlined, with a bar down it+ draw = ImageDraw.Draw(image)+ white = (248, 246, 240)+ small_half, small_top, small_bottom = half * 0.45, top + (bottom - top) * 0.22, bottom - (bottom - top) * 0.2+ small_shoulder = small_top + (small_bottom - small_top) * 0.5+ inner = [(cx - small_half, small_top), (cx + small_half, small_top), (cx + small_half, small_shoulder),+ (cx, small_bottom), (cx - small_half, small_shoulder)]+ draw.line(inner + [inner[0]], fill=white, width=SUPER * 3, joint="curve")+ draw.line((cx, small_top, cx, small_bottom - SUPER * 2), fill=white, width=SUPER * 3)+ return image++def cameo(painted):small = painted.resize((CAMEO_W, CAMEO_H), Image.LANCZOS)return small.filter(ImageFilter.UnsharpMask(radius=1, percent=60, threshold=2))@@ -189,7 +283,9 @@ def cameo(painted):def texture():rng = np.random.default_rng(SEED)sheet = Image.new("RGBA", (TEXTURE_W, TEXTURE_H), (0, 0, 0, 0))- for name, paint in (("attack", attack), ("hold", hold), ("move", move)):+ # in this order: the stream is shared, so a new cameo goes last and leaves the others as they were+ for name, paint in (("attack", attack), ("hold", hold), ("move", move), ("scout", scout), ("hunt", hunt),+ ("aggressive", aggressive), ("defensive", defensive)):sheet.paste(cameo(paint(rng)).convert("RGBA"), CAMEO_PLACES[name])return sheet@@ -208,6 +304,17 @@ def selfcheck():assert attack_mid[0] > attack_mid[2], attack_midassert hold_mid[2] > hold_mid[0], hold_midassert move_side[1] > move_side[0] and move_side[1] > move_side[2], move_side+ # and the four after them: amber, orange, red and steel blue plates+ def face(x0, y0, x1, y1):+ return np.asarray(sheet.crop((x0, y0, x1, y1)), dtype=int)[:, :, :3].mean(axis=(0, 1))+ scout_top = face(64 + 27, 64 + 6, 64 + 33, 64 + 10)+ hunt_foot = face(128 + 16, 32, 128 + 20, 36)+ aggressive_foot = face(192 + 27, 34, 192 + 33, 38)+ defensive_top = face(128 + 16, 64 + 8, 128 + 20, 64 + 14)+ assert scout_top[0] > 200 and scout_top[1] > 140 and scout_top[2] < 80, scout_top+ assert hunt_foot[0] > 160 and 60 < hunt_foot[1] < 140 and hunt_foot[2] < 60, hunt_foot+ assert aggressive_foot[0] > 140 and aggressive_foot[1] < 60, aggressive_foot+ assert defensive_top[2] > defensive_top[0] + 50, defensive_topassert np.array_equal(np.asarray(texture()), np.asarray(sheet)) # seeded: the same file every timeprint("order_cameos selfcheck ok")