Skip to content

Commit

Permalink
Fix for WDWA plasma issue #202
Browse files Browse the repository at this point in the history
CAbstractPlayer::AdaptableSettings() was overriding changes made by CWalkerActor::ReceiveConfig() for a level (WDWA) with a custom hull configuration.  Modified to allow ReceiveConfig() update the "classic" versions of those variables and AdaptableSettings uses the "classic" variables instead of the static hardcoded values.
  • Loading branch information
tra authored and assertivist committed Nov 22, 2021
1 parent 880e2ca commit 43d390d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
13 changes: 9 additions & 4 deletions src/game/CAbstractPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ void CAbstractPlayer::StartSystems() {

nextGrenadeLoad = 0;
nextMissileLoad = 0;

// variables in AdaptableSettings need to have "classic" counterparts in case they are changed in CWalkerActor::ReceiveConfig()
classicGeneratorPower = FIX3(30);
classicShieldRegen = FIX3(30); // Use 0.030 per frame to repair shields
classicChargeGunPerFrame = FIX3(35); // Charge gun at 0.035 units per frame
}

void CAbstractPlayer::LoadScout() {
Expand Down Expand Up @@ -277,10 +282,10 @@ CAbstractActor *CAbstractPlayer::EndScript() {
}

void CAbstractPlayer::AdaptableSettings() {
// any settings that are affected by frame rate should go here
generatorPower = FpsCoefficient2(FIX3(30));
shieldRegen = FpsCoefficient2(FIX3(30)); // Use 0.030 per frame to repair shields
chargeGunPerFrame = FpsCoefficient2(FIX3(35)); // Charge gun at 0.035 units per frame
// any settings that are affected by frame rate should go here, also double-check CWalkerActor::ReceiveConfig
generatorPower = FpsCoefficient2(classicGeneratorPower);
shieldRegen = FpsCoefficient2(classicShieldRegen);
chargeGunPerFrame = FpsCoefficient2(classicChargeGunPerFrame); // Charge gun at 0.035 units per frame
}

void CAbstractPlayer::Dispose() {
Expand Down
6 changes: 3 additions & 3 deletions src/game/CAbstractPlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ class CAbstractPlayer : public CRealMovers {
// Shields & energy:
Fixed energy;
Fixed maxEnergy; // Maximum stored energy level
Fixed generatorPower; // Energy gain/frame
Fixed classicGeneratorPower, generatorPower; // Energy gain/frame
long boostEndFrame;
long boostsRemaining;

Fixed maxShields; // Maximum shield energy
Fixed shieldRegen; // Shield regeneration rate
Fixed classicShieldRegen, shieldRegen; // Shield regeneration rate

short missileCount;
short grenadeCount;
Expand Down Expand Up @@ -88,7 +88,7 @@ class CAbstractPlayer : public CRealMovers {
Fixed gunEnergy[2]; // Left/right guns
Fixed fullGunEnergy;
Fixed activeGunEnergy;
Fixed chargeGunPerFrame;
Fixed classicChargeGunPerFrame, chargeGunPerFrame;
long mouseShootTime; // To pace mouse button autofire.
Vector gunOffset;
Boolean fireGun;
Expand Down
6 changes: 3 additions & 3 deletions src/game/CWalkerActor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -793,14 +793,14 @@ void CWalkerActor::ReceiveConfig(PlayerConfigRecord *config) {
grenadeLimit = hull.maxGrenades;

maxShields = FMul(maxShields, hull.shieldsRatio);
shieldRegen = FMul(shieldRegen, hull.shieldsChargeRatio);
classicShieldRegen = FMul(classicShieldRegen, hull.shieldsChargeRatio);
shields = maxShields;

maxEnergy = FMul(maxEnergy, hull.energyRatio);
energy = maxEnergy;
generatorPower = FMul(generatorPower, hull.energyChargeRatio);
classicGeneratorPower = FMul(classicGeneratorPower, hull.energyChargeRatio);

chargeGunPerFrame = FMul(chargeGunPerFrame, hull.shotChargeRatio);
classicChargeGunPerFrame = FMul(classicChargeGunPerFrame, hull.shotChargeRatio);
activeGunEnergy = FMul(activeGunEnergy, hull.minShotRatio);
fullGunEnergy = FMul(fullGunEnergy, hull.maxShotRatio);

Expand Down

0 comments on commit 43d390d

Please sign in to comment.