From a4483f131d5e875f18d45005bc7eeff833626a10 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@users.noreply.github.com>
Date: Tue, 5 Nov 2019 20:07:16 +0100
Subject: [PATCH] - Printf related cleanup.

---
 source/blood/CMakeLists.txt             |  2 ++
 source/build/src/sdlayer.cpp            | 43 +++---------------------
 source/common/console/c_cvars.cpp       |  8 +----
 source/common/console/c_dispatch.cpp    |  5 +++
 source/common/console/c_dispatch.h      |  4 +--
 source/common/filesystem/file_zip.cpp   | 14 ++++----
 source/common/fonts/v_font.cpp          | 10 +++---
 source/common/gamecontrol.cpp           | 44 +++++++++++++++++++++++++
 source/duke3d/CMakeLists.txt            |  2 ++
 source/duke3d/src/demo.cpp              |  5 +--
 source/duke3d/src/game.cpp              | 28 +---------------
 source/duke3d/src/gameexec.h            |  4 +--
 source/duke3d/src/gamevars.cpp          |  2 --
 source/platform/macos/i_specialpaths.mm |  2 +-
 source/platform/win32/winbits.cpp       | 44 -------------------------
 source/rr/CMakeLists.txt                |  2 ++
 source/rr/src/game.cpp                  | 21 ------------
 source/rr/src/game.h                    |  1 -
 source/rr/src/gameexec.h                |  3 +-
 source/sw/CMakeLists.txt                |  2 ++
 20 files changed, 86 insertions(+), 160 deletions(-)

diff --git a/source/blood/CMakeLists.txt b/source/blood/CMakeLists.txt
index 7203e11b4..31cdbdfbf 100644
--- a/source/blood/CMakeLists.txt
+++ b/source/blood/CMakeLists.txt
@@ -22,6 +22,8 @@ include_directories(
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/console
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
 	${CMAKE_CURRENT_SOURCE_DIR}/../platform
 )
 
diff --git a/source/build/src/sdlayer.cpp b/source/build/src/sdlayer.cpp
index 0c1f92b38..d70d7c509 100644
--- a/source/build/src/sdlayer.cpp
+++ b/source/build/src/sdlayer.cpp
@@ -31,13 +31,12 @@
 #include "inputstate.h"
 #include "c_cvars.h"
 #include "i_time.h"
+#include "c_dispatch.h"
 #ifndef NETCODE_DISABLE
 #include "enet.h"
 #endif
 #include "../../glbackend/glbackend.h"
 
-bool gHaveNetworking;
-
 #ifdef USE_OPENGL
 # include "glbuild.h"
 # include "glsurface.h"
@@ -130,8 +129,6 @@ static SDL_Surface *appicon = NULL;
 static SDL_Surface *loadappicon(void);
 #endif
 
-static mutex_t m_initprintf;
-
 // Joystick dead and saturation zones
 uint16_t joydead[9], joysatur[9];
 
@@ -391,6 +388,7 @@ static void sighandler(int signum)
 }
 #endif
 
+int GameMain();
 
 #ifdef _WIN32
 
@@ -453,34 +451,7 @@ int main(int argc, char *argv[])
 
 	if (initsystem()) Bexit(9);
 
-	try
-	{
-		// Write to the DOCUMENTS directory, not the game directory
-
-		// Initialize the netcode here, because enet pulls in a lot of headers that pollute the namespace.
-#ifndef NETCODE_DISABLE
-		gHaveNetworking = !enet_initialize();
-		if (!gHaveNetworking)
-			initprintf("An error occurred while initializing ENet.\n");
-#endif
-
-		FString logpath = M_GetDocumentsPath() + "demolition.log";
-		OSD_SetLogFile(logpath);
-		r = CONFIG_Init();
-	}
-	catch (const std::runtime_error & err)
-	{
-		wm_msgbox("Error", "%s", err.what());
-		return 3;
-	}
-	catch (const ExitEvent & exit)
-	{
-		// Just let the rest of the function execute.
-		r = exit.Reason();
-	}
-#ifndef NETCODE_DISABLE
-	if (gHaveNetworking) enet_deinitialize();
-#endif
+	r = GameMain();
 
 #if defined(HAVE_GTK2)
     gtkbuild_exit(r);
@@ -539,6 +510,7 @@ int32_t sdlayer_checkversion(void);
 #if SDL_MAJOR_VERSION != 1
 int32_t sdlayer_checkversion(void)
 {
+#if 0
     SDL_version compiled;
 
     SDL_GetVersion(&linked);
@@ -559,6 +531,7 @@ int32_t sdlayer_checkversion(void)
         return -1;
     }
 
+#endif
     return 0;
 }
 
@@ -569,12 +542,6 @@ int32_t initsystem(void)
 {
     const int sdlinitflags = SDL_INIT_VIDEO;
 
-    mutex_init(&m_initprintf);
-
-#ifdef _WIN32
-    win_init();
-#endif
-
     if (sdlayer_checkversion())
         return -1;
 
diff --git a/source/common/console/c_cvars.cpp b/source/common/console/c_cvars.cpp
index 5022de8ca..66f709d0b 100644
--- a/source/common/console/c_cvars.cpp
+++ b/source/common/console/c_cvars.cpp
@@ -43,14 +43,8 @@
 
 #include "cmdlib.h"
 #include "c_dispatch.h"
+#include "printf.h"
 
-//#include "g_game.h"
-//#include "d_player.h"
-//#include "v_video.h"
-//#include "d_netinf.h"
-
-//#include "menu/menu.h"
-//#include "vm.h"
 
 struct FLatchedValue
 {
diff --git a/source/common/console/c_dispatch.cpp b/source/common/console/c_dispatch.cpp
index 02f93fc18..b8831c1fc 100644
--- a/source/common/console/c_dispatch.cpp
+++ b/source/common/console/c_dispatch.cpp
@@ -865,6 +865,11 @@ FExecList *C_ParseCmdLineParams(FExecList *exec)
 	return exec;
 }
 
+void FConsoleCommand::PrintCommand() 
+{ 
+	Printf("%s\n", m_Name.GetChars()); 
+}
+
 bool FConsoleCommand::IsAlias ()
 {
 	return false;
diff --git a/source/common/console/c_dispatch.h b/source/common/console/c_dispatch.h
index a8668b288..2e8e53753 100644
--- a/source/common/console/c_dispatch.h
+++ b/source/common/console/c_dispatch.h
@@ -34,7 +34,7 @@
 #ifndef __C_DISPATCH_H__
 #define __C_DISPATCH_H__
 
-#include "printf.h"
+#include "c_console.h"
 #include "zstring.h"
 #include "c_commandline.h"
 #include "zstring.h"
@@ -87,7 +87,7 @@ public:
 	FConsoleCommand (const char *name, CCmdRun RunFunc);
 	virtual ~FConsoleCommand ();
 	virtual bool IsAlias ();
-	void PrintCommand () { Printf ("%s\n", m_Name.GetChars()); }
+	void PrintCommand();
 
 	virtual void Run (FCommandLine &args, void *instigator, int key);
 	static FConsoleCommand* FindByName (const char* name);
diff --git a/source/common/filesystem/file_zip.cpp b/source/common/filesystem/file_zip.cpp
index ac807ff09..7fc92993e 100644
--- a/source/common/filesystem/file_zip.cpp
+++ b/source/common/filesystem/file_zip.cpp
@@ -35,7 +35,7 @@
 
 #include <time.h>
 #include <algorithm>
-#include "osd.h"
+#include "printf.h"
 #include "file_zip.h"
 #include "ancientzip.h"
 #include "templates.h"
@@ -96,7 +96,7 @@ static bool UncompressZipLump(char *Cache, FileReader &Reader, int Method, int L
 	}
 	catch (const std::runtime_error &err)
 	{
-		OSD_Printf("%s\n", err.what());
+		Printf("%s\n", err.what());
 		return false;
 	}
 	return true;
@@ -181,7 +181,7 @@ bool FZipFile::Open(bool quiet)
 
 	if (centraldir == 0)
 	{
-		if (!quiet) OSD_Printf("\n%s: ZIP file corrupt!\n", FileName.GetChars());
+		if (!quiet) Printf("\n%s: ZIP file corrupt!\n", FileName.GetChars());
 		return false;
 	}
 
@@ -193,7 +193,7 @@ bool FZipFile::Open(bool quiet)
 	if (info.NumEntries != info.NumEntriesOnAllDisks ||
 		info.FirstDisk != 0 || info.DiskNumber != 0)
 	{
-		if (!quiet) OSD_Printf("\n%s: Multipart Zip files are not supported.\n", FileName.GetChars());
+		if (!quiet) Printf("\n%s: Multipart Zip files are not supported.\n", FileName.GetChars());
 		return false;
 	}
 
@@ -226,7 +226,7 @@ bool FZipFile::Open(bool quiet)
 		if (dirptr > ((char*)directory) + dirsize)	// This directory entry goes beyond the end of the file.
 		{
 			free(directory);
-			if (!quiet) OSD_Printf("\n%s: Central directory corrupted.", FileName.GetChars());
+			if (!quiet) Printf("\n%s: Central directory corrupted.", FileName.GetChars());
 			return false;
 		}
 		
@@ -246,7 +246,7 @@ bool FZipFile::Open(bool quiet)
 			zip_fh->Method != METHOD_IMPLODE &&
 			zip_fh->Method != METHOD_SHRINK)
 		{
-			if (!quiet) OSD_Printf("\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", FileName.GetChars(), name.GetChars(), zip_fh->Method);
+			if (!quiet) Printf("\n%s: '%s' uses an unsupported compression algorithm (#%d).\n", FileName.GetChars(), name.GetChars(), zip_fh->Method);
 			skipped++;
 			continue;
 		}
@@ -254,7 +254,7 @@ bool FZipFile::Open(bool quiet)
 		zip_fh->Flags = LittleShort(zip_fh->Flags);
 		if (zip_fh->Flags & ZF_ENCRYPTED)
 		{
-			if (!quiet) OSD_Printf("\n%s: '%s' is encrypted. Encryption is not supported.\n", FileName.GetChars(), name.GetChars());
+			if (!quiet) Printf("\n%s: '%s' is encrypted. Encryption is not supported.\n", FileName.GetChars(), name.GetChars());
 			skipped++;
 			continue;
 		}
diff --git a/source/common/fonts/v_font.cpp b/source/common/fonts/v_font.cpp
index 3354373db..a0d910573 100644
--- a/source/common/fonts/v_font.cpp
+++ b/source/common/fonts/v_font.cpp
@@ -713,16 +713,18 @@ void V_InitFonts()
 	FFont *CreateHexLumpFont(const char *fontname, const char* lump);
 	FFont *CreateHexLumpFont2(const char *fontname, const char * lump);
 
-	auto lump = kopenFileReader("newconsolefont.hex", 0);	// This is always loaded from gzdoom.pk3 to prevent overriding it with incomplete replacements.
-	if (!lump.isOpen()) I_Error("newconsolefont.hex not found");	// This font is needed - do not start up without it.
-	NewConsoleFont = CreateHexLumpFont("NewConsoleFont", "newconsolefont.hex");
-	NewSmallFont = CreateHexLumpFont2("NewSmallFont", "newconsolefont.hex");
+	if (fileSystem.FindFile("demolition/newconsolefont.hex") < 0)
+		I_Error("newconsolefont.hex not found");	// This font is needed - do not start up without it.
+	NewConsoleFont = CreateHexLumpFont("NewConsoleFont", "demolition/newconsolefont.hex");
+	NewSmallFont = CreateHexLumpFont2("NewSmallFont", "demolition/newconsolefont.hex");
 	CurrentConsoleFont = NewConsoleFont;
 
+	/*
 	ConFont = V_GetFont("ConsoleFont", "CONFONT");
 	{
 		ConFont = SmallFont;
 	}
+	*/
 }
 
 void V_ClearFonts()
diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp
index d87ce7628..5125df0bf 100644
--- a/source/common/gamecontrol.cpp
+++ b/source/common/gamecontrol.cpp
@@ -17,12 +17,21 @@
 #include "rts.h"
 #include "printf.h"
 #include "c_bind.h"
+#include "v_font.h"
+#include "c_console.h"
+#include "c_dispatch.h"
+#include "i_specialpaths.h"
+#ifndef NETCODE_DISABLE
+#include "enet.h"
+#endif
 
 InputState inputState;
 void SetClipshapes();
 int ShowStartupWindow(TArray<GrpEntry> &);
 void InitFileSystem(TArray<GrpEntry>&);
 int globalShadeDiv;
+bool gHaveNetworking;
+
 
 FString currentGame;
 FString LumpFilter;
@@ -221,6 +230,40 @@ void CheckFrontend(int flags)
 }
 
 
+int GameMain()
+{
+	// Set up the console before anything else so that it can receive text.
+	C_InitConsole(1024, 768, true);
+	FStringf logpath("logfile %sdemolition.log", M_GetDocumentsPath());
+	C_DoCommand(logpath);
+
+#ifndef NETCODE_DISABLE
+	gHaveNetworking = !enet_initialize();
+	if (!gHaveNetworking)
+		initprintf("An error occurred while initializing ENet.\n");
+#endif
+
+	int r;
+	try
+	{
+		r = CONFIG_Init();
+	}
+	catch (const std::runtime_error & err)
+	{
+		wm_msgbox("Error", "%s", err.what());
+		return 3;
+	}
+	catch (const ExitEvent & exit)
+	{
+		// Just let the rest of the function execute.
+		r = exit.Reason();
+	}
+#ifndef NETCODE_DISABLE
+	if (gHaveNetworking) enet_deinitialize();
+#endif
+	return r;
+}
+
 //==========================================================================
 //
 //
@@ -342,6 +385,7 @@ int CONFIG_Init()
 	{
 		playername = userConfig.CommandName;
 	}
+	V_InitFonts();
 
 
 
diff --git a/source/duke3d/CMakeLists.txt b/source/duke3d/CMakeLists.txt
index 9d93f0abd..d2b7d8406 100644
--- a/source/duke3d/CMakeLists.txt
+++ b/source/duke3d/CMakeLists.txt
@@ -22,6 +22,8 @@ include_directories(
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/console
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
 	${CMAKE_CURRENT_SOURCE_DIR}/../platform
 )
 
diff --git a/source/duke3d/src/demo.cpp b/source/duke3d/src/demo.cpp
index 53cb787a8..20a482d5b 100644
--- a/source/duke3d/src/demo.cpp
+++ b/source/duke3d/src/demo.cpp
@@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 #include "savegame.h"
 #include "screens.h"
 #include "i_specialpaths.h"
+#include "printf.h"
 
 #include "vfs.h"
 
@@ -104,7 +105,7 @@ static int32_t G_OpenDemoRead(int32_t g_whichDemo) // 0 = mine
     i = sv_loadsnapshot(g_demo_recFilePtr, -g_whichDemo, &saveh);
     if (i)
     {
-        OSD_Printf(OSD_ERROR "There were errors opening demo %d (code: %d).\n", g_whichDemo, i);
+        Printf(OSD_ERROR "There were errors opening demo %d (code: %d).\n", g_whichDemo, i);
         g_demo_recFilePtr.Close();
         return 0;
     }
@@ -183,7 +184,7 @@ void G_OpenDemoWrite(void)
     {
         MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
 error_wopen_demo:
-        Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
+        Bstrcpy(apStrings[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE CONSOLE FOR DETAILS.");
         P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
         ud.recstat = ud.m_recstat = 0;
         return;
diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp
index add0bd14e..fcd954a02 100644
--- a/source/duke3d/src/game.cpp
+++ b/source/duke3d/src/game.cpp
@@ -5710,7 +5710,6 @@ void G_Shutdown(void)
     CONTROL_Shutdown();
     engineUnInit();
     G_Cleanup();
-    OSD_Cleanup();
     Bfflush(NULL);
 }
 
@@ -6469,33 +6468,8 @@ MAIN_LOOP_RESTART:
         // only allow binds to function if the player is actually in a game (not in a menu, typing, et cetera) or demo
         inputState.SetBindsEnabled(!!(myplayer.gm & (MODE_GAME|MODE_DEMO)));
 
-#ifndef _WIN32
-        // stdin -> OSD input for dedicated server
-        if (g_networkMode == NET_DEDICATED_SERVER)
-        {
-            int32_t nb;
-            char ch;
-            static uint32_t bufpos = 0;
-            static char buf[128];
-#ifndef GEKKO
-            int32_t flag = 1;
-            ioctl(0, FIONBIO, &flag);
-#endif
-            if ((nb = read(0, &ch, 1)) > 0 && bufpos < sizeof(buf))
-            {
-                if (ch != '\n')
-                    buf[bufpos++] = ch;
 
-                if (ch == '\n' || bufpos >= sizeof(buf)-1)
-                {
-                    buf[bufpos] = 0;
-                    OSD_Dispatch(buf);
-                    bufpos = 0;
-                }
-            }
-        }
-        else
-#endif
+        if (g_networkMode != NET_DEDICATED_SERVER)
             G_HandleLocalKeys();
 
         OSD_DispatchQueued();
diff --git a/source/duke3d/src/gameexec.h b/source/duke3d/src/gameexec.h
index c57c40a9b..513672223 100644
--- a/source/duke3d/src/gameexec.h
+++ b/source/duke3d/src/gameexec.h
@@ -104,6 +104,7 @@ static inline void VM_DrawTilePalSmall(int32_t x, int32_t y, int32_t tilenum, in
 void VM_DrawTileSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int32_t orientation);
 #endif
 
+
 #define CON_ERRPRINTF(Text, ...) do { \
     vm.flags |= VM_RETURN; \
     OSD_Printf("Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
@@ -111,8 +112,7 @@ void VM_DrawTileSmall(int32_t x, int32_t y, int32_t tilenum, int32_t shade, int3
 
 #define CON_CRITICALERRPRINTF(Text, ...) do { \
     vm.flags |= VM_RETURN; \
-    OSD_Printf("Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
-    wm_msgbox(APPNAME, "Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
+    I_Error("Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
 } while (0)
 
 void G_GetTimeDate(int32_t * pValues);
diff --git a/source/duke3d/src/gamevars.cpp b/source/duke3d/src/gamevars.cpp
index a3adeceb3..e27a7da4a 100644
--- a/source/duke3d/src/gamevars.cpp
+++ b/source/duke3d/src/gamevars.cpp
@@ -342,8 +342,6 @@ void Gv_ResetVars(void) /* this is called during a new game and nowhere else */
 {
     Gv_Free();
 
-    osd->log.errors = 0;
-
     for (auto &aGameVar : aGameVars)
     {
         if (aGameVar.szLabel != NULL)
diff --git a/source/platform/macos/i_specialpaths.mm b/source/platform/macos/i_specialpaths.mm
index 55522acf2..59179f400 100644
--- a/source/platform/macos/i_specialpaths.mm
+++ b/source/platform/macos/i_specialpaths.mm
@@ -36,9 +36,9 @@
 #import <Foundation/NSFileManager.h>
 
 #include "cmdlib.h"
-#include "m_misc.h"
 #include "version.h"	// for GAMENAME
 
+FString M_GetMacAppSupportPath(const bool create);
 
 static FString GetSpecialPath(const NSSearchPathDirectory kind, const BOOL create = YES, const NSSearchPathDomainMask domain = NSUserDomainMask)
 {
diff --git a/source/platform/win32/winbits.cpp b/source/platform/win32/winbits.cpp
index 1633391a3..dd6f632dd 100644
--- a/source/platform/win32/winbits.cpp
+++ b/source/platform/win32/winbits.cpp
@@ -14,50 +14,6 @@ FString progdir;
 // CheckWinVersion() -- check to see what version of Windows we happen to be running under (stripped down to what is actually still supported.)
 //
 
-void win_init(void)
-{
-    const char *ver = "";
-	OSVERSIONINFOEXA osv;
-
-	osv.dwOSVersionInfoSize  = sizeof(osv);
-	GetVersionExA((LPOSVERSIONINFOA)&osv);
-	
-    switch (osv.dwPlatformId)
-    {
-        case VER_PLATFORM_WIN32_NT:
-            switch (osv.dwMajorVersion)
-            {
-                case 6:
-                    switch (osv.dwMinorVersion)
-                    {
-                        case 0: ver = osv.wProductType == VER_NT_WORKSTATION ? "Vista" : "Server 2008"; break;
-                        case 1: ver = osv.wProductType == VER_NT_WORKSTATION ? "7" : "Server 2008 R2"; break;
-                        case 2: ver = osv.wProductType == VER_NT_WORKSTATION ? "8" : "Server 2012"; break;
-                        case 3: ver = osv.wProductType == VER_NT_WORKSTATION ? "8.1" : "Server 2012 R2"; break;
-                    }
-                    break;
-
-                case 10:
-                    switch (osv.dwMinorVersion)
-                    {
-                        case 0: ver = osv.wProductType == VER_NT_WORKSTATION ? "10" : "Server 2016"; break;
-                    }
-                    break;
-            }
-            break;
-    }
-
-	FStringf str("Windows %s", ver);
-
-    // service packs
-    if (osv.szCSDVersion[0])
-    {
-		str.AppendFormat(" %s", osv.szCSDVersion);
-    }
-
-    initprintf("Running on %s (build %lu.%lu.%lu)\n", str.GetChars(), osv.dwMajorVersion, osv.dwMinorVersion, osv.dwBuildNumber);
-}
-
 //==========================================================================
 //
 // win_buildargs
diff --git a/source/rr/CMakeLists.txt b/source/rr/CMakeLists.txt
index e503f5b0c..f9f00b1ea 100644
--- a/source/rr/CMakeLists.txt
+++ b/source/rr/CMakeLists.txt
@@ -22,6 +22,8 @@ include_directories(
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/console
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
 	${CMAKE_CURRENT_SOURCE_DIR}/../platform
 )
 
diff --git a/source/rr/src/game.cpp b/source/rr/src/game.cpp
index 1ad8508ee..36a8a1e31 100644
--- a/source/rr/src/game.cpp
+++ b/source/rr/src/game.cpp
@@ -7078,7 +7078,6 @@ void G_Shutdown(void)
     G_SetFog(0);
     engineUnInit();
     G_Cleanup();
-    OSD_Cleanup();
     Bfflush(NULL);
 }
 
@@ -7878,26 +7877,6 @@ MAIN_LOOP_RESTART:
         // stdin -> OSD input for dedicated server
         if (g_networkMode == NET_DEDICATED_SERVER)
         {
-            int32_t nb;
-            char ch;
-            static uint32_t bufpos = 0;
-            static char buf[128];
-#ifndef GEKKO
-            int32_t flag = 1;
-            ioctl(0, FIONBIO, &flag);
-#endif
-            if ((nb = read(0, &ch, 1)) > 0 && bufpos < sizeof(buf))
-            {
-                if (ch != '\n')
-                    buf[bufpos++] = ch;
-
-                if (ch == '\n' || bufpos >= sizeof(buf)-1)
-                {
-                    buf[bufpos] = 0;
-                    OSD_Dispatch(buf);
-                    bufpos = 0;
-                }
-            }
         }
         else
 #endif
diff --git a/source/rr/src/game.h b/source/rr/src/game.h
index 83b72377f..b2ed285d4 100644
--- a/source/rr/src/game.h
+++ b/source/rr/src/game.h
@@ -289,7 +289,6 @@ void G_PrintGameQuotes(int32_t snum);
 void G_SetCrosshairColor(int32_t r,int32_t g,int32_t b);
 void G_Shutdown(void);
 void G_UpdatePlayerFromMenu(void);
-void M32RunScript(const char *s);
 void P_DoQuote(int32_t q,DukePlayer_t *p);
 void P_SetGamePalette(DukePlayer_t *player, uint32_t palid, int32_t set);
 void G_OnMotorcycle(DukePlayer_t *pPlayer, int spriteNum);
diff --git a/source/rr/src/gameexec.h b/source/rr/src/gameexec.h
index 7c6bda7d0..763d955f0 100644
--- a/source/rr/src/gameexec.h
+++ b/source/rr/src/gameexec.h
@@ -54,8 +54,7 @@ int32_t __fastcall G_GetAngleDelta(int32_t currAngle, int32_t newAngle);
 } while (0)
 
 #define CON_CRITICALERRPRINTF(Text, ...) do { \
-    OSD_Printf("Line %d, %s: " Text, g_errorLineNum, VM_GetKeywordForID(g_tw), ## __VA_ARGS__); \
-    wm_msgbox(APPNAME, "Line %d, %s: " Text, g_errorLineNum, VM_GetKeywordForID(g_tw), ## __VA_ARGS__); \
+    I_Error("Line %d, %s: " Text, VM_DECODE_LINE_NUMBER(g_tw), VM_GetKeywordForID(VM_DECODE_INST(g_tw)), ## __VA_ARGS__); \
 } while (0)
 
 void G_GetTimeDate(int32_t * pValues);
diff --git a/source/sw/CMakeLists.txt b/source/sw/CMakeLists.txt
index 45f51b7f5..bd1f829f5 100644
--- a/source/sw/CMakeLists.txt
+++ b/source/sw/CMakeLists.txt
@@ -22,6 +22,8 @@ include_directories(
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/utility
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/console
 	${CMAKE_CURRENT_SOURCE_DIR}/../common/textures
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/fonts
+	${CMAKE_CURRENT_SOURCE_DIR}/../common/2d
 	${CMAKE_CURRENT_SOURCE_DIR}/../platform
 )