(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
authorDarkvater
Sat, 29 Oct 2005 22:27:34 +0000
changeset 2565 19b3af477934
parent 2564 371e0fa97e1e
child 2566 da24c0f2d2d8
(svn r3102) - Fix (regression): Newly added sprite had problems when newgrf's where loaded. Thanks Tron for explaining what the problem was and how it should be solved.
gfxinit.c
table/sprites.h
--- a/gfxinit.c	Sat Oct 29 21:54:28 2005 +0000
+++ b/gfxinit.c	Sat Oct 29 22:27:34 2005 +0000
@@ -266,7 +266,12 @@
 	0xFFFF
 };
 
-#define OPENTTD_SPRITES_COUNT 100
+/* NOTE: When adding a normal sprite, increase OPENTTD_SPRITES_COUNT with the
+ * amount of sprites and add them to the end of the list, with the index of
+ * the old sprite-count offset from SPR_OPENTTD_BASE. With this there is no
+ * correspondence of any kind with the ID's in the grf file, but results in
+ * a maximum use of sprite slots. */
+#define OPENTTD_SPRITES_COUNT 101
 static const SpriteID _openttd_grf_indexes[] = {
 	SPR_OPENTTD_BASE + 0, SPR_OPENTTD_BASE + 7, // icons etc
 	134, 134,  // euro symbol medium size
@@ -277,7 +282,7 @@
 	616, 616, // nordic char: Æ
 	666, 666, // nordic char: ø
 	634, 634, // nordic char: Ø
-	SPR_OPENTTD_BASE+62, SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT, // more icons
+	SPR_OPENTTD_BASE+62, SPR_OPENTTD_BASE + 100, // more icons
 	382, 383, // ¼ ½ tiny
 	158, 159, // ¼ ½ medium
 	606, 607, // ¼ ½ large
@@ -303,7 +308,7 @@
 	317, 320, // { | } ~ tiny
 	 93,  96, // { | } ~ medium
 	541, 544, // { | } ~ large
-	SPR_OPENTTD_BASE+138, SPR_OPENTTD_BASE+138, // icon
+	SPR_OPENTTD_BASE + 101, SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT, // icon (HOUSE)
 	0xffff,
 };
 
--- a/table/sprites.h	Sat Oct 29 21:54:28 2005 +0000
+++ b/table/sprites.h	Sat Oct 29 22:27:34 2005 +0000
@@ -60,7 +60,7 @@
 	SPR_BOX_EMPTY     = SPR_OPENTTD_BASE + 66,
 	SPR_BOX_CHECKED   = SPR_OPENTTD_BASE + 67,
 	SPR_WINDOW_RESIZE = SPR_OPENTTD_BASE + 94,   // resize icon
-	SPR_HOUSE_ICON    = SPR_OPENTTD_BASE + 138,
+	SPR_HOUSE_ICON    = SPR_OPENTTD_BASE + 101,
 	// arrow icons pointing in all 4 directions
 	SPR_ARROW_DOWN    = SPR_OPENTTD_BASE + 95,
 	SPR_ARROW_UP      = SPR_OPENTTD_BASE + 96,