From 13ec4a87d36e18586142390632106eb85040d9ab Mon Sep 17 00:00:00 2001
From: kai <kai@zittrig.eu>
Date: Thu, 2 Apr 2020 19:07:13 +0100
Subject: enneract approved codeā„¢ for G_admin_isconsoleaschacht
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/game/g_admin.c | 37 +++++++++----------------------------
 1 file changed, 9 insertions(+), 28 deletions(-)

diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 12c50b2..cb1c36d 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -1089,38 +1089,19 @@ char* G_admin_adminPrintName( gentity_t *ent )
 }
 
 qboolean G_admin_isconsoleaschacht( void ){
-  time_t t;
-  struct tm *actual_time_tm;
-  char day_s[ 10 ];
-  int day;
-
-  time( &t ); // what's the time
-
-  actual_time_tm = localtime( &t ); // whats the local time
-
-  strftime( day_s, sizeof( day_s ), "%d", actual_time_tm ); // i just need the actual day number
+  qtime_t qt;
 
-  sscanf( day_s, "%d", &day ); // now convert it to an integer for the below logic
+  trap_RealTime( &qt );
 
-  // G_Printf( "Day is (string): %s, day is (int) %i\n", day_s, day ); // debug
+  // G_Printf( "Day is %i (integer)\n", qt.tm_mday ); // debug
 
-  if( day < 15 ){
-    if( g_consoleIsASchacht.integer == day ) {
-      return qfalse;
-    }
-    else
-    {
-      return qtrue;
-    }
+  if( qt.tm_mday < 15 )
+  {
+    return g_consoleIsASchacht.integer != qt.tm_mday;
   } 
-  else if( day >= 15 ){
-    if( g_consoleIsASchacht.integer == ceil( day / 3 ) ){
-      return qfalse;
-    }
-    else
-    {
-      return qtrue;
-    }
+  else
+  {
+    return g_consoleIsASchacht.integer != ceil( qt.tm_mday / 3.0f );
   }
 }
 
-- 
cgit