Change new functions return type and switch to enum class
As suggested by @krzys_h1008-fix
parent
d371338920
commit
ad6dd00275
src/level
|
@ -917,21 +917,21 @@ int CLevelParserParam::AsResearchFlag(int def)
|
||||||
return AsResearchFlag();
|
return AsResearchFlag();
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLevelParserParam::ToSortType(std::string value)
|
SortType CLevelParserParam::ToSortType(std::string value)
|
||||||
{
|
{
|
||||||
if (value == "Points" ) return SORT_POINTS;
|
if (value == "Points" ) return SortType::SORT_POINTS;
|
||||||
if (value == "Name" ) return SORT_ID;
|
if (value == "Name" ) return SortType::SORT_ID;
|
||||||
return Cast<int>(value, "sorttype");
|
return SortType::SORT_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLevelParserParam::AsSortType()
|
SortType CLevelParserParam::AsSortType()
|
||||||
{
|
{
|
||||||
if (m_empty)
|
if (m_empty)
|
||||||
throw CLevelParserExceptionMissingParam(this);
|
throw CLevelParserExceptionMissingParam(this);
|
||||||
return ToSortType(m_value);
|
return ToSortType(m_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CLevelParserParam::AsSortType(int def)
|
SortType CLevelParserParam::AsSortType(SortType def)
|
||||||
{
|
{
|
||||||
if (m_empty)
|
if (m_empty)
|
||||||
return def;
|
return def;
|
||||||
|
|
|
@ -31,6 +31,8 @@
|
||||||
#include "graphics/engine/pyro_type.h"
|
#include "graphics/engine/pyro_type.h"
|
||||||
#include "graphics/engine/water.h"
|
#include "graphics/engine/water.h"
|
||||||
|
|
||||||
|
#include "level/scoreboard.h"
|
||||||
|
|
||||||
#include "math/point.h"
|
#include "math/point.h"
|
||||||
|
|
||||||
#include "object/drive_type.h"
|
#include "object/drive_type.h"
|
||||||
|
@ -85,7 +87,7 @@ public:
|
||||||
Gfx::EngineObjectType AsTerrainType();
|
Gfx::EngineObjectType AsTerrainType();
|
||||||
int AsBuildFlag();
|
int AsBuildFlag();
|
||||||
int AsResearchFlag();
|
int AsResearchFlag();
|
||||||
int AsSortType();
|
SortType AsSortType();
|
||||||
Gfx::PyroType AsPyroType();
|
Gfx::PyroType AsPyroType();
|
||||||
Gfx::CameraType AsCameraType();
|
Gfx::CameraType AsCameraType();
|
||||||
MissionType AsMissionType();
|
MissionType AsMissionType();
|
||||||
|
@ -109,7 +111,7 @@ public:
|
||||||
Gfx::EngineObjectType AsTerrainType(Gfx::EngineObjectType def);
|
Gfx::EngineObjectType AsTerrainType(Gfx::EngineObjectType def);
|
||||||
int AsBuildFlag(int def);
|
int AsBuildFlag(int def);
|
||||||
int AsResearchFlag(int def);
|
int AsResearchFlag(int def);
|
||||||
int AsSortType(int def);
|
SortType AsSortType(SortType def);
|
||||||
Gfx::PyroType AsPyroType(Gfx::PyroType def);
|
Gfx::PyroType AsPyroType(Gfx::PyroType def);
|
||||||
Gfx::CameraType AsCameraType(Gfx::CameraType def);
|
Gfx::CameraType AsCameraType(Gfx::CameraType def);
|
||||||
MissionType AsMissionType(MissionType def);
|
MissionType AsMissionType(MissionType def);
|
||||||
|
@ -141,7 +143,7 @@ private:
|
||||||
Gfx::EngineObjectType ToTerrainType(std::string value);
|
Gfx::EngineObjectType ToTerrainType(std::string value);
|
||||||
int ToBuildFlag(std::string value);
|
int ToBuildFlag(std::string value);
|
||||||
int ToResearchFlag(std::string value);
|
int ToResearchFlag(std::string value);
|
||||||
int ToSortType(std::string value);
|
SortType ToSortType(std::string value);
|
||||||
Gfx::PyroType ToPyroType(std::string value);
|
Gfx::PyroType ToPyroType(std::string value);
|
||||||
Gfx::CameraType ToCameraType(std::string value);
|
Gfx::CameraType ToCameraType(std::string value);
|
||||||
MissionType ToMissionType(std::string value);
|
MissionType ToMissionType(std::string value);
|
||||||
|
|
|
@ -5919,7 +5919,7 @@ void CRobotMain::UpdateCodeBattleInterface()
|
||||||
assert(pw != nullptr);
|
assert(pw != nullptr);
|
||||||
std::set<int> teams = GetAllTeams();
|
std::set<int> teams = GetAllTeams();
|
||||||
std::vector<int> sortedTeams(teams.begin(), teams.end());
|
std::vector<int> sortedTeams(teams.begin(), teams.end());
|
||||||
if(m_scoreboard->GetSortType() == SORT_POINTS)
|
if(m_scoreboard->GetSortType() == SortType::SORT_POINTS)
|
||||||
{
|
{
|
||||||
std::sort(sortedTeams.begin(), sortedTeams.end(), [this](int teamA, int teamB)
|
std::sort(sortedTeams.begin(), sortedTeams.end(), [this](int teamA, int teamB)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,7 +42,7 @@ struct Score
|
||||||
float time = 0; //! Time when points were scored
|
float time = 0; //! Time when points were scored
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SortType
|
enum class SortType
|
||||||
{
|
{
|
||||||
SORT_ID, //Sort by team ID
|
SORT_ID, //Sort by team ID
|
||||||
SORT_POINTS, //Sort by points
|
SORT_POINTS, //Sort by points
|
||||||
|
@ -142,5 +142,5 @@ private:
|
||||||
std::vector<std::unique_ptr<CScoreboardEndTakeRule>> m_rulesEndTake = {};
|
std::vector<std::unique_ptr<CScoreboardEndTakeRule>> m_rulesEndTake = {};
|
||||||
std::map<int, Score> m_score;
|
std::map<int, Score> m_score;
|
||||||
int m_finishCounter = 0;
|
int m_finishCounter = 0;
|
||||||
SortType m_sorttype = SORT_ID;
|
SortType m_sorttype = SortType::SORT_ID;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue