(svn r1330) Increase size of some vars from int16 to int32 to guard against future overflows

This commit is contained in:
tron 2005-01-03 08:50:44 +00:00
parent 608cdbe3f6
commit 29e71638ce
7 changed files with 43 additions and 22 deletions

View File

@ -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()
};

View File

@ -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);
}

6
ttd.h
View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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);

View File

@ -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;