mirror of https://github.com/OpenTTD/OpenTTD
(svn r1554) -Fix: [ 1103187 ] Order Check messages are now validated before
displayed, so that there are no stray error messages any more. -Feature/Fix: Order Checking is only execute for ONE vehicle in an order-share systemrelease/0.4.5
parent
9fadf6cf84
commit
e0471187d0
|
@ -528,7 +528,7 @@ void OnNewDay_Aircraft(Vehicle *v)
|
||||||
if ((++v->day_counter & 7) == 0)
|
if ((++v->day_counter & 7) == 0)
|
||||||
DecreaseVehicleValue(v);
|
DecreaseVehicleValue(v);
|
||||||
|
|
||||||
CheckOrders(v);
|
CheckOrders(v->index, OC_INIT);
|
||||||
|
|
||||||
CheckVehicleBreakdown(v);
|
CheckVehicleBreakdown(v);
|
||||||
AgeVehicle(v);
|
AgeVehicle(v);
|
||||||
|
|
8
order.h
8
order.h
|
@ -33,6 +33,12 @@ enum {
|
||||||
CO_UNSHARE = 2
|
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:
|
/* If you change this, keep in mind that it is saved on 3 places:
|
||||||
- Load_ORDR, all the global orders
|
- Load_ORDR, all the global orders
|
||||||
- Vehicle -> current_order
|
- Vehicle -> current_order
|
||||||
|
@ -112,7 +118,7 @@ void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *order);
|
||||||
void DeleteDestinationFromVehicleOrder(Order dest);
|
void DeleteDestinationFromVehicleOrder(Order dest);
|
||||||
void InvalidateVehicleOrder(const Vehicle *v);
|
void InvalidateVehicleOrder(const Vehicle *v);
|
||||||
bool VehicleHasDepotOrders(const Vehicle *v);
|
bool VehicleHasDepotOrders(const Vehicle *v);
|
||||||
bool CheckOrders(const Vehicle *v);
|
bool CheckOrders(uint data_a, uint data_b);
|
||||||
void DeleteVehicleOrders(Vehicle *v);
|
void DeleteVehicleOrders(Vehicle *v);
|
||||||
bool IsOrderListShared(const Vehicle *v);
|
bool IsOrderListShared(const Vehicle *v);
|
||||||
void AssignOrder(Order *order, Order data);
|
void AssignOrder(Order *order, Order data);
|
||||||
|
|
34
order_cmd.c
34
order_cmd.c
|
@ -629,8 +629,9 @@ int32 CmdRestoreOrderIndex(int x, int y, uint32 flags, uint32 vehicle_id, uint32
|
||||||
* Check the orders of a vehicle, to see if there are invalid orders and stuff
|
* Check the orders of a vehicle, to see if there are invalid orders and stuff
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool CheckOrders(const Vehicle *v)
|
bool CheckOrders(uint data_a, uint data_b)
|
||||||
{
|
{
|
||||||
|
Vehicle *v = GetVehicle(data_a);
|
||||||
/* Does the user wants us to check things? */
|
/* Does the user wants us to check things? */
|
||||||
if (_patches.order_review_system == 0)
|
if (_patches.order_review_system == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -643,6 +644,10 @@ bool CheckOrders(const Vehicle *v)
|
||||||
if ( (_patches.order_review_system == 1) && (v->vehstatus & VS_STOPPED) )
|
if ( (_patches.order_review_system == 1) && (v->vehstatus & VS_STOPPED) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
/* do nothing we we're not the first vehicle in a share-chain */
|
||||||
|
if (v->next_shared != NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
/* Only check every 20 days, so that we don't flood the message log */
|
/* Only check every 20 days, so that we don't flood the message log */
|
||||||
if ( ( ( v->day_counter % 20) == 0 ) && (v->owner == _local_player) ) {
|
if ( ( ( v->day_counter % 20) == 0 ) && (v->owner == _local_player) ) {
|
||||||
int n_st, problem_type = -1;
|
int n_st, problem_type = -1;
|
||||||
|
@ -653,6 +658,12 @@ bool CheckOrders(const Vehicle *v)
|
||||||
/* Check the order list */
|
/* Check the order list */
|
||||||
n_st = 0;
|
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) {
|
FOR_VEHICLE_ORDERS(v, order) {
|
||||||
/* Dummy order? */
|
/* Dummy order? */
|
||||||
if (order->type == OT_DUMMY) {
|
if (order->type == OT_DUMMY) {
|
||||||
|
@ -683,17 +694,32 @@ bool CheckOrders(const Vehicle *v)
|
||||||
problem_type = 0;
|
problem_type = 0;
|
||||||
|
|
||||||
/* We don't have a problem */
|
/* We don't have a problem */
|
||||||
if (problem_type < 0)
|
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;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
message = (STR_TRAIN_HAS_TOO_FEW_ORDERS) + (((v->type) - VEH_Train) << 2) + problem_type;
|
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);*/
|
||||||
|
|
||||||
SetDParam(0, v->unitnumber);
|
SetDParam(0, v->unitnumber);
|
||||||
AddNewsItem(
|
AddValidatedNewsItem(
|
||||||
message,
|
message,
|
||||||
NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, 0),
|
NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_VEHICLE, NT_ADVICE, 0),
|
||||||
v->index,
|
v->index,
|
||||||
0);
|
OC_VALIDATE, //next time, just validate the orders
|
||||||
|
CheckOrders);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1481,7 +1481,7 @@ void OnNewDay_RoadVeh(Vehicle *v)
|
||||||
AgeVehicle(v);
|
AgeVehicle(v);
|
||||||
CheckIfRoadVehNeedsService(v);
|
CheckIfRoadVehNeedsService(v);
|
||||||
|
|
||||||
CheckOrders(v);
|
CheckOrders(v->index, OC_INIT);
|
||||||
|
|
||||||
/* update destination */
|
/* update destination */
|
||||||
if (v->current_order.type == OT_GOTO_STATION) {
|
if (v->current_order.type == OT_GOTO_STATION) {
|
||||||
|
|
|
@ -145,7 +145,7 @@ void OnNewDay_Ship(Vehicle *v)
|
||||||
AgeVehicle(v);
|
AgeVehicle(v);
|
||||||
CheckIfShipNeedsService(v);
|
CheckIfShipNeedsService(v);
|
||||||
|
|
||||||
CheckOrders(v);
|
CheckOrders(v->index, OC_INIT);
|
||||||
|
|
||||||
if (v->vehstatus & VS_STOPPED)
|
if (v->vehstatus & VS_STOPPED)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -2756,7 +2756,7 @@ void OnNewDay_Train(Vehicle *v)
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckOrders(v);
|
CheckOrders(v->index, OC_INIT);
|
||||||
|
|
||||||
/* update destination */
|
/* update destination */
|
||||||
if (v->current_order.type == OT_GOTO_STATION &&
|
if (v->current_order.type == OT_GOTO_STATION &&
|
||||||
|
|
Loading…
Reference in New Issue