|
@@ -18,12 +18,14 @@
|
|
|
#include "core/bitmath_func.hpp"
|
|
|
#include <string.h>
|
|
|
#include "settings_type.h"
|
|
|
|
|
|
#include "table/sprites.h"
|
|
|
|
|
|
Palette _use_palette = PAL_AUTODETECT;
|
|
|
|
|
|
struct MD5File {
|
|
|
const char * filename; ///< filename
|
|
|
uint8 hash[16]; ///< md5 sum of the file
|
|
|
};
|
|
|
|
|
|
struct FileList {
|
|
@@ -127,30 +129,30 @@ static bool FileMD5(const MD5File file)
|
|
|
* - all DOS files present -> DOS palette
|
|
|
* - no Windows files present and any DOS file present -> DOS palette
|
|
|
* - otherwise -> Windows palette
|
|
|
*/
|
|
|
static void DeterminePalette()
|
|
|
{
|
|
|
if (_use_dos_palette) return;
|
|
|
if (_use_palette < MAX_PAL) return;
|
|
|
|
|
|
/* Count of files from the different versions. */
|
|
|
uint dos = 0;
|
|
|
uint win = 0;
|
|
|
|
|
|
for (uint i = 0; i < lengthof(files_dos.basic); i++) if (FioCheckFileExists(files_dos.basic[i].filename)) dos++;
|
|
|
for (uint i = 0; i < lengthof(files_dos.landscape); i++) if (FioCheckFileExists(files_dos.landscape[i].filename)) dos++;
|
|
|
|
|
|
for (uint i = 0; i < lengthof(files_win.basic); i++) if (FioCheckFileExists(files_win.basic[i].filename)) win++;
|
|
|
for (uint i = 0; i < lengthof(files_win.landscape); i++) if (FioCheckFileExists(files_win.landscape[i].filename)) win++;
|
|
|
|
|
|
if (win == 5) {
|
|
|
_use_dos_palette = false;
|
|
|
_use_palette = PAL_WINDOWS;
|
|
|
} else if (dos == 5 || (win == 0 && dos > 0)) {
|
|
|
_use_dos_palette = true;
|
|
|
_use_palette = PAL_DOS;
|
|
|
} else {
|
|
|
_use_dos_palette = false;
|
|
|
_use_palette = PAL_WINDOWS;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Checks whether the MD5 checksums of the files are correct.
|
|
|
*
|
|
@@ -158,13 +160,13 @@ static void DeterminePalette()
|
|
|
*/
|
|
|
void CheckExternalFiles()
|
|
|
{
|
|
|
DeterminePalette();
|
|
|
|
|
|
static const size_t ERROR_MESSAGE_LENGTH = 128;
|
|
|
const FileList *files = _use_dos_palette ? &files_dos : &files_win;
|
|
|
const FileList *files = (_use_palette == PAL_DOS) ? &files_dos : &files_win;
|
|
|
char error_msg[ERROR_MESSAGE_LENGTH * (lengthof(files->basic) + lengthof(files->landscape) + 3)];
|
|
|
error_msg[0] = '\0';
|
|
|
char *add_pos = error_msg;
|
|
|
|
|
|
for (uint i = 0; i < lengthof(files->basic); i++) {
|
|
|
if (!FileMD5(files->basic[i])) {
|
|
@@ -189,13 +191,13 @@ void CheckExternalFiles()
|
|
|
if (add_pos != error_msg) ShowInfoF(error_msg);
|
|
|
}
|
|
|
|
|
|
|
|
|
static void LoadSpriteTables()
|
|
|
{
|
|
|
const FileList *files = _use_dos_palette ? &files_dos : &files_win;
|
|
|
const FileList *files = (_use_palette == PAL_DOS) ? &files_dos : &files_win;
|
|
|
uint i = FIRST_GRF_SLOT;
|
|
|
|
|
|
LoadGrfFile(files->basic[0].filename, 0, i++);
|
|
|
|
|
|
/*
|
|
|
* The second basic file always starts at the given location and does
|