diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..d3aca7b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: "https://paypal.me/Nightkingale" \ No newline at end of file diff --git a/README.md b/.github/README.md similarity index 100% rename from README.md rename to .github/README.md diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..50b323b --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "daily" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81b4e9f..e45f2d1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,13 +6,13 @@ jobs: build-binary: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Build Binary run: | - docker build -t plugin_builder . - docker run --rm -v ${PWD}:/project plugin_builder make + docker build -t builder . + docker run --rm -v ${PWD}:/project builder make - uses: actions/upload-artifact@v3 with: - name: Wii_U_Time_Sync.wps - path: "*.wps" - if-no-files-found: error \ No newline at end of file + name: Wii_U_Time_Sync.wps + path: "*.wps" + if-no-files-found: error \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index ae2b6d6..35533f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ -FROM ghcr.io/wiiu-env/devkitppc:20230326 +FROM ghcr.io/wiiu-env/devkitppc:20230621 -COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230215 /artifacts $DEVKITPRO -COPY --from=ghcr.io/wiiu-env/libnotifications:20230423 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/wiiupluginsystem:20230719 /artifacts $DEVKITPRO +COPY --from=ghcr.io/wiiu-env/libnotifications:20230621 /artifacts $DEVKITPRO WORKDIR project \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..d362aff --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Nightkingale + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/Makefile b/Makefile index 53b2b6e..9ac82ff 100644 --- a/Makefile +++ b/Makefile @@ -28,7 +28,8 @@ INCLUDES := source #------------------------------------------------------------------------------- # options for code generation #------------------------------------------------------------------------------- -CFLAGS := -g -Wall -O2 -ffunction-sections \ +CFLAGS := -Wall -Wextra -Wundef -Wshadow -Wpointer-arith -Wcast-align \ + -O2 -fipa-pta -pipe -ffunction-sections \ $(MACHDEP) CFLAGS += $(INCLUDE) -D__WIIU__ -D__WUT__ -D__WUPS__ diff --git a/source/main.cpp b/source/main.cpp index 8ab4f53..98e80ca 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -164,12 +164,27 @@ OSTime NTPGetTime(const char* hostname) } void updateTime() { + uint64_t roundtripStart = 0; + uint64_t roundtripEnd = 0; + + // Get the time from the server. + roundtripStart = OSGetTime(); OSTime time = NTPGetTime("pool.ntp.org"); // Connect to the time server. + roundtripEnd = OSGetTime(); if (time == 0) { return; // Probably didn't connect correctly. } + // Calculate the roundtrip time. + uint64_t roundtrip = roundtripEnd - roundtripStart; + + // Calculate the time it took to get the time from the server. + uint64_t timeTook = roundtrip / 2; + + // Subtract the time it took to get the time from the server. + time -= timeTook; + if (offsetHours < 0) { time -= OSSecondsToTicks(abs(offsetHours) * 60 * 60); } else { @@ -231,6 +246,7 @@ INITIALIZE_PLUGIN() { void syncingEnabled(ConfigItemBoolean *item, bool value) { + (void)item; // If false, bro is literally a time traveler! WUPS_StoreBool(nullptr, SYNCING_ENABLED_CONFIG_ID, value); enabledSync = value; @@ -238,24 +254,28 @@ void syncingEnabled(ConfigItemBoolean *item, bool value) void savingsEnabled(ConfigItemBoolean *item, bool value) { + (void)item; WUPS_StoreBool(nullptr, DST_ENABLED_CONFIG_ID, value); enabledDST = value; } void notifyEnabled(ConfigItemBoolean *item, bool value) { + (void)item; WUPS_StoreBool(nullptr, NOTIFY_ENABLED_CONFIG_ID, value); enabledNotify = value; } void onHourOffsetChanged(ConfigItemIntegerRange *item, int32_t offset) { + (void)item; WUPS_StoreInt(nullptr, OFFSET_HOURS_CONFIG_ID, offset); offsetHours = offset; } void onMinuteOffsetChanged(ConfigItemIntegerRange *item, int32_t offset) { + (void)item; WUPS_StoreInt(nullptr, OFFSET_MINUTES_CONFIG_ID, offset); offsetMinutes = offset; }