19 Jul 2017

This commit is contained in:
g-cont 2017-07-19 00:00:00 +03:00 committed by Alibek Omarov
parent 596de93657
commit 6298f8f8bc
6 changed files with 81 additions and 16 deletions

View File

@ -34,7 +34,7 @@ GNU General Public License for more details.
#define MAX_TEXTCHANNELS 8 // must be power of two (GoldSrc uses 4 channels)
#define TEXT_MSGNAME "TextMessage%i"
char cl_textbuffer[MAX_TEXTCHANNELS][512];
char cl_textbuffer[MAX_TEXTCHANNELS][2048];
client_textmessage_t cl_textmessage[MAX_TEXTCHANNELS];
static dllfunc_t cdll_exports[] =
@ -719,7 +719,54 @@ void CL_ParseTextMessage( sizebuf_t *msg )
else text->fxtime = 0.0f;
// to prevent grab too long messages
Q_strncpy( (char *)text->pMessage, MSG_ReadString( msg ), 512 );
Q_strncpy( (char *)text->pMessage, MSG_ReadString( msg ), 2048 );
// NOTE: a "HudText" message contain only 'string' with message name, so we
// don't needs to use MSG_ routines here, just directly write msgname into netbuffer
CL_DispatchUserMessage( "HudText", Q_strlen( text->pName ) + 1, (void *)text->pName );
}
/*
================
CL_ParseFinaleCutscene
show display finale or cutscene message
================
*/
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level )
{
static int msgindex = 0;
client_textmessage_t *text;
int channel;
cl.intermission = level;
channel = msgindex;
msgindex = (msgindex + 1) & (MAX_TEXTCHANNELS - 1);
// grab message channel
text = &cl_textmessage[channel];
// NOTE: svc_finale and svc_cutscene has a
// predefined settings like Quake-style
text->x = -1.0f;
text->y = 0.15f;
text->effect = 2; // scan out effect
text->r1 = 245;
text->g1 = 245;
text->b1 = 245;
text->a1 = 0; // unused
text->r2 = 0;
text->g2 = 0;
text->b2 = 0;
text->a2 = 0;
text->fadein = 0.15f;
text->fadeout = 0.0f;
text->holdtime = 99999.0f;
text->fxtime = 0.0f;
// to prevent grab too long messages
Q_strncpy( (char *)text->pMessage, MSG_ReadString( msg ), 2048 );
// NOTE: a "HudText" message contain only 'string' with message name, so we
// don't needs to use MSG_ routines here, just directly write msgname into netbuffer
@ -1744,8 +1791,12 @@ int pfnDrawConsoleString( int x, int y, char *string )
if( !string || !*string ) return 0; // silent ignore
Con_SetFont( con_fontsize->value );
clgame.ds.adjust_size = true;
drawLen = Con_DrawString( x, y, string, clgame.ds.textColor );
MakeRGBA( clgame.ds.textColor, 255, 255, 255, 255 );
clgame.ds.adjust_size = false;
Con_RestoreFont();
return (x + drawLen); // exclude color prexfixes

View File

@ -1814,10 +1814,10 @@ void CL_ParseServerMessage( sizebuf_t *msg, qboolean normal_message )
cl.intermission = 1;
break;
case svc_finale:
cl.intermission = 2;
CL_ParseFinaleCutscene( msg, 2 );
break;
case svc_cutscene:
cl.intermission = 3;
CL_ParseFinaleCutscene( msg, 3 );
break;
case svc_modelindex:
CL_PrecacheModel( msg );

View File

@ -722,6 +722,7 @@ void CL_UnloadProgs( void );
qboolean CL_LoadProgs( const char *name );
void CL_ParseUserMessage( sizebuf_t *msg, int svc_num );
void CL_LinkUserMessage( char *pszName, const int svc_num, int iSize );
void CL_ParseFinaleCutscene( sizebuf_t *msg, int level );
void CL_ParseTextMessage( sizebuf_t *msg );
void CL_DrawHUD( int state );
void CL_InitEdicts( void );

View File

@ -609,7 +609,7 @@ qboolean MSG_ReadBytes( sizebuf_t *sb, void *pOut, int nBytes )
char *MSG_ReadStringExt( sizebuf_t *sb, qboolean bLine )
{
static char string[MAX_SYSPATH];
static char string[2048];
int l = 0, c;
do

View File

@ -2613,13 +2613,23 @@ void pfnMessageEnd( void )
return;
}
if( svgame.msg_index < 0 && abs( svgame.msg_index ) == svc_studiodecal && svgame.msg_realsize == 27 )
// update some messages in case their was format was changed and we want to keep backward compatibility
if( svgame.msg_index < 0 )
{
// oldstyle message for svc_studiodecal has missed four additional bytes:
// modelIndex, skin and body. Write it here for backward compatibility
MSG_WriteWord( &sv.multicast, 0 );
MSG_WriteByte( &sv.multicast, 0 );
MSG_WriteByte( &sv.multicast, 0 );
int svc_msg = abs( svgame.msg_index );
if( svc_msg == svc_studiodecal && svgame.msg_realsize == 27 )
{
// oldstyle message for svc_studiodecal has missed four additional bytes:
// modelIndex, skin and body. Write it here for backward compatibility
MSG_WriteWord( &sv.multicast, 0 );
MSG_WriteByte( &sv.multicast, 0 );
MSG_WriteByte( &sv.multicast, 0 );
}
else if(( svc_msg == svc_finale || svc_msg == svc_cutscene ) && svgame.msg_realsize == 0 )
{
MSG_WriteChar( &sv.multicast, 0 ); // write null string
}
}
if( !VectorIsNull( svgame.msg_org )) org = svgame.msg_org;
@ -2724,11 +2734,14 @@ pfnWriteString
*/
void pfnWriteString( const char *src )
{
char *dst, string[MAX_SYSPATH];
int len = Q_strlen( src ) + 1;
int rem = (255 - svgame.msg_realsize);
static char string[2048];
int len = Q_strlen( src ) + 1;
int rem = (255 - svgame.msg_realsize);
char *dst;
if( len == 1 || len >= rem )
// user-message strings can't exceeds 255 symbols,
// but system message allow up to 2048 characters
if(( svgame.msg_index > 0 ) && ( len == 1 || len >= rem ))
{
if( len >= rem )
MsgDev( D_ERROR, "pfnWriteString: exceeds %i symbols\n", rem );

View File

@ -1,2 +1,2 @@
makefont.exe -font "Terminal" fonts.wad
makefont.exe -font "Quake_pixel" -pointsizes 11 13 15 fonts.wad
pause