Add EndMissionTimeout

1008-fix
krzys-h 2018-05-09 17:47:21 +02:00
parent 94a18e9648
commit abe489e294
10 changed files with 79 additions and 22 deletions

View File

@ -266,6 +266,10 @@ msgstr ""
msgid "The battle has ended"
msgstr ""
#, c-format
msgid "Time: %s"
msgstr ""
#, c-format
msgid "%s: %d pts"
msgstr ""

View File

@ -1546,6 +1546,10 @@ msgstr "Úder (\\key action;)"
msgid "Thumper"
msgstr "Buchar"
#, c-format
msgid "Time: %s"
msgstr ""
msgid "Titanium"
msgstr "Titan"

View File

@ -1563,6 +1563,10 @@ msgstr "Stampfen (\\key action;)"
msgid "Thumper"
msgstr "Stampfer"
#, c-format
msgid "Time: %s"
msgstr ""
msgid "Titanium"
msgstr "Titan"

View File

@ -1,7 +1,6 @@
# Didier Raboud <odyx@debian.org>, 2012, 2015, 2016.
# Martin Quinson <mquinson@debian.org>, 2016
# B-CE, 2018
msgid ""
msgstr ""
"Project-Id-Version: Colobot 0.1.11\n"
@ -174,10 +173,10 @@ msgstr "Sang\\Afficher du sang quand le cosmonaute est touché"
msgid "Blue"
msgstr "Bleue"
# tocheck : for team (fem): bleue
# tocheck : for flag/pen/bot (masc): bleu
# + capital also to check
msgid "Blue flag"
msgstr "Drapeau bleu"
@ -566,8 +565,8 @@ msgstr "Séquences cinématiques\\Films avant ou après une mission"
msgid "Finish"
msgstr "But/Objectif"
# OBJECT_END : GoalArea
# OBJECT_END : GoalArea
msgid "Fixed mine"
msgstr "Mine fixe"
@ -857,7 +856,6 @@ msgstr "Chargement du terrain"
# msgstr ""
# msgid "Speed 6.0x\\Sextuple speed"
# msgstr ""
msgid "Lower speed\\Decrease speed by half"
msgstr "Moins rapide\\Diminuer la vitesse de moitié"
@ -1257,8 +1255,8 @@ msgstr "Robot recycleur"
msgid "Red"
msgstr "Rouge"
# toCheck : capital (for team?)
# toCheck : capital (for team?)
msgid "Red flag"
msgstr "Drapeau rouge"
@ -1568,6 +1566,10 @@ msgstr "Secoue (\\key action;)"
msgid "Thumper"
msgstr "Robot secoueur"
#, c-format
msgid "Time: %s"
msgstr ""
msgid "Titanium"
msgstr "Titane"
@ -2048,4 +2050,3 @@ msgstr "epsitec.com"
#~ msgid "\\c; (none)\\n;\n"
#~ msgstr "\\c; (aucun)\\n;\n"

View File

@ -1545,6 +1545,10 @@ msgstr "Uderz (\\key action;)"
msgid "Thumper"
msgstr "Uderzacz"
#, c-format
msgid "Time: %s"
msgstr "Czas: %s"
msgid "Titanium"
msgstr "Tytan"

View File

@ -1576,6 +1576,10 @@ msgstr "Удар (\\key action;)"
msgid "Thumper"
msgstr "Ударник"
#, c-format
msgid "Time: %s"
msgstr ""
msgid "Titanium"
msgstr "Титан"

View File

@ -145,6 +145,7 @@ void InitializeRestext()
stringsText[RT_SCOREBOARD_RESULTS] = TR("Results");
stringsText[RT_SCOREBOARD_RESULTS_TEXT]= TR("The battle has ended");
stringsText[RT_SCOREBOARD_RESULTS_TIME]= TR("Time: %s");
stringsText[RT_SCOREBOARD_RESULTS_LINE]= TR("%s: %d pts");

View File

@ -142,7 +142,8 @@ enum ResTextType
RT_SCOREBOARD_RESULTS = 230,
RT_SCOREBOARD_RESULTS_TEXT= 231,
RT_SCOREBOARD_RESULTS_LINE= 232,
RT_SCOREBOARD_RESULTS_TIME= 232,
RT_SCOREBOARD_RESULTS_LINE= 233,
RT_MAX //! < number of values

View File

@ -2703,6 +2703,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_endTake.clear();
m_endTakeImmediat = false;
m_endTakeResearch = 0;
m_endTakeTimeout = -1.0f;
m_endTakeWinDelay = 2.0f;
m_endTakeLostDelay = 2.0f;
m_teamFinished.clear();
@ -3584,6 +3585,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_endTakeResearch |= line->GetParam("type")->AsResearchFlag();
continue;
}
if (line->GetCommand() == "EndMissionTimeout" && !resetObject)
{
m_endTakeTimeout = line->GetParam("time")->AsFloat();
continue;
}
if (line->GetCommand() == "Scoreboard" && !resetObject)
{
@ -3597,7 +3603,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (line->GetCommand() == "ScoreboardSortType" && !resetObject)
{
m_scoreboard->SetSortType(static_cast<SortType>(line->GetParam("sort")->AsSortType() ) );
m_scoreboard->SetSortType(line->GetParam("sort")->AsSortType());
continue;
}
@ -4979,6 +4985,22 @@ Error CRobotMain::ProcessEndMissionTakeForGroup(std::vector<CSceneEndCondition*>
//! If return value is different than ERR_MISSION_NOTERM, assume the mission is finished and pass on the result
Error CRobotMain::ProcessEndMissionTake()
{
bool timeout = false;
if (m_missionResult != INFO_LOST && m_missionResult != INFO_LOSTq)
{
if (m_endTakeTimeout >= 0.0f)
{
// Use the mission timer if available, or global mission time otherwise
// Useful for exercises where the time starts when you start the program, not the mission itself
float currentTime = m_missionTimerEnabled ? m_missionTimer : m_gameTime;
if (currentTime > m_endTakeTimeout)
{
m_missionResult = INFO_LOST;
timeout = true;
}
}
}
// Sort end conditions by teams
std::map<int, std::vector<CSceneEndCondition*>> teamsEndTake;
for (std::unique_ptr<CSceneEndCondition>& endTake : m_endTake)
@ -4989,21 +5011,43 @@ Error CRobotMain::ProcessEndMissionTake()
if (!usesTeamConditions)
{
m_missionResult = ProcessEndMissionTakeForGroup(teamsEndTake[0]);
if (!timeout)
m_missionResult = ProcessEndMissionTakeForGroup(teamsEndTake[0]);
if (m_missionResult != INFO_LOST && m_missionResult != INFO_LOSTq)
{
if (m_endTakeResearch != 0)
{
if (m_endTakeResearch != (m_endTakeResearch&m_researchDone[0]))
{
m_missionResult = ERR_MISSION_NOTERM;
}
}
}
}
else
{
assert(m_endTakeResearch == 0); // TODO: Add support for per-team EndTakeResearch
// Special handling for teams
m_missionResult = ERR_MISSION_NOTERM;
if (GetAllActiveTeams().empty())
if (GetAllActiveTeams().empty() || timeout)
{
GetLogger()->Info("All teams died, mission ended\n");
if (m_scoreboard)
{
std::string title, text, details_line;
GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS, title);
GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS_TEXT, text);
if (m_missionTimerEnabled && m_missionTimerStarted)
{
GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS_TIME, text);
text = StrUtils::Format(text.c_str(), TimeFormat(m_missionTimer).c_str());
}
else
{
GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS_TEXT, text);
}
GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS_LINE, details_line);
std::string details = "";
for (int team : GetAllTeams())
@ -5086,17 +5130,6 @@ Error CRobotMain::ProcessEndMissionTake()
}
}
if (m_missionResult != INFO_LOST && m_missionResult != INFO_LOSTq)
{
if (m_endTakeResearch != 0)
{
if (m_endTakeResearch != (m_endTakeResearch&m_researchDone[0]))
{
m_missionResult = ERR_MISSION_NOTERM;
}
}
}
return ERR_MISSION_NOTERM;
}

View File

@ -672,6 +672,7 @@ protected:
//! If true, the mission ends immediately after completing the requirements without requiring SpaceShip takeoff
bool m_endTakeImmediat = false;
long m_endTakeResearch = 0;
float m_endTakeTimeout = -1.0f;
float m_endTakeWinDelay = 0.0f;
float m_endTakeLostDelay = 0.0f;
//! Set to true for teams that have already finished