Skip to content

Ch 10. Incorrect Mission Successful after All Aircrafts are Destroyed #29

@kyuhyunp

Description

@kyuhyunp

The following tick code incorrectly sends MissionSuccess although no aircraft is alive. This error is more critical because it is also visible in the final output. To fix this, check if the code enters the foreach loop.

// Check for mission success = all planes with position.y < offset
	bool allAircraftsDone = true;
    bool allDestroyed = true;
	FOREACH(auto pair, mAircraftInfo)
	{
        allDestroyed = false;
		// As long as one player has not crossed the finish line yet, set variable to false
		if (pair.second.position.y > 0.f)
			allAircraftsDone = false;
	}

   if (!allDestroyed && allAircraftsDone)
	{
		sf::Packet missionSuccessPacket;
		missionSuccessPacket << static_cast<sf::Int32>(Server::MissionSuccess);
		sendToAll(missionSuccessPacket);
	}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions