(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
authortron
Mon, 03 Jan 2005 08:50:44 +0000
changeset 849 c3407041774f
parent 848 cd8ab251c7de
child 850 7a9b9f01d5f0
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
misc_cmd.c
texteff.c
ttd.h
vehicle.h
viewport.c
viewport.h
window.h
--- a/misc_cmd.c	Mon Jan 03 08:34:54 2005 +0000
+++ b/misc_cmd.c	Mon Jan 03 08:50:44 2005 +0000
@@ -321,8 +321,10 @@
 
 static const byte _sign_desc[] = {
 	SLE_VAR(SignStruct,str,						SLE_UINT16),
-	SLE_VAR(SignStruct,x,							SLE_INT16),
-	SLE_VAR(SignStruct,y,							SLE_INT16),
+	SLE_CONDVAR(SignStruct,x,         SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
+	SLE_CONDVAR(SignStruct,y,         SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
+	SLE_CONDVAR(SignStruct,x,         SLE_INT32, 5, 255),
+	SLE_CONDVAR(SignStruct,y,         SLE_INT32, 5, 255),
 	SLE_VAR(SignStruct,z,							SLE_UINT8),
 	SLE_END()
 };
--- a/texteff.c	Mon Jan 03 08:34:54 2005 +0000
+++ b/texteff.c	Mon Jan 03 08:50:44 2005 +0000
@@ -9,7 +9,10 @@
 
 typedef struct TextEffect {
 	StringID string_id;
-	int16 x,y,right,bottom;
+	int32 x;
+	int32 y;
+	int32 right;
+	int32 bottom;
 	uint16 duration;
 	uint32 params_1;
 	uint32 params_2;
@@ -276,10 +279,10 @@
 				continue;
 
 			/* intersection? */
-			if ((int16)dpi->left > te->right ||
-					(int16)dpi->top > te->bottom ||
-					(int16)(dpi->left + dpi->width) <= te->x ||
-					(int16)(dpi->top + dpi->height) <= te->y)
+			if (dpi->left > te->right ||
+					dpi->top > te->bottom ||
+					dpi->left + dpi->width <= te->x ||
+					dpi->top + dpi->height <= te->y)
 						continue;
 			AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2, 0);
 		}
--- a/ttd.h	Mon Jan 03 08:34:54 2005 +0000
+++ b/ttd.h	Mon Jan 03 08:50:44 2005 +0000
@@ -273,14 +273,16 @@
 } TileDesc;
 
 typedef struct {
-	int16 left, top;
+	int32 left;
+	int32 top;
 	byte width_1, width_2;
 } ViewportSign;
 
 typedef struct SignStruct {
 	StringID str;
 	ViewportSign sign;
-	int16 x,y;
+	int32 x;
+	int32 y;
 	byte z;
 } SignStruct;
 
--- a/vehicle.h	Mon Jan 03 08:34:54 2005 +0000
+++ b/vehicle.h	Mon Jan 03 08:50:44 2005 +0000
@@ -178,7 +178,10 @@
 
 	// Boundaries for the current position in the world and a next hash link.
 	// NOSAVE: All of those can be updated with VehiclePositionChanged()
-	int16 left_coord, top_coord, right_coord, bottom_coord;
+	int32 left_coord;
+	int32 top_coord;
+	int32 right_coord;
+	int32 bottom_coord;
 	uint16 next_hash;
 
 	// Related to age and service time
--- a/viewport.c	Mon Jan 03 08:34:54 2005 +0000
+++ b/viewport.c	Mon Jan 03 08:50:44 2005 +0000
@@ -18,8 +18,8 @@
 	uint16 string;
 	uint16 color;
 	struct StringSpriteToDraw *next;
-	int16 x;
-	int16 y;
+	int32 x;
+	int32 y;
 	uint32 params[3];
 	uint16 width;
 } StringSpriteToDraw;
@@ -27,21 +27,28 @@
 typedef struct TileSpriteToDraw {
 	uint32 image;
 	struct TileSpriteToDraw *next;
-	int16 x, y;
+	int32 x;
+	int32 y;
 	byte z;
 } TileSpriteToDraw;
 
 typedef struct ChildScreenSpriteToDraw {
 	uint32 image;
-	int16 x,y;
+	int32 x;
+	int32 y;
 	struct ChildScreenSpriteToDraw *next;
 } ChildScreenSpriteToDraw;
 
 typedef struct ParentSpriteToDraw {
 	uint32 image;
-	int16 left, top, right, bottom;
-	int16 tile_x, tile_y;
-	int16 tile_right, tile_bottom;
+	int32 left;
+	int32 top;
+	int32 right;
+	int32 bottom;
+	int32 tile_x;
+	int32 tile_y;
+	int32 tile_right;
+	int32 tile_bottom;
 	ChildScreenSpriteToDraw *child;
 	byte unk16;
 	byte tile_z;
@@ -333,7 +340,7 @@
 	return GetTileFromScreenXY(x+vp->left, y+vp->top);
 }
 
-void DrawGroundSpriteAt(uint32 image, int16 x, int16 y, byte z)
+void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z)
 {
 	ViewportDrawer *vd = _cur_vd;
 	TileSpriteToDraw *ts;
--- a/viewport.h	Mon Jan 03 08:34:54 2005 +0000
+++ b/viewport.h	Mon Jan 03 08:50:44 2005 +0000
@@ -25,7 +25,7 @@
 void OffsetGroundSprite(int x, int y);
 
 void DrawGroundSprite(uint32 image);
-void DrawGroundSpriteAt(uint32 image, int16 x, int16 y, byte z);
+void DrawGroundSpriteAt(uint32 image, int32 x, int32 y, byte z);
 void AddSortableSpriteToDraw(uint32 image, int x, int y, int w, int h, byte dz, byte z);
 void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3);
 void AddChildSpriteScreen(uint32 image, int x, int y);
--- a/window.h	Mon Jan 03 08:34:54 2005 +0000
+++ b/window.h	Mon Jan 03 08:50:44 2005 +0000
@@ -276,7 +276,9 @@
 } traindetails_d;
 
 typedef struct {
-	int16 scroll_x, scroll_y, subscroll;
+	int32 scroll_x;
+	int32 scroll_y;
+	int32 subscroll;
 } smallmap_d;
 
 typedef struct {
@@ -291,12 +293,14 @@
 
 typedef struct {
 	uint16 follow_vehicle;
-	int16 scrollpos_x, scrollpos_y;
+	int32 scrollpos_x;
+	int32 scrollpos_y;
 } vp_d;
 
 typedef struct {
 	uint16 follow_vehicle;
-	int16 scrollpos_x, scrollpos_y;
+	int32 scrollpos_x;
+	int32 scrollpos_y;
 	NewsItem *ni;
 } news_d;