01 Jul 2008
This commit is contained in:
parent
e64f9f0c90
commit
95aa92c67d
997
engine/cg_user.c
997
engine/cg_user.c
|
@ -1,997 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// cg_user.c - stuff that will moved into client.dat
|
||||
//=======================================================================
|
||||
|
||||
#include "common.h"
|
||||
#include "client.h"
|
||||
|
||||
extern cvar_t *scr_centertime;
|
||||
extern cvar_t *scr_showpause;
|
||||
|
||||
#define DISPLAY_ITEMS 17
|
||||
#define STAT_MINUS 10 // num frame for '-' stats digit
|
||||
|
||||
char *cg_nums[11] =
|
||||
{
|
||||
"hud/num_0", "hud/num_1", "hud/num_2",
|
||||
"hud/num_3", "hud/num_4", "hud/num_5",
|
||||
"hud/num_6", "hud/num_7", "hud/num_8",
|
||||
"hud/num_9", "hud/num_-",
|
||||
};
|
||||
|
||||
/*
|
||||
================
|
||||
CG_Init
|
||||
|
||||
initialize cg
|
||||
================
|
||||
*/
|
||||
void CG_Init( void )
|
||||
{
|
||||
cls.cg_numstats = 0; // reset hudprogram statsnames
|
||||
cls.cg_numcvars = 0; // reset hudprogram statsnames
|
||||
cls.cg_init = Com_LoadScript( "scripts/hud.txt", NULL, 0 );
|
||||
CG_ExecuteProgram( "Hud_Setup" ); // get stats and cvars names
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
V_RenderSplash
|
||||
|
||||
menu background
|
||||
================
|
||||
*/
|
||||
void V_RenderSplash( void )
|
||||
{
|
||||
// execute hudprogram
|
||||
CG_ExecuteProgram( "Hud_MenuBackground" );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
V_RenderLogo
|
||||
|
||||
loading splash
|
||||
================
|
||||
*/
|
||||
void V_RenderLogo( void )
|
||||
{
|
||||
// execute hudprogram
|
||||
CG_ExecuteProgram( "Hud_DrawPlaque" );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
V_RenderHUD
|
||||
|
||||
user hud rendering
|
||||
================
|
||||
*/
|
||||
void V_RenderHUD( void )
|
||||
{
|
||||
CG_MakeLevelShot();
|
||||
CG_DrawCenterString();
|
||||
CG_ExecuteProgram(cl.configstrings[CS_STATUSBAR]);
|
||||
CG_DrawInventory();
|
||||
CG_DrawLayout();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
CG_MakeLevelShot
|
||||
|
||||
used as splash logo
|
||||
==============
|
||||
*/
|
||||
void CG_MakeLevelShot( void )
|
||||
{
|
||||
if(cl.make_levelshot)
|
||||
{
|
||||
Con_ClearNotify();
|
||||
cl.make_levelshot = false;
|
||||
|
||||
// make levelshot at nextframe()
|
||||
Cbuf_ExecuteText(EXEC_APPEND, "levelshot\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
CG Draw Tools
|
||||
==============================================================================
|
||||
*/
|
||||
/*
|
||||
================
|
||||
SCR_GetBigStringWidth
|
||||
|
||||
skips color escape codes
|
||||
================
|
||||
*/
|
||||
int CG_GetBigStringWidth( const char *str )
|
||||
{
|
||||
return com.cstrlen( str ) * BIGCHAR_WIDTH;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_FadeColor
|
||||
================
|
||||
*/
|
||||
float *CG_FadeColor( float starttime, float endtime )
|
||||
{
|
||||
static vec4_t color;
|
||||
float time, fade_time;
|
||||
|
||||
if( starttime == 0 ) return NULL;
|
||||
time = cls.realtime - starttime;
|
||||
if( time >= endtime ) return NULL;
|
||||
|
||||
// fade time is 1/4 of endtime
|
||||
fade_time = endtime / 4;
|
||||
fade_time = bound( 0.3f, fade_time, 10.0f );
|
||||
|
||||
// fade out
|
||||
if((endtime - time) < fade_time)
|
||||
color[3] = (endtime - time) * 1.0f / fade_time;
|
||||
else color[3] = 1.0;
|
||||
color[0] = color[1] = color[2] = 1.0f;
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void CG_SetColor( float r, float g, float b, float a )
|
||||
{
|
||||
Vector4Set( cls.cg_color, r, g, b, a );
|
||||
re->SetColor( cls.cg_color );
|
||||
}
|
||||
|
||||
void CG_ResetColor( void )
|
||||
{
|
||||
Vector4Set( cls.cg_color, 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
re->SetColor( cls.cg_color );
|
||||
}
|
||||
|
||||
void CG_SetScale( float x, float y )
|
||||
{
|
||||
cls.cg_scale[0] = x;
|
||||
cls.cg_scale[1] = y;
|
||||
}
|
||||
|
||||
void CG_ResetScale( void )
|
||||
{
|
||||
cls.cg_scale[0] = cls.cg_scale[1] = 1.0f;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_DrawLayout
|
||||
================
|
||||
*/
|
||||
void CG_DrawLayout( void )
|
||||
{
|
||||
if(cl.frame.playerstate.stats[STAT_LAYOUTS] & 1)
|
||||
CG_ExecuteProgram( cl.layout );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_DrawInventory
|
||||
================
|
||||
*/
|
||||
void CG_DrawInventory( void )
|
||||
{
|
||||
float *select_color = NULL;
|
||||
int num = 0, selected_num = 0;
|
||||
int item, index[MAX_ITEMS];
|
||||
bool force_color = false;
|
||||
char string[1024];
|
||||
int i, j, x, y;
|
||||
char binding[1024];
|
||||
char *bind;
|
||||
int selected;
|
||||
int top;
|
||||
|
||||
if(!(cl.frame.playerstate.stats[STAT_LAYOUTS] & 2))
|
||||
return;
|
||||
|
||||
if(strcmp(cl.layout, "" ))
|
||||
{
|
||||
CG_ExecuteProgram( cl.layout );
|
||||
return;
|
||||
}
|
||||
|
||||
selected = cl.frame.playerstate.stats[STAT_SELECTED_ITEM];
|
||||
|
||||
num = 0;
|
||||
selected_num = 0;
|
||||
for ( i = 0; i < MAX_ITEMS; i++)
|
||||
{
|
||||
if (i == selected)
|
||||
selected_num = num;
|
||||
if (cl.inventory[i])
|
||||
{
|
||||
index[num] = i;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
// determine scroll point
|
||||
top = selected_num - DISPLAY_ITEMS/2;
|
||||
if (num - top < DISPLAY_ITEMS) top = num - DISPLAY_ITEMS;
|
||||
if (top < 0) top = 0;
|
||||
|
||||
x = (SCREEN_WIDTH - 256)>>1;
|
||||
y = (SCREEN_HEIGHT - 240)>>1;
|
||||
CG_DrawCenterPic( 256, 192, "hud/inventory" );
|
||||
|
||||
y += 42;
|
||||
x += 24;
|
||||
SCR_DrawSmallStringExt(x, y, "hotkey ### item", NULL, false );
|
||||
SCR_DrawSmallStringExt(x, y + 8, "------ --- ----", NULL, false );
|
||||
y += 16;
|
||||
|
||||
for (i = top; i < num && i < top + DISPLAY_ITEMS; i++)
|
||||
{
|
||||
item = index[i];
|
||||
// search for a binding
|
||||
com.sprintf(binding, "use %s", cl.configstrings[CS_ITEMS + item]);
|
||||
bind = "";
|
||||
for (j = 0; j < 256; j++)
|
||||
{
|
||||
if(Key_IsBind(j) && !strcasecmp(Key_IsBind(j), binding))
|
||||
{
|
||||
bind = Key_KeynumToString(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
com.sprintf(string, "%6s %3i %s", bind, cl.inventory[item], cl.configstrings[CS_ITEMS+item] );
|
||||
if (item != selected)
|
||||
{
|
||||
select_color = GetRGBA( 1.0f, 0.5f, 0.0f, 1.0f );
|
||||
force_color = true;
|
||||
}
|
||||
else // draw a blinky cursor by the selected item
|
||||
{
|
||||
select_color = NULL;
|
||||
force_color = false;
|
||||
if((int)(cls.realtime * 5.0f) & 1) SCR_DrawSmallChar( x - 8, y, 15);
|
||||
}
|
||||
SCR_DrawSmallStringExt(x, y, string, select_color, force_color );
|
||||
y += 8;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CG_DrawField( int value, int x, int y )
|
||||
{
|
||||
char num[16], *ptr;
|
||||
int l, frame;
|
||||
vec2_t scale;
|
||||
|
||||
com.sprintf(num, "%i", value );
|
||||
l = strlen( num );
|
||||
ptr = num;
|
||||
|
||||
if( cls.cg_scale[0] == 1.0f )
|
||||
scale[0] = GIANTCHAR_WIDTH;
|
||||
else scale[0] = cls.cg_scale[0];
|
||||
if( cls.cg_scale[1] == 1.0f )
|
||||
scale[1] = GIANTCHAR_HEIGHT;
|
||||
else scale[1] = cls.cg_scale[1];
|
||||
|
||||
while (*ptr && l)
|
||||
{
|
||||
if (*ptr == '-') frame = STAT_MINUS;
|
||||
else frame = *ptr -'0';
|
||||
SCR_DrawPic( x, y, scale[0], scale[1], cg_nums[frame]);
|
||||
x += scale[0];
|
||||
ptr++;
|
||||
l--;
|
||||
}
|
||||
|
||||
re->SetColor( NULL );
|
||||
CG_ResetScale();
|
||||
}
|
||||
|
||||
void CG_DrawBarImage( float percent, char *picname, int x, int y, int w, int h )
|
||||
{
|
||||
float progress = bound(0.0f, scr_loading->value * 0.01f, 100.0f );
|
||||
|
||||
w = bound(64.0f, w, 512.0f);
|
||||
h = bound(16.0f, h, 64.0f);
|
||||
|
||||
re->SetColor(GetRGBA(1.0f, 1.0f, 1.0f, 1.0f));
|
||||
SCR_DrawPic( x, y, w, h, picname );
|
||||
re->SetColor(GetRGBA(1.0f, 1.0f, 1.0f, 0.3f));
|
||||
SCR_DrawPic( x, y, w * progress, h, "common/fill_rect");
|
||||
CG_ResetColor();
|
||||
}
|
||||
|
||||
void CG_DrawCenterBarImage( float percent, char *picname, int w, int h )
|
||||
{
|
||||
CG_DrawBarImage(percent, picname, (SCREEN_WIDTH - w)>>1, (SCREEN_HEIGHT - h)>>1, w, h );
|
||||
}
|
||||
|
||||
void CG_DrawBarGeneric( float percent, int x, int y, int w, int h )
|
||||
{
|
||||
float progress = bound(0.0f, percent * 0.01f, 100.0f );
|
||||
|
||||
w = bound(64.0f, w, 512.0f);
|
||||
h = bound(16.0f, h, 64.0f);
|
||||
|
||||
SCR_FillRect(x, y, w, h, g_color_table[0] );
|
||||
SCR_DrawPic(x + 1, y + 1, w - 2, h - 2, "common/bar_back");
|
||||
SCR_DrawPic(x + 1, y + 1, (w - 2) * progress, h - 2, "common/bar_load");
|
||||
}
|
||||
|
||||
void CG_DrawCenterBarGeneric( float percent, int w, int h )
|
||||
{
|
||||
CG_DrawBarGeneric( percent, (SCREEN_WIDTH - w)>>1, (SCREEN_HEIGHT - h)>>1, w, h );
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
CG_DrawCenterString
|
||||
===================
|
||||
*/
|
||||
void CG_DrawCenterString( void )
|
||||
{
|
||||
char *start;
|
||||
int l, x, y, w;
|
||||
float *color;
|
||||
|
||||
if(!cl.centerPrintTime ) return;
|
||||
|
||||
color = CG_FadeColor( cl.centerPrintTime, scr_centertime->value );
|
||||
if( !color )
|
||||
{
|
||||
cl.centerPrintTime = 0.0f;
|
||||
return;
|
||||
}
|
||||
|
||||
re->SetColor( color );
|
||||
start = cl.centerPrint;
|
||||
y = cl.centerPrintY - cl.centerPrintLines * BIGCHAR_HEIGHT/2;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
char linebuffer[1024];
|
||||
|
||||
for ( l = 0; l < 50; l++ )
|
||||
{
|
||||
if ( !start[l] || start[l] == '\n' )
|
||||
break;
|
||||
linebuffer[l] = start[l];
|
||||
}
|
||||
linebuffer[l] = 0;
|
||||
|
||||
w = cl.centerPrintCharWidth * com.cstrlen( linebuffer );
|
||||
x = ( SCREEN_WIDTH - w )>>1;
|
||||
|
||||
SCR_DrawStringExt( x, y, cl.centerPrintCharWidth, BIGCHAR_HEIGHT, linebuffer, color, false );
|
||||
|
||||
y += cl.centerPrintCharWidth * 1.5;
|
||||
while ( *start && ( *start != '\n' )) start++;
|
||||
if( !*start ) break;
|
||||
start++;
|
||||
}
|
||||
re->SetColor( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
CG_CenterPrint
|
||||
|
||||
Called for important messages that should stay in the center of the screen
|
||||
for a few moments
|
||||
==============
|
||||
*/
|
||||
void CG_CenterPrint( const char *str, int y, int charWidth )
|
||||
{
|
||||
char *s;
|
||||
|
||||
strncpy( cl.centerPrint, str, sizeof(cl.centerPrint));
|
||||
|
||||
cl.centerPrintTime = cls.realtime;
|
||||
cl.centerPrintY = y;
|
||||
cl.centerPrintCharWidth = charWidth;
|
||||
|
||||
// count the number of lines for centering
|
||||
cl.centerPrintLines = 1;
|
||||
s = cl.centerPrint;
|
||||
while( *s )
|
||||
{
|
||||
if (*s == '\n') cl.centerPrintLines++;
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
CG_DrawCenterPic
|
||||
|
||||
Called for important messages that should stay in the center of the screen
|
||||
for a few moments
|
||||
==============
|
||||
*/
|
||||
void CG_DrawCenterPic( int w, int h, char *picname )
|
||||
{
|
||||
SCR_DrawPic((SCREEN_WIDTH - w)>>1, (SCREEN_HEIGHT - h)>>1, w, h, picname );
|
||||
}
|
||||
|
||||
void CG_DrawCenterStringBig( char *text, float alpha )
|
||||
{
|
||||
int xpos = (SCREEN_WIDTH - com.cstrlen(text) * BIGCHAR_WIDTH)>>1;
|
||||
int ypos = (SCREEN_HEIGHT - BIGCHAR_HEIGHT)>>1;
|
||||
|
||||
SCR_DrawBigString(xpos, ypos, text, alpha );
|
||||
re->SetColor( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
CG Virtual Machine
|
||||
==============================================================================
|
||||
*/
|
||||
/*
|
||||
================
|
||||
CG_GetAliasValue
|
||||
|
||||
get name from registered list
|
||||
================
|
||||
*/
|
||||
bool CG_GetAliasValue( const char *name, int *value, char *string )
|
||||
{
|
||||
int i, find = 0;
|
||||
|
||||
if(!name || !name[0]) return false;
|
||||
|
||||
// lookup stats
|
||||
for(i = 0; i < cls.cg_numstats; i++)
|
||||
{
|
||||
if(!strcmp(cls.cg_stats[i].name, name ))
|
||||
{
|
||||
find = cl.frame.playerstate.stats[cls.cg_stats[i].value];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i != cls.cg_numstats)
|
||||
{
|
||||
*value = find;
|
||||
return true;
|
||||
}
|
||||
|
||||
// lookup cvars
|
||||
for(i = 0; i < cls.cg_numcvars; i++)
|
||||
{
|
||||
if(!strcmp(cls.cg_cvars[i].name, name ))
|
||||
{
|
||||
cvar_t *alias = Cvar_FindVar( cls.cg_cvars[i].cvar );
|
||||
if(alias)
|
||||
{
|
||||
find = alias->integer;
|
||||
if(string) strncpy( string, alias->string, MAX_QPATH );
|
||||
break;
|
||||
}
|
||||
MsgDev(D_WARN, "CG_GetAliasValue: alias %s have invalid cvar name %s\n", name, cls.cg_cvars[i].cvar );
|
||||
}
|
||||
}
|
||||
if(i != cls.cg_numcvars)
|
||||
{
|
||||
*value = find;
|
||||
return true;
|
||||
}
|
||||
|
||||
// constant digit ?
|
||||
find = atoi(name);
|
||||
if(find)
|
||||
{
|
||||
*value = find;
|
||||
return true;
|
||||
}
|
||||
|
||||
*value = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
char *CG_StatsString( const char *name, int start, int end )
|
||||
{
|
||||
int i, value;
|
||||
|
||||
if(!name || !name[0]) return "common/black";
|
||||
|
||||
// clear tempstring
|
||||
memset( cls.cg_tempstring, 0, MAX_QPATH );
|
||||
|
||||
// search for alias
|
||||
if(!CG_GetAliasValue( name, &value, cls.cg_tempstring ))
|
||||
{
|
||||
// search for normal name
|
||||
for(i = 0; i < end; i++)
|
||||
{
|
||||
if(!strcmp(cl.configstrings[start + i], name ))
|
||||
{
|
||||
// index can be changed from server
|
||||
return cl.configstrings[start + i];
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(strlen(cls.cg_tempstring))
|
||||
{
|
||||
return cls.cg_tempstring;
|
||||
}
|
||||
else if(value < end)
|
||||
{
|
||||
// static image index
|
||||
return cl.configstrings[start + value];
|
||||
}
|
||||
|
||||
// direct path ?
|
||||
return (char *)name;
|
||||
}
|
||||
|
||||
char *CG_ImageIndex( const char *name )
|
||||
{
|
||||
return CG_StatsString(name, CS_IMAGES, MAX_IMAGES );
|
||||
}
|
||||
|
||||
char *CG_ModelIndex( const char *name )
|
||||
{
|
||||
return CG_StatsString(name, CS_MODELS, MAX_MODELS );
|
||||
}
|
||||
|
||||
bool CG_GetInteger( const char *name, int *value )
|
||||
{
|
||||
return CG_GetAliasValue( name, value, NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_ParseInventory
|
||||
================
|
||||
*/
|
||||
void CG_ParseInventory( sizebuf_t *msg )
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_ITEMS; i++)
|
||||
{
|
||||
cl.inventory[i] = MSG_ReadShort( msg );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_SetStatsAlias
|
||||
|
||||
register new alias for stats num (0-32)
|
||||
================
|
||||
*/
|
||||
void CG_SetStatsAlias( const char *name, int value )
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!name) return;
|
||||
if(strlen(name) > MAX_QPATH)
|
||||
{
|
||||
MsgDev(D_WARN, "SetStatsAlias: %s too long name, limit is %d\n", name, MAX_QPATH );
|
||||
}
|
||||
if(value < 0 || value >= MAX_STATS)
|
||||
{
|
||||
MsgDev(D_WARN, "SetStatsAlias: value %d out of range\n", value );
|
||||
value = bound(0, value, MAX_STATS - 1 );
|
||||
}
|
||||
if(cls.cg_numstats + 1 >= MAX_STATS)
|
||||
{
|
||||
MsgDev(D_WARN, "SetStatsAlias: aliases limit exceeded\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// check for duplicate
|
||||
for(i = 0; i < cls.cg_numstats; i++)
|
||||
{
|
||||
if(!strcmp(cls.cg_stats[i].name, name ))
|
||||
{
|
||||
if(cls.cg_stats[i].value != value)
|
||||
MsgDev(D_WARN, "SetStatsAlias: redefinition stat alias %s\n", name );
|
||||
else MsgDev(D_WARN, "SetStatsAlias: duplicated stat alias %s\n", name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// register new stat alias
|
||||
if(i == cls.cg_numstats)
|
||||
{
|
||||
strncpy(cls.cg_stats[cls.cg_numstats].name, name, MAX_QPATH );
|
||||
cls.cg_stats[cls.cg_numstats].value = value;
|
||||
cls.cg_numstats++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_SetCvarAlias
|
||||
|
||||
register new alias for console variable
|
||||
================
|
||||
*/
|
||||
void CG_SetCvarAlias( const char *name, const char *cvar )
|
||||
{
|
||||
int i;
|
||||
|
||||
if(!name || !cvar) return;
|
||||
if((strlen(name) > MAX_QPATH))
|
||||
{
|
||||
MsgDev(D_WARN, "SetCvarAlias: %s too long name, limit is %d\n", name, MAX_QPATH );
|
||||
}
|
||||
if(strlen(cvar) > MAX_QPATH)
|
||||
{
|
||||
MsgDev(D_WARN, "SetCvarAlias: %s too long cvar name, limit is %d\n", cvar, MAX_QPATH );
|
||||
}
|
||||
if(cls.cg_numstats + 1 >= 128 )
|
||||
{
|
||||
MsgDev(D_WARN, "SetCvarAlias: aliases limit exceeded\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
// check for duplicate
|
||||
for(i = 0; i < cls.cg_numcvars; i++)
|
||||
{
|
||||
if(!strcmp(cls.cg_cvars[i].name, name ))
|
||||
{
|
||||
if(strcmp(cls.cg_cvars[i].cvar, cvar ))
|
||||
MsgDev(D_WARN, "SetCvarAlias: redefinition cvar alias %s\n", name );
|
||||
else MsgDev(D_WARN, "SetCvarAlias: duplicated cvar alias %s\n", name );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// register new cvar alias
|
||||
if(i == cls.cg_numcvars)
|
||||
{
|
||||
strncpy(cls.cg_cvars[cls.cg_numcvars].name, name, MAX_QPATH );
|
||||
strncpy(cls.cg_cvars[cls.cg_numcvars].cvar, cvar, MAX_QPATH );
|
||||
cls.cg_numcvars++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_ParseArgs
|
||||
|
||||
soul of virtual machine
|
||||
================
|
||||
*/
|
||||
bool CG_ParseArgs( int num_argc )
|
||||
{
|
||||
cls.cg_argc = 0;
|
||||
memset(cls.cg_argv, 0, MAX_PARMS * MAX_QPATH );
|
||||
com.strncpy( cls.cg_builtin, com_token, MAX_QPATH );
|
||||
|
||||
// bound range silently
|
||||
num_argc = bound(0, num_argc, MAX_PARMS - 1);
|
||||
|
||||
while(Com_TryToken())
|
||||
{
|
||||
if(!num_argc) continue; // nothing to handle
|
||||
if(num_argc > 0 && cls.cg_argc > num_argc - 1 )
|
||||
{
|
||||
MsgDev(D_ERROR, "CG_ParseArgs: %s have too many parameters\n", cls.cg_builtin );
|
||||
return false; // stack overflow
|
||||
}
|
||||
else if(Com_MatchToken(";")) break; // end of parsing
|
||||
else if(Com_MatchToken(",")) cls.cg_argc++; // new argument
|
||||
else if(Com_MatchToken("(") || Com_MatchToken(")"))
|
||||
continue; // skip punctuation
|
||||
else com.strncpy(cls.cg_argv[cls.cg_argc], com_token, MAX_QPATH ); // fill stack
|
||||
}
|
||||
|
||||
if(num_argc > 0 && cls.cg_argc < num_argc - 1)
|
||||
MsgDev(D_WARN, "CG_ParseArgs: %s have too few parameters\n", cls.cg_builtin );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CG_SkipBlock( void )
|
||||
{
|
||||
cls.cg_depth2 = cls.cg_depth;
|
||||
|
||||
do {
|
||||
if(Com_MatchToken("{"))
|
||||
{
|
||||
// for bounds cheking
|
||||
cls.cg_depth++;
|
||||
}
|
||||
else if(Com_MatchToken("}"))
|
||||
{
|
||||
cls.cg_depth--;
|
||||
if(cls.cg_depth == cls.cg_depth2)
|
||||
break;
|
||||
}
|
||||
while(Com_TryToken());
|
||||
} while(Com_GetToken( true ));
|
||||
|
||||
if(cls.cg_depth != cls.cg_depth2)
|
||||
{
|
||||
MsgDev(D_ERROR, "CG_SkipBlock: missing } in function %s\n", cls.cg_function );
|
||||
}
|
||||
}
|
||||
|
||||
bool CG_ParseExpression( void )
|
||||
{
|
||||
cg_def_t expression;
|
||||
int j = 0, result = 0;
|
||||
|
||||
memset(&expression, 0, sizeof(cg_def_t));
|
||||
|
||||
cls.cg_depth2 = cls.cg_depth;
|
||||
|
||||
while(Com_TryToken())
|
||||
{
|
||||
if(Com_MatchToken("("))
|
||||
{
|
||||
}
|
||||
else if(Com_MatchToken(")")) break;
|
||||
else if(Com_MatchToken("&&")) expression.op = OP_LOGIC_AND;
|
||||
else if(Com_MatchToken("||")) expression.op = OP_LOGIC_OR;
|
||||
else if(Com_MatchToken("==")) expression.op = OP_EQUAL;
|
||||
else if(Com_MatchToken("!=")) expression.op = OP_NOTEQUAL;
|
||||
else if(Com_MatchToken(">")) expression.op = OP_MORE;
|
||||
else if(Com_MatchToken(">=")) expression.op = OP_MORE_OR_EQUAL;
|
||||
else if(Com_MatchToken("<")) expression.op = OP_SMALLER;
|
||||
else if(Com_MatchToken("<=")) expression.op = OP_SMALLER_OR_EQUAL;
|
||||
else if(Com_MatchToken("&")) expression.op = OP_WITH;
|
||||
else
|
||||
{
|
||||
int val;
|
||||
|
||||
if(CG_GetInteger( com_token[0] == '!' ? com_token + 1 : com_token, &val ))
|
||||
{
|
||||
if(com_token[0] == '!') expression.val[j] = !val;
|
||||
else expression.val[j] = val;
|
||||
|
||||
if(expression.op == OP_UNKNOWN)
|
||||
expression.op = OP_NOTEQUAL; // may be overrided
|
||||
j++; // force to done
|
||||
}
|
||||
else MsgDev(D_ERROR, "CG_ParseExpression: unknown variable %s\n", com_token );
|
||||
}
|
||||
}
|
||||
|
||||
// exec expression now
|
||||
switch(expression.op)
|
||||
{
|
||||
case OP_LOGIC_OR:
|
||||
if(expression.val[0] || expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_LOGIC_AND:
|
||||
if(expression.val[0] && expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_EQUAL:
|
||||
if(expression.val[0] == expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_NOTEQUAL:
|
||||
if(expression.val[0] != expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_MORE:
|
||||
if(expression.val[0] > expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_MORE_OR_EQUAL:
|
||||
if(expression.val[0] >= expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_SMALLER:
|
||||
if(expression.val[0] < expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_SMALLER_OR_EQUAL:
|
||||
if(expression.val[0] <= expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
case OP_WITH:
|
||||
if(expression.val[0] & expression.val[1]) result++;
|
||||
else result--;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CG_ExecBuiltins( void )
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
// builtins
|
||||
if(Com_MatchToken("{"))
|
||||
{
|
||||
cls.cg_depth++;
|
||||
return false;
|
||||
}
|
||||
else if(Com_MatchToken("}"))
|
||||
{
|
||||
cls.cg_depth--;
|
||||
return false;
|
||||
}
|
||||
else if(Com_MatchToken("if"))
|
||||
{
|
||||
// parse expression
|
||||
if(CG_ParseExpression() == -1)
|
||||
{
|
||||
CG_SkipBlock();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if(Com_MatchToken("SetStatAlias"))
|
||||
{
|
||||
// set alias name for stats numbers
|
||||
if(!CG_ParseArgs( 2 )) return false;
|
||||
CG_SetStatsAlias(cls.cg_argv[0], atoi(cls.cg_argv[1]));
|
||||
}
|
||||
else if(Com_MatchToken("SetCvarAlias"))
|
||||
{
|
||||
// set alias name for stats numbers
|
||||
if(!CG_ParseArgs( 2 )) return false;
|
||||
CG_SetCvarAlias(cls.cg_argv[0], cls.cg_argv[1]);
|
||||
}
|
||||
else if(Com_MatchToken("LoadPic"))
|
||||
{
|
||||
// cache hud pics
|
||||
if(!CG_ParseArgs( 1 )) return false;
|
||||
re->RegisterPic(cls.cg_argv[0]);
|
||||
}
|
||||
else if(Com_MatchToken("DrawField"))
|
||||
{
|
||||
// displayed health, armor, e.t.c.
|
||||
if(!CG_ParseArgs( 3 )) return false;
|
||||
if(!CG_GetInteger(cls.cg_argv[0], &value))
|
||||
MsgDev(D_ERROR, "%s: can't use undefined alias %s\n", cls.cg_builtin, cls.cg_argv[0]);
|
||||
else CG_DrawField( value, atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]));
|
||||
}
|
||||
else if(Com_MatchToken("SetColor"))
|
||||
{
|
||||
// set custom color
|
||||
if(!CG_ParseArgs( 4 )) return false;
|
||||
CG_SetColor(atof(cls.cg_argv[0]), atof(cls.cg_argv[1]), atof(cls.cg_argv[2]), atof(cls.cg_argv[3]));
|
||||
}
|
||||
else if(Com_MatchToken("ResetColor"))
|
||||
{
|
||||
// reset custom color
|
||||
if(!CG_ParseArgs( 0 )) return false;
|
||||
CG_ResetColor();
|
||||
}
|
||||
else if(Com_MatchToken("SetScale"))
|
||||
{
|
||||
// set custom scale
|
||||
if(!CG_ParseArgs( 2 )) return false;
|
||||
CG_SetScale(atof(cls.cg_argv[0]), atof(cls.cg_argv[1]));
|
||||
}
|
||||
else if(Com_MatchToken("ResetScale"))
|
||||
{
|
||||
// reset custom scale
|
||||
if(!CG_ParseArgs( 0 )) return false;
|
||||
CG_ResetScale();
|
||||
}
|
||||
else if(Com_MatchToken("DrawPic"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 5 )) return false;
|
||||
SCR_DrawPic( atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), atoi(cls.cg_argv[3]), atoi(cls.cg_argv[4]), CG_ImageIndex(cls.cg_argv[0]));
|
||||
}
|
||||
else if(Com_MatchToken("DrawCenterPic"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 3 )) return false;
|
||||
CG_DrawCenterPic( atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), CG_ImageIndex(cls.cg_argv[0]));
|
||||
}
|
||||
else if(Com_MatchToken("DrawBarImage"))
|
||||
{
|
||||
// fill image with "common/fill_rect"
|
||||
if(!CG_ParseArgs( 6 )) return false;
|
||||
if(!CG_GetInteger(cls.cg_argv[0], &value))
|
||||
MsgDev(D_ERROR, "%s: can't use undefined alias %s\n", cls.cg_builtin, cls.cg_argv[0]);
|
||||
else CG_DrawBarImage((float)value, CG_ImageIndex(cls.cg_argv[1]), atoi(cls.cg_argv[2]), atoi(cls.cg_argv[3]), atoi(cls.cg_argv[4]), atoi(cls.cg_argv[5]));
|
||||
}
|
||||
else if(Com_MatchToken("DrawCenterBarImage"))
|
||||
{
|
||||
// fill image with "common/fill_rect"
|
||||
if(!CG_ParseArgs( 4 )) return false;
|
||||
if(!CG_GetInteger(cls.cg_argv[0], &value))
|
||||
MsgDev(D_ERROR, "%s: can't use undefined alias %s\n", cls.cg_builtin, cls.cg_argv[0]);
|
||||
else CG_DrawCenterBarImage( (float)value, CG_ImageIndex(cls.cg_argv[1]), atoi(cls.cg_argv[2]), atoi(cls.cg_argv[3]));
|
||||
}
|
||||
else if(Com_MatchToken("DrawBarGeneric"))
|
||||
{
|
||||
// draw progress bar
|
||||
if(!CG_ParseArgs( 5 )) return false;
|
||||
if(!CG_GetInteger(cls.cg_argv[0], &value))
|
||||
MsgDev(D_ERROR, "%s: can't use undefined alias %s\n", cls.cg_builtin, cls.cg_argv[0]);
|
||||
else CG_DrawBarGeneric( (float)value, atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), atoi(cls.cg_argv[3]), atoi(cls.cg_argv[4]));
|
||||
}
|
||||
else if(Com_MatchToken("DrawCenterBarGeneric"))
|
||||
{
|
||||
// draw progress bar
|
||||
if(!CG_ParseArgs( 3 )) return false;
|
||||
if(!CG_GetInteger(cls.cg_argv[0], &value))
|
||||
MsgDev(D_ERROR, "%s: can't use undefined alias %s\n", cls.cg_builtin, cls.cg_argv[0]);
|
||||
else CG_DrawCenterBarGeneric( (float)value, atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]));
|
||||
}
|
||||
else if(Com_MatchToken("DrawString"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 3 )) return false;
|
||||
SCR_DrawBigString( atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), CG_ImageIndex(cls.cg_argv[0]), 1.0f );
|
||||
}
|
||||
else if(Com_MatchToken("DrawCenterString"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 1 )) return false;
|
||||
CG_DrawCenterStringBig(CG_ImageIndex(cls.cg_argv[0]), 1.0f );
|
||||
}
|
||||
else if(Com_MatchToken("(") || Com_MatchToken(")"));
|
||||
else
|
||||
{
|
||||
MsgDev(D_WARN, "%s: can't exec function %s\n", cls.cg_builtin, com_token );
|
||||
while(Com_TryToken());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_ExecuteProgram
|
||||
|
||||
Hudprogram executor
|
||||
================
|
||||
*/
|
||||
void CG_ExecuteProgram( char *section )
|
||||
{
|
||||
bool skip = true;
|
||||
|
||||
Com_ResetScript();
|
||||
com.strncpy( cls.cg_function, section, MAX_QPATH );
|
||||
cls.cg_depth = 0;
|
||||
|
||||
// not loaded
|
||||
if(!cls.cg_init) return;
|
||||
|
||||
// section not specified
|
||||
if(!section || !*section )
|
||||
return;
|
||||
|
||||
while(Com_GetToken( true ))
|
||||
{
|
||||
// first, we must find start of section
|
||||
if(Com_MatchToken("void"))
|
||||
{
|
||||
Com_GetToken( false ); // get section name
|
||||
if(Com_MatchToken( section )) skip = false;
|
||||
CG_ParseArgs( 1 ); // go to end of line
|
||||
}
|
||||
|
||||
if(skip) continue;
|
||||
|
||||
if(Com_MatchToken("return"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if(!CG_ExecBuiltins())
|
||||
{
|
||||
// end of section
|
||||
if(!cls.cg_depth) break;
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
CG_ResetColor(); // don't forget reset color
|
||||
}
|
|
@ -137,7 +137,7 @@ void CL_SetSky_f( void )
|
|||
SCR_TimeRefresh_f
|
||||
================
|
||||
*/
|
||||
void SCR_TimeRefresh_f (void)
|
||||
void SCR_TimeRefresh_f( void )
|
||||
{
|
||||
int i;
|
||||
float start, stop;
|
||||
|
@ -148,22 +148,22 @@ void SCR_TimeRefresh_f (void)
|
|||
|
||||
start = Sys_DoubleTime();
|
||||
|
||||
if (Cmd_Argc() == 2)
|
||||
if( Cmd_Argc() == 2 )
|
||||
{
|
||||
// run without page flipping
|
||||
re->BeginFrame();
|
||||
for (i = 0; i < 128; i++)
|
||||
for( i = 0; i < 128; i++ )
|
||||
{
|
||||
cl.refdef.viewangles[1] = i/128.0*360.0;
|
||||
cl.refdef.viewangles[1] = i/128.0 * 360.0f;
|
||||
re->RenderFrame (&cl.refdef);
|
||||
}
|
||||
re->EndFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 128; i++)
|
||||
for( i = 0; i < 128; i++ )
|
||||
{
|
||||
cl.refdef.viewangles[1] = i/128.0*360.0;
|
||||
cl.refdef.viewangles[1] = i/128.0 * 360.0f;
|
||||
|
||||
re->BeginFrame();
|
||||
re->RenderFrame(&cl.refdef);
|
||||
|
@ -173,5 +173,5 @@ void SCR_TimeRefresh_f (void)
|
|||
|
||||
stop = Sys_DoubleTime();
|
||||
time = stop - start;
|
||||
Msg ("%f seconds (%f fps)\n", time, 128/time);
|
||||
Msg( "%f seconds (%f fps)\n", time, 128 / time );
|
||||
}
|
|
@ -10,8 +10,12 @@ struct cl_edict_s
|
|||
// generic_edict_t (don't move these fields!)
|
||||
bool free;
|
||||
float freetime; // cl.time when the object was freed
|
||||
int serverframe; // if not current, this ent isn't in the frame
|
||||
|
||||
// ui_private_edict_t starts here
|
||||
// cl_private_edict_t
|
||||
entity_state_t baseline; // delta from this if not from a previous frame
|
||||
entity_state_t current;
|
||||
entity_state_t prev; // will always be valid, but might just be a copy of current
|
||||
};
|
||||
|
||||
struct cl_globalvars_s
|
||||
|
@ -25,37 +29,38 @@ struct cl_globalvars_s
|
|||
vec3_t v_forward;
|
||||
vec3_t v_right;
|
||||
vec3_t v_up;
|
||||
float time;
|
||||
float realtime;
|
||||
float frametime;
|
||||
float intermission;
|
||||
float paused;
|
||||
float spectator;
|
||||
float onground;
|
||||
float waterlevel;
|
||||
float clientflags;
|
||||
float intermission;
|
||||
float paused;
|
||||
vec3_t simvel;
|
||||
vec3_t simorg;
|
||||
vec3_t viewheight;
|
||||
float idealpitch;
|
||||
vec3_t viewheight;
|
||||
vec3_t cl_viewangles;
|
||||
float health;
|
||||
vec3_t crosshairangle;
|
||||
vec3_t punchangle;
|
||||
vec3_t crosshairangle;
|
||||
float smoothing;
|
||||
float maxclients;
|
||||
int viewentity;
|
||||
float playernum;
|
||||
float max_entities;
|
||||
float demoplayback;
|
||||
float smoothing;
|
||||
float screen_x;
|
||||
float screen_y;
|
||||
float screen_w;
|
||||
float screen_h;
|
||||
vec3_t blend_color;
|
||||
float blend_alpha;
|
||||
float max_entities;
|
||||
func_t HUD_Init;
|
||||
func_t HUD_Render;
|
||||
func_t HUD_ConsoleCommand;
|
||||
func_t HUD_StudioEvent;
|
||||
func_t HUD_ParseMessage;
|
||||
func_t HUD_Render;
|
||||
func_t HUD_UpdateEntities;
|
||||
func_t HUD_Shutdown;
|
||||
func_t V_CalcRefdef;
|
||||
};
|
||||
|
@ -63,19 +68,8 @@ struct cl_globalvars_s
|
|||
struct cl_entvars_s
|
||||
{
|
||||
string_t classname;
|
||||
string_t model;
|
||||
int chain;
|
||||
float frame;
|
||||
vec3_t origin;
|
||||
vec3_t angles;
|
||||
float sequence;
|
||||
float animtime;
|
||||
float framerate;
|
||||
float alpha;
|
||||
float body;
|
||||
float skin;
|
||||
float effects;
|
||||
float renderflags;
|
||||
string_t model;
|
||||
};
|
||||
|
||||
|
||||
|
@ -83,7 +77,7 @@ struct cl_entvars_s
|
|||
|
||||
static fields_t cl_reqfields[] =
|
||||
{
|
||||
{18, 2, "flags"}
|
||||
{3, 2, "flags"}
|
||||
};
|
||||
|
||||
#endif//CL_EDICT_H
|
|
@ -42,7 +42,10 @@ float LerpView(float org1, float org2, float ofs1, float ofs2, float frac)
|
|||
return org1 + ofs1 + frac * (org2 + ofs2 - (org1 + ofs1));
|
||||
}
|
||||
|
||||
|
||||
float LerpPoint( float oldpoint, float curpoint, float frac )
|
||||
{
|
||||
return oldpoint + frac * (curpoint - oldpoint);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -51,12 +54,10 @@ CL_ParseEntityBits
|
|||
Returns the entity number and the header bits
|
||||
=================
|
||||
*/
|
||||
int bitcounts[32]; /// just for protocol profiling
|
||||
int CL_ParseEntityBits( sizebuf_t *msg, uint *bits )
|
||||
{
|
||||
unsigned b, total;
|
||||
int i;
|
||||
int number;
|
||||
uint b, total;
|
||||
int number;
|
||||
|
||||
total = MSG_ReadByte (msg);
|
||||
if (total & U_MOREBITS1)
|
||||
|
@ -75,12 +76,8 @@ int CL_ParseEntityBits( sizebuf_t *msg, uint *bits )
|
|||
total |= b<<24;
|
||||
}
|
||||
|
||||
// count the bits for net profiling
|
||||
for( i = 0; i < 32; i++ )
|
||||
if( total&(1<<i)) bitcounts[i]++;
|
||||
|
||||
if (total & U_NUMBER16) number = MSG_ReadShort (msg);
|
||||
else number = MSG_ReadByte (msg);
|
||||
if( total & U_NUMBER16 ) number = MSG_ReadShort( msg );
|
||||
else number = MSG_ReadByte( msg );
|
||||
*bits = total;
|
||||
|
||||
return number;
|
||||
|
@ -110,27 +107,16 @@ void CL_DeltaEntity( sizebuf_t *msg, frame_t *frame, int newnum, entity_state_t
|
|||
// some data changes will force no lerping
|
||||
if (state->modelindex != ent->current.modelindex || state->weaponmodel != ent->current.weaponmodel || state->body != ent->current.body
|
||||
|| state->sequence != ent->current.sequence || abs(state->origin[0] - ent->current.origin[0]) > 512
|
||||
|| abs(state->origin[1] - ent->current.origin[1]) > 512 || abs(state->origin[2] - ent->current.origin[2]) > 512
|
||||
|| state->event == EV_PLAYER_TELEPORT || state->event == EV_OTHER_TELEPORT )
|
||||
|| abs(state->origin[1] - ent->current.origin[1]) > 512 || abs(state->origin[2] - ent->current.origin[2]) > 512 )
|
||||
{
|
||||
ent->serverframe = -99;
|
||||
}
|
||||
|
||||
if (ent->serverframe != cl.frame.serverframe - 1)
|
||||
{ // wasn't in last update, so initialize some things
|
||||
ent->trailcount = 1024; // for diminishing rocket / grenade trails
|
||||
if( ent->serverframe != cl.frame.serverframe - 1 )
|
||||
{
|
||||
// duplicate the current state so lerping doesn't hurt anything
|
||||
ent->prev = *state;
|
||||
if (state->event == EV_OTHER_TELEPORT)
|
||||
{
|
||||
VectorCopy (state->origin, ent->prev.origin);
|
||||
VectorCopy (state->origin, ent->lerp_origin);
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorCopy (state->old_origin, ent->prev.origin);
|
||||
VectorCopy (state->old_origin, ent->lerp_origin);
|
||||
}
|
||||
VectorCopy (state->old_origin, ent->prev.origin);
|
||||
}
|
||||
else
|
||||
{ // shuffle the last state to previous
|
||||
|
@ -161,11 +147,13 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
|
||||
// delta from the entities present in oldframe
|
||||
oldindex = 0;
|
||||
if( !oldframe ) oldnum = 99999;
|
||||
if( !oldframe ) oldnum = MAX_ENTNUMBER;
|
||||
else
|
||||
{
|
||||
if (oldindex >= oldframe->num_entities)
|
||||
oldnum = 99999;
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldstate = &cl_parse_entities[(oldframe->parse_entities+oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
|
@ -173,7 +161,7 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
}
|
||||
}
|
||||
|
||||
while (1)
|
||||
while( 1 )
|
||||
{
|
||||
newnum = CL_ParseEntityBits( msg, &bits );
|
||||
if (newnum >= MAX_EDICTS)
|
||||
|
@ -187,13 +175,14 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
while (oldnum < newnum)
|
||||
{
|
||||
// one or more entities from the old packet are unchanged
|
||||
if (cl_shownet->value == 3) Msg (" unchanged: %i\n", oldnum);
|
||||
CL_DeltaEntity( msg, newframe, oldnum, oldstate, 0);
|
||||
|
||||
oldindex++;
|
||||
|
||||
if (oldindex >= oldframe->num_entities)
|
||||
oldnum = 99999;
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldstate = &cl_parse_entities[(oldframe->parse_entities+oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
|
@ -201,15 +190,17 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
}
|
||||
}
|
||||
|
||||
if (bits & U_REMOVE)
|
||||
if( bits & U_REMOVE )
|
||||
{
|
||||
// the entity present in oldframe is not in the current frame
|
||||
if( cl_shownet->value == 3 ) Msg(" remove: %i\n", newnum);
|
||||
if( oldnum != newnum ) Msg("U_REMOVE: oldnum != newnum\n");
|
||||
|
||||
oldindex++;
|
||||
|
||||
if( oldindex >= oldframe->num_entities ) oldnum = 99999;
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldstate = &cl_parse_entities[(oldframe->parse_entities+oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
|
@ -218,16 +209,16 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
continue;
|
||||
}
|
||||
|
||||
if (oldnum == newnum)
|
||||
{ // delta from previous state
|
||||
if (cl_shownet->value == 3)
|
||||
Msg (" delta: %i\n", newnum);
|
||||
if( oldnum == newnum )
|
||||
{
|
||||
// delta from previous state
|
||||
CL_DeltaEntity( msg, newframe, newnum, oldstate, bits );
|
||||
|
||||
oldindex++;
|
||||
|
||||
if (oldindex >= oldframe->num_entities)
|
||||
oldnum = 99999;
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldstate = &cl_parse_entities[(oldframe->parse_entities+oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
|
@ -236,11 +227,9 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
continue;
|
||||
}
|
||||
|
||||
if (oldnum > newnum)
|
||||
if( oldnum > newnum )
|
||||
{
|
||||
// delta from baseline
|
||||
if (cl_shownet->value == 3)
|
||||
Msg (" baseline: %i\n", newnum);
|
||||
CL_DeltaEntity( msg, newframe, newnum, &cl_entities[newnum].baseline, bits );
|
||||
continue;
|
||||
}
|
||||
|
@ -248,16 +237,16 @@ void CL_ParsePacketEntities( sizebuf_t *msg, frame_t *oldframe, frame_t *newfram
|
|||
}
|
||||
|
||||
// any remaining entities in the old frame are copied over
|
||||
while (oldnum != 99999)
|
||||
{ // one or more entities from the old packet are unchanged
|
||||
if (cl_shownet->value == 3)
|
||||
Msg (" unchanged: %i\n", oldnum);
|
||||
while( oldnum != MAX_ENTNUMBER )
|
||||
{
|
||||
// one or more entities from the old packet are unchanged
|
||||
CL_DeltaEntity( msg, newframe, oldnum, oldstate, 0 );
|
||||
|
||||
oldindex++;
|
||||
|
||||
if (oldindex >= oldframe->num_entities)
|
||||
oldnum = 99999;
|
||||
if( oldindex >= oldframe->num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldstate = &cl_parse_entities[(oldframe->parse_entities+oldindex) & (MAX_PARSE_ENTITIES-1)];
|
||||
|
@ -378,36 +367,10 @@ void CL_ParsePlayerstate( sizebuf_t *msg, frame_t *oldframe, frame_t *newframe )
|
|||
|
||||
// parse stats
|
||||
statbits = MSG_ReadLong (msg);
|
||||
for (i = 0; i < MAX_STATS; i++)
|
||||
if (statbits & (1<<i) ) state->stats[i] = MSG_ReadShort(msg);
|
||||
for( i = 0; i < MAX_STATS; i++ )
|
||||
if(statbits & (1<<i)) state->stats[i] = MSG_ReadShort( msg );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_FireEntityEvents
|
||||
|
||||
==================
|
||||
*/
|
||||
void CL_FireEntityEvents (frame_t *frame)
|
||||
{
|
||||
entity_state_t *s1;
|
||||
int pnum, num;
|
||||
|
||||
for (pnum = 0 ; pnum<frame->num_entities ; pnum++)
|
||||
{
|
||||
num = (frame->parse_entities + pnum)&(MAX_PARSE_ENTITIES-1);
|
||||
s1 = &cl_parse_entities[num];
|
||||
if (s1->event)
|
||||
CL_EntityEvent (s1);
|
||||
|
||||
// EF_TELEPORTER acts like an event, but is not cleared each frame
|
||||
if (s1->effects & EF_TELEPORTER)
|
||||
CL_TeleporterParticles (s1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CL_ParseFrame
|
||||
|
@ -419,88 +382,76 @@ void CL_ParseFrame( sizebuf_t *msg )
|
|||
int len;
|
||||
frame_t *old;
|
||||
|
||||
memset (&cl.frame, 0, sizeof(cl.frame));
|
||||
|
||||
#if 0
|
||||
CL_ClearProjectiles(); // clear projectiles for new frame
|
||||
#endif
|
||||
|
||||
memset( &cl.frame, 0, sizeof(cl.frame));
|
||||
cl.frame.serverframe = MSG_ReadLong (msg);
|
||||
cl.frame.deltaframe = MSG_ReadLong (msg);
|
||||
cl.frame.servertime = cl.frame.serverframe * host_frametime->value;
|
||||
|
||||
// BIG HACK to let old demos continue to work
|
||||
if (cls.serverProtocol != 26) cl.surpressCount = MSG_ReadByte (msg);
|
||||
if (cl_shownet->value == 3) Msg (" frame:%i delta:%i\n", cl.frame.serverframe, cl.frame.deltaframe);
|
||||
cl.surpressCount = MSG_ReadByte (msg);
|
||||
|
||||
// If the frame is delta compressed from data that we
|
||||
// no longer have available, we must suck up the rest of
|
||||
// the frame, but not use it, then ask for a non-compressed
|
||||
// message
|
||||
if (cl.frame.deltaframe <= 0)
|
||||
if( cl.frame.deltaframe <= 0 )
|
||||
{
|
||||
cl.frame.valid = true; // uncompressed frame
|
||||
old = NULL;
|
||||
cl.frame.valid = true; // uncompressed frame
|
||||
cls.demowaiting = false; // we can start recording now
|
||||
old = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
old = &cl.frames[cl.frame.deltaframe & UPDATE_MASK];
|
||||
if (!old->valid)
|
||||
if( !old->valid )
|
||||
{
|
||||
// should never happen
|
||||
Msg ("Delta from invalid frame (not supposed to happen!).\n");
|
||||
MsgDev( D_INFO, "delta from invalid frame (not supposed to happen!).\n" );
|
||||
}
|
||||
if (old->serverframe != cl.frame.deltaframe)
|
||||
if( old->serverframe != cl.frame.deltaframe )
|
||||
{
|
||||
// The frame that the server did the delta from
|
||||
// is too old, so we can't reconstruct it properly.
|
||||
Msg ("Delta frame too old.\n");
|
||||
MsgDev( D_INFO, "Delta frame too old.\n" );
|
||||
}
|
||||
else if (cl.parse_entities - old->parse_entities > MAX_PARSE_ENTITIES-128)
|
||||
else if( cl.parse_entities - old->parse_entities > MAX_PARSE_ENTITIES - 128 )
|
||||
{
|
||||
Msg ("Delta parse_entities too old.\n");
|
||||
MsgDev( D_INFO, "delta parse_entities too old.\n" );
|
||||
}
|
||||
else cl.frame.valid = true; // valid delta parse
|
||||
}
|
||||
|
||||
// clamp time
|
||||
if (cl.time > cl.frame.servertime) cl.time = cl.frame.servertime;
|
||||
else if (cl.time < cl.frame.servertime - host_frametime->value) cl.time = cl.frame.servertime - host_frametime->value;
|
||||
if( cl.time > cl.frame.servertime ) cl.time = cl.frame.servertime;
|
||||
else if( cl.time < cl.frame.servertime - host_frametime->value )
|
||||
cl.time = cl.frame.servertime - host_frametime->value;
|
||||
|
||||
// read areabits
|
||||
len = MSG_ReadByte (msg);
|
||||
MSG_ReadData (msg, &cl.frame.areabits, len);
|
||||
len = MSG_ReadByte( msg );
|
||||
MSG_ReadData( msg, &cl.frame.areabits, len );
|
||||
|
||||
// read playerinfo
|
||||
cmd = MSG_ReadByte (msg);
|
||||
SHOWNET( msg, svc_strings[cmd] );
|
||||
if (cmd != svc_playerinfo) Host_Error("CL_ParseFrame: not playerinfo\n");
|
||||
cmd = MSG_ReadByte( msg );
|
||||
if( cmd != svc_playerinfo ) Host_Error( "CL_ParseFrame: not playerinfo\n" );
|
||||
CL_ParsePlayerstate( msg, old, &cl.frame );
|
||||
|
||||
// read packet entities
|
||||
cmd = MSG_ReadByte (msg);
|
||||
SHOWNET( msg, svc_strings[cmd] );
|
||||
if (cmd != svc_packetentities) Host_Error("CL_ParseFrame: not packetentities\n");
|
||||
if( cmd != svc_packetentities ) Host_Error("CL_ParseFrame: not packetentities\n" );
|
||||
CL_ParsePacketEntities( msg, old, &cl.frame );
|
||||
|
||||
|
||||
// save the frame off in the backup array for later delta comparisons
|
||||
cl.frames[cl.frame.serverframe & UPDATE_MASK] = cl.frame;
|
||||
|
||||
if (cl.frame.valid)
|
||||
if( cl.frame.valid )
|
||||
{
|
||||
// getting a valid frame message ends the connection process
|
||||
if(cls.state != ca_active)
|
||||
if( cls.state != ca_active )
|
||||
{
|
||||
cls.state = ca_active;
|
||||
cl.force_refdef = true;
|
||||
// getting a valid frame message ends the connection process
|
||||
VectorCopy( cl.frame.playerstate.origin, cl.predicted_origin );
|
||||
VectorCopy( cl.frame.playerstate.viewangles, cl.predicted_angles );
|
||||
}
|
||||
// fire entity events
|
||||
CL_FireEntityEvents (&cl.frame);
|
||||
CL_CheckPredictionError ();
|
||||
CL_CheckPredictionError();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,84 +462,31 @@ INTERPOLATE BETWEEN FRAMES TO GET RENDERING PARMS
|
|||
|
||||
==========================================================================
|
||||
*/
|
||||
|
||||
model_t *S_RegisterSexedModel (entity_state_t *ent, char *base)
|
||||
{
|
||||
int n;
|
||||
char *p;
|
||||
model_t *mdl;
|
||||
char model[MAX_QPATH];
|
||||
char buffer[MAX_QPATH];
|
||||
|
||||
// determine what model the client is using
|
||||
model[0] = 0;
|
||||
n = CS_PLAYERSKINS + ent->number - 1;
|
||||
if (cl.configstrings[n][0])
|
||||
{
|
||||
p = strchr(cl.configstrings[n], '\\');
|
||||
if (p)
|
||||
{
|
||||
p += 1;
|
||||
strcpy(model, p);
|
||||
p = strchr(model, '/');
|
||||
if (p)
|
||||
*p = 0;
|
||||
}
|
||||
}
|
||||
// if we can't figure it out, they're male
|
||||
if (!model[0])
|
||||
com.strcpy(model, "gordon");
|
||||
|
||||
com.sprintf (buffer, "players/%s/%s", model, base+1);
|
||||
mdl = re->RegisterModel(buffer);
|
||||
if (!mdl) {
|
||||
// not found, try default weapon model
|
||||
com.sprintf (buffer, "weapons/%s.mdl", model);
|
||||
mdl = re->RegisterModel(buffer);
|
||||
if (!mdl)
|
||||
{
|
||||
// no, revert to the male model
|
||||
com.sprintf (buffer, "models/players/%s/%s", "male", base+1);
|
||||
mdl = re->RegisterModel(buffer);
|
||||
if (!mdl)
|
||||
{
|
||||
// last try, default male weapon.mdl
|
||||
com.sprintf (buffer, "weapons/w_glock.mdl");
|
||||
mdl = re->RegisterModel(buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mdl;
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_AddPacketEntities
|
||||
|
||||
===============
|
||||
*/
|
||||
void CL_AddPacketEntities (frame_t *frame)
|
||||
void CL_AddPacketEntities( frame_t *frame )
|
||||
{
|
||||
entity_t ent;
|
||||
entity_state_t *s1;
|
||||
float autorotate;
|
||||
int i;
|
||||
int pnum;
|
||||
centity_t *cent;
|
||||
int autoanim;
|
||||
clientinfo_t *ci;
|
||||
entity_t ent;
|
||||
entity_state_t *s1;
|
||||
float autorotate;
|
||||
int i, pnum;
|
||||
centity_t *cent;
|
||||
int autoanim;
|
||||
uint effects, renderfx;
|
||||
|
||||
// bonus items rotate at a fixed rate
|
||||
autorotate = anglemod(cl.time/10);
|
||||
|
||||
// brush models can auto animate their frames
|
||||
autoanim = 2*cl.time/1000;
|
||||
autoanim = 2 * cl.time/1000;
|
||||
|
||||
memset (&ent, 0, sizeof(ent));
|
||||
memset( &ent, 0, sizeof(ent));
|
||||
|
||||
for (pnum = 0 ; pnum<frame->num_entities ; pnum++)
|
||||
for( pnum = 0; pnum < frame->num_entities; pnum++ )
|
||||
{
|
||||
s1 = &cl_parse_entities[(frame->parse_entities+pnum)&(MAX_PARSE_ENTITIES-1)];
|
||||
|
||||
|
@ -606,117 +504,59 @@ void CL_AddPacketEntities (frame_t *frame)
|
|||
ent.sequence = s1->sequence;
|
||||
ent.animtime = s1->animtime;
|
||||
|
||||
if (renderfx & (RF_FRAMELERP|RF_BEAM))
|
||||
// interpolate origin
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
// step origin discretely, because the frames
|
||||
// do the animation properly
|
||||
VectorCopy (cent->current.origin, ent.origin);
|
||||
VectorCopy (cent->current.old_origin, ent.oldorigin);
|
||||
}
|
||||
else
|
||||
{ // interpolate origin
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
ent.origin[i] = ent.oldorigin[i] = cent->prev.origin[i] + cl.lerpfrac *
|
||||
(cent->current.origin[i] - cent->prev.origin[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// create a new entity
|
||||
|
||||
// tweak the color of beams
|
||||
if ( renderfx & RF_BEAM )
|
||||
{ // the four beam colors are encoded in 32 bits of skin (hack)
|
||||
ent.alpha = 0.30;
|
||||
ent.skin = (s1->skin >> ((rand() % 4)*8)) & 0xff;
|
||||
ent.model = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// set skin
|
||||
if (s1->modelindex == 255)
|
||||
{ // use custom player skin
|
||||
ent.skin = 0;
|
||||
ci = &cl.clientinfo[s1->skin & 0xff];
|
||||
ent.image = ci->skin;
|
||||
ent.model = ci->model;
|
||||
if (!ent.image || !ent.model)
|
||||
{
|
||||
ent.image = cl.baseclientinfo.skin;
|
||||
ent.model = cl.baseclientinfo.model;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ent.skin = s1->skin;
|
||||
ent.image = NULL;
|
||||
ent.model = cl.model_draw[s1->modelindex];
|
||||
}
|
||||
ent.origin[i] = LerpPoint( cent->prev.origin[i], cent->current.origin[i], cl.lerpfrac );
|
||||
ent.oldorigin[i] = ent.origin[i];
|
||||
}
|
||||
|
||||
// set skin
|
||||
ent.skin = s1->skin;
|
||||
ent.model = cl.model_draw[s1->modelindex];
|
||||
ent.flags = renderfx;
|
||||
|
||||
// calculate angles
|
||||
if (effects & EF_ROTATE)
|
||||
{ // some bonus items auto-rotate
|
||||
if( effects & EF_ROTATE )
|
||||
{
|
||||
// some bonus items auto-rotate
|
||||
ent.angles[0] = 0;
|
||||
ent.angles[1] = autorotate;
|
||||
ent.angles[2] = 0;
|
||||
}
|
||||
else
|
||||
{ // interpolate angles
|
||||
float a1, a2;
|
||||
|
||||
for (i=0 ; i<3 ; i++)
|
||||
{
|
||||
// interpolate angles
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
a1 = cent->current.angles[i];
|
||||
a2 = cent->prev.angles[i];
|
||||
ent.angles[i] = LerpAngle (a2, a1, cl.lerpfrac);
|
||||
ent.angles[i] = LerpAngle( cent->prev.angles[i], cent->current.angles[i], cl.lerpfrac );
|
||||
}
|
||||
}
|
||||
|
||||
if (s1->number == cl.playernum+1)
|
||||
if( s1->number == cl.playernum + 1 )
|
||||
{
|
||||
ent.flags |= RF_VIEWERMODEL; // only draw from mirrors
|
||||
ent.flags |= RF_PLAYERMODEL; // only draw from mirrors
|
||||
continue;
|
||||
}
|
||||
|
||||
// if set to invisible, skip
|
||||
if (!s1->modelindex)
|
||||
continue;
|
||||
if( !s1->modelindex ) continue;
|
||||
|
||||
// add to refresh list
|
||||
V_AddEntity (&ent);
|
||||
V_AddEntity( &ent );
|
||||
|
||||
ent.image = NULL; // never use a custom skin on others
|
||||
ent.skin = 0;
|
||||
ent.flags = 0;
|
||||
ent.alpha = 0;
|
||||
|
||||
// duplicate for linked models
|
||||
if (s1->weaponmodel)
|
||||
if( s1->weaponmodel )
|
||||
{
|
||||
if (s1->weaponmodel == 255)
|
||||
{
|
||||
// custom weapon
|
||||
ci = &cl.clientinfo[s1->skin & 0xff];
|
||||
i = (s1->skin >> 8); // 0 is default weapon model
|
||||
if (!cl_vwep->value || i > MAX_CLIENTWEAPONMODELS - 1)
|
||||
i = 0;
|
||||
ent.model = ci->weaponmodel[i];
|
||||
if (!ent.model) {
|
||||
if (i != 0) ent.model = ci->weaponmodel[0];
|
||||
if (!ent.model) ent.model = cl.baseclientinfo.weaponmodel[0];
|
||||
}
|
||||
}
|
||||
else ent.model = cl.model_draw[s1->weaponmodel];
|
||||
|
||||
ent.model = cl.model_draw[s1->weaponmodel];
|
||||
V_AddEntity (&ent);
|
||||
|
||||
ent.flags = 0;
|
||||
ent.alpha = 0;
|
||||
}
|
||||
VectorCopy (ent.origin, cent->lerp_origin);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -727,13 +567,13 @@ void CL_AddPacketEntities (frame_t *frame)
|
|||
CL_AddViewWeapon
|
||||
==============
|
||||
*/
|
||||
void CL_AddViewWeapon (player_state_t *ps, player_state_t *ops)
|
||||
void CL_AddViewWeapon( player_state_t *ps, player_state_t *ops )
|
||||
{
|
||||
entity_t gun; // view model
|
||||
int i;
|
||||
entity_t gun; // view model
|
||||
int i;
|
||||
|
||||
// allow the gun to be completely removed
|
||||
if (!cl_gun->value) return;
|
||||
if( !cl_gun->value ) return;
|
||||
|
||||
// don't draw gun if in wide angle view
|
||||
if (ps->fov > 135) return;
|
||||
|
@ -745,29 +585,21 @@ void CL_AddViewWeapon (player_state_t *ps, player_state_t *ops)
|
|||
if (!gun.model) return;
|
||||
|
||||
// set up gun position
|
||||
for (i = 0; i < 3; i++)
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
gun.origin[i] = cl.refdef.vieworg[i] + ops->vmodel.offset[i] + cl.lerpfrac * (ps->vmodel.offset[i] - ops->vmodel.offset[i]);
|
||||
gun.angles[i] = cl.refdef.viewangles[i] + LerpAngle (ops->vmodel.angles[i], ps->vmodel.angles[i], cl.lerpfrac);
|
||||
}
|
||||
|
||||
if (gun_frame)
|
||||
{
|
||||
gun.frame = gun_frame; // development tool
|
||||
gun.prev.frame = gun_frame; // development tool
|
||||
}
|
||||
else
|
||||
{
|
||||
gun.frame = ps->vmodel.frame;
|
||||
if (gun.frame == 0) gun.prev.frame = 0; // just changed weapons, don't lerp from old
|
||||
else gun.prev.frame = ops->vmodel.frame;
|
||||
}
|
||||
gun.frame = ps->vmodel.frame;
|
||||
if( gun.frame == 0 ) gun.prev.frame = 0; // just changed weapons, don't lerp from old
|
||||
else gun.prev.frame = ops->vmodel.frame;
|
||||
|
||||
gun.body = ps->vmodel.body;
|
||||
gun.skin = ps->vmodel.skin;
|
||||
gun.sequence = ps->vmodel.sequence;
|
||||
|
||||
gun.flags = RF_MINLIGHT | RF_DEPTHHACK | RF_WEAPONMODEL;
|
||||
gun.flags = RF_MINLIGHT | RF_DEPTHHACK | RF_VIEWMODEL;
|
||||
gun.backlerp = 1.0 - cl.lerpfrac;
|
||||
VectorCopy ( gun.origin, gun.oldorigin ); // don't lerp at all
|
||||
V_AddEntity( &gun );
|
||||
|
@ -781,7 +613,7 @@ CL_CalcViewValues
|
|||
Sets cl.refdef view values
|
||||
===============
|
||||
*/
|
||||
void CL_CalcViewValues (void)
|
||||
void CL_CalcViewValues( void )
|
||||
{
|
||||
int i;
|
||||
float lerp, backlerp;
|
||||
|
@ -793,41 +625,38 @@ void CL_CalcViewValues (void)
|
|||
ps = &cl.frame.playerstate;
|
||||
i = (cl.frame.serverframe - 1) & UPDATE_MASK;
|
||||
oldframe = &cl.frames[i];
|
||||
if (oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid)
|
||||
if( oldframe->serverframe != cl.frame.serverframe-1 || !oldframe->valid )
|
||||
oldframe = &cl.frame; // previous frame was dropped or invalid
|
||||
ops = &oldframe->playerstate;
|
||||
|
||||
// see if the player entity was teleported this frame
|
||||
if (fabs(ops->origin[0] - ps->origin[0]) > 2048
|
||||
|| fabs(ops->origin[1] - ps->origin[1]) > 2048
|
||||
|| fabs(ops->origin[2] - ps->origin[2]) > 2048)
|
||||
if( fabs(ops->origin[0] - ps->origin[0]) > 2048 || fabs(ops->origin[1] - ps->origin[1]) > 2048 || fabs(ops->origin[2] - ps->origin[2]) > 2048)
|
||||
ops = ps; // don't interpolate
|
||||
|
||||
ent = &cl_entities[cl.playernum+1];
|
||||
ent = &cl_entities[cl.playernum + 1];
|
||||
lerp = cl.lerpfrac;
|
||||
|
||||
// calculate the origin
|
||||
if ((cl_predict->value) && !(cl.frame.playerstate.pm_flags & PMF_NO_PREDICTION))
|
||||
if((cl_predict->value) && !(cl.frame.playerstate.pm_flags & PMF_NO_PREDICTION))
|
||||
{
|
||||
// use predicted values
|
||||
float delta;
|
||||
|
||||
backlerp = 1.0 - lerp;
|
||||
for (i = 0; i < 3; i++)
|
||||
for( i = 0; i < 3; i++ )
|
||||
{
|
||||
cl.refdef.vieworg[i] = cl.predicted_origin[i] + ops->viewoffset[i]
|
||||
+ cl.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i])
|
||||
- backlerp * cl.prediction_error[i];
|
||||
+ cl.lerpfrac * (ps->viewoffset[i] - ops->viewoffset[i]) - backlerp * cl.prediction_error[i];
|
||||
}
|
||||
|
||||
// smooth out stair climbing
|
||||
delta = cls.realtime - cl.predicted_step_time;
|
||||
if (delta < host_frametime->value)
|
||||
if( delta < host_frametime->value )
|
||||
cl.refdef.vieworg[2] -= cl.predicted_step * (host_frametime->value - delta) * 0.01f;
|
||||
}
|
||||
else
|
||||
{ // just use interpolated values
|
||||
for (i = 0; i < 3; i++)
|
||||
for( i = 0; i < 3; i++ )
|
||||
cl.refdef.vieworg[i] = LerpView( ops->origin[i], ps->origin[i], ops->viewoffset[i], ps->viewoffset[i], lerp );
|
||||
}
|
||||
|
||||
|
@ -835,30 +664,28 @@ void CL_CalcViewValues (void)
|
|||
if( cls.demoplayback )
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
cl.refdef.viewangles[i] = LerpAngle (ops->viewangles[i], ps->viewangles[i], lerp);
|
||||
cl.refdef.viewangles[i] = LerpAngle( ops->viewangles[i], ps->viewangles[i], lerp );
|
||||
}
|
||||
else //if ( cl.frame.playerstate.pm_type < PM_DEAD )
|
||||
else
|
||||
{
|
||||
// in-game use predicted values
|
||||
for (i = 0; i < 3; i++) cl.refdef.viewangles[i] = cl.predicted_angles[i];
|
||||
}
|
||||
|
||||
for( i = 0; i < 3; i++ )
|
||||
cl.refdef.viewangles[i] += LerpAngle (ops->kick_angles[i], ps->kick_angles[i], lerp);
|
||||
cl.refdef.viewangles[i] += LerpAngle( ops->kick_angles[i], ps->kick_angles[i], lerp );
|
||||
|
||||
// sound engine requiried left-side hand
|
||||
AngleVectorsFLU(cl.refdef.viewangles, NULL, cl.v_left, NULL );
|
||||
AngleVectors(cl.refdef.viewangles, cl.v_forward, cl.v_right, cl.v_up);
|
||||
AngleVectors( cl.refdef.viewangles, cl.v_forward, cl.v_right, cl.v_up );
|
||||
|
||||
// interpolate field of view
|
||||
cl.refdef.fov_x = ops->fov + lerp * (ps->fov - ops->fov);
|
||||
cl.refdef.fov_x = ops->fov + lerp * ( ps->fov - ops->fov );
|
||||
|
||||
// don't interpolate blend color
|
||||
for (i = 0; i < 4; i++)
|
||||
for( i = 0; i < 4; i++ )
|
||||
cl.refdef.blend[i] = ps->blend[i];
|
||||
|
||||
// add the weapon
|
||||
CL_AddViewWeapon (ps, ops);
|
||||
CL_AddViewWeapon( ps, ops );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -868,14 +695,14 @@ CL_AddEntities
|
|||
Emits all entities, particles, and lights to the refresh
|
||||
===============
|
||||
*/
|
||||
void CL_AddEntities (void)
|
||||
void CL_AddEntities( void )
|
||||
{
|
||||
if (cls.state != ca_active)
|
||||
if( cls.state != ca_active )
|
||||
return;
|
||||
|
||||
if (cl.time > cl.frame.servertime)
|
||||
if( cl.time > cl.frame.servertime )
|
||||
{
|
||||
if (cl_showclamp->value)
|
||||
if( cl_showclamp->value )
|
||||
Msg ("high clamp %i\n", cl.time - cl.frame.servertime);
|
||||
cl.time = cl.frame.servertime;
|
||||
cl.lerpfrac = 1.0;
|
||||
|
@ -890,33 +717,10 @@ void CL_AddEntities (void)
|
|||
else cl.lerpfrac = 1.0 - (cl.frame.servertime - cl.time) * host_frametime->value;
|
||||
|
||||
CL_CalcViewValues();
|
||||
// PMM - moved this here so the heat beam has the right values for the vieworg, and can lock the beam to the gun
|
||||
CL_AddPacketEntities (&cl.frame);
|
||||
CL_AddTEnts ();
|
||||
CL_AddParticles ();
|
||||
CL_AddDLights ();
|
||||
CL_AddLightStyles ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
CL_GetEntitySoundOrigin
|
||||
|
||||
Called to get the sound spatialization origin
|
||||
===============
|
||||
*/
|
||||
void CL_GetEntitySoundOrigin (int ent, vec3_t org)
|
||||
{
|
||||
centity_t *old;
|
||||
|
||||
if (ent < 0 || ent >= MAX_EDICTS)
|
||||
Host_Error("CL_GetEntitySoundOrigin: entity out of range\n");
|
||||
old = &cl_entities[ent];
|
||||
VectorCopy (old->lerp_origin, org);
|
||||
|
||||
// FIXME: bmodel issues...
|
||||
CL_AddPacketEntities( &cl.frame );
|
||||
CL_AddParticles();
|
||||
CL_AddDLights();
|
||||
CL_AddLightStyles();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -939,28 +743,14 @@ void CL_GetEntitySoundSpatialization( int ent, vec3_t origin, vec3_t velocity )
|
|||
|
||||
cent = &cl_entities[ent];
|
||||
|
||||
if( cent->current.renderfx & (RF_FRAMELERP|RF_BEAM))
|
||||
{
|
||||
// calculate origin
|
||||
origin[0] = cent->current.old_origin[0] + (cent->current.origin[0] - cent->current.old_origin[0]) * cl.lerpfrac;
|
||||
origin[1] = cent->current.old_origin[1] + (cent->current.origin[1] - cent->current.old_origin[1]) * cl.lerpfrac;
|
||||
origin[2] = cent->current.old_origin[2] + (cent->current.origin[2] - cent->current.old_origin[2]) * cl.lerpfrac;
|
||||
// calculate origin
|
||||
origin[0] = cent->prev.origin[0] + (cent->current.origin[0] - cent->prev.origin[0]) * cl.lerpfrac;
|
||||
origin[1] = cent->prev.origin[1] + (cent->current.origin[1] - cent->prev.origin[1]) * cl.lerpfrac;
|
||||
origin[2] = cent->prev.origin[2] + (cent->current.origin[2] - cent->prev.origin[2]) * cl.lerpfrac;
|
||||
|
||||
// calculate velocity
|
||||
VectorSubtract( cent->current.origin, cent->current.old_origin, velocity );
|
||||
VectorScale(velocity, 10, velocity);
|
||||
}
|
||||
else
|
||||
{
|
||||
// calculate origin
|
||||
origin[0] = cent->prev.origin[0] + (cent->current.origin[0] - cent->prev.origin[0]) * cl.lerpfrac;
|
||||
origin[1] = cent->prev.origin[1] + (cent->current.origin[1] - cent->prev.origin[1]) * cl.lerpfrac;
|
||||
origin[2] = cent->prev.origin[2] + (cent->current.origin[2] - cent->prev.origin[2]) * cl.lerpfrac;
|
||||
|
||||
// calculate velocity
|
||||
VectorSubtract(cent->current.origin, cent->prev.origin, velocity);
|
||||
VectorScale(velocity, 10, velocity);
|
||||
}
|
||||
// calculate velocity
|
||||
VectorSubtract(cent->current.origin, cent->prev.origin, velocity);
|
||||
VectorScale(velocity, 10, velocity);
|
||||
|
||||
// if a brush model, offset the origin
|
||||
if( VectorIsNull( origin ))
|
||||
|
@ -988,7 +778,7 @@ void CL_AddLoopingSounds( void )
|
|||
|
||||
if( cls.state != ca_active ) return;
|
||||
if( cl_paused->integer ) return;
|
||||
//if( !cl.sound_prepped ) return;
|
||||
//if( !cl.sound_prepped ) return; //FIXME: enable
|
||||
|
||||
for( i = 0; i < cl.frame.num_entities; i++ )
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -388,7 +388,7 @@ void Field_Paste( field_t *edit )
|
|||
if ( !cbd ) return;
|
||||
|
||||
// send as if typed, so insert / overstrike works properly
|
||||
pasteLen = strlen( cbd );
|
||||
pasteLen = com.strlen( cbd );
|
||||
for ( i = 0 ; i < pasteLen ; i++ ) Field_CharEvent( edit, cbd[i] );
|
||||
Mem_Free( cbd );
|
||||
}
|
||||
|
@ -414,14 +414,7 @@ void Field_KeyDownEvent( field_t *edit, int key )
|
|||
return;
|
||||
}
|
||||
|
||||
// ctrl+v is paste
|
||||
if( key == 'v' && keys[K_CTRL].down )
|
||||
{
|
||||
Field_Paste( edit );
|
||||
return;
|
||||
}
|
||||
|
||||
len = strlen( edit->buffer );
|
||||
len = com.strlen( edit->buffer );
|
||||
|
||||
if ( key == K_DEL )
|
||||
{
|
||||
|
|
|
@ -280,7 +280,7 @@ void CL_Connect_f (void)
|
|||
|
||||
cls.state = ca_connecting;
|
||||
strncpy (cls.servername, server, sizeof(cls.servername)-1);
|
||||
cls.connect_time = -99999; // CL_CheckForResend() will fire immediately
|
||||
cls.connect_time = MAX_HEARTBEAT; // CL_CheckForResend() will fire immediately
|
||||
}
|
||||
|
||||
|
||||
|
@ -355,14 +355,11 @@ void CL_ClearState (void)
|
|||
{
|
||||
S_StopAllSounds ();
|
||||
CL_ClearEffects ();
|
||||
CL_ClearTEnts ();
|
||||
|
||||
// wipe the entire cl structure
|
||||
memset (&cl, 0, sizeof(cl));
|
||||
memset (&cl_entities, 0, sizeof(cl_entities));
|
||||
|
||||
SZ_Clear (&cls.netchan.message);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -517,7 +514,7 @@ void CL_Reconnect_f (void)
|
|||
CL_Disconnect();
|
||||
cls.connect_time = cls.realtime - 1.5f;
|
||||
}
|
||||
else cls.connect_time = -99999; // fire immediately
|
||||
else cls.connect_time = MAX_HEARTBEAT; // fire immediately
|
||||
|
||||
cls.state = ca_connecting;
|
||||
Msg ("reconnecting...\n");
|
||||
|
@ -1482,7 +1479,6 @@ void CL_Init( void )
|
|||
VID_Init();
|
||||
V_Init();
|
||||
CL_InitClientProgs();
|
||||
CG_Init();
|
||||
|
||||
net_message.data = net_message_buffer;
|
||||
net_message.maxsize = sizeof(net_message_buffer);
|
||||
|
|
|
@ -74,7 +74,7 @@ void UI_DrawCredits( void )
|
|||
if((y < (SCREEN_HEIGHT - BIGCHAR_HEIGHT) / 2) && i == credit_numlines - 1)
|
||||
{
|
||||
if(!credits_fade_time) credits_fade_time = cls.realtime;
|
||||
color = CG_FadeColor( credits_fade_time, credits_show_time );
|
||||
color = CL_FadeColor( credits_fade_time, credits_show_time );
|
||||
if( color ) SCR_DrawStringExt( x, (SCREEN_HEIGHT - BIGCHAR_HEIGHT)/2, 16, 16, credits[i], color, true );
|
||||
}
|
||||
else SCR_DrawStringExt( x, y, 16, 16, credits[i], white_color, false );
|
||||
|
@ -308,35 +308,6 @@ void PF_newserver( void )
|
|||
Cbuf_AddText( va("map %s\n", s ));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
PF_substring
|
||||
|
||||
string substring( string s, float start, float length )
|
||||
=========
|
||||
*/
|
||||
void PF_substring( void )
|
||||
{
|
||||
int i, start, length;
|
||||
string tempstring;
|
||||
const char *s;
|
||||
|
||||
if(!VM_ValidateArgs( "substring", 3 ))
|
||||
return;
|
||||
|
||||
s = PRVM_G_STRING(OFS_PARM0);
|
||||
start = (int)PRVM_G_FLOAT(OFS_PARM1);
|
||||
length = (int)PRVM_G_FLOAT(OFS_PARM2);
|
||||
if(!s) s = ""; // evil stuff...
|
||||
|
||||
for (i = 0; i < start && *s; i++, s++ );
|
||||
for (i = 0; i < MAX_STRING - 1 && *s && i < length; i++, s++)
|
||||
tempstring[i] = *s;
|
||||
tempstring[i] = 0;
|
||||
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString( tempstring );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
PF_serverstate
|
||||
|
@ -365,31 +336,6 @@ void PF_clientstate( void )
|
|||
PRVM_G_FLOAT(OFS_RETURN) = cls.state;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
PF_localsound
|
||||
|
||||
void localsound( string sample )
|
||||
=========
|
||||
*/
|
||||
void PF_localsound(void)
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if(!VM_ValidateArgs( "localsound", 1 ))
|
||||
return;
|
||||
|
||||
s = PRVM_G_STRING( OFS_PARM0 );
|
||||
|
||||
if(!S_StartLocalSound(s))
|
||||
{
|
||||
VM_Warning("PF_localsound: can't play %s!\n", s );
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 0;
|
||||
return;
|
||||
}
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
PF_getmousepos
|
||||
|
@ -692,7 +638,7 @@ VM_ComVA, // #29 string va( ... )
|
|||
VM_ComStrlen, // #30 float strlen( string text )
|
||||
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
|
||||
VM_LocalCmd, // #32 void LocalCmd( ... )
|
||||
NULL, // #33 -- reserved --
|
||||
VM_SubString, // #33 string substring( string s, float start, float length )
|
||||
NULL, // #34 -- reserved --
|
||||
NULL, // #35 -- reserved --
|
||||
NULL, // #36 -- reserved --
|
||||
|
@ -751,10 +697,10 @@ e10, e10, // #81 - #100 are reserved for future expansions
|
|||
// uimenufuncs_t
|
||||
VM_FindEdict, // #101 entity find( entity start, .string field, string match )
|
||||
VM_FindField, // #102 entity findfloat( entity start, .float field, float match )
|
||||
PF_substring, // #103 string substring( string s, float start, float length )
|
||||
NULL, // #103 -- reserved --
|
||||
PF_serverstate, // #104 float serverstate( void )
|
||||
PF_clientstate, // #105 float clientstate( void )
|
||||
PF_localsound, // #106 void localsound( string sample )
|
||||
VM_localsound, // #106 void localsound( string sample )
|
||||
PF_getmousepos, // #107 vector getmousepos( void )
|
||||
PF_loadfromdata, // #108 void loadfromdata( string data )
|
||||
PF_loadfromfile, // #109 float loadfromfile( string file )
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,32 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "common.h"
|
||||
#include "client.h"
|
||||
|
||||
char *svc_strings[256] =
|
||||
{
|
||||
"svc_bad",
|
||||
|
||||
"svc_temp_entity",
|
||||
"svc_layout",
|
||||
"svc_inventory",
|
||||
|
||||
"svc_nop",
|
||||
"svc_disconnect",
|
||||
"svc_reconnect",
|
||||
"svc_sound",
|
||||
"svc_ambientsound",
|
||||
"svc_print",
|
||||
"svc_stufftext",
|
||||
"svc_serverdata",
|
||||
"svc_configstring",
|
||||
"svc_spawnbaseline",
|
||||
"svc_centerprint",
|
||||
"svc_download",
|
||||
"svc_playerinfo",
|
||||
"svc_packetentities",
|
||||
"svc_deltapacketentities",
|
||||
"svc_frame"
|
||||
};
|
||||
|
||||
//=============================================================================
|
||||
|
||||
void CL_DownloadFileName(char *dest, int destlen, char *fn)
|
||||
|
@ -184,10 +158,9 @@ CL_RegisterSounds
|
|||
*/
|
||||
void CL_RegisterSounds (void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
S_BeginRegistration();
|
||||
CL_RegisterTEntSounds ();
|
||||
for (i = 1; i < MAX_SOUNDS; i++)
|
||||
{
|
||||
if (!cl.configstrings[CS_SOUNDS+i][0]) break;
|
||||
|
@ -599,8 +572,8 @@ CL_ParseServerMessage
|
|||
*/
|
||||
void CL_ParseServerMessage( sizebuf_t *msg )
|
||||
{
|
||||
int i, cmd;
|
||||
char *s;
|
||||
char *s;
|
||||
int cmd;
|
||||
|
||||
// if recording demos, copy the message out
|
||||
if (cl_shownet->value == 1) Msg ("%i ",msg->cursize);
|
||||
|
@ -624,101 +597,68 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
|||
SHOWNET( msg, "END OF MESSAGE" );
|
||||
break;
|
||||
}
|
||||
|
||||
if (cl_shownet->value >= 2)
|
||||
{
|
||||
if (!svc_strings[cmd]) Msg ("%3i:BAD CMD %i\n", msg->readcount - 1, cmd);
|
||||
else SHOWNET( msg, svc_strings[cmd] );
|
||||
}
|
||||
|
||||
// other commands
|
||||
switch (cmd)
|
||||
switch( cmd )
|
||||
{
|
||||
case svc_nop:
|
||||
// Msg ("svc_nop\n");
|
||||
MsgDev( D_ERROR, "CL_ParseServerMessage: user message out of bounds\n" );
|
||||
break;
|
||||
|
||||
case svc_disconnect:
|
||||
CL_Drop ();
|
||||
Host_AbortCurrentFrame();
|
||||
break;
|
||||
|
||||
case svc_reconnect:
|
||||
Msg ("Server disconnected, reconnecting\n");
|
||||
if (cls.download)
|
||||
Msg( "Server disconnected, reconnecting\n" );
|
||||
if( cls.download )
|
||||
{
|
||||
//ZOID, close download
|
||||
FS_Close (cls.download);
|
||||
FS_Close( cls.download );
|
||||
cls.download = NULL;
|
||||
}
|
||||
cls.state = ca_connecting;
|
||||
cls.connect_time = -99999; // CL_CheckForResend() will fire immediately
|
||||
cls.connect_time = MAX_HEARTBEAT; // CL_CheckForResend() will fire immediately
|
||||
break;
|
||||
|
||||
case svc_print:
|
||||
i = MSG_ReadByte( msg );
|
||||
if( i == PRINT_CHAT ) S_StartLocalSound ("misc/talk.wav"); // chat
|
||||
Msg ("^6%s", MSG_ReadString( msg ));
|
||||
break;
|
||||
|
||||
case svc_centerprint:
|
||||
CG_CenterPrint(MSG_ReadString( msg ), SCREEN_HEIGHT/2, BIGCHAR_WIDTH );
|
||||
break;
|
||||
|
||||
case svc_stufftext:
|
||||
s = MSG_ReadString( msg );
|
||||
Cbuf_AddText (s);
|
||||
Cbuf_AddText( s );
|
||||
break;
|
||||
|
||||
case svc_serverdata:
|
||||
Cbuf_Execute (); // make sure any stuffed commands are done
|
||||
Cbuf_Execute(); // make sure any stuffed commands are done
|
||||
CL_ParseServerData( msg );
|
||||
break;
|
||||
|
||||
case svc_configstring:
|
||||
CL_ParseConfigString( msg );
|
||||
break;
|
||||
|
||||
case svc_sound:
|
||||
CL_ParseStartSoundPacket( msg );
|
||||
break;
|
||||
|
||||
case svc_ambientsound:
|
||||
CL_ParseAmbientSound( msg );
|
||||
break;
|
||||
|
||||
case svc_spawnbaseline:
|
||||
CL_ParseBaseline( msg );
|
||||
break;
|
||||
|
||||
case svc_temp_entity:
|
||||
CL_ParseTEnt( msg );
|
||||
CL_ParseTempEnts( msg );
|
||||
break;
|
||||
|
||||
case svc_download:
|
||||
CL_ParseDownload( msg );
|
||||
break;
|
||||
|
||||
case svc_frame:
|
||||
CL_ParseFrame( msg );
|
||||
break;
|
||||
|
||||
case svc_inventory:
|
||||
CG_ParseInventory( msg );
|
||||
break;
|
||||
|
||||
case svc_layout:
|
||||
s = MSG_ReadString( msg );
|
||||
com.strncpy(cl.layout, s, sizeof(cl.layout)-1);
|
||||
break;
|
||||
|
||||
case svc_playerinfo:
|
||||
case svc_packetentities:
|
||||
case svc_deltapacketentities:
|
||||
Host_Error("Out of place frame data\n");
|
||||
Host_Error("CL_ParseServerMessage: out of place frame data\n");
|
||||
break;
|
||||
case svc_bad:
|
||||
Host_Error("CL_ParseServerMessage: svc_bad\n" );
|
||||
break;
|
||||
default:
|
||||
Host_Error("CL_ParseServerMessage: Illegible server message %d\n", cmd );
|
||||
// parse user messages
|
||||
if(!CL_ParseUserMessage( cmd ))
|
||||
Host_Error("CL_ParseServerMessage: illegible server message %d\n", cmd );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -728,6 +668,4 @@ void CL_ParseServerMessage( sizebuf_t *msg )
|
|||
if (cls.demorecording && !cls.demowaiting)
|
||||
CL_WriteDemoMessage();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -61,7 +61,7 @@ void CL_DrawHUD( void )
|
|||
// setup pparms
|
||||
prog->globals.cl->health = cl.frame.playerstate.stats[STAT_HEALTH];
|
||||
prog->globals.cl->maxclients = com.atoi(cl.configstrings[CS_MAXCLIENTS]);
|
||||
prog->globals.cl->time = cl.time;
|
||||
prog->globals.cl->realtime = cls.realtime;
|
||||
prog->globals.cl->paused = cl_paused->integer;
|
||||
|
||||
// setup args
|
||||
|
@ -71,6 +71,55 @@ void CL_DrawHUD( void )
|
|||
PRVM_End;
|
||||
}
|
||||
|
||||
bool CL_ParseUserMessage( int svc_number )
|
||||
{
|
||||
bool msg_parsed = false;
|
||||
|
||||
PRVM_Begin;
|
||||
PRVM_SetProg( PRVM_CLIENTPROG );
|
||||
|
||||
// set time
|
||||
*prog->time = cls.realtime;
|
||||
|
||||
// setup pparms
|
||||
prog->globals.cl->health = cl.frame.playerstate.stats[STAT_HEALTH];
|
||||
prog->globals.cl->maxclients = com.atoi(cl.configstrings[CS_MAXCLIENTS]);
|
||||
prog->globals.cl->realtime = cls.realtime;
|
||||
prog->globals.cl->paused = cl_paused->integer;
|
||||
|
||||
// setup args
|
||||
PRVM_G_FLOAT(OFS_PARM0) = (float)svc_number;
|
||||
PRVM_ExecuteProgram (prog->globals.cl->HUD_ParseMessage, "QC function HUD_ParseMessage is missing");
|
||||
msg_parsed = PRVM_G_FLOAT(OFS_RETURN);
|
||||
PRVM_End;
|
||||
|
||||
return msg_parsed;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
StudioEvent
|
||||
|
||||
Event callback for studio models
|
||||
====================
|
||||
*/
|
||||
void CL_StudioEvent ( mstudioevent_t *event, entity_t *ent )
|
||||
{
|
||||
PRVM_Begin;
|
||||
PRVM_SetProg( PRVM_CLIENTPROG );
|
||||
|
||||
// set time
|
||||
*prog->time = cls.realtime;
|
||||
|
||||
// setup args
|
||||
PRVM_G_FLOAT(OFS_PARM0) = (float)event->event;
|
||||
PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString( event->options );
|
||||
VectorCopy( ent->origin, PRVM_G_VECTOR(OFS_PARM2));
|
||||
VectorCopy( ent->angles, PRVM_G_VECTOR(OFS_PARM3));
|
||||
PRVM_ExecuteProgram( prog->globals.cl->HUD_StudioEvent, "QC function HUD_StudioEvent is missing");
|
||||
PRVM_End;
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
Client Builtin Functions
|
||||
|
@ -193,28 +242,24 @@ void PF_drawfield( void )
|
|||
=========
|
||||
PF_drawnet
|
||||
|
||||
void DrawNet( vector pos, vector size, string image )
|
||||
void DrawNet( vector pos, string image )
|
||||
=========
|
||||
*/
|
||||
void PF_drawnet( void )
|
||||
{
|
||||
float *pos, *size;
|
||||
float *pos;
|
||||
const char *pic;
|
||||
|
||||
if(!VM_ValidateArgs( "drawnet", 3 ))
|
||||
if(!VM_ValidateArgs( "drawnet", 2 ))
|
||||
return;
|
||||
if(cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP-1)
|
||||
return;
|
||||
|
||||
pos = PRVM_G_VECTOR(OFS_PARM0);
|
||||
size = PRVM_G_VECTOR(OFS_PARM1);
|
||||
pic = PRVM_G_STRING(OFS_PARM2);
|
||||
pic = PRVM_G_STRING(OFS_PARM1);
|
||||
VM_ValidateString( pic );
|
||||
|
||||
if(size[0] == 0.0f) size[0] = 48;
|
||||
if(size[1] == 0.0f) size[1] = 48;
|
||||
|
||||
SCR_DrawPic( pos[0], pos[1], size[0], size[1], pic );
|
||||
SCR_DrawPic( pos[0], pos[1], -1, -1, pic );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -438,7 +483,7 @@ VM_ComVA, // #29 string va( ... )
|
|||
VM_ComStrlen, // #30 float strlen( string text )
|
||||
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
|
||||
VM_LocalCmd, // #32 void LocalCmd( ... )
|
||||
NULL, // #33 -- reserved --
|
||||
VM_SubString, // #33 string substring( string s, float start, float length )
|
||||
NULL, // #34 -- reserved --
|
||||
NULL, // #35 -- reserved --
|
||||
NULL, // #36 -- reserved --
|
||||
|
@ -516,12 +561,13 @@ VM_drawfill, // #116 void DrawFill( vector pos, vector size, vector rgb, float
|
|||
VM_drawmodel, // #117 void DrawModel( vector pos, vector size, string mod, vector org, vector ang, float seq )
|
||||
PF_drawfield, // #118 void DrawField( float value, vector pos, vector size )
|
||||
VM_getimagesize, // #119 vector getimagesize( string pic )
|
||||
PF_drawnet, // #120 void DrawNet( vector pos, vector size, string image )
|
||||
PF_drawnet, // #120 void DrawNet( vector pos, string image )
|
||||
PF_drawfps, // #121 void DrawFPS( vector pos )
|
||||
PF_drawcenterprint, // #122 void DrawCenterPrint( void )
|
||||
PF_centerprint, // #123 void HUD_CenterPrint( string text, float y, float charwidth )
|
||||
PF_levelshot, // #124 float HUD_MakeLevelShot( void )
|
||||
PF_setcolor, // #125 void HUD_SetColor( vector rgb, float alpha )
|
||||
VM_localsound, // #126 void HUD_PlaySound( string sample )
|
||||
};
|
||||
|
||||
const int vm_cl_numbuiltins = sizeof(vm_cl_builtins) / sizeof(prvm_builtin_t); //num of builtins
|
||||
|
@ -558,7 +604,7 @@ void CL_InitClientProgs( void )
|
|||
}
|
||||
|
||||
// init some globals
|
||||
prog->globals.cl->time = cl.time;
|
||||
prog->globals.cl->realtime = cls.realtime;
|
||||
prog->globals.cl->pev = 0;
|
||||
prog->globals.cl->mapname = PRVM_SetEngineString( cls.servername );
|
||||
prog->globals.cl->playernum = cl.playernum;
|
||||
|
@ -572,7 +618,7 @@ void CL_FreeClientProgs( void )
|
|||
{
|
||||
CL_VM_Begin();
|
||||
|
||||
prog->globals.cl->time = cl.time;
|
||||
prog->globals.cl->realtime = cls.realtime;
|
||||
prog->globals.cl->pev = 0;
|
||||
PRVM_ExecuteProgram(prog->globals.cl->HUD_Shutdown, "QC function HUD_Shutdown is missing");
|
||||
PRVM_ResetProg();
|
||||
|
|
|
@ -247,58 +247,6 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
|
|||
re->SetColor( NULL );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SCR_DrawNet
|
||||
==============
|
||||
*/
|
||||
void SCR_DrawNet( void )
|
||||
{
|
||||
if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < CMD_BACKUP-1)
|
||||
return;
|
||||
|
||||
SCR_DrawPic( scr_vrect.x+64, scr_vrect.y, 48, 48, "common/net" );
|
||||
}
|
||||
|
||||
void SCR_DrawFPS( void )
|
||||
{
|
||||
float calc;
|
||||
static double nexttime = 0, lasttime = 0;
|
||||
static double framerate = 0;
|
||||
static int framecount = 0;
|
||||
double newtime;
|
||||
bool red = false; // fps too low
|
||||
char fpsstring[32];
|
||||
float *color;
|
||||
|
||||
if(cls.state != ca_active) return;
|
||||
if(!cl_showfps->integer) return;
|
||||
|
||||
newtime = Sys_DoubleTime();
|
||||
if (newtime >= nexttime)
|
||||
{
|
||||
framerate = framecount / (newtime - lasttime);
|
||||
lasttime = newtime;
|
||||
nexttime = max(nexttime + 1, lasttime - 1);
|
||||
framecount = 0;
|
||||
}
|
||||
framecount++;
|
||||
calc = framerate;
|
||||
|
||||
if ((red = (calc < 1.0f)))
|
||||
{
|
||||
com.snprintf(fpsstring, sizeof(fpsstring), "%4i spf", (int)(1.0f / calc + 0.5));
|
||||
color = g_color_table[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
com.snprintf(fpsstring, sizeof(fpsstring), "%4i fps", (int)(calc + 0.5));
|
||||
color = g_color_table[3];
|
||||
}
|
||||
SCR_DrawBigStringColor(SCREEN_WIDTH - 146, SCREEN_HEIGHT - 32, fpsstring, color );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
SCR_UpdateScreen
|
||||
|
@ -332,7 +280,6 @@ void SCR_UpdateScreen( void )
|
|||
Host_Error("SCR_UpdateScreen: bad cls.state" );
|
||||
break;
|
||||
}
|
||||
|
||||
V_PostRender();
|
||||
}
|
||||
|
||||
|
|
|
@ -22,472 +22,27 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "common.h"
|
||||
#include "client.h"
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ex_free, ex_explosion, ex_misc, ex_flash, ex_mflash, ex_poly, ex_poly2
|
||||
} exptype_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
exptype_t type;
|
||||
entity_t ent;
|
||||
|
||||
int frames;
|
||||
float light;
|
||||
vec3_t lightcolor;
|
||||
float start;
|
||||
int baseframe;
|
||||
} explosion_t;
|
||||
|
||||
// temp entity events
|
||||
//
|
||||
// Temp entity events are for things that happen
|
||||
// at a location seperate from any existing entity.
|
||||
// Temporary entity messages are explicitly constructed
|
||||
// and broadcast.
|
||||
typedef enum
|
||||
{
|
||||
TE_TELEPORT = 0,
|
||||
TE_GUNSHOT,
|
||||
TE_BLOOD,
|
||||
TE_BLASTER,
|
||||
TE_RAILTRAIL,
|
||||
TE_SHOTGUN,
|
||||
TE_EXPLOSION1,
|
||||
TE_EXPLOSION2,
|
||||
TE_ROCKET_EXPLOSION,
|
||||
TE_GRENADE_EXPLOSION,
|
||||
TE_SPARKS,
|
||||
TE_SPLASH,
|
||||
TE_BUBBLETRAIL,
|
||||
TE_SCREEN_SPARKS,
|
||||
TE_SHIELD_SPARKS,
|
||||
TE_BULLET_SPARKS,
|
||||
TE_LASER_SPARKS,
|
||||
TE_PARASITE_ATTACK,
|
||||
TE_ROCKET_EXPLOSION_WATER,
|
||||
TE_GRENADE_EXPLOSION_WATER,
|
||||
TE_MEDIC_CABLE_ATTACK,
|
||||
TE_BFG_EXPLOSION,
|
||||
TE_BFG_BIGEXPLOSION,
|
||||
TE_BOSSTPORT, // used as '22' in a map, so DON'T RENUMBER!!!
|
||||
TE_BFG_LASER,
|
||||
TE_GRAPPLE_CABLE,
|
||||
TE_WELDING_SPARKS,
|
||||
TE_GREENBLOOD,
|
||||
TE_BLUEHYPERBLASTER,
|
||||
TE_PLASMA_EXPLOSION,
|
||||
TE_TUNNEL_SPARKS,
|
||||
TE_FLASHLIGHT,
|
||||
TE_DEBUGTRAIL,
|
||||
} temp_event_t;
|
||||
|
||||
|
||||
#define MAX_EXPLOSIONS 32
|
||||
explosion_t cl_explosions[MAX_EXPLOSIONS];
|
||||
|
||||
|
||||
#define MAX_BEAMS 32
|
||||
typedef struct
|
||||
{
|
||||
int entity;
|
||||
int dest_entity;
|
||||
model_t *model;
|
||||
int endtime;
|
||||
vec3_t offset;
|
||||
vec3_t start, end;
|
||||
} beam_t;
|
||||
beam_t cl_beams[MAX_BEAMS];
|
||||
//PMM - added this for player-linked beams. Currently only used by the plasma beam
|
||||
beam_t cl_playerbeams[MAX_BEAMS];
|
||||
|
||||
|
||||
#define MAX_LASERS 32
|
||||
typedef struct
|
||||
{
|
||||
entity_t ent;
|
||||
int endtime;
|
||||
} laser_t;
|
||||
laser_t cl_lasers[MAX_LASERS];
|
||||
|
||||
void CL_BlasterParticles (vec3_t org, vec3_t dir);
|
||||
void CL_ExplosionParticles (vec3_t org);
|
||||
void CL_BFGExplosionParticles (vec3_t org);
|
||||
// RAFAEL
|
||||
void CL_BlueBlasterParticles (vec3_t org, vec3_t dir);
|
||||
|
||||
sound_t cl_sfx_ric1;
|
||||
sound_t cl_sfx_ric2;
|
||||
sound_t cl_sfx_ric3;
|
||||
sound_t cl_sfx_lashit;
|
||||
sound_t cl_sfx_spark5;
|
||||
sound_t cl_sfx_spark6;
|
||||
sound_t cl_sfx_spark7;
|
||||
sound_t cl_sfx_railg;
|
||||
sound_t cl_sfx_rockexp;
|
||||
sound_t cl_sfx_grenexp;
|
||||
sound_t cl_sfx_watrexp;
|
||||
// RAFAEL
|
||||
sound_t cl_sfx_plasexp;
|
||||
sound_t cl_sfx_footsteps[4];
|
||||
|
||||
model_t *cl_mod_explode;
|
||||
model_t *cl_mod_smoke;
|
||||
model_t *cl_mod_flash;
|
||||
model_t *cl_mod_laser;
|
||||
model_t *cl_mod_explo2;
|
||||
model_t *cl_mod_explo4;
|
||||
model_t *cl_mod_bfg_explo;
|
||||
model_t *cl_mod_plasmaexplo;
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_RegisterTEntSounds
|
||||
CL_ParseTempEnts
|
||||
=================
|
||||
*/
|
||||
void CL_RegisterTEntSounds (void)
|
||||
{
|
||||
int i;
|
||||
char name[MAX_QPATH];
|
||||
|
||||
// PMM - version stuff
|
||||
// PMM
|
||||
cl_sfx_ric1 = S_RegisterSound ("world/ric1.wav");
|
||||
cl_sfx_ric2 = S_RegisterSound ("world/ric2.wav");
|
||||
cl_sfx_ric3 = S_RegisterSound ("world/ric3.wav");
|
||||
cl_sfx_lashit = S_RegisterSound("weapons/lashit.wav");
|
||||
cl_sfx_spark5 = S_RegisterSound ("world/spark5.wav");
|
||||
cl_sfx_spark6 = S_RegisterSound ("world/spark6.wav");
|
||||
cl_sfx_spark7 = S_RegisterSound ("world/spark7.wav");
|
||||
cl_sfx_railg = S_RegisterSound ("weapons/railgf1a.wav");
|
||||
cl_sfx_rockexp = S_RegisterSound ("weapons/rocklx1a.wav");
|
||||
cl_sfx_grenexp = S_RegisterSound ("weapons/grenlx1a.wav");
|
||||
cl_sfx_watrexp = S_RegisterSound ("weapons/xpld_wat.wav");
|
||||
// RAFAEL
|
||||
// cl_sfx_plasexp = S_RegisterSound ("weapons/plasexpl.wav");
|
||||
S_RegisterSound ("player/land1.wav");
|
||||
|
||||
S_RegisterSound ("player/fall2.wav");
|
||||
S_RegisterSound ("player/fall1.wav");
|
||||
|
||||
for (i=0 ; i<4 ; i++)
|
||||
{
|
||||
com.sprintf (name, "player/step%i.wav", i+1);
|
||||
cl_sfx_footsteps[i] = S_RegisterSound (name);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_RegisterTEntModels
|
||||
=================
|
||||
*/
|
||||
void CL_RegisterTEntModels (void)
|
||||
{
|
||||
cl_mod_explode = re->RegisterModel ("sprites/explode01.spr");
|
||||
cl_mod_smoke = re->RegisterModel ("sprites/blacksmoke.spr");
|
||||
cl_mod_flash = re->RegisterModel ("sprites/s_flash.spr");
|
||||
cl_mod_laser = re->RegisterModel ("sprite/laserbeam.spr");
|
||||
cl_mod_explo2 = re->RegisterModel ("sprites/s_explo2.spr");
|
||||
cl_mod_explo4 = re->RegisterModel ("sprites/s_explod.spr");
|
||||
cl_mod_bfg_explo = re->RegisterModel ("sprites/s_bfg2.spr");
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ClearTEnts
|
||||
=================
|
||||
*/
|
||||
void CL_ClearTEnts (void)
|
||||
{
|
||||
memset (cl_beams, 0, sizeof(cl_beams));
|
||||
memset (cl_explosions, 0, sizeof(cl_explosions));
|
||||
memset (cl_lasers, 0, sizeof(cl_lasers));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_AllocExplosion
|
||||
=================
|
||||
*/
|
||||
explosion_t *CL_AllocExplosion (void)
|
||||
{
|
||||
int i;
|
||||
int time;
|
||||
int index;
|
||||
|
||||
for (i=0 ; i<MAX_EXPLOSIONS ; i++)
|
||||
{
|
||||
if (cl_explosions[i].type == ex_free)
|
||||
{
|
||||
memset (&cl_explosions[i], 0, sizeof (cl_explosions[i]));
|
||||
return &cl_explosions[i];
|
||||
}
|
||||
}
|
||||
// find the oldest explosion
|
||||
time = cl.time;
|
||||
index = 0;
|
||||
|
||||
for (i=0 ; i<MAX_EXPLOSIONS ; i++)
|
||||
if (cl_explosions[i].start < time)
|
||||
{
|
||||
time = cl_explosions[i].start;
|
||||
index = i;
|
||||
}
|
||||
memset (&cl_explosions[index], 0, sizeof (cl_explosions[index]));
|
||||
return &cl_explosions[index];
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_SmokeAndFlash
|
||||
=================
|
||||
*/
|
||||
void CL_SmokeAndFlash(vec3_t origin)
|
||||
{
|
||||
explosion_t *ex;
|
||||
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (origin, ex->ent.origin);
|
||||
ex->type = ex_misc;
|
||||
ex->frames = 4;
|
||||
ex->ent.flags = RF_TRANSLUCENT;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->ent.model = cl_mod_smoke;
|
||||
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (origin, ex->ent.origin);
|
||||
ex->type = ex_flash;
|
||||
ex->ent.flags = RF_TRANSLUCENT;
|
||||
ex->frames = 2;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->ent.model = cl_mod_flash;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseParticles
|
||||
=================
|
||||
*/
|
||||
void CL_ParseParticles( sizebuf_t *msg )
|
||||
{
|
||||
int color, count;
|
||||
vec3_t pos, dir;
|
||||
|
||||
MSG_ReadPos32(msg, pos);
|
||||
MSG_ReadPos32(msg, dir);
|
||||
|
||||
color = MSG_ReadByte(msg);
|
||||
count = MSG_ReadByte(msg);
|
||||
|
||||
CL_ParticleEffect(pos, dir, color, count);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseBeam
|
||||
=================
|
||||
*/
|
||||
int CL_ParseBeam( sizebuf_t *msg, model_t *model )
|
||||
{
|
||||
int ent;
|
||||
vec3_t start, end;
|
||||
beam_t *b;
|
||||
int i;
|
||||
|
||||
ent = MSG_ReadShort (msg);
|
||||
|
||||
MSG_ReadPos32(msg, start);
|
||||
MSG_ReadPos32(msg, end);
|
||||
|
||||
// override any beam with the same entity
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
if (b->entity == ent)
|
||||
{
|
||||
b->entity = ent;
|
||||
b->model = model;
|
||||
b->endtime = cl.time + 200;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorClear (b->offset);
|
||||
return ent;
|
||||
}
|
||||
|
||||
// find a free beam
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
{
|
||||
if (!b->model || b->endtime < cl.time)
|
||||
{
|
||||
b->entity = ent;
|
||||
b->model = model;
|
||||
b->endtime = cl.time + 200;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorClear (b->offset);
|
||||
return ent;
|
||||
}
|
||||
}
|
||||
Msg ("beam list overflow!\n");
|
||||
return ent;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseBeam2
|
||||
=================
|
||||
*/
|
||||
int CL_ParseBeam2( sizebuf_t *msg, model_t *model )
|
||||
{
|
||||
int ent;
|
||||
vec3_t start, end, offset;
|
||||
beam_t *b;
|
||||
int i;
|
||||
|
||||
ent = MSG_ReadShort (msg);
|
||||
|
||||
MSG_ReadPos32(msg, start);
|
||||
MSG_ReadPos32(msg, end);
|
||||
MSG_ReadPos32(msg, offset);
|
||||
|
||||
// Msg ("end- %f %f %f\n", end[0], end[1], end[2]);
|
||||
|
||||
// override any beam with the same entity
|
||||
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
if (b->entity == ent)
|
||||
{
|
||||
b->entity = ent;
|
||||
b->model = model;
|
||||
b->endtime = cl.time + 200;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorCopy (offset, b->offset);
|
||||
return ent;
|
||||
}
|
||||
|
||||
// find a free beam
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
{
|
||||
if (!b->model || b->endtime < cl.time)
|
||||
{
|
||||
b->entity = ent;
|
||||
b->model = model;
|
||||
b->endtime = cl.time + 200;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorCopy (offset, b->offset);
|
||||
return ent;
|
||||
}
|
||||
}
|
||||
Msg ("beam list overflow!\n");
|
||||
return ent;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseLightning
|
||||
=================
|
||||
*/
|
||||
int CL_ParseLightning( sizebuf_t *msg, model_t *model )
|
||||
{
|
||||
int srcEnt, destEnt;
|
||||
vec3_t start, end;
|
||||
beam_t *b;
|
||||
int i;
|
||||
|
||||
srcEnt = MSG_ReadShort (msg);
|
||||
destEnt = MSG_ReadShort (msg);
|
||||
|
||||
MSG_ReadPos32(msg, start);
|
||||
MSG_ReadPos32(msg, end);
|
||||
|
||||
// override any beam with the same source AND destination entities
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
if (b->entity == srcEnt && b->dest_entity == destEnt)
|
||||
{
|
||||
// Msg("%d: OVERRIDE %d -> %d\n", cl.time, srcEnt, destEnt);
|
||||
b->entity = srcEnt;
|
||||
b->dest_entity = destEnt;
|
||||
b->model = model;
|
||||
b->endtime = cl.time + 200;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorClear (b->offset);
|
||||
return srcEnt;
|
||||
}
|
||||
|
||||
// find a free beam
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
{
|
||||
if (!b->model || b->endtime < cl.time)
|
||||
{
|
||||
// Msg("%d: NORMAL %d -> %d\n", cl.time, srcEnt, destEnt);
|
||||
b->entity = srcEnt;
|
||||
b->dest_entity = destEnt;
|
||||
b->model = model;
|
||||
b->endtime = cl.time + 200;
|
||||
VectorCopy (start, b->start);
|
||||
VectorCopy (end, b->end);
|
||||
VectorClear (b->offset);
|
||||
return srcEnt;
|
||||
}
|
||||
}
|
||||
Msg ("beam list overflow!\n");
|
||||
return srcEnt;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseLaser
|
||||
=================
|
||||
*/
|
||||
void CL_ParseLaser( sizebuf_t *msg, int colors )
|
||||
{
|
||||
vec3_t start;
|
||||
vec3_t end;
|
||||
laser_t *l;
|
||||
int i;
|
||||
|
||||
MSG_ReadPos32(msg, start);
|
||||
MSG_ReadPos32(msg, end);
|
||||
|
||||
for (i=0, l=cl_lasers ; i< MAX_LASERS ; i++, l++)
|
||||
{
|
||||
if (l->endtime < cl.time)
|
||||
{
|
||||
l->ent.flags = RF_TRANSLUCENT | RF_BEAM;
|
||||
VectorCopy (start, l->ent.origin);
|
||||
VectorCopy (end, l->ent.oldorigin);
|
||||
l->ent.alpha = 0.30;
|
||||
l->ent.skinnum = (colors >> ((rand() % 4)*8)) & 0xff;
|
||||
l->ent.model = NULL;
|
||||
l->ent.frame = 4;
|
||||
l->endtime = cl.time + 100;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ParseTEnt
|
||||
=================
|
||||
*/
|
||||
static byte splash_color[] = {0x00, 0xe0, 0xb0, 0x50, 0xd0, 0xe0, 0xe8};
|
||||
|
||||
void CL_ParseTEnt( sizebuf_t *msg )
|
||||
void CL_ParseTempEnts( sizebuf_t *msg )
|
||||
{
|
||||
int type;
|
||||
vec3_t pos, pos2, dir;
|
||||
explosion_t *ex;
|
||||
int cnt;
|
||||
int color;
|
||||
int r;
|
||||
int ent;
|
||||
vec3_t pos, dir;
|
||||
|
||||
type = MSG_ReadByte (msg);
|
||||
type = MSG_ReadByte( msg );
|
||||
|
||||
switch (type)
|
||||
switch( type )
|
||||
{
|
||||
case TE_TELEPORT:
|
||||
MSG_ReadPos32( msg, pos );
|
||||
|
@ -499,511 +54,13 @@ void CL_ParseTEnt( sizebuf_t *msg )
|
|||
CL_ParticleEffect (pos, dir, 0xe8, 60);
|
||||
break;
|
||||
|
||||
case TE_GUNSHOT: // bullet hitting wall
|
||||
case TE_SPARKS:
|
||||
case TE_BULLET_SPARKS:
|
||||
case TE_GUNSHOT: // bullet hitting wall
|
||||
MSG_ReadPos32(msg, pos);
|
||||
MSG_ReadPos32(msg, dir);
|
||||
if (type == TE_GUNSHOT)
|
||||
CL_ParticleEffect (pos, dir, 0, 40);
|
||||
else
|
||||
CL_ParticleEffect (pos, dir, 0xe0, 6);
|
||||
|
||||
if (type != TE_SPARKS)
|
||||
{
|
||||
CL_SmokeAndFlash(pos);
|
||||
|
||||
// impact sound
|
||||
cnt = rand()&15;
|
||||
if (cnt == 1)
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_ric1);
|
||||
}
|
||||
else if (cnt == 2)
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_ric2);
|
||||
}
|
||||
else if (cnt == 3)
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_ric3);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case TE_SCREEN_SPARKS:
|
||||
case TE_SHIELD_SPARKS:
|
||||
MSG_ReadPos32(msg, pos);
|
||||
MSG_ReadPos32(msg, dir);
|
||||
if (type == TE_SCREEN_SPARKS)
|
||||
CL_ParticleEffect (pos, dir, 0xd0, 40);
|
||||
else
|
||||
CL_ParticleEffect (pos, dir, 0xb0, 40);
|
||||
//FIXME : replace or remove this sound
|
||||
S_StartSound (pos, 0, 0, cl_sfx_lashit);
|
||||
break;
|
||||
|
||||
case TE_SHOTGUN: // bullet hitting wall
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
CL_ParticleEffect (pos, dir, 0, 20);
|
||||
CL_SmokeAndFlash(pos);
|
||||
break;
|
||||
|
||||
case TE_SPLASH: // bullet hitting water
|
||||
cnt = MSG_ReadByte (msg);
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
r = MSG_ReadByte (msg);
|
||||
if (r > 6)
|
||||
color = 0x00;
|
||||
else
|
||||
color = splash_color[r];
|
||||
CL_ParticleEffect (pos, dir, color, cnt);
|
||||
break;
|
||||
|
||||
case TE_LASER_SPARKS:
|
||||
cnt = MSG_ReadByte (msg);
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
color = MSG_ReadByte (msg);
|
||||
CL_ParticleEffect2 (pos, dir, color, cnt);
|
||||
break;
|
||||
|
||||
// RAFAEL
|
||||
case TE_BLUEHYPERBLASTER:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
CL_BlasterParticles (pos, dir);
|
||||
break;
|
||||
|
||||
case TE_BLASTER: // blaster hitting wall
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
CL_BlasterParticles (pos, dir);
|
||||
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
ex->ent.angles[0] = acos(dir[2])/M_PI*180;
|
||||
// PMM - fixed to correct for pitch of 0
|
||||
if (dir[0])
|
||||
ex->ent.angles[1] = atan2(dir[1], dir[0])/M_PI*180;
|
||||
else if (dir[1] > 0)
|
||||
ex->ent.angles[1] = 90;
|
||||
else if (dir[1] < 0)
|
||||
ex->ent.angles[1] = 270;
|
||||
else
|
||||
ex->ent.angles[1] = 0;
|
||||
|
||||
ex->type = ex_misc;
|
||||
ex->ent.flags = RF_FULLBRIGHT|RF_TRANSLUCENT;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->light = 150;
|
||||
ex->lightcolor[0] = 1;
|
||||
ex->lightcolor[1] = 1;
|
||||
ex->ent.model = cl_mod_explode;
|
||||
ex->frames = 4;
|
||||
S_StartSound (pos, 0, 0, cl_sfx_lashit);
|
||||
break;
|
||||
|
||||
case TE_RAILTRAIL: // railgun effect
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, pos2);
|
||||
CL_RailTrail (pos, pos2);
|
||||
S_StartSound (pos2, 0, 0, cl_sfx_railg);
|
||||
break;
|
||||
|
||||
case TE_EXPLOSION2:
|
||||
case TE_GRENADE_EXPLOSION:
|
||||
case TE_GRENADE_EXPLOSION_WATER:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
ex->type = ex_poly;
|
||||
ex->ent.flags = RF_FULLBRIGHT;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->light = 350;
|
||||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 0.5;
|
||||
ex->lightcolor[2] = 0.5;
|
||||
ex->ent.model = cl_mod_explo2;
|
||||
ex->frames = 11;
|
||||
ex->baseframe = 0;
|
||||
ex->ent.angles[1] = rand() % 360;
|
||||
CL_ExplosionParticles (pos);
|
||||
if (type == TE_GRENADE_EXPLOSION_WATER)
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_watrexp);
|
||||
}
|
||||
else
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_grenexp);
|
||||
}
|
||||
break;
|
||||
|
||||
// RAFAEL
|
||||
case TE_PLASMA_EXPLOSION:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
ex->type = ex_poly;
|
||||
ex->ent.flags = RF_FULLBRIGHT;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->light = 350;
|
||||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 0.5;
|
||||
ex->lightcolor[2] = 0.5;
|
||||
ex->ent.angles[1] = rand() % 360;
|
||||
ex->ent.model = cl_mod_explo4;
|
||||
ex->baseframe = 0;
|
||||
ex->frames = 6;
|
||||
CL_ExplosionParticles (pos);
|
||||
S_StartSound (pos, 0, 0, cl_sfx_rockexp);
|
||||
break;
|
||||
|
||||
case TE_EXPLOSION1:
|
||||
case TE_ROCKET_EXPLOSION:
|
||||
case TE_ROCKET_EXPLOSION_WATER:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
ex->type = ex_poly;
|
||||
ex->ent.flags = RF_FULLBRIGHT;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->light = 350;
|
||||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 0.5;
|
||||
ex->lightcolor[2] = 0.5;
|
||||
ex->ent.angles[1] = rand() % 360;
|
||||
ex->ent.model = cl_mod_explo4; // PMM
|
||||
ex->baseframe = 0;
|
||||
ex->frames = 8;
|
||||
CL_ExplosionParticles (pos); // PMM
|
||||
if (type == TE_ROCKET_EXPLOSION_WATER)
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_watrexp);
|
||||
}
|
||||
else
|
||||
{
|
||||
S_StartSound (pos, 0, 0, cl_sfx_rockexp);
|
||||
}
|
||||
break;
|
||||
|
||||
case TE_BFG_EXPLOSION:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
ex->type = ex_poly;
|
||||
ex->ent.flags = RF_FULLBRIGHT;
|
||||
ex->start = cl.frame.servertime - 100;
|
||||
ex->light = 350;
|
||||
ex->lightcolor[0] = 0.0;
|
||||
ex->lightcolor[1] = 1.0;
|
||||
ex->lightcolor[2] = 0.0;
|
||||
ex->ent.model = cl_mod_bfg_explo;
|
||||
ex->ent.flags |= RF_TRANSLUCENT;
|
||||
ex->ent.alpha = 0.30;
|
||||
ex->frames = 4;
|
||||
break;
|
||||
|
||||
case TE_BFG_BIGEXPLOSION:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
CL_BFGExplosionParticles (pos);
|
||||
break;
|
||||
|
||||
case TE_BFG_LASER:
|
||||
CL_ParseLaser( msg, 0xd0d1d2d3 );
|
||||
break;
|
||||
|
||||
case TE_BUBBLETRAIL:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, pos2);
|
||||
CL_BubbleTrail (pos, pos2);
|
||||
break;
|
||||
|
||||
case TE_PARASITE_ATTACK:
|
||||
case TE_MEDIC_CABLE_ATTACK:
|
||||
ent = CL_ParseBeam( msg, cl_mod_laser );
|
||||
break;
|
||||
|
||||
case TE_BOSSTPORT: // boss teleporting to station
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
CL_BigTeleportParticles (pos);
|
||||
S_StartSound (pos, 0, 0, S_RegisterSound ("misc/bigtele.wav"));
|
||||
break;
|
||||
|
||||
case TE_GRAPPLE_CABLE:
|
||||
break;
|
||||
|
||||
// RAFAEL
|
||||
case TE_WELDING_SPARKS:
|
||||
cnt = MSG_ReadByte (msg);
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
color = MSG_ReadByte (msg);
|
||||
CL_ParticleEffect2 (pos, dir, color, cnt);
|
||||
|
||||
ex = CL_AllocExplosion ();
|
||||
VectorCopy (pos, ex->ent.origin);
|
||||
ex->type = ex_flash;
|
||||
// note to self
|
||||
// we need a better no draw flag
|
||||
ex->ent.flags = RF_BEAM;
|
||||
ex->start = cl.frame.servertime - 0.1;
|
||||
ex->light = 100 + (rand()%75);
|
||||
ex->lightcolor[0] = 1.0;
|
||||
ex->lightcolor[1] = 1.0;
|
||||
ex->lightcolor[2] = 0.3;
|
||||
ex->ent.model = cl_mod_flash;
|
||||
ex->frames = 2;
|
||||
break;
|
||||
|
||||
case TE_GREENBLOOD:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
CL_ParticleEffect2 (pos, dir, 0xdf, 30);
|
||||
break;
|
||||
|
||||
case TE_FLASHLIGHT:
|
||||
MSG_ReadPos32(msg, pos);
|
||||
ent = MSG_ReadShort(msg);
|
||||
CL_Flashlight(ent, pos);
|
||||
break;
|
||||
|
||||
case TE_DEBUGTRAIL:
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, pos2);
|
||||
CL_DebugTrail (pos, pos2);
|
||||
break;
|
||||
|
||||
// RAFAEL
|
||||
case TE_TUNNEL_SPARKS:
|
||||
cnt = MSG_ReadByte (msg);
|
||||
MSG_ReadPos32 (msg, pos);
|
||||
MSG_ReadPos32 (msg, dir);
|
||||
color = MSG_ReadByte (msg);
|
||||
CL_ParticleEffect3 (pos, dir, color, cnt);
|
||||
CL_ParticleEffect( pos, dir, 0, 40 );
|
||||
break;
|
||||
default:
|
||||
Host_Error("CL_ParseTEnt: bad type\n");
|
||||
Host_Error( "CL_ParseTEnt: bad type\n" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_AddBeams
|
||||
=================
|
||||
*/
|
||||
void CL_AddBeams (void)
|
||||
{
|
||||
int i,j;
|
||||
beam_t *b;
|
||||
vec3_t dist, org;
|
||||
float d;
|
||||
entity_t ent;
|
||||
float yaw, pitch;
|
||||
float forward;
|
||||
float len, steps;
|
||||
float model_length;
|
||||
|
||||
// update beams
|
||||
for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++)
|
||||
{
|
||||
if (!b->model || b->endtime < cl.time)
|
||||
continue;
|
||||
|
||||
// if coming from the player, update the start position
|
||||
if (b->entity == cl.playernum+1) // entity 0 is the world
|
||||
{
|
||||
VectorCopy (cl.refdef.vieworg, b->start);
|
||||
b->start[2] -= 22; // adjust for view height
|
||||
}
|
||||
VectorAdd (b->start, b->offset, org);
|
||||
|
||||
// calculate pitch and yaw
|
||||
VectorSubtract (b->end, org, dist);
|
||||
|
||||
if (dist[1] == 0 && dist[0] == 0)
|
||||
{
|
||||
yaw = 0;
|
||||
if (dist[2] > 0)
|
||||
pitch = 90;
|
||||
else
|
||||
pitch = 270;
|
||||
}
|
||||
else
|
||||
{
|
||||
// PMM - fixed to correct for pitch of 0
|
||||
if (dist[0])
|
||||
yaw = (atan2(dist[1], dist[0]) * 180 / M_PI);
|
||||
else if (dist[1] > 0)
|
||||
yaw = 90;
|
||||
else
|
||||
yaw = 270;
|
||||
if (yaw < 0)
|
||||
yaw += 360;
|
||||
|
||||
forward = sqrt (dist[0]*dist[0] + dist[1]*dist[1]);
|
||||
pitch = (atan2(dist[2], forward) * -180.0 / M_PI);
|
||||
if (pitch < 0)
|
||||
pitch += 360.0;
|
||||
}
|
||||
|
||||
// add new entities for the beams
|
||||
d = VectorNormalize(dist);
|
||||
|
||||
memset (&ent, 0, sizeof(ent));
|
||||
model_length = 30.0;
|
||||
steps = ceil(d/model_length);
|
||||
len = (d-model_length)/(steps-1);
|
||||
|
||||
while (d > 0)
|
||||
{
|
||||
VectorCopy (org, ent.origin);
|
||||
ent.model = b->model;
|
||||
ent.angles[0] = pitch;
|
||||
ent.angles[1] = yaw;
|
||||
ent.angles[2] = rand()%360;
|
||||
|
||||
V_AddEntity (&ent);
|
||||
|
||||
for (j=0 ; j<3 ; j++)
|
||||
org[j] += dist[j]*len;
|
||||
d -= model_length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_AddExplosions
|
||||
=================
|
||||
*/
|
||||
void CL_AddExplosions (void)
|
||||
{
|
||||
entity_t *ent;
|
||||
int i;
|
||||
explosion_t *ex;
|
||||
float frac;
|
||||
int f;
|
||||
|
||||
memset (&ent, 0, sizeof(ent));
|
||||
|
||||
for (i=0, ex=cl_explosions ; i< MAX_EXPLOSIONS ; i++, ex++)
|
||||
{
|
||||
if (ex->type == ex_free)
|
||||
continue;
|
||||
frac = (cl.time - ex->start)/100.0;
|
||||
f = floor(frac);
|
||||
|
||||
ent = &ex->ent;
|
||||
|
||||
switch (ex->type)
|
||||
{
|
||||
case ex_mflash:
|
||||
if (f >= ex->frames-1)
|
||||
ex->type = ex_free;
|
||||
break;
|
||||
case ex_misc:
|
||||
if (f >= ex->frames-1)
|
||||
{
|
||||
ex->type = ex_free;
|
||||
break;
|
||||
}
|
||||
ent->alpha = 1.0 - frac/(ex->frames-1);
|
||||
break;
|
||||
case ex_flash:
|
||||
if (f >= 1)
|
||||
{
|
||||
ex->type = ex_free;
|
||||
break;
|
||||
}
|
||||
ent->alpha = 1.0;
|
||||
break;
|
||||
case ex_poly:
|
||||
if (f >= ex->frames-1)
|
||||
{
|
||||
ex->type = ex_free;
|
||||
break;
|
||||
}
|
||||
|
||||
ent->alpha = (16.0 - (float)f)/16.0;
|
||||
|
||||
if (f < 10)
|
||||
{
|
||||
ent->skinnum = (f>>1);
|
||||
if (ent->skinnum < 0)
|
||||
ent->skinnum = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ent->flags |= RF_TRANSLUCENT;
|
||||
if (f < 13)
|
||||
ent->skinnum = 5;
|
||||
else
|
||||
ent->skinnum = 6;
|
||||
}
|
||||
break;
|
||||
case ex_poly2:
|
||||
if (f >= ex->frames-1)
|
||||
{
|
||||
ex->type = ex_free;
|
||||
break;
|
||||
}
|
||||
|
||||
ent->alpha = (5.0 - (float)f)/5.0;
|
||||
ent->skinnum = 0;
|
||||
ent->flags |= RF_TRANSLUCENT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ex->type == ex_free)
|
||||
continue;
|
||||
if (ex->light)
|
||||
{
|
||||
V_AddLight (ent->origin, ex->light*ent->alpha,
|
||||
ex->lightcolor[0], ex->lightcolor[1], ex->lightcolor[2]);
|
||||
}
|
||||
|
||||
VectorCopy (ent->origin, ent->oldorigin);
|
||||
|
||||
if (f < 0) f = 0;
|
||||
ent->frame = ex->baseframe + f + 1;
|
||||
ent->prev.frame = ex->baseframe + f;
|
||||
ent->backlerp = 1.0 - cl.lerpfrac;
|
||||
|
||||
V_AddEntity (ent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_AddLasers
|
||||
=================
|
||||
*/
|
||||
void CL_AddLasers (void)
|
||||
{
|
||||
laser_t *l;
|
||||
int i;
|
||||
|
||||
for (i=0, l=cl_lasers ; i< MAX_LASERS ; i++, l++)
|
||||
{
|
||||
if (l->endtime >= cl.time)
|
||||
V_AddEntity (&l->ent);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_AddTEnts
|
||||
=================
|
||||
*/
|
||||
void CL_AddTEnts (void)
|
||||
{
|
||||
CL_AddBeams ();
|
||||
CL_AddExplosions ();
|
||||
CL_AddLasers ();
|
||||
}
|
||||
}
|
|
@ -26,8 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
//
|
||||
// development tools for weapons
|
||||
//
|
||||
int gun_frame;
|
||||
model_t *gun_model;
|
||||
model_t *gun_model;
|
||||
|
||||
//=============
|
||||
|
||||
|
@ -56,14 +55,7 @@ int num_cl_weaponmodels;
|
|||
int entitycmpfnc( const entity_t *a, const entity_t *b )
|
||||
{
|
||||
// all other models are sorted by model then skin
|
||||
if ( a->model == b->model )
|
||||
{
|
||||
return ((int)a->image - (int)b->image);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ((int)a->model - (int)b->model);
|
||||
}
|
||||
return ((int)a->model - (int)b->model);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -227,7 +219,6 @@ void V_TestEntities (void)
|
|||
cl.v_right[j]*r;
|
||||
|
||||
ent->model = cl.baseclientinfo.model;
|
||||
ent->image = cl.baseclientinfo.skin;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -300,10 +291,8 @@ void CL_PrepRefresh( void )
|
|||
// let the render dll load the map
|
||||
FS_FileBase( cl.configstrings[CS_MODELS+1], mapname );
|
||||
SCR_UpdateScreen();
|
||||
re->BeginRegistration( mapname ); // load map
|
||||
re->BeginRegistration( mapname ); // load map
|
||||
SCR_UpdateScreen();
|
||||
CG_ExecuteProgram( "Hud_Precache" ); // get alias names
|
||||
CL_RegisterTEntModels ();
|
||||
|
||||
num_cl_weaponmodels = 1;
|
||||
com.strcpy(cl_weaponmodels[0], "v_glock.mdl");
|
||||
|
@ -396,35 +385,6 @@ float V_CalcFov( float fov_x, float width, float height )
|
|||
|
||||
//============================================================================
|
||||
|
||||
// gun frame debugging functions
|
||||
void V_Gun_Next_f (void)
|
||||
{
|
||||
gun_frame++;
|
||||
Msg ("frame %i\n", gun_frame);
|
||||
}
|
||||
|
||||
void V_Gun_Prev_f (void)
|
||||
{
|
||||
gun_frame--;
|
||||
if (gun_frame < 0) gun_frame = 0;
|
||||
Msg ("frame %i\n", gun_frame);
|
||||
}
|
||||
|
||||
void V_Gun_Model_f (void)
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
gun_model = NULL;
|
||||
return;
|
||||
}
|
||||
com.sprintf (name, "models/weapons/v_%s.mdl", Cmd_Argv(1));
|
||||
gun_model = re->RegisterModel (name);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
V_RenderView
|
||||
|
@ -534,10 +494,8 @@ V_PostRender
|
|||
*/
|
||||
void V_PostRender( void )
|
||||
{
|
||||
SCR_DrawNet();
|
||||
SCR_DrawFPS();
|
||||
Con_DrawConsole();
|
||||
UI_Draw();
|
||||
Con_DrawConsole();
|
||||
re->EndFrame();
|
||||
}
|
||||
|
||||
|
@ -546,9 +504,9 @@ void V_PostRender( void )
|
|||
V_Viewpos_f
|
||||
=============
|
||||
*/
|
||||
void V_Viewpos_f (void)
|
||||
void V_Viewpos_f( void )
|
||||
{
|
||||
Msg ("(%i %i %i) : %i\n", (int)cl.refdef.vieworg[0],
|
||||
Msg("(%i %i %i) : %i\n", (int)cl.refdef.vieworg[0],
|
||||
(int)cl.refdef.vieworg[1], (int)cl.refdef.vieworg[2],
|
||||
(int)cl.refdef.viewangles[YAW]);
|
||||
}
|
||||
|
@ -560,18 +518,12 @@ V_Init
|
|||
*/
|
||||
void V_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("gun_next", V_Gun_Next_f, "decrease viewmodel current frame" );
|
||||
Cmd_AddCommand ("gun_prev", V_Gun_Prev_f, "increase viewmodel current frame" );
|
||||
Cmd_AddCommand ("gun_model", V_Gun_Model_f, "change gun (not a weapon, just viewmodel)" );
|
||||
|
||||
Cmd_AddCommand ("viewpos", V_Viewpos_f, "prints current player origin" );
|
||||
|
||||
crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE, "crosshair style" );
|
||||
|
||||
cl_testblend = Cvar_Get ("cl_testblend", "0", 0, "test blending" );
|
||||
cl_testparticles = Cvar_Get ("cl_testparticles", "0", 0, "test particle engine" );
|
||||
cl_testentities = Cvar_Get ("cl_testentities", "0", 0, "test client entities" );
|
||||
cl_testlights = Cvar_Get ("cl_testlights", "0", 0, "test dynamic lights" );
|
||||
|
||||
cl_stats = Cvar_Get ("cl_stats", "0", 0, "enable client stats" );
|
||||
}
|
||||
|
|
|
@ -53,42 +53,6 @@ typedef struct field_s
|
|||
int maxchars; // menu stuff
|
||||
} field_t;
|
||||
|
||||
typedef struct cg_stats_s
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
uint value;
|
||||
|
||||
} cg_stats_t;
|
||||
|
||||
typedef struct cg_cvars_s
|
||||
{
|
||||
char name[MAX_QPATH];
|
||||
char cvar[MAX_QPATH];
|
||||
|
||||
} cg_cvars_t;
|
||||
|
||||
typedef struct cg_def_s
|
||||
{
|
||||
int val[2];
|
||||
int op;
|
||||
|
||||
} cg_def_t;
|
||||
|
||||
// cg expression types
|
||||
enum
|
||||
{
|
||||
OP_UNKNOWN = 0,
|
||||
OP_LOGIC_OR,
|
||||
OP_LOGIC_AND,
|
||||
OP_EQUAL,
|
||||
OP_NOTEQUAL,
|
||||
OP_MORE,
|
||||
OP_MORE_OR_EQUAL,
|
||||
OP_SMALLER,
|
||||
OP_SMALLER_OR_EQUAL,
|
||||
OP_WITH,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
entity_state_t baseline; // delta from this if not from a previous frame
|
||||
|
@ -96,11 +60,6 @@ typedef struct
|
|||
entity_state_t prev; // will always be valid, but might just be a copy of current
|
||||
|
||||
int serverframe; // if not current, this ent isn't in the frame
|
||||
|
||||
int trailcount; // for diminishing grenade trails
|
||||
vec3_t lerp_origin; // for trails (variable hz)
|
||||
|
||||
int fly_stoptime;
|
||||
} centity_t;
|
||||
|
||||
#define MAX_CLIENTWEAPONMODELS 20 // PGM -- upped from 16 to fit the chainfist vwep
|
||||
|
@ -173,12 +132,6 @@ typedef struct
|
|||
|
||||
bool make_levelshot;
|
||||
|
||||
//
|
||||
// transient data from server
|
||||
//
|
||||
char layout[1024]; // general 2D overlay
|
||||
int inventory[MAX_ITEMS];
|
||||
|
||||
//
|
||||
// server state information
|
||||
//
|
||||
|
@ -261,15 +214,15 @@ typedef struct
|
|||
string servername; // name of server from original connect
|
||||
float connect_time; // for connection retransmits
|
||||
|
||||
int quakePort; // a 16 bit value that allows quake servers
|
||||
// to work around address translating routers
|
||||
int quakePort; // a 16 bit value that allows quake servers
|
||||
// to work around address translating routers
|
||||
netchan_t netchan;
|
||||
sizebuf_t *multicast; // ptr for current message buffer (net or demo flow)
|
||||
int serverProtocol; // in case we are doing some kind of version hack
|
||||
|
||||
int challenge; // from the server to use for connecting
|
||||
int challenge; // from the server to use for connecting
|
||||
|
||||
file_t *download; // file transfer from server
|
||||
file_t *download; // file transfer from server
|
||||
char downloadtempname[MAX_OSPATH];
|
||||
char downloadname[MAX_OSPATH];
|
||||
int downloadnumber;
|
||||
|
@ -286,26 +239,6 @@ typedef struct
|
|||
serverinfo_t serverlist[MAX_SERVERS]; // servers to join
|
||||
int numservers;
|
||||
float pingtime; // servers timebase
|
||||
|
||||
// hudprogram stack
|
||||
byte *hud_program;
|
||||
uint hud_program_size;
|
||||
|
||||
bool cg_init;
|
||||
char cg_function[MAX_QPATH];
|
||||
char cg_builtin[MAX_QPATH];
|
||||
char cg_tempstring[MAX_QPATH];
|
||||
int cg_depth;
|
||||
int cg_depth2; // used for bounds chekiing
|
||||
char cg_argv[MAX_PARMS][MAX_QPATH];
|
||||
uint cg_argc;
|
||||
cg_stats_t cg_stats[MAX_STATS];
|
||||
uint cg_numstats;
|
||||
cg_cvars_t cg_cvars[128];
|
||||
uint cg_numcvars;
|
||||
vec4_t cg_color;
|
||||
vec2_t cg_scale;
|
||||
|
||||
} client_static_t;
|
||||
|
||||
extern client_static_t cls;
|
||||
|
@ -432,67 +365,40 @@ typedef struct cparticle_s
|
|||
float alphavel;
|
||||
} cparticle_t;
|
||||
|
||||
// cinematic states
|
||||
typedef enum
|
||||
{
|
||||
FMV_IDLE,
|
||||
FMV_PLAY, // play
|
||||
FMV_EOF, // all other conditions, i.e. stop/EOF/abort
|
||||
FMV_ID_BLT,
|
||||
FMV_ID_IDLE,
|
||||
FMV_LOOPED,
|
||||
FMV_ID_WAIT
|
||||
} e_status;
|
||||
|
||||
// cinematic flags
|
||||
#define CIN_loop 1
|
||||
#define CIN_hold 2
|
||||
#define CIN_silent 4
|
||||
|
||||
#define PARTICLE_GRAVITY 40
|
||||
#define BLASTER_PARTICLE_COLOR 0xe0
|
||||
// PMM
|
||||
#define INSTANT_PARTICLE -10000.0
|
||||
// PGM
|
||||
// ========
|
||||
|
||||
void CL_ClearEffects (void);
|
||||
void CL_ClearTEnts (void);
|
||||
void CL_BlasterTrail (vec3_t start, vec3_t end);
|
||||
void CL_QuadTrail (vec3_t start, vec3_t end);
|
||||
void CL_RailTrail (vec3_t start, vec3_t end);
|
||||
void CL_BubbleTrail (vec3_t start, vec3_t end);
|
||||
void CL_FlagTrail (vec3_t start, vec3_t end, float color);
|
||||
|
||||
// RAFAEL
|
||||
void CL_IonripperTrail (vec3_t start, vec3_t end);
|
||||
|
||||
// ========
|
||||
// PGM
|
||||
void CL_TeleportSplash( vec3_t org );
|
||||
void CL_BlasterParticles2 (vec3_t org, vec3_t dir, unsigned int color);
|
||||
void CL_BlasterTrail2 (vec3_t start, vec3_t end);
|
||||
void CL_DebugTrail (vec3_t start, vec3_t end);
|
||||
void CL_SmokeTrail (vec3_t start, vec3_t end, int colorStart, int colorRun, int spacing);
|
||||
void CL_Flashlight (int ent, vec3_t pos);
|
||||
void CL_ForceWall (vec3_t start, vec3_t end, int color);
|
||||
void CL_FlameEffects (centity_t *ent, vec3_t origin);
|
||||
void CL_GenericParticleEffect (vec3_t org, vec3_t dir, int color, int count, int numcolors, int dirspread, float alphavel);
|
||||
void CL_BubbleTrail2 (vec3_t start, vec3_t end, int dist);
|
||||
void CL_Heatbeam (vec3_t start, vec3_t end);
|
||||
void CL_ParticleSteamEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude);
|
||||
void CL_TrackerTrail (vec3_t start, vec3_t end, int particleColor);
|
||||
void CL_Tracker_Explode(vec3_t origin);
|
||||
void CL_TagTrail (vec3_t start, vec3_t end, float color);
|
||||
void CL_ColorFlash (vec3_t pos, int ent, int intensity, float r, float g, float b);
|
||||
void CL_Tracker_Shell(vec3_t origin);
|
||||
void CL_MonsterPlasma_Shell(vec3_t origin);
|
||||
void CL_ColorExplosionParticles (vec3_t org, int color, int run);
|
||||
void CL_ParticleSmokeEffect (vec3_t org, vec3_t dir, int color, int count, int magnitude);
|
||||
void CL_WidowSplash (vec3_t org);
|
||||
// PGM
|
||||
// ========
|
||||
|
||||
int CL_ParseEntityBits( sizebuf_t *msg, uint *bits );
|
||||
void CL_ParseFrame( sizebuf_t *msg );
|
||||
|
||||
void CL_ParseTEnt( sizebuf_t *msg );
|
||||
void CL_ParseTempEnts( sizebuf_t *msg );
|
||||
void CL_ParseConfigString( sizebuf_t *msg );
|
||||
void SmokeAndFlash(vec3_t origin);
|
||||
|
||||
void CL_SetLightstyle (int i);
|
||||
|
||||
void CL_RunParticles (void);
|
||||
void CL_RunDLights (void);
|
||||
void CL_RunLightStyles (void);
|
||||
|
||||
void CL_AddEntities (void);
|
||||
void CL_AddDLights (void);
|
||||
void CL_AddTEnts (void);
|
||||
void CL_AddLightStyles (void);
|
||||
|
||||
//=================================================
|
||||
|
@ -571,7 +477,8 @@ void CL_Stop_f( void );
|
|||
void CL_InitClientProgs( void );
|
||||
void CL_FreeClientProgs( void );
|
||||
void CL_DrawHUD( void );
|
||||
|
||||
float *CL_FadeColor( float starttime, float endtime );
|
||||
bool CL_ParseUserMessage( int svc_number );
|
||||
|
||||
//
|
||||
// cl_sound.c
|
||||
|
@ -622,8 +529,7 @@ void CL_Download_f (void);
|
|||
//
|
||||
// cl_view.c
|
||||
//
|
||||
extern int gun_frame;
|
||||
extern model_t *gun_model;
|
||||
extern model_t *gun_model;
|
||||
|
||||
void V_Init (void);
|
||||
void V_CalcRect( void );
|
||||
|
@ -639,14 +545,6 @@ void V_AddLight (vec3_t org, float intensity, float r, float g, float b);
|
|||
void V_AddLightStyle (int style, float r, float g, float b);
|
||||
float V_CalcFov( float fov_x, float width, float height );
|
||||
|
||||
//
|
||||
// cl_tent.c
|
||||
//
|
||||
void CL_RegisterTEntSounds (void);
|
||||
void CL_RegisterTEntModels (void);
|
||||
void CL_SmokeAndFlash(vec3_t origin);
|
||||
|
||||
|
||||
//
|
||||
// cl_pred.c
|
||||
//
|
||||
|
@ -664,14 +562,9 @@ void CL_AddLoopingSounds( void );
|
|||
// cl_fx.c
|
||||
//
|
||||
cdlight_t *CL_AllocDlight (int key);
|
||||
void CL_BigTeleportParticles (vec3_t org);
|
||||
void CL_RocketTrail (vec3_t start, vec3_t end, centity_t *old);
|
||||
void CL_DiminishingTrail (vec3_t start, vec3_t end, centity_t *old );
|
||||
void CL_AddParticles (void);
|
||||
void CL_EntityEvent (entity_state_t *ent);
|
||||
// RAFAEL
|
||||
void CL_TrapParticles (entity_t *ent);
|
||||
void CL_StudioEvent ( mstudioevent_t *event, entity_t *ent );
|
||||
void CL_ClearEffects( void );
|
||||
void CL_StudioEvent( mstudioevent_t *event, entity_t *ent );
|
||||
|
||||
//
|
||||
// cl_pred.c
|
||||
|
|
|
@ -760,6 +760,60 @@ void VM_TimeStamp( void )
|
|||
PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(timestamp((int)PRVM_G_FLOAT(OFS_PARM0)));
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_SubString
|
||||
|
||||
string substring( string s, float start, float length )
|
||||
=========
|
||||
*/
|
||||
void VM_SubString( void )
|
||||
{
|
||||
int i, start, length;
|
||||
string tempstring;
|
||||
const char *s;
|
||||
|
||||
if(!VM_ValidateArgs( "substring", 3 ))
|
||||
return;
|
||||
|
||||
s = PRVM_G_STRING(OFS_PARM0);
|
||||
start = (int)PRVM_G_FLOAT(OFS_PARM1);
|
||||
length = (int)PRVM_G_FLOAT(OFS_PARM2);
|
||||
if(!s) s = ""; // evil stuff...
|
||||
|
||||
for (i = 0; i < start && *s; i++, s++ );
|
||||
for (i = 0; i < MAX_STRING - 1 && *s && i < length; i++, s++)
|
||||
tempstring[i] = *s;
|
||||
tempstring[i] = 0;
|
||||
|
||||
PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString( tempstring );
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_localsound
|
||||
|
||||
void localsound( string sample )
|
||||
=========
|
||||
*/
|
||||
void VM_localsound( void )
|
||||
{
|
||||
const char *s;
|
||||
|
||||
if(!VM_ValidateArgs( "localsound", 1 ))
|
||||
return;
|
||||
|
||||
s = PRVM_G_STRING( OFS_PARM0 );
|
||||
|
||||
if(!S_StartLocalSound(s))
|
||||
{
|
||||
VM_Warning("localsound: can't play %s!\n", s );
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 0;
|
||||
return;
|
||||
}
|
||||
PRVM_G_FLOAT(OFS_RETURN) = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
=========
|
||||
VM_SpawnEdict
|
||||
|
|
|
@ -128,6 +128,10 @@ extern cvar_t *dedicated;
|
|||
extern cvar_t *host_serverstate;
|
||||
extern cvar_t *host_frametime;
|
||||
extern cvar_t *cm_paused;
|
||||
extern cvar_t *crosshair;
|
||||
extern cvar_t *scr_loading;
|
||||
extern cvar_t *scr_width;
|
||||
extern cvar_t *scr_height;
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
@ -320,7 +324,9 @@ void VM_CvarGetString( void );
|
|||
void VM_ComVA( void );
|
||||
void VM_ComStrlen( void );
|
||||
void VM_TimeStamp( void );
|
||||
void VM_SubString( void );
|
||||
void VM_LocalCmd( void );
|
||||
void VM_localsound( void );
|
||||
void VM_SpawnEdict( void );
|
||||
void VM_RemoveEdict( void );
|
||||
void VM_NextEdict( void );
|
||||
|
@ -400,7 +406,8 @@ bool Cmd_CheckMapsList( void );
|
|||
void Sys_Error( const char *msg, ... );
|
||||
void Sys_SendKeyEvents( void );
|
||||
|
||||
|
||||
#define MAX_ENTNUMBER 99999 // for server and client parsing
|
||||
#define MAX_HEARTBEAT -99999.0f // connection time
|
||||
|
||||
|
||||
// get rid of this
|
||||
|
|
|
@ -114,10 +114,6 @@ SOURCE="$(InputPath)"
|
|||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\cg_user.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\cl_cin.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -158,10 +154,6 @@ SOURCE=.\client\cl_menu.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\cl_newfx.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\client\cl_parse.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -213,16 +213,14 @@ void _MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t
|
|||
|
||||
if ( to->frame != from->frame ) bits |= U_FRAME;
|
||||
if ( to->solid != from->solid ) bits |= U_SOLID;
|
||||
if ( to->event ) bits |= U_EVENT; // event is not delta compressed, just 0 compressed
|
||||
|
||||
if ( to->modelindex != from->modelindex ) bits |= U_MODEL;
|
||||
if ( to->weaponmodel != from->weaponmodel ) bits |= U_WEAPONMODEL;
|
||||
if ( to->body != from->body ) bits |= U_BODY;
|
||||
if ( to->sequence != from->sequence ) bits |= U_SEQUENCE;
|
||||
if ( to->soundindex != from->soundindex ) bits |= U_SOUNDIDX;
|
||||
if (newentity || (to->renderfx & RF_BEAM)) bits |= U_OLDORIGIN;
|
||||
if ( to->alpha != from->alpha ) bits |= U_ALPHA;
|
||||
if ( to->animtime != from->animtime ) bits |= U_ANIMTIME;
|
||||
if ( newentity ) bits |= U_OLDORIGIN;
|
||||
|
||||
// write the message
|
||||
if (!bits && !force) return; // nothing to send!
|
||||
|
@ -295,7 +293,6 @@ void _MSG_WriteDeltaEntity (entity_state_t *from, entity_state_t *to, sizebuf_t
|
|||
MSG_WriteLong( msg, to->solid );
|
||||
}
|
||||
if (bits & U_ALPHA) _MSG_WriteFloat (msg, to->alpha, filename, fileline);
|
||||
if (bits & U_EVENT) _MSG_WriteByte (msg, to->event, filename, fileline);
|
||||
if (bits & U_SOUNDIDX) _MSG_WriteByte (msg, to->soundindex, filename, fileline);
|
||||
if (bits & U_BODY) _MSG_WriteByte (msg, to->body, filename, fileline);
|
||||
if (bits & U_ANIMTIME) _MSG_WriteFloat (msg, to->animtime, filename, fileline);
|
||||
|
@ -534,9 +531,7 @@ void MSG_ReadDeltaEntity( sizebuf_t *msg_read, entity_state_t *from, entity_stat
|
|||
if (bits & U_SEQUENCE) to->sequence = MSG_ReadByte(msg_read);
|
||||
if (bits & U_SOLID) to->solid = MSG_ReadLong(msg_read);
|
||||
if (bits & U_ALPHA) to->alpha = MSG_ReadFloat(msg_read);
|
||||
if (bits & U_EVENT) to->event = MSG_ReadByte (msg_read);
|
||||
if (bits & U_SOUNDIDX) to->soundindex = MSG_ReadByte (msg_read);
|
||||
else to->event = 0;
|
||||
|
||||
if (bits & U_BODY) to->body = MSG_ReadByte (msg_read);
|
||||
if (bits & U_ANIMTIME) to->animtime = MSG_ReadFloat (msg_read);
|
||||
|
|
|
@ -8,30 +8,27 @@
|
|||
// server to client
|
||||
enum svc_ops_e
|
||||
{
|
||||
svc_bad,
|
||||
|
||||
// these ops are known to the game dll
|
||||
svc_temp_entity,
|
||||
svc_layout,
|
||||
svc_inventory,
|
||||
|
||||
// the rest are private to the client and server
|
||||
svc_nop,
|
||||
svc_disconnect,
|
||||
svc_reconnect,
|
||||
// user messages
|
||||
svc_bad = 0,
|
||||
svc_sound, // <see code>
|
||||
svc_ambientsound, // ambient looping sound
|
||||
svc_temp_entity, // client effects
|
||||
svc_print, // [byte] id [string] null terminated string
|
||||
svc_centerprint, // [string] to put in center of the screen
|
||||
|
||||
// engine messages
|
||||
svc_nop = 201, // end of user messages
|
||||
svc_disconnect, // kick client from server
|
||||
svc_reconnect, // reconnecting server request
|
||||
svc_stufftext, // [string] stuffed into client's console buffer, should be \n terminated
|
||||
svc_serverdata, // [long] protocol ...
|
||||
svc_configstring, // [short] [string]
|
||||
svc_spawnbaseline,
|
||||
svc_centerprint, // [string] to put in center of the screen
|
||||
svc_spawnbaseline, // valid only at spawn
|
||||
svc_download, // [short] size [size bytes]
|
||||
svc_playerinfo, // variable
|
||||
svc_packetentities, // [...]
|
||||
svc_deltapacketentities, // [...]
|
||||
svc_frame,
|
||||
svc_frame, // server frame
|
||||
};
|
||||
|
||||
// client to server
|
||||
|
@ -140,7 +137,7 @@ typedef enum
|
|||
#define U_BODY (1<<25)
|
||||
#define U_SOLID (1<<26)
|
||||
#define U_ALPHA (1<<27) // alpha value
|
||||
#define U_EVENT (1<<28) // remove this
|
||||
|
||||
#define U_MOREBITS4 (1<<31) // read one additional byte
|
||||
|
||||
// entity_state_t communication
|
||||
|
@ -164,31 +161,11 @@ typedef struct entity_state_s
|
|||
int solid; // for client side prediction, 8*(bits 0-4) is x/y radius
|
||||
// 8*(bits 5-9) is z down distance, 8(bits10-15) is z up
|
||||
// gi.linkentity sets this properly
|
||||
int event; // impulse events -- muzzle flashes, footsteps, etc
|
||||
// events only go out for a single frame, they
|
||||
// are automatically cleared each frame
|
||||
float alpha; // alpha value
|
||||
float animtime; // auto-animating time
|
||||
|
||||
} entity_state_t;
|
||||
|
||||
// entity_state_t->event values
|
||||
// ertity events are for effects that take place reletive
|
||||
// to an existing entities origin. Very network efficient.
|
||||
// All muzzle flashes really should be converted to events...
|
||||
typedef enum
|
||||
{
|
||||
EV_NONE,
|
||||
EV_ITEM_RESPAWN,
|
||||
EV_FOOTSTEP,
|
||||
EV_FALLSHORT,
|
||||
EV_FALL,
|
||||
EV_FALLFAR,
|
||||
EV_PLAYER_TELEPORT,
|
||||
EV_OTHER_TELEPORT
|
||||
|
||||
} entity_event_t;
|
||||
|
||||
/*
|
||||
==========================================================
|
||||
|
||||
|
@ -392,7 +369,7 @@ extern netadr_t net_from;
|
|||
extern sizebuf_t net_message;
|
||||
extern byte net_message_buffer[MAX_MSGLEN];
|
||||
|
||||
#define PROTOCOL_VERSION 34
|
||||
#define PROTOCOL_VERSION 35
|
||||
#define PORT_MASTER 27900
|
||||
#define PORT_CLIENT 27901
|
||||
#define PORT_SERVER 27910
|
||||
|
|
|
@ -29,6 +29,8 @@ typedef struct vrect_s
|
|||
int height;
|
||||
} vrect_t;
|
||||
|
||||
extern vrect_t scr_vrect; // position of render window
|
||||
|
||||
// all drawing is done to a 640*480 virtual screen size
|
||||
// and will be automatically scaled to the real resolution
|
||||
#define SCREEN_WIDTH 640
|
||||
|
@ -43,40 +45,9 @@ typedef struct vrect_s
|
|||
#define GIANTCHAR_WIDTH 32
|
||||
#define GIANTCHAR_HEIGHT 48
|
||||
|
||||
// cinematic states
|
||||
typedef enum
|
||||
{
|
||||
FMV_IDLE,
|
||||
FMV_PLAY, // play
|
||||
FMV_EOF, // all other conditions, i.e. stop/EOF/abort
|
||||
FMV_ID_BLT,
|
||||
FMV_ID_IDLE,
|
||||
FMV_LOOPED,
|
||||
FMV_ID_WAIT
|
||||
} e_status;
|
||||
|
||||
// cinematic flags
|
||||
#define CIN_loop 1
|
||||
#define CIN_hold 2
|
||||
#define CIN_silent 4
|
||||
|
||||
void SCR_Init (void);
|
||||
void SCR_UpdateScreen (void);
|
||||
void SCR_SizeUp (void);
|
||||
void SCR_SizeDown (void);
|
||||
void SCR_CenterPrint (char *str);
|
||||
|
||||
void VID_Init( void );
|
||||
void VID_MenuInit( void );
|
||||
void VID_MenuDraw( void );
|
||||
const char *VID_MenuKey( int );
|
||||
|
||||
extern cvar_t *crosshair;
|
||||
extern cvar_t *scr_loading;
|
||||
extern vrect_t scr_vrect; // position of render window
|
||||
extern cvar_t *scr_width;
|
||||
extern cvar_t *scr_height;
|
||||
|
||||
void SCR_AdjustSize( float *x, float *y, float *w, float *h );
|
||||
void SCR_DrawPic( float x, float y, float width, float height, const char *picname );
|
||||
void SCR_FillRect( float x, float y, float width, float height, const float *color );
|
||||
|
@ -89,20 +60,4 @@ void SCR_DrawBigStringColor( int x, int y, const char *s, vec4_t color );
|
|||
void SCR_DrawFPS( void );
|
||||
void SCR_DrawNet( void );
|
||||
|
||||
//
|
||||
// cg_user.c
|
||||
//
|
||||
void CG_DrawCenterString( void );
|
||||
void CG_CenterPrint( const char *str, int y, int charWidth );
|
||||
float *CG_FadeColor( float starttime, float endtime );
|
||||
void CG_DrawCenterPic( int w, int h, char *picname );
|
||||
void CG_ExecuteProgram( char *section );
|
||||
bool CG_ExecBuiltins( void );
|
||||
void CG_MakeLevelShot( void );
|
||||
void CG_DrawPause( void );
|
||||
void CG_Init( void );
|
||||
void CG_ParseInventory( sizebuf_t *msg );
|
||||
void CG_DrawInventory( void );
|
||||
void CG_DrawLayout( void );
|
||||
|
||||
#endif//SCREEN_H
|
|
@ -48,7 +48,7 @@ void SV_SetMaster_f( void )
|
|||
Netchan_OutOfBandPrint (NS_SERVER, master_adr[slot], "ping");
|
||||
slot++;
|
||||
}
|
||||
svs.last_heartbeat = -99999.0f;
|
||||
svs.last_heartbeat = MAX_HEARTBEAT;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -419,7 +419,7 @@ SV_Heartbeat_f
|
|||
*/
|
||||
void SV_Heartbeat_f (void)
|
||||
{
|
||||
svs.last_heartbeat = -99999.0f;
|
||||
svs.last_heartbeat = MAX_HEARTBEAT;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -55,7 +55,6 @@ struct sv_edict_s
|
|||
|
||||
int serialnumber; // unical entity #id
|
||||
int solid; // see entity_state_t for details
|
||||
int event; // apply sv.events too
|
||||
physbody_t *physbody; // ptr to phys body
|
||||
|
||||
// baselines
|
||||
|
|
|
@ -33,7 +33,6 @@ void SV_UpdateEntityState( edict_t *ent)
|
|||
// copy progs values to state
|
||||
ent->priv.sv->s.number = ent->priv.sv->serialnumber;
|
||||
ent->priv.sv->s.solid = ent->priv.sv->solid;
|
||||
ent->priv.sv->s.event = ent->priv.sv->event;
|
||||
|
||||
VectorCopy (ent->progs.sv->origin, ent->priv.sv->s.origin);
|
||||
VectorCopy (ent->progs.sv->angles, ent->priv.sv->s.angles);
|
||||
|
@ -81,17 +80,22 @@ void SV_EmitPacketEntities (client_frame_t *from, client_frame_t *to, sizebuf_t
|
|||
|
||||
newindex = 0;
|
||||
oldindex = 0;
|
||||
while (newindex < to->num_entities || oldindex < from_num_entities)
|
||||
while( newindex < to->num_entities || oldindex < from_num_entities )
|
||||
{
|
||||
if (newindex >= to->num_entities)
|
||||
newnum = 9999;
|
||||
if( newindex >= to->num_entities )
|
||||
{
|
||||
newnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
newent = &svs.client_entities[(to->first_entity+newindex)%svs.num_client_entities];
|
||||
newnum = newent->number;
|
||||
}
|
||||
|
||||
if (oldindex >= from_num_entities) oldnum = 9999;
|
||||
if( oldindex >= from_num_entities )
|
||||
{
|
||||
oldnum = MAX_ENTNUMBER;
|
||||
}
|
||||
else
|
||||
{
|
||||
oldent = &svs.client_entities[(from->first_entity+oldindex)%svs.num_client_entities];
|
||||
|
@ -99,7 +103,8 @@ void SV_EmitPacketEntities (client_frame_t *from, client_frame_t *to, sizebuf_t
|
|||
}
|
||||
|
||||
if (newnum == oldnum)
|
||||
{ // delta update from old position
|
||||
{
|
||||
// delta update from old position
|
||||
// because the force parm is false, this will not result
|
||||
// in any bytes being emited if the entity has not changed at all
|
||||
// note that players are always 'newentities', this updates their oldorigin always
|
||||
|
@ -110,7 +115,7 @@ void SV_EmitPacketEntities (client_frame_t *from, client_frame_t *to, sizebuf_t
|
|||
continue;
|
||||
}
|
||||
|
||||
if (newnum < oldnum)
|
||||
if( newnum < oldnum )
|
||||
{ // this is a new entity, send it from the baseline
|
||||
MSG_WriteDeltaEntity (&sv.baselines[newnum], newent, msg, true, true);
|
||||
newindex++;
|
||||
|
@ -407,11 +412,11 @@ void SV_BuildClientFrame( client_state_t *client )
|
|||
ent = PRVM_EDICT_NUM(e);
|
||||
|
||||
// ignore ents without visible models unless they have an effect
|
||||
if( !ent->progs.sv->modelindex && !ent->progs.sv->effects && !ent->priv.sv->s.soundindex && !ent->priv.sv->event )
|
||||
if( !ent->progs.sv->modelindex && !ent->progs.sv->effects && !ent->priv.sv->s.soundindex )
|
||||
continue;
|
||||
|
||||
// ignore if not touching a PV leaf
|
||||
if (ent != clent)
|
||||
if( ent != clent )
|
||||
{
|
||||
// check area
|
||||
if (!pe->AreasConnected (clientarea, ent->priv.sv->areanum))
|
||||
|
@ -422,67 +427,57 @@ void SV_BuildClientFrame( client_state_t *client )
|
|||
continue; // blocked by a door
|
||||
}
|
||||
|
||||
// beams just check one point for PHS
|
||||
if ((int)ent->progs.sv->renderfx & RF_BEAM)
|
||||
// FIXME: if an ent has a model and a sound, but isn't
|
||||
// in the PVS, only the PHS, clear the model
|
||||
if (ent->priv.sv->s.soundindex ) bitvector = clientphs;
|
||||
else bitvector = clientpvs;
|
||||
|
||||
// check individual leafs
|
||||
if( !ent->priv.sv->num_clusters )
|
||||
{
|
||||
l = ent->priv.sv->clusternums[0];
|
||||
if ( !(clientphs[l >> 3] & (1 << (l&7) )) )
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
for( i = 0, l = 0; i < ent->priv.sv->num_clusters; i++ )
|
||||
{
|
||||
// FIXME: if an ent has a model and a sound, but isn't
|
||||
// in the PVS, only the PHS, clear the model
|
||||
if (ent->priv.sv->s.soundindex ) bitvector = clientphs;
|
||||
else bitvector = clientpvs;
|
||||
|
||||
// check individual leafs
|
||||
if( !ent->priv.sv->num_clusters )
|
||||
l = ent->priv.sv->clusternums[i];
|
||||
if( bitvector[l>>3] & (1<<(l&7)))
|
||||
break;
|
||||
}
|
||||
// if we haven't found it to be visible,
|
||||
// check overflow clusters that coudln't be stored
|
||||
if( i == ent->priv.sv->num_clusters )
|
||||
{
|
||||
if( ent->priv.sv->lastcluster )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for( i = 0, l = 0; i < ent->priv.sv->num_clusters; i++ )
|
||||
{
|
||||
l = ent->priv.sv->clusternums[i];
|
||||
if( bitvector[l>>3] & (1<<(l&7)))
|
||||
break;
|
||||
}
|
||||
// if we haven't found it to be visible,
|
||||
// check overflow clusters that coudln't be stored
|
||||
if( i == ent->priv.sv->num_clusters )
|
||||
{
|
||||
if( ent->priv.sv->lastcluster )
|
||||
for( ; l <= ent->priv.sv->lastcluster; l++ )
|
||||
{
|
||||
for( ; l <= ent->priv.sv->lastcluster; l++ )
|
||||
{
|
||||
if( bitvector[l>>3] & (1<<(l&7)))
|
||||
break;
|
||||
}
|
||||
if( l == ent->priv.sv->lastcluster )
|
||||
continue; // not visible
|
||||
if( bitvector[l>>3] & (1<<(l&7)))
|
||||
break;
|
||||
}
|
||||
else continue;
|
||||
if( l == ent->priv.sv->lastcluster )
|
||||
continue; // not visible
|
||||
}
|
||||
if( !ent->progs.sv->modelindex )
|
||||
{
|
||||
// don't send sounds if they will be attenuated away
|
||||
vec3_t delta, entorigin;
|
||||
float len;
|
||||
else continue;
|
||||
}
|
||||
if( !ent->progs.sv->modelindex )
|
||||
{
|
||||
// don't send sounds if they will be attenuated away
|
||||
vec3_t delta, entorigin;
|
||||
float len;
|
||||
|
||||
if(VectorIsNull( ent->progs.sv->origin ))
|
||||
{
|
||||
VectorAdd( ent->progs.sv->mins, ent->progs.sv->maxs, entorigin );
|
||||
VectorScale( entorigin, 0.5, entorigin );
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorCopy( ent->progs.sv->origin, entorigin );
|
||||
}
|
||||
|
||||
VectorSubtract( org, entorigin, delta );
|
||||
len = VectorLength( delta );
|
||||
if( len > 400 ) continue;
|
||||
if(VectorIsNull( ent->progs.sv->origin ))
|
||||
{
|
||||
VectorAdd( ent->progs.sv->mins, ent->progs.sv->maxs, entorigin );
|
||||
VectorScale( entorigin, 0.5, entorigin );
|
||||
}
|
||||
else
|
||||
{
|
||||
VectorCopy( ent->progs.sv->origin, entorigin );
|
||||
}
|
||||
|
||||
VectorSubtract( org, entorigin, delta );
|
||||
len = VectorLength( delta );
|
||||
if( len > 400 ) continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -307,7 +307,7 @@ void SV_InitGame (void)
|
|||
NET_Config ( (maxclients->value > 1) );
|
||||
|
||||
// heartbeats will always be sent to the id master
|
||||
svs.last_heartbeat = -99999.0f; // send immediately
|
||||
svs.last_heartbeat = MAX_HEARTBEAT; // send immediately
|
||||
com.sprintf(idmaster, "192.246.40.37:%i", PORT_MASTER);
|
||||
NET_StringToAdr (idmaster, &master_adr[0]);
|
||||
|
||||
|
|
|
@ -667,29 +667,6 @@ void SV_CheckTimeouts (void)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
SV_PrepWorldFrame
|
||||
|
||||
This has to be done before the world logic, because
|
||||
player processing happens outside RunWorldFrame
|
||||
================
|
||||
*/
|
||||
void SV_PrepWorldFrame (void)
|
||||
{
|
||||
edict_t *ent;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < prog->num_edicts ; i++, ent++)
|
||||
{
|
||||
ent = PRVM_EDICT_NUM(i);
|
||||
// events only last for a single message
|
||||
ent->priv.sv->event = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
SV_RunGameFrame
|
||||
|
@ -782,9 +759,6 @@ void SV_Frame (float time)
|
|||
// send a heartbeat to the master if needed
|
||||
Master_Heartbeat ();
|
||||
|
||||
// clear teleport flags, etc for next frame
|
||||
SV_PrepWorldFrame ();
|
||||
|
||||
// end the server VM frame
|
||||
SV_VM_End();
|
||||
}
|
||||
|
|
|
@ -1896,7 +1896,7 @@ void PF_checkbottom( void )
|
|||
=================
|
||||
PF_ClientPrint
|
||||
|
||||
void ClientPrint( float type, entity client, string s )
|
||||
void ClientPrintf( float type, entity client, string s )
|
||||
=================
|
||||
*/
|
||||
void PF_ClientPrint( void )
|
||||
|
@ -2222,7 +2222,7 @@ VM_ComVA, // #29 string va( ... )
|
|||
VM_ComStrlen, // #30 float strlen( string text )
|
||||
VM_TimeStamp, // #31 string Com_TimeStamp( float format )
|
||||
VM_LocalCmd, // #32 void LocalCmd( ... )
|
||||
NULL, // #33 -- reserved --
|
||||
VM_SubString, // #33 string substring( string s, float start, float length )
|
||||
NULL, // #34 -- reserved --
|
||||
NULL, // #35 -- reserved --
|
||||
NULL, // #36 -- reserved --
|
||||
|
|
|
@ -245,7 +245,7 @@ Misc helper function
|
|||
|
||||
void _MSG_Begin( int dest, const char *filename, int fileline )
|
||||
{
|
||||
_MSG_WriteChar (&sv.multicast, dest, filename, fileline );
|
||||
_MSG_WriteByte( &sv.multicast, dest, filename, fileline );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -691,50 +691,6 @@ void Cmd_Say_f (edict_t *ent, bool team, bool arg0)
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
HelpComputer
|
||||
|
||||
Draw help computer.
|
||||
==================
|
||||
*/
|
||||
void SV_HelpComputer (edict_t *ent)
|
||||
{
|
||||
char string[1024];
|
||||
char *sk = "medium";
|
||||
|
||||
com.sprintf (string, "xv 32 yv 8 picn help " // background
|
||||
"xv 202 yv 12 string2 \"%s\" " // skill
|
||||
"xv 0 yv 24 cstring2 \"%s\" " // level name
|
||||
"xv 0 yv 54 cstring2 \"%s\" " // help 1
|
||||
"xv 0 yv 110 cstring2 \"%s\" " // help 2
|
||||
"xv 50 yv 164 string2 \" kills goals secrets\" "
|
||||
"xv 50 yv 172 string2 \"%3i/%3i %i/%i %i/%i\" ",
|
||||
sk,
|
||||
sv.name,
|
||||
"",
|
||||
"",
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0);
|
||||
|
||||
MSG_Begin (svc_layout);
|
||||
MSG_WriteString (&sv.multicast, string);
|
||||
MSG_Send (MSG_ONE_R, NULL, ent );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Cmd_Help_f
|
||||
|
||||
Display the current help message
|
||||
==================
|
||||
*/
|
||||
void Cmd_Help_f (edict_t *ent)
|
||||
{
|
||||
SV_HelpComputer (ent);
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
SV_ClientCommand
|
||||
|
@ -762,11 +718,6 @@ void SV_ClientCommand (edict_t *ent)
|
|||
Cmd_Say_f (ent, true, false);
|
||||
return;
|
||||
}
|
||||
if (strcasecmp (cmd, "help") == 0)
|
||||
{
|
||||
Cmd_Help_f (ent);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void SV_Transform( sv_edict_t *ed, matrix4x3 transform )
|
||||
|
|
|
@ -9,20 +9,16 @@
|
|||
|
||||
#define MAX_LIGHTSTYLES 256
|
||||
|
||||
#define EF_TELEPORTER (1<<0) // particle fountain
|
||||
#define EF_ROTATE (1<<1) // rotate (bonus items)
|
||||
#define EF_ROTATE (1<<0) // rotate (bonus items)
|
||||
|
||||
// shared client/renderer flags
|
||||
#define RF_MINLIGHT 1 // allways have some light (viewmodel)
|
||||
#define RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
|
||||
#define RF_WEAPONMODEL 4 // only draw through eyes
|
||||
#define RF_PLAYERMODEL 2 // don't draw through eyes, only mirrors
|
||||
#define RF_VIEWMODEL 4 // it's a viewmodel
|
||||
#define RF_FULLBRIGHT 8 // allways draw full intensity
|
||||
#define RF_DEPTHHACK 16 // for view weapon Z crunching
|
||||
#define RF_TRANSLUCENT 32
|
||||
#define RF_FRAMELERP 64
|
||||
#define RF_BEAM 128
|
||||
#define RF_IR_VISIBLE 256 // skin is an index in image_precache
|
||||
#define RF_GLOW 512 // pulse lighting for bonus items
|
||||
#define RF_IR_VISIBLE 64 // skin is an index in image_precache
|
||||
|
||||
// render private flags
|
||||
#define RDF_NOWORLDMODEL 1 // used for player configuration screen
|
||||
|
@ -114,17 +110,6 @@ enum player_stats
|
|||
MAX_STATS = 32,
|
||||
};
|
||||
|
||||
typedef enum
|
||||
{
|
||||
R_BEAM,
|
||||
R_SPRITE,
|
||||
R_POLYGON,
|
||||
R_BSPMODEL,
|
||||
R_VIEWMODEL, // studio model that drawn trough eyes
|
||||
R_STUDIOMODEL,
|
||||
R_TYPES_COUNT,
|
||||
} reftype_t;
|
||||
|
||||
typedef struct dlight_s
|
||||
{
|
||||
vec3_t origin;
|
||||
|
@ -199,8 +184,6 @@ typedef struct entity_s
|
|||
|
||||
int lightstyle; // for flashing entities
|
||||
float alpha; // ignore if RF_TRANSLUCENT isn't set
|
||||
|
||||
image_t *image; // NULL for inline skin
|
||||
int flags;
|
||||
|
||||
} entity_t;
|
||||
|
|
|
@ -249,34 +249,27 @@ void R_DrawEntitiesOnList (void)
|
|||
for (i = 0; i < r_newrefdef.num_entities; i++)
|
||||
{
|
||||
currententity = &r_newrefdef.entities[i];
|
||||
currentmodel = currententity->model;
|
||||
|
||||
if ( currententity->flags & RF_BEAM )
|
||||
if (!currentmodel)
|
||||
{
|
||||
R_DrawBeam( currententity );
|
||||
R_DrawNullModel();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
switch (currentmodel->type)
|
||||
{
|
||||
currentmodel = currententity->model;
|
||||
if (!currentmodel)
|
||||
{
|
||||
R_DrawNullModel();
|
||||
continue;
|
||||
}
|
||||
switch (currentmodel->type)
|
||||
{
|
||||
case mod_brush:
|
||||
R_DrawBrushModel( RENDERPASS_SOLID );
|
||||
break;
|
||||
case mod_sprite:
|
||||
R_DrawSpriteModel( RENDERPASS_SOLID );
|
||||
break;
|
||||
case mod_studio:
|
||||
R_DrawStudioModel( RENDERPASS_SOLID );
|
||||
break;
|
||||
default:
|
||||
Sys_Error ("Bad modeltype. Pass: solid");
|
||||
break;
|
||||
}
|
||||
case mod_brush:
|
||||
R_DrawBrushModel( RENDERPASS_SOLID );
|
||||
break;
|
||||
case mod_sprite:
|
||||
R_DrawSpriteModel( RENDERPASS_SOLID );
|
||||
break;
|
||||
case mod_studio:
|
||||
R_DrawStudioModel( RENDERPASS_SOLID );
|
||||
break;
|
||||
default:
|
||||
Sys_Error ("Bad modeltype. Pass: solid");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,35 +279,27 @@ void R_DrawEntitiesOnList (void)
|
|||
for (i = 0; i < r_newrefdef.num_entities; i++)
|
||||
{
|
||||
currententity = &r_newrefdef.entities[i];
|
||||
currentmodel = currententity->model;
|
||||
|
||||
if ( currententity->flags & RF_BEAM )
|
||||
if (!currentmodel)
|
||||
{
|
||||
R_DrawBeam( currententity );
|
||||
R_DrawNullModel ();
|
||||
continue;
|
||||
}
|
||||
else
|
||||
switch (currentmodel->type)
|
||||
{
|
||||
currentmodel = currententity->model;
|
||||
|
||||
if (!currentmodel)
|
||||
{
|
||||
R_DrawNullModel ();
|
||||
continue;
|
||||
}
|
||||
switch (currentmodel->type)
|
||||
{
|
||||
case mod_brush:
|
||||
R_DrawBrushModel( RENDERPASS_ALPHA );
|
||||
break;
|
||||
case mod_sprite:
|
||||
R_DrawSpriteModel( RENDERPASS_ALPHA );
|
||||
break;
|
||||
case mod_studio:
|
||||
R_DrawStudioModel( RENDERPASS_ALPHA );
|
||||
break;
|
||||
default:
|
||||
Sys_Error ("Bad modeltype. Pass: alpha");
|
||||
break;
|
||||
}
|
||||
case mod_brush:
|
||||
R_DrawBrushModel( RENDERPASS_ALPHA );
|
||||
break;
|
||||
case mod_sprite:
|
||||
R_DrawSpriteModel( RENDERPASS_ALPHA );
|
||||
break;
|
||||
case mod_studio:
|
||||
R_DrawStudioModel( RENDERPASS_ALPHA );
|
||||
break;
|
||||
default:
|
||||
Sys_Error ("Bad modeltype. Pass: alpha");
|
||||
break;
|
||||
}
|
||||
}
|
||||
qglDepthMask(1);// back to writing
|
||||
|
@ -1397,75 +1382,6 @@ void R_SetPalette ( const byte *palette)
|
|||
qglClearColor (1, 0, 0.5, 0.5);
|
||||
}
|
||||
|
||||
/*
|
||||
** R_DrawBeam
|
||||
*/
|
||||
void R_DrawBeam( entity_t *e )
|
||||
{
|
||||
#define NUM_BEAM_SEGS 6
|
||||
|
||||
int i;
|
||||
float r, g, b;
|
||||
|
||||
vec3_t perpvec;
|
||||
vec3_t direction, normalized_direction;
|
||||
vec3_t start_points[NUM_BEAM_SEGS], end_points[NUM_BEAM_SEGS];
|
||||
vec3_t oldorigin, origin;
|
||||
|
||||
oldorigin[0] = e->oldorigin[0];
|
||||
oldorigin[1] = e->oldorigin[1];
|
||||
oldorigin[2] = e->oldorigin[2];
|
||||
|
||||
origin[0] = e->origin[0];
|
||||
origin[1] = e->origin[1];
|
||||
origin[2] = e->origin[2];
|
||||
|
||||
normalized_direction[0] = direction[0] = oldorigin[0] - origin[0];
|
||||
normalized_direction[1] = direction[1] = oldorigin[1] - origin[1];
|
||||
normalized_direction[2] = direction[2] = oldorigin[2] - origin[2];
|
||||
|
||||
if ( VectorNormalize( normalized_direction ) == 0 )
|
||||
return;
|
||||
|
||||
PerpendicularVector( perpvec, normalized_direction );
|
||||
VectorScale( perpvec, e->frame / 2, perpvec );
|
||||
|
||||
for ( i = 0; i < 6; i++ )
|
||||
{
|
||||
RotatePointAroundVector( start_points[i], normalized_direction, perpvec, (360.0/NUM_BEAM_SEGS)*i );
|
||||
VectorAdd( start_points[i], origin, start_points[i] );
|
||||
VectorAdd( start_points[i], direction, end_points[i] );
|
||||
}
|
||||
|
||||
qglDisable( GL_TEXTURE_2D );
|
||||
qglEnable( GL_BLEND );
|
||||
qglDepthMask( GL_FALSE );
|
||||
|
||||
r = ( d_8to24table[e->skinnum & 0xFF] ) & 0xFF;
|
||||
g = ( d_8to24table[e->skinnum & 0xFF] >> 8 ) & 0xFF;
|
||||
b = ( d_8to24table[e->skinnum & 0xFF] >> 16 ) & 0xFF;
|
||||
|
||||
r *= 1/255.0F;
|
||||
g *= 1/255.0F;
|
||||
b *= 1/255.0F;
|
||||
|
||||
qglColor4f( r, g, b, e->alpha );
|
||||
|
||||
qglBegin( GL_TRIANGLE_STRIP );
|
||||
for ( i = 0; i < NUM_BEAM_SEGS; i++ )
|
||||
{
|
||||
qglVertex3fv( start_points[i] );
|
||||
qglVertex3fv( end_points[i] );
|
||||
qglVertex3fv( start_points[(i+1)%NUM_BEAM_SEGS] );
|
||||
qglVertex3fv( end_points[(i+1)%NUM_BEAM_SEGS] );
|
||||
}
|
||||
qglEnd();
|
||||
|
||||
qglEnable( GL_TEXTURE_2D );
|
||||
qglDisable( GL_BLEND );
|
||||
qglDepthMask( GL_TRUE );
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
R_RegisterSkin
|
||||
|
|
|
@ -276,7 +276,7 @@ void R_SpriteSetupLighting( model_t *mod )
|
|||
R_LightPoint( currententity->origin, mod->lightcolor );
|
||||
|
||||
// doom sprite models
|
||||
if( currententity->flags & RF_WEAPONMODEL )
|
||||
if( currententity->flags & RF_VIEWMODEL )
|
||||
r_lightlevel->value = bound(0, VectorLength(mod->lightcolor) * 75.0f, 255);
|
||||
|
||||
}
|
||||
|
|
|
@ -1027,7 +1027,7 @@ static bool R_StudioCheckBBox( void )
|
|||
|
||||
int aggregatemask = ~0;
|
||||
|
||||
if(m_pCurrentEntity->flags & RF_WEAPONMODEL)
|
||||
if(m_pCurrentEntity->flags & RF_VIEWMODEL)
|
||||
return true;
|
||||
if(!R_StudioComputeBBox( bbox ))
|
||||
return false;
|
||||
|
@ -1088,7 +1088,7 @@ void R_StudioSetupLighting( void )
|
|||
VectorCopy( m_pCurrentEntity->origin, light_org );
|
||||
light_org[2] += 3; // make sure what lightpoint is off the ground
|
||||
R_LightPoint( light_org, m_plightcolor );
|
||||
if ( m_pCurrentEntity->flags & RF_WEAPONMODEL )
|
||||
if ( m_pCurrentEntity->flags & RF_VIEWMODEL )
|
||||
r_lightlevel->value = bound(0, VectorLength(m_plightcolor) * 75.0f, 255);
|
||||
|
||||
}
|
||||
|
@ -1306,7 +1306,7 @@ void R_StudioDrawPoints ( void )
|
|||
if (currententity->flags & RF_DEPTHHACK) // hack the depth range to prevent view model from poking into walls
|
||||
qglDepthRange (gldepthmin, gldepthmin + 0.3 * (gldepthmax-gldepthmin));
|
||||
|
||||
if (( m_pCurrentEntity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ))
|
||||
if (( m_pCurrentEntity->flags & RF_VIEWMODEL ) && ( r_lefthand->value == 1.0F ))
|
||||
{
|
||||
qglMatrixMode( GL_PROJECTION );
|
||||
qglPushMatrix();
|
||||
|
@ -1332,7 +1332,7 @@ void R_StudioDrawPoints ( void )
|
|||
qglColor4f( 1, 1, 1, 1 ); //reset color
|
||||
qglDisable(GL_BLEND);
|
||||
}
|
||||
if (( m_pCurrentEntity->flags & RF_WEAPONMODEL ) && ( r_lefthand->value == 1.0F ))
|
||||
if (( m_pCurrentEntity->flags & RF_VIEWMODEL ) && ( r_lefthand->value == 1.0F ))
|
||||
{
|
||||
qglMatrixMode( GL_PROJECTION );
|
||||
qglPopMatrix();
|
||||
|
@ -1522,7 +1522,7 @@ void R_StudioDrawHulls ( void )
|
|||
int i;
|
||||
vec3_t bbox[8];
|
||||
|
||||
if(m_pCurrentEntity->flags & RF_WEAPONMODEL) return;
|
||||
if(m_pCurrentEntity->flags & RF_VIEWMODEL) return;
|
||||
if(!R_StudioComputeBBox( bbox )) return;
|
||||
|
||||
qglDisable( GL_CULL_FACE );
|
||||
|
@ -1604,7 +1604,7 @@ void R_DrawStudioModel( int passnum )
|
|||
|
||||
// nothing to draw
|
||||
if(m_pStudioHeader->numbodyparts == 0) return;
|
||||
if(m_pCurrentEntity->flags & RF_WEAPONMODEL && r_lefthand->value == 2)
|
||||
if(m_pCurrentEntity->flags & RF_VIEWMODEL && r_lefthand->value == 2)
|
||||
return;
|
||||
|
||||
if (m_pCurrentEntity->movetype == MOVETYPE_FOLLOW)
|
||||
|
@ -1638,21 +1638,15 @@ void R_DrawStudioModel( int passnum )
|
|||
if(r_minimap->value > 1)
|
||||
{
|
||||
if(numRadarEnts >= MAX_RADAR_ENTS) return;
|
||||
if(currententity->flags & RF_VIEWERMODEL) return;
|
||||
if(currententity->flags & RF_WEAPONMODEL) return;
|
||||
if(currententity->flags & RF_VIEWMODEL) return;
|
||||
|
||||
if( currententity->flags & RF_GLOW)
|
||||
{
|
||||
RadarEnts[numRadarEnts].color[0]= 0.0;
|
||||
RadarEnts[numRadarEnts].color[1]= 1.0;
|
||||
RadarEnts[numRadarEnts].color[2]= 0.0;
|
||||
RadarEnts[numRadarEnts].color[3]= 0.5;
|
||||
}
|
||||
/*else if( currententity->flags & RF2_MONSTER)
|
||||
/*
|
||||
if( currententity->flags & RF2_MONSTER)
|
||||
{
|
||||
Vector4Set(RadarEnts[numRadarEnts].color, 1.0f, 0.0f, 2.0f, 1.0f );
|
||||
}*/
|
||||
}
|
||||
else
|
||||
*/
|
||||
{
|
||||
Vector4Set(RadarEnts[numRadarEnts].color, 0.0f, 1.0f, 1.0f, 0.5f );
|
||||
}
|
||||
|
@ -1661,7 +1655,7 @@ void R_DrawStudioModel( int passnum )
|
|||
numRadarEnts++;
|
||||
}
|
||||
|
||||
if (gl_shadows->value && !(m_pCurrentEntity->flags & (RF_TRANSLUCENT | RF_WEAPONMODEL)))
|
||||
if (gl_shadows->value && !(m_pCurrentEntity->flags & (RF_TRANSLUCENT | RF_VIEWMODEL)))
|
||||
{
|
||||
qglPushMatrix();
|
||||
R_RotateForEntity(m_pCurrentEntity);
|
||||
|
|
9
todo.log
9
todo.log
|
@ -20,9 +20,12 @@ fopen
|
|||
4. snd encoder äëÿ roqlib
|
||||
|
||||
Òåêóùèå çàäà÷è:
|
||||
0. Èìïëåìåíòàöèÿ client.dat
|
||||
1. Èìïîðò cg_user.c â client.dat
|
||||
2. Ïîääåðæêà êàñòîìíûõ ìåññàã
|
||||
0. Имплементация client.dat OK
|
||||
1. Импорт cg_user.c в client.dat OK
|
||||
2. Поддержка кастомных мессаг OK
|
||||
3. Упорядочить svc_ мессаги OK
|
||||
4. Вырезать все клиентские эффекты
|
||||
5. Создать cl_edict_s
|
||||
|
||||
|
||||
Ôèçèêà èãðîêà:
|
||||
|
|
|
@ -106,7 +106,56 @@ char *prvm_opnames[] =
|
|||
"^2OR",
|
||||
|
||||
"BITAND",
|
||||
"BITOR"
|
||||
"BITOR",
|
||||
"MULSTORE_F",
|
||||
"MULSTORE_V",
|
||||
"MULSTOREP_F",
|
||||
"MULSTOREP_V",
|
||||
|
||||
"DIVSTORE_F",
|
||||
"DIVSTOREP_F",
|
||||
|
||||
"ADDSTORE_F",
|
||||
"ADDSTORE_V",
|
||||
"ADDSTOREP_F",
|
||||
"ADDSTOREP_V",
|
||||
|
||||
"SUBSTORE_F",
|
||||
"SUBSTORE_V",
|
||||
"SUBSTOREP_F",
|
||||
"SUBSTOREP_V",
|
||||
|
||||
"FETCH_GBL_F",
|
||||
"FETCH_GBL_V",
|
||||
"FETCH_GBL_S",
|
||||
"FETCH_GBL_E",
|
||||
"FETCH_G_FNC",
|
||||
|
||||
"^9CSTATE",
|
||||
"^9CWSTATE",
|
||||
|
||||
"^6THINKTIME",
|
||||
|
||||
"^4BITSET",
|
||||
"^4BITSETP",
|
||||
"^4BITCLR",
|
||||
"^4BITCLRP",
|
||||
|
||||
"^9RAND0",
|
||||
"^9RAND1",
|
||||
"^9RAND2",
|
||||
"^9RANDV0",
|
||||
"^9RANDV1",
|
||||
"^9RANDV2",
|
||||
|
||||
"^6SWITCH_F",
|
||||
"^6SWITCH_V",
|
||||
"^6SWITCH_S",
|
||||
"^6SWITCH_E",
|
||||
"^6SWITCH_FNC",
|
||||
|
||||
"^6CASE",
|
||||
"^6CASERANGE"
|
||||
};
|
||||
|
||||
char *PRVM_GlobalString (int ofs);
|
||||
|
@ -397,8 +446,7 @@ int PRVM_EnterFunction (mfunction_t *f)
|
|||
{
|
||||
int i, j, c, o;
|
||||
|
||||
if (!f)
|
||||
PRVM_ERROR ("PRVM_EnterFunction: NULL function in %s", PRVM_NAME);
|
||||
if( !f ) PRVM_ERROR ("PRVM_EnterFunction: NULL function in %s", PRVM_NAME);
|
||||
|
||||
vm.prog->stack[vm.prog->depth].s = vm.prog->xstatement;
|
||||
vm.prog->stack[vm.prog->depth].f = vm.prog->xfunction;
|
||||
|
@ -406,7 +454,7 @@ int PRVM_EnterFunction (mfunction_t *f)
|
|||
if (vm.prog->depth >=PRVM_MAX_STACK_DEPTH)
|
||||
PRVM_ERROR ("stack overflow");
|
||||
|
||||
// save off any locals that the new function steps on
|
||||
// save off any locals that the new function steps on
|
||||
c = f->locals;
|
||||
if (vm.prog->localstack_used + c > PRVM_LOCALSTACK_SIZE)
|
||||
PRVM_ERROR ("PRVM_ExecuteProgram: locals stack overflow in %s", PRVM_NAME);
|
||||
|
@ -415,7 +463,7 @@ int PRVM_EnterFunction (mfunction_t *f)
|
|||
vm.prog->localstack[vm.prog->localstack_used+i] = ((int *)vm.prog->globals.gp)[f->parm_start + i];
|
||||
vm.prog->localstack_used += c;
|
||||
|
||||
// copy parameters
|
||||
// copy parameters
|
||||
o = f->parm_start;
|
||||
for (i=0 ; i<f->numparms ; i++)
|
||||
{
|
||||
|
@ -435,7 +483,7 @@ int PRVM_EnterFunction (mfunction_t *f)
|
|||
PRVM_LeaveFunction
|
||||
====================
|
||||
*/
|
||||
int PRVM_LeaveFunction (void)
|
||||
int PRVM_LeaveFunction( void )
|
||||
{
|
||||
int i, c;
|
||||
|
||||
|
@ -444,7 +492,7 @@ int PRVM_LeaveFunction (void)
|
|||
|
||||
if (!vm.prog->xfunction)
|
||||
PRVM_ERROR ("PR_LeaveFunction: NULL function in %s", PRVM_NAME);
|
||||
// restore locals from the stack
|
||||
// restore locals from the stack
|
||||
c = vm.prog->xfunction->locals;
|
||||
vm.prog->localstack_used -= c;
|
||||
if (vm.prog->localstack_used < 0)
|
||||
|
@ -453,7 +501,7 @@ int PRVM_LeaveFunction (void)
|
|||
for (i=0 ; i < c ; i++)
|
||||
((int *)vm.prog->globals.gp)[vm.prog->xfunction->parm_start + i] = vm.prog->localstack[vm.prog->localstack_used+i];
|
||||
|
||||
// up stack
|
||||
// up stack
|
||||
vm.prog->depth--;
|
||||
vm.prog->xfunction = vm.prog->stack[vm.prog->depth].f;
|
||||
return vm.prog->stack[vm.prog->depth].s;
|
||||
|
@ -474,9 +522,9 @@ PRVM_ExecuteProgram
|
|||
====================
|
||||
*/
|
||||
// LordHavoc: optimized
|
||||
#define OPA ((prvm_eval_t *)&vm.prog->globals.gp[(word) st->a])
|
||||
#define OPB ((prvm_eval_t *)&vm.prog->globals.gp[(word) st->b])
|
||||
#define OPC ((prvm_eval_t *)&vm.prog->globals.gp[(word) st->c])
|
||||
#define OPA ((prvm_eval_t *)&vm.prog->globals.gp[(word)st->a])
|
||||
#define OPB ((prvm_eval_t *)&vm.prog->globals.gp[(word)st->b])
|
||||
#define OPC ((prvm_eval_t *)&vm.prog->globals.gp[(word)st->c])
|
||||
extern cvar_t *prvm_boundscheck;
|
||||
extern cvar_t *prvm_traceqc;
|
||||
extern cvar_t *prvm_statementprofiling;
|
||||
|
@ -521,7 +569,7 @@ void PRVM_ExecuteProgram( func_t fnum, const char *errormessage )
|
|||
chooseexecprogram:
|
||||
cachedpr_trace = vm.prog->trace;
|
||||
|
||||
while (1)
|
||||
while( 1 )
|
||||
{
|
||||
st++;
|
||||
|
||||
|
@ -1062,7 +1110,7 @@ chooseexecprogram:
|
|||
break;
|
||||
case OP_LOADP_C:
|
||||
ptr = PRVM_EM_POINTER(OPA->_int + (int)OPB->_float);
|
||||
OPC->_float = *(unsigned char *)ptr;
|
||||
OPC->_float = *(byte *)ptr;
|
||||
break;
|
||||
case OP_LOADP_I:
|
||||
case OP_LOADP_F:
|
||||
|
|
|
@ -918,7 +918,7 @@ void PR_LexNumber (void)
|
|||
pr_immediate._float = (float)(num*sign);
|
||||
}
|
||||
|
||||
float PR_LexFloat (void)
|
||||
float PR_LexFloat( void )
|
||||
{
|
||||
int c;
|
||||
int len;
|
||||
|
@ -932,7 +932,7 @@ float PR_LexFloat (void)
|
|||
pr_file_p++;
|
||||
c = *pr_file_p;
|
||||
// only allow a . if the next isn't too...
|
||||
} while ((c >= '0' && c<= '9') || (c == '.'&&pr_file_p[1]!='.'));
|
||||
} while((c >= '0' && c <= '9') || (c == '.'&&pr_file_p[1]!='.') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'));
|
||||
|
||||
pr_token[len] = 0;
|
||||
return (float)com.atof (pr_token);
|
||||
|
|
|
@ -24,7 +24,7 @@ extern int prvm_developer;
|
|||
#define Host_Error com.error
|
||||
|
||||
#define PROG_CRC_SERVER 5103
|
||||
#define PROG_CRC_CLIENT 9014
|
||||
#define PROG_CRC_CLIENT 1652
|
||||
#define PROG_CRC_UIMENU 2460
|
||||
|
||||
enum op_state
|
||||
|
|
Reference in New Issue