summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-11-13 13:43:55 +0000
committertron <tron@openttd.org>2005-11-13 13:43:55 +0000
commitee15e3de13643b2d09abcc5424bf8e2d916cff75 (patch)
tree385ce09aff7cf19e072a627e83e91fe8a5f3fb3b
parent59e885c2bff5b1af6d7f5473106e9aa1f562abfd (diff)
downloadopenttd-ee15e3de13643b2d09abcc5424bf8e2d916cff75.tar.xz
(svn r3172) static, const
-rw-r--r--ai/default/default.c3
-rw-r--r--aircraft_cmd.c20
-rw-r--r--aircraft_gui.c7
-rw-r--r--economy.c4
-rw-r--r--economy.h2
-rw-r--r--industry.h2
-rw-r--r--industry_cmd.c25
-rw-r--r--main_gui.c19
-rw-r--r--misc_gui.c10
-rw-r--r--music_gui.c2
-rw-r--r--network_gui.c10
-rw-r--r--order.h4
-rw-r--r--order_cmd.c4
-rw-r--r--player_gui.c2
-rw-r--r--rail_gui.c2
-rw-r--r--roadveh_cmd.c2
-rw-r--r--roadveh_gui.c2
-rw-r--r--ship_cmd.c10
-rw-r--r--ship_gui.c6
-rw-r--r--station_cmd.c4
-rw-r--r--station_gui.c23
-rw-r--r--strings.c7
-rw-r--r--subsidy_gui.c9
-rw-r--r--town_cmd.c5
-rw-r--r--town_gui.c8
-rw-r--r--train_cmd.c21
-rw-r--r--train_gui.c2
-rw-r--r--vehicle.c14
-rw-r--r--vehicle.h4
-rw-r--r--vehicle_gui.c24
-rw-r--r--window.c6
31 files changed, 132 insertions, 131 deletions
diff --git a/ai/default/default.c b/ai/default/default.c
index 3c8264604..7f0ae2aa8 100644
--- a/ai/default/default.c
+++ b/ai/default/default.c
@@ -1905,7 +1905,8 @@ static const byte _dir_table_1[] = {3, 9, 12, 6};
static const byte _dir_table_2[] = {12, 6, 3, 9};
-static bool AiIsTileBanned(Player *p, TileIndex tile, byte val) {
+static bool AiIsTileBanned(const Player* p, TileIndex tile, byte val)
+{
int i;
for(i=0; i!=p->ai.banned_tile_count; i++)
diff --git a/aircraft_cmd.c b/aircraft_cmd.c
index 4dc24106f..13032b0a3 100644
--- a/aircraft_cmd.c
+++ b/aircraft_cmd.c
@@ -544,7 +544,7 @@ void HandleClickOnAircraft(Vehicle *v)
static void CheckIfAircraftNeedsService(Vehicle *v)
{
- Station *st;
+ const Station* st;
if (_patches.servint_aircraft == 0)
return;
@@ -1269,7 +1269,7 @@ static void AircraftEntersTerminal(Vehicle *v)
static bool ValidateAircraftInHangar( uint data_a, uint data_b )
{
- Vehicle *v = GetVehicle(data_a);
+ const Vehicle* v = GetVehicle(data_a);
return (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_STOPPED));
}
@@ -1324,7 +1324,7 @@ static void AircraftLandAirplane(Vehicle *v)
// set the right pos when heading to other airports after takeoff
static void AircraftNextAirportPos_and_Order(Vehicle *v)
{
- Station *st;
+ const Station* st;
const AirportFTAClass *Airport;
if (v->current_order.type == OT_GOTO_STATION ||
@@ -1634,7 +1634,7 @@ static AircraftStateHandler * const _aircraft_state_handlers[] = {
AircraftEventHandler_HeliEndLanding,// HELIENDLANDING = 18
};
-static void AirportClearBlock(Vehicle *v, const AirportFTAClass *Airport)
+static void AirportClearBlock(const Vehicle* v, const AirportFTAClass* Airport)
{
Station *st;
// we have left the previous block, and entered the new one. Free the previous block
@@ -1706,16 +1706,14 @@ static bool AirportMove(Vehicle *v, const AirportFTAClass *Airport)
// returns true if the road ahead is busy, eg. you must wait before proceeding
static bool AirportHasBlock(Vehicle *v, AirportFTA *current_pos, const AirportFTAClass *Airport)
{
- Station *st;
- uint32 airport_flags;
- AirportFTA *next, *reference;
- reference = &Airport->layout[v->u.air.pos];
- next = &Airport->layout[current_pos->next_position];
+ const AirportFTA* reference = &Airport->layout[v->u.air.pos];
+ const AirportFTA* next = &Airport->layout[current_pos->next_position];
// same block, then of course we can move
if (Airport->layout[current_pos->position].block != next->block) {
- airport_flags = next->block;
- st = GetStation(v->u.air.targetairport);
+ const Station* st = GetStation(v->u.air.targetairport);
+ uint32 airport_flags = next->block;
+
// check additional possible extra blocks
if (current_pos != reference && current_pos->block != NOTHING_block) {
airport_flags |= current_pos->block;
diff --git a/aircraft_gui.c b/aircraft_gui.c
index cb092deeb..8cd5c620a 100644
--- a/aircraft_gui.c
+++ b/aircraft_gui.c
@@ -77,10 +77,9 @@ static void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selectio
void CcBuildAircraft(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
- Vehicle *v;
-
if (success) {
- v = GetVehicle(_new_aircraft_id);
+ const Vehicle* v = GetVehicle(_new_aircraft_id);
+
if (v->tile == _backup_orders_tile) {
_backup_orders_tile = 0;
RestoreVehicleOrders(v, _backup_orders_data);
@@ -508,7 +507,7 @@ static void AircraftViewWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
- Vehicle *v = GetVehicle(w->window_number);
+ const Vehicle* v = GetVehicle(w->window_number);
uint32 disabled = 1<<8;
StringID str;
diff --git a/economy.c b/economy.c
index 00490a166..6b0029168 100644
--- a/economy.c
+++ b/economy.c
@@ -825,7 +825,7 @@ void StartupEconomy(void)
_economy.fluct = GB(Random(), 0, 8) + 168;
}
-Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode)
+Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode)
{
TileIndex tile;
TileIndex tile2;
@@ -983,7 +983,7 @@ static void FindSubsidyCargoRoute(FoundRoute *fr)
static bool CheckSubsidyDuplicate(Subsidy *s)
{
- Subsidy *ss;
+ const Subsidy* ss;
for(ss=_subsidies; ss != endof(_subsidies); ss++) {
if (s != ss &&
diff --git a/economy.h b/economy.h
index 404f5ded7..00c7ce4dd 100644
--- a/economy.h
+++ b/economy.h
@@ -60,7 +60,7 @@ void UpdatePlayerHouse(Player *p, uint score);
VARDEF Subsidy _subsidies[MAX_PLAYERS];
-Pair SetupSubsidyDecodeParam(Subsidy *s, bool mode);
+Pair SetupSubsidyDecodeParam(const Subsidy* s, bool mode);
void DeleteSubsidyWithIndustry(uint16 index);
void DeleteSubsidyWithStation(uint16 index);
diff --git a/industry.h b/industry.h
index 0e2fb5876..ef2ec6f38 100644
--- a/industry.h
+++ b/industry.h
@@ -9,7 +9,7 @@ struct Industry {
TileIndex xy;
byte width; /* swapped order of w/h with town */
byte height;
- Town *town;
+ const Town* town;
byte produced_cargo[2];
uint16 cargo_waiting[2];
byte production_rate[2];
diff --git a/industry_cmd.c b/industry_cmd.c
index b0f818984..239808c5e 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -38,8 +38,8 @@ void IndustryPoolNewBlock(uint start_item)
/* Initialize the industry-pool */
MemoryPool _industry_pool = { "Industry", INDUSTRY_POOL_MAX_BLOCKS, INDUSTRY_POOL_BLOCK_SIZE_BITS, sizeof(Industry), &IndustryPoolNewBlock, 0, 0, NULL };
-byte _industry_sound_ctr;
-TileIndex _industry_sound_tile;
+static byte _industry_sound_ctr;
+static TileIndex _industry_sound_tile;
void ShowIndustryViewWindow(int industry);
void BuildOilRig(TileIndex tile);
@@ -341,7 +341,7 @@ static IndustryDrawTileProc * const _industry_draw_tile_procs[5] = {
static void DrawTile_Industry(TileInfo *ti)
{
- Industry *ind;
+ const Industry* ind;
const DrawIndustryTileStruct *dits;
byte z;
uint32 image, ormod;
@@ -425,7 +425,7 @@ static void GetAcceptedCargo_Industry(TileIndex tile, AcceptedCargo ac)
static void GetTileDesc_Industry(TileIndex tile, TileDesc *td)
{
- Industry *i = GetIndustry(_m[tile].m2);
+ const Industry* i = GetIndustry(_m[tile].m2);
td->owner = i->owner;
td->str = STR_4802_COAL_MINE + i->type;
@@ -863,7 +863,8 @@ static uint32 GetTileTrackStatus_Industry(TileIndex tile, TransportType mode)
static void GetProducedCargo_Industry(TileIndex tile, byte *b)
{
- Industry *i = GetIndustry(_m[tile].m2);
+ const Industry* i = GetIndustry(_m[tile].m2);
+
b[0] = i->produced_cargo[0];
b[1] = i->produced_cargo[1];
}
@@ -1262,10 +1263,10 @@ static bool CheckSuitableIndustryPos(TileIndex tile)
return true;
}
-static Town *CheckMultipleIndustryInTown(TileIndex tile, int type)
+static const Town* CheckMultipleIndustryInTown(TileIndex tile, int type)
{
- Town *t;
- Industry *i;
+ const Town* t;
+ const Industry* i;
t = ClosestTownFromTile(tile, (uint)-1);
@@ -1309,7 +1310,7 @@ static const byte _industry_map5_bits[] = {
16, 16, 16, 16, 16, 16, 16,
};
-static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable *it, int type, Town *t)
+static bool CheckIfIndustryTilesAreFree(TileIndex tile, const IndustryTileTable* it, int type, const Town* t)
{
TileInfo ti;
@@ -1451,7 +1452,7 @@ static Industry *AllocateIndustry(void)
return AddBlockToPool(&_industry_pool) ? AllocateIndustry() : NULL;
}
-static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const IndustryTileTable *it, Town *t, byte owner)
+static void DoCreateNewIndustry(Industry* i, TileIndex tile, int type, const IndustryTileTable* it, const Town* t, byte owner)
{
const IndustrySpec *spec;
uint32 r;
@@ -1547,7 +1548,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, int type, const Ind
*/
int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- Town *t;
+ const Town* t;
Industry *i;
TileIndex tile = TileVirtXY(x, y);
int num;
@@ -1601,7 +1602,7 @@ int32 CmdBuildIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Industry *CreateNewIndustry(TileIndex tile, int type)
{
- Town *t;
+ const Town* t;
const IndustryTileTable *it;
Industry *i;
diff --git a/main_gui.c b/main_gui.c
index e51fcc643..2a0b1bd08 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -566,9 +566,9 @@ static const Widget _player_menu_widgets[] = {
static int GetPlayerIndexFromMenu(int index)
{
- Player *p;
-
if (index >= 0) {
+ const Player* p;
+
FOR_ALL_PLAYERS(p) {
if (p->is_active) {
if (--index < 0)
@@ -582,7 +582,7 @@ static int GetPlayerIndexFromMenu(int index)
static void UpdatePlayerMenuHeight(Window *w)
{
int num = 0;
- Player *p;
+ const Player* p;
FOR_ALL_PLAYERS(p) {
if (p->is_active)
@@ -822,7 +822,7 @@ static void ToolbarIndustryClick(Window *w)
static void ToolbarTrainClick(Window *w)
{
- Vehicle *v;
+ const Vehicle* v;
int dis = -1;
FOR_ALL_VEHICLES(v)
if (v->type == VEH_Train && v->subtype == TS_Front_Engine) CLRBIT(dis, v->owner);
@@ -831,7 +831,7 @@ static void ToolbarTrainClick(Window *w)
static void ToolbarRoadClick(Window *w)
{
- Vehicle *v;
+ const Vehicle* v;
int dis = -1;
FOR_ALL_VEHICLES(v)
if (v->type == VEH_Road) CLRBIT(dis, v->owner);
@@ -840,7 +840,7 @@ static void ToolbarRoadClick(Window *w)
static void ToolbarShipClick(Window *w)
{
- Vehicle *v;
+ const Vehicle* v;
int dis = -1;
FOR_ALL_VEHICLES(v)
if (v->type == VEH_Ship) CLRBIT(dis, v->owner);
@@ -849,7 +849,7 @@ static void ToolbarShipClick(Window *w)
static void ToolbarAirClick(Window *w)
{
- Vehicle *v;
+ const Vehicle* v;
int dis = -1;
FOR_ALL_VEHICLES(v)
if (v->type == VEH_Aircraft) CLRBIT(dis, v->owner);
@@ -1651,11 +1651,11 @@ static const Widget _scenedit_industry_candy_widgets[] = {
{ WIDGETS_END},
};
-int _industry_type_to_place;
static bool AnyTownExists(void)
{
- Town *t;
+ const Town* t;
+
FOR_ALL_TOWNS(t) {
if (t->xy)
return true;
@@ -1697,6 +1697,7 @@ static const byte _industry_type_list[4][16] = {
{26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36},
};
+static int _industry_type_to_place;
bool _ignore_restrictions;
static void ScenEditIndustryWndProc(Window *w, WindowEvent *e)
diff --git a/misc_gui.c b/misc_gui.c
index f3addb253..c349dbd46 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -29,7 +29,7 @@
static bool _fios_path_changed;
static bool _savegame_sort_dirty;
-bool _query_string_active;
+static bool _query_string_active;
typedef struct LandInfoData {
Town *town;
@@ -41,10 +41,9 @@ typedef struct LandInfoData {
static void LandInfoWndProc(Window *w, WindowEvent *e)
{
- LandInfoData *lid;
- StringID str;
-
if (e->event == WE_PAINT) {
+ const LandInfoData* lid;
+ StringID str;
int i;
DrawWindowWidgets(w);
@@ -883,7 +882,8 @@ bool MoveTextBufferPos(Textbuf *tb, int navmode)
*/
void UpdateTextBufferSize(Textbuf *tb)
{
- char *buf;
+ const char* buf;
+
tb->length = 0;
tb->width = 0;
diff --git a/music_gui.c b/music_gui.c
index f7136e34c..353531b56 100644
--- a/music_gui.c
+++ b/music_gui.c
@@ -206,9 +206,9 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
+ const byte* p;
uint i;
int y;
- byte *p;
w->disabled_state = (msf.playlist <= 3) ? (1 << 11) : 0;
w->click_state |= 0x18;
diff --git a/network_gui.c b/network_gui.c
index 5f09d9934..c99e10538 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -79,8 +79,9 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
_selected_field = 3;
_selected_item = NULL;
break;
+
case WE_PAINT: {
- NetworkGameList *sel = _selected_item;
+ const NetworkGameList* sel = _selected_item;
w->disabled_state = 0;
@@ -891,9 +892,10 @@ static WindowDesc _client_list_desc = {
};
// Finds the Xth client-info that is active
-static NetworkClientInfo *NetworkFindClientInfo(byte client_no)
+static const NetworkClientInfo* NetworkFindClientInfo(byte client_no)
{
- NetworkClientInfo *ci;
+ const NetworkClientInfo* ci;
+
for (ci = _network_client_info; ci != &_network_client_info[MAX_CLIENT_INFO]; ci++) {
// Skip non-active items
if (ci->client_index == NETWORK_EMPTY_INDEX) continue;
@@ -1012,7 +1014,7 @@ static uint ClientListPopupHeigth(void) {
static Window *PopupClientList(Window *w, int client_no, int x, int y)
{
int i, h;
- NetworkClientInfo *ci;
+ const NetworkClientInfo* ci;
DeleteWindowById(WC_TOOLBAR_MENU, 0);
// Clean the current actions
diff --git a/order.h b/order.h
index 08bbc7529..52ef207e3 100644
--- a/order.h
+++ b/order.h
@@ -168,7 +168,7 @@ static inline Order UnpackOrder(uint32 packed)
/* Functions */
void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *order);
-void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
+void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* order);
void DeleteDestinationFromVehicleOrder(Order dest);
void InvalidateVehicleOrder(const Vehicle *v);
bool VehicleHasDepotOrders(const Vehicle *v);
@@ -176,7 +176,7 @@ bool CheckOrders(uint data_a, uint data_b);
void DeleteVehicleOrders(Vehicle *v);
bool IsOrderListShared(const Vehicle *v);
void AssignOrder(Order *order, Order data);
-bool CheckForValidOrders(Vehicle *v);
+bool CheckForValidOrders(const Vehicle* v);
Order UnpackVersion4Order(uint16 packed);
Order UnpackOldOrder(uint16 packed);
diff --git a/order_cmd.c b/order_cmd.c
index fda452ba8..fc91034be 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -785,7 +785,7 @@ void BackupVehicleOrders(const Vehicle *v, BackuppedOrders *bak)
* Restore vehicle orders that are backupped via BackupVehicleOrders
*
*/
-void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
+void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* bak)
{
uint i;
@@ -1100,7 +1100,7 @@ bool IsOrderListShared(const Vehicle *v)
* @return false if there are no valid orders
*
*/
-bool CheckForValidOrders(Vehicle *v)
+bool CheckForValidOrders(const Vehicle* v)
{
const Order *order;
diff --git a/player_gui.c b/player_gui.c
index 1790f0ee7..85cfdf19a 100644
--- a/player_gui.c
+++ b/player_gui.c
@@ -421,7 +421,7 @@ static void DrawPlayerVehiclesAmount(PlayerID player)
{
const int x = 110;
int y = 72;
- Vehicle *v;
+ const Vehicle* v;
uint train,road,air,ship;
DrawString(x, y, STR_7039_VEHICLES, 0);
diff --git a/rail_gui.c b/rail_gui.c
index e105c6679..07f38ebc3 100644
--- a/rail_gui.c
+++ b/rail_gui.c
@@ -27,7 +27,7 @@ static byte _build_depot_direction;
static byte _waypoint_count=1;
static byte _cur_waypoint_type;
-struct {
+static struct {
byte orientation;
byte numtracks;
byte platlength;
diff --git a/roadveh_cmd.c b/roadveh_cmd.c
index 9ed41a694..421e809cc 100644
--- a/roadveh_cmd.c
+++ b/roadveh_cmd.c
@@ -799,7 +799,7 @@ static Vehicle *RoadVehFindCloseTo(Vehicle *v, int x, int y, byte dir)
return u;
}
-static void RoadVehArrivesAt(Vehicle *v, Station *st)
+static void RoadVehArrivesAt(const Vehicle* v, Station* st)
{
if (v->cargo_type == CT_PASSENGERS) {
/* Check if station was ever visited before */
diff --git a/roadveh_gui.c b/roadveh_gui.c
index 8a45d7ae7..f2fda8374 100644
--- a/roadveh_gui.c
+++ b/roadveh_gui.c
@@ -431,7 +431,7 @@ static void DrawNewRoadVehWindow(Window *w)
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
- Vehicle *v;
+ const Vehicle* v;
if (!success) return;
diff --git a/ship_cmd.c b/ship_cmd.c
index 887fd70d2..28d04c0bc 100644
--- a/ship_cmd.c
+++ b/ship_cmd.c
@@ -57,10 +57,10 @@ int GetShipImage(const Vehicle *v, byte direction)
return _ship_sprites[spritenum] + direction;
}
-static Depot *FindClosestShipDepot(Vehicle *v)
+static const Depot* FindClosestShipDepot(const Vehicle* v)
{
- Depot *depot;
- Depot *best_depot = NULL;
+ const Depot* depot;
+ const Depot* best_depot = NULL;
uint dist;
uint best_dist = (uint)-1;
TileIndex tile;
@@ -91,7 +91,7 @@ static Depot *FindClosestShipDepot(Vehicle *v)
static void CheckIfShipNeedsService(Vehicle *v)
{
- Depot *depot;
+ const Depot* depot;
if (_patches.servint_ships == 0)
return;
@@ -442,7 +442,7 @@ static void ShipEnterDepot(Vehicle *v)
InvalidateWindowClasses(WC_SHIPS_LIST);
}
-static void ShipArrivesAt(Vehicle *v, Station *st)
+static void ShipArrivesAt(const Vehicle* v, Station* st)
{
/* Check if station was ever visited before */
if (!(st->had_vehicle_of_type & HVOT_SHIP)) {
diff --git a/ship_gui.c b/ship_gui.c
index 553af1a7d..1ce2503e3 100644
--- a/ship_gui.c
+++ b/ship_gui.c
@@ -28,7 +28,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
{
YearMonthDay ymd;
const ShipVehicleInfo *svi = ShipVehInfo(engine_number);
- Engine *e;
+ const Engine* e;
/* Purchase cost - Max speed */
SetDParam(0, svi->base_cost * (_price.ship_base>>3)>>5);
@@ -301,7 +301,7 @@ static void ShowShipDetailsWindow(const Vehicle* v)
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
- Vehicle *v;
+ const Vehicle* v;
if (!success) return;
v = GetVehicle(_new_ship_id);
@@ -755,7 +755,7 @@ static void HandleCloneVehClick(const Vehicle* v, const Window* w)
static void ClonePlaceObj(TileIndex tile, const Window* w)
{
- Vehicle* v = CheckMouseOverVehicle();
+ const Vehicle* v = CheckMouseOverVehicle();
if (v != NULL) HandleCloneVehClick(v, w);
}
diff --git a/station_cmd.c b/station_cmd.c
index b0c88412c..a2c4acff6 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -2082,7 +2082,7 @@ static void DrawTile_Station(TileInfo *ti)
//debug("Cust-o-mized %p", statspec);
if (statspec != NULL) {
- Station *st = GetStation(_m[ti->tile].m2);
+ const Station* st = GetStation(_m[ti->tile].m2);
relocation = GetCustomStationRelocation(statspec, st, 0);
//debug("Relocation %d", relocation);
@@ -2197,7 +2197,7 @@ static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
switch (mode) {
case TRANSPORT_RAIL:
if (i < 8) {
- const byte tile_track_status_rail[8] = { 1, 2, 1, 2, 1, 2, 1, 2 };
+ static const byte tile_track_status_rail[] = { 1, 2, 1, 2, 1, 2, 1, 2 };
j = tile_track_status_rail[i];
}
j += (j << 8);
diff --git a/station_gui.c b/station_gui.c
index 568416bbe..2244386a4 100644
--- a/station_gui.c
+++ b/station_gui.c
@@ -164,10 +164,8 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
{
byte p = 0;
- Station *st;
- int x,xb = 2;
+ int xb = 2;
int y = 16; // offset from top of widget
- int j;
if (w->vscroll.count == 0) { // player has no stations
DrawString(xb, y, STR_304A_NONE, 0);
@@ -178,7 +176,9 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
assert(i < _num_station_sort[owner]); // at least one station must exist
while (i < _num_station_sort[owner]) { // do until max number of stations of owner
- st = GetStation(_station_sort[i].index);
+ const Station* st = GetStation(_station_sort[i].index);
+ uint j;
+ int x;
assert(st->xy && st->owner == owner);
@@ -211,7 +211,8 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
{
const PlayerID owner = w->window_number;
- Station *st;
+ const Station* st;
+
id_v += (owner == 0) ? 0 : _num_station_sort[owner - 1]; // first element in list
if (id_v >= _num_station_sort[owner]) { return;} // click out of station bound
@@ -310,17 +311,13 @@ static const Widget _station_view_widgets[] = {
static void DrawStationViewWindow(Window *w)
{
- Station *st;
- int i;
- int num;
+ StationID station_id = w->window_number;
+ const Station* st = GetStation(station_id);
+ uint i;
+ uint num;
int x,y;
int pos;
StringID str;
- StationID station_id;
-
- station_id = w->window_number;
-
- st = GetStation(station_id);
num = 1;
for(i=0; i!=NUM_CARGO; i++) {
diff --git a/strings.c b/strings.c
index d732c9ea1..77c891efe 100644
--- a/strings.c
+++ b/strings.c
@@ -702,10 +702,9 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
} break;
case 0x9A: { // {STATION}
- Station *st;
+ const Station* st = GetStation(GetInt32(&argv));
int32 temp[2];
- st = GetStation(GetInt32(&argv));
if (st->xy == 0) { // station doesn't exist anymore
buff = GetStringWithArgs(buff, STR_UNKNOWN_DESTINATION, NULL);
break;
@@ -716,10 +715,10 @@ static char *FormatString(char *buff, const char *str, const int32 *argv, uint c
break;
}
case 0x9B: { // {TOWN}
- Town *t;
+ const Town* t = GetTown(GetInt32(&argv));
int32 temp[1];
- t = GetTown(GetInt32(&argv));
assert(t->xy);
+
temp[0] = t->townnameparts;
buff = GetStringWithArgs(buff, t->townnametype, temp);
break;
diff --git a/subsidy_gui.c b/subsidy_gui.c
index db09ec9c5..70cc3078c 100644
--- a/subsidy_gui.c
+++ b/subsidy_gui.c
@@ -16,7 +16,7 @@
static void HandleSubsidyClick(int y)
{
- Subsidy *s;
+ const Subsidy* s;
int num,offs;
TileIndex xy;
@@ -74,12 +74,11 @@ handle_click:
}
}
-static void DrawSubsidiesWindow(Window *w)
+static void DrawSubsidiesWindow(const Window* w)
{
YearMonthDay ymd;
- Subsidy *s;
+ const Subsidy* s;
int x,xt,y,num,x2;
- Player *p;
DrawWindowWidgets(w);
@@ -114,6 +113,8 @@ static void DrawSubsidiesWindow(Window *w)
for(s=_subsidies; s != endof(_subsidies); s++) {
if (s->cargo_type != CT_INVALID && s->age >= 12) {
+ const Player* p;
+
SetupSubsidyDecodeParam(s, 1);
p = GetPlayer(GetStation(s->to)->owner);
diff --git a/town_cmd.c b/town_cmd.c
index 3894164b2..e49cf4eb5 100644
--- a/town_cmd.c
+++ b/town_cmd.c
@@ -201,7 +201,7 @@ static void UpdateTownRadius(Town *t);
static bool IsCloseToTown(TileIndex tile, uint dist)
{
- Town *t;
+ const Town* t;
FOR_ALL_TOWNS(t) {
if (t->xy != 0 && DistanceManhattan(tile, t->xy) < dist)
@@ -245,7 +245,8 @@ static void ChangePopulation(Town *t, int mod)
uint32 GetWorldPopulation(void)
{
uint32 pop;
- Town *t;
+ const Town* t;
+
pop = 0;
FOR_ALL_TOWNS(t) {
pop += t->population;
diff --git a/town_gui.c b/town_gui.c
index a348bf27c..931bc7bd6 100644
--- a/town_gui.c
+++ b/town_gui.c
@@ -107,7 +107,7 @@ static void TownAuthorityWndProc(Window *w, WindowEvent *e)
{
int y;
- Player *p;
+ const Player* p;
int r;
StringID str;
@@ -402,7 +402,7 @@ static int CDECL TownPopSorter(const void *a, const void *b)
static void MakeSortedTownList(void)
{
- Town *t;
+ const Town* t;
int n = 0;
/* Create array for sorting */
@@ -439,7 +439,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e)
DoDrawString(_town_sort_order & 1 ? DOWNARROW : UPARROW, (_town_sort_order <= 1) ? 88 : 187, 15, 0x10);
{
- Town *t;
+ const Town* t;
int n = 0;
uint16 i = w->vscroll.pos;
int y = 28;
@@ -486,7 +486,7 @@ static void TownDirectoryWndProc(Window *w, WindowEvent *e)
if (id_v >= _num_town_sort) return; // click out of town bounds
{
- Town *t = GetTown(_town_sort[id_v]);
+ const Town* t = GetTown(_town_sort[id_v]);
assert(t->xy);
ScrollMainWindowToTile(t->xy);
diff --git a/train_cmd.c b/train_cmd.c
index 71013483d..24c696f0c 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -188,9 +188,10 @@ enum AccelType {
AM_BRAKE
};
-static bool TrainShouldStop(Vehicle *v, TileIndex tile)
+static bool TrainShouldStop(const Vehicle* v, TileIndex tile)
{
- Order *o = &v->current_order;
+ const Order* o = &v->current_order;
+
assert(v->type == VEH_Train);
assert(IsTileType(v->tile, MP_STATION));
//When does a train drive through a station
@@ -590,9 +591,9 @@ static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
}
// Move all free vehicles in the depot to the train
-static void NormalizeTrainVehInDepot(Vehicle *u)
+static void NormalizeTrainVehInDepot(const Vehicle* u)
{
- Vehicle *v;
+ const Vehicle* v;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_Train && v->subtype == TS_Free_Car &&
@@ -624,7 +625,7 @@ static const byte _railveh_score[] = {
};
-int32 EstimateTrainCost(const RailVehicleInfo *rvi)
+static int32 EstimateTrainCost(const RailVehicleInfo* rvi)
{
return (rvi->base_cost * (_price.build_railvehicle >> 3)) >> 5;
}
@@ -1443,7 +1444,7 @@ static void AdvanceWagons(Vehicle *v, bool before)
}
}
-TileIndex GetVehicleTileOutOfTunnel(const Vehicle *v, bool reverse)
+static TileIndex GetVehicleTileOutOfTunnel(const Vehicle* v, bool reverse)
{
TileIndex tile;
byte direction = (!reverse) ? DirToDiagdir(v->direction) : ReverseDiagdir(v->direction >> 1);
@@ -1859,9 +1860,9 @@ static const int8 _vehicle_smoke_pos[8] = {
1, 1, 1, 0, -1, -1, -1, 0
};
-static void HandleLocomotiveSmokeCloud(Vehicle *v)
+static void HandleLocomotiveSmokeCloud(const Vehicle* v)
{
- Vehicle *u;
+ const Vehicle* u;
if (v->vehstatus & VS_TRAIN_SLOWING || v->load_unload_time_rem != 0 || v->cur_speed < 2)
return;
@@ -2054,7 +2055,7 @@ static bool NtpCallbFindStation(TileIndex tile, TrainTrackFollowerData *ttfd, in
}
}
-static void FillWithStationData(TrainTrackFollowerData *fd, Vehicle *v)
+static void FillWithStationData(TrainTrackFollowerData* fd, const Vehicle* v)
{
fd->dest_coords = v->dest_tile;
if (v->current_order.type == OT_GOTO_STATION)
@@ -3535,7 +3536,7 @@ void TrainEnterDepot(Vehicle *v, TileIndex tile)
static void CheckIfTrainNeedsService(Vehicle *v)
{
- Depot *depot;
+ const Depot* depot;
TrainFindDepotData tfdd;
if (PBSTileReserved(v->tile) & v->u.rail.track)
diff --git a/train_gui.c b/train_gui.c
index 5f925a8cb..294ad9267 100644
--- a/train_gui.c
+++ b/train_gui.c
@@ -148,7 +148,7 @@ void CcBuildWagon(bool success, TileIndex tile, uint32 p1, uint32 p2)
void CcBuildLoco(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
- Vehicle *v;
+ const Vehicle* v;
if (!success)
return;
diff --git a/vehicle.c b/vehicle.c
index ece0547b4..309a21e08 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -39,25 +39,25 @@
#define CMD_STARTSTOP_VEH(x) _veh_start_stop_proc_table[ x - VEH_Train]
#define CMD_REFIT_VEH(x) _veh_refit_proc_table[ x - VEH_Train]
-static uint32 const _veh_build_proc_table[] = {
+static const uint32 _veh_build_proc_table[] = {
CMD_BUILD_RAIL_VEHICLE,
CMD_BUILD_ROAD_VEH,
CMD_BUILD_SHIP,
CMD_BUILD_AIRCRAFT,
};
-static uint32 const _veh_sell_proc_table[] = {
+static const uint32 _veh_sell_proc_table[] = {
CMD_SELL_RAIL_WAGON,
CMD_SELL_ROAD_VEH,
CMD_SELL_SHIP,
CMD_SELL_AIRCRAFT,
};
-static uint32 const _veh_start_stop_proc_table[] = {
+static const uint32 _veh_start_stop_proc_table[] = {
CMD_START_STOP_TRAIN,
CMD_START_STOP_ROADVEH,
CMD_START_STOP_SHIP,
CMD_START_STOP_AIRCRAFT,
};
-static uint32 const _veh_refit_proc_table[] = {
+static const uint32 _veh_refit_proc_table[] = {
CMD_REFIT_RAIL_VEHICLE,
0, // road vehicles can't be refitted
CMD_REFIT_SHIP,
@@ -107,7 +107,7 @@ bool VehicleNeedsService(const Vehicle *v)
(v->date_of_last_service + v->service_interval < _date);
}
-void VehicleInTheWayErrMsg(Vehicle *v)
+void VehicleInTheWayErrMsg(const Vehicle* v)
{
StringID id;
@@ -525,7 +525,7 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v)
return (Vehicle*)v;
}
-int CountVehiclesInChain(Vehicle *v)
+uint CountVehiclesInChain(const Vehicle* v)
{
int count = 0;
do count++; while ( (v=v->next) != NULL);
@@ -570,7 +570,7 @@ void DisasterVehicle_Tick(Vehicle *v);
static void MaybeReplaceVehicle(Vehicle *v);
// head of the linked list to tell what vehicles that visited a depot in a tick
-Vehicle *_first_veh_in_depot_list;
+static Vehicle* _first_veh_in_depot_list;
/** Adds a vehicle to the list of vehicles, that visited a depot this tick
* @param *v vehicle to add
diff --git a/vehicle.h b/vehicle.h
index f5eb66db6..4b6d3ce3f 100644
--- a/vehicle.h
+++ b/vehicle.h
@@ -293,7 +293,7 @@ void AfterLoadVehicles(void);
Vehicle *GetLastVehicleInChain(Vehicle *v);
Vehicle *GetPrevVehicleInChain(const Vehicle *v);
Vehicle *GetFirstVehicleInChain(const Vehicle *v);
-int CountVehiclesInChain(Vehicle *v);
+uint CountVehiclesInChain(const Vehicle* v);
void DeleteVehicle(Vehicle *v);
void DeleteVehicleChain(Vehicle *v);
void *VehicleFromPos(TileIndex tile, void *data, VehicleFromPosProc *proc);
@@ -323,7 +323,7 @@ Vehicle *CreateEffectVehicleRel(const Vehicle *v, int x, int y, int z, EffectVeh
uint32 VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
-void VehicleInTheWayErrMsg(Vehicle *v);
+void VehicleInTheWayErrMsg(const Vehicle* v);
Vehicle *FindVehicleBetween(TileIndex from, TileIndex to, byte z);
TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v);
diff --git a/vehicle_gui.c b/vehicle_gui.c
index ebe2afebc..3e93ec6f9 100644
--- a/vehicle_gui.c
+++ b/vehicle_gui.c
@@ -490,9 +490,9 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
}
case VEH_Road: {
int num = NUM_ROAD_ENGINES;
- Engine *e = GetEngine(ROAD_ENGINES_INDEX);
+ const Engine* e = GetEngine(ROAD_ENGINES_INDEX);
byte cargo;
- EngineInfo *info;
+ const EngineInfo* info;
engine_id = ROAD_ENGINES_INDEX;
do {
@@ -523,9 +523,9 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
case VEH_Ship: {
int num = NUM_SHIP_ENGINES;
- Engine *e = GetEngine(SHIP_ENGINES_INDEX);
+ const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
byte cargo, refittable;
- EngineInfo *info;
+ const EngineInfo* info;
engine_id = SHIP_ENGINES_INDEX;
do {
@@ -560,8 +560,8 @@ static void SetupScrollStuffForReplaceWindow(Window *w)
case VEH_Aircraft:{
int num = NUM_AIRCRAFT_ENGINES;
byte subtype;
- Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
- EngineInfo *info;
+ const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
+ const EngineInfo* info;
engine_id = AIRCRAFT_ENGINES_INDEX;
do {
@@ -635,10 +635,10 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Road: {
int num = NUM_ROAD_ENGINES;
- Engine *e = GetEngine(ROAD_ENGINES_INDEX);
+ const Engine* e = GetEngine(ROAD_ENGINES_INDEX);
EngineID engine_id = ROAD_ENGINES_INDEX;
byte cargo;
- EngineInfo *info;
+ const EngineInfo* info;
if ( selected_id[0] >= ROAD_ENGINES_INDEX && selected_id[0] <= SHIP_ENGINES_INDEX ) {
cargo = RoadVehInfo(selected_id[0])->cargo_type;
@@ -671,10 +671,10 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Ship: {
int num = NUM_SHIP_ENGINES;
- Engine *e = GetEngine(SHIP_ENGINES_INDEX);
+ const Engine* e = GetEngine(SHIP_ENGINES_INDEX);
EngineID engine_id = SHIP_ENGINES_INDEX;
byte cargo, refittable;
- EngineInfo *info;
+ const EngineInfo* info;
if ( selected_id[0] != -1 ) {
cargo = ShipVehInfo(selected_id[0])->cargo_type;
@@ -710,10 +710,10 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
case VEH_Aircraft: {
if ( selected_id[0] != -1 ) {
int num = NUM_AIRCRAFT_ENGINES;
- Engine *e = GetEngine(AIRCRAFT_ENGINES_INDEX);
+ const Engine* e = GetEngine(AIRCRAFT_ENGINES_INDEX);
EngineID engine_id = AIRCRAFT_ENGINES_INDEX;
byte subtype = AircraftVehInfo(selected_id[0])->subtype;
- EngineInfo *info;
+ const EngineInfo* info;
do {
info = &_engine_info[engine_id];
diff --git a/window.c b/window.c
index 7ffadafc2..c37e573f8 100644
--- a/window.c
+++ b/window.c
@@ -158,7 +158,7 @@ void DrawOverlappedWindowForAll(int left, int top, int right, int bottom)
void DrawOverlappedWindow(Window *w, int left, int top, int right, int bottom)
{
- Window *v = w;
+ const Window* v = w;
int x;
while (++v != _last_window) {
@@ -1574,7 +1574,7 @@ void InvalidateWidget(const Window* w, byte widget_index)
void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index)
{
- Window *w;
+ const Window* w;
for(w=_windows; w!=_last_window; w++) {
if (w->window_class==cls && w->window_number==number) {
@@ -1585,7 +1585,7 @@ void InvalidateWindowWidget(byte cls, WindowNumber number, byte widget_index)
void InvalidateWindowClasses(byte cls)
{
- Window *w;
+ const Window* w;
for(w=_windows; w!=_last_window; w++) {
if (w->window_class==cls)
SetWindowDirty(w);