Changeset - r19:6da4a71c334c
[Not reviewed]
master
0 7 0
dominik - 20 years ago 2004-08-11 10:15:38
dominik@openttd.org
(svn r20) Feature: warning when a vehicle has invalid orders (celestar)
7 files changed with 102 insertions and 0 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -560,12 +560,14 @@ void OnNewDay_Aircraft(Vehicle *v)
 
	if (v->subtype > 2)
 
		return;
 

	
 
	if ((++v->day_counter & 7) == 0)
 
		DecreaseVehicleValue(v);
 

	
 
	CheckOrders(v);
 

	
 
	CheckVehicleBreakdown(v);
 
	AgeVehicle(v);
 
	CheckIfAircraftNeedsService(v);
 

	
 
	if (v->vehstatus & VS_STOPPED)
 
		return;
lang/english.txt
Show inline comments
 
@@ -900,12 +900,25 @@ STR_CANT_COPY_ORDER_LIST				:{WHITE}Can'
 
STR_END_OF_SHARED_ORDERS				:{SETX 10}- - End of Shared Orders - -
 

	
 
STR_TRAIN_IS_LOST						:{WHITE}Train {COMMA16} is lost.
 
STR_TRAIN_IS_UNPROFITABLE				:{WHITE}Train {COMMA16}'s profit last year was {CURRENCY}
 
STR_EURO_INTRODUCE					:{BLACK}{BIGFONT}European Monetary Union!{}{}The Euro is introduced as the sole currency for everyday transactions in your country!
 

	
 
STR_TRAIN_HAS_TOO_FEW_ORDERS				:{WHITE}Train {COMMA16} has too few orders in the schedule
 
STR_TRAIN_HAS_VOID_ORDER						:{WHITE}Train {COMMA16} has a void order
 
STR_TRAIN_HAS_DUPLICATE_ENTRY				:{WHITE}Train {COMMA16} has duplicate orders
 
STR_AIRCRAFT_HAS_TOO_FEW_ORDERS			:{WHITE}Aircraft {COMMA16} has too few orders in the schedule
 
STR_AIRCRAFT_HAS_VOID_ORDER					:{WHITE}Aircraft {COMMA16} has void order
 
STR_AIRCRAFT_HAS_DUPLICATE_ENTRY		:{WHITE}Aircraft {COMMA16} has duplicate orders
 
STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS	:{WHITE}Road Vehicle {COMMA16} has too few orders in the schedule
 
STR_ROADVEHICLE_HAS_VOID_ORDER			:{WHITE}Road Vehicle {COMMA16} has void order
 
STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY	:{WHITE}Road Vehicle {COMMA16} has duplicate orders
 
STR_SHIP_HAS_TOO_FEW_ORDERS					:{WHITE}Ship {COMMA16} has too few orders in the schedule
 
STR_SHIP_HAS_VOID_ORDER							:{WHITE}Ship {COMMA16} has void order
 
STR_SHIP_HAS_DUPLICATE_ENTRY				:{WHITE}Ship {COMMA16} has duplicate orders
 

	
 
STR_CONFIG_PATCHES						:{BLACK}Configure Patches
 
STR_CONFIG_PATCHES_TIP					:{BLACK}Configure the patches
 
STR_CONFIG_PATCHES_CAPTION				:{WHITE}Configure Patches
 

	
 
STR_CONFIG_PATCHES_OFF					:Off
 
STR_CONFIG_PATCHES_ON					:On
order_cmd.c
Show inline comments
 
#include "stdafx.h"
 
#include "ttd.h"
 
#include "vehicle.h"
 
#include "command.h"
 
#include "station.h"
 
#include "player.h"
 
#include "news.h"
 

	
 
/* p1 & 0xFFFF = vehicle
 
 * p1 >> 16 = index in order list
 
 * p2 = order command to insert
 
 */
 
int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
 
@@ -327,6 +328,83 @@ int32 CmdRestoreOrderIndex(int x, int y,
 
		Vehicle *v = &_vehicles[p1];
 
		v->service_interval = (uint16)(p2>>16);
 
		v->cur_order_index = (byte)(p2&0xFFFF);
 
	}
 
	return 0;
 
}
 

	
 
int CheckOrders(Vehicle *v)
 
{
 
	int i, n_st, duplicate;
 
	uint16 order, old_orderer;
 
	uint16 dummy;
 
	int message=0;
 
	
 
	/* check the order list */
 
	order = v->schedule_ptr[0];
 
	n_st = duplicate = dummy = 0;
 

	
 
	/* only check every 20 days */
 
	if ( ( ( v->day_counter % 20) == 0 ) && (v->owner == _local_player) ) {
 
		for(old_orderer = i = 0; order!=0; i++ ) {
 
			order = v->schedule_ptr[i];
 
			if (order == old_orderer) duplicate = -1;
 
			if ( (order & OT_MASK) == OT_DUMMY ) dummy = -1;
 
			if ( ( (order & OT_MASK) == OT_GOTO_STATION ) /*&& (order != old_order) */) {
 
				//I uncommented this in order not to get two error messages
 
				//when two identical entries are in the list
 
				n_st++;
 
			}
 
			old_orderer = order; //store the old order
 
		}
 

	
 
		//Now, check the last and the first order
 
		//as the last order is the end of order marker, jump back 2
 
		if ( (v->schedule_ptr[0] == v->schedule_ptr[i-2]) && ( i-2 != 0 ) ) duplicate = -1;
 

	
 
		SET_DPARAM16(0, v->unitnumber);
 

	
 
		if  (n_st < 2) {
 
			switch (v->type) {
 
				case VEH_Train: message = STR_TRAIN_HAS_TOO_FEW_ORDERS; break;
 
				case VEH_Road: message = STR_ROADVEHICLE_HAS_TOO_FEW_ORDERS; break;
 
				case VEH_Ship: message = STR_SHIP_HAS_TOO_FEW_ORDERS; break;
 
				case VEH_Aircraft: message = STR_AIRCRAFT_HAS_TOO_FEW_ORDERS; break;
 
			}
 
			AddNewsItem(
 
				message,
 
				NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 
				v->index,
 
				0);
 
		} else if (duplicate) {
 
			switch (v->type) {
 
				case VEH_Train: message = STR_TRAIN_HAS_DUPLICATE_ENTRY; break;
 
				case VEH_Road: message = STR_ROADVEHICLE_HAS_DUPLICATE_ENTRY; break;
 
				case VEH_Ship: message = STR_SHIP_HAS_DUPLICATE_ENTRY; break;
 
				case VEH_Aircraft: message = STR_AIRCRAFT_HAS_DUPLICATE_ENTRY; break;
 
			}
 
			AddNewsItem(
 
				message,
 
				NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 
				v->index,
 
				0);
 
		} else if (dummy) {
 
			switch (v->type) {
 
				case VEH_Train: message = STR_TRAIN_HAS_VOID_ORDER; break;
 
				case VEH_Road: message = STR_ROADVEHICLE_HAS_VOID_ORDER; break;
 
				case VEH_Ship: message = STR_SHIP_HAS_VOID_ORDER; break;
 
				case VEH_Aircraft: message = STR_AIRCRAFT_HAS_VOID_ORDER; break;
 
			}
 
			AddNewsItem(
 
				message,
 
				NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 
				v->index,
 
				0);
 
		}
 
	}
 
	// End of order check
 

	
 
	if ( (n_st > 2) || (duplicate) || (dummy) ) 
 
		return 1;
 
	else
 
		return 0;
 
}
roadveh_cmd.c
Show inline comments
 
@@ -1537,12 +1537,14 @@ void OnNewDay_RoadVeh(Vehicle *v)
 
	if (v->u.road.unk2 == 0)
 
		CheckVehicleBreakdown(v);
 

	
 
	AgeVehicle(v);
 
	CheckIfRoadVehNeedsService(v);
 

	
 
	CheckOrders(v);
 

	
 
	/* update destination */
 
	if ((v->next_order & OT_MASK) == OT_GOTO_STATION) {
 
		st = DEREF_STATION(v->next_order_param);
 
		if ((tile=(v->cargo_type==CT_PASSENGERS ? st->bus_tile : st->lorry_tile)) != 0)
 
			v->dest_tile = tile;
 
	}
ship_cmd.c
Show inline comments
 
@@ -124,15 +124,19 @@ void OnNewDay_Ship(Vehicle *v)
 
		DecreaseVehicleValue(v);
 

	
 
	CheckVehicleBreakdown(v);
 
	AgeVehicle(v);
 
	CheckIfShipNeedsService(v);
 

	
 
	CheckOrders(v);
 
	
 
	if (v->vehstatus & VS_STOPPED)
 
		return;
 

	
 
	
 

	
 
	cost = ship_vehicle_info(v->engine_type).running_cost * _price.ship_running / 364;
 
	v->profit_this_year -= cost >> 8;
 

	
 
	SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
 
	SubtractMoneyFromPlayerFract(v->owner, cost);
 

	
train_cmd.c
Show inline comments
 
@@ -2575,12 +2575,14 @@ void OnNewDay_Train(Vehicle *v)
 
				STR_TRAIN_IS_LOST,
 
				NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 
				v->index,
 
				0);
 
		}
 

	
 
		CheckOrders(v);
 
				
 
		/* update destination */
 
		if ((v->next_order & OT_MASK) == OT_GOTO_STATION &&
 
				(tile=DEREF_STATION(v->next_order_param)->train_tile) != 0)
 
					v->dest_tile = tile;
 

	
 
		if ((v->vehstatus & VS_STOPPED) == 0) {
vehicle.h
Show inline comments
 
@@ -351,12 +351,13 @@ void DoDeleteDepot(uint tile);
 
void UpdateTrainAcceleration(Vehicle *v);
 
int32 GetTrainRunningCost(Vehicle *v);
 

	
 
int CheckStoppedInDepot(Vehicle *v);
 

	
 
int ScheduleHasDepotOrders(uint16 *schedule);
 
int CheckOrders(Vehicle *v);
 

	
 
typedef struct GetNewVehiclePosResult {
 
	int x,y;
 
	uint old_tile;
 
	uint new_tile;
 
} GetNewVehiclePosResult;
0 comments (0 inline, 0 general)