diff options
author | bjarni <bjarni@openttd.org> | 2005-11-07 23:20:47 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2005-11-07 23:20:47 +0000 |
commit | df6c48fdba7933e30a16c82e69d8d57ab9515e6d (patch) | |
tree | 419d4e9a7f19cca429bc209799068506c9d20f9d /players.c | |
parent | 1258ca0bf0beeb045a6f039c900f31658b8c331b (diff) | |
download | openttd-df6c48fdba7933e30a16c82e69d8d57ab9515e6d.tar.xz |
(svn r3155) -Feature: [autoreplace] autoreplace can now remove cars from too long trains
-Trains will now remember the length of stations it visits and sell cars
when being autoreplaced if they became too long
-If it needs to remove cars, then it starts from the front and sells
all it can find until the train is short enough
-This only works for trains, that knows the station length of the route
so a full uninterrupted run is needed
-a train needs 1-2 runs to detect if the shortest station is expanded
-This feature can be turned on and off in the train replace window
and each company can have it's own setting
-NOTE: minor savegame version bump
Diffstat (limited to 'players.c')
-rw-r--r-- | players.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -497,6 +497,7 @@ Player *DoStartupNewPlayer(bool is_ai) for (i = 0; i < TOTAL_NUM_ENGINES; i++) p->engine_replacement[i] = INVALID_ENGINE; + p->renew_keep_length = false; p->engine_renew = false; p->engine_renew_months = -6; p->engine_renew_money = 100000; @@ -654,6 +655,7 @@ static void DeletePlayerStuff(PlayerID pi) * - p1 = 2 - change auto renew money * - p1 = 3 - change auto renew array * - p1 = 4 - change bool, months & money all together + * - p1 = 5 - change renew_keep_length * @param p2 value to set * if p1 = 0, then: * - p2 = enable engine renewal @@ -668,6 +670,8 @@ static void DeletePlayerStuff(PlayerID pi) * - p1 bit 15 = enable engine renewal * - p1 bits 16-31 = months left before engine expires to replace it * - p2 bits 0-31 = minimum amount of money available + * if p1 = 5, then + * - p2 = enable renew_keep_length */ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) { @@ -754,8 +758,19 @@ int32 CmdReplaceVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) } } break; - } + case 5: + if (p->renew_keep_length == (bool)GB(p2, 0, 1)) + return CMD_ERROR; + + if (flags & DC_EXEC) { + p->renew_keep_length = (bool)GB(p2, 0, 1); + if (IsLocalPlayer()) { + InvalidateWindow(WC_REPLACE_VEHICLE, VEH_Train); + } + } + break; + } return 0; } @@ -1131,9 +1146,11 @@ static const SaveLoad _player_desc[] = { SLE_CONDVAR(Player,engine_renew, SLE_UINT8, 16, 255), SLE_CONDVAR(Player,engine_renew_months, SLE_INT16, 16, 255), SLE_CONDVAR(Player,engine_renew_money, SLE_UINT32, 16, 255), + SLE_CONDVAR(Player,renew_keep_length, SLE_UINT8, 2, 255), // added with 16.1, but was blank since 2 - // reserve extra space in savegame here. (currently 64 bytes) - SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 8, 2, 255), + // reserve extra space in savegame here. (currently 63 bytes) + SLE_CONDARR(NullStruct,null,SLE_FILE_U8 | SLE_VAR_NULL, 7, 2, 255), + SLE_CONDARR(NullStruct,null,SLE_FILE_U64 | SLE_VAR_NULL, 7, 2, 255), SLE_END() }; |