(svn r16821) -Codechange: unify the naming of type::UpdateVirtCoord and UpdateAll[Type]VirtCoords.

pull/155/head
rubidium 15 years ago
parent a2ce1e6e8f
commit 79deeee323

@ -183,7 +183,7 @@ void ZoomInOrOutToCursorWindow(bool in, Window *w)
}
}
extern void UpdateAllStationVirtCoord();
extern void UpdateAllStationVirtCoords();
struct MainWindow : Window
{
@ -268,7 +268,7 @@ struct MainWindow : Window
break;
case '2' | WKC_ALT: // Update the coordinates of all station signs
UpdateAllStationVirtCoord();
UpdateAllStationVirtCoords();
break;
#endif

@ -213,10 +213,10 @@ static bool InitializeWindowsAndCaches()
ResetViewportAfterLoadGame();
/* Update coordinates of the signs. */
UpdateAllStationVirtCoord();
UpdateAllStationVirtCoords();
UpdateAllSignVirtCoords();
UpdateAllTownVirtCoords();
UpdateAllWaypointSigns();
UpdateAllWaypointVirtCoords();
Company *c;
FOR_ALL_COMPANIES(c) {

@ -645,9 +645,7 @@ static bool v_PositionMainToolbar(int32 p1)
static bool PopulationInLabelActive(int32 p1)
{
Town *t;
FOR_ALL_TOWNS(t) UpdateTownVirtCoord(t);
UpdateAllTownVirtCoords();
return true;
}

@ -321,8 +321,8 @@ struct GameOptionsWindow : Window {
case GOW_LANG_DROPDOWN: // Change interface language
ReadLanguagePack(index);
CheckForMissingGlyphsInLoadedLanguagePack();
UpdateAllStationVirtCoord();
UpdateAllWaypointSigns();
UpdateAllStationVirtCoords();
UpdateAllWaypointVirtCoords();
ReInitAllWindows();
MarkWholeScreenDirty();
break;

@ -33,16 +33,13 @@ Sign::~Sign()
}
/**
*
* Update the coordinate of one sign
* @param si Pointer to the Sign
*
*/
void UpdateSignVirtCoords(Sign *si)
void Sign::UpdateVirtCoord()
{
Point pt = RemapCoords(si->x, si->y, si->z);
SetDParam(0, si->index);
si->sign.UpdatePosition(pt.x, pt.y - 6, STR_SIGN_WHITE);
Point pt = RemapCoords(this->x, this->y, this->z);
SetDParam(0, this->index);
this->sign.UpdatePosition(pt.x, pt.y - 6, STR_SIGN_WHITE);
}
/** Update the coordinates of all signs */
@ -50,7 +47,9 @@ void UpdateAllSignVirtCoords()
{
Sign *si;
FOR_ALL_SIGNS(si) UpdateSignVirtCoords(si);
FOR_ALL_SIGNS(si) {
si->UpdateVirtCoord();
}
}
/**

@ -28,6 +28,8 @@ struct Sign : SignPool::PoolItem<&_sign_pool> {
/** Destroy the sign */
~Sign();
void UpdateVirtCoord();
};
#define FOR_ALL_SIGNS_FROM(var, start) FOR_ALL_ITEMS_FROM(Sign, sign_index, var, start)

@ -46,7 +46,7 @@ CommandCost CmdPlaceSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (!StrEmpty(text)) {
si->name = strdup(text);
}
UpdateSignVirtCoords(si);
si->UpdateVirtCoord();
si->sign.MarkDirty();
InvalidateWindowData(WC_SIGN_LIST, 0, 0);
_new_sign_id = si->index;
@ -82,7 +82,7 @@ CommandCost CmdRenameSign(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
/* Update; mark sign dirty twice, because it can either become longer, or shorter */
si->sign.MarkDirty();
UpdateSignVirtCoords(si);
si->UpdateVirtCoord();
si->sign.MarkDirty();
InvalidateWindowData(WC_SIGN_LIST, 0, 1);
}

@ -11,7 +11,6 @@ extern SignID _new_sign_id;
void UpdateAllSignVirtCoords();
void PlaceProc_Sign(TileIndex tile);
void UpdateSignVirtCoords(Sign *si);
/* signs_gui.cpp */
void ShowRenameSignWindow(const Sign *si);

@ -367,9 +367,7 @@ static Station *GetClosestDeletedStation(TileIndex tile)
}
/**
* Update the virtual coords needed to draw the station sign and
* mark the station sign dirty.
* @ingroup dirty
* Update the virtual coords needed to draw the station sign.
*/
void Station::UpdateVirtCoord()
{
@ -384,7 +382,7 @@ void Station::UpdateVirtCoord()
}
/** Update the virtual coords needed to draw the station sign for all stations. */
void UpdateAllStationVirtCoord()
void UpdateAllStationVirtCoords()
{
Station *st;

@ -20,7 +20,7 @@ typedef SmallVector<Station*, 1> StationList;
void FindStationsAroundTiles(TileIndex tile, int w_prod, int h_prod, StationList *stations);
void ShowStationViewWindow(StationID station);
void UpdateAllStationVirtCoord();
void UpdateAllStationVirtCoords();
CargoArray GetProductionAroundTiles(TileIndex tile, int w, int h, int rad);
CargoArray GetAcceptanceAroundTiles(TileIndex tile, int w, int h, int rad);

@ -48,7 +48,7 @@ struct Town : TownPool::PoolItem<&_town_pool> {
uint32 townnameparts;
char *name;
/* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */
/* NOSAVE: Location of name sign, UpdateVirtCoord updates this. */
ViewportSign sign;
/* Makes sure we don't build certain house types twice.
@ -136,6 +136,8 @@ struct Town : TownPool::PoolItem<&_town_pool> {
return ((this->population / _settings_game.economy.town_noise_population[_settings_game.difficulty.town_council_tolerance]) + 3);
}
void UpdateVirtCoord();
static FORCEINLINE Town *GetByTile(TileIndex tile)
{
return Town::Get(GetTownIndex(tile));
@ -147,7 +149,6 @@ struct Town : TownPool::PoolItem<&_town_pool> {
uint32 GetWorldPopulation();
void UpdateTownVirtCoord(Town *t);
void UpdateAllTownVirtCoords();
void InitializeTown();
void ShowTownViewWindow(TownID town);

@ -324,25 +324,25 @@ static bool IsCloseToTown(TileIndex tile, uint dist)
/**
* Resize the sign(label) of the town after changes in
* population (creation or growth or else)
* @param t Town to update
*/
void UpdateTownVirtCoord(Town *t)
void Town::UpdateVirtCoord()
{
t->sign.MarkDirty();
Point pt = RemapCoords2(TileX(t->xy) * TILE_SIZE, TileY(t->xy) * TILE_SIZE);
SetDParam(0, t->index);
SetDParam(1, t->population);
t->sign.UpdatePosition(pt.x, pt.y - 24,
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);
t->sign.MarkDirty();
this->sign.MarkDirty();
}
/** Update the virtual coords needed to draw the town sign for all towns. */
void UpdateAllTownVirtCoords()
{
Town *t;
FOR_ALL_TOWNS(t) {
UpdateTownVirtCoord(t);
t->UpdateVirtCoord();
}
}
@ -355,7 +355,7 @@ static void ChangePopulation(Town *t, int mod)
{
t->population += mod;
InvalidateWindow(WC_TOWN_VIEW, t->index);
UpdateTownVirtCoord(t);
t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
}
@ -1505,7 +1505,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
}
t->townnameparts = townnameparts;
UpdateTownVirtCoord(t);
t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 0);
t->InitializeLayout(layout);
@ -2285,10 +2285,10 @@ CommandCost CmdRenameTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
free(t->name);
t->name = reset ? NULL : strdup(text);
UpdateTownVirtCoord(t);
t->UpdateVirtCoord();
InvalidateWindowData(WC_TOWN_DIRECTORY, 0, 1);
UpdateAllStationVirtCoord();
UpdateAllWaypointSigns();
UpdateAllStationVirtCoords();
UpdateAllWaypointVirtCoords();
MarkWholeScreenDirty();
}
return CommandCost();

@ -20,12 +20,12 @@ INSTANTIATE_POOL_METHODS(Waypoint)
/**
* Update all signs
*/
void UpdateAllWaypointSigns()
void UpdateAllWaypointVirtCoords()
{
Waypoint *wp;
FOR_ALL_WAYPOINTS(wp) {
UpdateWaypointSign(wp);
wp->UpdateVirtCoord();
}
}

@ -37,6 +37,8 @@ struct Waypoint : WaypointPool::PoolItem<&_waypoint_pool> {
Waypoint(TileIndex tile = INVALID_TILE) : xy(tile) { }
~Waypoint();
void UpdateVirtCoord();
};
#define FOR_ALL_WAYPOINTS_FROM(var, start) FOR_ALL_ITEMS_FROM(Waypoint, waypoint_index, var, start)
@ -58,7 +60,6 @@ CommandCost RemoveTrainWaypoint(TileIndex tile, DoCommandFlag flags, bool justre
Station *ComposeWaypointStation(TileIndex tile);
void ShowWaypointWindow(const Waypoint *wp);
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype);
void UpdateAllWaypointSigns();
void UpdateWaypointSign(Waypoint *wp);
void UpdateAllWaypointVirtCoords();
#endif /* WAYPOINT_H */

@ -26,13 +26,13 @@
#include "table/strings.h"
/**
* Update the sign for the waypoint
* @param wp Waypoint to update sign */
void UpdateWaypointSign(Waypoint *wp)
* Update the virtual coords needed to draw the waypoint sign.
*/
void Waypoint::UpdateVirtCoord()
{
Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
SetDParam(0, wp->index);
wp->sign.UpdatePosition(pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
Point pt = RemapCoords2(TileX(this->xy) * TILE_SIZE, TileY(this->xy) * TILE_SIZE);
SetDParam(0, this->index);
this->sign.UpdatePosition(pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
}
/**
@ -211,7 +211,7 @@ CommandCost CmdBuildTrainWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1
if (wp->town_index == INVALID_TOWN) MakeDefaultWaypointName(wp);
UpdateWaypointSign(wp);
wp->UpdateVirtCoord();
wp->sign.MarkDirty();
YapfNotifyTrackLayoutChange(tile, AxisToTrack(axis));
}
@ -319,7 +319,7 @@ CommandCost CmdRenameWaypoint(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
wp->name = strdup(text);
}
UpdateWaypointSign(wp);
wp->UpdateVirtCoord();
MarkWholeScreenDirty();
}
return CommandCost();

Loading…
Cancel
Save