Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix game crashing on leap day (Feb 29th) #1814

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

Miigon
Copy link

@Miigon Miigon commented Feb 29, 2024

Since 0.4.8, the startingDate has been hardcoded to use the same date as real-life but with the year changed to 2019.

startingDate = LocalDateTime.of(
2019, // LocalDateTime.now().getYear(),
LocalDateTime.now().getMonth(),
LocalDateTime.now().getDayOfMonth(),
00,
00);

Because 2019 is not a leap year, this can cause issue when launching the game on a leap day (February 29th).

Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
	at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: java.time.DateTimeException: Invalid date 'February 29' as '2019' is not a leap year
	at java.base/java.time.LocalDate.create(LocalDate.java:459)
	at java.base/java.time.LocalDate.of(LocalDate.java:253)
	at java.base/java.time.LocalDateTime.of(LocalDateTime.java:238)
	at com.lilithsthrone.game.Game.<init>(Game.java:417)
	at com.lilithsthrone.main.Main.start(Main.java:489)
	at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
	at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
	at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
	at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
	at com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:184)
	... 1 more

This patch fixed this issue by changing the year to 2020, which IS a leap year.
This issue can alternatively be fixed by changing Feb 29 to Feb 28 if (for story-telling or whatever reason) the year being 2019 is absolutely required.
Or the real-life year can just be used instead.

to fix game crashing on leap year Feb 29.
@Moth-GITHUB
Copy link

lmao, this shit is so funny. even though this happens bug will happen once every 4 years I hope this patch gets added to the game.

@CognitiveMist
Copy link
Contributor

I think the alternate fix of changing Feb 29 to Feb 28 is most likely going to be the one that's selected, since that's already how birthdays are handled.

Originally, the game did use the real-life year, but some of the game lore involves characters who were adults in the 1980's still being alive, but that would also experience this issue, just in a slightly different way, due to the time jump during the prologue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants