aboutsummaryrefslogtreecommitdiffstats
path: root/code/qcommon/q_shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'code/qcommon/q_shared.c')
-rw-r--r--code/qcommon/q_shared.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/code/qcommon/q_shared.c b/code/qcommon/q_shared.c
index 2100390..de54e17 100644
--- a/code/qcommon/q_shared.c
+++ b/code/qcommon/q_shared.c
@@ -918,6 +918,26 @@ char * QDECL va( char *format, ... ) {
return buf;
}
+/*
+============
+Com_TruncateLongString
+
+Assumes buffer is atleast TRUNCATE_LENGTH big
+============
+*/
+void Com_TruncateLongString( char *buffer, const char *s )
+{
+ int length = strlen( s );
+
+ if( length <= TRUNCATE_LENGTH )
+ Q_strncpyz( buffer, s, TRUNCATE_LENGTH );
+ else
+ {
+ Q_strncpyz( buffer, s, ( TRUNCATE_LENGTH / 2 ) - 3 );
+ Q_strcat( buffer, TRUNCATE_LENGTH, " ... " );
+ Q_strcat( buffer, TRUNCATE_LENGTH, s + length - ( TRUNCATE_LENGTH / 2 ) + 3 );
+ }
+}
/*
=====================================================================