Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: MTA10_Server/core/CServerImpl.cpp
- ===================================================================
- --- MTA10_Server/core/CServerImpl.cpp (revision 5848)
- +++ MTA10_Server/core/CServerImpl.cpp (working copy)
- @@ -24,6 +24,13 @@
- #include <signal.h>
- #ifdef WIN32
- #include <Mmsystem.h>
- +#else
- + #include <termios.h>
- + #include <unistd.h>
- +
- + // This is probably safer than changing MTAPlatform.h against compatibility issues
- + #undef Printf
- + #define Print printf
- #endif
- // Define libraries
- @@ -33,6 +40,7 @@
- using namespace std;
- bool g_bSilent = false;
- +bool g_bNoCurses = false;
- bool g_bNoTopBar = false;
- #ifndef WIN32
- bool g_bDaemonized = false;
- @@ -107,7 +115,10 @@
- #ifdef WIN32
- vprintf ( szFormat, ap );
- #else
- - vwprintw ( stdscr, szFormat, ap );
- + if(!g_bNoCurses)
- + vwprintw ( stdscr, szFormat, ap );
- + else
- + vprintf ( szFormat, ap );
- #endif
- }
- @@ -205,49 +216,54 @@
- assert ( strcoll( "a", "B" ) > 0 );
- // Initialize the window and any necessary curses options
- - initscr ( );
- - keypad ( stdscr, TRUE );
- - nonl ( );
- - cbreak ( );
- - noecho ( );
- - nodelay ( stdscr, TRUE );
- - idlok ( stdscr, FALSE );
- - scrollok ( stdscr, TRUE );
- - if ( !g_bNoTopBar )
- - setscrreg ( 1, LINES - 1 );
- - else
- - setscrreg ( 0, LINES - 1 );
- -
- - // Initialize the colors
- - if ( has_colors ( ) )
- + if( !g_bNoCurses )
- {
- - start_color ( );
- + initscr ( );
- + keypad ( stdscr, TRUE );
- + nonl ( );
- + cbreak ( );
- + noecho ( );
- + nodelay ( stdscr, TRUE );
- + idlok ( stdscr, FALSE );
- + scrollok ( stdscr, TRUE );
- - init_pair ( 1, COLOR_BLACK, COLOR_WHITE );
- - init_pair ( 2, COLOR_BLACK, COLOR_GREEN );
- - init_pair ( 3, COLOR_WHITE, COLOR_WHITE );
- - init_pair ( 4, COLOR_RED, COLOR_WHITE );
- - init_pair ( 5, COLOR_GREEN, COLOR_WHITE );
- - init_pair ( 6, COLOR_BLUE, COLOR_WHITE );
- - }
- - // Create the input window
- - m_wndInput = subwin ( stdscr, 1, COLS, LINES - 1, 0 );
- - scrollok ( m_wndInput, TRUE );
- - wbkgd ( m_wndInput, COLOR_PAIR ( 2 ) );
- + if ( !g_bNoTopBar )
- + setscrreg ( 1, LINES - 1 );
- + else
- + setscrreg ( 0, LINES - 1 );
- - // Create the menu window
- - if ( !g_bNoTopBar )
- - {
- - m_wndMenu = subwin ( stdscr, 1, COLS, 0, 0 );
- - wbkgd ( m_wndMenu, COLOR_PAIR ( 1 ) );
- + // Initialize the colors
- + if ( has_colors ( ) )
- + {
- + start_color ( );
- +
- + init_pair ( 1, COLOR_BLACK, COLOR_WHITE );
- + init_pair ( 2, COLOR_BLACK, COLOR_GREEN );
- + init_pair ( 3, COLOR_WHITE, COLOR_WHITE );
- + init_pair ( 4, COLOR_RED, COLOR_WHITE );
- + init_pair ( 5, COLOR_GREEN, COLOR_WHITE );
- + init_pair ( 6, COLOR_BLUE, COLOR_WHITE );
- + }
- + // Create the input window
- + m_wndInput = subwin ( stdscr, 1, COLS, LINES - 1, 0 );
- + scrollok ( m_wndInput, TRUE );
- + wbkgd ( m_wndInput, COLOR_PAIR ( 2 ) );
- +
- + // Create the menu window
- + if ( !g_bNoTopBar )
- + {
- + m_wndMenu = subwin ( stdscr, 1, COLS, 0, 0 );
- + wbkgd ( m_wndMenu, COLOR_PAIR ( 1 ) );
- + }
- +
- + // Position the cursor and refresh the physical screen
- +
- + if ( !g_bNoTopBar)
- + move ( 1, 0 );
- + else
- + move ( 0, 0 );
- + refresh ( );
- }
- -
- - // Position the cursor and refresh the physical screen
- - if ( !g_bNoTopBar )
- - move ( 1, 0 );
- - else
- - move ( 0, 0 );
- - refresh ( );
- #endif
- }
- @@ -393,7 +409,7 @@
- while ( !m_bRequestedQuit )
- {
- #ifndef WIN32
- - if ( !g_bSilent )
- + if ( !g_bSilent && !g_bNoCurses)
- {
- // Update all the windows, and the physical screen in one burst
- if ( m_wndMenu )
- @@ -403,7 +419,7 @@
- wbkgd ( m_wndInput, COLOR_PAIR ( 2 ) );
- }
- #endif
- - if ( !g_bSilent && !g_bNoTopBar )
- + if ( !g_bSilent && !g_bNoTopBar && !g_bNoCurses)
- {
- // Show the info tag, 80 is a fixed length
- char szInfoTag[80] = { '\0' };
- @@ -472,7 +488,7 @@
- /*************************/
- void CServerImpl::ShowInfoTag ( char* szTag )
- {
- - if ( g_bSilent || g_bNoTopBar )
- + if ( g_bSilent || g_bNoTopBar || g_bNoCurses)
- return;
- #ifdef WIN32
- // Windows console code
- @@ -573,8 +589,28 @@
- iStdIn = _getwch();
- }
- #else
- - if ( get_wch(&iStdIn) == ERR )
- - iStdIn = 0;
- + if( !g_bNoCurses )
- + {
- + if ( get_wch(&iStdIn) == ERR )
- + iStdIn = 0;
- + }
- + else
- + {
- + struct termios oldattr, newattr;
- + int oldf;
- + tcgetattr( STDIN_FILENO, &oldattr );
- + newattr = oldattr;
- + newattr.c_lflag &= ~( ICANON | ECHO );
- + tcsetattr( STDIN_FILENO, TCSANOW, &newattr );
- + oldf = fcntl(STDIN_FILENO, F_GETFL, 0);
- + fcntl(STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
- + iStdIn = getwchar();
- + tcsetattr( STDIN_FILENO, TCSANOW, &oldattr );
- + fcntl(STDIN_FILENO, F_SETFL, oldf);
- +
- + if ( iStdIn == -1 )
- + iStdIn = 0;
- + }
- #endif
- if ( iStdIn == 0 )
- @@ -591,7 +627,7 @@
- // set string termination (required for compare/string functions
- m_szInputBuffer[m_uiInputCount] = 0;
- - if ( !g_bSilent )
- + if ( !g_bSilent && !g_bNoCurses)
- {
- // Clear the input window
- wclear ( m_wndInput );
- @@ -641,8 +677,8 @@
- #ifdef WIN32
- Printf ( "%c %c", 0x08, 0x08 );
- #else
- - if ( !g_bSilent )
- - wprintw ( m_wndInput, "%c %c", 0x08, 0x08 );
- + if ( !g_bSilent && !g_bNoCurses)
- + wprintw ( m_wndInput, "%c %c", 0x08, 0x08 );
- #endif
- m_uiInputCount--;
- m_szInputBuffer[m_uiInputCount] = 0;
- @@ -677,7 +713,7 @@
- Printf ( "\r%s", UTF16ToMbUTF8(szBuffer).c_str() );
- #else
- - if ( !g_bSilent )
- + if ( !g_bSilent && !g_bNoCurses )
- wmove ( m_wndInput, 0, --m_uiInputCount );
- #endif
- break;
- @@ -700,7 +736,7 @@
- Printf ( "\r%s", UTF16ToMbUTF8(szBuffer).c_str() );
- #else
- - if ( !g_bSilent )
- + if ( !g_bSilent && !g_bNoCurses )
- wmove ( m_wndInput, 0, ++m_uiInputCount );
- #endif
- break;
- @@ -738,7 +774,7 @@
- Printf ( "%s", UTF16ToMbUTF8(wUNICODE).c_str() );
- #else
- wchar_t wUNICODE[2] = { iStdIn, 0 };
- - if ( !g_bSilent )
- + if ( !g_bSilent && !g_bNoCurses)
- wprintw ( m_wndInput, "%s", UTF16ToMbUTF8(wUNICODE).c_str() );
- #endif
- @@ -806,6 +842,11 @@
- {
- g_bDaemonized = true;
- }
- + else if ( strcmp ( szArguments [i], "-n" ) == 0 )
- + {
- + g_bNoTopBar = true;
- + g_bNoCurses = true;
- + }
- #endif
- else if ( strcmp ( szArguments [i], "-t" ) == 0 )
- {
- @@ -851,7 +892,7 @@
- void CServerImpl::DestroyWindow ( void )
- {
- #ifndef WIN32
- - if ( !g_bSilent )
- + if ( !g_bSilent || !g_bNoCurses)
- {
- if ( m_wndMenu )
- delwin ( m_wndMenu );
- Index: MTA10_Server/launcher/Main.cpp
- ===================================================================
- --- MTA10_Server/launcher/Main.cpp (revision 5848)
- +++ MTA10_Server/launcher/Main.cpp (working copy)
- @@ -70,6 +70,7 @@
- #endif
- printf ( " -t Run server with a simple console\n" );
- printf ( " -f Run server with a standard console (Default)\n" );
- + printf ( " -n Disable the usage of ncurses\n" );
- printf ( " -D [PATH] Use as base directory\n" );
- printf ( " --config [FILE] Alternate mtaserver.conf file\n" );
- printf ( " --ip [ADDR] Set IP address\n" );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement