Mercurial > hg > openttd
changeset 889:8a7301b5aa5b draft
(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.
author | darkvater <darkvater@openttd.org> |
---|---|
date | Tue, 04 Jan 2005 17:11:03 +0000 |
parents | e914cad83268 |
children | 0d0e9e609c71 |
files | clear_cmd.c command.c industry_cmd.c landscape.c lang/english.txt rail_cmd.c road_cmd.c station_cmd.c train_cmd.c unmovable_cmd.c variables.h vehicle.c water_cmd.c |
diffstat | 13 files changed, 39 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/clear_cmd.c +++ b/clear_cmd.c @@ -330,6 +330,8 @@ uint tile; int32 ret, cost, money; + SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); + // remember level height h = _map_type_and_height[p1]&0xF;
--- a/command.c +++ b/command.c @@ -356,8 +356,8 @@ } } - // 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 @@ // 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
--- a/industry_cmd.c +++ b/industry_cmd.c @@ -398,6 +398,8 @@ 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))
--- a/landscape.c +++ b/landscape.c @@ -351,6 +351,8 @@ 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;
--- a/lang/english.txt +++ b/lang/english.txt @@ -2763,7 +2763,7 @@ 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
--- a/rail_cmd.c +++ b/rail_cmd.c @@ -542,6 +542,8 @@ 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 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 @@ 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 @@ 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 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;
--- a/road_cmd.c +++ b/road_cmd.c @@ -494,6 +494,8 @@ int mode; int32 cost,ret; + SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); + start_tile = p1; end_tile = TILE_FROM_XY(x, y); @@ -545,6 +547,8 @@ uint start_tile, end_tile, tile; int32 cost,ret; + SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); + start_tile = p1; end_tile = TILE_FROM_XY(x, y);
--- a/station_cmd.c +++ b/station_cmd.c @@ -957,6 +957,8 @@ 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]);
--- a/train_cmd.c +++ b/train_cmd.c @@ -231,6 +231,8 @@ 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 @@ 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)))
--- a/unmovable_cmd.c +++ b/unmovable_cmd.c @@ -318,6 +318,8 @@ 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 @@ 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
--- a/variables.h +++ b/variables.h @@ -399,7 +399,7 @@ #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];