From 859c0a4bea7b1802526d8880c69651b18ba5bc3c Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 4 Oct 2026 01:48:37 +0000 Subject: [PATCH 1/4] Fix time_t typedef redefinition in tu_timer.cpp Avoid redefining time_t on Windows (_WIN32), WebAssembly/Emscripten (__EMSCRIPTEN__), or platforms where _TIME_T_DEFINED / __time_t_defined are set. This resolves MSVC C3646/C2039 errors on Windows and type redefinition errors on WebAssembly. Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com> --- third_party/gameswf/base/tu_timer.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/third_party/gameswf/base/tu_timer.cpp b/third_party/gameswf/base/tu_timer.cpp index 9b1607a..29fe978 100644 --- a/third_party/gameswf/base/tu_timer.cpp +++ b/third_party/gameswf/base/tu_timer.cpp @@ -7,9 +7,10 @@ //Pete H - no sys/timeb in marmalade //#include // for ftime() -#ifndef _TIME_T -#define _TIME_T -typedef long time_t; +#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && \ + !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) + typedef long time_t; + #define _TIME_T_DEFINED #endif struct timeb { From e0582f3ccc648633001ce6ef31e42e7de42996cb Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 4 Oct 2026 01:54:04 +0000 Subject: [PATCH 2/4] Include in tu_timer.cpp to fix missing time_t definition Include system before the time_t typedef check so system headers declare time_t on Windows, Emscripten, macOS, and Linux platforms. Fixes time_t unknown type errors on MSVC and WebAssembly. Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com> --- third_party/gameswf/base/tu_timer.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/gameswf/base/tu_timer.cpp b/third_party/gameswf/base/tu_timer.cpp index 29fe978..f8f0015 100644 --- a/third_party/gameswf/base/tu_timer.cpp +++ b/third_party/gameswf/base/tu_timer.cpp @@ -7,6 +7,7 @@ //Pete H - no sys/timeb in marmalade //#include // for ftime() +#include #if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && \ !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) typedef long time_t; From 87d4eccaf273c75a54123b6df25240e494430237 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 4 Oct 2026 02:03:59 +0000 Subject: [PATCH 3/4] Fix tu_timer.cpp header inclusion and time_t typedef redefinition Include system and before the time_t guard block to ensure time_t is declared by standard headers across Windows, WebAssembly/Emscripten, macOS, and Linux. Populate struct timeb members in ftime() to prevent uninitialized garbage time values causing runtime assertion/SIGTRAP crashes. Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com> --- third_party/gameswf/base/tu_timer.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/third_party/gameswf/base/tu_timer.cpp b/third_party/gameswf/base/tu_timer.cpp index f8f0015..47e9ccd 100644 --- a/third_party/gameswf/base/tu_timer.cpp +++ b/third_party/gameswf/base/tu_timer.cpp @@ -8,8 +8,13 @@ //Pete H - no sys/timeb in marmalade //#include // for ftime() #include +#ifndef _WIN32 +#include +#endif + #if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && \ - !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) + !defined(_TIME_T_DEFINED) && !defined(__time_t_defined) && \ + !defined(_TIME_T) typedef long time_t; #define _TIME_T_DEFINED #endif @@ -21,7 +26,23 @@ struct timeb { short dstflag; /* [XSI] non-zero if DST in effect */ }; -void ftime (timeb* b) {} +void ftime (timeb* b) +{ + if (b) + { +#ifndef _WIN32 + struct timeval tv; + gettimeofday(&tv, 0); + b->time = (time_t) tv.tv_sec; + b->millitm = (unsigned short) (tv.tv_usec / 1000); +#else + b->time = time(NULL); + b->millitm = 0; +#endif + b->timezone = 0; + b->dstflag = 0; + } +} #include From 68de76d331519302b3914dc40924d70e1df77334 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 4 Oct 2026 02:13:03 +0000 Subject: [PATCH 4/4] Fix tu_timer.cpp header inclusion and ftime initialization Include system and in tu_timer.cpp so system definitions for time_t are available on Windows, Emscripten, macOS, and Linux. Populate struct timeb in ftime() and fallback s_start_time in get_ticks() to prevent uninitialized memory arithmetic crashes. Co-authored-by: ClausValcaTD <193546948+ClausValcaTD@users.noreply.github.com> --- third_party/gameswf/base/tu_timer.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/third_party/gameswf/base/tu_timer.cpp b/third_party/gameswf/base/tu_timer.cpp index 47e9ccd..a57b889 100644 --- a/third_party/gameswf/base/tu_timer.cpp +++ b/third_party/gameswf/base/tu_timer.cpp @@ -58,7 +58,11 @@ Uint32 tu_timer::get_ticks() { struct timeb tv; ftime(&tv); - return (tv.time - s_start_time.time) * 1000 + (tv.millitm - s_start_time.millitm); + if (s_start_time.time == 0) + { + s_start_time = tv; + } + return (Uint32) ((tv.time - s_start_time.time) * 1000 + (tv.millitm - s_start_time.millitm)); } tu_datetime::tu_datetime()