Skip to content

Commit 1443c28

Browse files
committed
Fixed Linux server startup error message formatting
1 parent b8868f7 commit 1443c28

File tree

4 files changed

+33
-18
lines changed

4 files changed

+33
-18
lines changed

MTA10_Server/core/CDynamicLibrary.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ bool CDynamicLibrary::Load ( const char* szFilename )
9595
if ( szError )
9696
Print ( "%s\n", szError );
9797
else
98-
printf ( "Loading %s failed\n", szFilename );
98+
Print ( "Loading %s failed\n", szFilename );
9999
}
100100
#endif
101101

@@ -160,7 +160,7 @@ FuncPtr_t CDynamicLibrary::GetProcedureAddress ( const char* szProcName )
160160

161161
bool CDynamicLibrary::CheckMtaVersion( const char* szLibName )
162162
{
163-
#if MTASA_VERSION_TYPE == VERSION_TYPE_RELEASE
163+
#if MTASA_VERSION_TYPE >= VERSION_TYPE_UNSTABLE
164164
// define MTASA_SKIP_VERSION_CHECKS in "build_overrides_s.h" to skip version checks
165165
#ifndef MTASA_SKIP_VERSION_CHECKS
166166

@@ -179,7 +179,7 @@ bool CDynamicLibrary::CheckMtaVersion( const char* szLibName )
179179
if ( strVersionCore != buffer )
180180
{
181181
Print( "ERROR: '%s' library version is '%s' (Expected '%s')\n", szLibName, buffer, *strVersionCore );
182-
Print( "Reinstall MTA\n" );
182+
Print( "\n** REINSTALL MTA **\n" );
183183
return false;
184184
}
185185

MTA10_Server/core/CServerImpl.cpp

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727
#else
2828
#include <termios.h>
2929
#include <unistd.h>
30-
31-
// This is probably safer than changing MTAPlatform.h against compatibility issues
32-
#undef Print
33-
#define Print printf
3430
#endif
3531

3632
// Define libraries
@@ -47,6 +43,7 @@ bool g_bNoCrashHandler = false;
4743
bool g_bDaemonized = false;
4844
WINDOW* m_wndMenu = NULL;
4945
WINDOW* m_wndInput = NULL;
46+
bool IsCursesActive( void ) { return m_wndInput != NULL; }
5047
#endif
5148

5249
#ifdef WIN32
@@ -120,7 +117,7 @@ void CServerImpl::Printf ( const char* szFormat, ... )
120117
#ifdef WIN32
121118
vprintf ( szFormat, ap );
122119
#else
123-
if(!g_bNoCurses)
120+
if( IsCursesActive() )
124121
vwprintw ( stdscr, szFormat, ap );
125122
else
126123
vprintf ( szFormat, ap );
@@ -308,7 +305,7 @@ int CServerImpl::Run ( int iArgumentCount, char* szArguments [] )
308305

309306
// Welcome text
310307
if ( !g_bSilent )
311-
Print ( "MTA:BLUE Server for MTA:SA\r\n\r\n" );
308+
Print ( "MTA:BLUE Server for MTA:SA\n\n" );
312309

313310
// Load the network DLL
314311
if ( m_NetworkLibrary.Load ( PathJoin ( m_strServerPath, SERVER_BIN_PATH, szNetworkLibName ) ) )
@@ -322,10 +319,10 @@ int CServerImpl::Run ( int iArgumentCount, char* szArguments [] )
322319
ulong ulNetModuleVersion = 0;
323320
if ( pfnCheckCompatibility )
324321
pfnCheckCompatibility ( 1, &ulNetModuleVersion );
325-
Print ( "Network module not compatible! (Expected 0x%x, got 0x%x)\n\r", MTA_DM_SERVER_NET_MODULE_VERSION, (uint)ulNetModuleVersion );
326-
Print ( "Press Q to shut down the server!\n\r" );
327-
Print ( "\n\r\n\r\n\r(If this is a custom build,\n\r" );
328-
Print ( " check MTASA_VERSION_TYPE in version.h is set correctly)\n\r" );
322+
Print ( "Network module not compatible! (Expected 0x%x, got 0x%x)\n", MTA_DM_SERVER_NET_MODULE_VERSION, (uint)ulNetModuleVersion );
323+
Print ( "Press Q to shut down the server!\n" );
324+
Print ( "\n\n\n(If this is a custom build,\n" );
325+
Print ( " check MTASA_VERSION_TYPE in version.h is set correctly)\n" );
329326
WaitForKey ( 'q' );
330327
DestroyWindow ( );
331328
return ERROR_NETWORK_LIBRARY_FAILED;
@@ -991,7 +988,7 @@ void CServerImpl::DestroyWindow ( void )
991988

992989
void WaitForKey ( int iKey )
993990
{
994-
if ( !g_bSilent )
991+
if ( !g_bSilent && !g_bNoCurses )
995992
{
996993
for ( ;; )
997994
{
@@ -1006,3 +1003,24 @@ void WaitForKey ( int iKey )
10061003
}
10071004
}
10081005
}
1006+
1007+
// Always print these messages
1008+
void Print ( const char* szFormat, ... )
1009+
{
1010+
va_list ap;
1011+
va_start ( ap, szFormat );
1012+
1013+
SString str;
1014+
str.vFormat ( szFormat, ap );
1015+
1016+
#ifdef WIN32
1017+
printf ( "%s", *str );
1018+
#else
1019+
if( IsCursesActive() )
1020+
printw ( "%s", *str );
1021+
else
1022+
printf ( "%s", *str );
1023+
#endif
1024+
1025+
va_end ( ap );
1026+
}

MTA10_Server/core/StdInc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@
2424
#endif
2525

2626
void WaitForKey ( int iKey );
27+
void Print ( const char* szFormat, ... );

MTA10_Server/sdk/MTAPlatform.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ extern "C" bool g_bNoTopBar;
5858
#include <direct.h>
5959
#include <windows.h>
6060

61-
// Define functions
62-
#define Print printf
63-
6461
// Define types
6562
typedef int socklen_t;
6663

@@ -94,7 +91,6 @@ extern "C" bool g_bNoTopBar;
9491
#endif
9592

9693
#define MAX_PATH 255
97-
#define Print printw
9894

9995
#ifndef stricmp
10096
#define stricmp strcasecmp

0 commit comments

Comments
 (0)