Skip to content

Commit

Permalink
fix(scummfont): Fix scummfont on most 64-bit systems
Browse files Browse the repository at this point in the history
Don't treat "long" as a 32-bit wide value, this is wrong on most 64-bit systems
(except for Windows).
  • Loading branch information
dwatteau committed Nov 28, 2020
1 parent b73d653 commit ca2fca7
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ScummFont/scummfont.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ static int usage()
return 0;
}

static void getFontInfo(long &baseOffset, std::ifstream &file, int &version, int &bpp,
static void getFontInfo(int &baseOffset, std::ifstream &file, int &version, int &bpp,
int &maxHeight, int &maxWidth, int &bytesPerChar, short &numChars)
{
int i;
long tag;
int tag;
int lineSpacing;

lineSpacing = 0;
Expand Down Expand Up @@ -170,7 +170,7 @@ static void getFontInfo(long &baseOffset, std::ifstream &file, int &version, int
maxWidth = maxHeight = 0;
for (i = 0; i < numChars; ++i)
{
long offset;
int offset;
int width, height;

#ifdef SCUMMFONT_MAKETABLE
Expand Down Expand Up @@ -206,7 +206,7 @@ static void getFontInfo(long &baseOffset, std::ifstream &file, int &version, int
if (maxHeight < lineSpacing)
maxHeight = lineSpacing;
}
if ((unsigned)bytesPerChar < 8 || bpp == 0 || bpp == 3 || (unsigned)bpp > 4
if ((unsigned int)bytesPerChar < 8 || bpp == 0 || bpp == 3 || (unsigned int)bpp > 4
|| (unsigned short)numChars > 0x100 || maxHeight < 0 || maxWidth < 0)
throw std::runtime_error("Your font is strange...");
}
Expand Down Expand Up @@ -312,7 +312,7 @@ static void saveFont(const char *path)
int i, j, k, version, bpp, maxHeight, maxWidth, bytesPerChar;
short numChars;
int newNumChars;
long baseOffset, endOffset;
int baseOffset, endOffset;

if (!file.is_open())
throw std::runtime_error("Cannot open font file");
Expand Down Expand Up @@ -379,7 +379,7 @@ static void saveFont(const char *path)
}
else
{
long offset;
int offset;
int x, y;

if (width != 0 && height != 0)
Expand Down Expand Up @@ -477,7 +477,7 @@ static void loadFont(const char *path)
std::ifstream file(path, std::ios::in | std::ios::binary);
int i, j, k, version, bpp, maxHeight, maxWidth, bytesPerChar;
short numChars;
long baseOffset;
int baseOffset;

if (!file.is_open())
throw std::runtime_error("Cannot open font file");
Expand Down Expand Up @@ -527,7 +527,7 @@ static void loadFont(const char *path)
}
else
{
long offset;
int offset;

file.seekg(baseOffset + 0x19 + i * 4, std::ios::beg);
file.read((char *)&offset, 4);
Expand Down

0 comments on commit ca2fca7

Please sign in to comment.