Skip to content

Commit

Permalink
Minor clean of sorts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koi-3088 committed Jun 5, 2021
1 parent c0a45ac commit 6841dce
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 150 deletions.
18 changes: 8 additions & 10 deletions sys-botbase/source/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
bool bControllerIsInitialised = false;
time_t curTime = 0;
time_t origTime = 0;
int resetSkips = 0;
HiddbgHdlsHandle controllerHandle = {0};
HiddbgHdlsDeviceInfo controllerDevice = {0};
HiddbgHdlsState controllerState = {0};
Expand Down Expand Up @@ -421,7 +420,7 @@ void clickSequence(char* seq, u8* token)
}
}

void dateSkip(int resetTimeAfterSkips, int resetNTP)
void dateSkip()
{
if (origTime == 0)
{
Expand All @@ -437,12 +436,6 @@ void dateSkip(int resetTimeAfterSkips, int resetNTP)
Result ts = timeSetCurrentTime(TimeType_NetworkSystemClock, (uint64_t)(curTime + 86400)); //Set new time
if (R_FAILED(ts))
fatalThrow(ts);

resetSkips++;
if (resetNTP == 0 && resetTimeAfterSkips != 0 && (resetTimeAfterSkips == resetSkips)) //Reset time after # of skips
resetTime();
else if (resetNTP != 0 && resetTimeAfterSkips != 0 && (resetTimeAfterSkips == resetSkips))
resetTimeNTP();
}

void resetTime()
Expand All @@ -454,13 +447,19 @@ void resetTime()
fatalThrow(ct);
}

if (origTime == 0)
{
Result ct = timeGetCurrentTime(TimeType_UserSystemClock, (u64*)&origTime);
if (R_FAILED(ct))
fatalThrow(ct);
}

struct tm currentTime = *localtime(&curTime);
struct tm timeReset = *localtime(&origTime);
timeReset.tm_hour = currentTime.tm_hour;
timeReset.tm_min = currentTime.tm_min;
timeReset.tm_sec = currentTime.tm_sec;
Result rt = timeSetCurrentTime(TimeType_NetworkSystemClock, mktime(&timeReset));
resetSkips = 0;
curTime = 0;
origTime = 0;
if (R_FAILED(rt))
Expand All @@ -469,7 +468,6 @@ void resetTime()

void resetTimeNTP()
{
resetSkips = 0;
curTime = 0;
origTime = 0;
Result ts = timeSetCurrentTime(TimeType_NetworkSystemClock, ntpGetTime());
Expand Down
2 changes: 1 addition & 1 deletion sys-botbase/source/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ u64 followMainPointer(s64* jumps, size_t count);
void touch(HidTouchState* state, u64 sequentialCount, u64 holdTime, bool hold, u8* token);
void key(HiddbgKeyboardAutoPilotState* states, u64 sequentialCount);
void clickSequence(char* seq, u8* token);
void dateSkip(int resetTimeAfterSkips, int resetNTP);
void dateSkip();
void resetTime();
void resetTimeNTP();
Loading

0 comments on commit 6841dce

Please sign in to comment.