1
0
Fork 0

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

release/0.4.5
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[] = { static const byte _sign_desc[] = {
SLE_VAR(SignStruct,str, SLE_UINT16), SLE_VAR(SignStruct,str, SLE_UINT16),
SLE_VAR(SignStruct,x, SLE_INT16), SLE_CONDVAR(SignStruct,x, SLE_FILE_I16 | SLE_VAR_I32, 0, 4),
SLE_VAR(SignStruct,y, SLE_INT16), 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_VAR(SignStruct,z, SLE_UINT8),
SLE_END() SLE_END()
}; };

View File

@ -9,7 +9,10 @@
typedef struct TextEffect { typedef struct TextEffect {
StringID string_id; StringID string_id;
int16 x,y,right,bottom; int32 x;
int32 y;
int32 right;
int32 bottom;
uint16 duration; uint16 duration;
uint32 params_1; uint32 params_1;
uint32 params_2; uint32 params_2;
@ -276,10 +279,10 @@ void DrawTextEffects(DrawPixelInfo *dpi)
continue; continue;
/* intersection? */ /* intersection? */
if ((int16)dpi->left > te->right || if (dpi->left > te->right ||
(int16)dpi->top > te->bottom || dpi->top > te->bottom ||
(int16)(dpi->left + dpi->width) <= te->x || dpi->left + dpi->width <= te->x ||
(int16)(dpi->top + dpi->height) <= te->y) dpi->top + dpi->height <= te->y)
continue; continue;
AddStringToDraw(te->x, te->y, te->string_id, te->params_1, te->params_2, 0); 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; } TileDesc;
typedef struct { typedef struct {
int16 left, top; int32 left;
int32 top;
byte width_1, width_2; byte width_1, width_2;
} ViewportSign; } ViewportSign;
typedef struct SignStruct { typedef struct SignStruct {
StringID str; StringID str;
ViewportSign sign; ViewportSign sign;
int16 x,y; int32 x;
int32 y;
byte z; byte z;
} SignStruct; } SignStruct;

View File

@ -178,7 +178,10 @@ struct Vehicle {
// Boundaries for the current position in the world and a next hash link. // Boundaries for the current position in the world and a next hash link.
// NOSAVE: All of those can be updated with VehiclePositionChanged() // 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; uint16 next_hash;
// Related to age and service time // Related to age and service time

View File

@ -18,8 +18,8 @@ typedef struct StringSpriteToDraw {
uint16 string; uint16 string;
uint16 color; uint16 color;
struct StringSpriteToDraw *next; struct StringSpriteToDraw *next;
int16 x; int32 x;
int16 y; int32 y;
uint32 params[3]; uint32 params[3];
uint16 width; uint16 width;
} StringSpriteToDraw; } StringSpriteToDraw;
@ -27,21 +27,28 @@ typedef struct StringSpriteToDraw {
typedef struct TileSpriteToDraw { typedef struct TileSpriteToDraw {
uint32 image; uint32 image;
struct TileSpriteToDraw *next; struct TileSpriteToDraw *next;
int16 x, y; int32 x;
int32 y;
byte z; byte z;
} TileSpriteToDraw; } TileSpriteToDraw;
typedef struct ChildScreenSpriteToDraw { typedef struct ChildScreenSpriteToDraw {
uint32 image; uint32 image;
int16 x,y; int32 x;
int32 y;
struct ChildScreenSpriteToDraw *next; struct ChildScreenSpriteToDraw *next;
} ChildScreenSpriteToDraw; } ChildScreenSpriteToDraw;
typedef struct ParentSpriteToDraw { typedef struct ParentSpriteToDraw {
uint32 image; uint32 image;
int16 left, top, right, bottom; int32 left;
int16 tile_x, tile_y; int32 top;
int16 tile_right, tile_bottom; int32 right;
int32 bottom;
int32 tile_x;
int32 tile_y;
int32 tile_right;
int32 tile_bottom;
ChildScreenSpriteToDraw *child; ChildScreenSpriteToDraw *child;
byte unk16; byte unk16;
byte tile_z; byte tile_z;
@ -333,7 +340,7 @@ Point GetTileZoomCenterWindow(bool in, Window * w)
return GetTileFromScreenXY(x+vp->left, y+vp->top); 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; ViewportDrawer *vd = _cur_vd;
TileSpriteToDraw *ts; TileSpriteToDraw *ts;

View File

@ -25,7 +25,7 @@ void UpdateViewportPosition(Window *w);
void OffsetGroundSprite(int x, int y); void OffsetGroundSprite(int x, int y);
void DrawGroundSprite(uint32 image); 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 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 *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2, uint32 params_3);
void AddChildSpriteScreen(uint32 image, int x, int y); void AddChildSpriteScreen(uint32 image, int x, int y);

View File

@ -276,7 +276,9 @@ typedef struct {
} traindetails_d; } traindetails_d;
typedef struct { typedef struct {
int16 scroll_x, scroll_y, subscroll; int32 scroll_x;
int32 scroll_y;
int32 subscroll;
} smallmap_d; } smallmap_d;
typedef struct { typedef struct {
@ -291,12 +293,14 @@ typedef struct {
typedef struct { typedef struct {
uint16 follow_vehicle; uint16 follow_vehicle;
int16 scrollpos_x, scrollpos_y; int32 scrollpos_x;
int32 scrollpos_y;
} vp_d; } vp_d;
typedef struct { typedef struct {
uint16 follow_vehicle; uint16 follow_vehicle;
int16 scrollpos_x, scrollpos_y; int32 scrollpos_x;
int32 scrollpos_y;
NewsItem *ni; NewsItem *ni;
} news_d; } news_d;