Skip to content

Commit

Permalink
use time(NULL) instead of SDL_GetTicks to save the hero data periodic…
Browse files Browse the repository at this point in the history
…ally
  • Loading branch information
pionere committed Sep 17, 2024
1 parent ea1dd6f commit 231b4cc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Source/pfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "diabloui.h"
#include "utils/file_util.h"
#include "DiabloUI/diablo.h"
#include <time.h>

DEVILUTION_BEGIN_NAMESPACE

Expand All @@ -22,7 +23,7 @@ DEVILUTION_BEGIN_NAMESPACE

unsigned mySaveIdx;
bool gbValidSaveFile;
static Uint32 guNextSaveTc;
static uint32_t guNextSaveTc;

#define PASSWORD_SINGLE "xrgyrkj1"
#define PASSWORD_MULTI "szqnlsk1"
Expand Down Expand Up @@ -304,7 +305,7 @@ void pfile_read_hero_from_save()
mypnum = 0;
gbValidSaveFile = pfile_archive_contains_game(archive);
SFileCloseArchive(archive);
guNextSaveTc = SDL_GetTicks() + PFILE_SAVE_INTERVAL;
guNextSaveTc = time(NULL) + PFILE_SAVE_INTERVAL;
}

void pfile_rename_temp_to_perm()
Expand Down Expand Up @@ -418,7 +419,7 @@ void pfile_read_save_file(bool full)
void pfile_update(bool force_save)
{
if (IsMultiGame) {
Uint32 currTc = SDL_GetTicks();
Uint32 currTc = time(NULL);
if (force_save || currTc > guNextSaveTc) {
guNextSaveTc = currTc + PFILE_SAVE_INTERVAL;
pfile_write_hero(false);
Expand Down

0 comments on commit 231b4cc

Please sign in to comment.