main: Minor refactor
This commit is contained in:
parent
bdd1ee48e3
commit
ad93ee1a18
@ -37,7 +37,10 @@ static void load_playtime(const char *titleid) {
|
|||||||
is_playtime_loaded = 1;
|
is_playtime_loaded = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_playtime(uint64_t playtime) {
|
static void write_playtime() {
|
||||||
|
uint32_t playtime = playtime_start +
|
||||||
|
(sceKernelGetProcessTimeWide() - tick_start) / SECOND;
|
||||||
|
|
||||||
SceUID fd = sceIoOpen(playtime_bin_path,
|
SceUID fd = sceIoOpen(playtime_bin_path,
|
||||||
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 0777);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
@ -79,6 +82,9 @@ static int check_adrenaline() {
|
|||||||
|
|
||||||
// Game changed?
|
// Game changed?
|
||||||
if (strncmp(adrenaline_titleid, titleid, 9)) {
|
if (strncmp(adrenaline_titleid, titleid, 9)) {
|
||||||
|
if (is_playtime_loaded)
|
||||||
|
write_playtime(); // Save closed game
|
||||||
|
|
||||||
is_playtime_loaded = 0;
|
is_playtime_loaded = 0;
|
||||||
strcpy(adrenaline_titleid, titleid);
|
strcpy(adrenaline_titleid, titleid);
|
||||||
|
|
||||||
@ -113,13 +119,10 @@ static int tracker_thread(SceSize args, void *argp) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_playtime_loaded) {
|
if (is_playtime_loaded) {
|
||||||
goto CONT;
|
write_playtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
write_playtime(playtime_start +
|
|
||||||
(sceKernelGetProcessTimeWide() - tick_start)/SECOND);
|
|
||||||
|
|
||||||
CONT:
|
CONT:
|
||||||
sceKernelDelayThread(SAVE_PERIOD * SECOND);
|
sceKernelDelayThread(SAVE_PERIOD * SECOND);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user