summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgame/cg_draw.c18
-rw-r--r--src/cgame/cg_local.h2
-rw-r--r--src/qcommon/q_shared.c7
-rw-r--r--src/qcommon/q_shared.h2
-rw-r--r--src/ui/ui_shared.c2
-rw-r--r--src/ui/ui_shared.h1
6 files changed, 26 insertions, 6 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
diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c
index 5b74badd..6da13ad0 100644
--- a/src/qcommon/q_shared.c
+++ b/src/qcommon/q_shared.c
@@ -935,6 +935,13 @@ int Q_CountChar(const char *string, char tocount)
return count;
}
+void Q_ParseNewlines( char *dest, const char *src, int destsize )
+{
+ for( ; *src && destsize > 1; src++, destsize-- )
+ *dest++ = ( ( *src == '\\' && *( ++src ) == 'n' ) ? '\n' : *src );
+ *dest++ = '\0';
+}
+
void QDECL Com_sprintf( char *dest, int size, const char *fmt, ...) {
int len;
va_list argptr;
diff --git a/src/qcommon/q_shared.h b/src/qcommon/q_shared.h
index 5aaf0878..34f3e471 100644
--- a/src/qcommon/q_shared.h
+++ b/src/qcommon/q_shared.h
@@ -791,6 +791,8 @@ void Q_strcat( char *dest, int size, const char *src );
int Q_PrintStrlen( const char *string );
// removes color sequences from string
char *Q_CleanStr( char *string );
+// parse "\n" into '\n'
+void Q_ParseNewlines( char *dest, const char *src, int destsize );
// Count the number of char tocount encountered in string
int Q_CountChar(const char *string, char tocount);
diff --git a/src/ui/ui_shared.c b/src/ui/ui_shared.c
index 81bc360d..28eb8758 100644
--- a/src/ui/ui_shared.c
+++ b/src/ui/ui_shared.c
@@ -4527,7 +4527,7 @@ void Item_TextColor( itemDef_t *item, vec4_t *newColor )
}
}
-static const char *Item_Text_Wrap( const char *text, float scale, float width )
+const char *Item_Text_Wrap( const char *text, float scale, float width )
{
static char out[ 8192 ] = "";
char *paint = out;
diff --git a/src/ui/ui_shared.h b/src/ui/ui_shared.h
index a42d2c41..dec93587 100644
--- a/src/ui/ui_shared.h
+++ b/src/ui/ui_shared.h
@@ -509,6 +509,7 @@ void Controls_SetDefaults( void );
//for cg_draw.c
void Item_Text_Wrapped_Paint( itemDef_t *item );
+const char *Item_Text_Wrap( const char *text, float scale, float width );
void UI_DrawTextBlock( rectDef_t *rect, float text_x, float text_y, vec4_t color,
float scale, int textalign, int textvalign,
int textStyle, const char *text );