20 Nov 2016

This commit is contained in:
g-cont 2016-11-20 00:00:00 +03:00 committed by Alibek Omarov
parent d5cac2bc91
commit 91b1f6c082
31 changed files with 1161 additions and 733 deletions

View File

@ -20,7 +20,7 @@
========================================================================
.WAD archive format (WhereAllData - WAD)
List of compressed files, that can be identify only by TYPE_*
List of compressed files, that can be identify only by TYP_*
<format>
header: dwadinfo_t[dwadinfo_t]
@ -33,7 +33,7 @@ infotable dlumpinfo_t[dwadinfo_t->numlumps]
========================================================================
*/
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W')
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W') // little-endian "WAD3" half-life wads
// dlumpinfo_t->attribs
#define ATTR_NONE 0 // allow to read-write

View File

@ -1224,7 +1224,7 @@ void CL_PlayDemo_f( void )
CL_Disconnect();
Host_ShutdownServer();
Con_Close();
Con_FastClose();
UI_SetActiveMenu( false );
}

View File

@ -1153,22 +1153,6 @@ void CL_Reconnect_f( void )
}
}
/*
=================
CL_ParseStatusMessage
Handle a reply from a info
=================
*/
void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
{
char *s = MSG_ReadString( msg );
// more info about servers
MsgDev( D_INFO, "Server: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( s, "gamedir" ));
UI_AddServerToList( from, s );
}
/*
=================
CL_FixupColorStringsForInfoString
@ -1233,6 +1217,26 @@ void CL_FixupColorStringsForInfoString( const char *in, char *out )
*out = '\0';
}
/*
=================
CL_ParseStatusMessage
Handle a reply from a info
=================
*/
void CL_ParseStatusMessage( netadr_t from, sizebuf_t *msg )
{
static char infostring[MAX_INFO_STRING+8];
char *s = MSG_ReadString( msg );
CL_FixupColorStringsForInfoString( s, infostring );
// more info about servers
MsgDev( D_INFO, "Server: %s, Game: %s\n", NET_AdrToString( from ), Info_ValueForKey( infostring, "gamedir" ));
UI_AddServerToList( from, infostring );
}
/*
=================
CL_ParseNETInfoMessage
@ -2153,4 +2157,6 @@ void CL_Shutdown( void )
SCR_FreeCinematic (); // release AVI's *after* client.dll because custom renderer may use them
S_Shutdown ();
R_Shutdown ();
Con_Shutdown ();
}

View File

@ -603,7 +603,7 @@ void SCR_Init( void )
Cmd_AddCommand( "sizeup", SCR_SizeUp_f, "screen size up to 10 points" );
Cmd_AddCommand( "sizedown", SCR_SizeDown_f, "screen size down to 10 points" );
if( host.state != HOST_RESTART && !UI_LoadProgs( ))
if( !UI_LoadProgs( ))
{
Msg( "^1Error: ^7can't initialize gameui.dll\n" ); // there is non fatal for us
if( !host.developer ) host.developer = 1; // we need console, because menu is missing
@ -616,12 +616,9 @@ void SCR_Init( void )
CL_InitNetgraph();
SCR_VidInit();
if( host.state != HOST_RESTART )
{
if( host.developer && Sys_CheckParm( "-toconsole" ))
Cbuf_AddText( "toggleconsole\n" );
else UI_SetActiveMenu( true );
}
if( host.developer && Sys_CheckParm( "-toconsole" ))
Cbuf_AddText( "toggleconsole\n" );
else UI_SetActiveMenu( true );
scr_init = true;
}
@ -635,9 +632,7 @@ void SCR_Shutdown( void )
Cmd_RemoveCommand( "skyname" );
Cmd_RemoveCommand( "viewpos" );
UI_SetActiveMenu( false );
if( host.state != HOST_RESTART )
UI_UnloadProgs();
UI_UnloadProgs();
scr_init = false;
}

View File

@ -37,7 +37,7 @@ GNU General Public License for more details.
#define MAX_CDTRACKS 32
#define MAX_IMAGES 256 // SpriteTextures
#define MAX_EFRAGS 4096
#define MAX_REQUESTS 128
#define MAX_REQUESTS 64
// screenshot types
#define VID_SCREENSHOT 0
@ -831,6 +831,7 @@ extern convar_t *con_fontsize;
qboolean Con_Visible( void );
void Con_Init( void );
void Con_VidInit( void );
void Con_Shutdown( void );
void Con_ToggleConsole_f( void );
void Con_ClearNotify( void );
void Con_DrawDebug( void );
@ -848,7 +849,7 @@ void Con_CharEvent( int key );
void Con_RestoreFont( void );
void Key_Console( int key );
void Key_Message( int key );
void Con_Close( void );
void Con_FastClose( void );
//
// s_main.c

View File

@ -379,6 +379,8 @@ void Matrix4x4_CreateScale3( matrix4x4 out, float x, float y, float z );
void Matrix4x4_CreateProjection(matrix4x4 out, float xMax, float xMin, float yMax, float yMin, float zNear, float zFar);
void Matrix4x4_CreateOrtho(matrix4x4 m, float xLeft, float xRight, float yBottom, float yTop, float zNear, float zFar);
void Matrix4x4_CreateModelview( matrix4x4 out );
void R_InitLookupTables( void );
float R_FastSin( float t );
//
// gl_rmisc.

View File

@ -18,6 +18,40 @@ GNU General Public License for more details.
#include "mathlib.h"
#include "client.h"
#define FTABLE_SIZE 1024
#define FTABLE_CLAMP( x ) (((uint)(( x ) * FTABLE_SIZE ) & ( FTABLE_SIZE - 1 )))
#define FTABLE_EVALUATE( table, x ) (( table )[FTABLE_CLAMP( x )] )
static float r_sintable[FTABLE_SIZE];
/*
==============
R_InitLookupTables
==============
*/
void R_InitLookupTables( void )
{
float t;
int i;
for( i = 0; i < FTABLE_SIZE; i++ )
{
t = (float)i / (float)FTABLE_SIZE;
r_sintable[i] = sin( t * M_PI2 );
}
}
/*
==============
R_FastSin
==============
*/
float R_FastSin( float t )
{
return sin( t );// FIXME FTABLE_EVALUATE( r_sintable, t );
}
/*
====================
V_CalcFov

View File

@ -1562,7 +1562,7 @@ void VID_CheckChanges( void )
if( renderinfo->modified )
{
if( !VID_SetMode())
if( !VID_SetMode( ))
{
Msg( "Error: can't initialize video subsystem\n" );
Host_NewInstance( va("#%s", GI->gamefolder ), "stopped" );
@ -1620,8 +1620,6 @@ GL_SetDefaults
*/
static void GL_SetDefaults( void )
{
int i;
pglFinish();
pglClearColor( 0.5f, 0.5f, 0.5f, 1.0f );
@ -1645,19 +1643,8 @@ static void GL_SetDefaults( void )
pglPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
pglPolygonOffset( -1.0f, -2.0f );
// properly disable multitexturing at startup
for( i = (MAX_TEXTURE_UNITS - 1); i > 0; i-- )
{
if( i >= GL_MaxTextureUnits( ))
continue;
GL_CleanupAllTextureUnits();
GL_SelectTexture( i );
pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
pglDisable( GL_BLEND );
pglDisable( GL_TEXTURE_2D );
}
GL_SelectTexture( 0 );
pglDisable( GL_BLEND );
pglDisable( GL_ALPHA_TEST );
pglDisable( GL_POLYGON_OFFSET_FILL );
@ -2035,6 +2022,7 @@ qboolean R_Init( void )
GL_InitCommands();
GL_SetDefaultState();
R_InitLookupTables();
// create the window and set up the context
if( !R_Init_OpenGL( ))

View File

@ -22,6 +22,7 @@ GNU General Public License for more details.
#define SKYCLOUDS_QUALITY 12
#define MAX_CLIP_VERTS 128 // skybox clip vertices
#define TURBSCALE ( 256.0f / ( M_PI2 ))
#define R_TurbSin( x ) ( R_FastSin( x * 0.02f + cl.time ))
static const char* r_skyBoxSuffix[6] = { "rt", "bk", "lf", "ft", "up", "dn" };
static const int r_skyTexOrder[6] = { 0, 2, 1, 3, 4, 5 };
@ -800,8 +801,7 @@ void EmitWaterPolys( glpoly_t *polys, qboolean noCull )
{
if( waveHeight )
{
nv = v[2] + waveHeight + ( waveHeight * sin(v[0] * 0.02f + cl.time)
* sin(v[1] * 0.02 + cl.time) * sin(v[2] * 0.02f + cl.time));
nv = v[2] + waveHeight + ( waveHeight * R_TurbSin( v[0] ) * R_TurbSin( v[1] ) * R_TurbSin( v[2] ));
nv -= waveHeight;
}
else nv = v[2];

View File

@ -132,6 +132,56 @@ skipwhite:
return data;
}
/*
================
COM_ParseVector
================
*/
qboolean COM_ParseVector( char **pfile, float *v, size_t size )
{
string token;
qboolean bracket = false;
char *saved;
uint i;
if( v == NULL || size == 0 )
return false;
memset( v, 0, sizeof( *v ) * size );
if( size == 1 )
{
*pfile = COM_ParseFile( *pfile, token );
v[0] = Q_atof( token );
return true;
}
saved = *pfile;
if(( *pfile = COM_ParseFile( *pfile, token )) == NULL )
return false;
if( token[0] == '(' )
bracket = true;
else *pfile = saved; // restore token to right get it again
for( i = 0; i < size; i++ )
{
*pfile = COM_ParseFile( *pfile, token );
v[i] = Q_atof( token );
}
if( !bracket ) return true; // done
if(( *pfile = COM_ParseFile( *pfile, token )) == NULL )
return false;
if( token[0] == ')' )
return true;
return false;
}
/*
=============
COM_FileSize

View File

@ -36,6 +36,7 @@ extern "C" {
#define MAX_STRING 256 // generic string
#define MAX_INFO_STRING 256 // infostrings are transmitted across network
#define MAX_SYSPATH 1024 // system filepath
#define MAX_PRINT_MSG 8192 // how many symbols can handle single call of Msg or MsgDev
#define MAX_MODS 512 // environment games that engine can keep visible
#define EXPORT __declspec( dllexport )
#define BIT( n ) (1<<( n ))
@ -225,7 +226,6 @@ typedef enum
HOST_ERR_FATAL, // sys error
HOST_SLEEP, // sleeped by different reason, e.g. minimize window
HOST_NOFOCUS, // same as HOST_FRAME, but disable mouse
HOST_RESTART, // during the changes video mode
HOST_CRASHED // an exception handler called
} host_state;
@ -370,15 +370,16 @@ void FS_LoadGameInfo( const char *rootfolder );
void FS_FileBase( const char *in, char *out );
const char *FS_FileExtension( const char *in );
void FS_DefaultExtension( char *path, const char *extension );
void FS_ExtractFilePath( const char* const path, char* dest );
void FS_ExtractFilePath( const char *path, char *dest );
const char *FS_GetDiskPath( const char *name, qboolean gamedironly );
const char *FS_FileWithoutPath( const char *in );
wfile_t *W_Open( const char *filename, const char *mode );
wfile_t *W_Open( const char *filename, const char *mode, int *errorcode );
byte *W_LoadLump( wfile_t *wad, const char *lumpname, size_t *lumpsizeptr, const char type );
void W_Close( wfile_t *wad );
file_t *FS_OpenFile( const char *path, long *filesizeptr, qboolean gamedironly );
byte *FS_LoadFile( const char *path, long *filesizeptr, qboolean gamedironly );
qboolean FS_WriteFile( const char *filename, const void *data, long len );
qboolean COM_ParseVector( char **pfile, float *v, size_t size );
int COM_FileSize( const char *filename );
void COM_FixSlashes( char *pname );
void COM_FreeFile( void *buffer );
@ -396,7 +397,7 @@ long FS_FileTime( const char *filename, qboolean gamedironly );
int FS_Print( file_t *file, const char *msg );
qboolean FS_Rename( const char *oldname, const char *newname );
qboolean FS_FileExists( const char *filename, qboolean gamedironly );
void FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
qboolean FS_FileCopy( file_t *pOutput, file_t *pInput, int fileSize );
qboolean FS_Delete( const char *path );
int FS_UnGetc( file_t *file, byte c );
void FS_StripExtension( char *path );
@ -913,8 +914,6 @@ void S_StopAllSounds( void );
void BuildGammaTable( float gamma, float texGamma );
byte TextureToTexGamma( byte b );
byte TextureToGamma( byte b );
float TextureToLinear( int c );
int LinearToTexture( float f );
#ifdef __cplusplus
}

View File

@ -25,14 +25,19 @@ convar_t *con_notifytime;
convar_t *scr_conspeed;
convar_t *con_fontsize;
#define CON_TIMES 5 // need for 4 lines
#define CON_TIMES 4 // notify lines
#define COLOR_DEFAULT '7'
#define CON_HISTORY 64
#define MAX_DBG_NOTIFY 128
#define CON_MAXCMDS 4096 // auto-complete intermediate list
#define CON_NUMFONTS 3 // maxfonts
#define CON_TEXTSIZE 131072 // 128 kb buffer
#define CON_LINES( i ) (con.lines[(con.lines_first + (i)) % con.maxlines])
#define CON_LINES_COUNT con.lines_count
#define CON_LINES_LAST() CON_LINES( CON_LINES_COUNT - 1 )
#define CON_TEXTSIZE 1048576 // max scrollback buffer characters in console (1 Mb)
#define CON_MAXLINES 16384 // max scrollback buffer lines in console
// console color typeing
rgba_t g_color_table[8] =
@ -63,29 +68,38 @@ typedef struct
int key_dest;
} notify_t;
typedef struct con_lineinfo_s
{
char *start;
size_t length;
double addtime; // notify stuff
} con_lineinfo_t;
typedef struct
{
qboolean initialized;
short text[CON_TEXTSIZE];
int current; // line where next message will be printed
int display; // bottom of console displays this line
int x; // offset in current line for next print
// conbuffer
char *buffer; // common buffer for all console lines
int bufsize; // CON_TEXSIZE
con_lineinfo_t *lines; // console lines
int maxlines; // CON_MAXLINES
int lines_first; // cyclic buffer
int lines_count;
// console scroll
int backscroll; // lines up from bottom to display
int linewidth; // characters across screen
int totallines; // total lines in console scrollback
float displayFrac; // aproaches finalFrac at scr_conspeed
float finalFrac; // 0.0 to 1.0 lines of console to display
// console animation
int showlines; // how many lines we should display
int vislines; // in scanlines
double times[CON_TIMES]; // host.realtime the line was generated for transparent notify lines
rgba_t color;
// console images
int background; // console background
// conchars
// console fonts
cl_font_t chars[CON_NUMFONTS];// fonts.wad/font1.fnt
cl_font_t *curFont, *lastUsedFont;
@ -124,11 +138,8 @@ Con_Clear_f
*/
void Con_Clear_f( void )
{
int i;
for( i = 0; i < CON_TEXTSIZE; i++ )
con.text[i] = ( ColorIndex( COLOR_DEFAULT ) << 8 ) | ' ';
con.display = con.current; // go to end
con.lines_count = 0;
con.backscroll = 0; // go to end
}
/*
@ -169,8 +180,8 @@ void Con_ClearNotify( void )
{
int i;
for( i = 0; i < CON_TIMES; i++ )
con.times[i] = 0;
for( i = 0; i < CON_LINES_COUNT; i++ )
CON_LINES( i ).addtime = 0.0;
}
/*
@ -296,6 +307,135 @@ void Con_ToggleConsole_f( void )
}
}
/*
================
Con_FixTimes
Notifies the console code about the current time
(and shifts back times of other entries when the time
went backwards)
================
*/
void Con_FixTimes( void )
{
double diff;
int i;
if( con.lines_count <= 0 ) return;
diff = cl.time - CON_LINES_LAST().addtime;
if( diff >= 0.0 ) return; // nothing to fix
for( i = 0; i < con.lines_count; i++ )
CON_LINES( i ).addtime += diff;
}
/*
================
Con_DeleteLine
Deletes the first line from the console history.
================
*/
void Con_DeleteLine( void )
{
if( con.lines_count == 0 )
return;
con.lines_count--;
con.lines_first = (con.lines_first + 1) % con.maxlines;
}
/*
================
Con_DeleteLastLine
Deletes the last line from the console history.
================
*/
void Con_DeleteLastLine( void )
{
if( con.lines_count == 0 )
return;
con.lines_count--;
}
/*
================
Con_BytesLeft
Checks if there is space for a line of the given length, and if yes, returns a
pointer to the start of such a space, and NULL otherwise.
================
*/
static char *Con_BytesLeft( int length )
{
if( length > con.bufsize )
return NULL;
if( con.lines_count == 0 )
{
return con.buffer;
}
else
{
char *firstline_start = con.lines[con.lines_first].start;
char *lastline_onepastend = CON_LINES_LAST().start + CON_LINES_LAST().length;
// the buffer is cyclic, so we first have two cases...
if( firstline_start < lastline_onepastend ) // buffer is contiguous
{
// put at end?
if( length <= con.buffer + con.bufsize - lastline_onepastend )
return lastline_onepastend;
// put at beginning?
else if( length <= firstline_start - con.buffer )
return con.buffer;
return NULL;
}
else
{
// buffer has a contiguous hole
if( length <= firstline_start - lastline_onepastend )
return lastline_onepastend;
return NULL;
}
}
}
/*
================
Con_AddLine
Appends a given string as a new line to the console.
================
*/
void Con_AddLine( const char *line, int length )
{
byte *putpos;
con_lineinfo_t *p;
if( !con.initialized ) return;
Con_FixTimes();
length++; // reserve space for term
ASSERT( length < CON_TEXTSIZE );
while( !( putpos = Con_BytesLeft( length )) || con.lines_count >= con.maxlines )
Con_DeleteLine();
memcpy( putpos, line, length );
putpos[length - 1] = '\0';
con.lines_count++;
p = &CON_LINES_LAST();
p->start = putpos;
p->length = length;
p->addtime = cl.time;
}
/*
================
Con_CheckResize
@ -305,63 +445,21 @@ If the line width has changed, reformat the buffer.
*/
void Con_CheckResize( void )
{
int i, j, width, numlines, numchars;
int oldwidth, oldtotallines;
short tbuf[CON_TEXTSIZE];
int charWidth = 8;
int i, width;
if( con.curFont && con.curFont->hFontTexture )
charWidth = con.curFont->charWidths[' '] - 1;
charWidth = con.curFont->charWidths['M'] - 1;
width = ( scr_width->integer / charWidth );
con.vislines = 0; // FIXME: sometimes here get unthinkable values
width = ( scr_width->integer / charWidth ) - 2;
if( !glw_state.initialized ) width = 78;
if( width == con.linewidth )
return;
if( !glw_state.initialized )
{
// video hasn't been initialized yet
con.linewidth = width;
con.totallines = CON_TEXTSIZE / con.linewidth;
for( i = 0; i < CON_TEXTSIZE; i++ )
con.text[i] = ( ColorIndex( COLOR_DEFAULT ) << 8 ) | ' ';
}
else
{
oldwidth = con.linewidth;
con.linewidth = width;
oldtotallines = con.totallines;
con.totallines = CON_TEXTSIZE / con.linewidth;
numlines = oldtotallines;
if( con.totallines < numlines )
numlines = con.totallines;
numchars = oldwidth;
if( con.linewidth < numchars )
numchars = con.linewidth;
memcpy( tbuf, con.text, CON_TEXTSIZE * sizeof( short ));
for( i = 0; i < CON_TEXTSIZE; i++ )
con.text[i] = ( ColorIndex( COLOR_DEFAULT ) << 8 ) | ' ';
for( i = 0; i < numlines; i++ )
{
for( j = 0; j < numchars; j++ )
{
con.text[(con.totallines - 1 - i) * con.linewidth + j] =
tbuf[((con.current - i + oldtotallines) % oldtotallines) * oldwidth + j + con.x];
}
}
Con_ClearNotify ();
}
con.current = con.totallines - 1;
con.display = con.current;
Con_ClearNotify();
con.linewidth = width;
con.backscroll = 0;
con.input.widthInChars = con.linewidth;
@ -376,10 +474,7 @@ Con_PageUp
*/
void Con_PageUp( int lines )
{
con.display -= abs( lines );
if( con.current - con.display >= con.totallines )
con.display = con.current - con.totallines + 1;
con.backscroll += abs( lines );
}
/*
@ -389,10 +484,7 @@ Con_PageDown
*/
void Con_PageDown( int lines )
{
con.display += abs( lines );
if( con.display > con.current )
con.display = con.current;
con.backscroll -= abs( lines );
}
/*
@ -402,10 +494,7 @@ Con_Top
*/
void Con_Top( void )
{
con.display = con.totallines;
if( con.current - con.display >= con.totallines )
con.display = con.current - con.totallines + 1;
con.backscroll = CON_MAXLINES;
}
/*
@ -415,7 +504,7 @@ Con_Bottom
*/
void Con_Bottom( void )
{
con.display = con.current;
con.backscroll = 0;
}
/*
@ -442,7 +531,7 @@ static void Con_LoadConsoleFont( int fontNumber, cl_font_t *font )
if( font->valid ) return; // already loaded
// loading conchars
font->hFontTexture = GL_LoadTexture( va( "fonts.wad/font%i", fontNumber ), NULL, 0, TF_FONT, NULL );
font->hFontTexture = GL_LoadTexture( va( "fonts.wad/font%i", fontNumber ), NULL, 0, TF_FONT|TF_NEAREST, NULL );
R_GetTextureParms( &fontWidth, NULL, font->hFontTexture );
// setup creditsfont
@ -504,7 +593,7 @@ static void Con_LoadConchars( void )
/*
====================
TextAdjustSize
Con_TextAdjustSize
draw charcters routine
====================
@ -513,7 +602,6 @@ static void Con_TextAdjustSize( int *x, int *y, int *w, int *h )
{
float xscale, yscale;
if( !clgame.ds.adjust_size ) return;
if( !x && !y && !w && !h ) return;
// scale for screen sizes
@ -561,7 +649,8 @@ static int Con_DrawGenericChar( int x, int y, int number, rgba_t color )
width = rc->right - rc->left;
height = rc->bottom - rc->top;
Con_TextAdjustSize( &x, &y, &width, &height );
if( clgame.ds.adjust_size )
Con_TextAdjustSize( &x, &y, &width, &height );
R_DrawStretchPic( x, y, width, height, s1, t1, s2, t2, con.curFont->hFontTexture );
pglColor4ub( 255, 255, 255, 255 ); // don't forget reset color
@ -681,10 +770,10 @@ int Con_DrawGenericString( int x, int y, const char *string, rgba_t setColor, qb
if( !con.curFont ) return 0; // no font set
// draw the colored text
s = string;
*(uint *)color = *(uint *)setColor;
s = string;
while ( *s )
while( *s )
{
if( *s == '\n' )
{
@ -748,6 +837,13 @@ void Con_Init( void )
con_notifytime = Cvar_Get( "con_notifytime", "3", CVAR_ARCHIVE, "notify time to live" );
con_fontsize = Cvar_Get( "con_fontsize", "1", CVAR_ARCHIVE, "console font number (0, 1 or 2)" );
// init the console buffer
con.bufsize = CON_TEXTSIZE;
con.buffer = (char *)Z_Malloc( con.bufsize );
con.maxlines = CON_MAXLINES;
con.lines = (con_lineinfo_t *)Z_Malloc( con.maxlines * sizeof( *con.lines ));
con.lines_first = con.lines_count = 0;
Con_CheckResize();
Con_ClearField( &con.input );
@ -773,26 +869,22 @@ void Con_Init( void )
}
/*
===============
Con_Linefeed
===============
================
Con_Shutdown
================
*/
void Con_Linefeed( void )
void Con_Shutdown( void )
{
int i;
con.initialized = false;
// mark time for transparent overlay
if( con.current >= 0 )
con.times[con.current % CON_TIMES] = host.realtime;
if( con.buffer )
Mem_Free( con.buffer );
con.x = 0;
if( con.display == con.current )
con.display++;
if( con.lines )
Mem_Free( con.lines );
con.current++;
for( i = 0; i < con.linewidth; i++ )
con.text[(con.current % con.totallines) * con.linewidth+i] = ( ColorIndex( COLOR_DEFAULT ) << 8 ) | ' ';
con.buffer = NULL;
con.lines = NULL;
}
/*
@ -800,54 +892,52 @@ void Con_Linefeed( void )
Con_Print
Handles cursor positioning, line wrapping, etc
All console printing must go through this in order to be logged to disk
If no console is visible, the text will appear at the top of the game window
All console printing must go through this in order to be displayed
If no console is visible, the notify window will pop up.
================
*/
void Con_Print( const char *txt )
{
int y, c, l, color;
static int cr_pending = 0;
static char buf[MAX_PRINT_MSG];
static int bufpos = 0;
// client not running
if( !con.initialized || host.type == HOST_DEDICATED )
if( !con.initialized || !con.buffer || host.type == HOST_DEDICATED )
return;
color = ColorIndex( COLOR_DEFAULT );
while(( c = *txt ) != 0 )
for( ; *txt; txt++ )
{
if( IsColorString( txt ))
if( cr_pending )
{
color = ColorIndex( *( txt + 1 ));
txt += 2;
continue;
Con_DeleteLastLine();
cr_pending = 0;
}
// count word length
for( l = 0; l < con.linewidth; l++ )
if( txt[l] <= ' ' ) break;
txt++;
switch( c )
switch( *txt )
{
case '\n':
Con_Linefeed();
case '\0':
break;
case '\r':
con.x = 0;
Con_AddLine( buf, bufpos );
cr_pending = 1;
bufpos = 0;
break;
default: // display character and advance
y = con.current % con.totallines;
con.text[y*con.linewidth+con.x] = (color << 8) | c;
con.x++;
if( con.x >= con.linewidth )
case '\n':
Con_AddLine( buf, bufpos );
bufpos = 0;
break;
default:
buf[bufpos++] = *txt;
if(( bufpos >= sizeof( buf ) - 1 ) || bufpos >= ( con.linewidth - 1 ))
{
Con_Linefeed();
con.x = 0;
Con_AddLine( buf, bufpos );
bufpos = 0;
}
break;
}
}
}
/*
@ -1448,7 +1538,7 @@ void Key_Console( int key )
}
// enter finishes the line
if ( key == K_ENTER || key == K_KP_ENTER )
if( key == K_ENTER || key == K_KP_ENTER )
{
// if not in the game explicitly prepent a slash if needed
if( cls.state != ca_active && con.input.buffer[0] != '\\' && con.input.buffer[0] != '/' )
@ -1471,8 +1561,7 @@ void Key_Console( int key )
// copy line to history buffer
con.historyLines[con.nextHistoryLine % CON_HISTORY] = con.input;
con.nextHistoryLine++;
con.historyLine = con.nextHistoryLine;
con.historyLine = con.nextHistoryLine++;
Con_ClearField( &con.input );
con.input.widthInChars = con.linewidth;
@ -1496,9 +1585,7 @@ void Key_Console( int key )
if(( key == K_MWHEELUP && Key_IsDown( K_SHIFT )) || ( key == K_UPARROW ) || (( Q_tolower(key) == 'p' ) && Key_IsDown( K_CTRL )))
{
if( con.nextHistoryLine - con.historyLine < CON_HISTORY && con.historyLine > 0 )
{
con.historyLine--;
}
con.input = con.historyLines[con.historyLine % CON_HISTORY];
return;
}
@ -1514,13 +1601,13 @@ void Key_Console( int key )
// console scrolling
if( key == K_PGUP )
{
Con_PageUp( 2 );
Con_PageUp( 1 );
return;
}
if( key == K_PGDN )
{
Con_PageDown( 2 );
Con_PageDown( 1 );
return;
}
@ -1606,21 +1693,17 @@ Con_DrawInput
The input line scrolls horizontally if typing goes beyond the right edge
================
*/
void Con_DrawInput( void )
void Con_DrawInput( int lines )
{
byte *colorDefault;
int x, y;
int y;
// don't draw anything (always draw if not active)
if( cls.key_dest != key_console ) return;
if( !con.curFont ) return;
if( cls.key_dest != key_console || !con.curFont )
return;
x = QCHAR_WIDTH; // room for ']'
y = con.vislines - ( con.curFont->charHeight * 2 );
colorDefault = g_color_table[ColorIndex( COLOR_DEFAULT )];
Con_DrawCharacter( QCHAR_WIDTH >> 1, y, ']', colorDefault );
Field_DrawInputLine( x, y, &con.input );
y = lines - ( con.curFont->charHeight * 2 );
Con_DrawCharacter( 8, y, ']', g_color_table[7] );
Field_DrawInputLine( 16, y, &con.input );
}
/*
@ -1633,8 +1716,8 @@ Custom debug messages
int Con_DrawDebugLines( void )
{
int i, count = 0;
int y = 20;
int defaultX;
int y = 20;
defaultX = glState.width / 4;
@ -1689,38 +1772,24 @@ Draws the last few lines of output transparently over the game top
*/
void Con_DrawNotify( void )
{
int i, x, v = 0;
int start, currentColor;
short *text;
float time;
double time = cl.time;
int i, x, y = 0;
if( !con.curFont ) return;
x = con.curFont->charWidths[' ']; // offset one space at left screen side
if( host.developer && ( !Cvar_VariableInteger( "cl_background" ) && !Cvar_VariableInteger( "sv_background" )))
{
currentColor = 7;
pglColor4ubv( g_color_table[currentColor] );
for( i = con.current - CON_TIMES + 1; i <= con.current; i++ )
for( i = CON_LINES_COUNT - CON_TIMES; i < CON_LINES_COUNT; i++ )
{
if( i < 0 ) continue;
time = con.times[i % CON_TIMES];
if( time == 0 ) continue;
time = host.realtime - time;
con_lineinfo_t *l = &CON_LINES( i );
if( time > con_notifytime->value )
continue; // expired
if( l->addtime < ( time - con_notifytime->value ))
continue;
text = con.text + (i % con.totallines) * con.linewidth;
start = con.curFont->charWidths[' ']; // offset one space at left screen side
for( x = 0; x < con.linewidth; x++ )
{
if((( text[x] >> 8 ) & 7 ) != currentColor )
currentColor = ( text[x] >> 8 ) & 7;
start += Con_DrawCharacter( start, v, text[x] & 0xFF, g_color_table[currentColor] );
}
v += con.curFont->charHeight;
Con_DrawString( x, y, l->start, g_color_table[7] );
y += con.curFont->charHeight;
}
}
@ -1729,26 +1798,71 @@ void Con_DrawNotify( void )
string buf;
int len;
currentColor = 7;
pglColor4ubv( g_color_table[currentColor] );
start = con.curFont->charWidths[' ']; // offset one space at left screen side
// update chatline position from client.dll
if( clgame.dllFuncs.pfnChatInputPosition )
clgame.dllFuncs.pfnChatInputPosition( &start, &v );
clgame.dllFuncs.pfnChatInputPosition( &x, &y );
Q_snprintf( buf, sizeof( buf ), "%s: ", con.chat_cmd );
Con_DrawStringLen( buf, &len, NULL );
Con_DrawString( start, v, buf, g_color_table[7] );
Con_DrawString( x, y, buf, g_color_table[7] );
Field_DrawInputLine( start + len, v, &con.chat );
Field_DrawInputLine( x + len, y, &con.chat );
}
pglColor4ub( 255, 255, 255, 255 );
}
/*
================
Con_DrawConsoleLine
Draws a line of the console; returns its height in lines.
If alpha is 0, the line is not drawn, but still wrapped and its height
returned.
================
*/
int Con_DrawConsoleLine( int y, int lineno )
{
con_lineinfo_t *li = &CON_LINES( lineno );
if( y >= con.curFont->charHeight )
Con_DrawGenericString( con.curFont->charWidths[' '], y, li->start, g_color_table[7], false, -1 );
return con.curFont->charHeight;
}
/*
================
Con_LastVisibleLine
Calculates the last visible line index and how much to show
of it based on con.backscroll.
================
*/
static void Con_LastVisibleLine( int *lastline )
{
int i, lines_seen = 0;
con.backscroll = Q_max( 0, con.backscroll );
*lastline = 0;
// now count until we saw con_backscroll actual lines
for( i = CON_LINES_COUNT - 1; i >= 0; i-- )
{
// line is the last visible line?
*lastline = i;
if( lines_seen + 1 > con.backscroll && lines_seen <= con.backscroll )
return;
lines_seen += 1;
}
// if we get here, no line was on screen - scroll so that one line is visible then.
con.backscroll = lines_seen - 1;
}
/*
================
Con_DrawConsole
@ -1756,37 +1870,27 @@ Con_DrawConsole
Draws the console with the solid background
================
*/
void Con_DrawSolidConsole( float frac )
void Con_DrawSolidConsole( int lines )
{
int i, x, y;
int rows;
short *text;
int row, start;
int currentColor;
string curbuild;
float fraction;
int start;
con.vislines = scr_height->integer * frac;
if( con.vislines <= 0 ) return;
if( con.vislines > scr_height->integer )
con.vislines = scr_height->integer;
if( lines <= 0 ) return;
// draw the background
y = frac * scr_height->integer;
GL_SetRenderMode( kRenderNormal );
pglColor4ub( 255, 255, 255, 255 ); // to prevent grab color from screenfade
R_DrawStretchPic( 0, lines - scr_height->integer, scr_width->integer, scr_height->integer, 0, 0, 1, 1, con.background );
if( y >= 1 )
{
GL_SetRenderMode( kRenderNormal );
pglColor4ub( 255, 255, 255, 255 ); // to prevent grab color from screenfade
R_DrawStretchPic( 0, y - scr_height->integer, scr_width->integer, scr_height->integer, 0, 0, 1, 1, con.background );
}
else y = 0;
if( !con.curFont || host.developer <= 0 )
return; // nothing to draw
if( !con.curFont ) return; // nothing to draw
if( host.developer )
if( host.developer > 0 )
{
// draw current version
int stringLen, width = 0, charH;
string curbuild;
byte color[4];
memcpy( color, g_color_table[7], sizeof( color ));
@ -1796,58 +1900,48 @@ void Con_DrawSolidConsole( float frac )
start = scr_width->integer - stringLen;
stringLen = Con_StringLength( curbuild );
color[3] = min( con.displayFrac * 2.0f, 1.0f ) * 255; // fadeout version number
fraction = lines / (float)scr_height->integer;
color[3] = Q_min( fraction * 2.0f, 1.0f ) * 255; // fadeout version number
for( i = 0; i < stringLen; i++ )
width += Con_DrawCharacter( start + width, 0, curbuild[i], color );
}
// draw the text
rows = ( con.vislines - QCHAR_WIDTH ) / QCHAR_WIDTH; // rows of text to draw
y = con.vislines - ( con.curFont->charHeight * 3 );
// draw from the bottom up
if( con.display != con.current )
if( CON_LINES_COUNT > 0 )
{
start = con.curFont->charWidths[' ']; // offset one space at left screen side
int ymax = lines - (con.curFont->charHeight * 2.0f);
int lastline;
// draw red arrows to show the buffer is backscrolled
for( x = 0; x < con.linewidth; x += 4 )
Con_DrawCharacter(( x + 1 ) * start, y, '^', g_color_table[1] );
y -= con.curFont->charHeight;
rows--;
}
row = con.display;
if( con.x == 0 ) row--;
Con_LastVisibleLine( &lastline );
y = ymax - con.curFont->charHeight;
currentColor = 7;
pglColor4ubv( g_color_table[currentColor] );
for( i = 0; i < rows; i++, y -= con.curFont->charHeight, row-- )
{
if( row < 0 ) break;
if( con.current - row >= con.totallines )
if( con.backscroll )
{
// past scrollback wrap point
continue;
start = con.curFont->charWidths[' ']; // offset one space at left screen side
// draw red arrows to show the buffer is backscrolled
for( x = 0; x < con.linewidth; x += 4 )
Con_DrawCharacter(( x + 1 ) * start, y, '^', g_color_table[1] );
y -= con.curFont->charHeight;
}
x = lastline;
text = con.text + ( row % con.totallines ) * con.linewidth;
start = con.curFont->charWidths[' ']; // offset one space at left screen side
for( x = 0; x < con.linewidth; x++ )
while( 1 )
{
if((( text[x] >> 8 ) & 7 ) != currentColor )
currentColor = ( text[x] >> 8 ) & 7;
start += Con_DrawCharacter( start, y, text[x] & 0xFF, g_color_table[currentColor] );
y -= Con_DrawConsoleLine( y, x );
// top of console buffer or console window
if( x == 0 || y < con.curFont->charHeight )
break;
x--;
}
}
// draw the input prompt, user text, and cursor if desired
Con_DrawInput();
Con_DrawInput( lines );
y = con.vislines - ( con.curFont->charHeight * 1.2f );
y = lines - ( con.curFont->charHeight * 1.2f );
SCR_DrawFPS( max( y, 4 )); // to avoid to hide fps counter
pglColor4ub( 255, 255, 255, 255 );
@ -1872,18 +1966,18 @@ void Con_DrawConsole( void )
if( !cl_allow_levelshots->integer )
{
if(( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" )) && cls.key_dest != key_console )
con.displayFrac = con.finalFrac = 0.0f;
else con.displayFrac = con.finalFrac = 1.0f;
con.vislines = con.showlines = 0;
else con.vislines = con.showlines = scr_height->integer;
}
else
{
if( host.developer >= 4 )
{
con.displayFrac = 0.5f; // keep console open
con.vislines = (scr_height->integer >> 1); // keep console open
}
else
{
con.finalFrac = 0.0f;
con.showlines = 0;
Con_RunConsole();
if( host.developer >= 2 )
@ -1900,26 +1994,30 @@ void Con_DrawConsole( void )
case ca_disconnected:
if( cls.key_dest != key_menu && host.developer )
{
Con_DrawSolidConsole( 1.0f );
Con_DrawSolidConsole( scr_height->integer );
Key_SetKeyDest( key_console );
}
break;
case ca_connected:
case ca_connecting:
// force to show console always for -dev 3 and higher
if( con.displayFrac ) Con_DrawSolidConsole( con.displayFrac );
if( con.vislines )
{
GL_CleanupAllTextureUnits(); // ugly hack to remove blinking voiceicon.spr during loading
Con_DrawSolidConsole( con.vislines );
}
break;
case ca_active:
case ca_cinematic:
if( Cvar_VariableInteger( "cl_background" ) || Cvar_VariableInteger( "sv_background" ))
{
if( cls.key_dest == key_console )
Con_DrawSolidConsole( 1.0f );
Con_DrawSolidConsole( scr_height->integer );
}
else
{
if( con.displayFrac )
Con_DrawSolidConsole( con.displayFrac );
if( con.vislines )
Con_DrawSolidConsole( con.vislines );
else if( cls.state == ca_active && ( cls.key_dest == key_game || cls.key_dest == key_message ))
Con_DrawNotify(); // draw notify lines
}
@ -1980,14 +2078,16 @@ Scroll it up or down
*/
void Con_RunConsole( void )
{
int lines_per_frame;
// decide on the destination height of the console
if( host.developer && cls.key_dest == key_console )
{
if( cls.state == ca_disconnected )
con.finalFrac = 1.0f;// full screen
else con.finalFrac = 0.5f; // half screen
con.showlines = scr_height->integer; // full screen
else con.showlines = (scr_height->integer >> 1); // half screen
}
else con.finalFrac = 0; // none visible
else con.showlines = 0; // none visible
// when level is loading frametime may be is wrong
if( cls.state == ca_connecting || cls.state == ca_connected )
@ -1997,17 +2097,19 @@ void Con_RunConsole( void )
else host.realframetime = HOST_FRAMETIME;
}
if( con.finalFrac < con.displayFrac )
lines_per_frame = bound( 1, fabs( scr_conspeed->value ) * host.realframetime, scr_height->integer );
if( con.showlines < con.vislines )
{
con.displayFrac -= fabs( scr_conspeed->value ) * 0.002f * host.realframetime;
if( con.finalFrac > con.displayFrac )
con.displayFrac = con.finalFrac;
con.vislines -= lines_per_frame;
if( con.showlines > con.vislines )
con.vislines = con.showlines;
}
else if( con.finalFrac > con.displayFrac )
else if( con.showlines > con.vislines )
{
con.displayFrac += fabs( scr_conspeed->value ) * 0.002f * host.realframetime;
if( con.finalFrac < con.displayFrac )
con.displayFrac = con.finalFrac;
con.vislines += lines_per_frame;
if( con.showlines < con.vislines )
con.vislines = con.showlines;
}
}
@ -2038,6 +2140,14 @@ void Con_CharEvent( int key )
}
}
/*
=========
Con_VidInit
reload background
resize console
=========
*/
void Con_VidInit( void )
{
Con_CheckResize();
@ -2095,6 +2205,12 @@ void Con_VidInit( void )
Con_LoadConchars();
}
/*
=========
Con_InvalidateFonts
=========
*/
void Con_InvalidateFonts( void )
{
memset( con.chars, 0, sizeof( con.chars ));
@ -2127,12 +2243,19 @@ void Cmd_AutoComplete( char *complete_string )
else Q_strncpy( complete_string, input.buffer, sizeof( input.buffer ));
}
void Con_Close( void )
/*
=========
Con_FastClose
immediately close the console
=========
*/
void Con_FastClose( void )
{
Con_ClearField( &con.input );
Con_ClearNotify();
con.finalFrac = 0.0f; // none visible
con.displayFrac = 0.0f;
con.showlines = 0;
con.vislines = 0;
}
/*

View File

@ -71,6 +71,29 @@ int Q_strlen( const char *string )
return len;
}
int Q_colorstr( const char *string )
{
int len;
const char *p;
if( !string ) return 0;
len = 0;
p = string;
while( *p )
{
if( IsColorString( p ))
{
len += 2;
p += 2;
continue;
}
p++;
}
return len;
}
char Q_toupper( const char in )
{
char out;

View File

@ -138,6 +138,7 @@ void Q_strnupr( const char *in, char *out, size_t size_out );
#define Q_strlwr( int, out ) Q_strnlwr( in, out, 99999 )
void Q_strnlwr( const char *in, char *out, size_t size_out );
int Q_strlen( const char *string );
int Q_colorstr( const char *string );
char Q_toupper( const char in );
char Q_tolower( const char in );
#define Q_strcat( dst, src ) Q_strncat( dst, src, 99999 )

View File

@ -969,6 +969,7 @@ void Cvar_List_f( void )
{
convar_t *var;
char *match = NULL;
char *value;
int i = 0;
if( Cmd_Argc() > 1 )
@ -982,9 +983,13 @@ void Cvar_List_f( void )
if( match && !Q_stricmpext( match, var->name ))
continue;
if( Q_colorstr( var->string ))
value = va( "\"%s\"", var->string );
else value = va( "\"^2%s^7\"", var->string );
if( FBitSet( var->flags, CVAR_SERVERDLL ))
Msg( " %-*s \"^2%s^7\" ^3%s^7\n", 32, var->name, var->string, "server cvar" );
else Msg( " %-*s \"^2%s^7\" ^3%s^7\n", 32, var->name, var->string, var->description );
Msg( " %-*s %s ^3%s^7\n", 32, var->name, value, "server cvar" );
else Msg( " %-*s %s ^3%s^7\n", 32, var->name, value, var->description );
i++;
}

File diff suppressed because it is too large Load Diff

View File

@ -58,9 +58,6 @@ file_n: byte[dwadinfo_t[num]->disksize]
infotable dlumpinfo_t[dwadinfo_t->numlumps]
========================================================================
*/
#define IDWAD2HEADER (('2'<<24)+('D'<<16)+('A'<<8)+'W') // little-endian "WAD2" quake1 gfx.wad
#define IDWAD3HEADER (('3'<<24)+('D'<<16)+('A'<<8)+'W') // little-endian "WAD3" half-life wads
#define WAD3_NAMELEN 16
#define HINT_NAMELEN 5 // e.g. _mask, _norm
#define MAX_FILES_IN_WAD 65535 // real limit as above <2Gb size not a lumpcount
@ -73,9 +70,9 @@ infotable dlumpinfo_t[dwadinfo_t->numlumps]
typedef struct
{
int ident; // should be IWAD, WAD2 or WAD3
int ident; // should be WAD3
int numlumps; // num files
int infotableofs;
int infotableofs; // LUT offset
} dwadinfo_t;
typedef struct

View File

@ -22,8 +22,6 @@ GNU General Public License for more details.
//-----------------------------------------------------------------------------
static byte gammatable[256];
static byte texgammatable[256]; // palette is sent through this to convert to screen gamma
static float texturetolinear[256]; // texture (0..255) to linear (0..1)
static int lineartotexture[1024]; // linear (0..1) to texture (0..255)
void BuildGammaTable( float gamma, float texGamma )
{
@ -49,18 +47,6 @@ void BuildGammaTable( float gamma, float texGamma )
inf = (int)(f + 0.5f);
gammatable[i] = bound( 0, inf, 255 );
}
for( i = 0; i < 256; i++ )
{
// convert from nonlinear texture space (0..255) to linear space (0..1)
texturetolinear[i] = pow( i / 255.0, GAMMA );
}
for( i = 0; i < 1024; i++ )
{
// convert from linear space (0..1) to nonlinear texture space (0..255)
lineartotexture[i] = pow( i / 1023.0, INVGAMMA ) * 255;
}
}
byte TextureToTexGamma( byte b )
@ -79,10 +65,4 @@ byte TextureToGamma( byte b )
b = bound( 0, b, 255 );
return gammatable[b];
}
// convert texture to linear 0..1 value
float TextureToLinear( int c ) { return texturetolinear[bound( 0, c, 255 )]; }
// convert texture to linear 0..1 value
int LinearToTexture( float f ) { return lineartotexture[bound( 0, (int)(f * 1023), 1023 )]; }
}

View File

@ -234,10 +234,10 @@ void Host_Exec_f( void )
return;
}
// HACKHACK: don't execute listenserver.cfg in singleplayer
// don't execute listenserver.cfg in singleplayer
if( !Q_stricmp( Cvar_VariableString( "lservercfgfile" ), Cmd_Argv( 1 )))
{
if( Cvar_VariableValue( "maxplayers" ) == 1.0f )
if( Cvar_VariableInteger( "maxplayers" ) == 1 )
return;
}
@ -828,7 +828,9 @@ void Host_InitCommon( const char *progname, qboolean bChangeGame )
host.mempool = Mem_AllocPool( "Zone Engine" );
if( Sys_CheckParm( "-console" )) host.developer = 1;
if( Sys_CheckParm( "-console" ))
host.developer = 1;
if( Sys_CheckParm( "-dev" ))
{
if( Sys_GetParmFromCmdLine( "-dev", dev_level ))
@ -1044,8 +1046,8 @@ int EXPORT Host_Main( const char *progname, int bChangeGame, pfnChangeGame func
// we need to execute it again here
Cmd_ExecuteString( "exec config.cfg\n" );
oldtime = Sys_DoubleTime();
SCR_CheckStartupVids(); // must be last
oldtime = Sys_DoubleTime() - 0.1;
SCR_CheckStartupVids(); // must be last
// main window message loop
while( !host.crashed )

View File

@ -257,24 +257,12 @@ qboolean Image_LoadLMP( const char *name, const byte *buffer, size_t filesize )
if( Q_stristr( name, "palette.lmp" ))
return Image_LoadPAL( name, buffer, filesize );
// greatest hack from id software
if( image.hint != IL_HINT_HL && Q_stristr( name, "conchars" ))
{
image.width = image.height = 128;
image.flags |= IMAGE_HAS_ALPHA;
rendermode = LUMP_QFONT;
filesize += sizeof(lmp);
fin = (byte *)buffer;
}
else
{
fin = (byte *)buffer;
memcpy( &lmp, fin, sizeof( lmp ));
image.width = lmp.width;
image.height = lmp.height;
rendermode = LUMP_NORMAL;
fin += sizeof(lmp);
}
fin = (byte *)buffer;
memcpy( &lmp, fin, sizeof( lmp ));
image.width = lmp.width;
image.height = lmp.height;
rendermode = LUMP_NORMAL;
fin += sizeof( lmp );
pixels = image.width * image.height;

View File

@ -105,8 +105,8 @@ static int Host_MapKey( int key )
case 0x0D: return K_KP_ENTER;
case 0x2F: return K_KP_SLASH;
case 0xAF: return K_KP_PLUS;
default: return result;
}
return result;
}
}
@ -290,7 +290,7 @@ void IN_DeactivateMouse( void )
/*
================
IN_Mouse
IN_MouseMove
================
*/
void IN_MouseMove( void )
@ -331,12 +331,12 @@ void IN_MouseEvent( int mstate )
// perform button actions
for( i = 0; i < in_mouse_buttons; i++ )
{
if(( mstate & ( 1<<i )) && !( in_mouse_oldbuttonstate & ( 1<<i )))
if( FBitSet( mstate, BIT( i )) && !FBitSet( in_mouse_oldbuttonstate, BIT( i )))
{
Key_Event( K_MOUSE1 + i, true );
}
if(!( mstate & ( 1<<i )) && ( in_mouse_oldbuttonstate & ( 1<<i )))
if( !FBitSet( mstate, BIT( i )) && FBitSet( in_mouse_oldbuttonstate, BIT( i )))
{
Key_Event( K_MOUSE1 + i, false );
}
@ -383,13 +383,13 @@ void Host_InputFrame( void )
Cbuf_Execute ();
if( host.state == HOST_RESTART )
host.state = HOST_FRAME; // restart is finished
if( host.type == HOST_DEDICATED )
{
// let the dedicated server some sleep
Sys_Sleep( 1 );
if( !FBitSet( host.features, ENGINE_FIXED_FRAMERATE ))
{
// let the dedicated server some sleep
Sys_Sleep( 1 );
}
}
else
{
@ -455,7 +455,8 @@ LONG IN_WndProc( HWND hWnd, UINT uMsg, UINT wParam, LONG lParam )
IN_ActivateCursor();
break;
case WM_MOUSEWHEEL:
if( !in_mouseactive ) break;
if( !in_mouseactive )
break;
if(( short )HIWORD( wParam ) > 0 )
{
Key_Event( K_MWHEELUP, true );
@ -478,17 +479,12 @@ LONG IN_WndProc( HWND hWnd, UINT uMsg, UINT wParam, LONG lParam )
case WM_ACTIVATE:
if( host.state == HOST_SHUTDOWN )
break; // no need to activate
if( host.state != HOST_RESTART )
{
if( HIWORD( wParam ))
host.state = HOST_SLEEP;
else if( LOWORD( wParam ) == WA_INACTIVE )
host.state = HOST_NOFOCUS;
else host.state = HOST_FRAME;
fActivate = (host.state == HOST_FRAME) ? true : false;
}
else fActivate = true; // video sucessfully restarted
if( HIWORD( wParam ))
host.state = HOST_SLEEP;
else if( LOWORD( wParam ) == WA_INACTIVE )
host.state = HOST_NOFOCUS;
else host.state = HOST_FRAME;
fActivate = (host.state == HOST_FRAME) ? true : false;
wnd_caption = GetSystemMetrics( SM_CYCAPTION ) + WND_BORDER;
S_Activate( fActivate, host.hWnd );
@ -500,7 +496,7 @@ LONG IN_WndProc( HWND hWnd, UINT uMsg, UINT wParam, LONG lParam )
SetForegroundWindow( hWnd );
ShowWindow( hWnd, SW_RESTORE );
}
else if( Cvar_VariableInteger( "fullscreen" ) && host.state != HOST_RESTART )
else if( Cvar_VariableInteger( "fullscreen" ))
{
ShowWindow( hWnd, SW_MINIMIZE );
}

View File

@ -726,9 +726,7 @@ void Key_ClearStates( void )
}
if( clgame.hInstance )
{
clgame.dllFuncs.IN_ClearStates();
}
}
/*

View File

@ -53,10 +53,10 @@ typedef BOOL (WINAPI *DllEntryProc)( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID
static void CopySections( const byte *data, PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module )
{
int i, size;
byte *dest;
byte *codeBase = module->codeBase;
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION( module->headers );
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION( module->headers );
byte *codeBase = module->codeBase;
int i, size;
byte *dest;
for( i = 0; i < module->headers->FileHeader.NumberOfSections; i++, section++ )
{
@ -85,9 +85,9 @@ static void CopySections( const byte *data, PIMAGE_NT_HEADERS old_headers, PMEMO
static void FreeSections( PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module )
{
int i, size;
byte *codeBase = module->codeBase;
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
PIMAGE_SECTION_HEADER section = IMAGE_FIRST_SECTION(module->headers);
byte *codeBase = module->codeBase;
int i, size;
for( i = 0; i < module->headers->FileHeader.NumberOfSections; i++, section++ )
{
@ -96,13 +96,13 @@ static void FreeSections( PIMAGE_NT_HEADERS old_headers, PMEMORYMODULE module )
size = old_headers->OptionalHeader.SectionAlignment;
if( size > 0 )
{
VirtualFree( codeBase + section->VirtualAddress, size, MEM_DECOMMIT );
VirtualFree((byte *)CALCULATE_ADDRESS( codeBase, section->VirtualAddress ), size, MEM_DECOMMIT );
section->Misc.PhysicalAddress = 0;
}
continue;
}
VirtualFree( codeBase + section->VirtualAddress, section->SizeOfRawData, MEM_DECOMMIT );
VirtualFree((byte *)CALCULATE_ADDRESS( codeBase, section->VirtualAddress ), section->SizeOfRawData, MEM_DECOMMIT );
section->Misc.PhysicalAddress = 0;
}
}
@ -154,9 +154,9 @@ static void FinalizeSections( MEMORYMODULE *module )
static void PerformBaseRelocation( MEMORYMODULE *module, DWORD delta )
{
DWORD i;
byte *codeBase = module->codeBase;
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY( module, IMAGE_DIRECTORY_ENTRY_BASERELOC );
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY( module, IMAGE_DIRECTORY_ENTRY_BASERELOC );
byte *codeBase = module->codeBase;
DWORD i;
if( directory->Size > 0 )
{
@ -200,12 +200,12 @@ static void PerformBaseRelocation( MEMORYMODULE *module, DWORD delta )
static FARPROC MemoryGetProcAddress( void *module, const char *name )
{
int idx = -1;
DWORD i, *nameRef;
WORD *ordinal;
PIMAGE_EXPORT_DIRECTORY exports;
byte *codeBase = ((PMEMORYMODULE)module)->codeBase;
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((MEMORYMODULE *)module, IMAGE_DIRECTORY_ENTRY_EXPORT );
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY((MEMORYMODULE *)module, IMAGE_DIRECTORY_ENTRY_EXPORT );
byte *codeBase = ((PMEMORYMODULE)module)->codeBase;
PIMAGE_EXPORT_DIRECTORY exports;
int idx = -1;
DWORD i, *nameRef;
WORD *ordinal;
if( directory->Size == 0 )
{
@ -253,9 +253,9 @@ static FARPROC MemoryGetProcAddress( void *module, const char *name )
static int BuildImportTable( MEMORYMODULE *module )
{
int result=1;
byte *codeBase = module->codeBase;
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY( module, IMAGE_DIRECTORY_ENTRY_IMPORT );
PIMAGE_DATA_DIRECTORY directory = GET_HEADER_DICTIONARY( module, IMAGE_DIRECTORY_ENTRY_IMPORT );
byte *codeBase = module->codeBase;
int result = 1;
if( directory->Size > 0 )
{

View File

@ -534,8 +534,8 @@ print into window console
void Sys_Print( const char *pMsg )
{
const char *msg;
char buffer[32768];
char logbuf[32768];
char buffer[MAX_PRINT_MSG];
char logbuf[MAX_PRINT_MSG];
char *b = buffer;
char *c = logbuf;
int i = 0;
@ -604,7 +604,7 @@ formatted message
void Msg( const char *pMsg, ... )
{
va_list argptr;
char text[8192];
char text[MAX_PRINT_MSG];
va_start( argptr, pMsg );
Q_vsnprintf( text, sizeof( text ), pMsg, argptr );
@ -623,7 +623,7 @@ formatted developer message
void MsgDev( int level, const char *pMsg, ... )
{
va_list argptr;
char text[8192];
char text[MAX_PRINT_MSG];
if( host.developer < level ) return;

View File

@ -253,9 +253,14 @@ void UI_DrawString( int x, int y, int w, int h, const char *string, const int co
{
if( IsColorString( l ))
{
if( !forceColor )
int colorNum = ColorIndex( *(l+1) );
if( colorNum == 7 && color != 0 )
{
modulate = color;
}
else if( !forceColor )
{
int colorNum = ColorIndex( *(l+1) );
modulate = PackAlpha( g_iColorTable[colorNum], UnpackAlpha( color ));
}
@ -1535,7 +1540,7 @@ void UI_Init( void )
Cmd_AddCommand( "menu_multiplayer", UI_MultiPlayer_Menu );
Cmd_AddCommand( "menu_options", UI_Options_Menu );
Cmd_AddCommand( "menu_langame", UI_LanGame_Menu );
Cmd_AddCommand( "menu_intenetgames", UI_InternetGames_Menu );
Cmd_AddCommand( "menu_internetgames", UI_InternetGames_Menu );
Cmd_AddCommand( "menu_playersetup", UI_PlayerSetup_Menu );
Cmd_AddCommand( "menu_controls", UI_Controls_Menu );
Cmd_AddCommand( "menu_advcontrols", UI_AdvControls_Menu );
@ -1579,7 +1584,7 @@ void UI_Shutdown( void )
Cmd_RemoveCommand( "menu_saveload" );
Cmd_RemoveCommand( "menu_multiplayer" );
Cmd_RemoveCommand( "menu_options" );
Cmd_RemoveCommand( "menu_intenetgames" );
Cmd_RemoveCommand( "menu_internetgames" );
Cmd_RemoveCommand( "menu_langame" );
Cmd_RemoveCommand( "menu_playersetup" );
Cmd_RemoveCommand( "menu_controls" );

View File

@ -74,7 +74,7 @@ GNU General Public License for more details.
#define UI_OUTLINE_WIDTH uiStatic.outlineWidth // outline thickness
#define UI_MAXGAMES 900 // slots for savegame/demos
#define UI_MAX_SERVERS 32
#define UI_MAX_SERVERS 64
#define UI_MAX_BGMAPS 32
#define MAX_HINT_TEXT 512

View File

@ -375,7 +375,7 @@ static void UI_CreateGame_Init( void )
uiCreateGame.hostName.generic.width = 205;
uiCreateGame.hostName.generic.height = 32;
uiCreateGame.hostName.generic.callback = UI_CreateGame_Callback;
uiCreateGame.hostName.maxLength = 16;
uiCreateGame.hostName.maxLength = 28;
strcpy( uiCreateGame.hostName.buffer, CVAR_GET_STRING( "hostname" ));
uiCreateGame.maxClients.generic.id = ID_MAXCLIENTS;

View File

@ -41,9 +41,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ID_YES 130
#define ID_NO 131
#define GAME_LENGTH 18
#define GAME_LENGTH 28
#define MAPNAME_LENGTH 20+GAME_LENGTH
#define TYPE_LENGTH 16+MAPNAME_LENGTH
#define TYPE_LENGTH 10+MAPNAME_LENGTH
#define MAXCL_LENGTH 15+TYPE_LENGTH
typedef struct
@ -118,24 +118,30 @@ UI_InternetGames_GetGamesList
static void UI_InternetGames_GetGamesList( void )
{
int i;
const char *info;
const char *info, *host, *map;
int colorOffset[2];
for( i = 0; i < uiStatic.numServers; i++ )
{
if( i >= UI_MAX_SERVERS ) break;
info = uiStatic.serverNames[i];
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "host" ), GAME_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, GAME_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "map" ), MAPNAME_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, MAPNAME_LENGTH );
host = Info_ValueForKey( info, "host" );
colorOffset[0] = ColorPrexfixCount( host );
StringConcat( uiInternetGames.gameDescription[i], host, GAME_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, GAME_LENGTH + colorOffset[0] );
map = Info_ValueForKey( info, "map" );
colorOffset[1] = ColorPrexfixCount( map );
StringConcat( uiInternetGames.gameDescription[i], map, MAPNAME_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, MAPNAME_LENGTH + colorOffset[0] + colorOffset[1] );
if( !strcmp( Info_ValueForKey( info, "dm" ), "1" ))
StringConcat( uiInternetGames.gameDescription[i], "deathmatch", TYPE_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], "dm", TYPE_LENGTH );
else if( !strcmp( Info_ValueForKey( info, "coop" ), "1" ))
StringConcat( uiInternetGames.gameDescription[i], "coop", TYPE_LENGTH );
else if( !strcmp( Info_ValueForKey( info, "team" ), "1" ))
StringConcat( uiInternetGames.gameDescription[i], "teamplay", TYPE_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, TYPE_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], "team", TYPE_LENGTH );
else StringConcat( uiInternetGames.gameDescription[i], "???", TYPE_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], uiEmptyString, TYPE_LENGTH + colorOffset[0] + colorOffset[1] );
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "numcl" ), MAXCL_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], "\\", MAXCL_LENGTH );
StringConcat( uiInternetGames.gameDescription[i], Info_ValueForKey( info, "maxcl" ), MAXCL_LENGTH );
@ -274,7 +280,7 @@ static void UI_InternetGames_Init( void )
StringConcat( uiInternetGames.hintText, uiEmptyString, MAPNAME_LENGTH );
StringConcat( uiInternetGames.hintText, "Type", TYPE_LENGTH );
StringConcat( uiInternetGames.hintText, uiEmptyString, TYPE_LENGTH );
StringConcat( uiInternetGames.hintText, "Num/Max Clients", MAXCL_LENGTH );
StringConcat( uiInternetGames.hintText, "Clients", MAXCL_LENGTH );
StringConcat( uiInternetGames.hintText, uiEmptyString, MAXCL_LENGTH );
uiInternetGames.background.generic.id = ID_BACKGROUND;

View File

@ -41,9 +41,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define ID_YES 130
#define ID_NO 131
#define GAME_LENGTH 18
#define GAME_LENGTH 28
#define MAPNAME_LENGTH 20+GAME_LENGTH
#define TYPE_LENGTH 16+MAPNAME_LENGTH
#define TYPE_LENGTH 10+MAPNAME_LENGTH
#define MAXCL_LENGTH 15+TYPE_LENGTH
typedef struct
@ -118,24 +118,30 @@ UI_LanGame_GetGamesList
static void UI_LanGame_GetGamesList( void )
{
int i;
const char *info;
const char *info, *host, *map;
int colorOffset[2];
for( i = 0; i < uiStatic.numServers; i++ )
{
if( i >= UI_MAX_SERVERS ) break;
info = uiStatic.serverNames[i];
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "host" ), GAME_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, GAME_LENGTH );
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "map" ), MAPNAME_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, MAPNAME_LENGTH );
host = Info_ValueForKey( info, "host" );
colorOffset[0] = ColorPrexfixCount( host );
StringConcat( uiLanGame.gameDescription[i], host, GAME_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, GAME_LENGTH + colorOffset[0] );
map = Info_ValueForKey( info, "map" );
colorOffset[1] = ColorPrexfixCount( map );
StringConcat( uiLanGame.gameDescription[i], map, MAPNAME_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, MAPNAME_LENGTH + colorOffset[0] + colorOffset[1] );
if( !strcmp( Info_ValueForKey( info, "dm" ), "1" ))
StringConcat( uiLanGame.gameDescription[i], "deathmatch", TYPE_LENGTH );
StringConcat( uiLanGame.gameDescription[i], "dm", TYPE_LENGTH );
else if( !strcmp( Info_ValueForKey( info, "coop" ), "1" ))
StringConcat( uiLanGame.gameDescription[i], "coop", TYPE_LENGTH );
else if( !strcmp( Info_ValueForKey( info, "team" ), "1" ))
StringConcat( uiLanGame.gameDescription[i], "teamplay", TYPE_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, TYPE_LENGTH );
StringConcat( uiLanGame.gameDescription[i], "team", TYPE_LENGTH );
else StringConcat( uiLanGame.gameDescription[i], "???", TYPE_LENGTH );
StringConcat( uiLanGame.gameDescription[i], uiEmptyString, TYPE_LENGTH + colorOffset[0] + colorOffset[1] );
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "numcl" ), MAXCL_LENGTH );
StringConcat( uiLanGame.gameDescription[i], "\\", MAXCL_LENGTH );
StringConcat( uiLanGame.gameDescription[i], Info_ValueForKey( info, "maxcl" ), MAXCL_LENGTH );
@ -274,7 +280,7 @@ static void UI_LanGame_Init( void )
StringConcat( uiLanGame.hintText, uiEmptyString, MAPNAME_LENGTH );
StringConcat( uiLanGame.hintText, "Type", TYPE_LENGTH );
StringConcat( uiLanGame.hintText, uiEmptyString, TYPE_LENGTH );
StringConcat( uiLanGame.hintText, "Num/Max Clients", MAXCL_LENGTH );
StringConcat( uiLanGame.hintText, "Clients", MAXCL_LENGTH );
StringConcat( uiLanGame.hintText, uiEmptyString, MAXCL_LENGTH );
uiLanGame.background.generic.id = ID_BACKGROUND;

View File

@ -67,6 +67,30 @@ int ColorStrlen( const char *str )
return len;
}
int ColorPrexfixCount( const char *str )
{
const char *p;
if( !str )
return 0;
int len = 0;
p = str;
while( *p )
{
if( IsColorString( p ))
{
len += 2;
p += 2;
continue;
}
p++;
}
return len;
}
void StringConcat( char *dst, const char *src, size_t size )
{
register char *d = dst;

View File

@ -109,6 +109,7 @@ inline float RemapVal( float val, float A, float B, float C, float D)
}
extern int ColorStrlen( const char *str ); // returns string length without color symbols
extern int ColorPrexfixCount( const char *str );
extern const int g_iColorTable[8];
extern void COM_FileBase( const char *in, char *out ); // ripped out from hlsdk 2.3
extern int UI_FadeAlpha( int starttime, int endtime );