<URL: http://bugs.freeciv.org/Ticket/Display.html?id=35866 >
If no sprite is available (possible in some tilesets) nothing should be
drawn. Instead the code in question here crashes (because of doing
mod-0 math).
This simple patch fixes it. For 2.1 and development branches - I will
commit immediately.
-jason
Index: client/tilespec.c
===================================================================
--- client/tilespec.c (revision 12631)
+++ client/tilespec.c (working copy)
@@ -3575,18 +3575,21 @@
int count = sprite_vector_size(&draw->layer[l].base);
int ox = draw->layer[l].offset_x, oy = draw->layer[l].offset_y;
- /* Pseudo-random reproducable algorithm to pick a sprite. */
-#define LARGE_PRIME 10007
-#define SMALL_PRIME 1009
- assert(count < SMALL_PRIME);
- assert((int)(LARGE_PRIME * MAP_INDEX_SIZE) > 0);
- count = ((ptile->index
- * LARGE_PRIME) % SMALL_PRIME) % count;
- if (draw->layer[l].is_tall) {
- ox += FULL_TILE_X_OFFSET;
- oy += FULL_TILE_Y_OFFSET;
+ if (count > 0) {
+ /* Pseudo-random reproducable algorithm to pick a sprite. */
+ const int LARGE_PRIME = 10007;
+ const int SMALL_PRIME = 1009;
+
+ assert(count < SMALL_PRIME);
+ assert((int)(LARGE_PRIME * MAP_INDEX_SIZE) > 0);
+ count = ((ptile->index
+ * LARGE_PRIME) % SMALL_PRIME) % count;
+ if (draw->layer[l].is_tall) {
+ ox += FULL_TILE_X_OFFSET;
+ oy += FULL_TILE_Y_OFFSET;
+ }
+ ADD_SPRITE(draw->layer[l].base.p[count], TRUE, ox, oy);
}
- ADD_SPRITE(draw->layer[l].base.p[count], TRUE, ox, oy);
} else {
int match_type = draw->layer[l].match_type;
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev