Skip to content

Commit

Permalink
fix(mechanics): Tidy up a few pointer issues and one typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Timothy Collett committed Sep 19, 2023
1 parent ef604cc commit 0db231b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions source/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ void Engine::EnterSystem()
if(flagship->Cloaking() == 0)
for(const shared_ptr<Ship> &ship : ships)
if(ship->GetSystem() == system && ship->Cloaking() == 0)
eventQueue.emplace_back(flagship, ship, ShipEvent::ENCOUNTER);
eventQueue.emplace_back(player.Flagship()->shared_from_this(), ship->shared_from_this(), ShipEvent::ENCOUNTER);

}

Expand Down Expand Up @@ -1444,14 +1444,14 @@ void Engine::CalculateStep()
bool wasCloaked = it->Cloaking() != 0;
MoveShip(it);
// If we decloaked, and we're in the same system as the player, they Encounter us
if(wasCloaked && it->Cloaking() == 0 && flagship->GetSystem() == it->GetSystem() && flagship->Cloaking() == 0 && it != flagship)
eventQueue.emplace_back(flagship, it, ShipEvent::ENCOUNTER);
if(wasCloaked && it->Cloaking() == 0 && flagship->GetSystem() == it->GetSystem() && flagship->Cloaking() == 0 && it.get() != flagship)
eventQueue.emplace_back(player.Flagship()->shared_from_this(), it, ShipEvent::ENCOUNTER);
}
// If we *are* the player, and we decloaked, we encounter everyone
if (flagshipWasCloaked && flagship->Cloaking() == 0)
for(const shared_ptr<Ship> &ship : ships)
if(ship->GetSystem() == playerSystem && ship->Cloaking() == 0)
eventQueue.emplace_back(flagship, ship, ShipEvent::ENCOUNTER);
eventQueue.emplace_back(player.Flagship()->shared_from_this(), ship, ShipEvent::ENCOUNTER);
// If the flagship just began jumping, play the appropriate sound.
if(!wasHyperspacing && flagship && flagship->IsEnteringHyperspace())
{
Expand Down Expand Up @@ -1718,7 +1718,7 @@ void Engine::MoveShip(const shared_ptr<Ship> &ship)
Audio::Play(sound.first, position);

if(flagship->Cloaking() == 0 && ship->Cloaking() == 0)
eventQueue.emplace_back(flagship, ship, ShipEvent::ENCOUNTER);
eventQueue.emplace_back(player.Flagship()->shared_from_this(), ship->shared_from_this(), ShipEvent::ENCOUNTER);
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/NPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void NPC::Load(const DataNode &node)
{"board", Trigger::BOARD},
{"capture", Trigger::CAPTURE},
{"destroy", Trigger::DESTROY},
{"kill", Trigger::KILL}
{"kill", Trigger::KILL},
{"encounter", Trigger::ENCOUNTER},
};
auto it = trigger.find(child.Token(1));
Expand Down

0 comments on commit 0db231b

Please sign in to comment.