summaryrefslogtreecommitdiff
path: root/spritecache.c
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2004-08-13 11:28:59 +0000
committerdominik <dominik@openttd.org>2004-08-13 11:28:59 +0000
commit0c25a4b10ce61dad50f4e0c353fc582669d4f85f (patch)
treedaf6f3c92e522d986c86c27ae66003b4ccc39661 /spritecache.c
parentec31ae9f16a53a3c6a67bc11c23728f64b6c8cf3 (diff)
downloadopenttd-0c25a4b10ce61dad50f4e0c353fc582669d4f85f.tar.xz
(svn r38) Preliminary slopes graphics fix. Neighboring tile check not done yet
Diffstat (limited to 'spritecache.c')
-rw-r--r--spritecache.c38
1 files changed, 32 insertions, 6 deletions
diff --git a/spritecache.c b/spritecache.c
index 3bcc68d4b..21524a2e6 100644
--- a/spritecache.c
+++ b/spritecache.c
@@ -71,6 +71,13 @@ static const uint16 * const _landscape_spriteindexes[] = {
_landscape_spriteindexes_3,
};
+static const uint16 * const _slopes_spriteindexes[] = {
+ _slopes_spriteindexes_0,
+ _slopes_spriteindexes_1,
+ _slopes_spriteindexes_2,
+ _slopes_spriteindexes_3,
+};
+
static void CompactSpriteCache();
void DecodeSpecialSprite(const char *filename, int num, int load_index);
@@ -210,6 +217,19 @@ static bool LoadNextSprite(int load_index, byte file_index)
return true;
}
+static void SkipSprites(int count)
+{
+ while(count>0)
+ {
+ uint16 size;
+ if ( (size = FioReadWord()) == 0)
+ return;
+
+ ReadSpriteHeaderSkipData(size, NUM_SPRITES-1);
+ count--;
+ }
+}
+
// Checks, if trg1r.grf is the Windows version
static bool CheckGrfFile()
{
@@ -246,16 +266,20 @@ static int LoadGrfFile(const char *filename, int load_index, int file_index)
static void LoadGrfIndexed(const char *filename, const uint16 *index_tbl, int file_index)
{
- int start, end;
+ int start;
FioOpenFile(file_index, filename);
for(;(start=*index_tbl++) != 0xffff;) {
- end = *index_tbl++;
- do {
- bool b = LoadNextSprite(start, file_index);
- assert(b);
- } while (++start <= end);
+ int end = *index_tbl++;
+ if(start==0xfffe) { // skip sprites (amount in second var)
+ SkipSprites(end);
+ } else { // load sprites and use indexes from start to end
+ do {
+ bool b = LoadNextSprite(start, file_index);
+ assert(b);
+ } while (++start <= end);
+ }
}
}
@@ -669,6 +693,8 @@ static void LoadSpriteTables()
if ((l=_sprite_page_to_load) != 0)
LoadGrfIndexed(_landscape_filenames[l-1], _landscape_spriteindexes[l-1], i++);
}
+
+ LoadGrfIndexed("trkfoundw.grf", _slopes_spriteindexes[_opt.landscape], i++);
load_index = SPR_CANALS_BASE;
load_index += LoadGrfFile("canalsw.grf", load_index, i++);