Skip to content

Commit

Permalink
Merge branch 'master' into server
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightkingale authored Oct 5, 2023
2 parents 148f9c1 + d43f818 commit 379bab9
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
custom: "https://paypal.me/Nightkingale"
File renamed without changes.
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "docker"
directory: "/"
schedule:
interval: "daily"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
name: Wii_U_Time_Sync.wps
path: "*.wps"
if-no-files-found: error
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -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.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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__
Expand Down
20 changes: 20 additions & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -231,31 +246,36 @@ 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;
}

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;
}
Expand Down

0 comments on commit 379bab9

Please sign in to comment.