summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-10 19:18:21 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:46 +0000
commit19ec3ab02940f56b4e927ff0e67ebcbab718ceb4 (patch)
treea110ba9ce795b59c0c1571dfadcb8f3efd698cac /src/cgame
parenta327db46a2d939633b6836de28251ae7d4dbbec5 (diff)
* (bug 3998) linewrap cp, parse newlines in cp and motd
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c18
-rw-r--r--src/cgame/cg_local.h2
2 files changed, 15 insertions, 5 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index b7e966a1..292af56e 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -1131,10 +1131,13 @@ static void CG_DrawMOTD( rectDef_t *rect, float text_x, float text_y,
int textalign, int textvalign, int textStyle )
{
const char *s;
+ char parsed[ MAX_STRING_CHARS ];
s = CG_ConfigString( CS_MOTD );
- UI_DrawTextBlock( rect, text_x, text_y, color, scale, textalign, textvalign, textStyle, s );
+ Q_ParseNewlines( parsed, s, sizeof( parsed ) );
+
+ UI_DrawTextBlock( rect, text_x, text_y, color, scale, textalign, textvalign, textStyle, parsed );
}
static void CG_DrawHostname( rectDef_t *rect, float text_x, float text_y,
@@ -2685,8 +2688,15 @@ for a few moments
void CG_CenterPrint( const char *str, int y, int charWidth )
{
char *s;
+ char newlineParsed[ MAX_STRING_CHARS ];
+ const char *wrapped;
+ static int maxWidth = (int) ((2.0/3.0) * (double) SCREEN_WIDTH );
+
+ Q_ParseNewlines( newlineParsed, str, sizeof( newlineParsed ) );
+
+ wrapped = Item_Text_Wrap( newlineParsed, 0.5, maxWidth );
- Q_strncpyz( cg.centerPrint, str, sizeof( cg.centerPrint ) );
+ Q_strncpyz( cg.centerPrint, wrapped, sizeof( cg.centerPrint ) );
cg.centerPrintTime = cg.time;
cg.centerPrintY = y;
@@ -2733,9 +2743,9 @@ static void CG_DrawCenterString( void )
while( 1 )
{
- char linebuffer[ 1024 ];
+ char linebuffer[ MAX_STRING_CHARS ];
- for( l = 0; l < 50; l++ )
+ for( l = 0; l < sizeof(linebuffer) - 1; l++ )
{
if( !start[ l ] || start[ l ] == '\n' )
break;
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index f7dda861..a3a5535f 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1024,7 +1024,7 @@ typedef struct
int centerPrintTime;
int centerPrintCharWidth;
int centerPrintY;
- char centerPrint[ 1024 ];
+ char centerPrint[ MAX_STRING_CHARS ];
int centerPrintLines;
// low ammo warning state