Changeset - r12385:b07134554c65
[Not reviewed]
master
0 5 0
rubidium - 15 years ago 2009-07-13 23:15:13
rubidium@openttd.org
(svn r16825) -Codechange: unify dirtying when updating the viewport signs.
5 files changed with 18 insertions and 40 deletions:
0 comments (0 inline, 0 general)
src/signs_cmd.cpp
Show inline comments
 
@@ -47,7 +47,6 @@ CommandCost CmdPlaceSign(TileIndex tile,
 
			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
 
			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
src/station_cmd.cpp
Show inline comments
 
@@ -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(Stati
 

	
 
	/* 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(Tile
 
		}
 

	
 
		st->MarkTilesDirty(false);
 
		UpdateStationVirtCoordDirty(st);
 
		st->UpdateVirtCoord();
 
		UpdateStationAcceptance(st, false);
 
		st->RecomputeIndustriesNear();
 
		InvalidateWindowData(WC_SELECT_STATION, 0, 0);
 
@@ -1218,7 +1203,7 @@ CommandCost CmdRemoveFromRailroadStation
 
		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
 
		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 t
 
			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(TileIn
 
		DoClearSquare(tile);
 
		st->rect.AfterRemoveTile(st, tile);
 

	
 
		UpdateStationVirtCoordDirty(st);
 
		st->UpdateVirtCoord();
 
		st->RecomputeIndustriesNear();
 
		DeleteStationIfEmpty(st);
 
	}
 
@@ -1837,7 +1822,7 @@ CommandCost CmdBuildAirport(TileIndex ti
 
			} 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(TileInd
 
			InvalidateWindow(WC_TOWN_VIEW, st->town->index);
 
		}
 

	
 
		UpdateStationVirtCoordDirty(st);
 
		st->UpdateVirtCoord();
 
		st->RecomputeIndustriesNear();
 
		DeleteStationIfEmpty(st);
 
	}
 
@@ -1957,7 +1942,7 @@ CommandCost CmdBuildBuoy(TileIndex tile,
 

	
 
		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 
 
		MakeWaterKeepingClass(tile, GetTileOwner(tile));
 
		MarkTileDirtyByTile(tile);
 

	
 
		UpdateStationVirtCoordDirty(st);
 
		st->UpdateVirtCoord();
 
		st->RecomputeIndustriesNear();
 
		DeleteStationIfEmpty(st);
 
	}
 
@@ -2136,7 +2121,7 @@ CommandCost CmdBuildDock(TileIndex tile,
 

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

	
 
		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;
 
}
src/town_cmd.cpp
Show inline comments
 
@@ -327,13 +327,11 @@ static bool IsCloseToTown(TileIndex tile
 
 */
 
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
 
		InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
 
		UpdateAllStationVirtCoords();
 
		UpdateAllWaypointVirtCoords();
 
		MarkWholeScreenDirty();
 
	}
 
	return CommandCost();
 
}
src/viewport.cpp
Show inline comments
 
@@ -1287,6 +1287,8 @@ static void ViewportAddWaypoints(DrawPix
 
 */
 
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 ce
 
	_cur_fontsize = FS_SMALL;
 
	this->width_small = GetStringBoundingBox(buffer).width + 3;
 
	_cur_fontsize = FS_NORMAL;
 

	
 
	this->MarkDirty();
 
}
 

	
 
/**
src/waypoint_cmd.cpp
Show inline comments
 
@@ -180,7 +180,6 @@ CommandCost CmdBuildTrainWaypoint(TileIn
 
				}
 
			}
 

	
 
			wp->sign.MarkDirty();
 
			wp->xy = tile;
 
			InvalidateWindowData(WC_WAYPOINT_VIEW, wp->index);
 
		}
 
@@ -212,7 +211,6 @@ CommandCost CmdBuildTrainWaypoint(TileIn
 
		if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp);
 

	
 
		wp->UpdateVirtCoord();
 
		wp->sign.MarkDirty();
 
		YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
 
	}
 

	
 
@@ -320,7 +318,6 @@ CommandCost CmdRenameWaypoint(TileIndex 
 
		}
 

	
 
		wp->UpdateVirtCoord();
 
		MarkWholeScreenDirty();
 
	}
 
	return CommandCost();
 
}
0 comments (0 inline, 0 general)