(svn r3758) Remove the news validation callback. It is superseded by r3757.
authortron
Sat, 04 Mar 2006 11:15:44 +0000
changeset 3140 69cb681c6d86
parent 3139 4c950c7ec5c9
child 3141 e840fc2a0f53
(svn r3758) Remove the news validation callback. It is superseded by r3757.
aircraft_cmd.c
news.h
news_gui.c
order.h
order_cmd.c
roadveh_cmd.c
ship_cmd.c
train_cmd.c
--- a/aircraft_cmd.c	Sat Mar 04 11:01:35 2006 +0000
+++ b/aircraft_cmd.c	Sat Mar 04 11:15:44 2006 +0000
@@ -562,7 +562,7 @@
 
 	if ((++v->day_counter & 7) == 0) DecreaseVehicleValue(v);
 
-	CheckOrders(v->index, OC_INIT);
+	CheckOrders(v);
 
 	CheckVehicleBreakdown(v);
 	AgeVehicle(v);
@@ -1218,12 +1218,6 @@
 	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 @@
 
 			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
+				);
 			}
 		}
 	}
--- a/news.h	Sat Mar 04 11:01:35 2006 +0000
+++ b/news.h	Sat Mar 04 11:15:44 2006 +0000
@@ -16,11 +16,6 @@
 	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 @@
 
 #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);
--- a/news_gui.c	Sat Mar 04 11:01:35 2006 +0000
+++ b/news_gui.c	Sat Mar 04 11:15:44 2006 +0000
@@ -275,13 +275,6 @@
 	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 @@
 		// 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);
--- a/order.h	Sat Mar 04 11:01:35 2006 +0000
+++ b/order.h	Sat Mar 04 11:15:44 2006 +0000
@@ -70,11 +70,6 @@
 	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 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);
--- a/order_cmd.c	Sat Mar 04 11:01:35 2006 +0000
+++ b/order_cmd.c	Sat Mar 04 11:15:44 2006 +0000
@@ -859,22 +859,20 @@
  * 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 @@
 		/* 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 @@
 		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;
 }
 
 /**
--- a/roadveh_cmd.c	Sat Mar 04 11:01:35 2006 +0000
+++ b/roadveh_cmd.c	Sat Mar 04 11:15:44 2006 +0000
@@ -1595,7 +1595,7 @@
 	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) {
--- a/ship_cmd.c	Sat Mar 04 11:01:35 2006 +0000
+++ b/ship_cmd.c	Sat Mar 04 11:15:44 2006 +0000
@@ -133,7 +133,7 @@
 	AgeVehicle(v);
 	CheckIfShipNeedsService(v);
 
-	CheckOrders(v->index, OC_INIT);
+	CheckOrders(v);
 
 	if (v->vehstatus & VS_STOPPED) return;
 
--- a/train_cmd.c	Sat Mar 04 11:01:35 2006 +0000
+++ b/train_cmd.c	Sat Mar 04 11:15:44 2006 +0000
@@ -3272,12 +3272,6 @@
 
 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 @@
 			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 @@
 				0);
 		}
 
-		CheckOrders(v->index, OC_INIT);
+		CheckOrders(v);
 
 		/* update destination */
 		if (v->current_order.type == OT_GOTO_STATION &&