Changeset - r15878:2d36635f395d
[Not reviewed]
master
0 2 0
rubidium - 14 years ago 2010-08-19 20:34:51
rubidium@openttd.org
(svn r20570) -Codechange: free/reserve some bits in the timetable commands to increase the vehicle pool limit
2 files changed with 12 insertions and 12 deletions:
0 comments (0 inline, 0 general)
src/timetable_cmd.cpp
Show inline comments
 
@@ -46,38 +46,38 @@ static void ChangeTimetable(Vehicle *v, 
 

	
 
/**
 
 * Add or remove waiting times from an order.
 
 * @param tile Not used.
 
 * @param flags Operation to perform.
 
 * @param p1 Various bitstuffed elements
 
 * - p1 = (bit  0-15) - Vehicle with the orders to change.
 
 * - p1 = (bit 16-23) - Order index to modify.
 
 * - p1 = (bit    24) - Whether to change the waiting time or the travelling
 
 * - p1 = (bit  0-19) - Vehicle with the orders to change.
 
 * - p1 = (bit 20-27) - Order index to modify.
 
 * - p1 = (bit    28) - Whether to change the waiting time or the travelling
 
 *                      time.
 
 * @param p2 The amount of time to wait.
 
 * - p2 = (bit  0-15) - Waiting or travelling time as specified by p1 bit 24
 
 * - p2 = (bit  0-15) - Waiting or travelling time as specified by p1 bit 28
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdChangeTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!_settings_game.order.timetabling) return CMD_ERROR;
 

	
 
	VehicleID veh = GB(p1, 0, 16);
 
	VehicleID veh = GB(p1, 0, 20);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
	if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	VehicleOrderID order_number = GB(p1, 16, 8);
 
	VehicleOrderID order_number = GB(p1, 20, 8);
 
	Order *order = v->GetOrder(order_number);
 
	if (order == NULL) return CMD_ERROR;
 

	
 
	bool is_journey = HasBit(p1, 24);
 
	bool is_journey = HasBit(p1, 28);
 

	
 
	int wait_time   = order->wait_time;
 
	int travel_time = order->travel_time;
 
	if (is_journey) {
 
		travel_time = GB(p2, 0, 16);
 
	} else {
 
@@ -109,22 +109,22 @@ CommandCost CmdChangeTimetable(TileIndex
 

	
 
/**
 
 * Clear the lateness counter to make the vehicle on time.
 
 * @param tile Not used.
 
 * @param flags Operation to perform.
 
 * @param p1 Various bitstuffed elements
 
 * - p1 = (bit  0-15) - Vehicle with the orders to change.
 
 * - p1 = (bit  0-19) - Vehicle with the orders to change.
 
 * @param p2 unused
 
 * @param text unused
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdSetVehicleOnTime(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!_settings_game.order.timetabling) return CMD_ERROR;
 

	
 
	VehicleID veh = GB(p1, 0, 16);
 
	VehicleID veh = GB(p1, 0, 20);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
	if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 
@@ -147,13 +147,13 @@ CommandCost CmdSetVehicleOnTime(TileInde
 
 * @return The error or cost of the operation.
 
 */
 
CommandCost CmdSetTimetableStart(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!_settings_game.order.timetabling) return CMD_ERROR;
 

	
 
	Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 16));
 
	Vehicle *v = Vehicle::GetIfValid(GB(p1, 0, 20));
 
	if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
 

	
 
	/* Don't let a timetable start more than 15 years into the future or 1 year in the past. */
 
@@ -188,13 +188,13 @@ CommandCost CmdSetTimetableStart(TileInd
 
 * @return the cost of this operation or an error
 
 */
 
CommandCost CmdAutofillTimetable(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
 
{
 
	if (!_settings_game.order.timetabling) return CMD_ERROR;
 

	
 
	VehicleID veh = GB(p1, 0, 16);
 
	VehicleID veh = GB(p1, 0, 20);
 

	
 
	Vehicle *v = Vehicle::GetIfValid(veh);
 
	if (v == NULL || !v->IsPrimaryVehicle()) return CMD_ERROR;
 

	
 
	CommandCost ret = CheckOwnership(v->owner);
 
	if (ret.Failed()) return ret;
src/timetable_gui.cpp
Show inline comments
 
@@ -494,13 +494,13 @@ struct TimetableWindow : Window {
 
	{
 
		uint order_number = (selected + 1) / 2;
 
		uint is_journey   = (selected % 2 == 1) ? 1 : 0;
 

	
 
		if (order_number >= v->GetNumOrders()) order_number = 0;
 

	
 
		return v->index | (order_number << 16) | (is_journey << 24);
 
		return v->index | (order_number << 20) | (is_journey << 28);
 
	}
 

	
 
	virtual void OnClick(Point pt, int widget, int click_count)
 
	{
 
		const Vehicle *v = this->vehicle;
 

	
0 comments (0 inline, 0 general)