Skip to content

Commit

Permalink
ucPlayingStats: Do not remove user statistics on database import
Browse files Browse the repository at this point in the history
  • Loading branch information
Chixpy committed Oct 15, 2023
1 parent 16d6d9a commit 3541d74
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion EmutecaCore/Abstracts/uaEmutecaCustomGroup.pas
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ procedure caEmutecaCustomGroup.LoadFromStrLst(aTxtFile: TStrings);
Exit;

while aTxtFile.Count < 6 do
aTxtFile.Add('');
aTxtFile.Add(krsImportKeepValueKey);

Self.ID := aTxtFile[0];
Self.Title := aTxtFile[1];
Expand Down
2 changes: 1 addition & 1 deletion EmutecaCore/Abstracts/uaEmutecaCustomSoft.pas
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ procedure caEmutecaCustomSoft.LoadFromStrLst(aTxtFile: TStrings);

// Dirty error fix
while aTxtFile.Count < 22 do
aTxtFile.Add('');
aTxtFile.Add(krsImportKeepValueKey);

GroupKey := aTxtFile[0];
SHA1 := StringToSHA1Digest(aTxtFile[1]);
Expand Down
20 changes: 15 additions & 5 deletions EmutecaCore/Classes/ucEmutecaPlayingStats.pas
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,10 @@ procedure cEmutecaPlayingStats.LoadFromIni(aIniFile: TCustomIniFile;
Exit;

LastTime := aIniFile.ReadDateTime(Section, krsIniKeyLastTime, LastTime);
PlayingTime := aIniFile.ReadInt64(Section, krsIniKeyPlayingTime, PlayingTime);
TimesPlayed := aIniFile.ReadInt64(Section, krsIniKeyTimesPlayed, TimesPlayed);
PlayingTime := aIniFile.ReadInt64(Section, krsIniKeyPlayingTime,
PlayingTime);
TimesPlayed := aIniFile.ReadInt64(Section, krsIniKeyTimesPlayed,
TimesPlayed);
end;

procedure cEmutecaPlayingStats.WriteToStrLst(aTxtFile: TStrings;
Expand All @@ -181,6 +183,8 @@ procedure cEmutecaPlayingStats.WriteToStrLst(aTxtFile: TStrings;

procedure cEmutecaPlayingStats.LoadFromStrLst(aTxtFile: TStrings;
const NLine: integer);
var
aStr: string;
begin
// TODO: Exception...
if not Assigned(aTxtFile) then
Expand All @@ -189,9 +193,15 @@ procedure cEmutecaPlayingStats.LoadFromStrLst(aTxtFile: TStrings;
if NLine + 3 > aTxtFile.Count then
Exit;

LastTime := StrToDateTimeDef(aTxtFile[Nline], LastTime);
TimesPlayed := StrToInt64Def(aTxtFile[Nline + 1], TimesPlayed);
PlayingTime := StrToInt64Def(aTxtFile[Nline + 2], PlayingTime);
aStr := aTxtFile[Nline];
if (aStr <> '') and (aStr <> krsImportKeepValueKey) then
LastTime := StrToDateTimeDef(aStr, LastTime);
aStr := aTxtFile[Nline + 1];
if (aStr <> '') and (aStr <> krsImportKeepValueKey) then
TimesPlayed := StrToInt64Def(aStr, TimesPlayed);
aStr := aTxtFile[Nline + 2];
if (aStr <> '') and (aStr <> krsImportKeepValueKey) then
PlayingTime := StrToInt64Def(aStr, PlayingTime);
end;

constructor cEmutecaPlayingStats.Create(aOwner: TComponent);
Expand Down

0 comments on commit 3541d74

Please sign in to comment.