2004-08-09 17:04:08 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
#include "ttd.h"
|
2004-11-25 10:47:30 +00:00
|
|
|
#include "table/strings.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
#include "vehicle.h"
|
|
|
|
#include "command.h"
|
|
|
|
#include "station.h"
|
|
|
|
#include "player.h"
|
2004-08-11 10:15:38 +00:00
|
|
|
#include "news.h"
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
|
|
|
Vehicle *v = &_vehicles[p1 & 0xFFFF];
|
|
|
|
int sel = p1 >> 16;
|
2004-12-05 12:43:04 +00:00
|
|
|
Order new_order = UnpackOrder(p2);
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (sel > v->num_orders) return_cmd_error(STR_EMPTY);
|
|
|
|
if (_ptr_to_next_order == endof(_order_array)) return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
|
|
|
|
if (v->num_orders >= 40) return_cmd_error(STR_8832_TOO_MANY_ORDERS);
|
|
|
|
|
|
|
|
// for ships, make sure that the station is not too far away from the previous destination.
|
|
|
|
if (v->type == VEH_Ship && IS_HUMAN_PLAYER(v->owner) &&
|
2004-12-05 12:43:04 +00:00
|
|
|
sel != 0 && v->schedule_ptr[sel - 1].type == OT_GOTO_STATION) {
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
int dist = GetTileDist(
|
|
|
|
DEREF_STATION(v->schedule_ptr[sel - 1].station)->xy,
|
|
|
|
DEREF_STATION(new_order.station)->xy
|
|
|
|
);
|
2004-08-09 17:04:08 +00:00
|
|
|
if (dist >= 130)
|
|
|
|
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
2004-12-05 12:43:04 +00:00
|
|
|
Order *s1;
|
|
|
|
Order *s2;
|
2004-08-09 17:04:08 +00:00
|
|
|
Vehicle *u;
|
|
|
|
|
|
|
|
s1 = &v->schedule_ptr[sel];
|
|
|
|
s2 = _ptr_to_next_order++;
|
|
|
|
do s2[1] = s2[0]; while (--s2 >= s1);
|
2004-12-05 12:43:04 +00:00
|
|
|
*s1 = new_order;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
s1 = v->schedule_ptr;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
FOR_ALL_VEHICLES(u) {
|
|
|
|
if (u->type != 0 && u->schedule_ptr != NULL) {
|
|
|
|
if (s1 < u->schedule_ptr) {
|
|
|
|
u->schedule_ptr++;
|
|
|
|
} else if (s1 == u->schedule_ptr) { // handle shared orders
|
|
|
|
u->num_orders++;
|
|
|
|
|
|
|
|
if ((byte)sel <= u->cur_order_index) {
|
|
|
|
sel++;
|
|
|
|
if ((byte)sel < u->num_orders)
|
|
|
|
u->cur_order_index = sel;
|
|
|
|
}
|
|
|
|
InvalidateWindow(WC_VEHICLE_VIEW, u->index);
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, u->index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-10 18:16:08 +00:00
|
|
|
|
|
|
|
RebuildVehicleLists();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int32 DecloneOrder(Vehicle *dst, uint32 flags)
|
|
|
|
{
|
|
|
|
if (_ptr_to_next_order == endof(_order_array))
|
|
|
|
return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
DeleteVehicleSchedule(dst);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
dst->num_orders = 0;
|
2004-12-05 12:43:04 +00:00
|
|
|
_ptr_to_next_order->type = OT_NOTHING;
|
|
|
|
_ptr_to_next_order->flags = 0;
|
|
|
|
dst->schedule_ptr = _ptr_to_next_order++;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, dst->index);
|
2004-12-10 18:16:08 +00:00
|
|
|
|
|
|
|
RebuildVehicleLists();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* p1 = vehicle
|
|
|
|
* p2 = sel
|
|
|
|
*/
|
|
|
|
int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
|
{
|
|
|
|
Vehicle *v = &_vehicles[p1], *u;
|
|
|
|
uint sel = (uint)p2;
|
|
|
|
|
|
|
|
_error_message = STR_EMPTY;
|
|
|
|
if (sel >= v->num_orders)
|
|
|
|
return DecloneOrder(v, flags);
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
2004-12-05 12:43:04 +00:00
|
|
|
Order *s1 = &v->schedule_ptr[sel];
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// copy all orders to get rid of the hole
|
|
|
|
do s1[0] = s1[1]; while (++s1 != _ptr_to_next_order);
|
|
|
|
_ptr_to_next_order--;
|
|
|
|
|
|
|
|
s1 = v->schedule_ptr;
|
|
|
|
|
|
|
|
FOR_ALL_VEHICLES(u) {
|
|
|
|
if (u->type != 0 && u->schedule_ptr != NULL) {
|
|
|
|
if (s1 < u->schedule_ptr) {
|
|
|
|
u->schedule_ptr--;
|
|
|
|
} else if (s1 == u->schedule_ptr) {// handle shared orders
|
|
|
|
u->num_orders--;
|
|
|
|
if ((byte)sel < u->cur_order_index)
|
|
|
|
u->cur_order_index--;
|
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
if ((byte)sel == u->cur_order_index &&
|
|
|
|
u->current_order.type == OT_LOADING &&
|
|
|
|
u->current_order.flags & OF_NON_STOP) {
|
|
|
|
u->current_order.flags = 0;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_VIEW, u->index);
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, u->index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-12-10 18:16:08 +00:00
|
|
|
|
|
|
|
RebuildVehicleLists();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* p1 = vehicle */
|
|
|
|
int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
|
{
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
Vehicle *v = &_vehicles[p1];
|
|
|
|
|
|
|
|
{
|
|
|
|
byte b = v->cur_order_index + 1;
|
|
|
|
if (b >= v->num_orders) b = 0;
|
|
|
|
v->cur_order_index = b;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if (v->type == VEH_Train)
|
|
|
|
v->u.rail.days_since_order_progr = 0;
|
|
|
|
}
|
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
if (v->current_order.type == OT_LOADING &&
|
|
|
|
v->current_order.flags & OF_NON_STOP) {
|
|
|
|
v->current_order.flags = 0;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, v->index);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* p1 = vehicle
|
|
|
|
* p2&0xFF = sel
|
|
|
|
* p2>>8 = mode
|
|
|
|
*/
|
|
|
|
int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
|
{
|
|
|
|
Vehicle *v = &_vehicles[p1];
|
|
|
|
byte sel = (byte)p2;
|
2004-12-05 12:43:04 +00:00
|
|
|
Order *sched;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (sel >= v->num_orders)
|
|
|
|
return CMD_ERROR;
|
|
|
|
|
|
|
|
sched = &v->schedule_ptr[sel];
|
2004-12-05 12:43:04 +00:00
|
|
|
if (sched->type != OT_GOTO_STATION &&
|
2004-12-19 21:03:16 +00:00
|
|
|
(sched->type != OT_GOTO_DEPOT || (p2 >> 8) == 1) &&
|
|
|
|
(sched->type != OT_GOTO_WAYPOINT || (p2 >> 8) != 2))
|
2004-08-09 17:04:08 +00:00
|
|
|
return CMD_ERROR;
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
2004-12-05 12:43:04 +00:00
|
|
|
switch (p2 >> 8) {
|
2004-08-09 17:04:08 +00:00
|
|
|
case 0: // full load
|
2004-12-05 12:43:04 +00:00
|
|
|
sched->flags ^= OF_FULL_LOAD;
|
|
|
|
if (sched->type != OT_GOTO_DEPOT) sched->flags &= ~OF_UNLOAD;
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
case 1: // unload
|
2004-12-05 12:43:04 +00:00
|
|
|
sched->flags ^= OF_UNLOAD;
|
|
|
|
sched->flags &= ~OF_FULL_LOAD;
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
case 2: // non stop
|
2004-12-05 12:43:04 +00:00
|
|
|
sched->flags ^= OF_NON_STOP;
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
sched = v->schedule_ptr;
|
|
|
|
|
|
|
|
FOR_ALL_VEHICLES(v) {
|
|
|
|
if (v->schedule_ptr == sched)
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, v->index);
|
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clone an order
|
|
|
|
// p1 & 0xFFFF is destination vehicle
|
|
|
|
// p1 >> 16 is source vehicle
|
|
|
|
|
|
|
|
// p2 is
|
|
|
|
// 0 - clone
|
|
|
|
// 1 - copy
|
|
|
|
// 2 - unclone
|
|
|
|
|
|
|
|
|
|
|
|
int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
|
{
|
|
|
|
Vehicle *dst = &_vehicles[p1 & 0xFFFF];
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if (!(dst->type && dst->owner == _current_player))
|
|
|
|
return CMD_ERROR;
|
|
|
|
|
|
|
|
switch(p2) {
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
// share vehicle orders?
|
|
|
|
case 0: {
|
|
|
|
Vehicle *src = &_vehicles[p1 >> 16];
|
|
|
|
|
|
|
|
// sanity checks
|
|
|
|
if (!(src->owner == _current_player && dst->type == src->type && dst != src))
|
|
|
|
return CMD_ERROR;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-12 21:29:26 +00:00
|
|
|
// let's see what happens with road vehicles
|
|
|
|
if (src->type == VEH_Road) {
|
|
|
|
if (src->cargo_type != dst->cargo_type && (src->cargo_type == CT_PASSENGERS || dst->cargo_type == CT_PASSENGERS))
|
|
|
|
return CMD_ERROR;
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
DeleteVehicleSchedule(dst);
|
|
|
|
dst->schedule_ptr = src->schedule_ptr;
|
|
|
|
dst->num_orders = src->num_orders;
|
|
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, src->index);
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, dst->index);
|
2004-12-10 18:16:08 +00:00
|
|
|
|
|
|
|
RebuildVehicleLists();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// copy vehicle orders?
|
|
|
|
case 1: {
|
|
|
|
Vehicle *src = &_vehicles[p1 >> 16];
|
|
|
|
int delta;
|
|
|
|
|
|
|
|
// sanity checks
|
|
|
|
if (!(src->owner == _current_player && dst->type == src->type && dst != src))
|
|
|
|
return CMD_ERROR;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-12 21:29:26 +00:00
|
|
|
// let's see what happens with road vehicles
|
|
|
|
if (src->type == VEH_Road) {
|
2004-12-05 12:43:04 +00:00
|
|
|
const Order *i;
|
2004-08-12 21:29:26 +00:00
|
|
|
TileIndex required_dst;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
for (i = src->schedule_ptr; i->type != OT_NOTHING; ++i) {
|
|
|
|
if (i->type == OT_GOTO_STATION) {
|
|
|
|
const Station *st = DEREF_STATION(i->station);
|
2004-08-12 21:29:26 +00:00
|
|
|
required_dst = (dst->cargo_type == CT_PASSENGERS) ? st->bus_tile : st->lorry_tile;
|
|
|
|
if ( !required_dst )
|
|
|
|
return CMD_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
// make sure there's orders available
|
|
|
|
delta = IsScheduleShared(dst) ? src->num_orders + 1 : src->num_orders - dst->num_orders;
|
|
|
|
if (delta > endof(_order_array) - _ptr_to_next_order)
|
|
|
|
return_cmd_error(STR_8831_NO_MORE_SPACE_FOR_ORDERS);
|
|
|
|
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
DeleteVehicleSchedule(dst);
|
|
|
|
dst->schedule_ptr = _ptr_to_next_order;
|
|
|
|
dst->num_orders = src->num_orders;
|
|
|
|
_ptr_to_next_order += src->num_orders + 1;
|
|
|
|
memcpy(dst->schedule_ptr, src->schedule_ptr, (src->num_orders + 1) * sizeof(uint16));
|
|
|
|
|
|
|
|
InvalidateWindow(WC_VEHICLE_ORDERS, dst->index);
|
2004-12-10 18:16:08 +00:00
|
|
|
|
|
|
|
RebuildVehicleLists();
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// declone vehicle orders?
|
|
|
|
case 2: return DecloneOrder(dst, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BackupVehicleOrders(Vehicle *v, BackuppedOrders *bak)
|
|
|
|
{
|
|
|
|
Vehicle *u = IsScheduleShared(v);
|
|
|
|
|
|
|
|
bak->orderindex = v->cur_order_index;
|
|
|
|
bak->service_interval = v->service_interval;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-09 17:04:08 +00:00
|
|
|
if ((v->string_id & 0xF800) != 0x7800) {
|
|
|
|
bak->name[0] = 0;
|
|
|
|
} else {
|
|
|
|
GetName(v->string_id & 0x7FF, bak->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
// stored shared orders in this special way?
|
2004-12-05 12:43:04 +00:00
|
|
|
if (u != NULL) {
|
|
|
|
bak->clone = u->index;
|
|
|
|
} else {
|
|
|
|
Order *sched = v->schedule_ptr;
|
|
|
|
Order *os = bak->order;
|
|
|
|
|
|
|
|
bak->clone = INVALID_VEHICLE;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
do {
|
|
|
|
*os++ = *sched++;
|
|
|
|
} while (sched->type != OT_NOTHING);
|
2004-12-19 16:26:45 +00:00
|
|
|
/* Make sure the last item is OT_NOTHING */
|
|
|
|
os->type = OT_NOTHING;
|
2004-12-05 12:43:04 +00:00
|
|
|
}
|
2004-08-09 17:04:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RestoreVehicleOrders(Vehicle *v, BackuppedOrders *bak)
|
|
|
|
{
|
2004-12-05 12:43:04 +00:00
|
|
|
int i;
|
2004-08-09 17:04:08 +00:00
|
|
|
|
|
|
|
if (bak->name[0]) {
|
|
|
|
strcpy((char*)_decode_parameters, bak->name);
|
|
|
|
DoCommandP(0, v->index, 0, NULL, CMD_NAME_VEHICLE);
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
DoCommandP(0, v->index, bak->orderindex|(bak->service_interval<<16) , NULL, CMD_RESTORE_ORDER_INDEX);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
if (bak->clone != INVALID_VEHICLE) {
|
|
|
|
DoCommandP(0, v->index | bak->clone << 16, 0, NULL, CMD_CLONE_ORDER);
|
2004-08-09 17:04:08 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-12-04 17:54:56 +00:00
|
|
|
// CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
|
|
|
|
// order number is one more then the current amount of orders, and because
|
|
|
|
// in network the commands are queued before send, the second insert always
|
|
|
|
// fails in test mode. By bypassing the test-mode, that no longer is a problem.
|
2004-12-05 12:43:04 +00:00
|
|
|
for (i = 0; bak->order[i].type != OT_NOTHING; ++i)
|
|
|
|
if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
|
2004-08-09 17:04:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* p1 = vehicle
|
|
|
|
* upper 16 bits p2 = service_interval
|
|
|
|
* lower 16 bits p2 = cur_order_index
|
|
|
|
*/
|
|
|
|
int32 CmdRestoreOrderIndex(int x, int y, uint32 flags, uint32 p1, uint32 p2)
|
|
|
|
{
|
|
|
|
// nonsense to update the windows, since, train rebought will have its window deleted
|
|
|
|
if (flags & DC_EXEC) {
|
|
|
|
Vehicle *v = &_vehicles[p1];
|
|
|
|
v->service_interval = (uint16)(p2>>16);
|
|
|
|
v->cur_order_index = (byte)(p2&0xFFFF);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2004-08-11 10:15:38 +00:00
|
|
|
|
|
|
|
int CheckOrders(Vehicle *v)
|
|
|
|
{
|
2004-08-15 13:21:18 +00:00
|
|
|
if (!_patches.order_review_system) //User doesn't want things to be checked
|
|
|
|
return 0;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-19 09:30:05 +00:00
|
|
|
if(v->vehstatus & VS_CRASHED)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ( (_patches.order_review_system == 1) && (v->vehstatus & VS_STOPPED) )
|
2004-08-15 13:21:18 +00:00
|
|
|
return 0;
|
2004-08-11 10:15:38 +00:00
|
|
|
|
2004-08-15 13:21:18 +00:00
|
|
|
/* only check every 20 days, so that we don't flood the message log */
|
2004-08-11 10:15:38 +00:00
|
|
|
if ( ( ( v->day_counter % 20) == 0 ) && (v->owner == _local_player) ) {
|
2004-12-05 12:43:04 +00:00
|
|
|
Order order;
|
|
|
|
Order old_order;
|
2004-08-15 13:21:18 +00:00
|
|
|
int i, n_st, problem_type = -1;
|
|
|
|
Station *st;
|
|
|
|
int message=0;
|
|
|
|
TileIndex required_tile=-1;
|
|
|
|
|
|
|
|
/* check the order list */
|
|
|
|
order = v->schedule_ptr[0];
|
|
|
|
n_st = 0;
|
|
|
|
|
2004-12-05 12:43:04 +00:00
|
|
|
old_order.type = OT_NOTHING;
|
|
|
|
old_order.flags = 0;
|
|
|
|
for (i = 0; order.type != OT_NOTHING; i++) {
|
2004-08-11 10:15:38 +00:00
|
|
|
order = v->schedule_ptr[i];
|
2004-12-05 12:43:04 +00:00
|
|
|
if (order.type == old_order.type &&
|
|
|
|
order.flags == old_order.flags &&
|
|
|
|
order.station == old_order.station) {
|
2004-08-15 13:21:18 +00:00
|
|
|
problem_type = 2;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 12:43:04 +00:00
|
|
|
if (order.type == OT_DUMMY) {
|
2004-08-15 13:21:18 +00:00
|
|
|
problem_type = 1;
|
|
|
|
break;
|
|
|
|
}
|
2004-12-05 12:43:04 +00:00
|
|
|
if (order.type == OT_GOTO_STATION /*&& (order != old_order) */) {
|
2004-08-11 10:15:38 +00:00
|
|
|
//I uncommented this in order not to get two error messages
|
|
|
|
//when two identical entries are in the list
|
|
|
|
n_st++;
|
2004-12-05 12:43:04 +00:00
|
|
|
st = DEREF_STATION(order.station);
|
2004-08-15 13:21:18 +00:00
|
|
|
required_tile = GetStationTileForVehicle(v,st);
|
2004-09-19 21:44:01 +00:00
|
|
|
if (!required_tile) problem_type = 3;
|
2004-08-11 10:15:38 +00:00
|
|
|
}
|
2004-08-15 13:21:18 +00:00
|
|
|
old_order = order; //store the old order
|
2004-08-11 10:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//Now, check the last and the first order
|
|
|
|
//as the last order is the end of order marker, jump back 2
|
2004-12-05 12:43:04 +00:00
|
|
|
if (i > 2 &&
|
|
|
|
v->schedule_ptr[0].type == v->schedule_ptr[i - 2].type &&
|
|
|
|
v->schedule_ptr[0].flags == v->schedule_ptr[i - 2].flags &&
|
|
|
|
v->schedule_ptr[0].station == v->schedule_ptr[i - 2].station)
|
2004-08-15 13:21:18 +00:00
|
|
|
problem_type = 2;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-11-06 15:13:44 +00:00
|
|
|
if ( (n_st < 2) && (problem_type == -1) ) problem_type = 0;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-12-02 22:53:07 +00:00
|
|
|
SetDParam(0, v->unitnumber);
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-15 13:21:18 +00:00
|
|
|
message = (STR_TRAIN_HAS_TOO_FEW_ORDERS) + (((v->type) - VEH_Train) << 2) + problem_type;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-15 13:21:18 +00:00
|
|
|
if (problem_type < 0) return 0;
|
2004-09-10 19:02:27 +00:00
|
|
|
|
2004-08-15 13:21:18 +00:00
|
|
|
AddNewsItem(
|
|
|
|
message,
|
|
|
|
NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0),
|
|
|
|
v->index,
|
|
|
|
0);
|
2004-08-11 10:15:38 +00:00
|
|
|
}
|
|
|
|
// End of order check
|
|
|
|
|
2004-08-15 13:21:18 +00:00
|
|
|
return 1;
|
2004-08-11 10:15:38 +00:00
|
|
|
}
|