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" msgid "The battle has ended"
msgstr "" msgstr ""
#, c-format
msgid "Time: %s"
msgstr ""
#, c-format #, c-format
msgid "%s: %d pts" msgid "%s: %d pts"
msgstr "" msgstr ""

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -145,6 +145,7 @@ void InitializeRestext()
stringsText[RT_SCOREBOARD_RESULTS] = TR("Results"); stringsText[RT_SCOREBOARD_RESULTS] = TR("Results");
stringsText[RT_SCOREBOARD_RESULTS_TEXT]= TR("The battle has ended"); 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"); stringsText[RT_SCOREBOARD_RESULTS_LINE]= TR("%s: %d pts");

View File

@ -142,7 +142,8 @@ enum ResTextType
RT_SCOREBOARD_RESULTS = 230, RT_SCOREBOARD_RESULTS = 230,
RT_SCOREBOARD_RESULTS_TEXT= 231, 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 RT_MAX //! < number of values

View File

@ -2703,6 +2703,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_endTake.clear(); m_endTake.clear();
m_endTakeImmediat = false; m_endTakeImmediat = false;
m_endTakeResearch = 0; m_endTakeResearch = 0;
m_endTakeTimeout = -1.0f;
m_endTakeWinDelay = 2.0f; m_endTakeWinDelay = 2.0f;
m_endTakeLostDelay = 2.0f; m_endTakeLostDelay = 2.0f;
m_teamFinished.clear(); m_teamFinished.clear();
@ -3584,6 +3585,11 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
m_endTakeResearch |= line->GetParam("type")->AsResearchFlag(); m_endTakeResearch |= line->GetParam("type")->AsResearchFlag();
continue; continue;
} }
if (line->GetCommand() == "EndMissionTimeout" && !resetObject)
{
m_endTakeTimeout = line->GetParam("time")->AsFloat();
continue;
}
if (line->GetCommand() == "Scoreboard" && !resetObject) if (line->GetCommand() == "Scoreboard" && !resetObject)
{ {
@ -3597,7 +3603,7 @@ void CRobotMain::CreateScene(bool soluce, bool fixScene, bool resetObject)
if (line->GetCommand() == "ScoreboardSortType" && !resetObject) if (line->GetCommand() == "ScoreboardSortType" && !resetObject)
{ {
m_scoreboard->SetSortType(static_cast<SortType>(line->GetParam("sort")->AsSortType() ) ); m_scoreboard->SetSortType(line->GetParam("sort")->AsSortType());
continue; 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 //! If return value is different than ERR_MISSION_NOTERM, assume the mission is finished and pass on the result
Error CRobotMain::ProcessEndMissionTake() 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 // Sort end conditions by teams
std::map<int, std::vector<CSceneEndCondition*>> teamsEndTake; std::map<int, std::vector<CSceneEndCondition*>> teamsEndTake;
for (std::unique_ptr<CSceneEndCondition>& endTake : m_endTake) for (std::unique_ptr<CSceneEndCondition>& endTake : m_endTake)
@ -4989,21 +5011,43 @@ Error CRobotMain::ProcessEndMissionTake()
if (!usesTeamConditions) 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 else
{ {
assert(m_endTakeResearch == 0); // TODO: Add support for per-team EndTakeResearch
// Special handling for teams // Special handling for teams
m_missionResult = ERR_MISSION_NOTERM; m_missionResult = ERR_MISSION_NOTERM;
if (GetAllActiveTeams().empty()) if (GetAllActiveTeams().empty() || timeout)
{ {
GetLogger()->Info("All teams died, mission ended\n"); GetLogger()->Info("All teams died, mission ended\n");
if (m_scoreboard) if (m_scoreboard)
{ {
std::string title, text, details_line; std::string title, text, details_line;
GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS, title); 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); GetResource(RES_TEXT, RT_SCOREBOARD_RESULTS_LINE, details_line);
std::string details = ""; std::string details = "";
for (int team : GetAllTeams()) 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; 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 //! If true, the mission ends immediately after completing the requirements without requiring SpaceShip takeoff
bool m_endTakeImmediat = false; bool m_endTakeImmediat = false;
long m_endTakeResearch = 0; long m_endTakeResearch = 0;
float m_endTakeTimeout = -1.0f;
float m_endTakeWinDelay = 0.0f; float m_endTakeWinDelay = 0.0f;
float m_endTakeLostDelay = 0.0f; float m_endTakeLostDelay = 0.0f;
//! Set to true for teams that have already finished //! Set to true for teams that have already finished