summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-08-24 14:31:18 +0000
committerrubidium <rubidium@openttd.org>2011-08-24 14:31:18 +0000
commit49d8852f3f016f385ee3fabc5b5a714c70b5b2c8 (patch)
tree0c4983e9aff7277661e15c08e0021b632696e734
parentb4edc30c64b98d35fd35eb53eccd52bfc039c1f7 (diff)
downloadopenttd-49d8852f3f016f385ee3fabc5b5a714c70b5b2c8.tar.xz
(svn r22828) -Codechange: give some variables a better name and clean up the code of loading old style GRFs
-rw-r--r--src/gfxinit.cpp49
-rw-r--r--src/table/landscape_sprite.h6
2 files changed, 32 insertions, 23 deletions
diff --git a/src/gfxinit.cpp b/src/gfxinit.cpp
index 652462f49..0dd3276db 100644
--- a/src/gfxinit.cpp
+++ b/src/gfxinit.cpp
@@ -27,18 +27,26 @@ bool _palette_remap_grf[MAX_FILE_SLOTS];
#include "table/landscape_sprite.h"
+/** Offsets for loading the different "replacement" sprites in the files. */
static const SpriteID * const _landscape_spriteindexes[] = {
- _landscape_spriteindexes_1,
- _landscape_spriteindexes_2,
- _landscape_spriteindexes_3,
+ _landscape_spriteindexes_arctic,
+ _landscape_spriteindexes_tropic,
+ _landscape_spriteindexes_toyland,
};
+/**
+ * Load an old fashioned GRF file.
+ * @param filename The name of the file to open.
+ * @param load_index The offset of the first sprite.
+ * @param file_index The Fio offset to load the file in.
+ * @return The number of loaded sprites.
+ */
static uint LoadGrfFile(const char *filename, uint load_index, int file_index)
{
uint load_index_org = load_index;
uint sprite_id = 0;
- FioOpenFile(file_index, filename, NEWGRF_DIR);
+ FioOpenFile(file_index, filename, BASESET_DIR);
DEBUG(sprite, 2, "Reading grf-file '%s'", filename);
@@ -54,32 +62,33 @@ static uint LoadGrfFile(const char *filename, uint load_index, int file_index)
return load_index - load_index_org;
}
-
-static void LoadSpritesIndexed(int file_index, uint *sprite_id, const SpriteID *index_tbl)
+/**
+ * Load an old fashioned GRF file to replace already loaded sprites.
+ * @param filename The name of the file to open.
+ * @param index_tlb The offsets of each of the sprites.
+ * @param file_index The Fio offset to load the file in.
+ * @return The number of loaded sprites.
+ */
+static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl, int file_index)
{
uint start;
+ uint sprite_id = 0;
+
+ FioOpenFile(file_index, filename, BASESET_DIR);
+
+ DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename);
+
while ((start = *index_tbl++) != END) {
uint end = *index_tbl++;
do {
- bool b = LoadNextSprite(start, file_index, *sprite_id);
+ bool b = LoadNextSprite(start, file_index, sprite_id);
assert(b);
- (*sprite_id)++;
+ sprite_id++;
} while (++start <= end);
}
}
-static void LoadGrfIndexed(const char *filename, const SpriteID *index_tbl, int file_index)
-{
- uint sprite_id = 0;
-
- FioOpenFile(file_index, filename, NEWGRF_DIR);
-
- DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename);
-
- LoadSpritesIndexed(file_index, &sprite_id, index_tbl);
-}
-
/**
* Checks whether the MD5 checksums of the files are correct.
*
@@ -153,7 +162,7 @@ static void LoadSpriteTables()
*/
if (_settings_game.game_creation.landscape != LT_TEMPERATE) {
_palette_remap_grf[i] = (PAL_DOS != used_set->palette);
- LoadGrfIndexed(
+ LoadGrfFileIndexed(
used_set->files[GFT_ARCTIC + _settings_game.game_creation.landscape - 1].filename,
_landscape_spriteindexes[_settings_game.game_creation.landscape - 1],
i++
diff --git a/src/table/landscape_sprite.h b/src/table/landscape_sprite.h
index 13fe22c92..7058ee033 100644
--- a/src/table/landscape_sprite.h
+++ b/src/table/landscape_sprite.h
@@ -11,7 +11,7 @@
static const SpriteID END = 0xFFFF;
-static const SpriteID _landscape_spriteindexes_1[] = {
+static const SpriteID _landscape_spriteindexes_arctic[] = {
0xF67, 0xF9F,
0xAAD, 0xAB0,
0x83A, 0x845,
@@ -37,7 +37,7 @@ static const SpriteID _landscape_spriteindexes_1[] = {
END
};
-static const SpriteID _landscape_spriteindexes_2[] = {
+static const SpriteID _landscape_spriteindexes_tropic[] = {
0xF67, 0xF9F,
0xAAD, 0xAB0,
0xFA0, 0xFC9,
@@ -74,7 +74,7 @@ static const SpriteID _landscape_spriteindexes_2[] = {
END
};
-static const SpriteID _landscape_spriteindexes_3[] = {
+static const SpriteID _landscape_spriteindexes_toyland[] = {
0xF54, 0xF9F,
0xFDD, 0xFE5,
0xFEC, 0xFEC,