summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-01-03 08:50:44 +0000
committertron <tron@openttd.org>2005-01-03 08:50:44 +0000
commit29e71638ce1dfa3d86a3b0ddf5b109e4fb0320a9 (patch)
tree5c567cb4d90a99802939c3df5715fe67cc68f45b
parent608cdbe3f67b9b05ace108cdf1ab4ffc808c792a (diff)
downloadopenttd-29e71638ce1dfa3d86a3b0ddf5b109e4fb0320a9.tar.xz
(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows
-rw-r--r--misc_cmd.c6
-rw-r--r--texteff.c13
-rw-r--r--ttd.h6
-rw-r--r--vehicle.h5
-rw-r--r--viewport.c23
-rw-r--r--viewport.h2
-rw-r--r--window.h10
7 files changed, 43 insertions, 22 deletions
diff --git a/misc_cmd.c b/misc_cmd.c
index 087eb0a0d..714a22b5e 100644
--- a/misc_cmd.c
+++ b/misc_cmd.c
@@ -321,8 +321,10 @@ int32 CmdChangeDifficultyLevel(int x, int y, uint32 flags, uint32 p1, uint32 p2)
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()
};
diff --git a/texteff.c b/texteff.c
index 05c9fc189..e9510fc57 100644
--- a/texteff.c
+++ b/texteff.c
@@ -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 @@ void DrawTextEffects(DrawPixelInfo *dpi)
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);
}
diff --git a/ttd.h b/ttd.h
index 45880270f..ee8967cfd 100644
--- a/ttd.h
+++ b/ttd.h
@@ -273,14 +273,16 @@ typedef struct TileDesc {
} 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;
diff --git a/vehicle.h b/vehicle.h
index bceeff763..59dbaf62e 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -178,7 +178,10 @@ struct Vehicle {
// 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
diff --git a/viewport.c b/viewport.c
index 3c8d72e92..b6bb6ba03 100644
--- a/viewport.c
+++ b/viewport.c
@@ -18,8 +18,8 @@ typedef struct StringSpriteToDraw {
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 StringSpriteToDraw {
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 @@ Point GetTileZoomCenterWindow(bool in, Window * w)
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;
diff --git a/viewport.h b/viewport.h
index e2f474c4e..068d34953 100644
--- a/viewport.h
+++ b/viewport.h
@@ -25,7 +25,7 @@ void UpdateViewportPosition(Window *w);
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);
diff --git a/window.h b/window.h
index 0d7c8be54..55c585999 100644
--- a/window.h
+++ b/window.h
@@ -276,7 +276,9 @@ typedef struct {
} 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 {
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;