Ahhh, TWHL, I need help (again for the 100th time.)
Today I have this function here (DrawHudStringReverse). It involves redrawing the HUD when you pick up something or another.
[quote]// draws a string from right to left (right-aligned)
int CHud :: DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b )
{
// find the end of the string
for ( char *szIt = szString; *szIt != 0; szIt++ )
{ // we should count the length?
}
[u][blue]char[/blue] *szIt;[green]// AMMO FAIL ? I put this in[/green][/u]
// iterate throug the string in reverse
for ( szIt--; szIt != (szString-1); szIt-- )
{
int next = xpos - gHUD.m_scrinfo.charWidths[ *szIt ]; // variable-width fonts look cool
if ( next < iMinX )
return xpos;
xpos = next;
TextMessageDrawChar( xpos, ypos, *szIt, r, g, b );
}
return xpos;
}[/quote]
So the problem is this: By default, the line that is underlined above does not exist. However, running it straight on in 2008 express causes the problem "szIt is undeclared" to appear in the subsequent for loop. So I added the underlined line to maybe fix the problem. Guess what happens?
Every time I pick up ammo, instead of a number like (8 shells) my HUD shows a Japanese symbol or something. So if I pick up ammo_buckshot it displays (Japanese Symbol) shells. If I pick up handgrenades it says I got (Japanese Symbol) grenades. You get the idea.
Sooo... how to fix this?
(P.S. if you noticed there's an empty for loop. Weird crap like this appear often in the codebase and the comments show alot of valve's dissatisfaction with the code and using "sleazy" coding. Boo.)
(P.P.S. If drawing a right-aligned text is this difficult for them then Microsoft word would go out of business..)