summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-06-11 18:49:55 +0000
committertruelight <truelight@openttd.org>2007-06-11 18:49:55 +0000
commit9ee02182fa3539b6b16eb27e5924c0b02dece407 (patch)
treec9c79e56a55f6e9226478bd1cf05f4cabfb28de2
parent8f30750ade537b6024ab15f4a462b113274871d1 (diff)
downloadopenttd-9ee02182fa3539b6b16eb27e5924c0b02dece407.tar.xz
(svn r10105) -Fix r10092: fix sprite 4845 till 4881 (inclusive), so they store the data as on the disk in the memory, as the old landscape generate assumes this. Talking about ugly hacks...
-rw-r--r--src/spritecache.cpp41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index d7f7a2b5a..438becf72 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -144,7 +144,46 @@ static void* ReadSprite(SpriteCache *sc, SpriteID id)
sc->ptr = dest;
FioReadBlock(dest, num);
- return dest;
+ return sc->ptr;
+ }
+ /* Ugly hack to work around the problem that the old landscape
+ * generator assumes that those sprites are stored uncompressed in
+ * the memory, and they are only read directly by the code, never
+ * send to the blitter. So do not send it to the blitter (which will
+ * result in a data array in the format the blitter likes most), but
+ * read the data directly from disk and store that as sprite.
+ * Ugly: yes. Other solution: no. Blame the original author or
+ * something ;) The image should really have been a data-stream
+ * (so type = 0xFF basicly). */
+ if (id >= 4845 && id <= 4881) {
+ uint height = FioReadByte();
+ uint width = FioReadWord();
+ Sprite *sprite;
+ byte *dest;
+
+ num = width * height;
+ sprite = (Sprite *)AllocSprite(sizeof(*sprite) + num);
+ sc->ptr = sprite;
+ sprite->height = height;
+ sprite->width = width;
+ sprite->x_offs = FioReadWord();
+ sprite->y_offs = FioReadWord();
+
+ dest = sprite->data;
+ while (num > 0) {
+ int8 i = FioReadByte();
+ if (i >= 0) {
+ num -= i;
+ for (; i > 0; --i) *dest++ = FioReadByte();
+ } else {
+ const byte* rel = dest - (((i & 7) << 8) | FioReadByte());
+ i = -(i >> 3);
+ num -= i;
+ for (; i > 0; --i) *dest++ = *rel++;
+ }
+ }
+
+ return sc->ptr;
}
SpriteLoaderGrf sprite_loader;