Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): audit unit modules, fix 90 behaviour bugs
Olcay Seygan2bb66e8e1d3f
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex a0efdecac..b95e209c6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -167,7 +167,12 @@ found and fixed — EA's own, not port damage.**- A unit that was driving somewhere when you saved is still driving there when you load. One flag was written to the save twice and another not at all, so every loaded unit came back claiming to stand still, and everything that asks - a bike waiting for its rider, a mob following its leader, an ability that breaks if you move - believed it.- A game saved after losing a supply center loads again. When a truck looked for somewhere to drop its cash and found a center that had been destroyed, it took the center off one list and counted it off the other, so the save recorded the wrong number of supply docks and could not be read back.- Your units decide the same way on both machines whether to chase what they spotted on their own. That answer was read from uninitialised memory, so the same order could send one player's tank after a target and leave the other's standing.-- A shell already in the air finishes its flight after a load instead of going off in the launcher's face.+- A shell already in the air finishes its flight after a load instead of going off in the launcher's face. It keeps the launcher's veterancy bonus too, and a smart bomb keeps homing.+- Supply trucks queued at a dock carry on after a load. Their place in the queue was written to the save and never read back, so every dock stopped letting anyone in until a thirty-second timeout sent the trucks round again.+- A cargo plane or bomber on its way off the map at save time flies on after a load. Its heading was not saved, so the first turn read as a sharp one and the plane was destroyed where it was.+- An EMP pulse, a bike being scuttled, a building's evacuation side and a horde's bonus all come back from a save as they went in.+- Where a supply dock's waiting spots are is the same on every machine. A dock with fewer spots in its model than in its data filled the rest from leftover memory, a different place on each computer.+- A building's toppling bursts are timed the same on every machine. They were timed off the picture's random numbers and created game objects, so two players could see different debris.- An aircraft carrier remembers the order it was given, and each runway its own ramp.- A barracks that has already put its mob on the street does not put a second one out after a load.- Effects tied together - a smoke column and its embers - stay tied together across a save.@@ -313,12 +318,26 @@ found and fixed — EA's own, not port damage.**- A unit lifts the fog only half as far again as its guns reach: enough to spot what it is about to fight, not enough to scout. A rifleman used to see well past the range of his rifle, so any cheap soldier was a scout. Artillery that outshoots its own eyes still needs a spotter, and units with no weapon at all, like bulldozers and supply trucks, keep the sight they had. Buildings are unchanged.- Hills and buildings block sight. A tank at the foot of a ridge used to see straight through it to the far side, and a squad in a city saw through every block around it. Now the fog stays on whatever a ridge, a building or a tree hides, yours, the enemy's or a civilian's, and a unit on high ground looks down over everything below it. Aircraft fly above it all and see past. Soldiers garrisoned in a building still see out of it; its own walls do not blind them.- High ground pays. A tank on a ridge now shoots, sees and picks its targets further down the slope than it could on the flat: three steps of range for every step of height over its target, up to twice its usual reach. Firing uphill costs nothing, and aircraft get no bonus from flying. Defences count too, and the range ring you see while placing one bends outward wherever the ground falls away, so you can site a Gattling Cannon on a hill and see exactly what it covers.+- The five soldiers in an Overlord's battle bunker live through the Overlord's death again. A rule added in this build, that nobody gets out of a vehicle which is itself being carried, caught the bunker too, so all five died on the spot where they used to take half damage and climb out.+- Pro Rules hold for the nuke and the carpet bomb whoever fires them. The refusal stopped the recharge but not the missile: a computer player or a map script could launch a neutron missile the rules forbid, and because the timer never started, launch it again straight away.+- A Spectre gunship called in by the computer or a map script circles its target. Its aim point and its gun's aim point were only set for a gunship you called yourself, so theirs lined up on the corner of the map and walked across from there before the howitzer could fire.+- A campaign's scripted drop from a B-52 or a cargo plane already in the air uses that plane. The instruction to leave the plane alone reached the game as a lifetime of zero, and a second transport was made at the drop point.+- A radar upgrade finished while its building was knocked out counted twice, and you kept the radar after the building was gone. It counts once.+- A unit built to survive on one hit point survives armour too. The cap was applied to the raw shot, before armour multiplied it, so anything weak to the weapon still died. The Battle Bus had it worse: the killing blow ran its death, then its second life revived it anyway.+- A building cleared by a Neutron Shell forgets the stealthed GLA soldiers it held. It kept counting them, so the Rangers who moved in next could be walked in on by an enemy and thrown out.+- A Point Defence Laser leads a fast missile the way its data says it should. The predicted position was worked out and then the distance was measured to where the missile already was. It also stopped firing one last shot at a missile that had just left its range.+- An Angry Mob bought at a barracks walks out one at a time, as the stagger in its data asks. The delay between members was calculated and thrown away, so the whole mob appeared at the door at once. A mob that loses its leader can take back the stragglers, which nothing could do before because every name in the list was skipped.+- A missile fooled by flares goes for the nearest flare of the last volley. It weighed the newest flare several times over and never looked at the others.+- A toppling building crushes the strip across its fall at any angle. The line was only square to the fall when the building fell along an axis; at forty-five degrees it ran down the length of the building and missed the units beside it.+- A transport killed by the blast of a Terrorist riding in it puts the other passengers out. They were handed back to a vehicle that had already died and were deleted with it, unseen.+- Something that knocks a unit off its feet lets it stand again. The flailing pose could outlast the stun and stay for good.## One crate, one collector- Salvage gets collected. A wreck leaves money and a free upgrade lying on the ground, and the game asked you to spot it in the middle of the fight that made it, work out which of your units was allowed to take it, and drive that one over it by hand. Nobody does that, so most salvage on most maps timed out where it fell. Whoever is standing nearest with nothing to do goes and gets it now: a unit that can still be upgraded off it goes first, however far back it is standing, and failing that the nearest idle unit takes the cash. Only idle units, so nothing is ever pulled out of a fight or off an order, and dozers and harvesters are left to the job they are already earning at.- And anybody can take the money. A salvage crate could only be picked up by a unit that salvages, so one dropped among troops who could not use it was money that belonged to nobody. The parts still only go to a salvager - the weapon, the armour, the promotion - but the cash goes to whoever drives over it.- A crate pays once per frame, not once per soldier who touched it.+- A unit that kills something carrying a crate now goes for the crate. The game noted the crate, then forgot which one before it looked, so the "pick up what I just dropped" order at seven places in the code never once fired.- A thrown vehicle's crash damage hits the pile once, not once per unit.- A dying unit is no longer promoted by its last kill.- Healing no longer counts as damage, so a medic stops revealing its stealth unit.@@ -810,6 +829,11 @@ found and fixed — EA's own, not port damage.**- Poison clouds, mine clearing, garrison kills and crew-killing weapons: all traced and fixed.- Blowing up a full transport is survivable now, in every remaining variant.- A unit can no longer load into a vehicle that no longer exists.+- Selling or losing an airfield under a jet on its takeoff roll no longer takes the game down. The jet takes off.+- A Particle Uplink Cannon fired by a script along a path no longer crashes at the path's last waypoint.+- A damage effect whose attacker died first no longer crashes the game, and neither does a flash-bang into a building with fewer soldiers than it was meant to kill.+- A disguised bomb truck losing its disguise used to rebuild itself onto the image it had just thrown away. It gets a fresh one now.+- A second exit order while a railed transport is still pushing a unit out no longer leaves the first one frozen half out of the door, unselectable, for the rest of the match.- A unit that kills itself survives its own turn now.- Sniping an empty bike, formation moves and hacker evasion no longer crash.- An order naming a player who is not there is dropped instead of crashing.@@ -1012,6 +1036,13 @@ found and fixed — EA's own, not port damage.**- A tracked unit braking while sitting exactly on the spot it was sent to divided nothing bynothing. The result stayed in its brakes and was multiplied into the next push it was given, anda vehicle handed a number that is not a number goes somewhere no player asked for.+- A wedged tank backs out along its route, not towards the corner of the map. The check that+ decides whether a unit is getting anywhere, and the sideways and backwards escape it tries when it+ is not, both measured against a point that was always the map's origin. And when that escape asked+ for a new route, the request was wiped out in the same frame, so the route never came. Over twenty+ brutal battles on Twilight Flame, units spent 8% less time wedged and 4% less time blocked, with 14%+ more new routes actually planned. One of those twenty went the other way: a unit sat stuck for most+ of the match, and why is not known yet.## Long orders stopped hitchingdiff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.hindex 271c9da80..477dde2a4 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/AIUpdate.h@@ -870,6 +870,7 @@ private:Coord3D m_rescueTo; ///< the free ground a wedged unit is backing out to.UnsignedInt m_rescueUntil; ///< frame that manoeuvre gives up (0 = not backing out).UnsignedInt m_rescueCool; ///< no second drastic thing before this frame.+ Bool m_repathAsked; ///< crowdRepath ran this doLocomotor; keep its blocked count for the move state.Real m_bumpSpeedLimit; ///< Max speed after bumping a unit.UnsignedInt m_ignoreCollisionsUntil; ///< Timer to cheat if we get stuck./**diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeliverPayloadAIUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeliverPayloadAIUpdate.hindex c54569996..a4bbe0d8d 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeliverPayloadAIUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/DeliverPayloadAIUpdate.h@@ -146,11 +146,20 @@ public:virtual StateReturnType update();virtual StateReturnType onEnter();protected:- // snapshot interface STUBBED - no member vars to save. jba.+ // snapshot interfacevirtual void crc( Xfer *xfer ){};- virtual void xfer( Xfer *xfer ){XferVersion cv = 1; XferVersion v = cv; xfer->xferVersion( &v, cv );}+ // version 2: the facing is saved, or a plane loaded on its way out reads a zero vector as a+ // hard turn and kills itself+ virtual void xfer( Xfer *xfer )+ {+ XferVersion cv = 2;+ XferVersion v = cv;+ xfer->xferVersion( &v, cv );+ if( v >= 2 )+ xfer->xferCoord3D( &facingDirectionUponDelivery );+ }virtual void loadPostProcess(){};-+Coord3D facingDirectionUponDelivery;};EMPTY_DTOR(HeadOffMapState)diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.hindex ca84bcd57..ea25d199c 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpecialPowerModule.h@@ -173,6 +173,7 @@ protected:void createViewObject( const Coord3D *location );void resolveSpecialPower( void );void aboutToDoSpecialPower( const Coord3D *location );+ Bool isRefused() const; ///< the base do calls return early on this; a subclass that adds its own effect must ask tooUnsignedInt m_availableOnFrame; ///< on this frame, this special power is availableInt m_pausedCount; ///< Reference count of sources pausing mediff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StructureCollapseUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StructureCollapseUpdate.hindex a80c9a6b5..28cf20d60 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StructureCollapseUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StructureCollapseUpdate.h@@ -78,9 +78,7 @@ public:m_minCollapseDelay = 0;m_maxCollapseDelay = 0;m_minBurstDelay = 9999;- //Removed by Sadullah Nader- //Redundancy from above- //m_minBurstDelay = 9999;+ m_maxBurstDelay = 9999;m_maxShudder = 0;m_collapseDamping = 0.0;m_bigBurstFrequency = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BridgeBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BridgeBehavior.cppindex 71a18f3ea..1ffcdba96 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BridgeBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BridgeBehavior.cpp@@ -1098,7 +1098,7 @@ void BridgeBehavior::createScaffolding( void )angleV.x = rightStart.x - leftStart.x;angleV.y = rightStart.y - leftStart.y;Real leftAngle = angleV.toAngle();- Real rightAngle = leftAngle + TWO_PI;+ Real rightAngle = leftAngle + PI; // the opposite way; + TWO_PI was the same angle// compute vector from left to right across bridge and the reverseCoord3D leftVector;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cppindex d7152af41..c4b88b02c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/CountermeasuresBehavior.cpp@@ -172,6 +172,8 @@ ObjectID CountermeasuresBehavior::calculateCountermeasureToDivertTo( const Objecif( !m_counterMeasures.empty() ){--it;+ // step back on every pass: stepping only past missing flares weighed the newest flare+ // volleySize times, and could walk off the front of a short listwhile( iteratorMax-- ){Object *obj = TheGameLogic->findObjectByID( *it );@@ -184,10 +186,9 @@ ObjectID CountermeasuresBehavior::calculateCountermeasureToDivertTo( const ObjecclosestFlare = obj;}}- else- {- --it;- }+ if( it == m_counterMeasures.begin() )+ break;+ --it;}}@@ -390,7 +391,7 @@ void CountermeasuresBehavior::xfer( Xfer *xfer )// extend base classUpgradeMux::upgradeMuxXfer( xfer );- if( currentVersion >= 2 )+ if( version >= 2 ){xfer->xferSTLObjectIDVector( &m_counterMeasures );xfer->xferUnsignedInt( &m_availableCountermeasures );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cppindex 4f57f735e..524075294 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/DumbProjectileBehavior.cpp@@ -495,7 +495,7 @@ Bool DumbProjectileBehavior::projectileHandleCollision( Object *other )const ContainedItemsList* items = contain->getContainedItemsList();if (items){- for (ContainedItemsList::const_iterator it = items->begin(); *it != NULL && numKilled < d->m_garrisonHitKillCount; )+ for (ContainedItemsList::const_iterator it = items->begin(); it != items->end() && numKilled < d->m_garrisonHitKillCount; ){Object* thingToKill = *it++;if (!thingToKill->isEffectivelyDead() && thingToKill->isKindOfMulti(d->m_garrisonHitKillKindof, d->m_garrisonHitKillKindofNot))@@ -742,7 +742,10 @@ void DumbProjectileBehavior::xfer( Xfer *xfer )// version 2 saves how far along its arc the shell is, and rebuilds the arc on load. Version 1// saved neither: a shell in flight came back at step zero of a path it no longer had, so it// went off in the launcher's face instead of finishing its flight.- XferVersion currentVersion = 2;+ // version 3 adds the launcher's weapon bonus flags, lost on load so a shell in flight detonated+ // without veterancy or horde bonus, and the detonated flag, so a DetonateCallsKill shell cannot+ // go off a second time+ XferVersion currentVersion = 3;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -796,6 +799,12 @@ void DumbProjectileBehavior::xfer( Xfer *xfer )if( version >= 2 )xfer->xferInt( &m_currentFlightPathStep );+ if( version >= 3 )+ {+ xfer->xferUnsignedInt( &m_extraBonusFlags );+ xfer->xferBool( &m_hasDetonated );+ }+// the path itself is a vector of points that is not saved; rebuild it from the start, end and// segment count that are, so the step we just read means somethingif( xfer->getXferMode() == XFER_LOAD && m_flightPathSegments > 0 )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cppindex d864a9afe..15e892157 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/FlightDeckBehavior.cpp@@ -195,7 +195,7 @@ void FlightDeckBehavior::buildInfo(Bool createUnits)std::vector<AsciiString>::const_iterator it;Int counter = 0;- for( it = spaces.begin(); it != spaces.end(), counter < row; it++, counter++ )+ for( it = spaces.begin(); it != spaces.end() && counter < row; it++, counter++ ){//just iterate to the spaces.}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cppindex e6f40f7c6..be3986504 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp@@ -153,7 +153,8 @@ UpdateSleepTime PoisonedBehavior::calcSleepTime(){// UPDATE_SLEEP requires a count-of-frames, not an absolute-frame, so subtract 'now'UnsignedInt now = TheGameLogic->getFrame();- if (m_poisonOverallStopFrame == 0 || m_poisonOverallStopFrame == now)+ // <= : a unit the poison killed keeps a stop frame that is already behind us+ if (m_poisonOverallStopFrame == 0 || m_poisonOverallStopFrame <= now)return UPDATE_SLEEP_FOREVER;return frameToSleepTime(m_poisonDamageFrame, m_poisonOverallStopFrame);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cppindex 156a86bee..8c4f82bf7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PropagandaTowerBehavior.cpp@@ -299,7 +299,8 @@ void PropagandaTowerBehavior::onDie( const DamageInfo *damageInfo )void PropagandaTowerBehavior::effectLogic( Object *obj, Bool giving,const PropagandaTowerBehaviorModuleData *modData ){- Bool effectUpgraded = getObject()->getControllingPlayer()->hasUpgradeComplete( m_upgradeRequired );+ // no UpgradeRequired leaves this NULL, which doScan already allows for+ Bool effectUpgraded = m_upgradeRequired && getObject()->getControllingPlayer()->hasUpgradeComplete( m_upgradeRequired );// if giving the effectif( giving )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cppindex 79a37def2..45aca8047 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SlowDeathBehavior.cpp@@ -402,11 +402,17 @@ UpdateSleepTime SlowDeathBehavior::update()return UPDATE_SLEEP_NONE;}- m_sinkFrame = (Real)m_sinkFrame * timeScale;- m_midpointFrame = (Real)m_midpointFrame * timeScale;- m_destructionFrame = (Real)m_destructionFrame * timeScale;+ // These are absolute frames by now (onDie added the start frame), so scale only what is+ // left of each; scaling the whole number put every death thousands of frames in the past.+ UnsignedInt scaleFrom = TheGameLogic->getFrame();+ if (m_sinkFrame > scaleFrom)+ m_sinkFrame = scaleFrom + (UnsignedInt)((Real)(m_sinkFrame - scaleFrom) * timeScale);+ if (m_midpointFrame > scaleFrom)+ m_midpointFrame = scaleFrom + (UnsignedInt)((Real)(m_midpointFrame - scaleFrom) * timeScale);+ if (m_destructionFrame > scaleFrom)+ m_destructionFrame = scaleFrom + (UnsignedInt)((Real)(m_destructionFrame - scaleFrom) * timeScale);m_acceleratedTimeScale = timeScale;- };+ };UnsignedInt now = TheGameLogic->getFrame();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cppindex 698e518eb..4b5337d7c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/SpawnBehavior.cpp@@ -240,7 +240,7 @@ UpdateSleepTime SpawnBehavior::update( void )--burstInitCount;birthFrame += (listIndex*SPAWN_DELAY_MIN_FRAMES);}- m_replacementTimes.push_back( runtimeProduced );// Set all spawns to be created in rapid succession+ m_replacementTimes.push_back( birthFrame );// Set all spawns to be created in rapid succession}elsem_replacementTimes.push_back( listIndex );// Set all spawns to be created as soon as possible@@ -596,18 +596,20 @@ Object *SpawnBehavior::reclaimOrphanSpawn( void )// This block scans the list for matchTemplates//+ // Closest over every template, so reset once. compare() is zero on a match: the old test skipped+ // every name that differed from the previous one, which was every name, and nothing was reclaimed.OrphanData orphanData;+ orphanData.m_source = getObject();+ orphanData.m_closest = NULL;+ orphanData.m_closestDistSq = BIG_DISTANCE;AsciiString prevName = "";for (std::vector<AsciiString>::const_iterator tempName = md->m_spawnTemplateNameData.begin();- tempName != md->m_spawnTemplateNameData.end();+ tempName != md->m_spawnTemplateNameData.end();++tempName){- if (prevName.compare(*tempName)) // the list may have redundancy, this will skip some of it+ if (prevName.compare(*tempName) == 0) // the list may have redundancy, this will skip some of itcontinue;- orphanData.m_matchTemplate = TheThingFactory->findTemplate( *tempName );;- orphanData.m_source = getObject();- orphanData.m_closest = NULL;- orphanData.m_closestDistSq = BIG_DISTANCE;+ orphanData.m_matchTemplate = TheThingFactory->findTemplate( *tempName );player->iterateObjects( findClosestOrphan, &orphanData );prevName = *tempName;}@@ -1008,9 +1010,12 @@ void SpawnBehavior::computeAggregateStates(void)// HEALTH BOX POSITION *****************************// pick a centered, average spot to draw the health box- avgSpawnPos.scale(1.0f / spawnCount);- avgSpawnPos.sub(obj->getPosition());- obj->setHealthBoxOffset(avgSpawnPos);+ if ( spawnCount ) // no living members: 1/0 made the offset NaN+ {+ avgSpawnPos.scale(1.0f / spawnCount);+ avgSpawnPos.sub(obj->getPosition());+ obj->setHealthBoxOffset(avgSpawnPos);+ }diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cppindex 87f6d2301..35653b89c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp@@ -562,11 +562,17 @@ void ActiveBody::attemptDamage( DamageInfo *damageInfo )amount = m_currentHealth;}- if (!alreadyHandled)+ if (!alreadyHandled){// do the damage simplistic damage subtractioninternalChangeHealth( -amount );}+ else+ {+ // health did not move; without this m_prevHealth is whatever the last real hit left, and a+ // subdual or status hit re-ran onDamage and the fear roll off that stale number+ m_prevHealth = m_currentHealth;+ }#ifdef ALLOW_SURRENDER//*****************************************************************************************@@ -1070,7 +1076,8 @@ void ActiveBody::createParticleSystems( const AsciiString &boneBaseName,// pick a bone index to place this particle system at// MDC: moving to GameLogicRandomValue. This does not need to be synced, but having it so makes searches *so* much nicer.// DTEH: Moved back to GameClientRandomValue because of desync problems. July 27th 2003.- Int boneIndex = GameClientRandomValue( 0, maxSystems - i - 1 );+ // over the bones still free, not the systems still to place: that range only ever reached the first maxSystems bones+ Int boneIndex = GameClientRandomValue( 0, numBones - i - 1 );// find the actual bone location to use and mark that bone index as usedInt count = 0;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/HighlanderBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/HighlanderBody.cppindex 9165ef791..9e119a5f0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/HighlanderBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/HighlanderBody.cpp@@ -54,8 +54,14 @@ HighlanderBody::~HighlanderBody( void )void HighlanderBody::attemptDamage( DamageInfo *damageInfo ){// Bind to one hitpoint remaining afterwards, unless it is Unresistable damage+ // Clamp what lands, not what the weapon carries: armour and the damage scalar are applied after+ // this, so a raw clamp to health-1 still killed through any armour coefficient above 100%.if( damageInfo->in.m_damageType != DAMAGE_UNRESISTABLE )- damageInfo->in.m_amount = min( damageInfo->in.m_amount, getHealth() - 1 );+ {+ Real landed = estimateDamage( damageInfo->in ) * getDamageScalar();+ if( landed > getHealth() - 1 && landed > 0.0f )+ damageInfo->in.m_amount *= ( getHealth() - 1 ) / landed;+ }ActiveBody::attemptDamage(damageInfo);}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/InactiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/InactiveBody.cppindex cb17a1b05..b7a54ee76 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/InactiveBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/InactiveBody.cpp@@ -176,19 +176,23 @@ void InactiveBody::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: m_dieCalled, or a loaded object that already died runs its die modules again */// ------------------------------------------------------------------------------------------------void InactiveBody::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );// base classBodyModule::xfer( xfer );+ if( version >= 2 )+ xfer->xferBool( &m_dieCalled );+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cppindex cf5af0d6f..9cfab244c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/UndeadBody.cpp@@ -89,7 +89,11 @@ void UndeadBody::attemptDamage( DamageInfo *damageInfo )&& IsHealthDamagingDamage(damageInfo->in.m_damageType)){- damageInfo->in.m_amount = min( damageInfo->in.m_amount, getHealth() - 1 );+ // clamp what lands, for the same reason as the test above: armour applied after a raw clamp+ // to health-1 still killed, ran the die modules, and then revived the bus anyway+ Real landed = estimateDamage( damageInfo->in ) * getDamageScalar();+ if( landed > getHealth() - 1 && landed > 0.0f )+ damageInfo->in.m_amount *= ( getHealth() - 1 ) / landed;shouldStartSecondLife = TRUE;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/MoneyCrateCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/MoneyCrateCollide.cppindex 6055713c2..89b08a285 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/MoneyCrateCollide.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/CrateCollide/MoneyCrateCollide.cpp@@ -81,7 +81,7 @@ Int MoneyCrateCollide::getUpgradedSupplyBoost( Object *other ) constupgradePair info = *it;// Check if the player has the desired upgrade. If so return the boost- static const UpgradeTemplate *upgradeTemplate = TheUpgradeCenter->findUpgrade( info.type.c_str() );+ const UpgradeTemplate *upgradeTemplate =TheUpgradeCenter->findUpgrade( info.type.c_str() );if (player && upgradeTemplate && player->hasUpgradeComplete(upgradeTemplate)){return info.amount;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/FireWeaponCollide.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/FireWeaponCollide.cppindex 39e8c068f..ef78705af 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/FireWeaponCollide.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Collide/FireWeaponCollide.cpp@@ -88,6 +88,7 @@ void FireWeaponCollide::onCollide( Object *other, const Coord3D *loc, const Coor{m_collideWeapon->loadAmmoNow( me );m_collideWeapon->fireWeapon( me, other );+ m_everFired = TRUE; // never set, so FireOnce did nothing}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cppindex 703122e98..51e985ece 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/GarrisonContain.cpp@@ -1802,14 +1802,15 @@ void GarrisonContain::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: m_evacDisposition, a script's left/right evacuation that a load reverted to the centre */// ------------------------------------------------------------------------------------------------void GarrisonContain::xfer( Xfer *xfer ){Int i;// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -1925,6 +1926,9 @@ void GarrisonContain::xfer( Xfer *xfer )// exit rally pointxfer->xferCoord3D( &m_exitRallyPoint );+ if( version >= 2 )+ xfer->xferUser( &m_evacDisposition, sizeof( EvacDisposition ) );+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cppindex 5564f9ff2..1301e8a82 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/OpenContain.cpp@@ -473,6 +473,12 @@ void OpenContain::killAllContained( void )if ( rider ){it = list.erase(it);+ // the counts removeFromContainViaIterator keeps: left alone, a building cleared this way+ // still counted its dead stealth garrison and let the next enemy in on top of new riders+ if( rider->isKindOf( KINDOF_STEALTH_GARRISON ) )+ m_stealthUnitsContained--;+ if( rider->isKindOf( KINDOF_HERO ) )+ m_heroUnitsContained--;onRemoving( rider );rider->onRemovedFrom( getObject() );@@ -1310,7 +1316,7 @@ void OpenContain::putObjAtNextFirePoint( Object *obj )AsciiString firepoint("FIREPOINT");char suffix[8];itoa( m_firePointNext + 1, suffix, 10 );//+1 from bone names starting at 1, not zero like my array- if( m_firePointNext < 10 )+ if( m_firePointNext + 1 < 10 ) // pad on the number the name uses, not the index{firepoint.concat('0');}@@ -1521,6 +1527,11 @@ void OpenContain::processDamageToContained(Real percentDamage)if( object->isEffectivelyDead() ){+ // the same counts killAllContained keeps+ if( object->isKindOf( KINDOF_STEALTH_GARRISON ) )+ m_stealthUnitsContained--;+ if( object->isKindOf( KINDOF_HERO ) )+ m_heroUnitsContained--;onRemoving( object );object->onRemovedFrom( getObject() );it = list.erase( it );@@ -1534,6 +1545,11 @@ void OpenContain::processDamageToContained(Real percentDamage)// and hand back whoever survivedm_containList.swap( list );m_containListSize = (UnsignedInt)m_containList.size();++ // A dying rider can kill the container while the list is parked; its onDie then found nothing+ // to put out, and the survivors just handed back would be deleted with it, unseen.+ if( getObject()->isEffectivelyDead() )+ removeAllContained();}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cppindex bc4f70c74..002e440e8 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/RiderChangeContain.cpp@@ -469,13 +469,14 @@ void RiderChangeContain::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: m_scuttledOnFrame, or a bike loaded mid-scuttle is never killed and stays unselectable */// ------------------------------------------------------------------------------------------------void RiderChangeContain::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -491,6 +492,9 @@ void RiderChangeContain::xfer( Xfer *xfer )// frame exit not busyxfer->xferUnsignedInt( &m_frameExitNotBusy );+ if( version >= 2 )+ xfer->xferUnsignedInt( &m_scuttledOnFrame );+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cppindex 34e8c91d9..89b536cef 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Contain/TransportContain.cpp@@ -578,7 +578,9 @@ Bool TransportContain::isSpecificRiderFreeToExit(Object* specificObject)// If this transport is itself inside something, its passengers have nowhere to step out to -// they would appear inside whatever is carrying us.- if (me->isContained())+ // Not an Overlord or Helix though: their bunker is a transport riding inside them, and treating+ // it like a truck in a Chinook killed all five soldiers outright whenever the Overlord died.+ if (me->isContained() && !me->getContainedBy()->getContain()->isSpecialOverlordStyleContainer())return FALSE;// I can always kick people out if I am in the air, I know what I'm doingdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Damage/TransitionDamageFX.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Damage/TransitionDamageFX.cppindex 057fdfc68..71467fe9c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Damage/TransitionDamageFX.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Damage/TransitionDamageFX.cpp@@ -379,7 +379,7 @@ void TransitionDamageFX::onBodyDamageStateChange( const DamageInfo* damageInfo,pos = getLocalEffectPos( &modData->m_OCL[ newState ][ i ].locInfo, draw );getObject()->convertBonePosToWorldPos( &pos, NULL, &pos, NULL );ObjectCreationList::create( modData->m_OCL[ newState ][ i ].ocl,- getObject(), &pos, damageSource->getPosition(), INVALID_ANGLE );+ getObject(), &pos, damageSource ? damageSource->getPosition() : NULL, INVALID_ANGLE ); // the attacker can be dead already} // end ifdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/FXListDie.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/FXListDie.cppindex 573ff4f6d..66f3db5d2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/FXListDie.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Die/FXListDie.cpp@@ -110,19 +110,24 @@ void FXListDie::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: the upgrade mux, as every other UpgradeMux module saves */// ------------------------------------------------------------------------------------------------void FXListDie::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );// extend base classDieModule::xfer( xfer );+ // extend upgrade mux+ if( version >= 2 )+ UpgradeMux::upgradeMuxXfer( xfer );+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/OCLSpecialPower.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/OCLSpecialPower.cppindex 5d2933e91..676a0e973 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/OCLSpecialPower.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/OCLSpecialPower.cpp@@ -152,7 +152,9 @@ OCLSpecialPower::~OCLSpecialPower( void )//-------------------------------------------------------------------------------------------------void OCLSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions ){- if (getObject()->isDisabled())+ // the whole refusal, not just disabled: the base call below returns early on a paused power or a+ // Pro Rules refusal, but the OCL further down was created anyway, with no recharge started+ if (isRefused())return;// sanity@@ -206,7 +208,9 @@ void OCLSpecialPower::doSpecialPowerAtLocation( const Coord3D *loc, Real angle,break;case USE_OWNER_OBJECT:creationCoord.set( &targetCoord );- ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, angle, false );+ // (Bool)FALSE picks the createOwner overload; with the Real angle beside it, false became+ // lifetimeFrames = 0 and a new transport was made after all+ ObjectCreationList::create( ocl, getObject(), &creationCoord, &targetCoord, (Bool)FALSE );break;case CREATE_ABOVE_LOCATION:// this is the case where the special power stuff originates above the location of the mouse click@@ -233,7 +237,7 @@ void OCLSpecialPower::doSpecialPowerAtObject( Object *obj, UnsignedInt commandOp// ------------------------------------------------------------------------------------------------void OCLSpecialPower::doSpecialPower( UnsignedInt commandOptions ){- if (getObject()->isDisabled())+ if (isRefused())return;Coord3D creationCoord;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cppindex 6edd41fcb..c1309e962 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp@@ -740,11 +740,17 @@ void SpecialPowerModule::doSpecialPowerAtObject( Object *obj, UnsignedInt comman}}+//-------------------------------------------------------------------------------------------------+Bool SpecialPowerModule::isRefused() const+{+ return m_pausedCount > 0 || getObject()->isDisabled() || proRulesRefuse( getObject(), getSpecialPowerTemplate() );+}+//-------------------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------------------void SpecialPowerModule::doSpecialPowerAtLocation( const Coord3D *loc, Real angle, UnsignedInt commandOptions ){- if (m_pausedCount > 0 || getObject()->isDisabled() || proRulesRefuse( getObject(), getSpecialPowerTemplate() )) {+ if (isRefused()) {return;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cppindex 17ac78ea0..382d76ae2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp@@ -335,6 +335,7 @@ AIUpdateInterface::AIUpdateInterface( Thing *thing, const ModuleData* moduleDatam_rescueTo.zero();m_rescueUntil = 0;m_rescueCool = 0;+ m_repathAsked = FALSE;m_bumpSpeedLimit = FAST_AS_POSSIBLE;m_ignoreCollisionsUntil = 0;m_queueForPathFrame = 0;@@ -1014,8 +1015,8 @@ Object* AIUpdateInterface::checkForCrateToPickup(){if (m_crateCreated != INVALID_ID){- m_crateCreated = INVALID_ID; // we have processed it, so clear it.Object* crate = TheGameLogic->findObjectByID(m_crateCreated);+ m_crateCreated = INVALID_ID; // we have processed it, so clear it.if (crate){for (BehaviorModule** m = crate->getBehaviorModules(); *m; ++m)@@ -1932,6 +1933,7 @@ Bool AIUpdateInterface::computePath( PathfindServicesInterface *pathServices, Co// this way out skips the reset at the bottom, and a flag left on would answer for whoever// asks the pathfinder nextTheAI->pathfinder()->setIgnoreUnderConstruction( FALSE );+ TheAI->pathfinder()->setIgnoreObstacleID( INVALID_ID );return computeQuickPath(destination);}@@ -2215,6 +2217,7 @@ Bool AIUpdateInterface::computeAttackPath( PathfindServicesInterface *pathServic&objPos, false, 0.2f, true );}if (m_path==NULL) {+ TheAI->pathfinder()->setIgnoreObstacleID( INVALID_ID );return false;}}@@ -2760,6 +2763,7 @@ void AIUpdateInterface::crowdRepath( void ){Pathfinder::bumpCrowdRepath();m_blockedFrames = 2 * LOGICFRAMES_PER_SECOND + 1;+ m_repathAsked = TRUE;m_isBlockedAndStuck = FALSE;m_crowdQueued = 0;m_noProgress = 0;@@ -3740,6 +3744,10 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )// layer is a possible bridge in the path. Check & set the layer if applicable.TheAI->pathfinder()->updateLayer(getObject(), info.layer);}+ // updateProgress and the rescue ladder read this as "where the route sends us";+ // setLocomotorGoalPositionOnPath() zeroes it, so without this they measured+ // against the map's origin corner+ m_locomotorGoalData = goalPos;Real speed = m_desiredSpeed;Real myMaxSpeed = m_curLocomotor->getMaxSpeedForCondition(getObject()->getBodyModule()->getDamageState());@@ -3833,10 +3841,13 @@ UpdateSleepTime AIUpdateInterface::doLocomotor( void )}}- if (!blocked && m_blockedFrames>1)+ // a repath asked for this frame is carried in m_blockedFrames; clamping it here threw it away+ // before the move state could read it+ if (!blocked && m_blockedFrames>1 && !m_repathAsked){m_blockedFrames = 1;}+ m_repathAsked = FALSE;// After our movement for the frame, update our AirborneTarget flag.if(getObject()->getHeightAboveTerrain() > m_curLocomotor->getAirborneTargetingHeight() )@@ -4133,7 +4144,7 @@ void AIUpdateInterface::joinTeam( void )} else {getStateMachine()->setGoalPosition(ai->getGoalPosition());}- StateID state = getCurrentStateID();+ StateID state = ai->getCurrentStateID();setLastCommandSource( CMD_FROM_AI );// Match the state.getStateMachine()->setState( state );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cppindex 122d289bc..5bcafe033 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/ChinookAIUpdate.cpp@@ -182,7 +182,7 @@ public:return STATE_CONTINUE;}- void onExit()+ virtual void onExit( StateExitType status ){Object *owner = getMachineOwner();owner->clearStatus( MAKE_OBJECT_STATUS_MASK( OBJECT_STATUS_RIDER8 ) );@@ -519,6 +519,10 @@ public:for (Int i = 0; i < numRopes; ++i){RopeInfo info;+ // a missing rope template leaves no drawable: zero lengths so update() never animates it+ info.ropeSpeed = 0.0f;+ info.ropeLen = 0.0f;+ info.ropeLenMax = 0.0f;obj->convertBonePosToWorldPos( NULL, &dropMtx[i], NULL, &info.dropStartMtx );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeliverPayloadAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeliverPayloadAIUpdate.cppindex c09d70410..ee0c1ba37 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeliverPayloadAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeliverPayloadAIUpdate.cpp@@ -720,7 +720,7 @@ StateReturnType DeliveringState::update() // Kick a dude out every so often}//Handle contained payload delivery.- if( items )+ if( items && !items->empty() ){Object* item = items->front();@@ -1036,7 +1036,7 @@ void ConsiderNewApproachState::onExit( StateExitType status )}// go back to normal.- ai->getCurLocomotor()->setAllowInvalidPosition(true);+ ai->getCurLocomotor()->setAllowInvalidPosition(false);}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cppindex 23a96f664..5b73efd9a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DeployStyleAIUpdate.cpp@@ -241,7 +241,7 @@ UpdateSleepTime DeployStyleAIUpdate::update( void )case DEPLOY:if( data->m_manualDeployAnimations ){- UnsignedInt totalFrames = getPackTime();+ UnsignedInt totalFrames = getUnpackTime(); // DEPLOY waits the unpack time, see setMyStateUnsignedInt framesLeft = m_frameToWaitForDeploy - now;Drawable *draw = self->getDrawable();if( draw )diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cppindex a0666aeb9..52ae606b8 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/DozerAIUpdate.cpp@@ -694,7 +694,8 @@ StateReturnType DozerActionDoActionState::update( void ){// issue repair complete message, we might want to remove this later cause it could be annoying- TheInGameUI->message( "DOZER:RepairComplete" );+ if( dozer->isLocallyControlled() )+ TheInGameUI->message( "DOZER:RepairComplete" );// we're now completecomplete = TRUE;@@ -2356,15 +2357,7 @@ void DozerAIUpdate::onDelete( void ){Int i;- // cancel any of the tasks we had queued up- for( i = DOZER_TASK_FIRST; i < DOZER_NUM_TASKS; ++i )- {-- if( isTaskPending( (DozerTask)i ) )- cancelTask( (DozerTask)i );-- } // end for i-+ // before the cancel below, which forgets every target IDfor( i = 0; i < DOZER_NUM_TASKS; i++ ){Object* goalObject = TheGameLogic->findObjectByID(m_task[i].m_targetObjectID);@@ -2373,6 +2366,15 @@ void DozerAIUpdate::onDelete( void )goalObject->clearModelConditionState(MODELCONDITION_ACTIVELY_BEING_CONSTRUCTED);}}++ // cancel any of the tasks we had queued up+ for( i = DOZER_TASK_FIRST; i < DOZER_NUM_TASKS; ++i )+ {++ if( isTaskPending( (DozerTask)i ) )+ cancelTask( (DozerTask)i );++ } // end for i}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cppindex b105fc334..e07a3f0a7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/JetAIUpdate.cpp@@ -872,17 +872,26 @@ public://As it approaches the end of the runway, the plane will gain more lift, even if it's already//going quickly. Using speed for lift is bad in the case of the aircraft carrier, because//we don't want it to take off quickly.- ParkingPlaceBehaviorInterface::PPInfo ppinfo;- pp->calcPPInfo( jet->getID(), &ppinfo );- Coord3D vector = ppinfo.runwayEnd;- vector.sub( jet->getPosition() );- Real dist = vector.length();-- Real ratio = 1.0f - (dist / ppinfo.runwayTakeoffDist);- ratio *= ratio; //dampen it....- if (ratio < 0.0f) ratio = 0.0f;- if (ratio > 1.0f) ratio = 1.0f;- jetAI->getCurLocomotor()->setMaxLift(m_maxLift * ratio);+ // the airfield can be sold or destroyed under a jet on its takeoff roll: no runway left+ // to measure against, so give it full lift and let it go+ if (pp)+ {+ ParkingPlaceBehaviorInterface::PPInfo ppinfo;+ pp->calcPPInfo( jet->getID(), &ppinfo );+ Coord3D vector = ppinfo.runwayEnd;+ vector.sub( jet->getPosition() );+ Real dist = vector.length();++ Real ratio = 1.0f - (dist / ppinfo.runwayTakeoffDist);+ ratio *= ratio; //dampen it....+ if (ratio < 0.0f) ratio = 0.0f;+ if (ratio > 1.0f) ratio = 1.0f;+ jetAI->getCurLocomotor()->setMaxLift(m_maxLift * ratio);+ }+ else+ {+ jetAI->getCurLocomotor()->setMaxLift(m_maxLift);+ }}StateReturnType ret = AIFollowPathState::update();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/MissileAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/MissileAIUpdate.cppindex 20bc00782..36c1f6754 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/MissileAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/MissileAIUpdate.cpp@@ -348,7 +348,7 @@ Bool MissileAIUpdate::projectileHandleCollision( Object *other )const ContainedItemsList* items = contain->getContainedItemsList();if (items){- for (ContainedItemsList::const_iterator it = items->begin(); *it != NULL && numKilled < d->m_garrisonHitKillCount; )+ for (ContainedItemsList::const_iterator it = items->begin(); it != items->end() && numKilled < d->m_garrisonHitKillCount; ){Object* thingToKill = *it++;if (!thingToKill->isEffectivelyDead() && thingToKill->isKindOfMulti(d->m_garrisonHitKillKindof, d->m_garrisonHitKillKindofNot))@@ -823,6 +823,7 @@ void MissileAIUpdate::projectileNowJammed()m_isTrackingTarget = FALSE;m_originalTargetPos = targetPosition;m_victimID = INVALID_ID;+ m_isJammed = TRUE;}// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailedTransportAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailedTransportAIUpdate.cppindex de8638ed4..b7329cf2b 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailedTransportAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailedTransportAIUpdate.cpp@@ -114,8 +114,10 @@ void RailedTransportAIUpdate::loadWaypointData( void )if( start && end ){- m_path[ i ].startWaypointID = start->getID();- m_path[ i ].endWaypointID = end->getID();+ // packed: every reader and the xfer walk 0..m_numPaths-1, so a gap in the numbering+ // left a zero path in slot 0+ m_path[ m_numPaths ].startWaypointID = start->getID();+ m_path[ m_numPaths ].endWaypointID = end->getID();m_numPaths++;} // end ifdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cppindex 403a29779..4a06bb3bb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/RailroadGuideAIUpdate.cpp@@ -1429,6 +1429,8 @@ void RailroadBehavior::FindPosByPathDistance( Coord3D *pos, const Real dist, con{const TrackPoint *thisPoint = &(*pointIter);++pointIter;// next pointIter in this list, so then...+ if ( pointIter == pointList->end() )+ break;// the last point has nothing after it to lie betweenconst TrackPoint *nextPoint = &(*pointIter);@@ -1476,9 +1478,9 @@ void RailroadBehavior::FindPosByPathDistance( Coord3D *pos, const Real dist, conif ( edge && ! m_inTunnel ){//play my clickety clack sound, `cause I just rode over a join IN the tracks- TheAudio->addAudioEvent( &m_clicketyClackSound );m_clicketyClackSound.setPosition( getObject()->getPosition() );m_clicketyClackSound.setVolume( (Real)conductorPullInfo.speed / 10.0f );//assumed max speed+ TheAudio->addAudioEvent( &m_clicketyClackSound );}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cppindex 0fdf04bfa..0e2393c3a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate/WorkerAIUpdate.cpp@@ -942,15 +942,7 @@ void WorkerAIUpdate::onDelete( void ){Int i;- // cancel any of the tasks we had queued up- for( i = DOZER_TASK_FIRST; i < DOZER_NUM_TASKS; ++i )- {-- if( isTaskPending( (DozerTask)i ) )- cancelTask( (DozerTask)i );-- } // end for i-+ // before the cancel below, which forgets every target IDfor( i = 0; i < DOZER_NUM_TASKS; i++ ){Object* goalObject = TheGameLogic->findObjectByID(m_task[i].m_targetObjectID);@@ -959,6 +951,15 @@ void WorkerAIUpdate::onDelete( void )goalObject->clearModelConditionState(MODELCONDITION_ACTIVELY_BEING_CONSTRUCTED);}}++ // cancel any of the tasks we had queued up+ for( i = DOZER_TASK_FIRST; i < DOZER_NUM_TASKS; ++i )+ {++ if( isTaskPending( (DozerTask)i ) )+ cancelTask( (DozerTask)i );++ } // end for i}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cppindex d990d6a7a..e77ea8b4a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AutoDepositUpdate.cpp@@ -259,7 +259,7 @@ Int AutoDepositUpdate::getUpgradedSupplyBoost() constupgradePair info = *it;// Check if the player has the desired upgrade. If so return the boost- static const UpgradeTemplate *upgradeTemplate = TheUpgradeCenter->findUpgrade( info.type.c_str() );+ const UpgradeTemplate *upgradeTemplate =TheUpgradeCenter->findUpgrade( info.type.c_str() );if (player && upgradeTemplate && player->hasUpgradeComplete(upgradeTemplate)){return info.amount;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cppindex 28fb8d646..779e2dce4 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BattlePlanUpdate.cpp@@ -665,7 +665,7 @@ void BattlePlanUpdate::setStatus( TransitionStatus newStatus )obj->setModelConditionState( MODELCONDITION_DOOR_1_CLOSING );obj->getDrawable()->setAnimationLoopDuration( data->m_bombardmentPlanAnimationFrames );m_nextReadyFrame = now + data->m_bombardmentPlanAnimationFrames;- if( m_bombardmentUnpack.getEventName().isNotEmpty() )+ if( m_bombardmentPack.getEventName().isNotEmpty() ){m_bombardmentPack.setObjectID( obj->getID() );m_bombardmentPack.setPlayingHandle( TheAudio->addAudioEvent( &m_bombardmentPack ) );@@ -675,7 +675,7 @@ void BattlePlanUpdate::setStatus( TransitionStatus newStatus )obj->setModelConditionState( MODELCONDITION_DOOR_2_CLOSING );obj->getDrawable()->setAnimationLoopDuration( data->m_holdTheLinePlanAnimationFrames );m_nextReadyFrame = now + data->m_holdTheLinePlanAnimationFrames;- if( m_holdTheLineUnpack.getEventName().isNotEmpty() )+ if( m_holdTheLinePack.getEventName().isNotEmpty() ){m_holdTheLinePack.setObjectID( obj->getID() );m_holdTheLinePack.setPlayingHandle( TheAudio->addAudioEvent( &m_holdTheLinePack ) );@@ -685,7 +685,7 @@ void BattlePlanUpdate::setStatus( TransitionStatus newStatus )obj->setModelConditionState( MODELCONDITION_DOOR_3_CLOSING );obj->getDrawable()->setAnimationLoopDuration( data->m_searchAndDestroyPlanAnimationFrames );m_nextReadyFrame = now + data->m_searchAndDestroyPlanAnimationFrames;- if( m_searchAndDestroyUnpack.getEventName().isNotEmpty() )+ if( m_searchAndDestroyPack.getEventName().isNotEmpty() ){m_searchAndDestroyPack.setObjectID( obj->getID() );m_searchAndDestroyPack.setPlayingHandle( TheAudio->addAudioEvent( &m_searchAndDestroyPack ) );diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BoneFXUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BoneFXUpdate.cppindex c7d817b5d..8092008a2 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BoneFXUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/BoneFXUpdate.cpp@@ -448,8 +448,18 @@ void BoneFXUpdate::doParticleSystemAtBone(const ParticleSystemTemplate *particleObject *building = getObject();ParticleSystem *psys = TheParticleSystemManager->createParticleSystem(particleSystemTemplate);- if (psys != NULL)+ if (psys != NULL){+ // drop the systems that have already died: a repeating emitter otherwise grows this list for+ // the whole match, and its saved count is only an UnsignedShort+ std::vector<ParticleSystemID>::iterator live = m_particleSystemIDs.begin();+ while (live != m_particleSystemIDs.end())+ {+ if (TheParticleSystemManager->findParticleSystem(*live) == NULL)+ live = m_particleSystemIDs.erase(live);+ else+ ++live;+ }m_particleSystemIDs.push_back(psys->getSystemID());psys->setPosition(bonePosition);psys->attachToObject(building);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cppindex d5a225185..339e696d9 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CleanupHazardUpdate.cpp@@ -223,6 +223,7 @@ void CleanupHazardUpdate::fireWhenReady()//re-evaluate by forcing a new scan.m_nextScanFrames = GameLogicRandomValue( 0, 3 );m_bestTargetID = INVALID_ID;+ m_inRange = false; // or every later out-of-range target rescans and drops tooif( !m_nextScanFrames ){scanClosestTarget();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CommandButtonHuntUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CommandButtonHuntUpdate.cppindex adb1b6bf2..fc68a6365 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CommandButtonHuntUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/CommandButtonHuntUpdate.cpp@@ -290,14 +290,15 @@ Object* CommandButtonHuntUpdate::scanClosestTarget(void)return NULL; // isn't going to happen.isBlackLotusVehicleHack = (spTemplate->getSpecialPowerType() == SPECIAL_BLACKLOTUS_DISABLE_VEHICLE_HACK);isCaptureBuilding = (spTemplate->getSpecialPowerType() == SPECIAL_INFANTRY_CAPTURE_BUILDING);- if (isCaptureBuilding)+ if (isCaptureBuilding){filters[3] = NULL; // It's ok (in fact necessary for oil derricks) to capture special buildings.- if (spTemplate->getSpecialPowerType() == SPECIAL_TIMED_CHARGES)- isPlaceExplosive = true;- if (spTemplate->getSpecialPowerType() == SPECIAL_TANKHUNTER_TNT_ATTACK)- isPlaceExplosive = true;}+ // outside the capture test: inside it the power type is always capture, so these never set+ if (spTemplate->getSpecialPowerType() == SPECIAL_TIMED_CHARGES)+ isPlaceExplosive = true;+ if (spTemplate->getSpecialPowerType() == SPECIAL_TANKHUNTER_TNT_ATTACK)+ isPlaceExplosive = true;}ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange( me->getPosition(), data->m_scanRange,diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cppindex cd18cc8e8..1a7b59b78 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/DockUpdate.cpp@@ -422,8 +422,19 @@ UpdateSleepTime DockUpdate::update()// forever and this dock never granted entry to anyone again - the classic "supply center stops// accepting trucks" stall.//+ // Clear what cancelDock() would have: a stale m_dockerInside makes a crippled warehouse kill the+ // next truck while it is still outside.if( m_activeDocker != INVALID_ID && TheGameLogic->findObjectByID( m_activeDocker ) == NULL )+ {m_activeDocker = INVALID_ID;+ m_dockerInside = FALSE;+ ModelConditionFlags clear;+ clear.set( MODELCONDITION_DOCKING_ENDING );+ clear.set( MODELCONDITION_DOCKING_BEGINNING );+ clear.set( MODELCONDITION_DOCKING_ACTIVE );+ clear.set( MODELCONDITION_DOCKING );+ getObject()->clearModelConditionFlags( clear );+ }if( m_activeDocker == INVALID_ID && !m_dockCrippled ){@@ -529,11 +540,14 @@ void DockUpdate::loadDockPositions()if( m_numberApproachPositions != DYNAMIC_APPROACH_VECTOR_FLAG ){// Dynamic means no bones+ // Only the bones found are written, and an INI count above the array would overrun it;+ // copying unwritten stack slots put garbage (and a desync) into the approach positions.Coord3D approachBones[DEFAULT_APPROACH_VECTOR_SIZE];- m_numberApproachPositionBones = myDrawable->getPristineBonePositions( "DockWaiting", 1, approachBones, NULL, m_numberApproachPositions);+ Int maxBones = min( m_numberApproachPositions, (Int)DEFAULT_APPROACH_VECTOR_SIZE );+ m_numberApproachPositionBones = myDrawable->getPristineBonePositions( "DockWaiting", 1, approachBones, NULL, maxBones );if( m_numberApproachPositions == m_approachPositions.size() )//safeguard: will always be true{- for( Int copyIndex = 0; copyIndex < m_numberApproachPositions; ++copyIndex )+ for( Int copyIndex = 0; copyIndex < m_numberApproachPositionBones; ++copyIndex ){m_approachPositions[copyIndex] = approachBones[copyIndex];}@@ -631,6 +645,8 @@ void DockUpdate::xfer( Xfer *xfer )// Vector of Bool gets packed as bitfield internallyBool unpack = m_approachPositionReached[vectorIndex];xfer->xferBool( &unpack );+ if( xfer->getXferMode() == XFER_LOAD )+ m_approachPositionReached[vectorIndex] = unpack;}// active dockerdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/RailedTransportDockUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/RailedTransportDockUpdate.cppindex 45fbfb234..0228f7fdc 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/RailedTransportDockUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/DockUpdate/RailedTransportDockUpdate.cpp@@ -233,6 +233,15 @@ void RailedTransportDockUpdate::unloadAll( void )void RailedTransportDockUpdate::unloadSingleObject( Object *obj ){+ // one already sliding out: queue this one behind it, or unloadNext() would drop the first+ // unloader mid-push and leave it HELD and unselectable for good+ if( m_unloadingObjectID != INVALID_ID )+ {+ if( m_unloadCount != UNLOAD_ALL )+ ++m_unloadCount;+ return;+ }+// start the unload process of a single objectm_unloadCount = 1;unloadNext();diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cppindex f74de4464..6293419e0 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/EMPUpdate.cpp@@ -200,8 +200,8 @@ void EMPUpdate::doDisableAttack( void )}}- SimpleObjectIterator *iter;- Object *curVictim;+ SimpleObjectIterator *iter = NULL;+ Object *curVictim = NULL;if (radius > 0.0f){@@ -379,16 +379,27 @@ void EMPUpdate::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: the timers and scale, or a load re-times the pulse from the load frame and disables twice */// ------------------------------------------------------------------------------------------------void EMPUpdate::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );+ if( version >= 2 )+ {+ UpdateModule::xfer( xfer );+ xfer->xferUnsignedInt( &m_dieFrame );+ xfer->xferUnsignedInt( &m_tintEnvFadeFrames );+ xfer->xferUnsignedInt( &m_tintEnvPlayFrame );+ xfer->xferReal( &m_targetScale );+ xfer->xferReal( &m_currentScale );+ }+} // end xfer// ------------------------------------------------------------------------------------------------@@ -503,8 +514,8 @@ void LeafletDropBehavior::doDisableAttack( void )Real curVictimDistSqr;const Coord3D *pos = object->getPosition();- SimpleObjectIterator *iter;- Object *curVictim;+ SimpleObjectIterator *iter = NULL;+ Object *curVictim = NULL;if (radius > 0.0f){diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FloatUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FloatUpdate.cppindex 63db03cfb..76ff312d1 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FloatUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/FloatUpdate.cpp@@ -107,7 +107,7 @@ UpdateSleepTime FloatUpdate::update( void )const Coord3D *pos = getObject()->getPosition();// get the height of the water here- Real waterZ;+ Real waterZ = pos->z; // isUnderwater leaves it alone where there is no waterTheTerrainLogic->isUnderwater( pos->x, pos->y, &waterZ );// snap to the water surfacediff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cppindex 223873234..34e9eb94c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp@@ -397,13 +397,14 @@ void HordeUpdate::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: m_trueHordeMember and m_lastHordeRefreshFrame, which neighbours read for the rub-off test */// ------------------------------------------------------------------------------------------------void HordeUpdate::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -416,6 +417,12 @@ void HordeUpdate::xfer( Xfer *xfer )// has flagxfer->xferBool( &m_hasFlag );+ if( version >= 2 )+ {+ xfer->xferBool( &m_trueHordeMember );+ xfer->xferUnsignedInt( &m_lastHordeRefreshFrame );+ }+} // end xfer// ------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cppindex 0002e08c9..b4b9841df 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/MissileLauncherBuildingUpdate.cpp@@ -206,6 +206,9 @@ void MissileLauncherBuildingUpdate::switchToState(DoorStateType dst)//-------------------------------------------------------------------------------------------------Bool MissileLauncherBuildingUpdate::initiateIntentToDoSpecialPower( const SpecialPowerTemplate *specialPowerTemplate, const Object *targetObj, const Coord3D *targetPos, const Waypoint *way, UnsignedInt commandOptions ){+ // update() caches this, but a script can fire a map-placed silo before its first update+ if( !m_specialPowerModule )+ m_specialPowerModule = getObject()->getSpecialPowerModule( getMissileLauncherBuildingUpdateModuleData()->m_specialPowerTemplate );if( m_specialPowerModule->getSpecialPowerTemplate() != specialPowerTemplate ){return FALSE;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/OCLUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/OCLUpdate.cppindex 73b5fab52..b6e23fc4e 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/OCLUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/OCLUpdate.cpp@@ -125,7 +125,10 @@ UpdateSleepTime OCLUpdate::update( void ){if( getObject()->isDisabled() ){- m_nextCreationFrame++;+ // push the timer back, but only once it is running: 0 means "start the first delay", and+ // bumping it off 0 skipped that delay+ if( m_nextCreationFrame != 0 )+ m_nextCreationFrame++;return UPDATE_SLEEP_NONE;}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cppindex 81a0b5047..e8e0a25c7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp@@ -590,9 +590,13 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()//Advance to the next waypoint.Int linkCount = way->getNumLinks();Int which = GameLogicRandomValue( 0, linkCount-1 );- way = way->getLink( which );- m_nextDestWaypointID = way->getID();- m_overrideTargetDestination.set( way->getLocation() );+ // the last waypoint of a path has no links: stay on it, as initiateIntentToDoSpecialPower does+ Waypoint *next = way->getLink( which );+ if( next )+ {+ m_nextDestWaypointID = next->getID();+ m_overrideTargetDestination.set( next->getLocation() );+ }}}}@@ -955,7 +959,7 @@ void ParticleUplinkCannonUpdate::createGroundToOrbitLaser( UnsignedInt growthFraif( beam ){TheGameClient->destroyDrawable( beam );- m_orbitToTargetBeamID = INVALID_DRAWABLE_ID;+ m_groundToOrbitBeamID = INVALID_DRAWABLE_ID;}if( data->m_particleBeamLaserName.isNotEmpty() )@@ -1119,7 +1123,7 @@ Bool ParticleUplinkCannonUpdate::calculateUpBonePositions(){obj->convertBonePosToWorldPos( &pos, &mtx, &m_connectorNodePosition, &mtx );}- if( data->m_connectorBoneName.isNotEmpty() && draw->getCurrentClientBonePositions( data->m_fireBoneName.str(), 0, &pos, &mtx, 1 ) )+ if( data->m_fireBoneName.isNotEmpty() && draw->getCurrentClientBonePositions( data->m_fireBoneName.str(), 0, &pos, &mtx, 1 ) ){obj->convertBonePosToWorldPos( &pos, &mtx, &m_laserOriginPosition, &mtx );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cppindex 1f6b45728..ab8e0a03a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PhysicsUpdate.cpp@@ -229,6 +229,8 @@ PhysicsBehavior::PhysicsBehavior( Thing *thing, const ModuleData* moduleData ) :m_ignoreCollisionsWith = INVALID_ID;setAllowBouncing(getPhysicsBehaviorModuleData()->m_allowBouncing);+ // what a finished bounce restores; never set, so it restored FALSE and AllowBouncing = Yes was lost+ m_originalAllowBounce = getPhysicsBehaviorModuleData()->m_allowBouncing;setAllowCollideForce(getPhysicsBehaviorModuleData()->m_allowCollideForce);m_pui = NULL;@@ -705,7 +707,9 @@ UpdateSleepTime PhysicsBehavior::update()obj->isSignificantlyAboveTerrain() == FALSE ){setStunned(false);- getObject()->clearModelConditionState(MODELCONDITION_STUNNED);+ // tested on last frame's position, so this can run before the landing below ever+ // swaps flailing for stunned; clear both or the unit flails for good+ getObject()->clearModelConditionFlags( MAKE_MODELCONDITION_MASK2( MODELCONDITION_STUNNED, MODELCONDITION_STUNNED_FLAILING ) );}}@@ -1075,6 +1079,12 @@ void PhysicsBehavior::addVelocityTo( const Coord3D *vel){if (vel != NULL)m_vel.add( vel );+ // as applyForce does: the cached magnitude is stale, and a sleeping body has to wake to move+ m_velMag = INVALID_VEL_MAG;+#ifdef SLEEPY_PHYSICS+ if (!getFlag(IS_IN_UPDATE))+ setWakeFrame(getObject(), UPDATE_SLEEP_NONE);+#endif}//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PointDefenseLaserUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PointDefenseLaserUpdate.cppindex 3e9a47dc9..181b1d555 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PointDefenseLaserUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/PointDefenseLaserUpdate.cpp@@ -181,6 +181,7 @@ void PointDefenseLaserUpdate::fireWhenReady()//re-evaluate by forcing a new scan.m_nextScanFrames = GameLogicRandomValue( 0, 3 );m_bestTargetID = INVALID_ID;+ m_inRange = false; // the fire block below needs it, or a non-zero rescan delay shoots out of rangeif( !m_nextScanFrames ){scanClosestTarget();@@ -317,7 +318,7 @@ Object* PointDefenseLaserUpdate::scanClosestTarget()pos.add( other->getPosition() );//Recalculate the distance.- fDist = sqrt( ThePartitionManager->getDistanceSquared( me, other, FROM_CENTER_2D ) );+ fDist = sqrt( ThePartitionManager->getDistanceSquared( me, &pos, FROM_CENTER_2D ) );}}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SupplyCenterProductionExitUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SupplyCenterProductionExitUpdate.cppindex ef71b17c4..d7557f802 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SupplyCenterProductionExitUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionExitUpdate/SupplyCenterProductionExitUpdate.cpp@@ -53,6 +53,7 @@ SupplyCenterProductionExitUpdate::SupplyCenterProductionExitUpdate( Thing *thing{// no rally point has been setm_rallyPointExists = false;+ m_rallyPoint.zero();setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);}@@ -143,7 +144,7 @@ void SupplyCenterProductionExitUpdate::exitObjectViaDoor( Object *newObj, ExitDo//GPS scrambler. We want that to take precendence.if( getObject()->testStatus( OBJECT_STATUS_STEALTHED ) ){- if( stealth->isTemporaryGrant() || !newObj->testStatus( OBJECT_STATUS_CAN_STEALTH ) )+ if( stealth && ( stealth->isTemporaryGrant() || !newObj->testStatus( OBJECT_STATUS_CAN_STEALTH ) ) ){stealth->receiveGrant( TRUE, md->m_grantTemporaryStealthFrames );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cppindex 1cee65774..18b065fa5 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp@@ -219,6 +219,7 @@ ProductionUpdate::~ProductionUpdate( void )production = m_productionQueue;removeFromProductionQueue( production );+ production->deleteInstance(); // unlinking does not free it} // end while@@ -385,9 +386,11 @@ void ProductionUpdate::cancelUpgrade( const UpgradeTemplate *upgrade )// remove the IN_PRODUCTION status of this upgrade from the player, object upgrades don't// have any other IN_PRODUCTION status other than their existence in the build queue//- if( upgrade->getUpgradeType() == UPGRADE_TYPE_PLAYER )+ // only when it really is in production: removeUpgrade drops the entry whatever its status, so a+ // player who already owns the upgrade complete (a queue carried over by a change of owner) lost it+ if( upgrade->getUpgradeType() == UPGRADE_TYPE_PLAYER && refundIt )player->removeUpgrade( upgrade );-+} // end cancelUpgrade//-------------------------------------------------------------------------------------------------diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cppindex a7a746d8c..80804ffa7 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SlavedUpdate.cpp@@ -298,7 +298,9 @@ void SlavedUpdate::doAttackLogic( const Object *target )//calculate the closest allowable position.const Coord3D *targetPos = target->getPosition();Real dist = ThePartitionManager->getDistanceSquared( me, targetPos, FROM_BOUNDINGSPHERE_2D );- if( dist > sqr( data->m_attackRange ) )+ // the leash is measured from the master, the same point the clamp below is taken from; measured+ // from the drone it sent a drone far from a near target to a spot past that target+ if( ThePartitionManager->getDistanceSquared( master, targetPos, FROM_BOUNDINGSPHERE_2D ) > sqr( data->m_attackRange ) ){//The distance is too far, so calculate the best allowable position.Coord3D vector;@@ -360,7 +362,8 @@ void SlavedUpdate::doScoutLogic( const Coord3D *mastersDestination )//First, determine the scout position. If our master's destination is too far away, then we'll//calculate the closest allowable position.- Real dist = ThePartitionManager->getDistanceSquared( me, mastersDestination, FROM_BOUNDINGSPHERE_2D );+ // from the master, like the clamp below+ Real dist = ThePartitionManager->getDistanceSquared( master, mastersDestination, FROM_BOUNDINGSPHERE_2D );if( dist > sqr( data->m_scoutRange ) ){//The distance is too far, so calculate the best allowable position.@@ -643,7 +646,7 @@ void SlavedUpdate::setRepairState( RepairStates repairState )}weldingSys->setPosition( &pos );- Real time = (Real)(m_framesToWait * LOGICFRAMES_PER_SECOND);+ Real time = (Real)m_framesToWait; // already framesweldingSys->setLifetimeRange( time, time );AudioEventRTS soundToPlay = TheAudio->getMiscAudio()->m_repairSparks;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SmartBombTargetHomingUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SmartBombTargetHomingUpdate.cppindex 6cc2bf70e..91d17742c 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SmartBombTargetHomingUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SmartBombTargetHomingUpdate.cpp@@ -124,19 +124,26 @@ void SmartBombTargetHomingUpdate::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer method* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: the target, or a bomb falling at save time drops unguided after the load */// ------------------------------------------------------------------------------------------------void SmartBombTargetHomingUpdate::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );// extend base classUpdateModule::xfer( xfer );+ if( version >= 2 )+ {+ xfer->xferBool( &m_targetReceived );+ xfer->xferCoord3D( &m_target );+ }+} // end xferdiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cppindex bdfb94893..42eec453f 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpecialAbilityUpdate.cpp@@ -908,6 +908,7 @@ Bool SpecialAbilityUpdate::isWithinStartAbilityRange() constPartitionFilterLineOfSight filterLOS( self );PartitionFilter *filters[] = { &filterLOS, NULL };ObjectIterator *iter = ThePartitionManager->iterateObjectsInRange( self, range, FROM_BOUNDINGSPHERE_2D, filters, ITER_SORTED_NEAR_TO_FAR );+ MemoryPoolObjectHolder hold( iter );for( Object *theTarget = iter->first(); theTarget; theTarget = iter->next() ){//LOS check succeeded.diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cppindex 5746ee274..73b7fc1bf 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpectreGunshipUpdate.cpp@@ -207,6 +207,9 @@ Bool SpectreGunshipUpdate::initiateIntentToDoSpecialPower(const SpecialPowerTempUnsignedInt now = TheGameLogic->getFrame();m_specialPowerModule->setReadyFrame( now );m_initialTargetPosition.set( targetPos );+ // a fresh gunship, so these were (0,0,0): the AI's and scripts' gunships aimed at the map corner+ m_overrideTargetDestination.set( targetPos );+ m_gattlingTargetPosition.set( targetPos );setLogicalStatus( GUNSHIP_STATUS_INSERTING );}diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpyVisionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpyVisionUpdate.cppindex 7b487f7c5..d97c89794 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpyVisionUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/SpyVisionUpdate.cpp@@ -196,7 +196,12 @@ void SpyVisionUpdate::doActivationWork( Player *playerToSetFor, Bool setting )const SpyVisionUpdateModuleData *data = getSpyVisionUpdateModuleData();if( playerToSetFor == NULL || ThePlayerList == NULL )return;-++ // setVisionSpied is reference counted: switching on twice (a power fired while it is already+ // on) and off once left the enemy spied for good+ if( setting == m_currentlyActive )+ return;+for (Int i=0; i < ThePlayerList->getPlayerCount(); ++i){Player *player = ThePlayerList->getNthPlayer(i);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cppindex 5ac3af4dc..6debf3d4a 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StealthUpdate.cpp@@ -89,6 +89,7 @@ StealthUpdateModuleData::StealthUpdateModuleData()m_enemyDetectionEvaEvent = EVA_Invalid;m_ownDetectionEvaEvent = EVA_Invalid;m_grantedBySpecialPower = FALSE;+ m_useRiderStealth = FALSE;}@@ -618,7 +619,9 @@ UpdateSleepTime StealthUpdate::update( void )Object *self = getObject();Object *stealthOwner = calcStealthOwner();- UnsignedInt stealthDelay;+ // our own delay unless a rider's stealth module overrides it below; a rider without one left+ // this as stack garbage+ UnsignedInt stealthDelay = getStealthUpdateModuleData()->m_stealthDelay;if( self == stealthOwner ){@@ -875,7 +878,9 @@ void StealthUpdate::markAsDetected(UnsignedInt numFrames)Object *self = getObject();Object *stealthOwner = calcStealthOwner();- UnsignedInt stealthDelay, orderIdlesToAttack;+ // our own rules unless a rider's stealth module overrides them below+ UnsignedInt stealthDelay = getStealthUpdateModuleData()->m_stealthDelay;+ UnsignedInt orderIdlesToAttack = getStealthUpdateModuleData()->m_orderIdleEnemiesToAttackMeUponReveal;if( self == stealthOwner ){const StealthUpdateModuleData *data = getStealthUpdateModuleData();@@ -1058,7 +1063,7 @@ void StealthUpdate::changeVisualDisguise()const ThingTemplate *tTemplate = self->getTemplate();- TheThingFactory->newDrawable( tTemplate );+ draw = TheThingFactory->newDrawable( tTemplate ); // the old one was just freedif( draw ){TheGameLogic->bindObjectAndDrawable(self, draw);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cppindex de00b2c7f..a3828edc3 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StructureToppleUpdate.cpp@@ -179,7 +179,8 @@ void StructureToppleUpdate::beginStructureTopple(const DamageInfo *damageInfo)m_delayBurstLocation.z = TheTerrainLogic->getGroundHeight(m_delayBurstLocation.x, m_delayBurstLocation.y);doToppleStartFX(building, damageInfo);- m_nextBurstFrame = now + GameClientRandomValue(d->m_minToppleBurstDelay, d->m_maxToppleBurstDelay);+ // logic random: each burst runs doPhaseStuff(STPHASE_DELAY), which creates OCL objects+ m_nextBurstFrame = now + GameLogicRandomValue(d->m_minToppleBurstDelay, d->m_maxToppleBurstDelay);m_toppleState = TOPPLESTATE_WAITINGFORTOPPLESTART;@@ -228,8 +229,8 @@ UpdateSleepTime StructureToppleUpdate::update( void )UnsignedInt now = TheGameLogic->getFrame();if (now >= m_nextBurstFrame) {doToppleDelayBurstFX();- // This uses a game client random value because the delay bursts are purely visual and aural effects.- m_nextBurstFrame = now + GameClientRandomValue(d->m_minToppleBurstDelay, d->m_maxToppleBurstDelay);+ // Logic random, not client: the burst also fires the STPHASE_DELAY OCLs, which are logic objects.+ m_nextBurstFrame = now + GameLogicRandomValue(d->m_minToppleBurstDelay, d->m_maxToppleBurstDelay);}if (now >= m_toppleFrame) {m_toppleState = TOPPLESTATE_TOPPLING;@@ -276,8 +277,8 @@ UpdateSleepTime StructureToppleUpdate::update( void )if (now >= m_nextBurstFrame) {doToppleDelayBurstFX();- // This uses a game client random value because the delay bursts are purely visual and aural effects.- m_nextBurstFrame = now + GameClientRandomValue(d->m_minToppleBurstDelay, d->m_maxToppleBurstDelay);+ // Logic random, not client: the burst also fires the STPHASE_DELAY OCLs, which are logic objects.+ m_nextBurstFrame = now + GameLogicRandomValue(d->m_minToppleBurstDelay, d->m_maxToppleBurstDelay);}Object *building = getObject();@@ -434,7 +435,8 @@ void StructureToppleUpdate::doDamageLine(Object *building, const WeaponTemplate*for (Real i = -facingWidth; i < facingWidth; i += WEAPON_SPACING_PARALLEL){- target.x = building->getPosition()->x + jcos + (i * Sin(toppleAngle));+ // across the fall line: (-sin, cos) is perpendicular to (cos, sin), (sin, cos) only at 0 and 90 degrees+ target.x = building->getPosition()->x + jcos - (i * Sin(toppleAngle));target.y = building->getPosition()->y + jsin + (i * Cos(toppleAngle));target.z = TheTerrainLogic->getGroundHeight(target.x, target.y);@@ -446,7 +448,7 @@ void StructureToppleUpdate::doDamageLine(Object *building, const WeaponTemplate*}// Make sure there are weapons fired and FX done on the edge of the building.- target.x = building->getPosition()->x + jcos + (facingWidth * Sin(toppleAngle));+ target.x = building->getPosition()->x + jcos - (facingWidth * Sin(toppleAngle));target.y = building->getPosition()->y + jsin + (facingWidth * Cos(toppleAngle));target.z = TheTerrainLogic->getGroundHeight(target.x, target.y);diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/TensileFormationUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/TensileFormationUpdate.cppindex 6cd4d1950..04e865fdf 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/TensileFormationUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/TensileFormationUpdate.cpp@@ -302,7 +302,7 @@ UpdateSleepTime TensileFormationUpdate::update( void )Object *tree = ThePartitionManager->getClosestObject( &newPos, getObject()->getGeometryInfo().getMajorRadius(), FROM_CENTER_2D );- if (tree->isKindOf( KINDOF_SHRUBBERY ))+ if (tree && tree != getObject() && tree->isKindOf( KINDOF_SHRUBBERY )) // nothing in reach comes back NULLtree->topple( &m_inertia, m_inertia.length(), 1 );//No Bouncediff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/WaveGuideUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/WaveGuideUpdate.cppindex f5890cc18..0e9fe9a74 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/WaveGuideUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/WaveGuideUpdate.cpp@@ -60,6 +60,7 @@ WaveGuideUpdateModuleData::WaveGuideUpdateModuleData( void ){//Added By Sadullah Nader//Initialization(s) inserted+ m_bridgeParticle = NULL;m_bridgeParticleAngleFudge = 0.0f;m_randomSplashSoundFrequency = 0;m_waveDelay = 0.0f;@@ -553,7 +554,7 @@ void WaveGuideUpdate::doDamage( void )const WaveGuideUpdateModuleData *modData = getWaveGuideUpdateModuleData();// get our position forward unit direction vector-// const Coord3D *unitForward = waveGuide->getUnitDirectionVector2D();+ const Coord3D *unitForward = waveGuide->getUnitDirectionVector2D();// iterate over all our sample points and kill stuff around usfor( Int i = 0; i < m_shapePointCount; i++ )@@ -604,9 +605,9 @@ void WaveGuideUpdate::doDamage( void )// get the cosine of the angle between the our forward direction and the vector to the obj// otherwise known as a dot product//- angle = v.x * m_transformedShapePoints[ i ].x +- v.y * m_transformedShapePoints[ i ].y +- v.z * m_transformedShapePoints[ i ].z;+ // against the forward direction: dotting with the sample point's world position made+ // "behind the wave" depend on where the map origin is+ angle = v.x * unitForward->x + v.y * unitForward->y;//// we will only do damage if the object is "behind" the wave ... that is, behinddiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/RadarUpgrade.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/RadarUpgrade.cppindex 4da76556c..90644b893 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/RadarUpgrade.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Upgrade/RadarUpgrade.cpp@@ -131,8 +131,10 @@ void RadarUpgrade::upgradeImplementation( void )Player *player = getObject()->getControllingPlayer();- // update the player with another radar facility- player->addRadar( md->m_isDisableProof );+ // update the player with another radar facility; while disabled, Object::onDisabledEdge adds it+ // on re-enable, and adding it here as well counted it twice (radar kept after the building died)+ if( !getObject()->isDisabled() )+ player->addRadar( md->m_isDisableProof );// find the radar update module of this objectNameKeyType radarUpdateKey = NAMEKEY( "RadarUpdate" );