Browse Source

Show an error on outdated devilutionx/font.mpq

pull/5186/head
Gleb Mazovetskiy 4 years ago committed by Anders Jenbo
parent
commit
8f7dd16ac3
  1. 16
      Source/diablo.cpp
  2. 11
      Source/engine/render/text_render.cpp

16
Source/diablo.cpp

@ -944,6 +944,20 @@ void SetApplicationVersions()
*BufCopy(gszVersionNumber, "version ", PROJECT_VERSION) = '\0';
}
void CheckArchivesUpToDate()
{
const bool devilutionxMpqOutOfDate = devilutionx_mpq && devilutionx_mpq->HasFile("fonts\\12-00.pcx");
const bool fontsMpqOutOfDate = font_mpq && font_mpq->HasFile("fonts\\12-4e.pcx");
if (devilutionxMpqOutOfDate && fontsMpqOutOfDate) {
app_fatal(_("Please update devilutionx.mpq and fonts.mpq to the latest version"));
} else if (devilutionxMpqOutOfDate) {
app_fatal(_("Please update devilutionx.mpq to the latest version"));
} else if (fontsMpqOutOfDate) {
app_fatal(_("Please update fonts.mpq to the latest version"));
}
}
void DiabloInit()
{
if (*sgOptions.Graphics.showFPS)
@ -1003,6 +1017,8 @@ void DiabloInit()
// Always available.
LoadSmallSelectionSpinner();
CheckArchivesUpToDate();
}
void DiabloSplash()

11
Source/engine/render/text_render.cpp

@ -19,6 +19,7 @@
#include "engine/load_cel.hpp"
#include "engine/load_clx.hpp"
#include "engine/load_file.hpp"
#include "engine/load_pcx.hpp"
#include "engine/palette.h"
#include "engine/point.hpp"
#include "engine/render/clx_render.hpp"
@ -198,6 +199,16 @@ const OwnedClxSpriteList *LoadFont(GameFontTables size, text_color color, uint16
OptionalOwnedClxSpriteList &font = Fonts[fontId];
font = LoadOptionalClx(path);
if (!font) {
// Could be an old devilutionx.mpq or fonts.mpq with PCX instead of CLX.
//
// We'll show an error elsewhere (in `CheckArchivesUpToDate`) and we need to load
// the font files to display it.
char pcxPath[32];
GetFontPath(size, row, "pcx", &pcxPath[0]);
font = LoadPcxSpriteList(pcxPath, /*numFramesOrFrameHeight=*/256, /*transparentColor=*/1);
}
if (!font) {
LogError("Error loading font: {}", path);
return nullptr;

Loading…
Cancel
Save