Skip to content

Commit

Permalink
- fixed the usedcolor array's base type.
Browse files Browse the repository at this point in the history
The usedcolors array which counts the number of pixels in a given color in a font used bytes as storage, so any color that just happened to have a count that is a multiple of 256 the color was considered not present.
  • Loading branch information
coelckers committed Feb 22, 2019
1 parent 3d4b5ae commit e06aa28
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/gamedata/fonts/font.cpp
Expand Up @@ -471,7 +471,7 @@ FFont *FFont::FindFont (FName name)
//
//==========================================================================

void RecordTextureColors (FImageSource *pic, uint8_t *usedcolors)
void RecordTextureColors (FImageSource *pic, uint32_t *usedcolors)
{
int x;

Expand Down Expand Up @@ -524,7 +524,7 @@ static int compare (const void *arg1, const void *arg2)
//
//==========================================================================

int FFont::SimpleTranslation (uint8_t *colorsused, uint8_t *translation, uint8_t *reverse, TArray<double> &Luminosity)
int FFont::SimpleTranslation (uint32_t *colorsused, uint8_t *translation, uint8_t *reverse, TArray<double> &Luminosity)
{
double min, max, diver;
int i, j;
Expand Down Expand Up @@ -889,10 +889,10 @@ int FFont::StringWidth(const uint8_t *string) const
void FFont::LoadTranslations()
{
unsigned int count = LastChar - FirstChar + 1;
uint8_t usedcolors[256], identity[256];
uint32_t usedcolors[256] = {};
uint8_t identity[256];
TArray<double> Luminosity;

memset (usedcolors, 0, 256);
for (unsigned int i = 0; i < count; i++)
{
if (Chars[i].TranslatedPic)
Expand Down
2 changes: 1 addition & 1 deletion src/gamedata/fonts/fontinternals.h
Expand Up @@ -39,6 +39,6 @@ extern uint16_t upperforlower[65536];

class FImageSource;

void RecordTextureColors (FImageSource *pic, uint8_t *usedcolors);
void RecordTextureColors (FImageSource *pic, uint32_t *usedcolors);
bool myislower(int code);
int stripaccent(int code);
4 changes: 2 additions & 2 deletions src/gamedata/fonts/specialfont.cpp
Expand Up @@ -153,12 +153,12 @@ FSpecialFont::FSpecialFont (const char *name, int first, int count, FTexture **l
void FSpecialFont::LoadTranslations()
{
int count = LastChar - FirstChar + 1;
uint8_t usedcolors[256], identity[256];
uint32_t usedcolors[256] = {};
uint8_t identity[256];
TArray<double> Luminosity;
int TotalColors;
int i, j;

memset (usedcolors, 0, 256);
for (i = 0; i < count; i++)
{
if (Chars[i].TranslatedPic)
Expand Down
1 change: 0 additions & 1 deletion src/gamedata/fonts/v_font.cpp
Expand Up @@ -63,7 +63,6 @@
#define DEFAULT_LOG_COLOR PalEntry(223,223,223)

// TYPES -------------------------------------------------------------------
void RecordTextureColors (FImageSource *pic, uint8_t *colorsused);

// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/gamedata/fonts/v_font.h
Expand Up @@ -114,7 +114,7 @@ class FFont
const void *ranges, int total_colors, const PalEntry *palette);
void FixXMoves();

static int SimpleTranslation (uint8_t *colorsused, uint8_t *translation,
static int SimpleTranslation (uint32_t *colorsused, uint8_t *translation,
uint8_t *identity, TArray<double> &Luminosity);

void ReadSheetFont(TArray<FolderEntry> &folderdata, int width, int height, const DVector2 &Scale);
Expand Down

0 comments on commit e06aa28

Please sign in to comment.