[iortcw] 260/497: All: Fix negative glyph index in text functions

Simon McVittie smcv at debian.org
Fri Sep 8 10:37:03 UTC 2017


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to annotated tag 1.42d
in repository iortcw.

commit 5752a54ba1727c8644027a46b90f1ce8373456ef
Author: M4N4T4RMS at gmail.com <M4N4T4RMS at gmail.com@e65d2741-a53d-b2dc-ae96-bb75fa5e4c4a>
Date:   Thu Dec 4 00:58:57 2014 +0000

    All: Fix negative glyph index in text functions
---
 MP/code/cgame/cg_draw.c    |  6 +++---
 MP/code/cgame/cg_newdraw.c |  2 +-
 MP/code/ui/ui_main.c       | 18 +++++++++---------
 SP/code/cgame/cg_draw.c    |  6 +++---
 SP/code/cgame/cg_newdraw.c |  2 +-
 SP/code/ui/ui_main.c       | 14 +++++++-------
 6 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/MP/code/cgame/cg_draw.c b/MP/code/cgame/cg_draw.c
index 9107bd6..9630850 100644
--- a/MP/code/cgame/cg_draw.c
+++ b/MP/code/cgame/cg_draw.c
@@ -83,7 +83,7 @@ int CG_Text_Width( const char *text, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &font->glyphs[(int)*s];
+				glyph = &font->glyphs[*s & 255];
 				out += glyph->xSkip;
 				s++;
 				count++;
@@ -118,7 +118,7 @@ int CG_Text_Height( const char *text, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &font->glyphs[(int)*s];
+				glyph = &font->glyphs[*s & 255];
 				if ( max < glyph->height ) {
 					max = glyph->height;
 				}
@@ -163,7 +163,7 @@ void CG_Text_Paint( float x, float y, float scale, vec4_t color, const char *tex
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			glyph = &font->glyphs[(int)*s];
+			glyph = &font->glyphs[*s & 255];
 			//int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
 			//float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
 			if ( Q_IsColorString( s ) ) {
diff --git a/MP/code/cgame/cg_newdraw.c b/MP/code/cgame/cg_newdraw.c
index 542d0ed..f30895e 100644
--- a/MP/code/cgame/cg_newdraw.c
+++ b/MP/code/cgame/cg_newdraw.c
@@ -1874,7 +1874,7 @@ static void CG_Text_Paint_Limit( float *maxX, float x, float y, float scale, vec
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			glyph = &font->glyphs[(unsigned char)*s];           // NERVE - SMF - this needs to be an unsigned cast for localization
+			glyph = &font->glyphs[*s & 255];
 			if ( Q_IsColorString( s ) ) {
 				memcpy( newColor, g_color_table[ColorIndex( *( s + 1 ) )], sizeof( newColor ) );
 				newColor[3] = color[3];
diff --git a/MP/code/ui/ui_main.c b/MP/code/ui/ui_main.c
index 233d1ee..4185249 100644
--- a/MP/code/ui/ui_main.c
+++ b/MP/code/ui/ui_main.c
@@ -482,7 +482,7 @@ int Text_Width( const char *text, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &font->glyphs[(unsigned char)*s];           // NERVE - SMF - this needs to be an unsigned cast for localization
+				glyph = &font->glyphs[*s & 255];
 				out += glyph->xSkip;
 				s++;
 				count++;
@@ -517,7 +517,7 @@ int Text_Height( const char *text, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &font->glyphs[(unsigned char)*s];           // NERVE - SMF - this needs to be an unsigned cast for localization
+				glyph = &font->glyphs[*s & 255];
 				if ( max < glyph->height ) {
 					max = glyph->height;
 				}
@@ -580,7 +580,7 @@ void Text_Paint( float x, float y, float scale, vec4_t color, const char *text,
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			index = (unsigned char)*s;
+			index = *s;
 
 			// NERVE - SMF - don't draw tabs and newlines
 			if ( index < 20 ) {
@@ -589,7 +589,7 @@ void Text_Paint( float x, float y, float scale, vec4_t color, const char *text,
 				continue;
 			}
 
-			glyph = &font->glyphs[index];           // NERVE - SMF - this needs to be an unsigned cast for localization
+			glyph = &font->glyphs[index & 255];
 			if ( Q_IsColorString( s ) ) {
 				memcpy( newColor, g_color_table[ColorIndex( *( s + 1 ) )], sizeof( newColor ) );
 				newColor[3] = color[3];
@@ -685,7 +685,7 @@ char* Text_AutoWrap_Paint_Chunk( float x, float y, int width, float scale, vec4_
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			index = (unsigned char)*s;
+			index = *s;
 			if ( *s == ' ' || *s == '\t' || *s == '\n' ) {
 				wrap_point = s;
 			}
@@ -697,7 +697,7 @@ char* Text_AutoWrap_Paint_Chunk( float x, float y, int width, float scale, vec4_
 				continue;
 			}
 
-			glyph = &font->glyphs[index];           // NERVE - SMF - this needs to be an unsigned cast for localization
+			glyph = &font->glyphs[index & 255];
 			if ( Q_IsColorString( s ) ) {
 				memcpy( newColor, g_color_table[ColorIndex( *( s + 1 ) )], sizeof( newColor ) );
 				newColor[3] = color[3];
@@ -844,9 +844,9 @@ void Text_PaintWithCursor( float x, float y, float scale, vec4_t color, const ch
 			len = limit;
 		}
 		count = 0;
-		glyph2 = &font->glyphs[(unsigned char)cursor];
+		glyph2 = &font->glyphs[cursor & 255];
 		while ( s && *s && count < len ) {
-			glyph = &font->glyphs[(unsigned char)*s];           // NERVE - SMF - this needs to be an unsigned cast for localization
+			glyph = &font->glyphs[*s & 255];
 			//int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
 			//float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
 			if ( Q_IsColorString( s ) ) {
@@ -965,7 +965,7 @@ static void Text_Paint_Limit( float *maxX, float x, float y, float scale, vec4_t
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			glyph = &font->glyphs[(unsigned char)*s];           // NERVE - SMF - this needs to be an unsigned cast for localization
+			glyph = &font->glyphs[*s & 255];
 			if ( Q_IsColorString( s ) ) {
 				memcpy( newColor, g_color_table[ColorIndex( *( s + 1 ) )], sizeof( newColor ) );
 				newColor[3] = color[3];
diff --git a/SP/code/cgame/cg_draw.c b/SP/code/cgame/cg_draw.c
index 5009433..5248205 100644
--- a/SP/code/cgame/cg_draw.c
+++ b/SP/code/cgame/cg_draw.c
@@ -88,7 +88,7 @@ int CG_Text_Width( const char *text, int font, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &fnt->glyphs[(int)*s];
+				glyph = &fnt->glyphs[*s & 255];
 				out += glyph->xSkip;
 				s++;
 				count++;
@@ -133,7 +133,7 @@ int CG_Text_Height( const char *text, int font, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &fnt->glyphs[(int)*s];
+				glyph = &fnt->glyphs[*s & 255];
 				if ( max < glyph->height ) {
 					max = glyph->height;
 				}
@@ -188,7 +188,7 @@ void CG_Text_Paint( float x, float y, int font, float scale, vec4_t color, const
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			glyph = &fnt->glyphs[(int)*s];
+			glyph = &fnt->glyphs[*s & 255];
 			//int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
 			//float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
 			if ( Q_IsColorString( s ) ) {
diff --git a/SP/code/cgame/cg_newdraw.c b/SP/code/cgame/cg_newdraw.c
index 6e5b01a..5a57b92 100644
--- a/SP/code/cgame/cg_newdraw.c
+++ b/SP/code/cgame/cg_newdraw.c
@@ -1813,7 +1813,7 @@ static void CG_Text_Paint_Limit( float *maxX, float x, float y, int font, float
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			glyph = &fnt->glyphs[(unsigned char)*s];
+			glyph = &fnt->glyphs[*s & 255];
 			if ( Q_IsColorString( s ) ) {
 				memcpy( newColor, g_color_table[ColorIndex( *( s + 1 ) )], sizeof( newColor ) );
 				newColor[3] = color[3];
diff --git a/SP/code/ui/ui_main.c b/SP/code/ui/ui_main.c
index e3a3ecb..172055c 100644
--- a/SP/code/ui/ui_main.c
+++ b/SP/code/ui/ui_main.c
@@ -317,7 +317,7 @@ int Text_Width( const char *text, int font, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &fnt->glyphs[(unsigned char)*s];
+				glyph = &fnt->glyphs[*s & 255];
 				out += glyph->xSkip;
 				s++;
 				count++;
@@ -362,7 +362,7 @@ int Text_Height( const char *text, int font, float scale, int limit ) {
 				s += 2;
 				continue;
 			} else {
-				glyph = &fnt->glyphs[(unsigned char)*s];
+				glyph = &fnt->glyphs[*s & 255];
 				if ( max < glyph->height ) {
 					max = glyph->height;
 				}
@@ -414,7 +414,7 @@ void Text_Paint( float x, float y, int font, float scale, vec4_t color, const ch
 		}
 		count = 0;
 		while ( s && *s && count < len ) {
-			glyph = &fnt->glyphs[(unsigned char)*s];
+			glyph = &fnt->glyphs[*s & 255];
 			//int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
 			//float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
 			if ( Q_IsColorString( s ) ) {
@@ -494,9 +494,9 @@ void Text_PaintWithCursor( float x, float y, int font, float scale, vec4_t color
 			len = limit;
 		}
 		count = 0;
-		glyph2 = &fnt->glyphs[(unsigned char)cursor];
+		glyph2 = &fnt->glyphs[cursor & 255];
 		while ( s && *s && count < len ) {
-			glyph = &fnt->glyphs[(unsigned char)*s];
+			glyph = &fnt->glyphs[*s & 255];
 			//int yadj = Assets.textFont.glyphs[text[i]].bottom + Assets.textFont.glyphs[text[i]].top;
 			//float yadj = scale * (Assets.textFont.glyphs[text[i]].imageHeight - Assets.textFont.glyphs[text[i]].height);
 			if ( Q_IsColorString( s ) ) {
@@ -583,7 +583,7 @@ static void Text_Paint_Limit(float *maxX, float x, float y, int font, float scal
 	vec4_t newColor;
 	glyphInfo_t *glyph;
 	if (text) {
-		const unsigned char *s = text;
+		const char *s = text;
 		float max = *maxX;
 		float useScale;
 
@@ -610,7 +610,7 @@ static void Text_Paint_Limit(float *maxX, float x, float y, int font, float scal
 		}
 		count = 0;
 		while (s && *s && count < len) {
-			glyph = &fnt->glyphs[*s];
+			glyph = &fnt->glyphs[*s & 255];
 			if ( Q_IsColorString( s ) ) {
 				memcpy( newColor, g_color_table[ColorIndex(*(s+1))], sizeof( newColor ) );
 				newColor[3] = color[3];

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git



More information about the Pkg-games-commits mailing list