01 Aug 2010

This commit is contained in:
g-cont 2010-08-01 00:00:00 +04:00 committed by Alibek Omarov
parent a152abab5c
commit edcae071bd
15 changed files with 748 additions and 66 deletions

View File

@ -1173,6 +1173,8 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle )
memset( szBuffer, 0, MAX_RULE_BUFFER );
pToken = COM_Parse( &pFileList );
if ( !pToken ) break;
if ( strlen( pToken ) <= 0 )
break;

View File

@ -1,6 +1,10 @@
build ????
build 1271
Engine: enable server.cfg, listenserver.cfg, mapcycle.txt etc
Engine: got to work mapcycle.txt
GameUI: implement redefine keys menu
Engine: added autocomplete for cmd 'exec'
Engine: added version info in menu
build 1270

View File

@ -348,7 +348,7 @@ void CL_MouseMove( usercmd_t *cmd )
rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
// check for dead
if( !g_iAlive ) return;
if( !g_iAlive || gHUD.m_iIntermission ) return;
accel_sensitivity = m_sensitivity->value + rate * cl_mouseaccel->value;
if ( gHUD.GetSensitivity( )) accel_sensitivity *= gHUD.GetSensitivity(); // scale by fov
@ -388,7 +388,8 @@ void CL_AdjustAngles( void )
float speed;
float up, down;
if( !g_iAlive ) return;
if( !g_iAlive || gHUD.m_iIntermission )
return;
if ( in_speed.state & 1 )
{
@ -494,7 +495,7 @@ void IN_CreateMove( usercmd_t *cmd, int msec, int active )
g_iAlive = gHUD.UpdateClientData();
if ( active )
if ( active && !gHUD.m_iIntermission )
{
GetViewAngles( cl_viewangles );

View File

@ -328,7 +328,7 @@ bool Cmd_GetMusicList( const char *s, char *completedname, int length )
=====================================
Cmd_GetSavesList
Prints or complete movie filename
Prints or complete savegame filename
=====================================
*/
bool Cmd_GetSavesList( const char *s, char *completedname, int length )
@ -369,6 +369,51 @@ bool Cmd_GetSavesList( const char *s, char *completedname, int length )
return true;
}
/*
=====================================
Cmd_GetConfigList
Prints or complete .cfg filename
=====================================
*/
bool Cmd_GetConfigList( const char *s, char *completedname, int length )
{
search_t *t;
string matchbuf;
int i, numconfigs;
t = FS_Search( va( "%s*.cfg", s ), true );
if( !t ) return false;
FS_FileBase( t->filenames[0], matchbuf );
if( completedname && length ) com.strncpy( completedname, matchbuf, length );
if( t->numfilenames == 1 ) return true;
for( i = 0, numconfigs = 0; i < t->numfilenames; i++ )
{
const char *ext = FS_FileExtension( t->filenames[i] );
if( com.stricmp( ext, "cfg" )) continue;
FS_FileBase( t->filenames[i], matchbuf );
Msg( "%16s\n", matchbuf );
numconfigs++;
}
Msg( "\n^3 %i configs found.\n", numconfigs );
Mem_Free( t );
// cut shortestMatch to the amount common with s
if( completedname && length )
{
for( i = 0; matchbuf[i]; i++ )
{
if( com.tolower( completedname[i] ) != com.tolower( matchbuf[i] ))
completedname[i] = 0;
}
}
return true;
}
/*
=====================================
Cmd_GetSoundList
@ -600,7 +645,7 @@ bool Cmd_GetGamesList( const char *s, char *completedname, int length )
bool Cmd_CheckMapsList( bool fRefresh )
{
byte buf[MAX_SYSPATH]; // 1 kb
byte buf[MAX_MSGLEN];
char *buffer;
string result;
search_t *t;
@ -673,15 +718,16 @@ bool Cmd_CheckMapsList( bool fRefresh )
// if there are entities to parse, a missing message key just
// means there is no title, so clear the message string now
token_t token;
bool worldspawn = true;
message[0] = 0;
com.strncpy( message, "No Title", MAX_STRING );
while( Com_ReadToken( ents, SC_ALLOW_NEWLINES|SC_ALLOW_PATHNAMES2, &token ))
{
if( !com.strcmp( token.string, "{" )) continue;
else if( !com.strcmp( token.string, "}" )) break;
else if( !com.strcmp( token.string, "message" ))
if( token.string[0] == '}' && worldspawn )
worldspawn = false;
else if( !com.strcmp( token.string, "message" ) && worldspawn )
{
// get the message contents
Com_ReadString( ents, SC_ALLOW_PATHNAMES2, message );
@ -691,19 +737,22 @@ bool Cmd_CheckMapsList( bool fRefresh )
Com_ReadToken( ents, SC_ALLOW_PATHNAMES2, &token );
if( !com.strcmp( token.string, GI->dm_entity ))
num_spawnpoints++;
else if( !com.strcmp( token.string, GI->sp_entity ))
num_spawnpoints++;
}
if( num_spawnpoints > 1 ) break; // valid map
}
Com_CloseScript( ents );
}
if( f ) FS_Close(f);
if( f ) FS_Close( f );
// format: mapname "maptitle"\n
com.sprintf( result, "%s \"%s\"\n", mapname, message );
com.strcat( buffer, result ); // add new string
Msg( "spawnpoints %i\n", num_spawnpoints );
if( num_spawnpoints > 1 )
{
// format: mapname "maptitle"\n
com.sprintf( result, "%s \"%s\"\n", mapname, message );
com.strcat( buffer, result ); // add new string
}
}
}
if( t ) Mem_Free( t ); // free search result
@ -727,6 +776,7 @@ autocomplete_list_t cmd_list[] =
{ "setfont", Cmd_GetFontList, },
{ "music", Cmd_GetSoundList, },
{ "movie", Cmd_GetMovieList },
{ "exec", Cmd_GetConfigList },
{ "give", Cmd_GetItemsList },
{ "drop", Cmd_GetItemsList },
{ "game", Cmd_GetGamesList },

View File

@ -1290,6 +1290,24 @@ Con_DrawConsole
*/
void Con_DrawConsole( void )
{
if( cls.key_dest == key_menu )
{
// draws the current build
byte *color = g_color_table[7];
int i, stringLen, width = 0, charH;
int start, height = scr_height->integer;
string curbuild;
com.snprintf( curbuild, MAX_STRING, "v%i/%g (build %i)", PROTOCOL_VERSION, SI->version, com_buildnum( ));
Con_DrawStringLen( curbuild, &stringLen, &charH );
start = scr_width->integer - stringLen * 1.05f;
stringLen = com.cstrlen( curbuild );
height -= charH * 1.5f;
for( i = 0; i < stringLen; i++ )
width += Con_DrawCharacter( start + width, height, curbuild[i], color );
}
// never draw console whel changelevel in-progress
if( cls.changelevel ) return;

View File

@ -396,4 +396,328 @@ bool BF_WriteString( bitbuf_t *bf, const char *pStr )
else BF_WriteChar( bf, 0 );
return !bf->bOverflow;
}
int BF_ReadOneBit( bitbuf_t *bf )
{
if( !BF_Overflow( bf, 1 ))
{
int value = bf->pData[bf->iCurBit >> 3] & (1 << ( bf->iCurBit & 7 ));
bf->iCurBit++;
return !!value;
}
return 0;
}
uint BF_ReadUBitLong( bitbuf_t *bf, int numbits )
{
int idword1;
uint dword1, ret;
if(( bf->iCurBit + numbits ) > bf->nDataBits )
{
bf->bOverflow = true;
bf->iCurBit = bf->nDataBits;
MsgDev( D_ERROR, "Msg %s: overflow!\n", bf->pDebugName );
return 0;
}
ASSERT( numbits > 0 && numbits <= 32 );
// Read the current dword.
idword1 = bf->iCurBit >> 5;
dword1 = ((uint *)bf->pData)[idword1];
dword1 >>= ( bf->iCurBit & 31 ); // get the bits we're interested in.
bf->iCurBit += numbits;
ret = dword1;
// Does it span this dword?
if(( bf->iCurBit - 1 ) >> 5 == idword1 )
{
if( numbits != 32 )
ret &= ExtraMasks[numbits];
}
else
{
int nExtraBits = bf->iCurBit & 31;
uint dword2 = ((uint *)bf->pData)[idword1+1] & ExtraMasks[nExtraBits];
// no need to mask since we hit the end of the dword.
// shift the second dword's part into the high bits.
ret |= (dword2 << ( numbits - nExtraBits ));
}
return ret;
}
float BF_ReadBitFloat( bitbuf_t *bf )
{
long val;
int bit, byte;
ASSERT( sizeof( float ) == sizeof( long ));
ASSERT( sizeof( float ) == 4 );
if( BF_Overflow( bf, 32 ))
return 0.0f;
bit = bf->iCurBit & 0x7;
byte = bf->iCurBit >> 3;
val = bf->pData[byte] >> bit;
val |= ((int)bf->pData[byte + 1]) << ( 8 - bit );
val |= ((int)bf->pData[byte + 2]) << ( 16 - bit );
val |= ((int)bf->pData[byte + 3]) << ( 24 - bit );
if( bit != 0 )
val |= ((int)bf->pData[byte + 4]) << ( 32 - bit );
bf->iCurBit += 32;
return *((float *)&val);
}
bool BF_ReadBits( bitbuf_t *bf, void *pOutData, int nBits )
{
byte *pOut = (byte *)pOutData;
int nBitsLeft = nBits;
// get output dword-aligned.
while((( dword )pOut & 3) != 0 && nBitsLeft >= 8 )
{
*pOut = (byte)BF_ReadUBitLong( bf, 8 );
++pOut;
nBitsLeft -= 8;
}
// read dwords.
while( nBitsLeft >= 32 )
{
*((dword *)pOut) = BF_ReadUBitLong( bf, 32 );
pOut += sizeof( dword );
nBitsLeft -= 32;
}
// read the remaining bytes.
while( nBitsLeft >= 8 )
{
*pOut = BF_ReadUBitLong( bf, 8 );
++pOut;
nBitsLeft -= 8;
}
// read the remaining bits.
if( nBitsLeft )
{
*pOut = BF_ReadUBitLong( bf, nBitsLeft );
}
return !bf->bOverflow;
}
float BF_ReadBitAngle( bitbuf_t *bf, int numbits )
{
float fReturn, shift;
int i;
shift = (float)( 1 << numbits );
i = BF_ReadUBitLong( bf, numbits );
fReturn = (float)i * ( 360.0 / shift );
return fReturn;
}
// Append numbits least significant bits from data to the current bit stream
int BF_ReadSBitLong( bitbuf_t *bf, int numbits )
{
int r, sign;
r = BF_ReadUBitLong( bf, numbits - 1 );
// NOTE: it does this wierdness here so it's bit-compatible with regular integer data in the buffer.
// (Some old code writes direct integers right into the buffer).
sign = BF_ReadOneBit( bf );
if( sign ) r = -(( 1 << ( numbits - 1 )) - r);
return r;
}
uint BF_ReadBitLong( bitbuf_t *bf, int numbits, bool bSigned )
{
if( bSigned )
return (uint)BF_ReadSBitLong( bf, numbits );
return BF_ReadUBitLong( bf, numbits );
}
// Basic Coordinate Routines (these contain bit-field size AND fixed point scaling constants)
float BF_ReadBitCoord( bitbuf_t *bf )
{
int intval = 0, fractval = 0, signbit = 0;
float value = 0.0;
// read the required integer and fraction flags
intval = BF_ReadOneBit( bf );
fractval = BF_ReadOneBit( bf );
// if we got either parse them, otherwise it's a zero.
if( intval || fractval )
{
// read the sign bit
signbit = BF_ReadOneBit( bf );
// if there's an integer, read it in
if( intval )
{
// adjust the integers from [0..MAX_COORD_VALUE-1] to [1..MAX_COORD_VALUE]
intval = BF_ReadUBitLong( bf, COORD_INTEGER_BITS ) + 1;
}
// if there's a fraction, read it in
if( fractval )
{
fractval = BF_ReadUBitLong( bf, COORD_FRACTIONAL_BITS );
}
// calculate the correct floating point value
value = intval + ((float)fractval * COORD_RESOLUTION );
// fixup the sign if negative.
if( signbit ) value = -value;
}
return value;
}
void BF_ReadBitVec3Coord( bitbuf_t *bf, vec3_t fa )
{
int xflag, yflag, zflag;
// This vector must be initialized! Otherwise, If any of the flags aren't set,
// the corresponding component will not be read and will be stack garbage.
fa[0] = fa[1] = fa[2] = 0.0f;
xflag = BF_ReadOneBit( bf );
yflag = BF_ReadOneBit( bf );
zflag = BF_ReadOneBit( bf );
if( xflag ) fa[0] = BF_ReadBitCoord( bf );
if( yflag ) fa[1] = BF_ReadBitCoord( bf );
if( zflag ) fa[2] = BF_ReadBitCoord( bf );
}
float BF_ReadBitNormal( bitbuf_t *bf )
{
// read the sign bit
int signbit = BF_ReadOneBit( bf );
// read the fractional part
uint fractval = BF_ReadUBitLong( bf, NORMAL_FRACTIONAL_BITS );
// calculate the correct floating point value
float value = (float)fractval * NORMAL_RESOLUTION;
// fixup the sign if negative.
if( signbit ) value = -value;
return value;
}
void BF_ReadBitVec3Normal( bitbuf_t *bf, vec3_t fa )
{
int xflag = BF_ReadOneBit( bf );
int yflag = BF_ReadOneBit( bf );
int znegative;
float fafafbfb;
if( xflag ) fa[0] = BF_ReadBitNormal( bf );
else fa[0] = 0.0f;
if( yflag ) fa[1] = BF_ReadBitNormal( bf );
else fa[1] = 0.0f;
// the first two imply the third (but not its sign)
znegative = BF_ReadOneBit( bf );
fafafbfb = fa[0] * fa[0] + fa[1] * fa[1];
if( fafafbfb < 1.0f )
fa[2] = com.sqrt( 1.0f - fafafbfb );
else fa[2] = 0.0f;
if( znegative ) fa[2] = -fa[2];
}
int BF_ReadChar( bitbuf_t *bf )
{
return BF_ReadSBitLong( bf, sizeof( char ) << 3 );
}
int BF_ReadByte( bitbuf_t *bf )
{
return BF_ReadUBitLong( bf, sizeof( byte ) << 3 );
}
int BF_ReadShort( bitbuf_t *bf )
{
return BF_ReadSBitLong( bf, sizeof( short ) << 3 );
}
int BF_ReadWord( bitbuf_t *bf )
{
return BF_ReadUBitLong( bf, sizeof( word ) << 3 );
}
long BF_ReadLong( bitbuf_t *bf )
{
return BF_ReadSBitLong( bf, sizeof( long ) << 3 );
}
float BF_ReadFloat( bitbuf_t *bf )
{
float ret;
ASSERT( sizeof( ret ) == 4 );
BF_ReadBits( bf, &ret, 32 );
return ret;
}
bool BF_ReadBytes( bitbuf_t *bf, void *pOut, int nBytes )
{
return BF_ReadBits( bf, pOut, nBytes << 3 );
}
const char *BF_ReadString( bitbuf_t *bf, bool bLine )
{
static char string[2048];
int maxLen = sizeof( string ) - 1;
char *pStr = string;
bool bTooSmall = false;
int iChar = 0;
while( 1 )
{
char val = BF_ReadChar( bf );
if( val == 0 ) break;
else if( bLine && val == '\n' )
break;
// translate all fmt spec to avoid crash bugs
if( val == '%' ) val = '.';
if( iChar < ( maxLen - 1 ))
{
pStr[iChar] = val;
iChar++;
}
else bTooSmall = true;
}
// make sure it's null-terminated.
ASSERT( iChar < maxLen );
pStr[iChar] = 0;
return string;
}

View File

@ -28,6 +28,9 @@ typedef struct
#define BF_WriteUBitLong( bf, data, bits ) BF_WriteUBitLongExt( bf, data, bits, true );
#define BF_StartReading BF_StartWriting
#define BF_GetNumBytesRead BF_GetNumBytesWritten
#define BF_ReadBitAngles BF_ReadBitVec3Coord
#define BF_ReadStringLine( bf ) BF_ReadString( bf, true );
// common functions
void BF_Init( bitbuf_t *bf, const char *pDebugName, void *pData, int nBytes, int nMaxBits );
@ -69,5 +72,28 @@ _inline int BF_GetMaxNumBits( bitbuf_t *bf ) { return bf->nDataBits; }
_inline int BF_GetNumBitsLeft( bitbuf_t *bf ) { return bf->nDataBits - bf->iCurBit; }
_inline int BF_GetNumBytesLeft( bitbuf_t *bf ) { return BF_GetNumBitsLeft( bf ) >> 3; }
_inline byte *BF_GetData( bitbuf_t *bf ) { return bf->pData; }
// Bit-read functions
int BF_ReadOneBit( bitbuf_t *bf );
float BF_ReadBitFloat( bitbuf_t *bf );
bool BF_ReadBits( bitbuf_t *bf, void *pOutData, int nBits );
float BF_ReadBitAngle( bitbuf_t *bf, int numbits );
int BF_ReadSBitLong( bitbuf_t *bf, int numbits );
uint BF_ReadBitLong( bitbuf_t *bf, int numbits, bool bSigned );
float BF_ReadBitCoord( bitbuf_t *bf );
void BF_ReadBitVec3Coord( bitbuf_t *bf, vec3_t fa );
float BF_ReadBitNormal( bitbuf_t *bf );
void BF_ReadBitVec3Normal( bitbuf_t *bf, vec3_t fa );
// Byte-read functions
int BF_ReadChar( bitbuf_t *bf );
int BF_ReadByte( bitbuf_t *bf );
int BF_ReadShort( bitbuf_t *bf );
int BF_ReadWord( bitbuf_t *bf );
long BF_ReadLong( bitbuf_t *bf );
float BF_ReadFloat( bitbuf_t *bf );
bool BF_ReadBytes( bitbuf_t *bf, void *pOut, int nBytes );
const char *BF_ReadString( bitbuf_t *bf, bool bLine );
#endif//NET_BUFFER_H

View File

@ -103,7 +103,6 @@ static net_field_t ent_fields[] =
{ ES_FIELD(health), NET_FLOAT, false }, // client health
{ ES_FIELD(iStepLeft), NET_LONG, false }, // client footsteps
{ ES_FIELD(flFallVelocity), NET_FLOAT, false }, // client fallvelocity
{ ES_FIELD(localtime), NET_FLOAT, false }, // push localtime
// revision 6. reserve for 5 fields without enlarge null_msg_size
{ NULL }
};

View File

@ -630,9 +630,10 @@ void SV_Init( void )
Cvar_Get ("showtriggers", "0", CVAR_LATCH, "debug cvar shows triggers" );
Cvar_Get ("sv_aim", "0", CVAR_ARCHIVE, "enable auto-aiming" );
Cvar_Get ("mapcyclefile", "mapcycle.txt", 0, "name of multiplayer map cycle configuration file" );
Cvar_Get ( "servercfgfile","server.cfg", 0, "name of dedicated server configuration file" );
Cvar_Get ( "lservercfgfile","listenserver.cfg", 0, "name of listen server configuration file" );
Cvar_Get ("servercfgfile","server.cfg", 0, "name of dedicated server configuration file" );
Cvar_Get ("lservercfgfile","listenserver.cfg", 0, "name of listen server configuration file" );
Cvar_Get ("sv_language", "0", 0, "game language (currently unused)" );
// half-life shared variables
sv_zmax = Cvar_Get ("sv_zmax", "0", 0, "zfar server value" );
sv_wateramp = Cvar_Get ("sv_wateramp", "0", 0, "global water wave height" );
@ -706,7 +707,7 @@ void SV_FinalMessage( char *message, bool reconnect )
if( reconnect )
{
if( sv.loadgame )
if( sv.loadgame || sv_maxclients->integer > 1 )
MSG_WriteByte( &msg, svc_changing );
else MSG_WriteByte( &msg, svc_reconnect );
}

View File

@ -37,6 +37,8 @@ const char *uiSoundOut = "common/launch_dnmenu1.wav";
const char *uiSoundLaunch = "common/launch_select2.wav";
const char *uiSoundGlow = "common/launch_glow1.wav";
const char *uiSoundBuzz = "common/menu1.wav";
const char *uiSoundKey = "common/launch_select1.wav";
const char *uiSoundRemoveKey = "commons/launch_deny1.wav";
const char *uiSoundMove = ""; // Xash3D not use movesound
const char *uiSoundNull = "";
@ -51,6 +53,18 @@ int uiColorWhite = 0xFFFFFFFF; // 255, 255, 255, 255 // useful for bitmaps
int uiColorDkGrey = 0xFF404040; // 64, 64, 64, 255 // shadow and grayed items
int uiColorBlack = 0xFF000000; // 0, 0, 0, 255 // some controls background
// color presets (this is nasty hack to allow color presets to part of text)
const int g_iColorTable[8] =
{
0xFF000000, // black
0xFFFF0000, // red
0xFF00FF00, // green
0xFFFFFF00, // yellow
0xFF0000FF, // blue
0xFF00FFFF, // cyan
0xFFF0B418, // dialog or button letters color
0xFFFFFFFF, // white
};
/*
=================
@ -1283,6 +1297,8 @@ void UI_Init( void )
Cmd_AddCommand( "menu_vidmodes", UI_VidModes_Menu, "open the video modes menu" );
Cmd_AddCommand( "menu_customgame", UI_CustomGame_Menu, "open the change game menu" );
// CHECK_MAP_LIST( TRUE );
memset( uiEmptyString, ' ', sizeof( uiEmptyString )); // HACKHACK
uiStatic.initialized = true;
}

View File

@ -311,6 +311,8 @@ extern uiStatic_t uiStatic;
extern char uiEmptyString[256]; // HACKHACK
extern const char *uiSoundIn;
extern const char *uiSoundOut;
extern const char *uiSoundKey;
extern const char *uiSoundRemoveKey;
extern const char *uiSoundLaunch;
extern const char *uiSoundBuzz;
extern const char *uiSoundGlow;

View File

@ -21,6 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "extdll.h"
#include "basemenu.h"
#include "utils.h"
#include "keydefs.h"
#define ART_BANNER "gfx/shell/head_controls"
@ -32,17 +33,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ID_CANCEL 5
#define ID_KEYLIST 6
#define ID_TABLEHINT 7
#define ID_MSGBOX 8
#define ID_MSGTEXT 9
#define MAX_KEYS 256
#define CMD_LENGTH 24
#define CMD_LENGTH 38
#define KEY1_LENGTH 20+CMD_LENGTH
#define KEY2_LENGTH 20+KEY1_LENGTH
typedef struct
{
char keysBind[MAX_KEYS][32];
char firstKey[MAX_KEYS][32];
char secondKey[MAX_KEYS][32];
char keysBind[MAX_KEYS][CMD_LENGTH];
char firstKey[MAX_KEYS][20];
char secondKey[MAX_KEYS][20];
char keysDescription[MAX_KEYS][256];
char *keysDescriptionPtr[MAX_KEYS];
@ -55,9 +58,15 @@ typedef struct
menuAction_s done;
menuAction_s cancel;
// redefine key wait dialog
menuAction_s msgBox;
menuAction_s dlgMessage;
menuScrollList_s keysList;
menuAction_s hintMessage;
char hintText[MAX_HINT_TEXT];
int bind_grab; // waiting for key input
} uiControls_t;
static uiControls_t uiControls;
@ -67,7 +76,7 @@ static uiControls_t uiControls;
UI_Controls_GetKeyBindings
=================
*/
static void UI_Controls_GetKeyBindings( char *command, int *twoKeys )
static void UI_Controls_GetKeyBindings( const char *command, int *twoKeys )
{
int i, count = 0;
const char *b;
@ -87,41 +96,264 @@ static void UI_Controls_GetKeyBindings( char *command, int *twoKeys )
if( count == 2 ) break;
}
}
// swap keys if needed
if( twoKeys[0] != -1 && twoKeys[1] != -1 )
{
int tempKey = twoKeys[1];
twoKeys[1] = twoKeys[0];
twoKeys[0] = tempKey;
}
}
/*
=================
UI_Controls_GetKeysList
=================
*/
static void UI_Controls_GetKeysList( void )
void UI_UnbindCommand( const char *command )
{
int i, j;
int i, l;
const char *b;
for( i = j = 0; i < MAX_KEYS; i++ )
l = strlen( command );
for( i = 0; i < 256; i++ )
{
b = KEY_GetBinding( i );
if( !b ) continue;
strncpy( uiControls.keysBind[j], b, sizeof( uiControls.keysBind[j] ));
strncpy( uiControls.firstKey[j], KEY_KeynumToString( i ), sizeof( uiControls.firstKey[j] ));
strncpy( uiControls.secondKey[j], KEY_KeynumToString( i ), sizeof( uiControls.secondKey[j] ));
if( !strncmp( b, command, l ))
KEY_SetBinding( i, "" );
}
}
StringConcat( uiControls.keysDescription[j], uiControls.keysBind[j], CMD_LENGTH );
StringConcat( uiControls.keysDescription[j], uiEmptyString, CMD_LENGTH );
StringConcat( uiControls.keysDescription[j], uiControls.firstKey[j], KEY1_LENGTH );
StringConcat( uiControls.keysDescription[j], uiEmptyString, KEY1_LENGTH );
StringConcat( uiControls.keysDescription[j], uiControls.secondKey[j], KEY2_LENGTH );
StringConcat( uiControls.keysDescription[j], uiEmptyString, KEY2_LENGTH );
uiControls.keysDescriptionPtr[j] = uiControls.keysDescription[j];
j++;
static void UI_Controls_ParseKeysList( void )
{
char *afile = (char *)LOAD_FILE( "gfx/shell/kb_act.lst", NULL );
const char *pfile = afile;
char *token;
int i = 0;
if( !afile )
{
ALERT( at_error, "UI_Parse_KeysList: kb_act.lst not found\n" );
return;
}
for( ; j < MAX_KEYS; j++ ) uiControls.keysDescriptionPtr[j] = NULL;
while(( token = COM_ParseToken( &pfile )) != NULL )
{
char str[128];
if( !stricmp( token, "blank" ))
{
// seperator
token = COM_ParseToken( &pfile );
if( !token ) break; // technically an error
sprintf( str, "^6%s^7", token ); // enable uiPromptTextColor
StringConcat( uiControls.keysDescription[i], str, strlen( str ) + 1 );
StringConcat( uiControls.keysDescription[i], uiEmptyString, 256 ); // empty
uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i];
strcpy( uiControls.keysBind[i], "" );
strcpy( uiControls.firstKey[i], "" );
strcpy( uiControls.secondKey[i], "" );
i++;
}
else
{
// key definition
int keys[2];
UI_Controls_GetKeyBindings( token, keys );
strncpy( uiControls.keysBind[i], token, sizeof( uiControls.keysBind[i] ));
token = COM_ParseToken( &pfile );
if( !token ) break; // technically an error
sprintf( str, "^6%s^7", token ); // enable uiPromptTextColor
if( keys[0] == -1 ) strcpy( uiControls.firstKey[i], "" );
else strncpy( uiControls.firstKey[i], KEY_KeynumToString( keys[0] ), sizeof( uiControls.firstKey[i] ));
if( keys[1] == -1 ) strcpy( uiControls.secondKey[i], "" );
else strncpy( uiControls.secondKey[i], KEY_KeynumToString( keys[1] ), sizeof( uiControls.secondKey[i] ));
StringConcat( uiControls.keysDescription[i], str, CMD_LENGTH );
StringConcat( uiControls.keysDescription[i], uiEmptyString, CMD_LENGTH );
// HACKHACK this color should be get from kb_keys.lst
if( !strnicmp( uiControls.firstKey[i], "MOUSE", 5 ))
sprintf( str, "^5%s^7", uiControls.firstKey[i] ); // cyan
else sprintf( str, "^3%s^7", uiControls.firstKey[i] ); // yellow
StringConcat( uiControls.keysDescription[i], str, KEY1_LENGTH );
StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY1_LENGTH );
// HACKHACK this color should be get from kb_keys.lst
if( !strnicmp( uiControls.secondKey[i], "MOUSE", 5 ))
sprintf( str, "^5%s^7", uiControls.secondKey[i] );// cyan
else sprintf( str, "^3%s^7", uiControls.secondKey[i] ); // yellow
StringConcat( uiControls.keysDescription[i], str, KEY2_LENGTH );
StringConcat( uiControls.keysDescription[i], uiEmptyString, KEY2_LENGTH );
uiControls.keysDescriptionPtr[i] = uiControls.keysDescription[i];
i++;
}
}
FREE_FILE( afile );
for( ; i < MAX_KEYS; i++ ) uiControls.keysDescriptionPtr[i] = NULL;
uiControls.keysList.itemNames = (const char **)uiControls.keysDescriptionPtr;
}
static void UI_PromptDialog( void )
{
// toggle main menu between active\inactive
// show\hide quit dialog
uiControls.defaults.generic.flags ^= QMF_INACTIVE;
uiControls.advanced.generic.flags ^= QMF_INACTIVE;
uiControls.done.generic.flags ^= QMF_INACTIVE;
uiControls.cancel.generic.flags ^= QMF_INACTIVE;
uiControls.keysList.generic.flags ^= QMF_INACTIVE;
uiControls.msgBox.generic.flags ^= QMF_HIDDEN;
uiControls.dlgMessage.generic.flags ^= QMF_HIDDEN;
}
static void UI_Controls_RestartMenu( void )
{
int lastSelectedKey = uiControls.keysList.curItem;
int lastTopItem = uiControls.keysList.topItem;
// restarts the menu
UI_PopMenu();
UI_Controls_Menu();
// restore last key and top item
uiControls.keysList.curItem = lastSelectedKey;
uiControls.keysList.topItem = lastTopItem;
}
static void UI_Controls_ResetKeysList( void )
{
char *afile = (char *)LOAD_FILE( "gfx/shell/kb_def.lst", NULL );
const char *pfile = afile;
char *token;
int i = 0;
if( !afile )
{
ALERT( at_error, "UI_Parse_KeysList: kb_act.lst not found\n" );
return;
}
while(( token = COM_ParseToken( &pfile )) != NULL )
{
char key[32];
strncpy( key, token, sizeof( key ));
token = COM_ParseToken( &pfile );
if( !token ) break; // technically an error
char cmd[128];
if( key[0] == '\\' && key[1] == '\\' )
{
key[0] = '\\';
key[1] = '\0';
}
UI_UnbindCommand( token );
sprintf( cmd, "bind \"%s\" \"%s\"\n", key, token );
CLIENT_COMMAND( TRUE, cmd );
}
FREE_FILE( afile );
UI_Controls_RestartMenu ();
}
/*
=================
UI_Controls_KeyFunc
=================
*/
static const char *UI_Controls_KeyFunc( int key, int down )
{
char cmd[128];
if( down )
{
if( uiControls.bind_grab ) // assume we are in grab-mode
{
// defining a key
if( key == '`' || key == '~' )
{
return uiSoundBuzz;
}
else if( key != K_ESCAPE )
{
const char *bindName = uiControls.keysBind[uiControls.keysList.curItem];
sprintf( cmd, "bind \"%s\" \"%s\"\n", KEY_KeynumToString( key ), bindName );
CLIENT_COMMAND( TRUE, cmd );
}
uiControls.bind_grab = false;
UI_Controls_RestartMenu();
return uiSoundLaunch;
}
if( key == K_ENTER && uiControls.dlgMessage.generic.flags & QMF_HIDDEN )
{
if( !strlen( uiControls.keysBind[uiControls.keysList.curItem] ))
{
// probably it's a seperator
return uiSoundBuzz;
}
// entering to grab-mode
const char *bindName = uiControls.keysBind[uiControls.keysList.curItem];
int keys[2];
UI_Controls_GetKeyBindings( bindName, keys );
if( keys[1] != -1 ) UI_UnbindCommand( bindName );
uiControls.bind_grab = true;
UI_PromptDialog(); // show prompt
return uiSoundKey;
}
if(( key == K_BACKSPACE || key == K_DEL ) && uiControls.dlgMessage.generic.flags & QMF_HIDDEN )
{
// delete bindings
if( !strlen( uiControls.keysBind[uiControls.keysList.curItem] ))
{
// probably it's a seperator
return uiSoundNull;
}
const char *bindName = uiControls.keysBind[uiControls.keysList.curItem];
UI_UnbindCommand( bindName );
UI_StartSound( uiSoundRemoveKey );
UI_Controls_RestartMenu();
return uiSoundNull;
}
}
return UI_DefaultKey( &uiControls.menu, key, down );
}
/*
=================
UI_MsgBox_Ownerdraw
=================
*/
static void UI_MsgBox_Ownerdraw( void *self )
{
menuCommon_s *item = (menuCommon_s *)self;
UI_FillRect( item->x, item->y, item->width, item->height, uiPromptBgColor );
}
/*
=================
UI_Controls_Callback
@ -141,9 +373,7 @@ static void UI_Controls_Callback( void *self, int event )
UI_PopMenu();
break;
case ID_DEFAULTS:
//FIXME
// CLIENT_COMMAND( TRUE, "exec keys.def\n" );
UI_Controls_GetKeysList (); // reload all buttons
UI_Controls_ResetKeysList ();
break;
case ID_ADVANCED:
UI_AdvControls_Menu();
@ -160,10 +390,12 @@ static void UI_Controls_Init( void )
{
memset( &uiControls, 0, sizeof( uiControls_t ));
uiControls.menu.keyFunc = UI_Controls_KeyFunc;
StringConcat( uiControls.hintText, "Action", CMD_LENGTH );
StringConcat( uiControls.hintText, uiEmptyString, CMD_LENGTH );
StringConcat( uiControls.hintText, uiEmptyString, CMD_LENGTH-4 );
StringConcat( uiControls.hintText, "Key/Button", KEY1_LENGTH );
StringConcat( uiControls.hintText, uiEmptyString, KEY1_LENGTH );
StringConcat( uiControls.hintText, uiEmptyString, KEY1_LENGTH-8 );
StringConcat( uiControls.hintText, "Alternate", KEY2_LENGTH );
StringConcat( uiControls.hintText, uiEmptyString, KEY2_LENGTH );
@ -238,7 +470,23 @@ static void UI_Controls_Init( void )
uiControls.keysList.generic.height = 440;
uiControls.keysList.generic.callback = UI_Controls_Callback;
UI_Controls_GetKeysList();
UI_Controls_ParseKeysList();
uiControls.msgBox.generic.id = ID_MSGBOX;
uiControls.msgBox.generic.type = QMTYPE_ACTION;
uiControls.msgBox.generic.flags = QMF_INACTIVE|QMF_HIDDEN;
uiControls.msgBox.generic.ownerdraw = UI_MsgBox_Ownerdraw; // just a fill rectangle
uiControls.msgBox.generic.x = 192;
uiControls.msgBox.generic.y = 256;
uiControls.msgBox.generic.width = 640;
uiControls.msgBox.generic.height = 128;
uiControls.dlgMessage.generic.id = ID_MSGTEXT;
uiControls.dlgMessage.generic.type = QMTYPE_ACTION;
uiControls.dlgMessage.generic.flags = QMF_INACTIVE|QMF_HIDDEN|QMF_DROPSHADOW;
uiControls.dlgMessage.generic.name = "Press a key or button";
uiControls.dlgMessage.generic.x = 320;
uiControls.dlgMessage.generic.y = 280;
UI_AddItem( &uiControls.menu, (void *)&uiControls.background );
UI_AddItem( &uiControls.menu, (void *)&uiControls.banner );
@ -248,6 +496,8 @@ static void UI_Controls_Init( void )
UI_AddItem( &uiControls.menu, (void *)&uiControls.cancel );
UI_AddItem( &uiControls.menu, (void *)&uiControls.hintMessage );
UI_AddItem( &uiControls.menu, (void *)&uiControls.keysList );
UI_AddItem( &uiControls.menu, (void *)&uiControls.msgBox );
UI_AddItem( &uiControls.menu, (void *)&uiControls.dlgMessage );
}
/*

View File

@ -26,19 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "utils.h"
#include "keydefs.h"
// color presets
const int g_iColorTable[8] =
{
0xFF000000, // black
0xFFFF0000, // red
0xFF00FF00, // green
0xFFFFFF00, // yellow
0xFF0000FF, // blue
0xFF00FFFF, // cyan
0xFFFF00FF, // magenta
0xFFFFFFFF, // white
};
#ifdef _DEBUG
void DBG_AssertFunction( BOOL fExpr, const char* szExpr, const char* szFile, int szLine, const char* szMessage )
{

View File

@ -372,7 +372,7 @@ void Sys_LookupInstance( void )
CloseHandle( Sys.hMutex );
Sys.hMutex = CreateSemaphore( NULL, 0, 1, "Xash Dedicated Server" );
if( !Sys.developer ) Sys.developer = 3; // otherwise we see empty console
com_sprintf( Sys.log_path, "bin/%s.log", com_timestamp( TIME_FILENAME )); // logs folder
com_sprintf( Sys.log_path, "engine.log", com_timestamp( TIME_FILENAME )); // logs folder
}
else
{
@ -382,7 +382,7 @@ void Sys_LookupInstance( void )
if( Sys.developer < D_WARN )
Sys.con_showalways = false;
com_sprintf( Sys.log_path, "bin/%s.log", com_timestamp( TIME_FILENAME )); // logs folder
com_sprintf( Sys.log_path, "engine.log", com_timestamp( TIME_FILENAME )); // logs folder
}
Sys.linked_dll = &engine_dll; // pointer to engine.dll info

View File

@ -1219,6 +1219,8 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle )
memset( szBuffer, 0, MAX_RULE_BUFFER );
pToken = COM_Parse( &pFileList );
if ( !pToken ) break;
if ( strlen( pToken ) <= 0 )
break;