diff options
author | rubidium <rubidium@openttd.org> | 2009-07-13 23:15:13 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2009-07-13 23:15:13 +0000 |
commit | 2b1c43f81f792a1aa28065c1fef4ea9cbad1f5a9 (patch) | |
tree | 9b98a78d444cd0aa174569000255df06d53ae562 | |
parent | 0e1dc88b9bb40c226f7f2e71200401fa42fc1cc3 (diff) | |
download | openttd-2b1c43f81f792a1aa28065c1fef4ea9cbad1f5a9.tar.xz |
(svn r16825) -Codechange: unify dirtying when updating the viewport signs.
-rw-r--r-- | src/signs_cmd.cpp | 4 | ||||
-rw-r--r-- | src/station_cmd.cpp | 44 | ||||
-rw-r--r-- | src/town_cmd.cpp | 3 | ||||
-rw-r--r-- | src/viewport.cpp | 4 | ||||
-rw-r--r-- | src/waypoint_cmd.cpp | 3 |
5 files changed, 18 insertions, 40 deletions
diff --git a/src/signs_cmd.cpp b/src/signs_cmd.cpp index 968885533..9d18c21c0 100644 --- a/src/signs_cmd.cpp +++ b/src/signs_cmd.cpp @@ -47,7 +47,6 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 si->name = strdup(text); } si->UpdateVirtCoord(); - si->sign.MarkDirty(); InvalidateWindowData(WC_SIGN_LIST, 0, 0); _new_sign_id = si->index; } @@ -80,10 +79,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 si->name = strdup(text); si->owner = _current_company; - /* Update; mark sign dirty twice, because it can either become longer, or shorter */ - si->sign.MarkDirty(); si->UpdateVirtCoord(); - si->sign.MarkDirty(); InvalidateWindowData(WC_SIGN_LIST, 0, 1); } } else { // Delete sign diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index a47655736..4ab1a93f3 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -391,21 +391,6 @@ void UpdateAllStationVirtCoords() } } -/** - * Update the station virt coords while making the modified parts dirty. - * - * This function updates the virt coords and mark the modified parts as dirty - * - * @param st The station to update the virt coords - * @ingroup dirty - */ -static void UpdateStationVirtCoordDirty(Station *st) -{ - st->sign.MarkDirty(); - st->UpdateVirtCoord(); - st->sign.MarkDirty(); -} - /** Get a mask of the cargo types that the station accepts. * @param st Station to query * @return the expected mask @@ -598,7 +583,7 @@ static void UpdateStationSignCoord(Station *st) /* clamp sign coord to be inside the station rect */ st->xy = TileXY(ClampU(TileX(st->xy), r->left, r->right), ClampU(TileY(st->xy), r->top, r->bottom)); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); } /** This is called right after a station was deleted. @@ -1043,7 +1028,7 @@ CommandCost CmdBuildRailroadStation(TileIndex tile_org, DoCommandFlag flags, uin } st->MarkTilesDirty(false); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); InvalidateWindowData(WC_SELECT_STATION, 0, 0); @@ -1218,7 +1203,7 @@ CommandCost CmdRemoveFromRailroadStation(TileIndex tile, DoCommandFlag flags, ui if (st->train_tile == INVALID_TILE) { st->facilities &= ~FACIL_TRAIN; InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); DeleteStationIfEmpty(st); } @@ -1302,7 +1287,7 @@ static CommandCost RemoveRailroadStation(TileIndex tile, DoCommandFlag flags) st->cached_anim_triggers = 0; InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_TRAINS); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); DeleteStationIfEmpty(st); } @@ -1468,7 +1453,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin MakeRoadStop(tile, st->owner, st->index, rs_type, rts, (DiagDirection)p1); } - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); InvalidateWindowData(WC_SELECT_STATION, 0, 0); @@ -1553,7 +1538,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags) DoClearSquare(tile); st->rect.AfterRemoveTile(st, tile); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); DeleteStationIfEmpty(st); } @@ -1837,7 +1822,7 @@ CommandCost CmdBuildAirport(TileIndex tile, DoCommandFlag flags, uint32 p1, uint } END_TILE_LOOP(tile_cur, w, h, tile) } - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); InvalidateWindowData(WC_SELECT_STATION, 0, 0); @@ -1913,7 +1898,7 @@ static CommandCost RemoveAirport(TileIndex tile, DoCommandFlag flags) InvalidateWindow(WC_TOWN_VIEW, st->town->index); } - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); DeleteStationIfEmpty(st); } @@ -1957,7 +1942,7 @@ CommandCost CmdBuildBuoy(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 MakeBuoy(tile, st->index, GetWaterClass(tile)); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); InvalidateWindowData(WC_STATION_LIST, st->owner, 0); @@ -2021,7 +2006,7 @@ static CommandCost RemoveBuoy(TileIndex tile, DoCommandFlag flags) MakeWaterKeepingClass(tile, GetTileOwner(tile)); MarkTileDirtyByTile(tile); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); DeleteStationIfEmpty(st); } @@ -2136,7 +2121,7 @@ CommandCost CmdBuildDock(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 MakeDock(tile, st->owner, st->index, direction, wc); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); InvalidateWindowData(WC_SELECT_STATION, 0, 0); @@ -2177,7 +2162,7 @@ static CommandCost RemoveDock(TileIndex tile, DoCommandFlag flags) st->facilities &= ~FACIL_DOCK; InvalidateWindowWidget(WC_STATION_VIEW, st->index, SVW_SHIPS); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); DeleteStationIfEmpty(st); } @@ -2850,7 +2835,6 @@ CommandCost CmdRenameStation(TileIndex tile, DoCommandFlag flags, uint32 p1, uin st->UpdateVirtCoord(); InvalidateWindowData(WC_STATION_LIST, st->owner, 1); - MarkWholeScreenDirty(); } return CommandCost(); @@ -3008,7 +2992,7 @@ void BuildOilRig(TileIndex tile) st->goods[j].last_age = 255; } - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); UpdateStationAcceptance(st, false); st->RecomputeIndustriesNear(); } @@ -3027,7 +3011,7 @@ void DeleteOilRig(TileIndex tile) st->rect.AfterRemoveTile(st, tile); - UpdateStationVirtCoordDirty(st); + st->UpdateVirtCoord(); st->RecomputeIndustriesNear(); if (st->facilities == 0) delete st; } diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index cc806f238..e361cb1f3 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -327,13 +327,11 @@ static bool IsCloseToTown(TileIndex tile, uint dist) */ void Town::UpdateVirtCoord() { - this->sign.MarkDirty(); Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE); SetDParam(0, this->index); SetDParam(1, this->population); this->sign.UpdatePosition(pt.x, pt.y - 24, _settings_client.gui.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL); - this->sign.MarkDirty(); } /** Update the virtual coords needed to draw the town sign for all towns. */ @@ -2289,7 +2287,6 @@ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1); UpdateAllStationVirtCoords(); UpdateAllWaypointVirtCoords(); - MarkWholeScreenDirty(); } return CommandCost(); } diff --git a/src/viewport.cpp b/src/viewport.cpp index 0c510693e..e881edf64 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1287,6 +1287,8 @@ static void ViewportAddWaypoints(DrawPixelInfo *dpi) */ void ViewportSign::UpdatePosition(int center, int top, StringID str) { + if (this->width_normal != 0) this->MarkDirty(); + this->top = top; char buffer[DRAW_STRING_BUFFER]; @@ -1299,6 +1301,8 @@ void ViewportSign::UpdatePosition(int center, int top, StringID str) _cur_fontsize = FS_SMALL; this->width_small = GetStringBoundingBox(buffer).width + 3; _cur_fontsize = FS_NORMAL; + + this->MarkDirty(); } /** diff --git a/src/waypoint_cmd.cpp b/src/waypoint_cmd.cpp index e2ad292ba..ded31903c 100644 --- a/src/waypoint_cmd.cpp +++ b/src/waypoint_cmd.cpp @@ -180,7 +180,6 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1 } } - wp->sign.MarkDirty(); wp->xy = tile; InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index); } @@ -212,7 +211,6 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1 if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp); wp->UpdateVirtCoord(); - wp->sign.MarkDirty(); YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis)); } @@ -320,7 +318,6 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui } wp->UpdateVirtCoord(); - MarkWholeScreenDirty(); } return CommandCost(); } |