From c39237f39bf682d01f0d0e8f62ca01c873a79c06 Mon Sep 17 00:00:00 2001
From: Miloslav Ciz <drummyfish@disroot.org>
Date: Mon, 10 Mar 2025 22:05:37 +0100
Subject: [PATCH] Add number logs

---
 game.h     | 30 +++++++++++++++++++++++++++++-
 map.h      |  3 ++-
 renderer.h |  5 ++++-
 3 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/game.h b/game.h
index 2f90694..63c4e4b 100644
--- a/game.h
+++ b/game.h
@@ -173,17 +173,44 @@ uint8_t LCR_gameGetNextAudioSample(void);
 #define LCR_LOG1(s) ;
 #define LCR_LOG2(s) ;
 
+#define LCR_LOG0_NUM(x) ;
+#define LCR_LOG1_NUM(x) ;
+#define LCR_LOG2_NUM(x) ;
+
 #if LCR_SETTING_LOG_LEVEL > 0
+
+void _LCR_logNum(uint32_t n)
+{
+  char s[9];
+
+  s[8] = 0;
+
+  for (int i = 7; i >= 0; --i)
+  {
+    s[i] = n % 16;
+    s[i] = s[i] < 10 ? ('0' + s[i]) : ('a' - 10 + s[i]);
+    n /= 16;
+  }
+
+  LCR_log(s);
+}
+
   #undef LCR_LOG0
+  #undef LCR_LOG0_NUM
   #define LCR_LOG0(s) LCR_log(s);
+  #define LCR_LOG0_NUM(x) _LCR_logNum(x);
 
   #if LCR_SETTING_LOG_LEVEL > 1
     #undef LCR_LOG1
+    #undef LCR_LOG1_NUM
     #define LCR_LOG1(s) LCR_log(s);
+    #define LCR_LOG1_NUM(x) _LCR_logNum(x);
 
     #if LCR_SETTING_LOG_LEVEL > 2
       #undef LCR_LOG2
+      #undef LCR_LOG2_NUM
       #define LCR_LOG2(s) LCR_log(s);
+      #define LCR_LOG2_NUM(x) _LCR_logNum(x);
     #endif
   #endif
 #endif
@@ -1558,7 +1585,8 @@ uint8_t LCR_gameStep(uint32_t time)
     else if (events & LCR_RACING_EVENT_FINISHED &&
       LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
     {
-      LCR_LOG1("finished");
+      LCR_LOG1("finished, time:");
+      LCR_LOG1_NUM(LCR_game.runTime);
 
       if (LCR_game.runTime <= LCR_currentMap.targetTime &&
         !LCR_racing.playingReplay)
diff --git a/map.h b/map.h
index 768feb1..dfac4d5 100644
--- a/map.h
+++ b/map.h
@@ -696,7 +696,8 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name)
 
   _LCR_mapComputeHash();
 
-  LCR_LOG2("map loaded")
+  LCR_LOG1("map loaded, block count:")
+  LCR_LOG1_NUM(LCR_currentMap.blockCount)
 
   LCR_mapReset();
 
diff --git a/renderer.h b/renderer.h
index 36383b2..7043ce8 100644
--- a/renderer.h
+++ b/renderer.h
@@ -1001,7 +1001,10 @@ uint8_t _LCR_buildMapModel(void)
   }
 
   _LCR_cullHiddenMapTris();
-  LCR_LOG1("map model built");
+  LCR_LOG1("map model built, verts/tris:");
+  LCR_LOG1_NUM(LCR_renderer.mapModel.triangleCount);
+  LCR_LOG1_NUM(LCR_renderer.mapModel.vertexCount);
+
   return 1;
 }