Changeset - r3140:72affb391e90
[Not reviewed]
master
0 8 0
tron - 18 years ago 2006-03-04 11:15:44
tron@openttd.org
(svn r3758) Remove the news validation callback. It is superseded by r3757.
8 files changed with 21 insertions and 78 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -562,7 +562,7 @@ void OnNewDay_Aircraft(Vehicle *v)
 

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

	
 
	CheckOrders(v->index, OC_INIT);
 
	CheckOrders(v);
 

	
 
	CheckVehicleBreakdown(v);
 
	AgeVehicle(v);
 
@@ -1218,12 +1218,6 @@ static void AircraftEntersTerminal(Vehic
 
	InvalidateWindowClasses(WC_AIRCRAFT_LIST);
 
}
 

	
 
static bool ValidateAircraftInHangar(uint data_a, uint data_b)
 
{
 
	const Vehicle* v = GetVehicle(data_a);
 

	
 
	return (IsAircraftHangarTile(v->tile) && (v->vehstatus & VS_STOPPED));
 
}
 

	
 
static void AircraftEnterHangar(Vehicle *v)
 
{
 
@@ -1249,12 +1243,12 @@ static void AircraftEnterHangar(Vehicle 
 

	
 
			if (v->owner == _local_player) {
 
				SetDParam(0, v->unitnumber);
 
				AddValidatedNewsItem(
 
				AddNewsItem(
 
					STR_A014_AIRCRAFT_IS_WAITING_IN,
 
					NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 
					v->index,
 
					0,
 
					ValidateAircraftInHangar);
 
					0
 
				);
 
			}
 
		}
 
	}
news.h
Show inline comments
 
@@ -16,11 +16,6 @@ struct NewsItem {
 
	TileIndex data_b;
 

	
 
	uint32 params[10];
 

	
 
	/* The validation functions for news items get called immediately
 
	 * before the news are supposed to be shown. If this funcion returns
 
	 * false, the news item won't be displayed. */
 
	bool (*isValid) ( uint data_a, uint data_b );
 
};
 

	
 
typedef bool ValidationProc ( uint data_a, uint data_b );
 
@@ -29,7 +24,6 @@ typedef StringID GetNewsStringCallbackPr
 

	
 
#define NEWS_FLAGS(mode,flag,type,cb) ((cb)<<24 | (type)<<16 | (flag)<<8 | (mode))
 
void AddNewsItem(StringID string, uint32 flags, uint data_a, uint data_b);
 
void AddValidatedNewsItem(StringID string, uint32 flags, uint data_a, uint data_b, ValidationProc *validation);
 
void NewsLoop(void);
 
void DrawNewsBorder(const Window *w);
 
void InitNewsItemStructs(void);
news_gui.c
Show inline comments
 
@@ -275,13 +275,6 @@ void AddNewsItem(StringID string, uint32
 
	w->vscroll.count = _total_news;
 
}
 

	
 
/* To add a news item with an attached validation function. This validation function
 
 * makes sure that the news item is not outdated when the newspaper pops up. */
 
void AddValidatedNewsItem(StringID string, uint32 flags, uint data_a, uint data_b, ValidationProc *validation)
 
{
 
	AddNewsItem(string, flags, data_a, data_b);
 
	_news_items[_latest_news].isValid = validation;
 
}
 

	
 
// don't show item if it's older than x days
 
static const byte _news_items_age[] = {60, 60, 90, 60, 90, 30, 150, 30, 90, 180};
 
@@ -466,9 +459,6 @@ static void MoveToNexItem(void)
 
		// check the date, don't show too old items
 
		if (_date - _news_items_age[ni->type] > ni->date) return;
 

	
 
		// execute the validation function to see if this item is still valid
 
		if (ni->isValid != NULL && !ni->isValid(ni->data_a, ni->data_b)) return;
 

	
 
		switch (GetNewsDisplayValue(ni->type)) {
 
		case 0: { /* Off - show nothing only a small reminder in the status bar */
 
			Window* w = FindWindowById(WC_STATUS_BAR, 0);
order.h
Show inline comments
 
@@ -70,11 +70,6 @@ enum {
 
	CO_UNSHARE = 2
 
};
 

	
 
/* Modes for the order checker */
 
enum {
 
	OC_INIT     = 0, //the order checker can initialize a news message
 
	OC_VALIDATE = 1, //the order checker validates a news message
 
};
 

	
 
/* If you change this, keep in mind that it is saved on 3 places:
 
    - Load_ORDR, all the global orders
 
@@ -172,7 +167,7 @@ void RestoreVehicleOrders(const Vehicle*
 
void DeleteDestinationFromVehicleOrder(Order dest);
 
void InvalidateVehicleOrder(const Vehicle *v);
 
bool VehicleHasDepotOrders(const Vehicle *v);
 
bool CheckOrders(uint data_a, uint data_b);
 
void CheckOrders(const Vehicle*);
 
void DeleteVehicleOrders(Vehicle *v);
 
bool IsOrderListShared(const Vehicle *v);
 
void AssignOrder(Order *order, Order data);
order_cmd.c
Show inline comments
 
@@ -859,22 +859,20 @@ int32 CmdRestoreOrderIndex(int x, int y,
 
 * Check the orders of a vehicle, to see if there are invalid orders and stuff
 
 *
 
 */
 
bool CheckOrders(uint data_a, uint data_b)
 
void CheckOrders(const Vehicle* v)
 
{
 
	const Vehicle* v = GetVehicle(data_a);
 

	
 
	/* Does the user wants us to check things? */
 
	if (_patches.order_review_system == 0) return false;
 
	if (_patches.order_review_system == 0) return;
 

	
 
	/* Do nothing for crashed vehicles */
 
	if (v->vehstatus & VS_CRASHED) return false;
 
	if (v->vehstatus & VS_CRASHED) return;
 

	
 
	/* Do nothing for stopped vehicles if setting is '1' */
 
	if (_patches.order_review_system == 1 && v->vehstatus & VS_STOPPED)
 
		return false;
 
		return;
 

	
 
	/* do nothing we we're not the first vehicle in a share-chain */
 
	if (v->next_shared != NULL) return false;
 
	if (v->next_shared != NULL) return;
 

	
 
	/* Only check every 20 days, so that we don't flood the message log */
 
	if (v->owner == _local_player && v->day_counter % 20 == 0) {
 
@@ -886,12 +884,6 @@ bool CheckOrders(uint data_a, uint data_
 
		/* Check the order list */
 
		n_st = 0;
 

	
 
		/*if (data_b == OC_INIT) {
 
			DEBUG(misc, 3) ("CheckOrder called in mode 0 (initiation mode) for %d", v->index);
 
		} else {
 
			DEBUG(misc, 3) ("CheckOrder called in mode 1 (validation mode) for %d", v->index);
 
		}*/
 

	
 
		FOR_VEHICLE_ORDERS(v, order) {
 
			/* Dummy order? */
 
			if (order->type == OT_DUMMY) {
 
@@ -920,35 +912,19 @@ bool CheckOrders(uint data_a, uint data_
 
		if (n_st < 2 && problem_type == -1) problem_type = 0;
 

	
 
		/* We don't have a problem */
 
		if (problem_type < 0) {
 
			/*if (data_b == OC_INIT) {
 
				DEBUG(misc, 3) ("CheckOrder mode 0: no problems found for %d", v->index);
 
			} else {
 
				DEBUG(misc, 3) ("CheckOrder mode 1: news item surpressed for %d", v->index);
 
			}*/
 
			return false;
 
		}
 

	
 
		/* we have a problem, are we're just in the validation process
 
		   so don't display an error message */
 
		if (data_b == OC_VALIDATE) {
 
			/*DEBUG(misc, 3) ("CheckOrder mode 1: new item validated for %d", v->index);*/
 
			return true;
 
		}
 
		if (problem_type < 0) return;
 

	
 
		message = STR_TRAIN_HAS_TOO_FEW_ORDERS + ((v->type - VEH_Train) << 2) + problem_type;
 
		/*DEBUG(misc, 3) ("Checkorder mode 0: Triggered News Item for %d", v->index);*/
 
		//DEBUG(misc, 3) ("Triggered News Item for %d", v->index);
 

	
 
		SetDParam(0, v->unitnumber);
 
		AddValidatedNewsItem(
 
		AddNewsItem(
 
			message,
 
			NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, 0),
 
			v->index,
 
			OC_VALIDATE,	//next time, just validate the orders
 
			CheckOrders);
 
			0
 
		);
 
	}
 

	
 
	return true;
 
}
 

	
 
/**
roadveh_cmd.c
Show inline comments
 
@@ -1595,7 +1595,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
 
	AgeVehicle(v);
 
	CheckIfRoadVehNeedsService(v);
 

	
 
	CheckOrders(v->index, OC_INIT);
 
	CheckOrders(v);
 

	
 
	//Current slot has expired
 
	if (v->u.road.slot_age-- == 0 && v->u.road.slot != NULL) {
ship_cmd.c
Show inline comments
 
@@ -133,7 +133,7 @@ void OnNewDay_Ship(Vehicle *v)
 
	AgeVehicle(v);
 
	CheckIfShipNeedsService(v);
 

	
 
	CheckOrders(v->index, OC_INIT);
 
	CheckOrders(v);
 

	
 
	if (v->vehstatus & VS_STOPPED) return;
 

	
train_cmd.c
Show inline comments
 
@@ -3272,12 +3272,6 @@ void Train_Tick(Vehicle *v)
 

	
 
static const byte _depot_track_ind[4] = {0,1,0,1};
 

	
 
// Validation for the news item "Train is waiting in depot"
 
static bool ValidateTrainInDepot( uint data_a, uint data_b )
 
{
 
	Vehicle *v = GetVehicle(data_a);
 
	return  (v->u.rail.track == 0x80 && (v->vehstatus | VS_STOPPED));
 
}
 

	
 
void TrainEnterDepot(Vehicle *v, TileIndex tile)
 
{
 
@@ -3310,12 +3304,12 @@ void TrainEnterDepot(Vehicle *v, TileInd
 
			v->vehstatus |= VS_STOPPED;
 
			if (v->owner == _local_player) {
 
				SetDParam(0, v->unitnumber);
 
				AddValidatedNewsItem(
 
				AddNewsItem(
 
					STR_8814_TRAIN_IS_WAITING_IN_DEPOT,
 
					NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
 
					v->index,
 
					0,
 
					ValidateTrainInDepot);
 
					0
 
				);
 
			}
 
		}
 
	}
 
@@ -3403,7 +3397,7 @@ void OnNewDay_Train(Vehicle *v)
 
				0);
 
		}
 

	
 
		CheckOrders(v->index, OC_INIT);
 
		CheckOrders(v);
 

	
 
		/* update destination */
 
		if (v->current_order.type == OT_GOTO_STATION &&
0 comments (0 inline, 0 general)