mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-05 22:04:57 +00:00
(svn r14197) -Codechange: rework (original) base graphics determination methods. This yields in the following:
-Feature: make configuring the to-be-used base graphics via openttd.cfg and the command line possible. -Feature: allow both the German as well as non-German toyland graphics as "correct" and official graphics. -Feature: allow people to create their own base graphics easily and without requiring code changes.
This commit is contained in:
parent
1afa473d0f
commit
c3a9653c89
31
bin/data/orig_dos.obg
Normal file
31
bin/data/orig_dos.obg
Normal file
@ -0,0 +1,31 @@
|
||||
; $Id$
|
||||
;
|
||||
; This represents the original graphics as on the non-German Transport
|
||||
; Tycoon Deluxe DOS CD.
|
||||
;
|
||||
[metadata]
|
||||
name = original_dos
|
||||
shortname = TTDD
|
||||
version = 1
|
||||
description = Original Transport Tycoon Deluxe DOS edition graphics
|
||||
palette = DOS
|
||||
|
||||
[files]
|
||||
base = TRG1.GRF
|
||||
logos = TRGI.GRF
|
||||
arctic = TRGC.GRF
|
||||
tropical = TRGH.GRF
|
||||
toyland = TRGT.GRF
|
||||
extra = OPENTTDD.GRF
|
||||
|
||||
[md5s]
|
||||
TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
|
||||
TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
|
||||
TRGC.GRF = ed446637e034104c5559b32c18afe78d
|
||||
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
|
||||
TRGT.GRF = e30e8a398ae86c03dc534a8ac7dfb3b6
|
||||
OPENTTDD.GRF = f829f62c137d6d7c6e272c481b796dd5
|
||||
|
||||
[origin]
|
||||
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
|
||||
OPENTTDD.GRF = This file was part of your installation.
|
31
bin/data/orig_dos_de.obg
Normal file
31
bin/data/orig_dos_de.obg
Normal file
@ -0,0 +1,31 @@
|
||||
; $Id$
|
||||
;
|
||||
; This represents the original graphics as on the German Transport
|
||||
; Tycoon Deluxe DOS CD. It contains one broken sprite.
|
||||
;
|
||||
[metadata]
|
||||
name = original_dos_de
|
||||
shortname = TTDD
|
||||
version = 0
|
||||
description = Original Transport Tycoon Deluxe DOS (German) edition graphics
|
||||
palette = DOS
|
||||
|
||||
[files]
|
||||
base = TRG1.GRF
|
||||
logos = TRGI.GRF
|
||||
arctic = TRGC.GRF
|
||||
tropical = TRGH.GRF
|
||||
toyland = TRGT.GRF
|
||||
extra = OPENTTDD.GRF
|
||||
|
||||
[md5s]
|
||||
TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
|
||||
TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
|
||||
TRGC.GRF = ed446637e034104c5559b32c18afe78d
|
||||
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
|
||||
TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
|
||||
OPENTTDD.GRF = f829f62c137d6d7c6e272c481b796dd5
|
||||
|
||||
[origin]
|
||||
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
|
||||
OPENTTDD.GRF = This file was part of your installation.
|
31
bin/data/orig_win.obg
Normal file
31
bin/data/orig_win.obg
Normal file
@ -0,0 +1,31 @@
|
||||
; $Id$
|
||||
;
|
||||
; This represents the original graphics as on the Transport
|
||||
; Tycoon Deluxe for Windows.
|
||||
;
|
||||
[metadata]
|
||||
name = original_windows
|
||||
shortname = TTDW
|
||||
version = 0
|
||||
description = Original Transport Tycoon Deluxe Windows edition graphics
|
||||
palette = Windows
|
||||
|
||||
[files]
|
||||
base = TRG1R.GRF
|
||||
logos = TRGIR.GRF
|
||||
arctic = TRGCR.GRF
|
||||
tropical = TRGHR.GRF
|
||||
toyland = TRGTR.GRF
|
||||
extra = OPENTTDW.GRF
|
||||
|
||||
[md5s]
|
||||
TRG1R.GRF = b04ce593d8c5016e07473a743d7d3358
|
||||
TRGIR.GRF = 0c2484ff6be49fc63a83be6ab5c38f32
|
||||
TRGCR.GRF = 3668f410c761a050b5e7095a2b14879b
|
||||
TRGHR.GRF = 06bf2b7a31766f048baac2ebe43457b1
|
||||
TRGTR.GRF = de53650517fe661ceaa3138c6edb0eb8
|
||||
OPENTTDW.GRF = 894fa4b04dc16dc43921493fd83d809e
|
||||
|
||||
[origin]
|
||||
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
|
||||
OPENTTDW.GRF = This file was part of your installation.
|
46
docs/obg_format.txt
Normal file
46
docs/obg_format.txt
Normal file
@ -0,0 +1,46 @@
|
||||
;
|
||||
; Example file for the OpenTTD Base Graphics replacement sets.
|
||||
; This file consists of basically two different parts:
|
||||
; * metadata
|
||||
; * information about the files
|
||||
;
|
||||
; Metadata contains information about the name, version and palette
|
||||
; of the graphics set.
|
||||
;
|
||||
[metadata]
|
||||
name = example ; the name of the pack, preferably less than 16 characters
|
||||
shortname = XMPL ; the short name (4 characters), used to identify this set within NewGRFs
|
||||
version = 0 ; the version of this graphics set (read as single integer)
|
||||
description = foo ; a fairly short description of the set
|
||||
palette = DOS ; palette used by the set; either DOS or Windows
|
||||
|
||||
; The files section lists the files that replace sprites.
|
||||
; The file names are case sensitive.
|
||||
[files]
|
||||
base = TRG1.GRF ; GRF file with the base sprites
|
||||
logos = TRGI.GRF ; GRF file with logos, original terrain generator sprites
|
||||
arctic = TRGC.GRF ; GRF file with extra arctic sprites
|
||||
tropical = TRGH.GRF ; GRF file with extra tropical sprites
|
||||
toyland = TRGT.GRF ; GRF file with extra toyland sprites
|
||||
extra = OPENTTDD.GRF ; NewGRF file using Actions 5, 7, 9 and A to replace sprites
|
||||
|
||||
; The md5s section lists the MD5 checksum for the files that replace them.
|
||||
; Note that the list of files is case sensitive. Each GRF listed in the
|
||||
; files section must be listed here with it's MD5 checksum, otherwise you
|
||||
; will get a lot of warnings when starting OpenTTD.
|
||||
[md5s]
|
||||
TRG1.GRF = 9311676280e5b14077a8ee41c1b42192
|
||||
TRGI.GRF = da6a6c9dcc451eec88d79211437b76a8
|
||||
TRGH.GRF = ee6616fb0e6ef6b24892c58c93d86fc9
|
||||
TRGC.GRF = ed446637e034104c5559b32c18afe78d
|
||||
TRGT.GRF = fcde1d7e8a74197d72a62695884b909e
|
||||
OPENTTDD.GRF = f829f62c137d6d7c6e272c481b796dd5
|
||||
|
||||
; The origin section provides the possibility to put and extra line into
|
||||
; the warning that a file is missing/corrupt. This can be used to tell
|
||||
; them where to find it. It works on the filename specified in the
|
||||
; files section and if that is not found it will fall back to the default
|
||||
; as shown below here.
|
||||
[origin]
|
||||
default = You can find it on your Transport Tycoon Deluxe CD-ROM.
|
||||
OPENTTDD.GRF = This file was part of your installation.
|
287
src/gfxinit.cpp
287
src/gfxinit.cpp
@ -16,36 +16,67 @@
|
||||
#include "gfx_func.h"
|
||||
#include "core/alloc_func.hpp"
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "core/smallvec_type.hpp"
|
||||
#include <string.h>
|
||||
#include "settings_type.h"
|
||||
#include "string_func.h"
|
||||
#include "ini_type.h"
|
||||
|
||||
#include "table/sprites.h"
|
||||
|
||||
/** The currently used palette */
|
||||
PaletteType _use_palette = PAL_AUTODETECT;
|
||||
char _ini_graphics_set[32];
|
||||
|
||||
/** Structure holding filename and MD5 information about a single file */
|
||||
struct MD5File {
|
||||
const char * filename; ///< filename
|
||||
uint8 hash[16]; ///< md5 sum of the file
|
||||
const char *filename; ///< filename
|
||||
uint8 hash[16]; ///< md5 sum of the file
|
||||
const char *missing_warning; ///< warning when this file is missing
|
||||
};
|
||||
|
||||
/**
|
||||
* Information about a single graphics set.
|
||||
*/
|
||||
/** Types of graphics in the base graphics set */
|
||||
enum GraphicsFileType {
|
||||
GFT_BASE, ///< Base sprites for all climates
|
||||
GFT_LOGOS, ///< Logos, landscape icons and original terrain generator sprites
|
||||
GFT_ARCTIC, ///< Landscape replacement sprites for arctic
|
||||
GFT_TROPICAL, ///< Landscape replacement sprites for tropical
|
||||
GFT_TOYLAND, ///< Landscape replacement sprites for toyland
|
||||
GFT_EXTRA, ///< Extra sprites that were not part of the original sprites
|
||||
MAX_GFT ///< We are looking for this amount of GRFs
|
||||
};
|
||||
|
||||
/** Information about a single graphics set. */
|
||||
struct GraphicsSet {
|
||||
const char *name; ///< The name of the graphics set
|
||||
const char *description; ///< Description of the graphics set
|
||||
uint32 shortname; ///< Four letter short variant of the name
|
||||
uint32 version; ///< The version of this graphics set
|
||||
PaletteType palette; ///< Palette of this graphics set
|
||||
MD5File basic[2]; ///< GRF files that always have to be loaded
|
||||
MD5File landscape[3]; ///< Landscape specific grf files
|
||||
const char *base_missing; ///< Warning when one of the base GRF files is missing
|
||||
MD5File extra; ///< NewGRF File with extra graphics loaded using Action 05
|
||||
const char *extra_missing; ///< Warning when the extra (NewGRF) file is missing
|
||||
|
||||
MD5File files[MAX_GFT]; ///< All GRF files part of this set
|
||||
uint found_grfs; ///< Number of the GRFs that could be found
|
||||
|
||||
GraphicsSet *next; ///< The next graphics set in this list
|
||||
|
||||
/** Free everything we allocated */
|
||||
~GraphicsSet()
|
||||
{
|
||||
free((void*)this->name);
|
||||
free((void*)this->description);
|
||||
for (uint i = 0; i < MAX_GFT; i++) {
|
||||
free((void*)this->files[i].filename);
|
||||
free((void*)this->files[i].missing_warning);
|
||||
}
|
||||
|
||||
delete this->next;
|
||||
}
|
||||
};
|
||||
|
||||
static const uint GRAPHICS_SET_GRF_COUNT = 6;
|
||||
static int _use_graphics_set = -1;
|
||||
/** All graphics sets currently available */
|
||||
static GraphicsSet *_available_graphics_sets = NULL;
|
||||
/** The one and only graphics set that is currently being used. */
|
||||
static const GraphicsSet *_used_graphics_set = NULL;
|
||||
|
||||
#include "table/files.h"
|
||||
#include "table/landscape_sprite.h"
|
||||
@ -140,14 +171,17 @@ static bool FileMD5(const MD5File file)
|
||||
*/
|
||||
static void DetermineGraphicsPack()
|
||||
{
|
||||
if (_use_graphics_set >= 0) return;
|
||||
if (_used_graphics_set != NULL) return;
|
||||
|
||||
uint max_index = 0;
|
||||
for (uint j = 1; j < lengthof(_graphics_sets); j++) {
|
||||
if (_graphics_sets[max_index].found_grfs < _graphics_sets[j].found_grfs) max_index = j;
|
||||
const GraphicsSet *best = _available_graphics_sets;
|
||||
for (const GraphicsSet *c = _available_graphics_sets; c != NULL; c = c->next) {
|
||||
if (best->found_grfs < c->found_grfs ||
|
||||
(best->found_grfs == c->found_grfs && best->shortname == c->shortname && best->version < c->version)) {
|
||||
best = c;
|
||||
}
|
||||
}
|
||||
|
||||
_use_graphics_set = max_index;
|
||||
_used_graphics_set = best;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -159,7 +193,7 @@ static void DeterminePalette()
|
||||
{
|
||||
if (_use_palette < MAX_PAL) return;
|
||||
|
||||
_use_palette = _graphics_sets[_use_graphics_set].palette;
|
||||
_use_palette = _used_graphics_set->palette;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -173,20 +207,13 @@ void CheckExternalFiles()
|
||||
DeterminePalette();
|
||||
|
||||
static const size_t ERROR_MESSAGE_LENGTH = 128;
|
||||
const GraphicsSet *graphics = &_graphics_sets[_use_graphics_set];
|
||||
char error_msg[ERROR_MESSAGE_LENGTH * (GRAPHICS_SET_GRF_COUNT + 1)];
|
||||
char error_msg[ERROR_MESSAGE_LENGTH * (MAX_GFT + 1)];
|
||||
error_msg[0] = '\0';
|
||||
char *add_pos = error_msg;
|
||||
|
||||
for (uint i = 0; i < lengthof(graphics->basic); i++) {
|
||||
if (!FileMD5(graphics->basic[i])) {
|
||||
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! %s.\n", graphics->basic[i].filename, graphics->base_missing);
|
||||
}
|
||||
}
|
||||
|
||||
for (uint i = 0; i < lengthof(graphics->landscape); i++) {
|
||||
if (!FileMD5(graphics->landscape[i])) {
|
||||
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! %s\n", graphics->landscape[i].filename, graphics->base_missing);
|
||||
for (uint i = 0; i < lengthof(_used_graphics_set->files); i++) {
|
||||
if (!FileMD5(_used_graphics_set->files[i])) {
|
||||
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! %s\n", _used_graphics_set->files[i].filename, _used_graphics_set->files[i].missing_warning);
|
||||
}
|
||||
}
|
||||
|
||||
@ -199,20 +226,15 @@ void CheckExternalFiles()
|
||||
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your 'sample.cat' file is corrupted or missing! You can find 'sample.cat' on your Transport Tycoon Deluxe CD-ROM.\n");
|
||||
}
|
||||
|
||||
if (!FileMD5(graphics->extra)) {
|
||||
add_pos += snprintf(add_pos, ERROR_MESSAGE_LENGTH, "Your '%s' file is corrupted or missing! %s\n", graphics->extra.filename, graphics->extra_missing);
|
||||
}
|
||||
|
||||
if (add_pos != error_msg) ShowInfoF(error_msg);
|
||||
}
|
||||
|
||||
|
||||
static void LoadSpriteTables()
|
||||
{
|
||||
const GraphicsSet *graphics = &_graphics_sets[_use_graphics_set];
|
||||
uint i = FIRST_GRF_SLOT;
|
||||
|
||||
LoadGrfFile(graphics->basic[0].filename, 0, i++);
|
||||
LoadGrfFile(_used_graphics_set->files[GFT_BASE].filename, 0, i++);
|
||||
|
||||
/*
|
||||
* The second basic file always starts at the given location and does
|
||||
@ -220,7 +242,7 @@ static void LoadSpriteTables()
|
||||
* has a few sprites less. However, we do not care about those missing
|
||||
* sprites as they are not shown anyway (logos in intro game).
|
||||
*/
|
||||
LoadGrfFile(graphics->basic[1].filename, 4793, i++);
|
||||
LoadGrfFile(_used_graphics_set->files[GFT_LOGOS].filename, 4793, i++);
|
||||
|
||||
/*
|
||||
* Load additional sprites for climates other than temperate.
|
||||
@ -229,7 +251,7 @@ static void LoadSpriteTables()
|
||||
*/
|
||||
if (_settings_game.game_creation.landscape != LT_TEMPERATE) {
|
||||
LoadGrfIndexed(
|
||||
graphics->landscape[_settings_game.game_creation.landscape - 1].filename,
|
||||
_used_graphics_set->files[GFT_ARCTIC + _settings_game.game_creation.landscape - 1].filename,
|
||||
_landscape_spriteindexes[_settings_game.game_creation.landscape - 1],
|
||||
i++
|
||||
);
|
||||
@ -245,7 +267,7 @@ static void LoadSpriteTables()
|
||||
*/
|
||||
GRFConfig *top = _grfconfig;
|
||||
GRFConfig *master = CallocT<GRFConfig>(1);
|
||||
master->filename = strdup(graphics->extra.filename);
|
||||
master->filename = strdup(_used_graphics_set->files[GFT_EXTRA].filename);
|
||||
FillGRFDetails(master, false);
|
||||
ClrBit(master->flags, GCF_INIT_ONLY);
|
||||
master->next = top;
|
||||
@ -269,20 +291,173 @@ void GfxLoadSprites()
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all graphics sets and populate their data.
|
||||
* Try to read a single piece of metadata and return false if it doesn't exist.
|
||||
* @param name the name of the item to fetch.
|
||||
*/
|
||||
#define fetch_metadata(name) \
|
||||
item = metadata->GetItem(name, false); \
|
||||
if (item == NULL || strlen(item->value) == 0) { \
|
||||
DEBUG(grf, 0, "Base graphics set detail loading: %s field missing", name); \
|
||||
return false; \
|
||||
}
|
||||
|
||||
/** Names corresponding to the GraphicsFileType */
|
||||
static const char *_gft_names[MAX_GFT] = { "base", "logos", "arctic", "tropical", "toyland", "extra" };
|
||||
|
||||
/**
|
||||
* Read the graphics set information from a loaded ini.
|
||||
* @param graphics the graphics set to write to
|
||||
* @param ini the ini to read from
|
||||
* @param path the path to this ini file (for filenames)
|
||||
* @return true if loading was successful.
|
||||
*/
|
||||
static bool FillGraphicsSetDetails(GraphicsSet *graphics, IniFile *ini, const char *path)
|
||||
{
|
||||
memset(graphics, 0, sizeof(*graphics));
|
||||
|
||||
IniGroup *metadata = ini->GetGroup("metadata");
|
||||
IniItem *item;
|
||||
|
||||
fetch_metadata("name");
|
||||
graphics->name = strdup(item->value);
|
||||
|
||||
fetch_metadata("description");
|
||||
graphics->description = strdup(item->value);
|
||||
|
||||
fetch_metadata("shortname");
|
||||
for (uint i = 0; item->value[i] != '\0' && i < 4; i++) {
|
||||
graphics->shortname |= ((uint8)item->value[i]) << (32 - i * 8);
|
||||
}
|
||||
|
||||
fetch_metadata("version");
|
||||
graphics->version = atoi(item->value);
|
||||
|
||||
fetch_metadata("palette");
|
||||
graphics->palette = (*item->value == 'D' || *item->value == 'd') ? PAL_DOS : PAL_WINDOWS;
|
||||
|
||||
/* For each of the graphics file types we want to find the file, MD5 checksums and warning messages. */
|
||||
IniGroup *files = ini->GetGroup("files");
|
||||
IniGroup *md5s = ini->GetGroup("md5s");
|
||||
IniGroup *origin = ini->GetGroup("origin");
|
||||
for (uint i = 0; i < MAX_GFT; i++) {
|
||||
MD5File *file = &graphics->files[i];
|
||||
/* Find the filename first. */
|
||||
item = files->GetItem(_gft_names[i], false);
|
||||
if (item == NULL) {
|
||||
DEBUG(grf, 0, "No graphics file for: %s", _gft_names[i]);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *filename = item->value;
|
||||
file->filename = MallocT<char>(strlen(filename) + strlen(path) + 1);
|
||||
sprintf((char*)file->filename, "%s%s", path, filename);
|
||||
|
||||
/* Then find the MD5 checksum */
|
||||
item = md5s->GetItem(filename, false);
|
||||
if (item == NULL) {
|
||||
DEBUG(grf, 0, "No MD5 checksum specified for: %s", filename);
|
||||
return false;
|
||||
}
|
||||
char *c = item->value;
|
||||
for (uint i = 0; i < sizeof(file->hash) * 2; i++, c++) {
|
||||
uint j;
|
||||
if ('0' <= *c && *c <= '9') {
|
||||
j = *c - '0';
|
||||
} else if ('a' <= *c && *c <= 'f') {
|
||||
j = *c - 'a' + 10;
|
||||
} else if ('A' <= *c && *c <= 'F') {
|
||||
j = *c - 'A' + 10;
|
||||
} else {
|
||||
DEBUG(grf, 0, "Malformed MD5 checksum specified for: %s", filename);
|
||||
return false;
|
||||
}
|
||||
if (i % 2 == 0) {
|
||||
file->hash[i / 2] = j << 4;
|
||||
} else {
|
||||
file->hash[i / 2] |= j;
|
||||
}
|
||||
}
|
||||
|
||||
/* Then find the warning message when the file's missing */
|
||||
item = origin->GetItem(filename, false);
|
||||
if (item == NULL) item = origin->GetItem("default", false);
|
||||
if (item == NULL) {
|
||||
DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
|
||||
file->missing_warning = strdup("");
|
||||
} else {
|
||||
file->missing_warning = strdup(item->value);
|
||||
}
|
||||
|
||||
if (FileMD5(*file)) graphics->found_grfs++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Helper for scanning for files with GRF as extension */
|
||||
class OBGFileScanner : FileScanner {
|
||||
public:
|
||||
/* virtual */ bool AddFile(const char *filename, size_t basepath_length);
|
||||
|
||||
/** Do the scan for OBGs. */
|
||||
static uint DoScan()
|
||||
{
|
||||
OBGFileScanner fs;
|
||||
return fs.Scan(".obg", DATA_DIR);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Try to add a graphics set with the given filename.
|
||||
* @param filename the full path to the file to read
|
||||
* @param basepath_length amount of characters to chop of before to get a relative DATA_DIR filename
|
||||
* @return true if the file is added.
|
||||
*/
|
||||
bool OBGFileScanner::AddFile(const char *filename, size_t basepath_length)
|
||||
{
|
||||
bool ret = false;
|
||||
DEBUG(grf, 1, "Found %s as base graphics set", filename);
|
||||
|
||||
GraphicsSet *graphics = new GraphicsSet();;
|
||||
IniFile *ini = new IniFile();
|
||||
ini->LoadFromDisk(filename);
|
||||
|
||||
char *path = strdup(filename + basepath_length);
|
||||
char *psep = strrchr(path, PATHSEPCHAR);
|
||||
if (psep != NULL) {
|
||||
psep[1] = '\0';
|
||||
} else {
|
||||
*path = '\0';
|
||||
}
|
||||
|
||||
if (FillGraphicsSetDetails(graphics, ini, path)) {
|
||||
bool duplicate = false;
|
||||
for (const GraphicsSet *c = _available_graphics_sets; !duplicate && c != NULL; c = c->next) {
|
||||
duplicate = (strcmp(c->name, graphics->name) == 0) || (c->shortname == graphics->shortname && c->version == graphics->version);
|
||||
}
|
||||
if (duplicate) {
|
||||
delete graphics;
|
||||
} else {
|
||||
graphics->next = _available_graphics_sets;
|
||||
_available_graphics_sets = graphics;
|
||||
ret = true;
|
||||
}
|
||||
} else {
|
||||
delete graphics;
|
||||
}
|
||||
free(path);
|
||||
|
||||
delete ini;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Scan for all Grahpics sets */
|
||||
void FindGraphicsSets()
|
||||
{
|
||||
for (uint j = 0; j < lengthof(_graphics_sets); j++) {
|
||||
_graphics_sets[j].found_grfs = 0;
|
||||
for (uint i = 0; i < lengthof(_graphics_sets[j].basic); i++) {
|
||||
if (FioCheckFileExists(_graphics_sets[j].basic[i].filename)) _graphics_sets[j].found_grfs++;
|
||||
}
|
||||
for (uint i = 0; i < lengthof(_graphics_sets[j].landscape); i++) {
|
||||
if (FioCheckFileExists(_graphics_sets[j].landscape[i].filename)) _graphics_sets[j].found_grfs++;
|
||||
}
|
||||
if (FioCheckFileExists(_graphics_sets[j].extra.filename)) _graphics_sets[j].found_grfs++;
|
||||
}
|
||||
DEBUG(grf, 1, "Scanning for Graphics sets");
|
||||
OBGFileScanner::DoScan();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,9 +473,9 @@ bool SetGraphicsSet(const char *name)
|
||||
return true;
|
||||
}
|
||||
|
||||
for (uint i = 0; i < lengthof(_graphics_sets); i++) {
|
||||
if (strcmp(name, _graphics_sets[i].name) == 0) {
|
||||
_use_graphics_set = i;
|
||||
for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) {
|
||||
if (strcmp(name, g->name) == 0) {
|
||||
_used_graphics_set = g;
|
||||
CheckExternalFiles();
|
||||
return true;
|
||||
}
|
||||
@ -317,11 +492,11 @@ bool SetGraphicsSet(const char *name)
|
||||
char *GetGraphicsSetsList(char *p, const char *last)
|
||||
{
|
||||
p += snprintf(p, last - p, "List of graphics sets:\n");
|
||||
for (uint i = 0; i < lengthof(_graphics_sets); i++) {
|
||||
if (_graphics_sets[i].found_grfs <= 1) continue;
|
||||
for (const GraphicsSet *g = _available_graphics_sets; g != NULL; g = g->next) {
|
||||
if (g->found_grfs <= 1) continue;
|
||||
|
||||
p += snprintf(p, last - p, "%18s: %s", _graphics_sets[i].name, _graphics_sets[i].description);
|
||||
int difference = GRAPHICS_SET_GRF_COUNT - _graphics_sets[i].found_grfs;
|
||||
p += snprintf(p, last - p, "%18s: %s", g->name, g->description);
|
||||
int difference = MAX_GFT - g->found_grfs;
|
||||
if (difference != 0) {
|
||||
p += snprintf(p, last - p, " (missing %i file%s)\n", difference, difference == 1 ? "" : "s");
|
||||
} else {
|
||||
|
@ -15,4 +15,6 @@ void FindGraphicsSets();
|
||||
bool SetGraphicsSet(const char *name);
|
||||
char *GetGraphicsSetsList(char *p, const char *last);
|
||||
|
||||
extern char _ini_graphics_set[32];
|
||||
|
||||
#endif /* GFXINIT_H */
|
||||
|
@ -515,7 +515,9 @@ int ttd_main(int argc, char *argv[])
|
||||
CheckConfig();
|
||||
LoadFromHighScore();
|
||||
|
||||
|
||||
/* override config? */
|
||||
if (!StrEmpty(graphics_set)) ttd_strlcpy(_ini_graphics_set, graphics_set, sizeof(_ini_graphics_set));
|
||||
if (!StrEmpty(musicdriver)) ttd_strlcpy(_ini_musicdriver, musicdriver, sizeof(_ini_musicdriver));
|
||||
if (!StrEmpty(sounddriver)) ttd_strlcpy(_ini_sounddriver, sounddriver, sizeof(_ini_sounddriver));
|
||||
if (!StrEmpty(videodriver)) ttd_strlcpy(_ini_videodriver, videodriver, sizeof(_ini_videodriver));
|
||||
@ -558,10 +560,10 @@ int ttd_main(int argc, char *argv[])
|
||||
/* This must be done early, since functions use the InvalidateWindow* calls */
|
||||
InitWindowSystem();
|
||||
|
||||
if (!SetGraphicsSet(graphics_set)) {
|
||||
StrEmpty(graphics_set) ?
|
||||
if (!SetGraphicsSet(_ini_graphics_set)) {
|
||||
StrEmpty(_ini_graphics_set) ?
|
||||
usererror("Failed to find a graphics set. Please acquire a graphics set for OpenTTD.") :
|
||||
usererror("Failed to select requested graphics set '%s'", graphics_set);
|
||||
usererror("Failed to select requested graphics set '%s'", _ini_graphics_set);
|
||||
}
|
||||
|
||||
/* Initialize game palette */
|
||||
|
@ -60,6 +60,7 @@
|
||||
#include "sound/sound_driver.hpp"
|
||||
#include "music/music_driver.hpp"
|
||||
#include "blitter/factory.hpp"
|
||||
#include "gfxinit.h"
|
||||
#include "gamelog.h"
|
||||
#include "station_func.h"
|
||||
#include "settings_func.h"
|
||||
@ -1157,6 +1158,7 @@ static const SettingDescGlobVarList _misc_settings[] = {
|
||||
SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION||FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
|
||||
SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL),
|
||||
SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL),
|
||||
SDTG_STR("graphicsset", SLE_STRB,C|S,0, _ini_graphics_set, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("musicdriver", SLE_STRB,C|S,0, _ini_musicdriver, NULL, STR_NULL, NULL),
|
||||
SDTG_STR("sounddriver", SLE_STRB,C|S,0, _ini_sounddriver, NULL, STR_NULL, NULL),
|
||||
|
@ -11,7 +11,7 @@
|
||||
TRGC.GRF ed446637e034104c5559b32c18afe78d
|
||||
TRGH.GRF ee6616fb0e6ef6b24892c58c93d86fc9
|
||||
TRGI.GRF da6a6c9dcc451eec88d79211437b76a8
|
||||
TRGT.GRF fcde1d7e8a74197d72a62695884b909e
|
||||
TRGT.GRF e30e8a398ae86c03dc534a8ac7dfb3b6 (German: fcde1d7e8a74197d72a62695884b909e)
|
||||
SAMPLE.CAT 422ea3dd074d2859bb51639a6e0e85da
|
||||
|
||||
WINDOWS -
|
||||
@ -25,49 +25,7 @@
|
||||
*/
|
||||
|
||||
|
||||
static GraphicsSet _graphics_sets[] = {
|
||||
/** Filenames and MD5 checksums of the original DOS graphics */
|
||||
{
|
||||
"original_dos",
|
||||
"Original Transport Tycoon Deluxe DOS edition graphics",
|
||||
PAL_DOS,
|
||||
{
|
||||
{ "TRG1.GRF", {0x93, 0x11, 0x67, 0x62, 0x80, 0xe5, 0xb1, 0x40, 0x77, 0xa8, 0xee, 0x41, 0xc1, 0xb4, 0x21, 0x92} }, // 0 - 4792 inclusive
|
||||
{ "TRGI.GRF", {0xda, 0x6a, 0x6c, 0x9d, 0xcc, 0x45, 0x1e, 0xec, 0x88, 0xd7, 0x92, 0x11, 0x43, 0x7b, 0x76, 0xa8} } // 4793 - 4889 inclusive
|
||||
}, {
|
||||
{ "TRGC.GRF", {0xed, 0x44, 0x66, 0x37, 0xe0, 0x34, 0x10, 0x4c, 0x55, 0x59, 0xb3, 0x2c, 0x18, 0xaf, 0xe7, 0x8d} },
|
||||
{ "TRGH.GRF", {0xee, 0x66, 0x16, 0xfb, 0x0e, 0x6e, 0xf6, 0xb2, 0x48, 0x92, 0xc5, 0x8c, 0x93, 0xd8, 0x6f, 0xc9} },
|
||||
{ "TRGT.GRF", {0xfc, 0xde, 0x1d, 0x7e, 0x8a, 0x74, 0x19, 0x7d, 0x72, 0xa6, 0x26, 0x95, 0x88, 0x4b, 0x90, 0x9e} }
|
||||
},
|
||||
"You can find it on your Transport Tycoon Deluxe CD-ROM.",
|
||||
|
||||
{ "OPENTTDD.GRF", {0xf8, 0x29, 0xf6, 0x2c, 0x13, 0x7d, 0x6d, 0x7c, 0x6e, 0x27, 0x2c, 0x48, 0x1b, 0x79, 0x6d, 0xd5} },
|
||||
"This file was part of your installation.",
|
||||
0
|
||||
},
|
||||
|
||||
/** Filenames and MD5 checksums of the original Windows graphics */
|
||||
{
|
||||
"original_windows",
|
||||
"Original Transport Tycoon Deluxe Windows edition graphics",
|
||||
PAL_WINDOWS,
|
||||
{
|
||||
{ "TRG1R.GRF", {0xb0, 0x4c, 0xe5, 0x93, 0xd8, 0xc5, 0x01, 0x6e, 0x07, 0x47, 0x3a, 0x74, 0x3d, 0x7d, 0x33, 0x58} }, // 0 - 4792 inclusive
|
||||
{ "TRGIR.GRF", {0x0c, 0x24, 0x84, 0xff, 0x6b, 0xe4, 0x9f, 0xc6, 0x3a, 0x83, 0xbe, 0x6a, 0xb5, 0xc3, 0x8f, 0x32} } // 4793 - 4895 inclusive
|
||||
}, {
|
||||
{ "TRGCR.GRF", {0x36, 0x68, 0xf4, 0x10, 0xc7, 0x61, 0xa0, 0x50, 0xb5, 0xe7, 0x09, 0x5a, 0x2b, 0x14, 0x87, 0x9b} },
|
||||
{ "TRGHR.GRF", {0x06, 0xbf, 0x2b, 0x7a, 0x31, 0x76, 0x6f, 0x04, 0x8b, 0xaa, 0xc2, 0xeb, 0xe4, 0x34, 0x57, 0xb1} },
|
||||
{ "TRGTR.GRF", {0xde, 0x53, 0x65, 0x05, 0x17, 0xfe, 0x66, 0x1c, 0xea, 0xa3, 0x13, 0x8c, 0x6e, 0xdb, 0x0e, 0xb8} }
|
||||
},
|
||||
"You can find it on your Transport Tycoon Deluxe CD-ROM",
|
||||
|
||||
{ "OPENTTDW.GRF", {0x89, 0x4f, 0xa4, 0xb0, 0x4d, 0xc1, 0x6d, 0xc4, 0x39, 0x21, 0x49, 0x3f, 0xd8, 0x3d, 0x80, 0x9e} },
|
||||
"This file was part of your installation.",
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
static MD5File _sound_sets[] = {
|
||||
{ "SAMPLE.CAT", {0x42, 0x2e, 0xa3, 0xdd, 0x07, 0x4d, 0x28, 0x59, 0xbb, 0x51, 0x63, 0x9a, 0x6e, 0x0e, 0x85, 0xda} },
|
||||
{ "SAMPLE.CAT", {0x92, 0x12, 0xe8, 0x1e, 0x72, 0xba, 0xdd, 0x4b, 0xbe, 0x1e, 0xae, 0xae, 0x66, 0x45, 0x8e, 0x10} },
|
||||
{ "SAMPLE.CAT", {0x42, 0x2e, 0xa3, 0xdd, 0x07, 0x4d, 0x28, 0x59, 0xbb, 0x51, 0x63, 0x9a, 0x6e, 0x0e, 0x85, 0xda}, NULL },
|
||||
{ "SAMPLE.CAT", {0x92, 0x12, 0xe8, 0x1e, 0x72, 0xba, 0xdd, 0x4b, 0xbe, 0x1e, 0xae, 0xae, 0x66, 0x45, 0x8e, 0x10}, NULL },
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user