diff --git a/src/g_shared/sbarinfo_display.cpp b/src/g_shared/sbarinfo_display.cpp index 3eebc16abb..c141d547b4 100644 --- a/src/g_shared/sbarinfo_display.cpp +++ b/src/g_shared/sbarinfo_display.cpp @@ -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; diff --git a/src/resourcefiles/ancientzip.cpp b/src/resourcefiles/ancientzip.cpp index 5c26fca776..cb9479de80 100644 --- a/src/resourcefiles/ancientzip.cpp +++ b/src/resourcefiles/ancientzip.cpp @@ -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 &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 &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 &decoder) diff --git a/src/resourcefiles/ancientzip.h b/src/resourcefiles/ancientzip.h index a85e430d8d..c9e15c9906 100644 --- a/src/resourcefiles/ancientzip.h +++ b/src/resourcefiles/ancientzip.h @@ -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 LiteralDecoder; - TArray DistanceDecoder; - TArray LengthDecoder; - unsigned char ReadBuf[256]; - unsigned int bs, be; - - static int STACK_ARGS buildercmp(const void *a, const void *b); + + TArray LiteralDecoder; + TArray DistanceDecoder; + TArray LengthDecoder; + unsigned char ReadBuf[256]; + unsigned int bs, be; + + static int STACK_ARGS buildercmp(const void *a, const void *b); void InsertCode(TArray &decoder, unsigned int pos, int bits, unsigned short code, int len, unsigned char value); unsigned int InitTable(TArray &decoder, int numspots); - int BuildDecoder(TArray &decoder, TableBuilder *values, int numvals); - int DecodeSFValue(const TArray ¤tTree); - int DecodeSF(TArray &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 &decoder, TableBuilder *values, int numvals); + int DecodeSFValue(const TArray ¤tTree); + int DecodeSF(TArray &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); \ No newline at end of file