SBARINFO patch:

- Fixed: SBarInfo's string drawing sometimes used the wrong variable.

SVN r1594 (trunk)
This commit is contained in:
Randy Heit 2009-05-20 01:42:47 +00:00
parent 2e87ebff22
commit b7dab65754
3 changed files with 82 additions and 82 deletions

View File

@ -1521,7 +1521,7 @@ void DSBarInfo::DrawString(const char* str, SBarInfoCoordinate x, SBarInfoCoordi
{
if(*str == ' ')
{
x += drawingFont->GetSpaceWidth();
ax += drawingFont->GetSpaceWidth();
str++;
continue;
}
@ -1537,7 +1537,7 @@ void DSBarInfo::DrawString(const char* str, SBarInfoCoordinate x, SBarInfoCoordi
continue;
}
if(script->spacingCharacter == '\0') //If we are monospaced lets use the offset
x += (character->LeftOffset+1); //ignore x offsets since we adapt to character size
ax += (character->LeftOffset+1); //ignore x offsets since we adapt to character size
int rx, ry, rw, rh;
rx = ax + xOffset;

View File

@ -79,9 +79,9 @@
DROPBITS(a); \
} while (0)
/****************************************************************
Shannon-Fano tree routines
****************************************************************/
/****************************************************************
Shannon-Fano tree routines
****************************************************************/
static const unsigned char BitReverse4[] = {
0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e,
@ -146,42 +146,42 @@ int STACK_ARGS FZipExploder::buildercmp(const void *a, const void *b)
return d;
}
int FZipExploder::BuildDecoder(TArray<HuffNode> &decoder, TableBuilder *values, int numvals)
{
int i;
qsort(values, numvals, sizeof(*values), buildercmp);
// Generate the Shannon-Fano tree:
unsigned short code = 0;
unsigned short code_increment = 0;
unsigned short last_bit_length = 0;
for (i = numvals - 1; i >= 0; --i)
{
code += code_increment;
if (values[i].Length != last_bit_length)
{
last_bit_length = values[i].Length;
code_increment = 1 << (16 - last_bit_length);
}
// Reverse the order of the bits in the code before storing it.
values[i].Code = BitReverse4[code >> 12] |
(BitReverse4[(code >> 8) & 0xf] << 4) |
(BitReverse4[(code >> 4) & 0xf] << 8) |
(BitReverse4[code & 0xf] << 12);
}
// Insert each code into the hierarchical table. The top level is FIRST_BIT_LEN bits,
// and the other levels are REST_BIT_LEN bits. If a code does not completely fill
// a level, every permutation for the remaining bits is filled in to
// match this one.
InitTable(decoder, 1 << FIRST_BIT_LEN); // Set up the top level.
for (i = 0; i < numvals; ++i)
{
InsertCode(decoder, 0, FIRST_BIT_LEN, values[i].Code, values[i].Length, values[i].Value);
}
return 0;
}
int FZipExploder::BuildDecoder(TArray<HuffNode> &decoder, TableBuilder *values, int numvals)
{
int i;
qsort(values, numvals, sizeof(*values), buildercmp);
// Generate the Shannon-Fano tree:
unsigned short code = 0;
unsigned short code_increment = 0;
unsigned short last_bit_length = 0;
for (i = numvals - 1; i >= 0; --i)
{
code += code_increment;
if (values[i].Length != last_bit_length)
{
last_bit_length = values[i].Length;
code_increment = 1 << (16 - last_bit_length);
}
// Reverse the order of the bits in the code before storing it.
values[i].Code = BitReverse4[code >> 12] |
(BitReverse4[(code >> 8) & 0xf] << 4) |
(BitReverse4[(code >> 4) & 0xf] << 8) |
(BitReverse4[code & 0xf] << 12);
}
// Insert each code into the hierarchical table. The top level is FIRST_BIT_LEN bits,
// and the other levels are REST_BIT_LEN bits. If a code does not completely fill
// a level, every permutation for the remaining bits is filled in to
// match this one.
InitTable(decoder, 1 << FIRST_BIT_LEN); // Set up the top level.
for (i = 0; i < numvals; ++i)
{
InsertCode(decoder, 0, FIRST_BIT_LEN, values[i].Code, values[i].Length, values[i].Value);
}
return 0;
}
int FZipExploder::DecodeSFValue(const TArray<HuffNode> &decoder)

View File

@ -1,50 +1,50 @@
#include "files.h"
#include "doomerrors.h"
class FZipExploder
{
unsigned int Hold, Bits;
FileReader *In;
unsigned int InLeft;
/****************************************************************
Shannon-Fano tree structures, variables and related routines
****************************************************************/
struct HuffNode
{
unsigned char Value;
unsigned char Length;
unsigned short ChildTable;
};
#include "files.h"
#include "doomerrors.h"
class FZipExploder
{
unsigned int Hold, Bits;
FileReader *In;
unsigned int InLeft;
/****************************************************************
Shannon-Fano tree structures, variables and related routines
****************************************************************/
struct HuffNode
{
unsigned char Value;
unsigned char Length;
unsigned short ChildTable;
};
struct TableBuilder
{
unsigned char Value;
unsigned char Length;
unsigned short Code;
};
TArray<HuffNode> LiteralDecoder;
TArray<HuffNode> DistanceDecoder;
TArray<HuffNode> LengthDecoder;
unsigned char ReadBuf[256];
unsigned int bs, be;
static int STACK_ARGS buildercmp(const void *a, const void *b);
TArray<HuffNode> LiteralDecoder;
TArray<HuffNode> DistanceDecoder;
TArray<HuffNode> LengthDecoder;
unsigned char ReadBuf[256];
unsigned int bs, be;
static int STACK_ARGS buildercmp(const void *a, const void *b);
void InsertCode(TArray<HuffNode> &decoder, unsigned int pos, int bits, unsigned short code, int len, unsigned char value);
unsigned int InitTable(TArray<HuffNode> &decoder, int numspots);
int BuildDecoder(TArray<HuffNode> &decoder, TableBuilder *values, int numvals);
int DecodeSFValue(const TArray<HuffNode> &currentTree);
int DecodeSF(TArray<HuffNode> &decoder, int numvals);
public:
int Explode(unsigned char *out, unsigned int outsize, FileReader *in, unsigned int insize, int flags);
};
class CExplosionError : CRecoverableError
{
public:
CExplosionError(const char *message) : CRecoverableError(message) {}
};
int BuildDecoder(TArray<HuffNode> &decoder, TableBuilder *values, int numvals);
int DecodeSFValue(const TArray<HuffNode> &currentTree);
int DecodeSF(TArray<HuffNode> &decoder, int numvals);
public:
int Explode(unsigned char *out, unsigned int outsize, FileReader *in, unsigned int insize, int flags);
};
class CExplosionError : CRecoverableError
{
public:
CExplosionError(const char *message) : CRecoverableError(message) {}
};
int ShrinkLoop(unsigned char *out, unsigned int outsize, FileReader *in, unsigned int insize);