Mercurial > hg > openttd
changeset 2819:717b7b06dcdb draft
(svn r3367) Unify the 4 distinct CMD_CHANGE_{AIRCRAFT,ROADVEH,SHIP,TRAIN}_SERVICE_INT commands into one CMD_CHANGE_SERVICE_INT command.
As side effect this is a
-Fix: The default AI tried to change the service intervals of vehicles via the CMD_CHANGE_TRAIN_SERVICE_INT command - regardless of the type of the vehicle - which of course failed for non-trains
author | tron <tron@openttd.org> |
---|---|
date | Thu, 05 Jan 2006 21:35:54 +0000 |
parents | 6634108b4540 |
children | 9d8e0b41ef8a |
files | ai/default/default.c aircraft_cmd.c aircraft_gui.c command.c command.h roadveh_cmd.c roadveh_gui.c ship_cmd.c ship_gui.c train_cmd.c train_gui.c vehicle.c |
diffstat | 12 files changed, 40 insertions(+), 115 deletions(-) [+] |
line wrap: on
line diff
--- a/ai/default/default.c +++ b/ai/default/default.c @@ -311,7 +311,7 @@ AiRestoreVehicleOrders(GetVehicle(veh), orderbak); DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_TRAIN); - DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT); + DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); } } } @@ -340,7 +340,7 @@ AiRestoreVehicleOrders(GetVehicle(veh), orderbak); DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_ROADVEH); - DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT); + DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); } } } @@ -369,7 +369,7 @@ AiRestoreVehicleOrders(GetVehicle(veh), orderbak); DoCommandByTile(0, veh, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT); - DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT); + DoCommandByTile(0, veh, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); } } } @@ -2450,7 +2450,7 @@ DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_TRAIN); - DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT); + DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); if (p->ai.num_want_fullload != 0) p->ai.num_want_fullload--; @@ -3207,7 +3207,7 @@ } DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_ROADVEH); - DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT); + DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); if (p->ai.num_want_fullload != 0) p->ai.num_want_fullload--; if (--p->ai.num_loco_to_build == 0) p->ai.state = AIS_0; @@ -3521,7 +3521,7 @@ DoCommandByTile(0, loco_id, 0, DC_EXEC, CMD_START_STOP_AIRCRAFT); - DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_TRAIN_SERVICE_INT); + DoCommandByTile(0, loco_id, _ai_service_interval, DC_EXEC, CMD_CHANGE_SERVICE_INT); if (p->ai.num_want_fullload != 0) p->ai.num_want_fullload--;
--- a/aircraft_cmd.c +++ b/aircraft_cmd.c @@ -452,29 +452,6 @@ return 0; } -/** Change the service interval for aircraft. - * @param x,y unused - * @param p1 vehicle ID that is being service-interval-changed - * @param p2 new service interval - */ -int32 CmdChangeAircraftServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) -{ - Vehicle *v; - uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */ - - if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR; - - v = GetVehicle(p1); - - if (v->type != VEH_Aircraft || !CheckOwnership(v->owner)) return CMD_ERROR; - - if (flags & DC_EXEC) { - v->service_interval = serv_int; - InvalidateWindowWidget(WC_VEHICLE_DETAILS, v->index, 7); - } - - return 0; -} /** Refits an aircraft to the specified cargo type. * @param x,y unused
--- a/aircraft_gui.c +++ b/aircraft_gui.c @@ -415,7 +415,7 @@ mod = GetServiceIntervalClamped(mod + v->service_interval); if (mod == v->service_interval) return; - DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_AIRCRAFT_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); + DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); break; } } break;
--- a/command.c +++ b/command.c @@ -77,7 +77,7 @@ DEF_COMMAND(CmdSkipOrder); DEF_COMMAND(CmdDeleteOrder); DEF_COMMAND(CmdInsertOrder); -DEF_COMMAND(CmdChangeTrainServiceInt); +DEF_COMMAND(CmdChangeServiceInt); DEF_COMMAND(CmdRestoreOrderIndex); DEF_COMMAND(CmdBuildIndustry); @@ -103,7 +103,6 @@ DEF_COMMAND(CmdStartStopAircraft); DEF_COMMAND(CmdBuildAircraft); DEF_COMMAND(CmdSendAircraftToHangar); -DEF_COMMAND(CmdChangeAircraftServiceInt); DEF_COMMAND(CmdRefitAircraft); DEF_COMMAND(CmdPlaceSign); @@ -114,7 +113,6 @@ DEF_COMMAND(CmdSellRoadVeh); DEF_COMMAND(CmdSendRoadVehToDepot); DEF_COMMAND(CmdTurnRoadVeh); -DEF_COMMAND(CmdChangeRoadVehServiceInt); DEF_COMMAND(CmdPause); @@ -136,7 +134,6 @@ DEF_COMMAND(CmdSellShip); DEF_COMMAND(CmdBuildShip); DEF_COMMAND(CmdSendShipToDepot); -DEF_COMMAND(CmdChangeShipServiceInt); DEF_COMMAND(CmdRefitShip); DEF_COMMAND(CmdCloneOrder); @@ -212,7 +209,7 @@ {CmdDeleteOrder, 0}, /* 44 */ {CmdInsertOrder, 0}, /* 45 */ - {CmdChangeTrainServiceInt, 0}, /* 46 */ + {CmdChangeServiceInt, 0}, /* 46 */ {CmdBuildIndustry, 0}, /* 47 */ {CmdBuildCompanyHQ, 0}, /* 48 */ @@ -237,7 +234,7 @@ {CmdBuildAircraft, 0}, /* 61 */ {CmdSendAircraftToHangar, 0}, /* 62 */ - {CmdChangeAircraftServiceInt, 0}, /* 63 */ + {NULL, 0}, /* 63 */ {CmdRefitAircraft, 0}, /* 64 */ {CmdPlaceSign, 0}, /* 65 */ @@ -248,7 +245,7 @@ {CmdSellRoadVeh, 0}, /* 69 */ {CmdSendRoadVehToDepot, 0}, /* 70 */ {CmdTurnRoadVeh, 0}, /* 71 */ - {CmdChangeRoadVehServiceInt, 0}, /* 72 */ + {NULL, 0}, /* 72 */ {CmdPause, CMD_SERVER}, /* 73 */ @@ -271,7 +268,7 @@ {CmdSellShip, 0}, /* 87 */ {CmdBuildShip, 0}, /* 88 */ {CmdSendShipToDepot, 0}, /* 89 */ - {CmdChangeShipServiceInt, 0}, /* 90 */ + {NULL, 0}, /* 90 */ {CmdRefitShip, 0}, /* 91 */ {NULL, 0}, /* 92 */
--- a/command.h +++ b/command.h @@ -58,7 +58,7 @@ CMD_DELETE_ORDER = 44, CMD_INSERT_ORDER = 45, - CMD_CHANGE_TRAIN_SERVICE_INT = 46, + CMD_CHANGE_SERVICE_INT = 46, CMD_BUILD_INDUSTRY = 47, @@ -81,7 +81,6 @@ CMD_START_STOP_AIRCRAFT = 60, CMD_BUILD_AIRCRAFT = 61, CMD_SEND_AIRCRAFT_TO_HANGAR = 62, - CMD_CHANGE_AIRCRAFT_SERVICE_INT = 63, CMD_REFIT_AIRCRAFT = 64, CMD_PLACE_SIGN = 65, @@ -92,7 +91,6 @@ CMD_SELL_ROAD_VEH = 69, CMD_SEND_ROADVEH_TO_DEPOT = 70, CMD_TURN_ROADVEH = 71, - CMD_CHANGE_ROADVEH_SERVICE_INT = 72, CMD_PAUSE = 73, @@ -113,7 +111,6 @@ CMD_SELL_SHIP = 87, CMD_BUILD_SHIP = 88, CMD_SEND_SHIP_TO_DEPOT = 89, - CMD_CHANGE_SHIP_SERVICE_INT = 90, CMD_REFIT_SHIP = 91, CMD_CLONE_ORDER = 99,
--- a/roadveh_cmd.c +++ b/roadveh_cmd.c @@ -410,30 +410,6 @@ return 0; } -/** Change the service interval for road vehicles. - * @param x,y unused - * @param p1 vehicle ID that is being service-interval-changed - * @param p2 new service interval - */ -int32 CmdChangeRoadVehServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) -{ - Vehicle *v; - uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */ - - if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR; - - v = GetVehicle(p1); - - if (v->type != VEH_Road || !CheckOwnership(v->owner)) return CMD_ERROR; - - if (flags & DC_EXEC) { - v->service_interval = serv_int; - InvalidateWindowWidget(WC_VEHICLE_DETAILS, v->index, 7); - } - - return 0; -} - static void MarkRoadVehDirty(Vehicle *v) {
--- a/roadveh_gui.c +++ b/roadveh_gui.c @@ -169,7 +169,7 @@ mod = GetServiceIntervalClamped(mod + v->service_interval); if (mod == v->service_interval) return; - DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_ROADVEH_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); + DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); break; } } break;
--- a/ship_cmd.c +++ b/ship_cmd.c @@ -1008,29 +1008,6 @@ return 0; } -/** Change the service interval for ships. - * @param x,y unused - * @param p1 vehicle ID that is being service-interval-changed - * @param p2 new service interval - */ -int32 CmdChangeShipServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) -{ - Vehicle *v; - uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */ - - if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR; - - v = GetVehicle(p1); - - if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR; - - if (flags & DC_EXEC) { - v->service_interval = serv_int; - InvalidateWindowWidget(WC_VEHICLE_DETAILS, v->index, 7); - } - - return 0; -} /** Refits a ship to the specified cargo type. * @param x,y unused
--- a/ship_gui.c +++ b/ship_gui.c @@ -246,7 +246,7 @@ mod = GetServiceIntervalClamped(mod + v->service_interval); if (mod == v->service_interval) return; - DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SHIP_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); + DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); break; } } break;
--- a/train_cmd.c +++ b/train_cmd.c @@ -1897,29 +1897,6 @@ return 0; } -/** Change the service interval for trains. - * @param x,y unused - * @param p1 vehicle ID that is being service-interval-changed - * @param p2 new service interval - */ -int32 CmdChangeTrainServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) -{ - Vehicle *v; - uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */ - - if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR; - - v = GetVehicle(p1); - - if (v->type != VEH_Train || !CheckOwnership(v->owner)) return CMD_ERROR; - - if (flags & DC_EXEC) { - v->service_interval = serv_int; - InvalidateWindowWidget(WC_VEHICLE_DETAILS, v->index, 8); - } - - return 0; -} void OnTick_Train(void) {
--- a/train_gui.c +++ b/train_gui.c @@ -1254,7 +1254,7 @@ mod = GetServiceIntervalClamped(mod + v->service_interval); if (mod == v->service_interval) return; - DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_TRAIN_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); + DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING)); break; /* details buttons*/ case 9: // Cargo
--- a/vehicle.c +++ b/vehicle.c @@ -1844,6 +1844,30 @@ } +/** Change the service interval of a vehicle + * @param x,y unused + * @param p1 vehicle ID that is being service-interval-changed + * @param p2 new service interval + */ +int32 CmdChangeServiceInt(int x, int y, uint32 flags, uint32 p1, uint32 p2) +{ + Vehicle* v; + uint16 serv_int = GetServiceIntervalClamped(p2); /* Double check the service interval from the user-input */ + + if (serv_int != p2 || !IsVehicleIndex(p1)) return CMD_ERROR; + + v = GetVehicle(p1); + + if (v->type == 0 || !CheckOwnership(v->owner)) return CMD_ERROR; + + if (flags & DC_EXEC) { + v->service_interval = serv_int; + InvalidateWindow(WC_VEHICLE_DETAILS, v->index); + } + + return 0; +} + static Rect _old_vehicle_coords;