mirror of https://github.com/OpenTTD/OpenTTD
(svn r1375) -Fix: [1050990] Buying trains sometimes accounted for incorrectly. Was the result of the cost getting reset in a recursive call of docommand. That is fixed. In addition all cost-commands are typed explicitely. Please do not forget to do so or your costs will be credited to construction if you are unlucky.
parent
88b8a01da6
commit
6edb21231e
|
@ -330,6 +330,8 @@ int32 CmdLevelLand(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||||
uint tile;
|
uint tile;
|
||||||
int32 ret, cost, money;
|
int32 ret, cost, money;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
// remember level height
|
// remember level height
|
||||||
h = _map_type_and_height[p1]&0xF;
|
h = _map_type_and_height[p1]&0xF;
|
||||||
|
|
||||||
|
|
|
@ -356,8 +356,8 @@ int32 DoCommand(int x, int y, uint32 p1, uint32 p2, uint32 flags, uint procc)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// execute the command here.
|
/* Execute the command here. All cost-relevant functions set the expenses type
|
||||||
_yearly_expenses_type = 0;
|
* themselves with "SET_EXPENSES_TYPE(...);" at the beginning of the function */
|
||||||
res = proc(x, y, flags, p1, p2);
|
res = proc(x, y, flags, p1, p2);
|
||||||
if ((uint32)res >> 16 == 0x8000) {
|
if ((uint32)res >> 16 == 0x8000) {
|
||||||
if (res & 0xFFFF) _error_message = res & 0xFFFF;
|
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.
|
// update last build coordinate of player.
|
||||||
if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile;
|
if ( tile != 0 && _current_player < MAX_PLAYERS) DEREF_PLAYER(_current_player)->last_build_coordinate = tile;
|
||||||
|
|
||||||
// actually try and execute the command.
|
/* Actually try and execute the command. If no cost-type is given
|
||||||
_yearly_expenses_type = 0;
|
* use the construction one */
|
||||||
|
_yearly_expenses_type = EXPENSES_CONSTRUCTION;
|
||||||
res2 = proc(x,y, flags|DC_EXEC, p1, p2);
|
res2 = proc(x,y, flags|DC_EXEC, p1, p2);
|
||||||
|
|
||||||
// If notest is on, it means the result of the test can be different than
|
// If notest is on, it means the result of the test can be different than
|
||||||
|
|
|
@ -398,6 +398,8 @@ int32 CmdDestroyIndustry(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
Industry *i = DEREF_INDUSTRY((uint16)p1);
|
Industry *i = DEREF_INDUSTRY((uint16)p1);
|
||||||
Town *t = ClosestTownFromTile(tile, (uint)-1); // find closest town to penaltize (ALWAYS penaltize)
|
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
|
// check if you're allowed to remove the industry. Minimum amount
|
||||||
// of ratings to remove the industry depends on difficulty setting
|
// of ratings to remove the industry depends on difficulty setting
|
||||||
if (!CheckforTownRating(tile, flags, t, INDUSTRY_REMOVE))
|
if (!CheckforTownRating(tile, flags, t, INDUSTRY_REMOVE))
|
||||||
|
|
|
@ -351,6 +351,8 @@ int32 CmdClearArea(int ex, int ey, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int x,y;
|
int x,y;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
// make sure sx,sy are smaller than ex,ey
|
// make sure sx,sy are smaller than ex,ey
|
||||||
sx = GET_TILE_X(p1)*16;
|
sx = GET_TILE_X(p1)*16;
|
||||||
sy = GET_TILE_Y(p1)*16;
|
sy = GET_TILE_Y(p1)*16;
|
||||||
|
|
|
@ -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 :{BLACK}Replace Vehicles
|
||||||
STR_REPLACE_VEHICLES_WHITE :{WHITE}Replace Vehicles
|
STR_REPLACE_VEHICLES_WHITE :{WHITE}Replace Vehicles
|
||||||
STR_REPLACE_VEHICLES_START :{BLACK}Start Replacing 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 :{BLACK}Not replacing
|
||||||
STR_NOT_REPLACING_VEHICLE_SELECTED :{BLACK}No vehicle selected
|
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
|
STR_REPLACE_HELP_LEFT_ARRAY :{BLACK}Select a type of engine to replace{}Select an engine on the right side to replace to
|
||||||
|
|
|
@ -542,6 +542,8 @@ int32 CmdBuildRailroadTrack(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int32 ret, total_cost = 0;
|
int32 ret, total_cost = 0;
|
||||||
int railbit;
|
int railbit;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
if (flags & DC_EXEC)
|
if (flags & DC_EXEC)
|
||||||
SndPlayTileFx(SND_20_SPLAT_2, TILE_FROM_XY(x,y));
|
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;
|
int32 ret, total_cost = 0;
|
||||||
int railbit;
|
int railbit;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
if (flags & DC_EXEC)
|
if (flags & DC_EXEC)
|
||||||
SndPlayTileFx(SND_20_SPLAT_2, TILE_FROM_XY(x,y));
|
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)
|
int32 CmdRemoveTrainWaypoint(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
uint tile = TILE_FROM_XY(x,y);
|
uint tile = TILE_FROM_XY(x,y);
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
return RemoveTrainWaypoint(tile, flags, true);
|
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;
|
byte signals = (p2 >> 8)&0xFF;
|
||||||
mode = p2 & 0x1; // build/remove signals
|
mode = p2 & 0x1; // build/remove signals
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
/* unpack end tile */
|
/* unpack end tile */
|
||||||
ex = GET_TILE_X(p1)*16;
|
ex = GET_TILE_X(p1)*16;
|
||||||
ey = GET_TILE_Y(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;
|
int32 ret, cost, money;
|
||||||
int sx,sy,x,y;
|
int sx,sy,x,y;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
// make sure sx,sy are smaller than ex,ey
|
// make sure sx,sy are smaller than ex,ey
|
||||||
sx = GET_TILE_X(p1)*16;
|
sx = GET_TILE_X(p1)*16;
|
||||||
sy = GET_TILE_Y(p1)*16;
|
sy = GET_TILE_Y(p1)*16;
|
||||||
|
|
|
@ -494,6 +494,8 @@ int32 CmdBuildLongRoad(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int mode;
|
int mode;
|
||||||
int32 cost,ret;
|
int32 cost,ret;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
start_tile = p1;
|
start_tile = p1;
|
||||||
end_tile = TILE_FROM_XY(x, y);
|
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;
|
uint start_tile, end_tile, tile;
|
||||||
int32 cost,ret;
|
int32 cost,ret;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
start_tile = p1;
|
start_tile = p1;
|
||||||
end_tile = TILE_FROM_XY(x, y);
|
end_tile = TILE_FROM_XY(x, y);
|
||||||
|
|
||||||
|
|
|
@ -957,6 +957,8 @@ int32 CmdRemoveFromRailroadStation(int x, int y, uint32 flags, uint32 p1, uint32
|
||||||
uint tile = TILE_FROM_XY(x, y);
|
uint tile = TILE_FROM_XY(x, y);
|
||||||
Station *st;
|
Station *st;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
// make sure the specified tile belongs to the current player, and that it is a railroad station.
|
// 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;
|
if (!IS_TILETYPE(tile, MP_STATION) || _map5[tile] >= 8 || !_patches.nonuniform_stations) return CMD_ERROR;
|
||||||
st = DEREF_STATION(_map2[tile]);
|
st = DEREF_STATION(_map2[tile]);
|
||||||
|
|
|
@ -231,6 +231,8 @@ static int32 CmdBuildRailWagon(uint engine, uint tile, uint32 flags)
|
||||||
const Engine *e;
|
const Engine *e;
|
||||||
int x,y;
|
int x,y;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||||
|
|
||||||
rvi = RailVehInfo(engine);
|
rvi = RailVehInfo(engine);
|
||||||
value = (rvi->base_cost * _price.build_railwagon) >> 8;
|
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;
|
p2 = p2 & 0xFF;
|
||||||
|
|
||||||
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
SET_EXPENSES_TYPE(EXPENSES_TRAIN_RUN);
|
||||||
|
|
||||||
v = &_vehicles[p1];
|
v = &_vehicles[p1];
|
||||||
if (!CheckOwnership(v->owner) || ((CheckStoppedInDepot(v) < 0) && !(SkipStoppedInDepotCheck)))
|
if (!CheckOwnership(v->owner) || ((CheckStoppedInDepot(v) < 0) && !(SkipStoppedInDepotCheck)))
|
||||||
|
|
|
@ -318,6 +318,8 @@ int32 CmdBuildCompanyHQ(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
int score;
|
int score;
|
||||||
int32 cost = 0;
|
int32 cost = 0;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
|
||||||
|
|
||||||
if (CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL) == CMD_ERROR)
|
if (CheckFlatLandBelow(tile, 2, 2, flags, 0, NULL) == CMD_ERROR)
|
||||||
return 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);
|
uint tile = TILE_FROM_XY(x,y);
|
||||||
Player *p;
|
Player *p;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_PROPERTY);
|
||||||
|
|
||||||
if ((int)p1 != OWNER_WATER) // destruction was initiated by player
|
if ((int)p1 != OWNER_WATER) // destruction was initiated by player
|
||||||
p = DEREF_PLAYER((byte)p1);
|
p = DEREF_PLAYER((byte)p1);
|
||||||
else { // find player that has HQ flooded, and reset their location_of_house
|
else { // find player that has HQ flooded, and reset their location_of_house
|
||||||
|
|
|
@ -399,7 +399,7 @@ static inline uint32 GetDParam(uint n)
|
||||||
|
|
||||||
#define INJECT_DPARAM(n) InjectDparam(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 */
|
/* landscape.c */
|
||||||
extern const byte _tileh_to_sprite[32];
|
extern const byte _tileh_to_sprite[32];
|
||||||
|
|
|
@ -1412,6 +1412,8 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
uint32 autorefit_money = (p2 >> 16) * 100000;
|
uint32 autorefit_money = (p2 >> 16) * 100000;
|
||||||
Vehicle *v = DEREF_VEHICLE(p1);
|
Vehicle *v = DEREF_VEHICLE(p1);
|
||||||
int cost, build_cost;
|
int cost, build_cost;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
|
||||||
|
|
||||||
if (v->type != _engines[new_engine_type].type) return CMD_ERROR;
|
if (v->type != _engines[new_engine_type].type) return CMD_ERROR;
|
||||||
|
|
||||||
|
|
|
@ -171,6 +171,8 @@ int32 CmdBuildLock(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
||||||
uint tile = TILE_FROM_XY(x,y);
|
uint tile = TILE_FROM_XY(x,y);
|
||||||
int32 ret;
|
int32 ret;
|
||||||
uint th;
|
uint th;
|
||||||
|
|
||||||
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
th = GetTileSlope(tile, NULL);
|
th = GetTileSlope(tile, NULL);
|
||||||
|
|
||||||
if (th==3 || th==6 || th==9 || th==12) {
|
if (th==3 || th==6 || th==9 || th==12) {
|
||||||
|
|
Loading…
Reference in New Issue