Skip to content

Commit

Permalink
Fix regression with Hazard speed that would mutate base Power
Browse files Browse the repository at this point in the history
  • Loading branch information
dorkster committed Aug 5, 2018
1 parent 764b2b6 commit c0bfd54
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Hazard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Hazard::Hazard(MapCollision *_collider)
, crit_chance(0)
, accuracy(0)
, source_type(0)
, base_speed(0)
, lifespan(1)
, animationKind(0)
, delay_frames(0)
Expand Down Expand Up @@ -281,8 +282,8 @@ void Hazard::setAngle(const float& _angle) {
while (angle >= static_cast<float>(M_PI)*2) angle -= static_cast<float>(M_PI)*2;
while (angle < 0.0) angle += static_cast<float>(M_PI)*2;

speed.x = power->speed * cosf(angle);
speed.y = power->speed * sinf(angle);
speed.x = base_speed * cosf(angle);
speed.y = base_speed * sinf(angle);

if (power->directional)
animationKind = Utils::calcDirection(pos.x, pos.y, pos.x + speed.x, pos.y + speed.y);
Expand Down
1 change: 1 addition & 0 deletions src/Hazard.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Hazard {
int crit_chance;
int accuracy;
int source_type;
float base_speed;
int lifespan; // ticks down to zero
int animationKind; // either a direction or option/random
int delay_frames;
Expand Down
3 changes: 2 additions & 1 deletion src/PowerManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,7 @@ void PowerManager::initHazard(int power_index, StatBlock *src_stats, const FPoin
}

// combat traits
haz->base_speed = powers[power_index].speed;
haz->lifespan = powers[power_index].lifespan;
haz->active = !powers[power_index].no_attack;

Expand Down Expand Up @@ -1257,7 +1258,7 @@ bool PowerManager::missile(int power_index, StatBlock *src_stats, const FPoint&
}

// set speed and angle
haz->power->speed += speed_var;
haz->base_speed += speed_var;
haz->setAngle(alpha);

// add optional delay
Expand Down
2 changes: 1 addition & 1 deletion src/Version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ FLARE. If not, see https://www.gnu.org/licenses/

#include <SDL.h>

Version VersionInfo::ENGINE(1, 6, 34);
Version VersionInfo::ENGINE(1, 6, 35);
Version VersionInfo::MIN(0, 0, 0);
Version VersionInfo::MAX(USHRT_MAX, USHRT_MAX, USHRT_MAX);

Expand Down

0 comments on commit c0bfd54

Please sign in to comment.