]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
sys: commenting and tidying
authorbones_was_here <bones_was_here@xonotic.au>
Tue, 2 Jan 2024 06:58:35 +0000 (16:58 +1000)
committerbones_was_here <bones_was_here@xonotic.au>
Wed, 3 Jan 2024 00:36:23 +0000 (10:36 +1000)
Signed-off-by: bones_was_here <bones_was_here@xonotic.au>
console.c
host.c
keys.c
makefile.inc
sys.h
sys_null.c [new file with mode: 0644]
sys_sdl.c
sys_shared.c
sys_unix.c [deleted file]

index 58409bef3164a3b9e012ea42b43a04ae8b5ae51d..f35645cc8ba034ddab9447929d62b95c2ab5fc82 100644 (file)
--- a/console.c
+++ b/console.c
@@ -930,8 +930,6 @@ void Con_Init (void)
        Cmd_AddCommand(CF_SHARED, "condump", Con_ConDump_f, "output console history to a file (see also log_file)");
 
        con_initialized = true;
-
-       Con_Print("Console initialized.\n");
 }
 
 void Con_Shutdown (void)
diff --git a/host.c b/host.c
index 3274be807cd098c522c2953c076f25092f7e3327..7c89c589f69f203e9de180eed8ea825b62b48fef 100644 (file)
--- a/host.c
+++ b/host.c
@@ -439,6 +439,7 @@ static void Host_Init (void)
        Memory_Init_Commands();
 
        // initialize console and logging and its cvars/commands
+       // this enables Con_Printf() messages to be coloured
        Con_Init();
 
        // initialize various cvars that could not be initialized earlier
diff --git a/keys.c b/keys.c
index fd0a24b202a07b64491ec1e2dc793db61e774676..4d7ed1749a14ad0d2f7c35c546d5346185934443 100644 (file)
--- a/keys.c
+++ b/keys.c
@@ -768,7 +768,7 @@ int Key_Parse_CommonKeys(cmd_state_t *cmd, qbool is_console, int key, int unicod
        if ((key == 'v' && KM_CTRL) || ((key == K_INS || key == K_KP_INS) && KM_SHIFT))
        {
                char *cbd, *p;
-               if ((cbd = Sys_GetClipboardData()) != 0)
+               if ((cbd = Sys_SDL_GetClipboardData()) != 0)
                {
                        int i;
 #if 1
index 2534cff705da601a3b61acbd5cb46d0c77557cf8..fc39741582424ff1b38354b9cf7f01f29f63949d 100644 (file)
@@ -126,7 +126,7 @@ OBJ_MENU= \
 # note that builddate.c is very intentionally not compiled to a .o before
 # being linked, because it should be recompiled every time an executable is
 # built to give the executable a proper date string
-OBJ_SV= builddate.c sys_unix.o vid_null.o thread_null.o $(OBJ_SND_NULL) $(OBJ_COMMON)
+OBJ_SV= builddate.c sys_null.o vid_null.o thread_null.o $(OBJ_SND_NULL) $(OBJ_COMMON)
 OBJ_SDL= builddate.c sys_sdl.o vid_sdl.o thread_sdl.o $(OBJ_MENU) $(OBJ_SND_COMMON) $(OBJ_SND_XMP) snd_sdl.o $(OBJ_VIDEO_CAPTURE) $(OBJ_COMMON)
 
 
diff --git a/sys.h b/sys.h
index 1b076a697f6fdb3ef4673111e533b4594394b664..119748ed8448c41ca241c3c012c37825389c3dfe 100644 (file)
--- a/sys.h
+++ b/sys.h
@@ -209,6 +209,7 @@ void Sys_Error (const char *error, ...) DP_FUNC_PRINTF(1) DP_FUNC_NORETURN;
 
 /// (may) output text to terminal which launched program
 void Sys_Print(const char *text);
+/// for the console to report failures inside Con_Printf()
 void Sys_Printf(const char *fmt, ...);
 
 /// INFO: This is only called by Host_Shutdown so we dont need testing for recursion
@@ -236,6 +237,7 @@ double Sys_DirtyTime(void);
 
 void Sys_ProvideSelfFD (void);
 
+/// Reads a line from POSIX stdin or the Windows console
 char *Sys_ConsoleInput (void);
 
 /// called to yield for a little bit so as not to hog cpu when paused or debugging
@@ -246,7 +248,7 @@ void Sys_SDL_Init(void);
 /// Perform Key_Event () callbacks until the input que is empty
 void Sys_SDL_HandleEvents(void);
 
-char *Sys_GetClipboardData (void);
+char *Sys_SDL_GetClipboardData (void);
 
 extern qbool sys_supportsdlgetticks;
 unsigned int Sys_SDL_GetTicks (void); // wrapper to call SDL_GetTicks
diff --git a/sys_null.c b/sys_null.c
new file mode 100644 (file)
index 0000000..e2b9b0a
--- /dev/null
@@ -0,0 +1,35 @@
+
+#include "darkplaces.h"
+
+
+// =======================================================================
+// General routines
+// =======================================================================
+
+void Sys_SDL_Shutdown(void)
+{
+}
+
+void Sys_SDL_Dialog(const char *title, const char *string)
+{
+}
+
+char *Sys_SDL_GetClipboardData (void)
+{
+       return NULL;
+}
+
+void Sys_SDL_Init(void)
+{
+}
+
+qbool sys_supportsdlgetticks = false;
+unsigned int Sys_SDL_GetTicks (void)
+{
+       Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
+       return 0;
+}
+void Sys_SDL_Delay (unsigned int milliseconds)
+{
+       Sys_Error("Called Sys_SDL_Delay on non-SDL target");
+}
index ce3d28cece51a03d9756697f2d5d7e331a8b07cc..a876b38885f8a1bac4e4c2a9db3939140ef6a787 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -1,8 +1,3 @@
-#ifdef WIN32
-#else
-#include <sys/time.h>
-#endif
-
 /*
  * Include this BEFORE darkplaces.h because it breaks wrapping
  * _Static_assert. Cloudwalk has no idea how or why so don't ask.
@@ -18,7 +13,6 @@
 #endif
 #endif
 
-sys_t sys;
 
 // =======================================================================
 // General routines
@@ -38,7 +32,7 @@ void Sys_SDL_Dialog(const char *title, const char *string)
                SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, string, NULL);
 }
 
-char *Sys_GetClipboardData (void)
+char *Sys_SDL_GetClipboardData (void)
 {
        char *data = NULL;
        char *cliptext;
index 5d19784daf45354765868ebdf13581026b75caf3..286ff7e5a80f1e13df408a3d3e470ea3b9ded7e1 100644 (file)
@@ -38,6 +38,8 @@
 #include "thread.h"
 #include "libcurl.h"
 
+sys_t sys;
+
 static char sys_timestring[128];
 char *Sys_TimeString(const char *timeformat)
 {
@@ -497,7 +499,7 @@ double Sys_Sleep(double time)
        }
 
        if(sys_debugsleep.integer)
-               Sys_Printf("sys_debugsleep: requesting %u ", microseconds);
+               Con_Printf("sys_debugsleep: requesting %u ", microseconds);
        dt = Sys_DirtyTime();
 
        // less important on newer libcurl so no need to disturb dedicated servers
@@ -552,10 +554,19 @@ double Sys_Sleep(double time)
 
        dt = Sys_DirtyTime() - dt;
        if(sys_debugsleep.integer)
-               Sys_Printf(" got %u oversleep %d\n", (unsigned int)(dt * 1000000), (unsigned int)(dt * 1000000) - microseconds);
+               Con_Printf(" got %u oversleep %d\n", (unsigned int)(dt * 1000000), (unsigned int)(dt * 1000000) - microseconds);
        return (dt < 0 || dt >= 1800) ? 0 : dt;
 }
 
+
+/*
+===============================================================================
+
+STDIO
+
+===============================================================================
+*/
+
 void Sys_Print(const char *text)
 {
 #ifdef __ANDROID__
@@ -590,6 +601,7 @@ void Sys_Print(const char *text)
 #endif
 }
 
+/// for the console to report failures inside Con_Printf()
 void Sys_Printf(const char *fmt, ...)
 {
        va_list argptr;
@@ -602,6 +614,7 @@ void Sys_Printf(const char *fmt, ...)
        Sys_Print(msg);
 }
 
+/// Reads a line from POSIX stdin or the Windows console
 char *Sys_ConsoleInput(void)
 {
        static char text[MAX_INPUTLINE];
@@ -663,6 +676,14 @@ char *Sys_ConsoleInput(void)
 }
 
 
+/*
+===============================================================================
+
+Startup and Shutdown
+
+===============================================================================
+*/
+
 void Sys_Error (const char *error, ...)
 {
        va_list argptr;
diff --git a/sys_unix.c b/sys_unix.c
deleted file mode 100644 (file)
index 78b6eeb..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-
-#ifdef WIN32
-#include <windows.h>
-#include <mmsystem.h>
-#else
-#include <sys/time.h>
-#endif
-
-#include "darkplaces.h"
-
-sys_t sys;
-
-// =======================================================================
-// General routines
-// =======================================================================
-void Sys_SDL_Shutdown(void)
-{
-}
-
-void Sys_SDL_Dialog(const char *title, const char *string)
-{
-}
-
-char *Sys_GetClipboardData (void)
-{
-       return NULL;
-}
-
-void Sys_SDL_Init(void)
-{
-}
-
-qbool sys_supportsdlgetticks = false;
-unsigned int Sys_SDL_GetTicks (void)
-{
-       Sys_Error("Called Sys_SDL_GetTicks on non-SDL target");
-       return 0;
-}
-void Sys_SDL_Delay (unsigned int milliseconds)
-{
-       Sys_Error("Called Sys_SDL_Delay on non-SDL target");
-}