# HG changeset patch # User darkvater # Date 1104858663 0 # Node ID 64d2f7d5f02bcc717c463e9b6b3662f6e0fece97 # Parent a299cab0927e9541d1c8d8820eee6280fa353bf6 (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. diff -r a299cab0927e -r 64d2f7d5f02b clear_cmd.c --- a/clear_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/clear_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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; diff -r a299cab0927e -r 64d2f7d5f02b command.c --- a/command.c Tue Jan 04 17:04:10 2005 +0000 +++ b/command.c Tue Jan 04 17:11:03 2005 +0000 @@ -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 diff -r a299cab0927e -r 64d2f7d5f02b industry_cmd.c --- a/industry_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/industry_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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)) diff -r a299cab0927e -r 64d2f7d5f02b landscape.c --- a/landscape.c Tue Jan 04 17:04:10 2005 +0000 +++ b/landscape.c Tue Jan 04 17:11:03 2005 +0000 @@ -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; diff -r a299cab0927e -r 64d2f7d5f02b lang/english.txt --- a/lang/english.txt Tue Jan 04 17:04:10 2005 +0000 +++ b/lang/english.txt Tue Jan 04 17:11:03 2005 +0000 @@ -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 diff -r a299cab0927e -r 64d2f7d5f02b rail_cmd.c --- a/rail_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/rail_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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; diff -r a299cab0927e -r 64d2f7d5f02b road_cmd.c --- a/road_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/road_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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); diff -r a299cab0927e -r 64d2f7d5f02b station_cmd.c --- a/station_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/station_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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]); diff -r a299cab0927e -r 64d2f7d5f02b train_cmd.c --- a/train_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/train_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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))) diff -r a299cab0927e -r 64d2f7d5f02b unmovable_cmd.c --- a/unmovable_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/unmovable_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -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 diff -r a299cab0927e -r 64d2f7d5f02b variables.h --- a/variables.h Tue Jan 04 17:04:10 2005 +0000 +++ b/variables.h Tue Jan 04 17:11:03 2005 +0000 @@ -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]; diff -r a299cab0927e -r 64d2f7d5f02b vehicle.c --- a/vehicle.c Tue Jan 04 17:04:10 2005 +0000 +++ b/vehicle.c Tue Jan 04 17:11:03 2005 +0000 @@ -1412,6 +1412,8 @@ 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 -r a299cab0927e -r 64d2f7d5f02b water_cmd.c --- a/water_cmd.c Tue Jan 04 17:04:10 2005 +0000 +++ b/water_cmd.c Tue Jan 04 17:11:03 2005 +0000 @@ -171,6 +171,8 @@ 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) {