Permalink
Browse files

Remove redundant StoredGame::SpringVersion (Use storedGame.battle.Get…

…EngineVersion() instead).
  • Loading branch information...
specing committed Aug 22, 2018
1 parent b19bf62 commit 2a87fe72d5c5238df34033927fae6c55fb86e43f
Showing with 9 additions and 11 deletions.
  1. +2 −2 src/gui/playback/playbackdatamodel.cpp
  2. +7 −7 src/replaylist.cpp
  3. +0 −2 src/storedgame.h
@@ -49,7 +49,7 @@ int PlaybackDataModel::Compare(const wxDataViewItem& itemA, const wxDataViewItem
sortingResult = GenericCompare(storedGameA->duration, storedGameB->duration);
break;
case VERSION:
sortingResult = storedGameA->SpringVersion.compare(storedGameB->SpringVersion);
sortingResult = storedGameA->battle.GetEngineVersion().compare(storedGameB->battle.GetEngineVersion());
break;
case FILESIZE:
sortingResult = GenericCompare(storedGameA->size, storedGameB->size);
@@ -131,7 +131,7 @@ void PlaybackDataModel::GetValue(wxVariant& variant, const wxDataViewItem& item,
variant = wxString::Format(_T("%02d:%02d:%02d"), hours, minutes, seconds);
} break;
case VERSION:
variant = TowxString(storedGame->SpringVersion);
variant = TowxString(storedGame->battle.GetEngineVersion());
break;

case FILESIZE:
@@ -124,24 +124,24 @@ static void MarkBroken(StoredGame& ret)
ret.battle.SetHostGame("broken", "");
}

static void FixSpringVersion(StoredGame& ret)
static void FixSpringVersion(std::string& springVersion)
{
const int version = LSL::Util::FromIntString(ret.SpringVersion);
if (LSL::Util::ToIntString(version) != ret.SpringVersion)
const int version = LSL::Util::FromIntString(springVersion);
if (LSL::Util::ToIntString(version) != springVersion)
return;

ret.SpringVersion = ret.SpringVersion + ".0";
springVersion += ".0";
}

bool ReplayList::GetReplayInfos(const std::string& ReplayPath, StoredGame& ret) const
{
const std::string FileName = LSL::Util::AfterLast(ReplayPath, SEP); // strips file path
ret.type = StoredGame::REPLAY;
ret.battle.SetPlayBackFilePath(ReplayPath);
ret.SpringVersion = LSL::Util::BeforeLast(LSL::Util::AfterLast(FileName, "_"), ".");
std::string engineVersion = LSL::Util::BeforeLast(LSL::Util::AfterLast(FileName, "_"), ".");
ret.size = wxFileName::GetSize(ReplayPath).GetLo(); //FIXME: use longlong

FixSpringVersion(ret);
FixSpringVersion(engineVersion);

if (!wxFileExists(TowxString(ReplayPath))) {
wxLogWarning(wxString::Format(_T("File %s does not exist!"), ReplayPath.c_str()));
@@ -189,7 +189,7 @@ bool ReplayList::GetReplayInfos(const std::string& ReplayPath, StoredGame& ret)
ret.battle.GetBattleFromScript(false);
ret.battle.SetBattleType(BT_Replay);
ret.battle.SetEngineName("spring");
ret.battle.SetEngineVersion(ret.SpringVersion);
ret.battle.SetEngineVersion(engineVersion);
ret.battle.SetPlayBackFilePath(ReplayPath);
delete replay;
return true;
@@ -14,7 +14,6 @@ struct StoredGame
bool can_watch;
int duration; //in seconds
int size; //in bytes
std::string SpringVersion;
time_t date;
std::string date_string;
OfflineBattle battle;
@@ -50,7 +49,6 @@ struct StoredGame
can_watch = moved.can_watch;
duration = moved.duration;
size = moved.size;
SpringVersion = moved.SpringVersion;
date = moved.date;
date_string = moved.date_string;
battle.operator=((OfflineBattle && )moved.battle);

0 comments on commit 2a87fe7

Please sign in to comment.