From 28c427bfcb87335326e5eea0f2fd7f7240cd33b6 Mon Sep 17 00:00:00 2001 From: MrS-ibra Date: Tue, 23 Dec 2025 01:51:42 +0300 Subject: [PATCH 1/3] fix vet 1 quad damage --- .../Source/GameLogic/Object/Weapon.cpp | 889 +++++++++--------- 1 file changed, 445 insertions(+), 444 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp index 8e0dcb27947..d4a44bc27cc 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #define DEFINE_DEATH_NAMES #define DEFINE_WEAPONBONUSCONDITION_NAMES @@ -48,7 +48,7 @@ #include "Common/ThingFactory.h" #include "Common/ThingTemplate.h" #include "Common/Xfer.h" - + #include "GameClient/Drawable.h" #include "GameClient/FXList.h" #include "GameClient/InGameUI.h" @@ -159,86 +159,86 @@ WeaponStore *TheWeaponStore = NULL; ///< the weapon store definition /////////////////////////////////////////////////////////////////////////////////////////////////// // PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// -const FieldParse WeaponTemplate::TheWeaponTemplateFieldParseTable[] = -{ - - { "PrimaryDamage", INI::parseReal, NULL, offsetof(WeaponTemplate, m_primaryDamage) }, - { "PrimaryDamageRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_primaryDamageRadius) }, - { "SecondaryDamage", INI::parseReal, NULL, offsetof(WeaponTemplate, m_secondaryDamage) }, - { "SecondaryDamageRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_secondaryDamageRadius) }, - { "ShockWaveAmount", INI::parseReal, NULL, offsetof(WeaponTemplate, m_shockWaveAmount) }, - { "ShockWaveRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_shockWaveRadius) }, - { "ShockWaveTaperOff", INI::parseReal, NULL, offsetof(WeaponTemplate, m_shockWaveTaperOff) }, - { "AttackRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_attackRange) }, - { "MinimumAttackRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_minimumAttackRange) }, - { "RequestAssistRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_requestAssistRange) }, - { "AcceptableAimDelta", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_aimDelta) }, - { "ScatterRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterRadius) }, - { "ScatterTargetScalar", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterTargetScalar) }, +const FieldParse WeaponTemplate::TheWeaponTemplateFieldParseTable[] = +{ + + { "PrimaryDamage", INI::parseReal, NULL, offsetof(WeaponTemplate, m_primaryDamage) }, + { "PrimaryDamageRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_primaryDamageRadius) }, + { "SecondaryDamage", INI::parseReal, NULL, offsetof(WeaponTemplate, m_secondaryDamage) }, + { "SecondaryDamageRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_secondaryDamageRadius) }, + { "ShockWaveAmount", INI::parseReal, NULL, offsetof(WeaponTemplate, m_shockWaveAmount) }, + { "ShockWaveRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_shockWaveRadius) }, + { "ShockWaveTaperOff", INI::parseReal, NULL, offsetof(WeaponTemplate, m_shockWaveTaperOff) }, + { "AttackRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_attackRange) }, + { "MinimumAttackRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_minimumAttackRange) }, + { "RequestAssistRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_requestAssistRange) }, + { "AcceptableAimDelta", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_aimDelta) }, + { "ScatterRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterRadius) }, + { "ScatterTargetScalar", INI::parseReal, NULL, offsetof(WeaponTemplate, m_scatterTargetScalar) }, { "ScatterRadiusVsInfantry", INI::parseReal, NULL, offsetof( WeaponTemplate, m_infantryInaccuracyDist ) }, - { "DamageType", DamageTypeFlags::parseSingleBitFromINI, NULL, offsetof(WeaponTemplate, m_damageType) }, - { "DamageStatusType", ObjectStatusMaskType::parseSingleBitFromINI, NULL, offsetof(WeaponTemplate, m_damageStatusType) }, - { "DeathType", INI::parseIndexList, TheDeathNames, offsetof(WeaponTemplate, m_deathType) }, - { "WeaponSpeed", INI::parseVelocityReal, NULL, offsetof(WeaponTemplate, m_weaponSpeed) }, - { "MinWeaponSpeed", INI::parseVelocityReal, NULL, offsetof(WeaponTemplate, m_minWeaponSpeed) }, - { "ScaleWeaponSpeed", INI::parseBool, NULL, offsetof(WeaponTemplate, m_isScaleWeaponSpeed) }, - { "WeaponRecoil", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_weaponRecoil) }, - { "MinTargetPitch", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_minTargetPitch) }, - { "MaxTargetPitch", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_maxTargetPitch) }, - { "RadiusDamageAngle", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_radiusDamageAngle) }, - { "ProjectileObject", INI::parseAsciiString, NULL, offsetof(WeaponTemplate, m_projectileName) }, - { "FireSound", INI::parseAudioEventRTS, NULL, offsetof(WeaponTemplate, m_fireSound) }, - { "FireSoundLoopTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_fireSoundLoopTime) }, - { "FireFX", parseAllVetLevelsFXList, NULL, offsetof(WeaponTemplate, m_fireFXs) }, - { "ProjectileDetonationFX", parseAllVetLevelsFXList, NULL, offsetof(WeaponTemplate, m_projectileDetonateFXs) }, - { "FireOCL", parseAllVetLevelsAsciiString, NULL, offsetof(WeaponTemplate, m_fireOCLNames) }, - { "ProjectileDetonationOCL", parseAllVetLevelsAsciiString, NULL, offsetof(WeaponTemplate, m_projectileDetonationOCLNames) }, - { "ProjectileExhaust", parseAllVetLevelsPSys, NULL, offsetof(WeaponTemplate, m_projectileExhausts) }, - { "VeterancyFireFX", parsePerVetLevelFXList, NULL, offsetof(WeaponTemplate, m_fireFXs) }, - { "VeterancyProjectileDetonationFX", parsePerVetLevelFXList, NULL, offsetof(WeaponTemplate, m_projectileDetonateFXs) }, - { "VeterancyFireOCL", parsePerVetLevelAsciiString, NULL, offsetof(WeaponTemplate, m_fireOCLNames) }, - { "VeterancyProjectileDetonationOCL", parsePerVetLevelAsciiString, NULL, offsetof(WeaponTemplate, m_projectileDetonationOCLNames) }, - { "VeterancyProjectileExhaust", parsePerVetLevelPSys, NULL, offsetof(WeaponTemplate, m_projectileExhausts) }, - { "ClipSize", INI::parseInt, NULL, offsetof(WeaponTemplate, m_clipSize) }, - { "ContinuousFireOne", INI::parseInt, NULL, offsetof(WeaponTemplate, m_continuousFireOneShotsNeeded) }, - { "ContinuousFireTwo", INI::parseInt, NULL, offsetof(WeaponTemplate, m_continuousFireTwoShotsNeeded) }, - { "ContinuousFireCoast", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_continuousFireCoastFrames) }, - { "AutoReloadWhenIdle", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_autoReloadWhenIdleFrames) }, - { "ClipReloadTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_clipReloadTime) }, + { "DamageType", DamageTypeFlags::parseSingleBitFromINI, NULL, offsetof(WeaponTemplate, m_damageType) }, + { "DamageStatusType", ObjectStatusMaskType::parseSingleBitFromINI, NULL, offsetof(WeaponTemplate, m_damageStatusType) }, + { "DeathType", INI::parseIndexList, TheDeathNames, offsetof(WeaponTemplate, m_deathType) }, + { "WeaponSpeed", INI::parseVelocityReal, NULL, offsetof(WeaponTemplate, m_weaponSpeed) }, + { "MinWeaponSpeed", INI::parseVelocityReal, NULL, offsetof(WeaponTemplate, m_minWeaponSpeed) }, + { "ScaleWeaponSpeed", INI::parseBool, NULL, offsetof(WeaponTemplate, m_isScaleWeaponSpeed) }, + { "WeaponRecoil", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_weaponRecoil) }, + { "MinTargetPitch", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_minTargetPitch) }, + { "MaxTargetPitch", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_maxTargetPitch) }, + { "RadiusDamageAngle", INI::parseAngleReal, NULL, offsetof(WeaponTemplate, m_radiusDamageAngle) }, + { "ProjectileObject", INI::parseAsciiString, NULL, offsetof(WeaponTemplate, m_projectileName) }, + { "FireSound", INI::parseAudioEventRTS, NULL, offsetof(WeaponTemplate, m_fireSound) }, + { "FireSoundLoopTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_fireSoundLoopTime) }, + { "FireFX", parseAllVetLevelsFXList, NULL, offsetof(WeaponTemplate, m_fireFXs) }, + { "ProjectileDetonationFX", parseAllVetLevelsFXList, NULL, offsetof(WeaponTemplate, m_projectileDetonateFXs) }, + { "FireOCL", parseAllVetLevelsAsciiString, NULL, offsetof(WeaponTemplate, m_fireOCLNames) }, + { "ProjectileDetonationOCL", parseAllVetLevelsAsciiString, NULL, offsetof(WeaponTemplate, m_projectileDetonationOCLNames) }, + { "ProjectileExhaust", parseAllVetLevelsPSys, NULL, offsetof(WeaponTemplate, m_projectileExhausts) }, + { "VeterancyFireFX", parsePerVetLevelFXList, NULL, offsetof(WeaponTemplate, m_fireFXs) }, + { "VeterancyProjectileDetonationFX", parsePerVetLevelFXList, NULL, offsetof(WeaponTemplate, m_projectileDetonateFXs) }, + { "VeterancyFireOCL", parsePerVetLevelAsciiString, NULL, offsetof(WeaponTemplate, m_fireOCLNames) }, + { "VeterancyProjectileDetonationOCL", parsePerVetLevelAsciiString, NULL, offsetof(WeaponTemplate, m_projectileDetonationOCLNames) }, + { "VeterancyProjectileExhaust", parsePerVetLevelPSys, NULL, offsetof(WeaponTemplate, m_projectileExhausts) }, + { "ClipSize", INI::parseInt, NULL, offsetof(WeaponTemplate, m_clipSize) }, + { "ContinuousFireOne", INI::parseInt, NULL, offsetof(WeaponTemplate, m_continuousFireOneShotsNeeded) }, + { "ContinuousFireTwo", INI::parseInt, NULL, offsetof(WeaponTemplate, m_continuousFireTwoShotsNeeded) }, + { "ContinuousFireCoast", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_continuousFireCoastFrames) }, + { "AutoReloadWhenIdle", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_autoReloadWhenIdleFrames) }, + { "ClipReloadTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_clipReloadTime) }, { "DelayBetweenShots", WeaponTemplate::parseShotDelay, NULL, 0 }, { "ShotsPerBarrel", INI::parseInt, NULL, offsetof(WeaponTemplate, m_shotsPerBarrel) }, - { "DamageDealtAtSelfPosition",INI::parseBool, NULL, offsetof(WeaponTemplate, m_damageDealtAtSelfPosition) }, - { "RadiusDamageAffects", INI::parseBitString32, TheWeaponAffectsMaskNames, offsetof(WeaponTemplate, m_affectsMask) }, - { "ProjectileCollidesWith", INI::parseBitString32, TheWeaponCollideMaskNames, offsetof(WeaponTemplate, m_collideMask) }, - { "AntiAirborneVehicle", INI::parseBitInInt32, (void*)WEAPON_ANTI_AIRBORNE_VEHICLE, offsetof(WeaponTemplate, m_antiMask) }, - { "AntiGround", INI::parseBitInInt32, (void*)WEAPON_ANTI_GROUND, offsetof(WeaponTemplate, m_antiMask) }, - { "AntiProjectile", INI::parseBitInInt32, (void*)WEAPON_ANTI_PROJECTILE, offsetof(WeaponTemplate, m_antiMask) }, + { "DamageDealtAtSelfPosition",INI::parseBool, NULL, offsetof(WeaponTemplate, m_damageDealtAtSelfPosition) }, + { "RadiusDamageAffects", INI::parseBitString32, TheWeaponAffectsMaskNames, offsetof(WeaponTemplate, m_affectsMask) }, + { "ProjectileCollidesWith", INI::parseBitString32, TheWeaponCollideMaskNames, offsetof(WeaponTemplate, m_collideMask) }, + { "AntiAirborneVehicle", INI::parseBitInInt32, (void*)WEAPON_ANTI_AIRBORNE_VEHICLE, offsetof(WeaponTemplate, m_antiMask) }, + { "AntiGround", INI::parseBitInInt32, (void*)WEAPON_ANTI_GROUND, offsetof(WeaponTemplate, m_antiMask) }, + { "AntiProjectile", INI::parseBitInInt32, (void*)WEAPON_ANTI_PROJECTILE, offsetof(WeaponTemplate, m_antiMask) }, { "AntiSmallMissile", INI::parseBitInInt32, (void*)WEAPON_ANTI_SMALL_MISSILE, offsetof(WeaponTemplate, m_antiMask) }, { "AntiMine", INI::parseBitInInt32, (void*)WEAPON_ANTI_MINE, offsetof(WeaponTemplate, m_antiMask) }, { "AntiParachute", INI::parseBitInInt32, (void*)WEAPON_ANTI_PARACHUTE, offsetof(WeaponTemplate, m_antiMask) }, { "AntiAirborneInfantry", INI::parseBitInInt32, (void*)WEAPON_ANTI_AIRBORNE_INFANTRY, offsetof(WeaponTemplate, m_antiMask) }, { "AntiBallisticMissile", INI::parseBitInInt32, (void*)WEAPON_ANTI_BALLISTIC_MISSILE, offsetof(WeaponTemplate, m_antiMask) }, - { "AutoReloadsClip", INI::parseIndexList, TheWeaponReloadNames, offsetof(WeaponTemplate, m_reloadType) }, + { "AutoReloadsClip", INI::parseIndexList, TheWeaponReloadNames, offsetof(WeaponTemplate, m_reloadType) }, { "ProjectileStreamName", INI::parseAsciiString, NULL, offsetof(WeaponTemplate, m_projectileStreamName) }, { "LaserName", INI::parseAsciiString, NULL, offsetof(WeaponTemplate, m_laserName) }, { "LaserBoneName", INI::parseAsciiString, NULL, offsetof(WeaponTemplate, m_laserBoneName) }, - { "WeaponBonus", WeaponTemplate::parseWeaponBonusSet, NULL, 0 }, - { "HistoricBonusTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_historicBonusTime) }, - { "HistoricBonusRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_historicBonusRadius) }, - { "HistoricBonusCount", INI::parseInt, NULL, offsetof(WeaponTemplate, m_historicBonusCount) }, - { "HistoricBonusWeapon", INI::parseWeaponTemplate, NULL, offsetof(WeaponTemplate, m_historicBonusWeapon) }, + { "WeaponBonus", WeaponTemplate::parseWeaponBonusSet, NULL, 0 }, + { "HistoricBonusTime", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_historicBonusTime) }, + { "HistoricBonusRadius", INI::parseReal, NULL, offsetof(WeaponTemplate, m_historicBonusRadius) }, + { "HistoricBonusCount", INI::parseInt, NULL, offsetof(WeaponTemplate, m_historicBonusCount) }, + { "HistoricBonusWeapon", INI::parseWeaponTemplate, NULL, offsetof(WeaponTemplate, m_historicBonusWeapon) }, { "LeechRangeWeapon", INI::parseBool, NULL, offsetof(WeaponTemplate, m_leechRangeWeapon) }, - { "ScatterTarget", WeaponTemplate::parseScatterTarget, NULL, 0 }, + { "ScatterTarget", WeaponTemplate::parseScatterTarget, NULL, 0 }, { "CapableOfFollowingWaypoints", INI::parseBool, NULL, offsetof(WeaponTemplate, m_capableOfFollowingWaypoint) }, { "ShowsAmmoPips", INI::parseBool, NULL, offsetof(WeaponTemplate, m_isShowsAmmoPips) }, { "AllowAttackGarrisonedBldgs", INI::parseBool, NULL, offsetof(WeaponTemplate, m_allowAttackGarrisonedBldgs) }, { "PlayFXWhenStealthed", INI::parseBool, NULL, offsetof(WeaponTemplate, m_playFXWhenStealthed) }, { "PreAttackDelay", INI::parseDurationUnsignedInt, NULL, offsetof( WeaponTemplate, m_preAttackDelay ) }, - { "PreAttackType", INI::parseIndexList, TheWeaponPrefireNames, offsetof(WeaponTemplate, m_prefireType) }, + { "PreAttackType", INI::parseIndexList, TheWeaponPrefireNames, offsetof(WeaponTemplate, m_prefireType) }, { "ContinueAttackRange", INI::parseReal, NULL, offsetof(WeaponTemplate, m_continueAttackRange) }, - { "SuspendFXDelay", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_suspendFXDelay) }, + { "SuspendFXDelay", INI::parseDurationUnsignedInt, NULL, offsetof(WeaponTemplate, m_suspendFXDelay) }, { "MissileCallsOnDie", INI::parseBool, NULL, offsetof(WeaponTemplate, m_dieOnDetonate) }, - { NULL, NULL, NULL, 0 } + { NULL, NULL, NULL, 0 } }; @@ -322,8 +322,8 @@ WeaponTemplate::WeaponTemplate() : m_nextTemplate(NULL) m_damageStatusType = OBJECT_STATUS_NONE; m_suspendFXDelay = 0; m_dieOnDetonate = FALSE; - - m_historicDamageTriggerId = 0; + + m_historicDamageTriggerId = 0; } //------------------------------------------------------------------------------------------------- @@ -342,7 +342,7 @@ WeaponTemplate::~WeaponTemplate() void WeaponTemplate::reset( void ) { m_historicDamage.clear(); -} +} //------------------------------------------------------------------------------------------------- /*static*/ void WeaponTemplate::parseWeaponBonusSet( INI* ini, void *instance, void * /*store*/, const void* /*userData*/ ) @@ -392,14 +392,14 @@ void WeaponTemplate::reset( void ) else self->m_maxDelayBetweenShots = INI::scanInt(ini->getNextToken(ini->getSepsColon())); } - else + else { // single entry, as in no label so the first token is just a number self->m_minDelayBetweenShots = INI::scanInt(token); self->m_maxDelayBetweenShots = self->m_minDelayBetweenShots; } - // No matter what we have now, we want to convert it to frames from msec. + // No matter what we have now, we want to convert it to frames from msec. // ShotDelay used to use parseDurationUnsignedInt, and we are expanding on that. self->m_minDelayBetweenShots = ceilf(ConvertDurationFromMsecsToFrames((Real)self->m_minDelayBetweenShots)); self->m_maxDelayBetweenShots = ceilf(ConvertDurationFromMsecsToFrames((Real)self->m_maxDelayBetweenShots)); @@ -414,7 +414,7 @@ void WeaponTemplate::postProcessLoad() DEBUG_CRASH(("you must call this after TheThingFactory is inited")); return; } - + if (m_projectileName.isEmpty()) { m_projectileTmpl = NULL; @@ -452,37 +452,37 @@ void WeaponTemplate::postProcessLoad() m_projectileDetonationOCLNames[i].clear(); } -} +} //------------------------------------------------------------------------------------------------- -Real WeaponTemplate::getAttackRange(const WeaponBonus& bonus) const +Real WeaponTemplate::getAttackRange(const WeaponBonus& bonus) const { #ifdef RATIONALIZE_ATTACK_RANGE // Note - undersize by 1/4 of a pathfind cell, so that the goal is not teetering on the edge // of firing range. jba. const Real UNDERSIZE = PATHFIND_CELL_SIZE_F*0.25f; - Real r = m_attackRange * bonus.getField(WeaponBonus::RANGE) - UNDERSIZE; + Real r = m_attackRange * bonus.getField(WeaponBonus::RANGE) - UNDERSIZE; if (r < 0.0f) r = 0.0f; return r; #else // fudge this a little to account for pathfinding roundoff & such const Real ATTACK_RANGE_FUDGE = 1.05f; - return m_attackRange * bonus.getField(WeaponBonus::RANGE) * ATTACK_RANGE_FUDGE; + return m_attackRange * bonus.getField(WeaponBonus::RANGE) * ATTACK_RANGE_FUDGE; #endif } //------------------------------------------------------------------------------------------------- -Real WeaponTemplate::getMinimumAttackRange() const -{ +Real WeaponTemplate::getMinimumAttackRange() const +{ #ifdef RATIONALIZE_ATTACK_RANGE // Note - undersize by 1/4 of a pathfind cell, so that the goal is not teetering on the edge // of firing range. jba. const Real UNDERSIZE = PATHFIND_CELL_SIZE_F*0.25f; - Real r = m_minimumAttackRange - UNDERSIZE; + Real r = m_minimumAttackRange - UNDERSIZE; if (r < 0.0f) r = 0.0f; return r; #else - return m_minimumAttackRange; + return m_minimumAttackRange; #endif } @@ -493,7 +493,7 @@ Real WeaponTemplate::getUnmodifiedAttackRange() const } //------------------------------------------------------------------------------------------------- -Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const +Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const { // yes, divide, not multiply; the larger the rate-of-fire bonus, the shorter // we want the delay time to be. @@ -505,10 +505,10 @@ Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const // TODO_NGMP: Better solution, less hackyness #if defined(GENERALS_ONLINE_HIGH_FPS_SERVER) - if (delayToUse != 0 && delayToUse < (2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER)) - { - delayToUse = 2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER; - } + if (delayToUse != 0 && delayToUse < GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER) + { + delayToUse = GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER; + } // HACK // TODO_NGMP: Better solution for this, seems like an ini data bug @@ -521,48 +521,48 @@ Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const } #endif Real bonusROF = bonus.getField(WeaponBonus::RATE_OF_FIRE); - //CRCDEBUG_LOG(("WeaponTemplate::getDelayBetweenShots() - min:%d max:%d val:%d, bonusROF=%g/%8.8X", + //CRCDEBUG_LOG(("WeaponTemplate::getDelayBetweenShots() - min:%d max:%d val:%d, bonusROF=%g/%8.8X", //m_minDelayBetweenShots, m_maxDelayBetweenShots, delayToUse, bonusROF, AS_INT(bonusROF))); - return REAL_TO_INT_FLOOR(delayToUse / bonusROF); + return REAL_TO_INT_FLOOR(delayToUse / bonusROF); } //------------------------------------------------------------------------------------------------- -Int WeaponTemplate::getClipReloadTime(const WeaponBonus& bonus) const +Int WeaponTemplate::getClipReloadTime(const WeaponBonus& bonus) const { // yes, divide, not multiply; the larger the rate-of-fire bonus, the shorter // we want the reload time to be. - return REAL_TO_INT_FLOOR(m_clipReloadTime / bonus.getField(WeaponBonus::RATE_OF_FIRE)); + return REAL_TO_INT_FLOOR(m_clipReloadTime / bonus.getField(WeaponBonus::RATE_OF_FIRE)); } //------------------------------------------------------------------------------------------------- Int WeaponTemplate::getPreAttackDelay( const WeaponBonus& bonus ) const { - return m_preAttackDelay * bonus.getField( WeaponBonus::PRE_ATTACK ); + return m_preAttackDelay * bonus.getField( WeaponBonus::PRE_ATTACK ); } //------------------------------------------------------------------------------------------------- -Real WeaponTemplate::getPrimaryDamage(const WeaponBonus& bonus) const +Real WeaponTemplate::getPrimaryDamage(const WeaponBonus& bonus) const { - return m_primaryDamage * bonus.getField(WeaponBonus::DAMAGE); + return m_primaryDamage * bonus.getField(WeaponBonus::DAMAGE); } //------------------------------------------------------------------------------------------------- -Real WeaponTemplate::getPrimaryDamageRadius(const WeaponBonus& bonus) const +Real WeaponTemplate::getPrimaryDamageRadius(const WeaponBonus& bonus) const { - return m_primaryDamageRadius * bonus.getField(WeaponBonus::RADIUS); + return m_primaryDamageRadius * bonus.getField(WeaponBonus::RADIUS); } //------------------------------------------------------------------------------------------------- -Real WeaponTemplate::getSecondaryDamage(const WeaponBonus& bonus) const +Real WeaponTemplate::getSecondaryDamage(const WeaponBonus& bonus) const { - return m_secondaryDamage * bonus.getField(WeaponBonus::DAMAGE); + return m_secondaryDamage * bonus.getField(WeaponBonus::DAMAGE); } //------------------------------------------------------------------------------------------------- -Real WeaponTemplate::getSecondaryDamageRadius(const WeaponBonus& bonus) const +Real WeaponTemplate::getSecondaryDamageRadius(const WeaponBonus& bonus) const { - return m_secondaryDamageRadius * bonus.getField(WeaponBonus::RADIUS); + return m_secondaryDamageRadius * bonus.getField(WeaponBonus::RADIUS); } //------------------------------------------------------------------------------------------------- @@ -571,20 +571,20 @@ Bool WeaponTemplate::isContactWeapon() const #ifdef RATIONALIZE_ATTACK_RANGE // Note - undersize by 1/4 of a pathfind cell, so that the goal is not teetering on the edge // of firing range. jba. - const Real UNDERSIZE = PATHFIND_CELL_SIZE_F*0.25f; + const Real UNDERSIZE = PATHFIND_CELL_SIZE_F*0.25f; return (m_attackRange - UNDERSIZE) < PATHFIND_CELL_SIZE_F; #else // fudge this a little to account for pathfinding roundoff & such const Real ATTACK_RANGE_FUDGE = 1.05f; - return m_attackRange * ATTACK_RANGE_FUDGE < PATHFIND_CELL_SIZE_F; + return m_attackRange * ATTACK_RANGE_FUDGE < PATHFIND_CELL_SIZE_F; #endif } //------------------------------------------------------------------------------------------------- Real WeaponTemplate::estimateWeaponTemplateDamage( - const Object *sourceObj, - const Object *victimObj, - const Coord3D* victimPos, + const Object *sourceObj, + const Object *victimObj, + const Coord3D* victimPos, const WeaponBonus& bonus ) const { @@ -594,16 +594,16 @@ Real WeaponTemplate::estimateWeaponTemplateDamage( return 0.0f; } - const Real damageAmount = getPrimaryDamage(bonus); - if ( victimObj == NULL ) - { - return damageAmount; - } - + const Real damageAmount = getPrimaryDamage(bonus); + if ( victimObj == NULL ) + { + return damageAmount; + } + DamageType damageType = getDamageType(); DeathType deathType = getDeathType(); - if ( victimObj->isKindOf(KINDOF_SHRUBBERY) ) + if ( victimObj->isKindOf(KINDOF_SHRUBBERY) ) { if (deathType == DEATH_BURNED) { @@ -616,7 +616,7 @@ Real WeaponTemplate::estimateWeaponTemplateDamage( } } - + // hmm.. must be shooting a firebase or such, if there is noone home to take the bullet, return 0! if ( victimObj->isKindOf( KINDOF_STRUCTURE) && damageType == DAMAGE_SNIPER ) { @@ -630,7 +630,7 @@ Real WeaponTemplate::estimateWeaponTemplateDamage( - if ( damageType == DAMAGE_SURRENDER || m_allowAttackGarrisonedBldgs ) + if ( damageType == DAMAGE_SURRENDER || m_allowAttackGarrisonedBldgs ) { ContainModuleInterface* contain = victimObj->getContain(); if( contain && contain->getContainCount() > 0 && contain->isGarrisonable() && !contain->isImmuneToClearBuildingAttacks() ) @@ -640,58 +640,58 @@ Real WeaponTemplate::estimateWeaponTemplateDamage( } } - if( damageType == DAMAGE_DISARM ) + if( damageType == DAMAGE_DISARM ) { - if( victimObj->isKindOf( KINDOF_MINE ) || victimObj->isKindOf( KINDOF_BOOBY_TRAP ) || victimObj->isKindOf( KINDOF_DEMOTRAP ) ) + if( victimObj->isKindOf( KINDOF_MINE ) || victimObj->isKindOf( KINDOF_BOOBY_TRAP ) || victimObj->isKindOf( KINDOF_DEMOTRAP ) ) { - // this is just a nonzero value, to ensure we can target mines with disarm weapons, regardless... + // this is just a nonzero value, to ensure we can target mines with disarm weapons, regardless... return 1.0f; } - return 0.0f; + return 0.0f; + } + if( damageType == DAMAGE_DEPLOY && !victimObj->isAirborneTarget() ) + { + return 1.0f; } - if( damageType == DAMAGE_DEPLOY && !victimObj->isAirborneTarget() ) - { - return 1.0f; - } //@todo Kris need to examine the DAMAGE_HACK type for damage estimation purposes. //Likely this damage type will have threat implications that won't properly be dealt with until resolved. - DamageInfoInput damageInfo; - damageInfo.m_damageType = damageType; - damageInfo.m_deathType = deathType; - damageInfo.m_sourceID = sourceObj->getID(); - damageInfo.m_amount = damageAmount; - return victimObj->estimateDamage(damageInfo); + DamageInfoInput damageInfo; + damageInfo.m_damageType = damageType; + damageInfo.m_deathType = deathType; + damageInfo.m_sourceID = sourceObj->getID(); + damageInfo.m_amount = damageAmount; + return victimObj->estimateDamage(damageInfo); } //------------------------------------------------------------------------------------------------- Bool WeaponTemplate::shouldProjectileCollideWith( - const Object* projectileLauncher, - const Object* projectile, + const Object* projectileLauncher, + const Object* projectile, const Object* thingWeCollidedWith, ObjectID intendedVictimID // could be INVALID_ID for a position-shot ) const { if (!projectile || !thingWeCollidedWith) return false; - + // if it's our intended victim, we want to collide with it, regardless of any other considerations. if (intendedVictimID == thingWeCollidedWith->getID()) return true; if (projectileLauncher != NULL) { - + // Don't hit your own launcher, ever. if (projectileLauncher == thingWeCollidedWith) return false; - + // If our launcher is inside something, and that something is 'thingWeCollidedWith' we won't collide const Object *launcherContainedBy = projectileLauncher->getContainedBy(); if( launcherContainedBy == thingWeCollidedWith ) return false; - + } // never bother burning already-burned things. (srj) @@ -709,7 +709,7 @@ Bool WeaponTemplate::shouldProjectileCollideWith( if (thingWeCollidedWith->isKindOf(KINDOF_FS_AIRFIELD)) { // - // ok, so if we are an airfield, and our intended victim has a reserved space + // ok, so if we are an airfield, and our intended victim has a reserved space // with us, it "belongs" to us and collisions intended for it should not detonate // as a result of colliding with us. // @@ -752,23 +752,23 @@ Bool WeaponTemplate::shouldProjectileCollideWith( if (thingWeCollidedWith->getTemplate()->getFenceWidth() > 0) requiredMask |= WEAPON_COLLIDE_WALLS; if (thingWeCollidedWith->isKindOf(KINDOF_SMALL_MISSILE)) requiredMask |= WEAPON_COLLIDE_SMALL_MISSILES; //All missiles are also projectiles! if (thingWeCollidedWith->isKindOf(KINDOF_BALLISTIC_MISSILE)) requiredMask |= WEAPON_COLLIDE_BALLISTIC_MISSILES; //All missiles are also projectiles! - + // if any in requiredMask are present in collidemask, do the collision. (srj) if ((getProjectileCollideMask() & requiredMask) != 0) return true; - //DEBUG_LOG(("Rejecting projectile collision between %s and %s!",projectile->getTemplate()->getName().str(),thingWeCollidedWith->getTemplate()->getName().str())); + //DEBUG_LOG(("Rejecting projectile collision between %s and %s!",projectile->getTemplate()->getName().str(),thingWeCollidedWith->getTemplate()->getName().str())); return false; } //------------------------------------------------------------------------------------------------- UnsignedInt WeaponTemplate::fireWeaponTemplate ( - const Object *sourceObj, - WeaponSlotType wslot, - Int specificBarrelToUse, - Object *victimObj, - const Coord3D* victimPos, + const Object *sourceObj, + WeaponSlotType wslot, + Int specificBarrelToUse, + Object *victimObj, + const Coord3D* victimPos, const WeaponBonus& bonus, Bool isProjectileDetonation, Bool ignoreRanges, @@ -778,8 +778,8 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate ) const { - //-extraLogging - #if defined(RTS_DEBUG) + //-extraLogging + #if defined(RTS_DEBUG) AsciiString targetStr; if( TheGlobalData->m_extraLogging ) { @@ -790,23 +790,23 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate else targetStr.format( "SELF." ); - DEBUG_LOG( ("%d - WeaponTemplate::fireWeaponTemplate() begin - %s attacking %s", + DEBUG_LOG( ("%d - WeaponTemplate::fireWeaponTemplate() begin - %s attacking %s", TheGameLogic->getFrame(), sourceObj->getTemplate()->getName().str(), targetStr.str() ) ); } #endif - //end -extraLogging + //end -extraLogging - //CRCDEBUG_LOG(("WeaponTemplate::fireWeaponTemplate() from %s", DescribeObject(sourceObj).str())); - DEBUG_ASSERTCRASH(specificBarrelToUse >= 0, ("specificBarrelToUse should no longer be -1")); + //CRCDEBUG_LOG(("WeaponTemplate::fireWeaponTemplate() from %s", DescribeObject(sourceObj).str())); + DEBUG_ASSERTCRASH(specificBarrelToUse >= 0, ("specificBarrelToUse should no longer be -1")); if (sourceObj == NULL || (victimObj == NULL && victimPos == NULL)) { - //-extraLogging - #if defined(RTS_DEBUG) + //-extraLogging + #if defined(RTS_DEBUG) if( TheGlobalData->m_extraLogging ) - DEBUG_LOG( ("FAIL 1 (sourceObj %d == NULL || (victimObj %d == NULL && victimPos %d == NULL)", sourceObj != 0, victimObj != 0, victimPos != 0) ); + DEBUG_LOG( ("FAIL 1 (sourceObj %d == NULL || (victimObj %d == NULL && victimPos %d == NULL)", sourceObj != 0, victimObj != 0, victimPos != 0) ); #endif - //end -extraLogging + //end -extraLogging return 0; } @@ -822,7 +822,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate Coord3D victimPosStorage; if (victimObj) { - DEBUG_ASSERTLOG(sourceObj != victimObj, ("*** firing weapon at self -- is this really what you want?")); + DEBUG_ASSERTLOG(sourceObj != victimObj, ("*** firing weapon at self -- is this really what you want?")); victimPos = victimObj->getPosition(); victimID = victimObj->getID(); @@ -843,21 +843,21 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate } else { - if (victimObj->isKindOf(KINDOF_BRIDGE)) + if (victimObj->isKindOf(KINDOF_BRIDGE)) { // Bridges are kind of oddball - they have 2 target points at either end. TheTerrainLogic->getBridgeAttackPoints(victimObj, &info); distSqr = ThePartitionManager->getDistanceSquared( sourceObj, &info.attackPoint1, ATTACK_RANGE_CALC_TYPE ); victimPos = &info.attackPoint1; Real distSqr2 = ThePartitionManager->getDistanceSquared( sourceObj, &info.attackPoint2, ATTACK_RANGE_CALC_TYPE ); - if (distSqr > distSqr2) + if (distSqr > distSqr2) { // Try the other one. distSqr = distSqr2; victimPos = &info.attackPoint2; } - } - else + } + else { distSqr = ThePartitionManager->getDistanceSquared(sourceObj, victimObj, ATTACK_RANGE_CALC_TYPE); } @@ -869,7 +869,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate distSqr = ThePartitionManager->getDistanceSquared(sourceObj, victimPos, ATTACK_RANGE_CALC_TYPE); } -// DEBUG_LOG(("WeaponTemplate::fireWeaponTemplate: firing weapon %s (source=%s, victim=%s)", +// DEBUG_LOG(("WeaponTemplate::fireWeaponTemplate: firing weapon %s (source=%s, victim=%s)", // m_name.str(),sourceObj->getTemplate()->getName().str(),victimObj?victimObj->getTemplate()->getName().str():"NULL")); //Only perform this check if the weapon isn't a leech range weapon (which can have unlimited range!) @@ -878,14 +878,14 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate Real attackRangeSqr = sqr(getAttackRange(bonus)); if (distSqr > attackRangeSqr) { - //DEBUG_ASSERTCRASH(distSqr < 5*5 || distSqr < attackRangeSqr*1.2f, ("*** victim is out of range (%f vs %f) of this weapon -- why did we attempt to fire?",sqrtf(distSqr),sqrtf(attackRangeSqr))); - - //-extraLogging - #if defined(RTS_DEBUG) + //DEBUG_ASSERTCRASH(distSqr < 5*5 || distSqr < attackRangeSqr*1.2f, ("*** victim is out of range (%f vs %f) of this weapon -- why did we attempt to fire?",sqrtf(distSqr),sqrtf(attackRangeSqr))); + + //-extraLogging + #if defined(RTS_DEBUG) if( TheGlobalData->m_extraLogging ) - DEBUG_LOG( ("FAIL 2 (distSqr %.2f > attackRangeSqr %.2f)", distSqr, attackRangeSqr ) ); + DEBUG_LOG( ("FAIL 2 (distSqr %.2f > attackRangeSqr %.2f)", distSqr, attackRangeSqr ) ); #endif - //end -extraLogging + //end -extraLogging return 0; } @@ -900,14 +900,14 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate if (distSqr < minAttackRangeSqr-0.5f && !isProjectileDetonation) #endif { - DEBUG_ASSERTCRASH(distSqr > minAttackRangeSqr*0.8f, ("*** victim is closer than min attack range (%f vs %f) of this weapon -- why did we attempt to fire?",sqrtf(distSqr),sqrtf(minAttackRangeSqr))); + DEBUG_ASSERTCRASH(distSqr > minAttackRangeSqr*0.8f, ("*** victim is closer than min attack range (%f vs %f) of this weapon -- why did we attempt to fire?",sqrtf(distSqr),sqrtf(minAttackRangeSqr))); - //-extraLogging - #if defined(RTS_DEBUG) + //-extraLogging + #if defined(RTS_DEBUG) if( TheGlobalData->m_extraLogging ) - DEBUG_LOG( ("FAIL 3 (distSqr %.2f< minAttackRangeSqr %.2f - 0.5f && !isProjectileDetonation %d)", distSqr, minAttackRangeSqr, isProjectileDetonation ) ); + DEBUG_LOG( ("FAIL 3 (distSqr %.2f< minAttackRangeSqr %.2f - 0.5f && !isProjectileDetonation %d)", distSqr, minAttackRangeSqr, isProjectileDetonation ) ); #endif - //end -extraLogging + //end -extraLogging return 0; } @@ -929,15 +929,15 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate Real reDir = reAngle != 0.0f ? (atan2(victimPos->y - sourcePos->y, victimPos->x - sourcePos->x)) : 0.0f; VeterancyLevel v = sourceObj->getVeterancyLevel(); const FXList* fx = isProjectileDetonation ? getProjectileDetonateFX(v) : getFireFX(v); - + if ( TheGameLogic->getFrame() < firingWeapon->getSuspendFXFrame() ) fx = NULL; Bool handled; - - // TheSuperHackers @todo: Remove hardcoded KINDOF_MINE check and apply PlayFXWhenStealthed = Yes to the mine weapons instead. - - if (!sourceObj->isLogicallyVisible() // if user watching cannot see us + + // TheSuperHackers @todo: Remove hardcoded KINDOF_MINE check and apply PlayFXWhenStealthed = Yes to the mine weapons instead. + + if (!sourceObj->isLogicallyVisible() // if user watching cannot see us && !sourceObj->isKindOf(KINDOF_MINE) // and not a mine (which always do the FX, even if hidden)... && !isPlayFXWhenStealthed() // and not a weapon marked to playwhenstealthed ) @@ -946,12 +946,12 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate } else { - handled = sourceObj->getDrawable()->handleWeaponFireFX(wslot, - specificBarrelToUse, - fx, - getWeaponSpeed(), - reAngle, - reDir, + handled = sourceObj->getDrawable()->handleWeaponFireFX(wslot, + specificBarrelToUse, + fx, + getWeaponSpeed(), + reAngle, + reDir, &targetPos, getPrimaryDamageRadius(bonus) ); @@ -960,7 +960,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate if (handled == false && fx != NULL) { // bah. just play it at the drawable's pos. - //DEBUG_LOG(("*** WeaponFireFX not fully handled by the client")); + //DEBUG_LOG(("*** WeaponFireFX not fully handled by the client")); const Coord3D* where = isContactWeapon() ? &targetPos : sourceObj->getDrawable()->getPosition(); FXList::doFXPos(fx, where, sourceObj->getDrawable()->getTransformMatrix(), getWeaponSpeed(), &targetPos, getPrimaryDamageRadius(bonus)); } @@ -1062,18 +1062,18 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate if (delayInFrames < 1.0f) { // go ahead and do it now - //DEBUG_LOG(("WeaponTemplate::fireWeaponTemplate: firing weapon immediately!")); + //DEBUG_LOG(("WeaponTemplate::fireWeaponTemplate: firing weapon immediately!")); if( inflictDamage ) { dealDamageInternal(sourceID, damageID, damagePos, bonus, isProjectileDetonation); } - //-extraLogging - #if defined(RTS_DEBUG) + //-extraLogging + #if defined(RTS_DEBUG) if( TheGlobalData->m_extraLogging ) - DEBUG_LOG( ("EARLY 4 (delayed damage applied now)") ); + DEBUG_LOG( ("EARLY 4 (delayed damage applied now)") ); #endif - //end -extraLogging + //end -extraLogging return TheGameLogic->getFrame(); @@ -1085,16 +1085,16 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate { UnsignedInt delayInWholeFrames = REAL_TO_INT_CEIL(delayInFrames); when = TheGameLogic->getFrame() + delayInWholeFrames; - //DEBUG_LOG(("WeaponTemplate::fireWeaponTemplate: firing weapon in %d frames (= %d)!", delayInWholeFrames,when)); + //DEBUG_LOG(("WeaponTemplate::fireWeaponTemplate: firing weapon in %d frames (= %d)!", delayInWholeFrames,when)); TheWeaponStore->setDelayedDamage(this, damagePos, when, sourceID, damageID, bonus); } - //-extraLogging - #if defined(RTS_DEBUG) + //-extraLogging + #if defined(RTS_DEBUG) if( TheGlobalData->m_extraLogging ) - DEBUG_LOG( ("EARLY 5 (delaying damage applied until frame %d)", when ) ); + DEBUG_LOG( ("EARLY 5 (delaying damage applied until frame %d)", when ) ); #endif - //end -extraLogging + //end -extraLogging return when; @@ -1105,7 +1105,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate Player *owningPlayer = sourceObj->getControllingPlayer(); //Need to know so missiles don't collide with firer Object *projectile = TheThingFactory->newObject( getProjectileTemplate(), owningPlayer->getDefaultTeam() ); projectile->setProducer(sourceObj); - + //If the player has battle plans (America Strategy Center), then apply those bonuses //to this object if applicable. Internally it validates certain kinds of objects. //When projectiles are created, weapon bonuses such as damage may get applied. @@ -1139,7 +1139,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate } } - firingWeapon->newProjectileFired( sourceObj, projectile, victimObj, victimPos );//The actual logic weapon needs to know this was created. + firingWeapon->newProjectileFired( sourceObj, projectile, victimObj, victimPos );//The actual logic weapon needs to know this was created. ProjectileUpdateInterface* pui = NULL; for (BehaviorModule** u = projectile->getBehaviorModules(); *u; ++u) @@ -1162,7 +1162,7 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate } else { - //DEBUG_CRASH(("Projectiles should implement ProjectileUpdateInterface!")); + //DEBUG_CRASH(("Projectiles should implement ProjectileUpdateInterface!")); // actually, this is ok, for things like Firestorm.... (srj) projectile->setPosition(&projectileDestination); } @@ -1178,25 +1178,25 @@ UnsignedInt WeaponTemplate::fireWeaponTemplate //an available decoy flare. victimObj->reportMissileForCountermeasures( projectile ); } - + } - //-extraLogging - #if defined(RTS_DEBUG) + //-extraLogging + #if defined(RTS_DEBUG) if( TheGlobalData->m_extraLogging ) - DEBUG_LOG( ("DONE") ); + DEBUG_LOG( ("DONE") ); #endif - //end -extraLogging + //end -extraLogging return 0; } } //------------------------------------------------------------------------------------------------- -#if RETAIL_COMPATIBLE_CRC +#if RETAIL_COMPATIBLE_CRC void WeaponTemplate::trimOldHistoricDamage() const { UnsignedInt expirationDate = TheGameLogic->getFrame() - TheGlobalData->m_historicDamageLimit; - while (!m_historicDamage.empty()) + while (!m_historicDamage.empty()) { HistoricWeaponDamageInfo& h = m_historicDamage.front(); if (h.frame <= expirationDate) @@ -1212,42 +1212,42 @@ void WeaponTemplate::trimOldHistoricDamage() const } } } -#else -void WeaponTemplate::trimOldHistoricDamage() const -{ - if (m_historicDamage.empty()) - return; - - const UnsignedInt currentFrame = TheGameLogic->getFrame(); - const UnsignedInt expirationFrame = currentFrame - m_historicBonusTime; - - HistoricWeaponDamageList::iterator it = m_historicDamage.begin(); - - while (it != m_historicDamage.end()) - { - if (it->frame <= expirationFrame) - it = m_historicDamage.erase(it); - else - break; - } -} -#endif - -//------------------------------------------------------------------------------------------------- -void WeaponTemplate::trimTriggeredHistoricDamage() const -{ - HistoricWeaponDamageList::iterator it = m_historicDamage.begin(); - - while (it != m_historicDamage.end()) - { - if (it->triggerId == m_historicDamageTriggerId) - it = m_historicDamage.erase(it); - else - ++it; - } -} - -//------------------------------------------------------------------------------------------------- +#else +void WeaponTemplate::trimOldHistoricDamage() const +{ + if (m_historicDamage.empty()) + return; + + const UnsignedInt currentFrame = TheGameLogic->getFrame(); + const UnsignedInt expirationFrame = currentFrame - m_historicBonusTime; + + HistoricWeaponDamageList::iterator it = m_historicDamage.begin(); + + while (it != m_historicDamage.end()) + { + if (it->frame <= expirationFrame) + it = m_historicDamage.erase(it); + else + break; + } +} +#endif + +//------------------------------------------------------------------------------------------------- +void WeaponTemplate::trimTriggeredHistoricDamage() const +{ + HistoricWeaponDamageList::iterator it = m_historicDamage.begin(); + + while (it != m_historicDamage.end()) + { + if (it->triggerId == m_historicDamageTriggerId) + it = m_historicDamage.erase(it); + else + ++it; + } +} + +//------------------------------------------------------------------------------------------------- static Bool is2DDistSquaredLessThan(const Coord3D& a, const Coord3D& b, Real distSqr) { Real da = sqr(a.x - b.x) + sqr(a.y - b.y); @@ -1255,8 +1255,8 @@ static Bool is2DDistSquaredLessThan(const Coord3D& a, const Coord3D& b, Real dis } //------------------------------------------------------------------------------------------------- -#if RETAIL_COMPATIBLE_CRC -void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* pos) const +#if RETAIL_COMPATIBLE_CRC +void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* pos) const { // /** @todo We need to rewrite the historic stuff ... if you fire 5 missiles, and the 5th, @@ -1267,15 +1267,15 @@ void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* if( m_historicBonusCount > 0 && m_historicBonusWeapon != this ) { - trimOldHistoricDamage(); - + trimOldHistoricDamage(); + Real radSqr = m_historicBonusRadius * m_historicBonusRadius; Int count = 0; UnsignedInt frameNow = TheGameLogic->getFrame(); UnsignedInt oldestThatWillCount = frameNow - m_historicBonusTime; // Anything before this frame is "more than two seconds ago" eg for( HistoricWeaponDamageList::const_iterator it = m_historicDamage.begin(); it != m_historicDamage.end(); ++it ) { - if( it->frame >= oldestThatWillCount && + if( it->frame >= oldestThatWillCount && is2DDistSquaredLessThan( *pos, it->location, radSqr ) ) { // This one is close enough in time and distance, so count it. This is tracked by template since it applies @@ -1283,7 +1283,7 @@ void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* ++count; } } - + if( count >= m_historicBonusCount - 1 ) // minus 1 since we include ourselves implicitly { TheWeaponStore->createAndFireTempWeapon(m_historicBonusWeapon, source, pos); @@ -1296,67 +1296,67 @@ void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* } else { - + // add AFTER checking for historic stuff m_historicDamage.push_back( HistoricWeaponDamageInfo(frameNow, *pos) ); - } - - } -} -#else -void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* pos) const -{ - if (m_historicBonusCount > 0 && m_historicBonusWeapon != this) - { - trimOldHistoricDamage(); - - ++m_historicDamageTriggerId; - - const Int requiredCount = m_historicBonusCount - 1; // minus 1 since we include ourselves implicitly - if (m_historicDamage.size() >= requiredCount) - { - const Real radSqr = m_historicBonusRadius * m_historicBonusRadius; - Int count = 0; - - for (HistoricWeaponDamageList::iterator it = m_historicDamage.begin(); it != m_historicDamage.end(); ++it) - { - if (is2DDistSquaredLessThan(*pos, it->location, radSqr)) - { - // This one is close enough in time and distance, so count it. This is tracked by template since it applies - // across units, so don't try to clear historicDamage on success in here. - it->triggerId = m_historicDamageTriggerId; - - if (++count == requiredCount) - { - TheWeaponStore->createAndFireTempWeapon(m_historicBonusWeapon, source, pos); - trimTriggeredHistoricDamage(); - return; - } - } - } - } - - // add AFTER checking for historic stuff - m_historicDamage.push_back(HistoricWeaponDamageInfo(TheGameLogic->getFrame(), *pos)); - } -} -#endif - -//------------------------------------------------------------------------------------------------- -void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, const Coord3D *pos, const WeaponBonus& bonus, Bool isProjectileDetonation) const -{ - if (sourceID == 0) // must have a source - return; - - if (victimID == 0 && pos == NULL) // must have some sort of destination - return; - - Object *source = TheGameLogic->findObjectByID(sourceID); // might be null... - - processHistoricDamage(source, pos); - -//DEBUG_LOG(("WeaponTemplate::dealDamageInternal: dealing damage %s at frame %d",m_name.str(),TheGameLogic->getFrame())); + } + + } +} +#else +void WeaponTemplate::processHistoricDamage(const Object* source, const Coord3D* pos) const +{ + if (m_historicBonusCount > 0 && m_historicBonusWeapon != this) + { + trimOldHistoricDamage(); + + ++m_historicDamageTriggerId; + + const Int requiredCount = m_historicBonusCount - 1; // minus 1 since we include ourselves implicitly + if (m_historicDamage.size() >= requiredCount) + { + const Real radSqr = m_historicBonusRadius * m_historicBonusRadius; + Int count = 0; + + for (HistoricWeaponDamageList::iterator it = m_historicDamage.begin(); it != m_historicDamage.end(); ++it) + { + if (is2DDistSquaredLessThan(*pos, it->location, radSqr)) + { + // This one is close enough in time and distance, so count it. This is tracked by template since it applies + // across units, so don't try to clear historicDamage on success in here. + it->triggerId = m_historicDamageTriggerId; + + if (++count == requiredCount) + { + TheWeaponStore->createAndFireTempWeapon(m_historicBonusWeapon, source, pos); + trimTriggeredHistoricDamage(); + return; + } + } + } + } + + // add AFTER checking for historic stuff + m_historicDamage.push_back(HistoricWeaponDamageInfo(TheGameLogic->getFrame(), *pos)); + } +} +#endif + +//------------------------------------------------------------------------------------------------- +void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, const Coord3D *pos, const WeaponBonus& bonus, Bool isProjectileDetonation) const +{ + if (sourceID == 0) // must have a source + return; + + if (victimID == 0 && pos == NULL) // must have some sort of destination + return; + + Object *source = TheGameLogic->findObjectByID(sourceID); // might be null... + + processHistoricDamage(source, pos); + +//DEBUG_LOG(("WeaponTemplate::dealDamageInternal: dealing damage %s at frame %d",m_name.str(),TheGameLogic->getFrame())); // if there's a specific victim, use it's pos (overriding the value passed in) Object *primaryVictim = victimID ? TheGameLogic->findObjectByID(victimID) : NULL; // might be null... @@ -1380,7 +1380,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co Real secondaryDamage = getSecondaryDamage(bonus); Int affects = getAffectsMask(); - DEBUG_ASSERTCRASH(secondaryRadius >= primaryRadius || secondaryRadius == 0.0f, ("secondary radius should be >= primary radius (or zero)")); + DEBUG_ASSERTCRASH(secondaryRadius >= primaryRadius || secondaryRadius == 0.0f, ("secondary radius should be >= primary radius (or zero)")); Real primaryRadiusSqr = sqr(primaryRadius); Real radius = max(primaryRadius, secondaryRadius); @@ -1388,7 +1388,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co { iter = ThePartitionManager->iterateObjectsInRange(pos, radius, DAMAGE_RANGE_CALC_TYPE); curVictim = iter->firstWithNumeric(&curVictimDistSqr); - } + } else { //DEBUG_ASSERTCRASH(primaryVictim != NULL, ("weapons without radii should always pass in specific victims")); @@ -1430,7 +1430,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co } else { - + // should object ever be allowed to damage themselves? methinks not... // exception: a few weapons allow this (eg, for suicide bombers). if( (affects & WEAPON_AFFECTS_SELF) == 0 ) @@ -1438,7 +1438,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co // Remember that source is a missile for some units, and they don't want to injure them'selves' either if( source == curVictim || source->getProducerID() == curVictim->getID() ) { - //DEBUG_LOG(("skipping damage done to SELF...")); + //DEBUG_LOG(("skipping damage done to SELF...")); continue; } } @@ -1461,13 +1461,13 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co /* The idea here is: if its our ally(/enemies), AND it's not the direct target, AND the weapon doesn't - do radius-damage to allies(/enemies)... skip it. + do radius-damage to allies(/enemies)... skip it. */ Relationship r = curVictim->getRelationship(source); Int requiredMask; - if (r == ALLIES) + if (r == ALLIES) requiredMask = WEAPON_AFFECTS_ALLIES; - else if (r == ENEMIES) + else if (r == ENEMIES) requiredMask = WEAPON_AFFECTS_ENEMIES; else /* r == NEUTRAL */ requiredMask = WEAPON_AFFECTS_NEUTRALS; @@ -1487,7 +1487,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co damageInfo.in.m_sourceID = sourceID; damageInfo.in.m_sourcePlayerMask = 0; damageInfo.in.m_damageStatusType = damageStatusType; - + Coord3D damageDirection; damageDirection.zero(); if( curVictim && source ) @@ -1501,7 +1501,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co { if( curVictim == NULL || source == NULL ) continue; // We are directional damage, but can't figure out our direction. Just bail. - + // People can only be hit in a cone oriented as the firer is oriented Vector3 sourceVector = source->getTransformMatrix()->Get_X_Vector(); Vector3 damageVector(damageDirection.x, damageDirection.y, damageDirection.z); @@ -1523,8 +1523,8 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co Coord3D shockWaveVector = damageDirection; // Guard against zero vector. Make vector stright up if that is the case - if (fabs(shockWaveVector.x) < WWMATH_EPSILON && - fabs(shockWaveVector.y) < WWMATH_EPSILON && + if (fabs(shockWaveVector.x) < WWMATH_EPSILON && + fabs(shockWaveVector.y) < WWMATH_EPSILON && fabs(shockWaveVector.z) < WWMATH_EPSILON) { shockWaveVector.z = 1.0f; @@ -1539,7 +1539,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co if (source && source->getControllingPlayer()) { damageInfo.in.m_sourcePlayerMask = source->getControllingPlayer()->getPlayerMask(); } - // note, don't bother with damage multipliers here... + // note, don't bother with damage multipliers here... // that's handled internally by the attemptDamage() method. damageInfo.in.m_amount = (curVictimDistSqr <= primaryRadiusSqr) ? primaryDamage : secondaryDamage; @@ -1574,14 +1574,14 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co } curVictim->attemptDamage(&damageInfo); - //DEBUG_ASSERTLOG(damageInfo.out.m_noEffect, ("WeaponTemplate::dealDamageInternal: dealt to %s %08lx: attempted %f, actual %f (%f)", + //DEBUG_ASSERTLOG(damageInfo.out.m_noEffect, ("WeaponTemplate::dealDamageInternal: dealt to %s %08lx: attempted %f, actual %f (%f)", // curVictim->getTemplate()->getName().str(),curVictim, // damageInfo.in.m_amount, damageInfo.out.m_actualDamageDealt, damageInfo.out.m_actualDamageClipped)); } } else { - DEBUG_CRASH(("projectile weapons should never get dealDamage called directly")); + DEBUG_CRASH(("projectile weapons should never get dealDamage called directly")); } } @@ -1590,7 +1590,7 @@ void WeaponTemplate::dealDamageInternal(ObjectID sourceID, ObjectID victimID, co //------------------------------------------------------------------------------------------------- WeaponStore::WeaponStore() { -} +} //------------------------------------------------------------------------------------------------- WeaponStore::~WeaponStore() @@ -1629,7 +1629,7 @@ void WeaponStore::createAndFireTempWeapon(const WeaponTemplate* wt, const Object //------------------------------------------------------------------------------------------------- void WeaponStore::createAndFireTempWeapon(const WeaponTemplate* wt, const Object *source, Object *target) { - //CRCDEBUG_LOG(("WeaponStore::createAndFireTempWeapon() for %s", DescribeObject(source))); + //CRCDEBUG_LOG(("WeaponStore::createAndFireTempWeapon() for %s", DescribeObject(source))); if (wt == NULL) return; Weapon* w = TheWeaponStore->allocateNewWeapon(wt, PRIMARY_WEAPON); @@ -1639,26 +1639,26 @@ void WeaponStore::createAndFireTempWeapon(const WeaponTemplate* wt, const Object } //------------------------------------------------------------------------------------------------- -const WeaponTemplate *WeaponStore::findWeaponTemplate( const AsciiString& name ) const -{ - if (name.compareNoCase("None") == 0) +const WeaponTemplate *WeaponStore::findWeaponTemplate( const AsciiString& name ) const +{ + if (name.compareNoCase("None") == 0) + return NULL; + const WeaponTemplate * wt = findWeaponTemplatePrivate( TheNameKeyGenerator->nameToKey( name ) ); + DEBUG_ASSERTCRASH(wt != NULL, ("Weapon %s not found!",name)); + return wt; +} + +//------------------------------------------------------------------------------------------------- +const WeaponTemplate *WeaponStore::findWeaponTemplate( const char* name ) const +{ + if (stricmp(name, "None") == 0) return NULL; const WeaponTemplate * wt = findWeaponTemplatePrivate( TheNameKeyGenerator->nameToKey( name ) ); - DEBUG_ASSERTCRASH(wt != NULL, ("Weapon %s not found!",name)); + DEBUG_ASSERTCRASH(wt != NULL, ("Weapon %s not found!",name)); return wt; } //------------------------------------------------------------------------------------------------- -const WeaponTemplate *WeaponStore::findWeaponTemplate( const char* name ) const -{ - if (stricmp(name, "None") == 0) - return NULL; - const WeaponTemplate * wt = findWeaponTemplatePrivate( TheNameKeyGenerator->nameToKey( name ) ); - DEBUG_ASSERTCRASH(wt != NULL, ("Weapon %s not found!",name)); - return wt; -} - -//------------------------------------------------------------------------------------------------- WeaponTemplate *WeaponStore::findWeaponTemplatePrivate( NameKeyType key ) const { // search weapon list for name @@ -1685,21 +1685,21 @@ WeaponTemplate *WeaponStore::newWeaponTemplate(AsciiString name) m_weaponTemplateVector.push_back(wt); return wt; -} +} //------------------------------------------------------------------------------------------------- WeaponTemplate *WeaponStore::newOverride(WeaponTemplate *weaponTemplate) { if (!weaponTemplate) return NULL; - + // allocate a new weapon WeaponTemplate *wt = newInstance(WeaponTemplate); (*wt) = (*weaponTemplate); (wt)->friend_setNextTemplate(weaponTemplate); - + return wt; -} +} //------------------------------------------------------------------------------------------------- void WeaponStore::update() @@ -1746,7 +1746,7 @@ void WeaponStore::reset() for (size_t i = 0; i < m_weaponTemplateVector.size(); ++i) { WeaponTemplate *wt = m_weaponTemplateVector[i]; - if (wt->isOverride()) + if (wt->isOverride()) { WeaponTemplate *override = wt; wt = wt->friend_clearNextTemplate(); @@ -1787,7 +1787,7 @@ void WeaponStore::postProcessLoad() wt->postProcessLoad(); } -} +} //------------------------------------------------------------------------------------------------- /*static*/ void WeaponStore::parseWeaponTemplateDefinition(INI* ini) @@ -1796,7 +1796,7 @@ void WeaponStore::postProcessLoad() // read the weapon name const char* c = ini->getNextToken(); - name.set(c); + name.set(c); // find existing item if present WeaponTemplate *weapon = TheWeaponStore->findWeaponTemplatePrivate( TheNameKeyGenerator->nameToKey( name ) ); @@ -1804,7 +1804,7 @@ void WeaponStore::postProcessLoad() { if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES) weapon = TheWeaponStore->newOverride(weapon); - else + else { DEBUG_CRASH(("Weapon '%s' already exists, but OVERRIDE not specified", c)); return; @@ -1815,7 +1815,7 @@ void WeaponStore::postProcessLoad() { // no item is present, create a new one weapon = TheWeaponStore->newWeaponTemplate(name); - } + } // parse the ini weapon definition ini->initFromINI(weapon, weapon->getFieldParse()); @@ -1823,10 +1823,10 @@ void WeaponStore::postProcessLoad() if (weapon->m_projectileName.isNone()) weapon->m_projectileName.clear(); -#if defined(RTS_DEBUG) - if (!weapon->getFireSound().getEventName().isEmpty() && weapon->getFireSound().getEventName().compareNoCase("NoSound") != 0) - { - DEBUG_ASSERTCRASH(TheAudio->isValidAudioEvent(&weapon->getFireSound()), ("Invalid FireSound %s in Weapon '%s'.", weapon->getFireSound().getEventName().str(), weapon->getName().str())); +#if defined(RTS_DEBUG) + if (!weapon->getFireSound().getEventName().isEmpty() && weapon->getFireSound().getEventName().compareNoCase("NoSound") != 0) + { + DEBUG_ASSERTCRASH(TheAudio->isValidAudioEvent(&weapon->getFireSound()), ("Invalid FireSound %s in Weapon '%s'.", weapon->getFireSound().getEventName().str(), weapon->getName().str())); } #endif @@ -1914,9 +1914,9 @@ void Weapon::computeBonus(const Object *source, WeaponBonusConditionFlags extraB { bonus.clear(); WeaponBonusConditionFlags flags = source->getWeaponBonusCondition(); - //CRCDEBUG_LOG(("Weapon::computeBonus() - flags are %X for %s", flags, DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::computeBonus() - flags are %X for %s", flags, DescribeObject(source).str())); flags |= extraBonusFlags; - + if( source->getContainedBy() ) { // We may be able to add in our container's flags @@ -1968,10 +1968,10 @@ void Weapon::setClipPercentFull(Real percent, Bool allowReduction) { m_ammoInClip = ammo; m_status = m_ammoInClip ? OUT_OF_AMMO : READY_TO_FIRE; - //CRCDEBUG_LOG(("Weapon::setClipPercentFull() just set m_status to %d (ammo in clip is %d)", m_status, m_ammoInClip)); + //CRCDEBUG_LOG(("Weapon::setClipPercentFull() just set m_status to %d (ammo in clip is %d)", m_status, m_ammoInClip)); m_whenLastReloadStarted = TheGameLogic->getFrame(); - m_whenWeCanFireAgain = m_whenLastReloadStarted; - //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::setClipPercentFull", m_whenWeCanFireAgain)); + m_whenWeCanFireAgain = m_whenLastReloadStarted; + //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::setClipPercentFull", m_whenWeCanFireAgain)); rebuildScatterTargets(); } } @@ -1992,7 +1992,7 @@ void Weapon::rebuildScatterTargets() //------------------------------------------------------------------------------------------------- void Weapon::reloadWithBonus(const Object *sourceObj, const WeaponBonus& bonus, Bool loadInstantly) { - if (m_template->getClipSize() > 0 + if (m_template->getClipSize() > 0 && m_ammoInClip == m_template->getClipSize() && !sourceObj->isReloadTimeShared()) return; // don't restart our reload delay. @@ -2004,22 +2004,22 @@ void Weapon::reloadWithBonus(const Object *sourceObj, const WeaponBonus& bonus, m_status = RELOADING_CLIP; Real reloadTime = loadInstantly ? 0 : m_template->getClipReloadTime(bonus); m_whenLastReloadStarted = TheGameLogic->getFrame(); - m_whenWeCanFireAgain = m_whenLastReloadStarted + reloadTime; - //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::reloadWithBonus 1", m_whenWeCanFireAgain)); + m_whenWeCanFireAgain = m_whenLastReloadStarted + reloadTime; + //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::reloadWithBonus 1", m_whenWeCanFireAgain)); // if we are sharing reload times // go through other weapons in weapon set - // set their m_whenWeCanFireAgain to this guy's delay + // set their m_whenWeCanFireAgain to this guy's delay // set their m_status to this guy's status if (sourceObj->isReloadTimeShared()) - { + { for (Int wt = 0; wtgetWeaponInWeaponSlot((WeaponSlotType)wt); if (weapon) { weapon->setPossibleNextShotFrame(m_whenWeCanFireAgain); - //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::reloadWithBonus 2", m_whenWeCanFireAgain)); + //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::reloadWithBonus 2", m_whenWeCanFireAgain)); weapon->setStatus(RELOADING_CLIP); } } @@ -2033,7 +2033,7 @@ static void clipToTerrainExtent(Coord3D& approachTargetPos) { Region3D bounds; TheTerrainLogic->getExtent(&bounds); - if (approachTargetPos.x < bounds.lo.x+PATHFIND_CELL_SIZE_F) { + if (approachTargetPos.x < bounds.lo.x+PATHFIND_CELL_SIZE_F) { approachTargetPos.x = bounds.lo.x+PATHFIND_CELL_SIZE_F; } if (approachTargetPos.y < bounds.lo.y+PATHFIND_CELL_SIZE_F) { @@ -2072,10 +2072,10 @@ void Weapon::onWeaponBonusChange(const Object *source) if( needUpdate ) { m_whenLastReloadStarted = TheGameLogic->getFrame(); - m_whenWeCanFireAgain = m_whenLastReloadStarted + newDelay; - + m_whenWeCanFireAgain = m_whenLastReloadStarted + newDelay; + if (source->isReloadTimeShared()) - { + { for (Int wt = 0; wtgetWeaponInWeaponSlot((WeaponSlotType)wt); @@ -2095,12 +2095,12 @@ Bool Weapon::computeApproachTarget(const Object *source, const Object *target, c // compute unit direction vector from us to our victim const Coord3D *targetPos; Coord3D dir; - if (target) + if (target) { targetPos = target->getPosition(); ThePartitionManager->getVectorTo( target, source, ATTACK_RANGE_CALC_TYPE, dir ); - } - else if (pos) + } + else if (pos) { targetPos = pos; ThePartitionManager->getVectorTo( source, pos, ATTACK_RANGE_CALC_TYPE, dir ); @@ -2118,10 +2118,10 @@ Bool Weapon::computeApproachTarget(const Object *source, const Object *target, c Real dist = dir.length(); Real minAttackRange = m_template->getMinimumAttackRange(); - if (minAttackRange > PATHFIND_CELL_SIZE_F && dist < minAttackRange) + if (minAttackRange > PATHFIND_CELL_SIZE_F && dist < minAttackRange) { // We aret too close, so move away from the target. - DEBUG_ASSERTCRASH((minAttackRange<0.9f*getAttackRange(source)), ("Min attack range is too near attack range.")); + DEBUG_ASSERTCRASH((minAttackRange<0.9f*getAttackRange(source)), ("Min attack range is too near attack range.")); // Recompute dir, cause if the bounding spheres touch, it will be 0. Coord3D srcPos = *source->getPosition(); dir.x = srcPos.x-targetPos->x; @@ -2158,11 +2158,11 @@ Bool Weapon::computeApproachTarget(const Object *source, const Object *target, c // select a spot along the line between us, halfway between the min & max range. Real attackRange = (getAttackRange(source) + minAttackRange)/2.0f; #ifdef ATTACK_RANGE_IS_2D - if (target) + if (target) attackRange += target->getGeometryInfo().getBoundingCircleRadius(); attackRange += source->getGeometryInfo().getBoundingCircleRadius(); #else - if (target) + if (target) attackRange += target->getGeometryInfo().getBoundingSphereRadius(); attackRange += source->getGeometryInfo().getBoundingSphereRadius(); #endif @@ -2177,13 +2177,13 @@ Bool Weapon::computeApproachTarget(const Object *source, const Object *target, c const Real FUDGE = 0.001f; if (dist < FUDGE) { - // we're close enough! + // we're close enough! approachTargetPos = *source->getPosition(); return true; } else { - if (isContactWeapon()) + if (isContactWeapon()) { // Weapon is basically a contact weapon, like a car bomb. The approach target logic // has been modified to let it approach the object, so just return the target position. jba. @@ -2220,12 +2220,12 @@ Bool Weapon::computeApproachTarget(const Object *source, const Object *target, c //------------------------------------------------------------------------------------------------- //Special case attack range calculate that fakes moving the object (to a garrisoned point) without -//actually moving the object. This is used to help determine if a garrisoned unit not yet +//actually moving the object. This is used to help determine if a garrisoned unit not yet //positioned can attack someone. //------------------------------------------------------------------------------------------------- Bool Weapon::isSourceObjectWithGoalPositionWithinAttackRange( const Object *source, const Coord3D *goalPos, const Object *target, const Coord3D *targetPos ) const { - + Real distSqr; if( target ) distSqr = ThePartitionManager->getGoalDistanceSquared( source, goalPos, target, ATTACK_RANGE_CALC_TYPE ); @@ -2273,20 +2273,20 @@ Bool Weapon::isWithinAttackRange(const Object *source, const Object *target) con if( !target->isKindOf(KINDOF_BRIDGE) ) { distSqr = ThePartitionManager->getDistanceSquared( source, target, ATTACK_RANGE_CALC_TYPE ); - } - else + } + else { // Special case - bridges have two attackable points at either end. TBridgeAttackInfo info; TheTerrainLogic->getBridgeAttackPoints(target, &info); distSqr = ThePartitionManager->getDistanceSquared( source, &info.attackPoint1, ATTACK_RANGE_CALC_TYPE ); - if (distSqr>attackRangeSqr) + if (distSqr>attackRangeSqr) { // Try the other one. distSqr = ThePartitionManager->getDistanceSquared( source, &info.attackPoint2, ATTACK_RANGE_CALC_TYPE ); } } - + Real minAttackRangeSqr = sqr(m_template->getMinimumAttackRange()); #ifdef RATIONALIZE_ATTACK_RANGE if (distSqr < minAttackRangeSqr) @@ -2315,12 +2315,12 @@ Bool Weapon::isWithinAttackRange(const Object *source, const Object *target) con { return true; } - } + } return false; } return true; } - return false; + return false; } //------------------------------------------------------------------------------------------------- @@ -2335,7 +2335,7 @@ Bool Weapon::isTooClose(const Object *source, const Object *target) const { return true; } - return false; + return false; } //------------------------------------------------------------------------------------------------- @@ -2350,7 +2350,7 @@ Bool Weapon::isTooClose( const Object *source, const Coord3D *pos ) const { return true; } - return false; + return false; } //------------------------------------------------------------------------------------------------- @@ -2359,8 +2359,8 @@ Bool Weapon::isGoalPosWithinAttackRange(const Object *source, const Coord3D* goa Real distSqr; // Note - undersize by 1/4 of a pathfind cell, so that the goal is not teetering on the edge // of firing range. jba. - // Note 2 - even with RATIONALIZE_ATTACK_RANGE, we still need to subtract 1/4 of a pathfind cell, - // otherwise if it teters on the edge, attacks can fail. jba. + // Note 2 - even with RATIONALIZE_ATTACK_RANGE, we still need to subtract 1/4 of a pathfind cell, + // otherwise if it teters on the edge, attacks can fail. jba. Real attackRangeSqr = sqr(getAttackRange(source)-(PATHFIND_CELL_SIZE_F*0.25f)); if (target != NULL) @@ -2371,13 +2371,13 @@ Bool Weapon::isGoalPosWithinAttackRange(const Object *source, const Coord3D* goa TBridgeAttackInfo info; TheTerrainLogic->getBridgeAttackPoints(target, &info); distSqr = ThePartitionManager->getGoalDistanceSquared( source, goalPos, &info.attackPoint1, ATTACK_RANGE_CALC_TYPE ); - if (distSqr>attackRangeSqr) + if (distSqr>attackRangeSqr) { // Try the other one. distSqr = ThePartitionManager->getGoalDistanceSquared( source, goalPos, &info.attackPoint2, ATTACK_RANGE_CALC_TYPE ); } - } - else + } + else { distSqr = ThePartitionManager->getGoalDistanceSquared( source, goalPos, target, ATTACK_RANGE_CALC_TYPE ); } @@ -2389,8 +2389,8 @@ Bool Weapon::isGoalPosWithinAttackRange(const Object *source, const Coord3D* goa // Note - oversize by 1/4 of a pathfind cell, so that the goal is not teetering on the edge // of firing range. jba. - // Note 2 - even with RATIONALIZE_ATTACK_RANGE, we still need to add 1/4 of a pathfind cell, - // otherwise if it teters on the edge, attacks can fail. jba. + // Note 2 - even with RATIONALIZE_ATTACK_RANGE, we still need to add 1/4 of a pathfind cell, + // otherwise if it teters on the edge, attacks can fail. jba. Real minAttackRangeSqr = sqr(m_template->getMinimumAttackRange()+(PATHFIND_CELL_SIZE_F*0.25f)); #ifdef RATIONALIZE_ATTACK_RANGE if (distSqr < minAttackRangeSqr) @@ -2450,10 +2450,10 @@ Real Weapon::getPercentReadyToFire() const //------------------------------------------------------------------------------------------------- Real Weapon::getAttackRange(const Object *source) const -{ +{ WeaponBonus bonus; computeBonus(source, 0, bonus); - return m_template->getAttackRange(bonus); + return m_template->getAttackRange(bonus); //Contained objects have longer ranges. //const Object *container = source->getContainedBy(); @@ -2466,7 +2466,7 @@ Real Weapon::getAttackRange(const Object *source) const //------------------------------------------------------------------------------------------------- Real Weapon::getAttackDistance(const Object *source, const Object *victimObj, const Coord3D* victimPos) const -{ +{ Real range = getAttackRange(source); if (victimObj != NULL) @@ -2536,7 +2536,7 @@ void Weapon::createLaser( const Object *sourceObj, const Object *victimObj, cons const ThingTemplate* pst = TheThingFactory->findTemplate(m_template->getLaserName()); if( !pst ) { - DEBUG_CRASH( ("Weapon::createLaser(). %s could not find template for its laser %s.", + DEBUG_CRASH( ("Weapon::createLaser(). %s could not find template for its laser %s.", sourceObj->getTemplate()->getName().str(), m_template->getLaserName().str() ) ); return; } @@ -2546,7 +2546,7 @@ void Weapon::createLaser( const Object *sourceObj, const Object *victimObj, cons // Give it a good basis in reality to ensure it can draw when on screen. laser->setPosition(sourceObj->getPosition()); - + //Check for laser update Drawable *draw = laser->getDrawable(); if( draw ) @@ -2571,17 +2571,17 @@ void Weapon::createLaser( const Object *sourceObj, const Object *victimObj, cons // return true if we auto-reloaded our clip after firing. //DECLARE_PERF_TIMER(fireWeapon) Bool Weapon::privateFireWeapon( - const Object *sourceObj, - Object *victimObj, - const Coord3D* victimPos, - Bool isProjectileDetonation, - Bool ignoreRanges, + const Object *sourceObj, + Object *victimObj, + const Coord3D* victimPos, + Bool isProjectileDetonation, + Bool ignoreRanges, WeaponBonusConditionFlags extraBonusFlags, ObjectID* projectileID, Bool inflictDamage ) { - //CRCDEBUG_LOG(("Weapon::privateFireWeapon() for %s", DescribeObject(sourceObj).str())); + //CRCDEBUG_LOG(("Weapon::privateFireWeapon() for %s", DescribeObject(sourceObj).str())); //USE_PERF_TIMER(fireWeapon) if (projectileID) *projectileID = INVALID_ID; @@ -2593,8 +2593,8 @@ Bool Weapon::privateFireWeapon( if( m_template->getRequestAssistRange() && victimObj ) processRequestAssistance( sourceObj, victimObj ); - //For weapon templates that have the leech range weapon flag set, it essentially grants - //the weapon unlimited range for the remainder of the attack. While it's triggered here + //For weapon templates that have the leech range weapon flag set, it essentially grants + //the weapon unlimited range for the remainder of the attack. While it's triggered here //it's the AIAttackState machine that actually uses and resets this value. //This makes the ASSUMPTION that it is IMPOSSIBLE TO FIRE A WEAPON WITHOUT BEING IN AN AIATTACKSTATE // @@ -2673,7 +2673,7 @@ Bool Weapon::privateFireWeapon( //We're using a hacker unit to hack a target. Hacking has various effects and //instead of inflicting damage, we are waiting for a period of time until the hack takes effect. //return FALSE; - } + } } WeaponBonus bonus; @@ -2699,7 +2699,7 @@ Bool Weapon::privateFireWeapon( m_numShotsForCurBarrel = m_template->getShotsPerBarrel(); } - if( !m_scatterTargetsUnused.empty() ) + if( !m_scatterTargetsUnused.empty() ) { // If I have a set scatter pattern, I need to offset the target by a random pick from that pattern if( victimObj ) @@ -2731,7 +2731,7 @@ Bool Weapon::privateFireWeapon( { m_template->fireWeaponTemplate(sourceObj, m_wslot, m_curBarrel, victimObj, victimPos, bonus, isProjectileDetonation, ignoreRanges, this, projectileID, inflictDamage ); } - + m_lastFireFrame = now; --m_ammoInClip; --m_maxShotCount; @@ -2753,41 +2753,41 @@ Bool Weapon::privateFireWeapon( { m_status = OUT_OF_AMMO; m_whenWeCanFireAgain = 0x7fffffff; - //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::privateFireWeapon 1", m_whenWeCanFireAgain)); + //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::privateFireWeapon 1", m_whenWeCanFireAgain)); } } else { m_status = BETWEEN_FIRING_SHOTS; - //CRCDEBUG_LOG(("Weapon::privateFireWeapon() just set m_status to BETWEEN_FIRING_SHOTS")); + //CRCDEBUG_LOG(("Weapon::privateFireWeapon() just set m_status to BETWEEN_FIRING_SHOTS")); Int delay = m_template->getDelayBetweenShots(bonus); m_whenLastReloadStarted = now; m_whenWeCanFireAgain = now + delay; - //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d (delay is %d) in Weapon::privateFireWeapon", m_whenWeCanFireAgain, delay)); - + //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d (delay is %d) in Weapon::privateFireWeapon", m_whenWeCanFireAgain, delay)); + // if we are sharing reload times // go through other weapons in weapon set // set their m_whenWeCanFireAgain to this guy's delay // set their m_status to this guy's status if ( sourceObj->isReloadTimeShared() ) - { + { for (Int wt = 0; wtgetWeaponInWeaponSlot((WeaponSlotType)wt); if (weapon) { weapon->setPossibleNextShotFrame(m_whenWeCanFireAgain); - //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::privateFireWeapon 3", m_whenWeCanFireAgain)); + //CRCDEBUG_LOG(("Just set m_whenWeCanFireAgain to %d in Weapon::privateFireWeapon 3", m_whenWeCanFireAgain)); weapon->setStatus(BETWEEN_FIRING_SHOTS); } } } - + } } - + return reloaded; } @@ -2810,7 +2810,7 @@ void Weapon::preFireWeapon( const Object *source, const Object *victim ) //------------------------------------------------------------------------------------------------- Bool Weapon::fireWeapon(const Object *source, Object *target, ObjectID* projectileID) { - //CRCDEBUG_LOG(("Weapon::fireWeapon() for %s at %s", DescribeObject(source).str(), DescribeObject(target).str())); + //CRCDEBUG_LOG(("Weapon::fireWeapon() for %s at %s", DescribeObject(source).str(), DescribeObject(target).str())); return privateFireWeapon( source, target, NULL, false, false, 0, projectileID, TRUE ); } @@ -2818,21 +2818,21 @@ Bool Weapon::fireWeapon(const Object *source, Object *target, ObjectID* projecti // return true if we auto-reloaded our clip after firing. Bool Weapon::fireWeapon(const Object *source, const Coord3D* pos, ObjectID* projectileID) { - //CRCDEBUG_LOG(("Weapon::fireWeapon() for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::fireWeapon() for %s", DescribeObject(source).str())); return privateFireWeapon( source, NULL, pos, false, false, 0, projectileID, TRUE ); } //------------------------------------------------------------------------------------------------- void Weapon::fireProjectileDetonationWeapon(const Object *source, Object *target, WeaponBonusConditionFlags extraBonusFlags, Bool inflictDamage ) { - //CRCDEBUG_LOG(("Weapon::fireProjectileDetonationWeapon() for %sat %s", DescribeObject(source).str(), DescribeObject(target).str())); + //CRCDEBUG_LOG(("Weapon::fireProjectileDetonationWeapon() for %sat %s", DescribeObject(source).str(), DescribeObject(target).str())); privateFireWeapon( source, target, NULL, true, false, extraBonusFlags, NULL, inflictDamage ); } //------------------------------------------------------------------------------------------------- void Weapon::fireProjectileDetonationWeapon(const Object *source, const Coord3D* pos, WeaponBonusConditionFlags extraBonusFlags, Bool inflictDamage ) { - //CRCDEBUG_LOG(("Weapon::fireProjectileDetonationWeapon() for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::fireProjectileDetonationWeapon() for %s", DescribeObject(source).str())); privateFireWeapon( source, NULL, pos, true, false, extraBonusFlags, NULL, inflictDamage ); } @@ -2841,7 +2841,7 @@ void Weapon::fireProjectileDetonationWeapon(const Object *source, const Coord3D* //and immediately gain control of the weapon that was fired to give it special orders... Object* Weapon::forceFireWeapon( const Object *source, const Coord3D *pos) { - //CRCDEBUG_LOG(("Weapon::forceFireWeapon() for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::forceFireWeapon() for %s", DescribeObject(source).str())); //Force the ammo to load instantly. //loadAmmoNow( source ); //Fire the weapon at the position. Internally, it'll store the weapon projectile ID if so created. @@ -2865,7 +2865,7 @@ WeaponStatus Weapon::getStatus() const m_status = READY_TO_FIRE; else m_status = OUT_OF_AMMO; - //CRCDEBUG_LOG(("Weapon::getStatus() just set m_status to %d (ammo in clip is %d)", m_status, m_ammoInClip)); + //CRCDEBUG_LOG(("Weapon::getStatus() just set m_status to %d (ammo in clip is %d)", m_status, m_ammoInClip)); } return m_status; } @@ -2892,7 +2892,7 @@ Bool Weapon::isWithinTargetPitch(const Object *source, const Object *victim) con (minPitch <= m_template->getMinTargetPitch() && maxPitch >= m_template->getMaxTargetPitch())) return true; - //DEBUG_LOG(("pitch %f-%f is out of range",rad2deg(minPitch),rad2deg(maxPitch),rad2deg(m_template->getMinTargetPitch()),rad2deg(m_template->getMaxTargetPitch()))); + //DEBUG_LOG(("pitch %f-%f is out of range",rad2deg(minPitch),rad2deg(maxPitch),rad2deg(m_template->getMinTargetPitch()),rad2deg(m_template->getMaxTargetPitch()))); return false; } @@ -2924,7 +2924,7 @@ Bool Weapon::isDamageWeapon() const case DAMAGE_HACK: return FALSE; } - + //Use no bonus WeaponBonus whoCares; if( m_template->getPrimaryDamage( whoCares ) > 0.0f || m_template->getSecondaryDamage( whoCares ) > 0.0f ) @@ -3014,7 +3014,7 @@ static void makeAssistanceRequest( Object *requestOf, void *userData ) //------------------------------------------------------------------------------------------------- void Weapon::processRequestAssistance( const Object *requestingObject, Object *victimObject ) { - // Iterate through our player's objects, and tell everyone like us within our assistance range + // Iterate through our player's objects, and tell everyone like us within our assistance range // who is free to do so to assist us on this shot. Player *ourPlayer = requestingObject->getControllingPlayer(); if( !ourPlayer ) @@ -3030,8 +3030,8 @@ void Weapon::processRequestAssistance( const Object *requestingObject, Object *v //------------------------------------------------------------------------------------------------- /*static*/ void Weapon::calcProjectileLaunchPosition( - const Object* launcher, - WeaponSlotType wslot, + const Object* launcher, + WeaponSlotType wslot, Int specificBarrelToUse, Matrix3D& worldTransform, Coord3D& worldPos @@ -3056,17 +3056,17 @@ void Weapon::processRequestAssistance( const Object *requestingObject, Object *v Real turretPitch = 0.0f; const AIUpdateInterface* ai = launcher->getAIUpdateInterface(); WhichTurretType tur = ai ? ai->getWhichTurretForWeaponSlot(wslot, &turretAngle, &turretPitch) : TURRET_INVALID; - //CRCDEBUG_LOG(("calcProjectileLaunchPosition(): Turret %d, slot %d, barrel %d for %s", tur, wslot, specificBarrelToUse, DescribeObject(launcher).str())); + //CRCDEBUG_LOG(("calcProjectileLaunchPosition(): Turret %d, slot %d, barrel %d for %s", tur, wslot, specificBarrelToUse, DescribeObject(launcher).str())); Matrix3D attachTransform(true); Coord3D turretRotPos = {0.0f, 0.0f, 0.0f}; Coord3D turretPitchPos = {0.0f, 0.0f, 0.0f}; const Drawable* draw = launcher->getDrawable(); - //CRCDEBUG_LOG(("Do we have a drawable? %d", (draw != NULL))); + //CRCDEBUG_LOG(("Do we have a drawable? %d", (draw != NULL))); if (!draw || !draw->getProjectileLaunchOffset(wslot, specificBarrelToUse, &attachTransform, tur, &turretRotPos, &turretPitchPos)) { - //CRCDEBUG_LOG(("ProjectileLaunchPos %d %d not found!",wslot, specificBarrelToUse)); - DEBUG_CRASH(("ProjectileLaunchPos %d %d not found!",wslot, specificBarrelToUse)); + //CRCDEBUG_LOG(("ProjectileLaunchPos %d %d not found!",wslot, specificBarrelToUse)); + DEBUG_CRASH(("ProjectileLaunchPos %d %d not found!",wslot, specificBarrelToUse)); attachTransform.Make_Identity(); turretRotPos.zero(); turretPitchPos.zero(); @@ -3098,11 +3098,11 @@ void Weapon::processRequestAssistance( const Object *requestingObject, Object *v #endif } -//#if defined(RTS_DEBUG) +//#if defined(RTS_DEBUG) // Real muzzleHeight = attachTransform.Get_Z_Translation(); // DEBUG_ASSERTCRASH( muzzleHeight > 0.001f, ("YOUR TURRET HAS A VERY LOW PROJECTILE LAUNCH POSITION, BUT FOUND A VALID BONE. DID YOU PICK THE WRONG ONE? %s", launcher->getTemplate()->getName().str())); //#endif - + launcher->convertBonePosToWorldPos(NULL, &attachTransform, NULL, &worldTransform); Vector3 tmp = worldTransform.Get_Translation(); @@ -3113,13 +3113,13 @@ void Weapon::processRequestAssistance( const Object *requestingObject, Object *v //------------------------------------------------------------------------------------------------- /*static*/ void Weapon::positionProjectileForLaunch( - Object* projectile, - const Object* launcher, - WeaponSlotType wslot, + Object* projectile, + const Object* launcher, + WeaponSlotType wslot, Int specificBarrelToUse ) { - //CRCDEBUG_LOG(("Weapon::positionProjectileForLaunch() for %s from %s", + //CRCDEBUG_LOG(("Weapon::positionProjectileForLaunch() for %s from %s", //DescribeObject(projectile).str(), DescribeObject(launcher).str())); // if our launch vehicle is gone, destroy ourselves @@ -3154,7 +3154,7 @@ void Weapon::getFiringLineOfSightOrigin(const Object* source, Coord3D& origin) c { //GS 1-6-03 // Sorry, but we have to simplify this. If we take the actual projectile launch pos, then - // that point can change. Take a Ranger with his gun on his shoulder. His point is very high so + // that point can change. Take a Ranger with his gun on his shoulder. His point is very high so // he clears this check and transitions to attacking. This puts his gun at waist level and // now he fails this check so he transitions back. Our height won't change. origin.z += source->getGeometryInfo().getMaxHeightAbovePosition(); @@ -3186,12 +3186,12 @@ Bool Weapon::isClearFiringLineOfSightTerrain(const Object* source, const Object* { Coord3D origin; origin = *source->getPosition(); - //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain(Object) for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain(Object) for %s", DescribeObject(source).str())); //DUMPCOORD3D(&origin); getFiringLineOfSightOrigin(source, origin); Coord3D victimPos; victim->getGeometryInfo().getCenterPosition( *victim->getPosition(), victimPos ); - //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain() - victimPos is (%g,%g,%g) (%X,%X,%X)", + //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain() - victimPos is (%g,%g,%g) (%X,%X,%X)", // victimPos.x, victimPos.y, victimPos.z, // AS_INT(victimPos.x),AS_INT(victimPos.y),AS_INT(victimPos.z))); return ThePartitionManager->isClearLineOfSightTerrain(NULL, origin, NULL, victimPos); @@ -3203,7 +3203,7 @@ Bool Weapon::isClearFiringLineOfSightTerrain(const Object* source, const Coord3D { Coord3D origin; origin = *source->getPosition(); - //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain(Coord3D) for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain(Coord3D) for %s", DescribeObject(source).str())); //DUMPCOORD3D(&origin); getFiringLineOfSightOrigin(source, origin); return ThePartitionManager->isClearLineOfSightTerrain(NULL, origin, NULL, victimPos); @@ -3215,7 +3215,7 @@ Bool Weapon::isClearFiringLineOfSightTerrain(const Object* source, const Coord3D Bool Weapon::isClearGoalFiringLineOfSightTerrain(const Object* source, const Coord3D& goalPos, const Object* victim) const { Coord3D origin=goalPos; - //CRCDEBUG_LOG(("Weapon::isClearGoalFiringLineOfSightTerrain(Object) for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::isClearGoalFiringLineOfSightTerrain(Object) for %s", DescribeObject(source).str())); //DUMPCOORD3D(&origin); getFiringLineOfSightOrigin(source, origin); Coord3D victimPos; @@ -3229,10 +3229,10 @@ Bool Weapon::isClearGoalFiringLineOfSightTerrain(const Object* source, const Coo Bool Weapon::isClearGoalFiringLineOfSightTerrain(const Object* source, const Coord3D& goalPos, const Coord3D& victimPos) const { Coord3D origin=goalPos; - //CRCDEBUG_LOG(("Weapon::isClearGoalFiringLineOfSightTerrain(Coord3D) for %s", DescribeObject(source).str())); + //CRCDEBUG_LOG(("Weapon::isClearGoalFiringLineOfSightTerrain(Coord3D) for %s", DescribeObject(source).str())); //DUMPCOORD3D(&origin); getFiringLineOfSightOrigin(source, origin); - //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain() - victimPos is (%g,%g,%g) (%X,%X,%X)", + //CRCDEBUG_LOG(("Weapon::isClearFiringLineOfSightTerrain() - victimPos is (%g,%g,%g) (%X,%X,%X)", // victimPos.x, victimPos.y, victimPos.z, // AS_INT(victimPos.x),AS_INT(victimPos.y),AS_INT(victimPos.z))); return ThePartitionManager->isClearLineOfSightTerrain(NULL, origin, NULL, victimPos); @@ -3243,8 +3243,8 @@ Bool Weapon::isClearGoalFiringLineOfSightTerrain(const Object* source, const Coo //This function was added to transfer key weapon stats for Jarmen Kell to and from the bike for //the sniper attack, so he can share the stats. //------------------------------------------------------------------------------------------------- -void Weapon::transferNextShotStatsFrom( const Weapon &weapon ) -{ +void Weapon::transferNextShotStatsFrom( const Weapon &weapon ) +{ m_whenWeCanFireAgain = weapon.getPossibleNextShotFrame(); m_whenLastReloadStarted = weapon.getLastReloadStartedFrame(); m_status = weapon.getStatus(); @@ -3420,7 +3420,7 @@ void Weapon::crc( Xfer *xfer ) } #endif // DEBUG_CRC - } + } // pitch limited xfer->xferBool( &m_pitchLimited ); @@ -3446,11 +3446,11 @@ void Weapon::crc( Xfer *xfer ) #ifdef DEBUG_CRC if (doLogging) { - CRCDEBUG_LOG(("%s", logString.str())); + CRCDEBUG_LOG(("%s", logString.str())); } #endif // DEBUG_CRC -} +} // ------------------------------------------------------------------------------------------------ /** Xfer @@ -3523,7 +3523,7 @@ void Weapon::xfer( Xfer *xfer ) UnsignedShort scatterCount = m_scatterTargetsUnused.size(); xfer->xferUnsignedShort( &scatterCount ); Int intData; - if( xfer->getXferMode() == XFER_SAVE ) + if( xfer->getXferMode() == XFER_SAVE ) { std::vector< Int >::const_iterator it; @@ -3533,9 +3533,9 @@ void Weapon::xfer( Xfer *xfer ) intData = *it; xfer->xferInt( &intData ); - } + } - } + } else { @@ -3548,9 +3548,9 @@ void Weapon::xfer( Xfer *xfer ) xfer->xferInt( &intData ); m_scatterTargetsUnused.push_back( intData ); - } + } - } + } // pitch limited xfer->xferBool( &m_pitchLimited ); @@ -3558,7 +3558,7 @@ void Weapon::xfer( Xfer *xfer ) // leech weapon range active xfer->xferBool( &m_leechWeaponRangeActive ); -} +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -3619,8 +3619,9 @@ void WeaponBonusSet::appendBonuses(WeaponBonusConditionFlags flags, WeaponBonus& { if ((flags & (1 << i)) == 0) continue; - + this->m_bonus[i].appendBonuses(bonus); } } + From 99eb4346679aa79e6dd5909651150ec48553056f Mon Sep 17 00:00:00 2001 From: MrS-ibra Date: Tue, 23 Dec 2025 02:04:36 +0300 Subject: [PATCH 2/3] Update Weapon.cpp --- .../Code/GameEngine/Source/GameLogic/Object/Weapon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp index d4a44bc27cc..2735a5e7b33 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp @@ -505,9 +505,9 @@ Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const // TODO_NGMP: Better solution, less hackyness #if defined(GENERALS_ONLINE_HIGH_FPS_SERVER) - if (delayToUse != 0 && delayToUse < GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER) + if (delayToUse != 0 && delayToUse < (2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER)) { - delayToUse = GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER; + delayToUse = 2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER; } // HACK @@ -3625,3 +3625,4 @@ void WeaponBonusSet::appendBonuses(WeaponBonusConditionFlags flags, WeaponBonus& } + From 80fac53e7f95e71b45fa3f855a49f0df9f6a5ff3 Mon Sep 17 00:00:00 2001 From: MrS-ibra Date: Thu, 25 Dec 2025 18:25:04 +0300 Subject: [PATCH 3/3] Update Weapon.cpp --- .../GameEngine/Source/GameLogic/Object/Weapon.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp index 2735a5e7b33..1c7bef98da8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp @@ -505,10 +505,10 @@ Int WeaponTemplate::getDelayBetweenShots(const WeaponBonus& bonus) const // TODO_NGMP: Better solution, less hackyness #if defined(GENERALS_ONLINE_HIGH_FPS_SERVER) - if (delayToUse != 0 && delayToUse < (2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER)) - { - delayToUse = 2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER; - } + if (delayToUse != 0 && delayToUse < (2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER)) + { + delayToUse = 2*GENERALS_ONLINE_HIGH_FPS_FRAME_MULTIPLIER; + } // HACK // TODO_NGMP: Better solution for this, seems like an ini data bug @@ -3623,6 +3623,3 @@ void WeaponBonusSet::appendBonuses(WeaponBonusConditionFlags flags, WeaponBonus& this->m_bonus[i].appendBonuses(bonus); } } - - -