diff options
| author | fusion32 <marcopuzziello@gmail.com> | 2025-05-25 22:37:57 -0300 |
|---|---|---|
| committer | fusion32 <marcopuzziello@gmail.com> | 2025-05-25 22:37:57 -0300 |
| commit | ad8213f35523cbb07f418ae275af448a47cc0288 (patch) | |
| tree | 4d77b8ff2b44461734b5a2cbaad5402b4a94736f /src/time.cc | |
| parent | 5f883a80175a4cc9abda9d647a6a0d73bda84878 (diff) | |
| download | game-ad8213f35523cbb07f418ae275af448a47cc0288.tar.gz game-ad8213f35523cbb07f418ae275af448a47cc0288.zip | |
linux Makefile + fix most compilation problems
I wanted to see if the compiler had any problems with the code
so far and added a few stub definitions so that each file would
properly compile. We still fail when linking but we're able to to
find and fix compile time errors.
Diffstat (limited to 'src/time.cc')
| -rw-r--r-- | src/time.cc | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/time.cc b/src/time.cc index 4e743ed..0003c39 100644 --- a/src/time.cc +++ b/src/time.cc @@ -1,5 +1,7 @@ #include "common.hh" +#include <time.h> + // IMPORTANT(fusion): `RoundNr` is just the number of seconds since startup which // is why `GetRoundAtTime` and `GetRoundForNextMinute` straight up uses it as // seconds. It is incremented every 1 second inside `AdvanceGame`. @@ -38,7 +40,7 @@ void GetDate(int *Year, int *Cycle, int *Day){ // NOTE(fusion): This maps each real time week to a game time year. time_t RealTime = time(NULL); struct tm LocalTime = GetLocalTimeTM(RealTime); - *Year = ((T / 86400) + 4) / 7 + *Year = (int)(((RealTime / 86400) + 4) / 7); *Cycle = LocalTime.tm_wday; *Day = LocalTime.tm_hour; } @@ -79,7 +81,7 @@ void GetAmbiente(int *Brightness, int *Color){ } uint32 GetRoundAtTime(int Hour, int Minute){ - struct tm LocalTime = GetLocalTimeTM(RealTime); + struct tm LocalTime = GetLocalTimeTM(time(NULL)); int SecondsToTime = (Hour - LocalTime.tm_hour) * 3600 + (Minute - LocalTime.tm_min) * 60 + (0 - LocalTime.tm_sec); @@ -90,7 +92,7 @@ uint32 GetRoundAtTime(int Hour, int Minute){ } uint32 GetRoundForNextMinute(void){ - struct tm LocalTime = GetLocalTimeTM(RealTime); + struct tm LocalTime = GetLocalTimeTM(time(NULL)); int SecondsToNextMinute = 60 - LocalTime.tm_sec; return SecondsToNextMinute + RoundNr + 30; } |
