diff options
| author | Nycz <63111944+Nycz-lab@users.noreply.github.com> | 2022-08-03 05:48:41 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-02 23:48:41 -0400 |
| commit | db33604171bd09d33ddde83508da852e246df3d2 (patch) | |
| tree | c19bd359cd122269f0f56e5138fd993db81e2646 | |
| parent | 27e0f19dac4a2b429430414712a45d0585f9092e (diff) | |
added Cheat Sync Time (#957)
* added Cheat Sync Time
This syncs the ingame time with the real world time.
I wasnt quite sure where to put the code so im sorry if this is bad i just wanted to contribute to this project.
* Update soh/src/code/z_play.c
Co-authored-by: Christopher Leggett <chris@leggett.dev>
* Update z_play.c
added suggestions from leggettc18
* Update z_play.c
Co-authored-by: Christopher Leggett <chris@leggett.dev>
| -rw-r--r-- | libultraship/libultraship/ImGuiImpl.cpp | 3 | ||||
| -rw-r--r-- | soh/src/code/z_play.c | 28 |
2 files changed, 31 insertions, 0 deletions
diff --git a/libultraship/libultraship/ImGuiImpl.cpp b/libultraship/libultraship/ImGuiImpl.cpp index 555878b30..e6f7a31c6 100644 --- a/libultraship/libultraship/ImGuiImpl.cpp +++ b/libultraship/libultraship/ImGuiImpl.cpp @@ -1416,6 +1416,9 @@ namespace SohImGui { Tooltip("Prevents the Deku Shield from burning on contact with fire"); EnhancementCheckbox("Shield with Two-Handed Weapons", "gShieldTwoHanded"); Tooltip("This allows you to put up your shield with any two-handed weapon in hand except for Deku Sticks"); + Tooltip("This allows you to put up your shield with any two-handed weapon in hand\nexcept for Deku Sticks"); + EnhancementCheckbox("Time Sync", "gTimeSync"); + Tooltip("This syncs the ingame time with the real world time"); { static int32_t betaQuestEnabled = CVar_GetS32("gEnableBetaQuest", 0); diff --git a/soh/src/code/z_play.c b/soh/src/code/z_play.c index d5bcb5beb..f99979715 100644 --- a/soh/src/code/z_play.c +++ b/soh/src/code/z_play.c @@ -7,6 +7,8 @@ #include "../libultraship/ImGuiImpl.h" #include "soh/frame_interpolation.h" +#include <time.h> + void* D_8012D1F0 = NULL; //UNK_TYPE D_8012D1F4 = 0; // unused Input* D_8012D1F8 = NULL; @@ -1444,6 +1446,18 @@ void Gameplay_Draw(GlobalContext* globalCtx) { CLOSE_DISPS(gfxCtx); } +time_t Gameplay_GetRealTime() { + time_t t1, t2; + struct tm* tms; + time(&t1); + tms = localtime(&t1); + tms->tm_hour = 0; + tms->tm_min = 0; + tms->tm_sec = 0; + t2 = mktime(tms); + return t1 - t2; +} + void Gameplay_Main(GameState* thisx) { GlobalContext* globalCtx = (GlobalContext*)thisx; @@ -1487,6 +1501,20 @@ void Gameplay_Main(GameState* thisx) { if (1 && HREG(63)) { LOG_NUM("1", 1); } + + if (CVar_GetS32("gTimeSync", 0)) { + const int maxRealDaySeconds = 86400; + const int maxInGameDayTicks = 65536; + + int secs = (int)Gameplay_GetRealTime(); + float percent = (float)secs / (float)maxRealDaySeconds; + + int newIngameTime = maxInGameDayTicks * percent; + + gSaveContext.dayTime = newIngameTime; + + } + } // original name: "Game_play_demo_mode_check" |
