summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clear_cmd.c2
-rw-r--r--command.c9
-rw-r--r--industry_cmd.c2
-rw-r--r--landscape.c2
-rw-r--r--lang/english.txt2
-rw-r--r--rail_cmd.c9
-rw-r--r--road_cmd.c4
-rw-r--r--station_cmd.c2
-rw-r--r--train_cmd.c4
-rw-r--r--unmovable_cmd.c4
-rw-r--r--variables.h2
-rw-r--r--vehicle.c2
-rw-r--r--water_cmd.c2
13 files changed, 39 insertions, 7 deletions
diff --git a/clear_cmd.c b/clear_cmd.c
index ac77c1632..319412592 100644
--- a/clear_cmd.c
+++ b/clear_cmd.c
@@ -330,6 +330,8 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
uint tile;
int32 ret, cost, money;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
// remember level height
h = _map_type_and_height[p1]&0xF;
diff --git a/command.c b/command.c
index 09b803b84..6c0e0d7c9 100644
--- a/command.c
+++ b/command.c
@@ -356,8 +356,8 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
}
}
- // execute the command here.
- _yearly_expenses_type = 0;
+ /* Execute the command here. All cost-relevant functions set the expenses type
+ * themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
res = proc(x, y, flags, p1, p2);
if ((uint32)res >> 16 == 0x8000) {
if (res & 0xFFFF) _error_message = res & 0xFFFF;
@@ -470,8 +470,9 @@ bool DoCommandP(TileIndex tile, uint32 p1, uint32 p2, CommandCallback *callback,
// update last build coordinate of player.
if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile;
- // actually try and execute the command.
- _yearly_expenses_type = 0;
+ /* Actually try and execute the command. If no cost-type is given
+ * use the construction one */
+ _yearly_expenses_type = EXPENSES_CONSTRUCTION;
res2 = proc(x,y, flags|DC_EXEC, p1, p2);
// If notest is on, it means the result of the test can be different than
diff --git a/industry_cmd.c b/industry_cmd.c
index aae700653..25ee07567 100644
--- a/industry_cmd.c
+++ b/industry_cmd.c
@@ -398,6 +398,8 @@ int32 CmdDestroyIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2)
Industry *i = DEREF_INDUSTRY((uint16)p1);
Town *t = ClosestTownFromTile(tile, (uint)-1); // find closest town to penaltize (ALWAYS penaltize)
+ SET_EXPENSES_TYPE(EXPENSES_OTHER);
+
// check if you're allowed to remove the industry. Minimum amount
// of ratings to remove the industry depends on difficulty setting
if (!CheckforTownRating(tile, flags, t, INDUSTRY_REMOVE))
diff --git a/landscape.c b/landscape.c
index 232f0e188..adc9f7855 100644
--- a/landscape.c
+++ b/landscape.c
@@ -351,6 +351,8 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
int x,y;
bool success = false;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
// make sure sx,sy are smaller than ex,ey
sx = GET_TILE_X(p1)*16;
sy = GET_TILE_Y(p1)*16;
diff --git a/lang/english.txt b/lang/english.txt
index c8077ed11..fc9916b73 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -2763,7 +2763,7 @@ STR_SCHEDULED_SHIPS_TIP :{BLACK}Show all ships which have this station on t
STR_REPLACE_VEHICLES :{BLACK}Replace Vehicles
STR_REPLACE_VEHICLES_WHITE :{WHITE}Replace Vehicles
STR_REPLACE_VEHICLES_START :{BLACK}Start Replacing Vehicles
-STR_REPLACE_VEHICLES_STOP :{BLACK}Stop Replaing Vehicles
+STR_REPLACE_VEHICLES_STOP :{BLACK}Stop Replacing Vehicles
STR_NOT_REPLACING :{BLACK}Not replacing
STR_NOT_REPLACING_VEHICLE_SELECTED :{BLACK}No vehicle selected
STR_REPLACE_HELP_LEFT_ARRAY :{BLACK}Select a type of engine to replace{}Select an engine on the right side to replace to
diff --git a/rail_cmd.c b/rail_cmd.c
index 3896ecf16..bc71e40c4 100644
--- a/rail_cmd.c
+++ b/rail_cmd.c
@@ -542,6 +542,8 @@ int32 CmdBuildRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 ret, total_cost = 0;
int railbit;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
if (flags & DC_EXEC)
SndPlayTileFx(SND_20_SPLAT_2, TILE_FROM_XY(x,y));
@@ -592,6 +594,8 @@ int32 CmdRemoveRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 ret, total_cost = 0;
int railbit;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
if (flags & DC_EXEC)
SndPlayTileFx(SND_20_SPLAT_2, TILE_FROM_XY(x,y));
@@ -820,6 +824,7 @@ static int32 RemoveTrainWaypoint(uint tile, uint32 flags, bool justremove)
int32 CmdRemoveTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
uint tile = TILE_FROM_XY(x,y);
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
return RemoveTrainWaypoint(tile, flags, true);
}
@@ -975,6 +980,8 @@ int32 CmdBuildManySignals(int x, int y, uint32 flags, uint32 p1, uint32 p2)
byte signals = (p2 >> 8)&0xFF;
mode = p2 & 0x1; // build/remove signals
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
/* unpack end tile */
ex = GET_TILE_X(p1)*16;
ey = GET_TILE_Y(p1)*16;
@@ -1134,6 +1141,8 @@ int32 CmdConvertRail(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
int32 ret, cost, money;
int sx,sy,x,y;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
// make sure sx,sy are smaller than ex,ey
sx = GET_TILE_X(p1)*16;
sy = GET_TILE_Y(p1)*16;
diff --git a/road_cmd.c b/road_cmd.c
index 0676293ab..d42e50f03 100644
--- a/road_cmd.c
+++ b/road_cmd.c
@@ -494,6 +494,8 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int mode;
int32 cost,ret;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
start_tile = p1;
end_tile = TILE_FROM_XY(x, y);
@@ -545,6 +547,8 @@ int32 CmdRemoveLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint start_tile, end_tile, tile;
int32 cost,ret;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
start_tile = p1;
end_tile = TILE_FROM_XY(x, y);
diff --git a/station_cmd.c b/station_cmd.c
index cad045458..8d6ec1bcd 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -957,6 +957,8 @@ int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32
uint tile = TILE_FROM_XY(x, y);
Station *st;
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
+
// make sure the specified tile belongs to the current player, and that it is a railroad station.
if (!IS_TILETYPE(tile, MP_STATION) || _map5[tile] >= 8 || !_patches.nonuniform_stations) return CMD_ERROR;
st = DEREF_STATION(_map2[tile]);
diff --git a/train_cmd.c b/train_cmd.c
index 45f34285a..63d541338 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -231,6 +231,8 @@ static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags)
const Engine *e;
int x,y;
+ SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+
rvi = RailVehInfo(engine);
value = (rvi->base_cost * _price.build_railwagon) >> 8;
@@ -1069,7 +1071,7 @@ int32 CmdRefitRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
p2 = p2 & 0xFF;
- SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
+ SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN);
v = &_vehicles[p1];
if (!CheckOwnership(v->owner) || ((CheckStoppedInDepot(v) < 0) && !(SkipStoppedInDepotCheck)))
diff --git a/unmovable_cmd.c b/unmovable_cmd.c
index f94156424..f1511e76d 100644
--- a/unmovable_cmd.c
+++ b/unmovable_cmd.c
@@ -318,6 +318,8 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int score;
int32 cost = 0;
+ SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
+
if (CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL) == CMD_ERROR)
return CMD_ERROR;
@@ -361,6 +363,8 @@ int32 CmdDestroyCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint tile = TILE_FROM_XY(x,y);
Player *p;
+ SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
+
if ((int)p1 != OWNER_WATER) // destruction was initiated by player
p = DEREF_PLAYER((byte)p1);
else { // find player that has HQ flooded, and reset their location_of_house
diff --git a/variables.h b/variables.h
index 3d6b7a5fd..b12ed7ce6 100644
--- a/variables.h
+++ b/variables.h
@@ -399,7 +399,7 @@ static inline uint32 GetDParam(uint n)
#define INJECT_DPARAM(n) InjectDparam(n);
-#define SET_EXPENSES_TYPE(x) if (x) _yearly_expenses_type=x;
+#define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;
/* landscape.c */
extern const byte _tileh_to_sprite[32];
diff --git a/vehicle.c b/vehicle.c
index 0680581e8..7ff4ba787 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1412,6 +1412,8 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint32 autorefit_money = (p2 >> 16) * 100000;
Vehicle *v = DEREF_VEHICLE(p1);
int cost, build_cost;
+
+ SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
if (v->type != _engines[new_engine_type].type) return CMD_ERROR;
diff --git a/water_cmd.c b/water_cmd.c
index c75cfe2e4..85b307b50 100644
--- a/water_cmd.c
+++ b/water_cmd.c
@@ -171,6 +171,8 @@ int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
uint tile = TILE_FROM_XY(x,y);
int32 ret;
uint th;
+
+ SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
th = GetTileSlope(tile, NULL);
if (th==3 || th==6 || th==9 || th==12) {