Browse Source

Adds isSameSource Missile method (#5036)

pull/5037/head
Cesar Canassa 4 years ago committed by GitHub
parent
commit
ac583cbb2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Source/missiles.cpp
  2. 5
      Source/missiles.h

4
Source/missiles.cpp

@ -1490,7 +1490,7 @@ void AddSearch(Missile &missile, const AddMissileParameter & /*parameter*/)
UseMana(player, SPL_SEARCH);
for (auto &other : Missiles) {
if (&other != &missile && other._misource == missile._misource && other._mitype == MIS_SEARCH) {
if (&other != &missile && missile.isSameSource(other) && other._mitype == MIS_SEARCH) {
int r1 = missile._mirange;
int r2 = other._mirange;
if (r2 < INT_MAX - r1)
@ -1868,7 +1868,7 @@ void AddTown(Missile &missile, const AddMissileParameter &parameter)
missile._mirange = 100;
missile.var1 = missile._mirange - missile._miAnimLen;
for (auto &other : Missiles) {
if (other._mitype == MIS_TOWN && &other != &missile && other._misource == missile._misource)
if (other._mitype == MIS_TOWN && &other != &missile && missile.isSameSource(other))
other._mirange = 0;
}
PutMissile(missile);

5
Source/missiles.h

@ -153,6 +153,11 @@ struct Missile {
return &Monsters[_misource];
}
[[nodiscard]] bool isSameSource(Missile &missile)
{
return sourceType() == missile.sourceType() && _misource == missile._misource;
}
MissileSource sourceType()
{
if (_misource == -1)

Loading…
Cancel
Save