From 8f7dd16ac3eb8399b3dc40436eaee60d414a00c5 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Wed, 3 Aug 2022 13:17:27 +0100 Subject: [PATCH] Show an error on outdated devilutionx/font.mpq --- Source/diablo.cpp | 16 ++++++++++++++++ Source/engine/render/text_render.cpp | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/Source/diablo.cpp b/Source/diablo.cpp index 762387144..abf37e86a 100644 --- a/Source/diablo.cpp +++ b/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() diff --git a/Source/engine/render/text_render.cpp b/Source/engine/render/text_render.cpp index 60b000138..9149ab6b4 100644 --- a/Source/engine/render/text_render.cpp +++ b/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;