19 Feb 2010

This commit is contained in:
g-cont 2010-02-19 00:00:00 +03:00 committed by Alibek Omarov
parent 6107be7dba
commit afb127dfb3
19 changed files with 283 additions and 171 deletions

View File

@ -11,7 +11,6 @@
#include "com_world.h"
#define MAX_DEMOS 32
#define MAX_EDIT_LINE 256
#define COMMAND_HISTORY 32
#define MAX_GAME_TITLES 1024
#define ColorIndex(c) (((c) - '0') & 7)
@ -21,6 +20,15 @@
#define STRING( offset ) CL_GetString( offset )
#define MAKE_STRING(str) CL_AllocString( str )
// console stuff
typedef struct
{
string buffer;
int cursor;
int scroll;
int widthInChars;
} field_t;
typedef struct player_info_s
{
char name[CS_SIZE];
@ -40,17 +48,8 @@ typedef struct frame_s
int parse_entities; // non-masked index into cl_parse_entities array
} frame_t;
// console stuff
typedef struct field_s
{
int cursor;
int scroll;
int widthInChars;
char buffer[MAX_EDIT_LINE];
} field_t;
#define CMD_BACKUP 64 // allow a lot of command backups for very fast systems
#define CMD_MASK (CMD_BACKUP - 1)
#define CMD_BACKUP 64 // allow a lot of command backups for very fast systems
#define CMD_MASK (CMD_BACKUP - 1)
// the cl_parse_entities must be large enough to hold UPDATE_BACKUP frames of
// entities, so that when a delta compressed message arives from the server

View File

@ -245,6 +245,7 @@ char *Cvar_Serverinfo( void );
void Cmd_WriteVariables( file_t *f );
bool Cmd_CheckMapsList( void );
void Cmd_ForwardToServer( void );
void Cmd_AutoComplete( char *complete_string );
typedef struct autocomplete_list_s
{

View File

@ -117,7 +117,7 @@ EDIT FIELDS
void Field_Clear( field_t *edit )
{
Mem_Set( edit->buffer, 0, MAX_EDIT_LINE );
Mem_Set( edit->buffer, 0, MAX_STRING );
edit->cursor = 0;
edit->scroll = 0;
}
@ -209,14 +209,14 @@ static void ConcatRemaining( const char *src, const char *start )
{
char *str;
str = com.strstr(src, start);
if (!str)
str = com.strstr( src, start );
if( !str )
{
keyConcatArgs();
return;
}
str += com.strlen(start);
str += com.strlen( start );
com.strncat( completionField->buffer, str, sizeof( completionField->buffer ));
}
@ -277,7 +277,8 @@ void Field_CompleteCommand( field_t *field )
if( matchCount == 1 )
{
com.sprintf( completionField->buffer, "\\%s", shortestMatch );
if ( Cmd_Argc() == 1 ) com.strncat( completionField->buffer, " ", sizeof( completionField->buffer ));
if( Cmd_Argc() == 1 )
com.strncat( completionField->buffer, " ", sizeof( completionField->buffer ));
else ConcatRemaining( temp.buffer, completionString );
completionField->cursor = com.strlen( completionField->buffer );
return;
@ -508,14 +509,14 @@ void Field_CharEvent( field_t *edit, int ch )
if ( host.key_overstrike )
{
if ( edit->cursor == MAX_EDIT_LINE - 1 ) return;
if ( edit->cursor == MAX_STRING - 1 ) return;
edit->buffer[edit->cursor] = ch;
edit->cursor++;
}
else
{
// insert mode
if ( len == MAX_EDIT_LINE - 1 ) return; // all full
if ( len == MAX_STRING - 1 ) return; // all full
memmove( edit->buffer + edit->cursor + 1, edit->buffer + edit->cursor, len + 1 - edit->cursor );
edit->buffer[edit->cursor] = ch;
edit->cursor++;
@ -1062,7 +1063,7 @@ void Key_AddKeyUpCommands( int key, const char *kb )
/*
===================
CL_KeyEvent
Key_Event
Called by the system for both key up and key down events
===================
@ -1198,6 +1199,47 @@ void Key_Event( int key, bool down, int time )
}
}
/*
=========
Key_SetKeyDest
=========
*/
void Key_SetKeyDest( int key_dest )
{
switch( key_dest )
{
case key_game:
cls.key_dest = key_game;
break;
case key_menu:
cls.key_dest = key_menu;
break;
case key_console:
cls.key_dest = key_console;
break;
default:
Host_Error( "Key_SetKeyDest: wrong destination (%i)\n", key_dest );
break;
}
}
/*
===================
Key_ClearStates
===================
*/
void Key_ClearStates( void )
{
int i;
anykeydown = false;
for ( i = 0; i < 256; i++ )
{
if( keys[i].down ) Key_Event( i, false, 0 );
keys[i].down = 0;
keys[i].repeats = 0;
}
}
/*
===================
@ -1243,42 +1285,26 @@ void CL_MouseEvent( int mx, int my )
/*
=========
Key_SetKeyDest
Cmd_AutoComplete
NOTE: input string must be equal or longer than MAX_STRING
=========
*/
void Key_SetKeyDest( int key_dest )
void Cmd_AutoComplete( char *complete_string )
{
switch( key_dest )
{
case key_game:
cls.key_dest = key_game;
break;
case key_menu:
cls.key_dest = key_menu;
break;
case key_console:
cls.key_dest = key_console;
break;
default:
Host_Error( "Key_SetKeyDest: wrong destination (%i)\n", key_dest );
break;
}
}
field_t input;
/*
===================
Key_ClearStates
===================
*/
void Key_ClearStates( void )
{
int i;
if( !complete_string || !*complete_string )
return;
anykeydown = false;
for ( i = 0; i < 256; i++ )
{
if( keys[i].down ) Key_Event( i, false, 0 );
keys[i].down = 0;
keys[i].repeats = 0;
}
// setup input
com.strncpy( input.buffer, complete_string, sizeof( input.buffer ));
input.cursor = input.scroll = 0;
Field_CompleteCommand( &input );
// setup output
if( input.buffer[0] == '\\' || input.buffer[0] == '/' )
com.strncpy( complete_string, input.buffer + 1, sizeof( input.buffer ));
else com.strncpy( complete_string, input.buffer, sizeof( input.buffer ));
}

View File

@ -88,7 +88,7 @@ bool Cmd_GetMapList( const char *s, char *completedname, int length )
char *entities = NULL;
FS_Seek( f, lumpofs, SEEK_SET );
entities = (char *)Mem_Alloc( cls.mempool, lumplen + 1 );
entities = (char *)Mem_Alloc( host.mempool, lumplen + 1 );
FS_Read( f, entities, lumplen );
ents = Com_OpenScript( "ents", entities, lumplen + 1 );
Mem_Free( entities ); // no reason to keep it
@ -616,7 +616,7 @@ bool Cmd_CheckMapsList( void )
t = FS_Search( "maps/*.bsp", false );
if( !t ) return false;
buffer = Mem_Alloc( cls.mempool, t->numfilenames * 2 * sizeof( result ));
buffer = Mem_Alloc( host.mempool, t->numfilenames * 2 * sizeof( result ));
for( i = 0; i < t->numfilenames; i++ )
{
script_t *ents = NULL;
@ -668,7 +668,7 @@ bool Cmd_CheckMapsList( void )
char *entities = NULL;
FS_Seek( f, lumpofs, SEEK_SET );
entities = (char *)Mem_Alloc( cls.mempool, lumplen + 1 );
entities = (char *)Mem_Alloc( host.mempool, lumplen + 1 );
FS_Read( f, entities, lumplen );
ents = Com_OpenScript( "ents", entities, lumplen + 1 );
Mem_Free( entities ); // no reason to keep it

View File

@ -58,7 +58,7 @@ static int Host_MapKey( int key )
modified = ( key >> 16 ) & 255;
if( modified > 127 ) return 0;
if ( key & ( 1 << 24 ))
if( key & ( 1 << 24 ))
is_extended = true;
result = scan_to_key[modified];
@ -454,13 +454,15 @@ long IN_WndProc( void *hWnd, uint uMsg, uint wParam, long lParam )
case WM_MBUTTONDOWN:
case WM_MBUTTONUP:
case WM_MOUSEMOVE:
if(wParam & MK_LBUTTON) temp |= 1;
if(wParam & MK_RBUTTON) temp |= 2;
if(wParam & MK_MBUTTON) temp |= 4;
if( wParam & MK_LBUTTON ) temp |= 1;
if( wParam & MK_RBUTTON ) temp |= 2;
if( wParam & MK_MBUTTON ) temp |= 4;
IN_MouseEvent( temp );
break;
case WM_SYSCOMMAND:
if( wParam == SC_SCREENSAVE ) return 0;
// never turn screensave when Xash is active
if( wParam == SC_SCREENSAVE && host.state != HOST_SLEEP )
return 0;
break;
case WM_SYSKEYDOWN:
if( wParam == VK_RETURN )

View File

@ -673,8 +673,18 @@ void Host_Error( const char *error, ... )
void Host_Error_f( void )
{
if( Cmd_Argc() == 1 ) Sys_Break( "\n" );
else Host_Error( "%s\n", Cmd_Argv( 1 ));
const char *error = Cmd_Argv( 1 );
if( !*error ) error = "Invoked host error";
Host_Error( "%s\n", error );
}
void Sys_Error_f( void )
{
const char *error = Cmd_Argv( 1 );
if( !*error ) error = "Invoked sys error";
com.error( "%s\n", error );
}
/*
@ -795,16 +805,20 @@ void Host_Init( const int argc, const char **argv )
Host_InitCommon( argc, argv );
Key_Init();
// get user configuration
Cbuf_AddText( "exec keys.rc\n" );
Cbuf_AddText( "exec vars.rc\n" );
Cbuf_Execute();
if( host.type != HOST_DEDICATED )
{
// get user configuration
Cbuf_AddText( "exec keys.rc\n" );
Cbuf_AddText( "exec vars.rc\n" );
Cbuf_Execute();
}
// init commands and vars
if( host.developer )
{
Cmd_AddCommand ("error", Host_Error_f, "just throw a fatal error to test shutdown procedures" );
Cmd_AddCommand ("crash", Host_Crash_f, "a way to force a bus error for development reasons");
Cmd_AddCommand ( "sys_error", Sys_Error_f, "just throw a fatal error to test shutdown procedures");
Cmd_AddCommand ( "host_error", Host_Error_f, "just throw a host error to test shutdown procedures");
Cmd_AddCommand ( "crash", Host_Crash_f, "a way to force a bus error for development reasons");
}
host_cheats = Cvar_Get( "sv_cheats", "1", CVAR_SYSTEMINFO, "allow cheat variables to enable" );
@ -901,6 +915,7 @@ launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, void *unused )
Host.Free = Host_Free;
Host.CPrint = Host_Print;
Host.CmdForward = Cmd_ForwardToServer;
Host.CmdComplete = Cmd_AutoComplete;
return &Host;
}

View File

@ -243,7 +243,7 @@ static void UI_AdvControls_Init( void )
uiAdvControls.lookSpring.generic.y = 380;
uiAdvControls.lookSpring.generic.name = "Look spring";
uiAdvControls.lookSpring.generic.callback = UI_AdvControls_Callback;
uiAdvControls.lookSpring.generic.statusText = "Causes th screen to to 'spring' back to looking straight ahead when you\nmove forward";
uiAdvControls.lookSpring.generic.statusText = "Causes the screen to 'spring' back to looking straight ahead when you\nmove forward";
uiAdvControls.lookStrafe.generic.id = ID_LOOKSTRAFE;
uiAdvControls.lookStrafe.generic.type = QMTYPE_CHECKBOX;

View File

@ -96,7 +96,7 @@ static void UI_CustomGame_GetModList( void )
// see if the load button should be grayed
if( !com.stricmp( GI->gamefolder, uiCustomGame.modsDir[uiCustomGame.modList.curItem] ))
uiCustomGame.load.generic.flags |= QMF_GRAYED;
if( com.strlen( uiCustomGame.modsWebSites[0] ) == 0 )
if( com.strlen( uiCustomGame.modsWebSites[uiCustomGame.modList.curItem] ) == 0 )
uiCustomGame.go2url.generic.flags |= QMF_GRAYED;
}

View File

@ -112,6 +112,7 @@ typedef enum
#define QMF_FOCUSBEHIND BIT(18) // Focus draws behind normal item
#define QMF_NOTIFY BIT(19) // draw notify at right screen side
#define QMF_ACT_ONRELEASE BIT(20) // call Key_Event when button is released
#define QMF_ALLOW_COLORSTRINGS BIT(21) // allow colorstring in MENU_FIELD
// Callback notifications
#define QM_GOTFOCUS 1

View File

@ -1218,6 +1218,12 @@ void UI_Field_Char( menuField_s *f, int key )
// ignore any other non printable chars
if( key < 32 ) return;
if( key == '^' && !( f->generic.flags & QMF_ALLOW_COLORSTRINGS ))
{
// ignore color key-symbol
return;
}
if( f->generic.flags & QMF_NUMBERSONLY )
{
if( key < '0' || key > '9' )

View File

@ -18,25 +18,31 @@ WIN32 CONSOLE
// console defines
#define SUBMIT_ID 1 // "submit" button
#define QUIT_ON_ESCAPE_ID 2 // escape event
#define AUTO_COMPLETE_ID 3 // autocomplete event
#define HISTORY_NEXT_ID 4
#define HISTORY_PREV_ID 5
#define EDIT_ID 110
#define INPUT_ID 109
#define IDI_ICON1 101
#define SYSCONSOLE "SystemConsole"
#define COMMAND_HISTORY 64 // system console keep more commands than game console
typedef struct
{
HWND hWnd;
HWND hwndBuffer;
HWND hwndButtonSubmit;
HWND hwndErrorBox;
HWND hwndErrorText;
HBRUSH hbrEditBackground;
HBRUSH hbrErrorBackground;
HFONT hfBufferFont;
HFONT hfButtonFont;
HWND hwndInputLine;
char errorString[80];
char consoleText[512], returnedText[512];
string consoleText;
string returnedText;
string historyLines[COMMAND_HISTORY];
int nextHistoryLine;
int historyLine;
int status;
int windowWidth, windowHeight;
WNDPROC SysInputLineWndProc;
@ -60,21 +66,31 @@ void Con_ShowConsole( bool show )
else ShowWindow( s_wcd.hWnd, SW_HIDE );
}
void Con_DisableInput( void )
{
if( Sys.con_readonly ) return;
SendMessage( s_wcd.hwndButtonSubmit, WM_ENABLE, 0, 0 );
SendMessage( s_wcd.hwndInputLine, WM_ENABLE, 0, 0 );
UnregisterHotKey( s_wcd.hwndInputLine, AUTO_COMPLETE_ID );
UnregisterHotKey( s_wcd.hwndInputLine, HISTORY_NEXT_ID );
UnregisterHotKey( s_wcd.hwndInputLine, HISTORY_PREV_ID );
}
void Con_SetInputText( const char *inputText )
{
if( Sys.con_readonly ) return;
SetWindowText( s_wcd.hwndInputLine, inputText );
SendMessage( s_wcd.hwndInputLine, EM_SETSEL, com_strlen( inputText ), -1 );
}
static long _stdcall Con_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static bool s_timePolarity;
PAINTSTRUCT ps;
HDC hdc;
switch (uMsg)
switch( uMsg )
{
case WM_ACTIVATE:
if ( LOWORD( wParam ) != WA_INACTIVE ) SetFocus( s_wcd.hwndInputLine );
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, (LPPAINTSTRUCT)&ps);
EndPaint(hWnd,(LPPAINTSTRUCT)&ps);
return TRUE;
if( LOWORD( wParam ) != WA_INACTIVE )
SetFocus( s_wcd.hwndInputLine );
break;
case WM_CLOSE:
if( Sys.app_state == SYS_ERROR )
@ -82,39 +98,25 @@ static long _stdcall Con_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
// send windows message
PostQuitMessage( 0 );
}
else Sys_Exit(); //otherwise
else Sys_Exit(); // otherwise
return 0;
case WM_CTLCOLORSTATIC:
if (( HWND )lParam == s_wcd.hwndBuffer )
if( (HWND)lParam == s_wcd.hwndBuffer )
{
SetBkColor( ( HDC ) wParam, RGB( 0x90, 0x90, 0x90 ));
SetTextColor( ( HDC ) wParam, RGB( 0xff, 0xff, 0xff ));
return ( long ) s_wcd.hbrEditBackground;
}
else if (( HWND )lParam == s_wcd.hwndErrorBox )
{
if ( s_timePolarity & 1 )
{
SetBkColor(( HDC )wParam, RGB( 0x80, 0x80, 0x80 ));
SetTextColor(( HDC )wParam, RGB( 0xff, 0x0, 0x00 ));
}
else
{
SetBkColor(( HDC )wParam, RGB( 0x80, 0x80, 0x80 ));
SetTextColor(( HDC )wParam, RGB( 0x00, 0x0, 0x00 ));
}
return ( long )s_wcd.hbrErrorBackground;
SetBkColor( (HDC)wParam, RGB( 0x90, 0x90, 0x90 ));
SetTextColor( (HDC)wParam, RGB( 0xff, 0xff, 0xff ));
return (long)s_wcd.hbrEditBackground;
}
break;
case WM_COMMAND:
if ( wParam == SUBMIT_ID )
if( wParam == SUBMIT_ID )
{
SendMessage(s_wcd.hwndInputLine, WM_CHAR, 13, 0L);
SendMessage( s_wcd.hwndInputLine, WM_CHAR, 13, 0L );
SetFocus( s_wcd.hwndInputLine );
}
break;
case WM_HOTKEY:
switch(LOWORD(wParam))
switch( LOWORD( wParam ))
{
case QUIT_ON_ESCAPE_ID:
PostQuitMessage( 0 );
@ -122,44 +124,59 @@ static long _stdcall Con_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
}
break;
case WM_CREATE:
s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x90, 0x90, 0x90 ) );
s_wcd.hbrErrorBackground = CreateSolidBrush( RGB( 0x80, 0x80, 0x80 ) );
SetTimer( hWnd, 1, 1000, NULL );
break;
case WM_ERASEBKGND:
return DefWindowProc( hWnd, uMsg, wParam, lParam );
case WM_TIMER:
if ( wParam == 1 )
{
s_timePolarity = !s_timePolarity;
if ( s_wcd.hwndErrorBox ) InvalidateRect( s_wcd.hwndErrorBox, NULL, FALSE );
}
s_wcd.hbrEditBackground = CreateSolidBrush( RGB( 0x90, 0x90, 0x90 ));
break;
}
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
long _stdcall Con_InputLineProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
long _stdcall Con_InputLineProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
char inputBuffer[1024];
char inputBuffer[1024];
switch ( uMsg )
switch( uMsg )
{
case WM_KILLFOCUS:
if (( HWND ) wParam == s_wcd.hWnd || ( HWND ) wParam == s_wcd.hwndErrorBox )
if(( HWND )wParam == s_wcd.hWnd )
{
SetFocus( hWnd );
return 0;
}
break;
case WM_CHAR:
if ( wParam == 13 )
case WM_HOTKEY:
switch( LOWORD( wParam ))
{
GetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ) );
case AUTO_COMPLETE_ID:
GetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ));
if( Sys.CmdAuto ) Sys.CmdAuto( inputBuffer );
Con_SetInputText( inputBuffer );
return 0;
case HISTORY_PREV_ID:
if( s_wcd.nextHistoryLine - s_wcd.historyLine < COMMAND_HISTORY && s_wcd.historyLine > 0 )
s_wcd.historyLine--;
Con_SetInputText( s_wcd.historyLines[s_wcd.historyLine % COMMAND_HISTORY] );
return 0;
case HISTORY_NEXT_ID:
if( s_wcd.historyLine == s_wcd.nextHistoryLine )
return 0;
s_wcd.historyLine++;
Con_SetInputText( s_wcd.historyLines[s_wcd.historyLine % COMMAND_HISTORY] );
return 0;
}
break;
case WM_CHAR:
if( wParam == 13 && Sys.app_state != SYS_ERROR )
{
GetWindowText( s_wcd.hwndInputLine, inputBuffer, sizeof( inputBuffer ));
com_strncat( s_wcd.consoleText, inputBuffer, sizeof( s_wcd.consoleText ) - com_strlen( s_wcd.consoleText ) - 5 );
com_strcat( s_wcd.consoleText, "\n" );
SetWindowText( s_wcd.hwndInputLine, "" );
Msg(">%s\n", inputBuffer );
Msg( ">%s\n", inputBuffer );
// copy line to history buffer
com_strncpy( s_wcd.historyLines[s_wcd.nextHistoryLine % COMMAND_HISTORY], inputBuffer, MAX_STRING );
s_wcd.nextHistoryLine++;
s_wcd.historyLine = s_wcd.nextHistoryLine;
return 0;
}
}
@ -181,11 +198,11 @@ Con_PrintA
print into cmd32 console
================
*/
void Con_PrintA(const char *pMsg)
void Con_PrintA( const char *pMsg )
{
DWORD cbWritten;
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), pMsg, com_strlen(pMsg), &cbWritten, 0 );
WriteFile( GetStdHandle( STD_OUTPUT_HANDLE ), pMsg, com_strlen( pMsg ), &cbWritten, 0 );
}
/*
@ -224,16 +241,18 @@ create win32 console
*/
void Con_CreateConsole( void )
{
HDC hDC;
WNDCLASS wc;
RECT rect;
HDC hDC;
WNDCLASS wc;
RECT rect;
int nHeight;
int swidth, sheight, fontsize;
string Title, FontName;
int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION;
int CONSTYLE = WS_CHILD|WS_VISIBLE|WS_VSCROLL|WS_BORDER|WS_EX_CLIENTEDGE|ES_LEFT|ES_MULTILINE|ES_AUTOVSCROLL|ES_READONLY;
if( Sys.con_silentmode ) return;
if( Sys.con_silentmode )
return;
Sys_InitLog();
if( Sys.hooked_out )
@ -285,7 +304,7 @@ void Con_CreateConsole( void )
else // dedicated console
{
rect.left = 0;
rect.right = 540;
rect.right = 640;
rect.top = 0;
rect.bottom = 392;
com.strncpy( FontName, "System", MAX_STRING );
@ -304,7 +323,7 @@ void Con_CreateConsole( void )
s_wcd.windowHeight = rect.bottom - rect.top;
s_wcd.hWnd = CreateWindowEx( WS_EX_DLGMODALFRAME, SYSCONSOLE, Title, DEDSTYLE, ( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1, NULL, NULL, base_hInstance, NULL );
if ( s_wcd.hWnd == NULL )
if( s_wcd.hWnd == NULL )
{
Msg( "Can't create window '%s'\n", Title );
return;
@ -319,22 +338,25 @@ void Con_CreateConsole( void )
if( !Sys.con_readonly )
{
// create the input line
s_wcd.hwndInputLine = CreateWindowEx( WS_EX_CLIENTEDGE, "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL, 0, 366, 450, 25, s_wcd.hWnd, ( HMENU ) INPUT_ID, base_hInstance, NULL );
s_wcd.hwndInputLine = CreateWindowEx( WS_EX_CLIENTEDGE, "edit", NULL, WS_CHILD|WS_VISIBLE|WS_BORDER|ES_LEFT|ES_AUTOHSCROLL, 0, 366, 550, 25, s_wcd.hWnd, ( HMENU )INPUT_ID, base_hInstance, NULL );
s_wcd.hwndButtonSubmit = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON, 452, 367, 87, 25, s_wcd.hWnd, ( HMENU ) SUBMIT_ID, base_hInstance, NULL );
s_wcd.hwndButtonSubmit = CreateWindow( "button", NULL, BS_PUSHBUTTON|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON, 552, 367, 87, 25, s_wcd.hWnd, ( HMENU )SUBMIT_ID, base_hInstance, NULL );
SendMessage( s_wcd.hwndButtonSubmit, WM_SETTEXT, 0, ( LPARAM ) "submit" );
RegisterHotKey( s_wcd.hwndInputLine, AUTO_COMPLETE_ID, 0, VK_TAB );
RegisterHotKey( s_wcd.hwndInputLine, HISTORY_NEXT_ID, 0, VK_DOWN );
RegisterHotKey( s_wcd.hwndInputLine, HISTORY_PREV_ID, 0, VK_UP );
}
// create the scrollbuffer
GetClientRect( s_wcd.hWnd, &rect );
s_wcd.hwndBuffer = CreateWindowEx( WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, min(365, rect.bottom), s_wcd.hWnd, ( HMENU )EDIT_ID, base_hInstance, NULL );
SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
s_wcd.hwndBuffer = CreateWindowEx( WS_EX_DLGMODALFRAME|WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, min(365, rect.bottom), s_wcd.hWnd, ( HMENU )EDIT_ID, base_hInstance, NULL );
SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM )s_wcd.hfBufferFont, 0 );
if(!Sys.con_readonly)
if( !Sys.con_readonly )
{
s_wcd.SysInputLineWndProc = ( WNDPROC )SetWindowLong( s_wcd.hwndInputLine, GWL_WNDPROC, ( long ) Con_InputLineProc );
SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
s_wcd.SysInputLineWndProc = ( WNDPROC )SetWindowLong( s_wcd.hwndInputLine, GWL_WNDPROC, ( long )Con_InputLineProc );
SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM )s_wcd.hfBufferFont, 0 );
}
// show console if needed
@ -345,7 +367,7 @@ void Con_CreateConsole( void )
UpdateWindow( s_wcd.hWnd );
SetForegroundWindow( s_wcd.hWnd );
if(Sys.con_readonly) SetFocus( s_wcd.hWnd );
if( Sys.con_readonly ) SetFocus( s_wcd.hWnd );
else SetFocus( s_wcd.hwndInputLine );
s_wcd.status = true;
}
@ -367,10 +389,10 @@ void Con_DestroyConsole( void )
Sys_CloseLog();
if( Sys.hooked_out ) return;
if ( s_wcd.hWnd )
if( s_wcd.hWnd )
{
DeleteObject(s_wcd.hbrEditBackground);
DeleteObject( s_wcd.hbrErrorBackground);
DeleteObject( s_wcd.hbrEditBackground );
DeleteObject( s_wcd.hbrErrorBackground );
DeleteObject( s_wcd.hfBufferFont );
ShowWindow( s_wcd.hWnd, SW_HIDE );
@ -378,6 +400,9 @@ void Con_DestroyConsole( void )
s_wcd.hWnd = 0;
}
UnregisterClass( SYSCONSOLE, Sys.hInstance );
// place it here in case Sys_Crash working properly
if( Sys.hMutex ) CloseHandle( Sys.hMutex );
}
/*
@ -389,9 +414,10 @@ returned input text
*/
char *Sys_Input( void )
{
if( s_wcd.consoleText[0] == 0 ) return NULL;
if( s_wcd.consoleText[0] == 0 )
return NULL;
com_strncpy( s_wcd.returnedText, s_wcd.consoleText, sizeof(s_wcd.returnedText));
com_strncpy( s_wcd.returnedText, s_wcd.consoleText, sizeof( s_wcd.returnedText ));
s_wcd.consoleText[0] = 0;
return s_wcd.returnedText;
@ -406,7 +432,7 @@ change focus to console hwnd
*/
void Con_RegisterHotkeys( void )
{
if(Sys.hooked_out) return;
if( Sys.hooked_out ) return;
SetFocus( s_wcd.hWnd );

View File

@ -1722,6 +1722,7 @@ void FS_Init( void )
}
FS_UpdateSysInfo();
MsgDev( D_INFO, "FS_Root: %s\n", sys_rootdir );
MsgDev( D_NOTE, "FS_Init: done\n" );
}
@ -3121,15 +3122,15 @@ void FS_UpdateEnvironmentVariables( void )
// so, set current working directory as path from registry and test it
FS_BuildPath( szTemp, szPath );
if(!FS_SysFileExists( szPath )) // Step2: engine root dir has been moved to other place?
if( !FS_SysFileExists( szPath )) // Step2: engine root dir has been moved to other place?
{
FS_BuildPath( sys_rootdir, szPath );
if(!FS_SysFileExists( szPath )) // Step3: directly execute from bin directory?
if( !FS_SysFileExists( szPath )) // Step3: directly execute from bin directory?
{
// Step4: create last test for bin directory
FS_GetBaseDir( sys_rootdir, szTemp );
FS_BuildPath( szTemp, szPath );
if(!FS_SysFileExists( szPath ))
if( !FS_SysFileExists( szPath ))
{
// big bada-boom: engine was moved and launcher was running from other place
// step5: so, path form registry is invalid, current path is no valid

View File

@ -59,6 +59,7 @@ typedef struct system_s
int msg_time; // GetMessage time
char ModuleName[4096]; // exe.filename
HANDLE hMutex;
HINSTANCE hInstance;
LPTOP_LEVEL_EXCEPTION_FILTER oldFilter;
dll_info_t *linked_dll;
@ -84,6 +85,7 @@ typedef struct system_s
void ( *Free ) ( void ); // close host
void (*CPrint)( const char *msg ); // console print
void (*CmdFwd)( void ); // forward to server
void (*CmdAuto)( char *complete_string );
} system_t;
typedef struct timer_s
@ -129,6 +131,7 @@ void Con_CreateConsole( void );
void Con_DestroyConsole( void );
char *Sys_Input( void );
void Con_RegisterHotkeys( void );
void Con_DisableInput( void );
//
// system.c

View File

@ -14,9 +14,9 @@
#include <winreg.h>
#include <stdio.h>
#pragma comment(lib, "msvcrt")
#pragma comment(linker,"/MERGE:.rdata=.text")
#pragma comment(linker,"/FILEALIGN:512 /SECTION:.text, EWRX /IGNORE:4078")
#pragma comment( lib, "msvcrt" )
#pragma comment( linker, "/MERGE:.rdata=.text" )
#pragma comment( linker, "/FILEALIGN:512 /SECTION:.text, EWRX /IGNORE:4078" )
#define Run( prog ) int main( int argc, char **argv )\
{ return CreateMain32()( #prog, TRUE ); }
@ -38,7 +38,7 @@ void GetError( const char *errorstring )
if(!errorstring) exit( 0 );
if( user32_dll ) pMessageBoxA = (void *)GetProcAddress( user32_dll, "MessageBoxA" );
if(pMessageBoxA) pMessageBoxA( 0, errorstring, "Error", MB_OK );
if(pMessageBoxA) pMessageBoxA( 0, errorstring, "Xash Error", MB_OK|MB_SETFOREGROUND|MB_ICONSTOP );
if( user32_dll ) FreeLibrary( user32_dll ); // no need anymore...
exit( 1 );
@ -52,15 +52,20 @@ BOOL GetBin( void )
BOOL GetEnv( void )
{
char *pEnvPath = getenv("Xash3D");
#ifndef HOST_NORMAL
char *pEnvPath = getenv( "Xash3D" );
if( !pEnvPath ) return FALSE;
strcpy( szFsPath, pEnvPath );
return TRUE;
#else
return FALSE;
#endif
}
BOOL GetReg( void )
{
#ifndef HOST_NORMAL
HINSTANCE advapi32_dll = LoadLibrary( "advapi32.dll" );
static long( _stdcall *pRegOpenKeyEx )( HKEY, LPCSTR, DWORD, REGSAM, PHKEY );
static long( _stdcall *pRegQueryValueEx )( HKEY, LPCSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD );
@ -92,6 +97,9 @@ BOOL GetReg( void )
failure:
if( advapi32_dll ) FreeLibrary( advapi32_dll ); // don't forget freeing
return result;
#else
return FALSE;
#endif
}
void GetLibrary( void )
@ -111,6 +119,7 @@ void GetLibrary( void )
strcpy( szSearch[count], "launch.dll" );
count++;
}
if( GetEnv( ))
{
// get environment variable (e.g. compilers)
@ -124,6 +133,7 @@ void GetLibrary( void )
sprintf( szSearch[count], "%s\\bin\\launch.dll", szFsPath );
count++;
}
for( i = 0; i < count; i++ )
{
if( hmain = LoadLibrary( szSearch[i] ))

View File

@ -293,7 +293,7 @@ NOTE: at this day we have ten instances
4. "bsplib" - four BSP compilers in one
5. "sprite" - sprite creator (requires qc. script)
6. "studio" - Half-Life style models creator (requires qc. script)
7. "roqlib" - wad-file maker
7. "wadlib" - wad-file maker
8. "ripper" - resource EXTRActor GENeric
9. "ximage" - ImageLib Processng
==================
@ -319,7 +319,7 @@ void Sys_LookupInstance( void )
}
// lookup all instances
if(!com_strcmp(Sys.progname, "credits"))
if(!com_strcmp( Sys.progname, "credits" ))
{
Sys.app_name = HOST_CREDITS; // easter egg
Sys.linked_dll = NULL; // no need to loading library
@ -333,6 +333,18 @@ void Sys_LookupInstance( void )
{
Sys.app_name = HOST_DEDICATED;
Sys.con_readonly = false;
// check for duplicate dedicated server
Sys.hMutex = CreateMutex( NULL, 0, "Xash Dedicated Server" );
if( !Sys.hMutex )
{
MSGBOX( "Dedicated server already running" );
Sys_Exit();
return;
}
CloseHandle( Sys.hMutex );
Sys.hMutex = CreateSemaphore( NULL, 0, 1, "Xash Dedicated Server" );
}
else
{
@ -427,6 +439,7 @@ void Sys_CreateInstance( void )
Sys.Free = Host->Free;
Sys.CPrint = Host->CPrint;
Sys.CmdFwd = Host->CmdForward;
Sys.CmdAuto = Host->CmdComplete;
if( baserc_dll.link )
{
CreateBaserc = (void *)baserc_dll.main;
@ -788,7 +801,7 @@ void Sys_WaitForQuit( void )
if( Sys.hooked_out )
{
// in-pipeline mode we don't want to wait for press any key
if(abs((int)GetStdHandle(STD_OUTPUT_HANDLE)) <= 100 )
if( abs((int)GetStdHandle(STD_OUTPUT_HANDLE)) <= 100 )
{
Sys_Print( "press any key to quit\n" );
system( "@pause>nul\n" ); // wait for quit
@ -802,10 +815,10 @@ void Sys_WaitForQuit( void )
// wait for the user to quit
while( msg.message != WM_QUIT )
{
if(PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
if( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
TranslateMessage( &msg );
DispatchMessage( &msg );
}
else Sys_Sleep( 20 );
}
@ -840,7 +853,10 @@ void Sys_Error( const char *error, ... )
va_end( argptr );
Con_ShowConsole( true );
if( Sys.developer >= D_ERROR ) Sys_Print( text ); // print error message
Con_DisableInput(); // disable input line for dedicated server
if( Sys.developer >= D_ERROR )
Sys_Print( text ); // print error message
else Sys_Print( "Internal engine error\n" ); // don't confuse non-developers with technique stuff
if( Sys.app_name == HOST_NORMAL )
Sys.Free(); // kill video
@ -864,7 +880,7 @@ void Sys_Break( const char *error, ... )
if( Sys.app_name == HOST_NORMAL )
Sys.Free(); // kill video
if( Sys.developer > 0 || Sys.app_name != HOST_NORMAL )
if( Sys.con_readonly && ( Sys.developer > 0 || Sys.app_name != HOST_NORMAL ))
{
Con_ShowConsole( true );
Sys_Print( text );
@ -872,6 +888,7 @@ void Sys_Break( const char *error, ... )
}
else
{
Con_ShowConsole( false );
MSGBOX( text );
}
Sys_Exit();
@ -935,9 +952,9 @@ void Sys_Init( void )
else Sys_MergeCommandLine( GetCommandLine());
// parse and copy args into local array
if(FS_CheckParm( "-log" )) Sys.log_active = true;
if(FS_CheckParm( "-console" )) Sys.developer = 1;
if(FS_GetParmFromCmdLine( "-dev", dev_level, sizeof( dev_level )))
if( FS_CheckParm( "-log" )) Sys.log_active = true;
if( FS_CheckParm( "-console" )) Sys.developer = 1;
if( FS_GetParmFromCmdLine( "-dev", dev_level, sizeof( dev_level )))
Sys.developer = com_atoi( dev_level );
FS_UpdateEnvironmentVariables(); // set working directory

View File

@ -2,6 +2,7 @@
// Copyright (C) XashXT Group 2007
//=======================================================================
#define HOST_NORMAL
#include "../rundll.h"
Run32( normal );

View File

@ -74,6 +74,7 @@ typedef struct launch_exp_s
void (*Free)( void ); // close host
void (*CPrint)( const char *msg ); // host print
void (*CmdForward)( void ); // cmd forward to server
void (*CmdComplete)( char *complete_string ); // cmd autocomplete for system console
} launch_exp_t;
#endif//ENGINE_API_H

View File

@ -125,7 +125,7 @@ typedef struct
word port;
} netadr_t;
typedef struct sizebuf_s // FIXME: rename to netbuf
typedef struct sizebuf_s
{
bool overflowed; // set to true if the buffer size failed

View File

@ -34,7 +34,10 @@ Beta 13.02.10
6. revision of all resources
7. fix loaders for ATI1N and ATI2N OK
8. fix sky changelevel bug
9. rewrote UI_Field code
9. rewrote UI_Field code OK
10.autocomplete and command history for system console OK
11.create mutex for dedicated server OK
12.revision of Xash Environment System OK