# HG changeset patch # User rubidium # Date 2007-06-21 19:08:47 # Node ID 514975584cfc9779f37a026dfa3d302d1687a628 # Parent 9f6265c4d056afc63a26b33fdad3ed27325df593 (svn r10262) -Fix (r10258): some places that needed to be changed to uint64 were hidden/forgotten, which caused memory corruptions and that in caused all kinds of assertions to trigger. diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp --- a/src/misc_gui.cpp +++ b/src/misc_gui.cpp @@ -702,7 +702,7 @@ static void TooltipsWndProc(Window *w, W * @param paramcount number of params to deal with * @param params (optional) up to 5 pieces of additional information that may be * added to a tooltip; currently only supports parameters of {NUM} (integer) */ -void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint32 params[]) +void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]) { char buffer[512]; BoundingRect br; @@ -1214,7 +1214,7 @@ enum QueryWidgets { struct query_d { void (*proc)(Window*, bool); ///< callback function executed on closing of popup. Window* points to parent, bool is true if 'yes' clicked, false otherwise StringID message; ///< message shown for query window - uint32 params[20]; ///< local copy of _decode_parameters + uint64 params[10]; ///< local copy of _decode_parameters bool calledback; ///< has callback been executed already (internal usage for WE_DESTROY event) }; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(query_d)); diff --git a/src/news.h b/src/news.h --- a/src/news.h +++ b/src/news.h @@ -17,7 +17,7 @@ struct NewsItem { TileIndex data_a; TileIndex data_b; - uint32 params[10]; + uint64 params[10]; }; typedef bool ValidationProc ( uint data_a, uint data_b ); diff --git a/src/strings.cpp b/src/strings.cpp --- a/src/strings.cpp +++ b/src/strings.cpp @@ -217,7 +217,7 @@ void SetDParamStr(uint n, const char *st void InjectDParam(int amount) { - memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint32)); + memmove(_decode_parameters + amount, _decode_parameters, sizeof(_decode_parameters) - amount * sizeof(uint64)); } static const uint32 _divisor_table[] = { diff --git a/src/texteff.cpp b/src/texteff.cpp --- a/src/texteff.cpp +++ b/src/texteff.cpp @@ -35,8 +35,8 @@ struct TextEffect { int32 right; int32 bottom; uint16 duration; - uint32 params_1; - uint32 params_2; + uint64 params_1; + uint64 params_2; TextEffectMode mode; }; diff --git a/src/viewport.cpp b/src/viewport.cpp --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -58,7 +58,7 @@ struct StringSpriteToDraw { StringSpriteToDraw *next; int32 x; int32 y; - uint32 params[2]; + uint64 params[2]; uint16 width; }; @@ -580,7 +580,7 @@ void AddChildSpriteScreen(SpriteID image } /* Returns a StringSpriteToDraw */ -void *AddStringToDraw(int x, int y, StringID string, uint32 params_1, uint32 params_2) +void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2) { ViewportDrawer *vd = _cur_vd; StringSpriteToDraw *ss; @@ -2028,7 +2028,7 @@ void VpSetPlaceSizingLimit(int limit) * @param to TileIndex of the last tile to highlight */ void VpSetPresizeRange(TileIndex from, TileIndex to) { - uint distance = DistanceManhattan(from, to) + 1; + uint64 distance = DistanceManhattan(from, to) + 1; _thd.selend.x = TileX(to) * TILE_SIZE; _thd.selend.y = TileY(to) * TILE_SIZE; @@ -2304,7 +2304,7 @@ static void CalcRaildirsDrawstyle(TileHi TileIndex t1 = TileVirtXY(x, y); uint distance = DistanceManhattan(t0, t1) + 1; byte index = 0; - uint params[2]; + uint64 params[2]; if (distance != 1) { int heightdiff = CalcHeightdiff(b, distance, t0, t1); @@ -2383,7 +2383,7 @@ calc_heightdiff_single_direction:; TileIndex t1 = TileVirtXY(x, y); uint distance = DistanceManhattan(t0, t1) + 1; byte index = 0; - uint params[2]; + uint64 params[2]; if (distance != 1) { /* With current code passing a HT_LINE style to calculate the height @@ -2416,7 +2416,7 @@ calc_heightdiff_single_direction:; uint dx = delta(TileX(t0), TileX(t1)) + 1; uint dy = delta(TileY(t0), TileY(t1)) + 1; byte index = 0; - uint params[3]; + uint64 params[3]; /* If dragging an area (eg dynamite tool) and it is actually a single * row/column, change the type to 'line' to get proper calculation for height */ diff --git a/src/viewport.h b/src/viewport.h --- a/src/viewport.h +++ b/src/viewport.h @@ -49,7 +49,7 @@ void OffsetGroundSprite(int x, int y); void DrawGroundSprite(SpriteID image, SpriteID pal); void DrawGroundSpriteAt(SpriteID image, SpriteID pal, int32 x, int32 y, byte z); void AddSortableSpriteToDraw(SpriteID image, SpriteID pal, 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); +void *AddStringToDraw(int x, int y, StringID string, uint64 params_1, uint64 params_2); void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y); diff --git a/src/window.h b/src/window.h --- a/src/window.h +++ b/src/window.h @@ -321,7 +321,7 @@ assert_compile(WINDOW_CUSTOM_SIZE >= siz struct tooltips_d { StringID string_id; byte paramcount; - uint32 params[5]; + uint64 params[5]; }; assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d)); @@ -764,7 +764,7 @@ void CDECL SetWindowWidgetsHiddenState(W void CDECL SetWindowWidgetsLoweredState(Window *w, bool lowered_stat, int widgets, ...); /* misc_gui.cpp */ -void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint params[]); +void GuiShowTooltipsWithArgs(StringID str, uint paramcount, const uint64 params[]); static inline void GuiShowTooltips(StringID str) { GuiShowTooltipsWithArgs(str, 0, NULL);