summaryrefslogtreecommitdiff
path: root/order_cmd.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2005-01-06 22:31:58 +0000
committertruelight <truelight@openttd.org>2005-01-06 22:31:58 +0000
commit63e97754fbf907cfefd277087bfbac5e0d4434e8 (patch)
tree254702245ba43d006f4823111d0c2c592fb701ca /order_cmd.c
parenta4111363c0def2ccec66ef28b5e8169e8a2df2f0 (diff)
downloadopenttd-63e97754fbf907cfefd277087bfbac5e0d4434e8.tar.xz
(svn r1407) -Codechange: changed a lot around _stations, _vehicles, _towns and _industries
(in prepare of dynamic arrays): - DEREF_XXX is changed into GetXXX - All direct call are directed via GetXXX - struct Industry has now an index-field - ENUM'd some stuff - Replaced home built loops with FOR_ALL_XXX - Added _stations_size, _vehicles_size, ... which gives the length of the array (which will be dynamic in the near future) - Changed lengtof(XXX) to _XXX_size (e.g. _stations_size) - Removed all endof(XXX) (because mostly it was part of a FOR_ALL_XXX) - Made the sort-functions of all 4 dynamic - Made all 4 Initialize functions more of the same - Some minor tab-fixing and stuff (tnx to Tron for proof-reading my 100kb patch ;)) Note for all: please do NOT directly call _stations, _vehicles, _towns and _industries, but use the right wrapper to access them. Thank you. Ps: please also do not use 'v++', where v is of type Vehicle *.
Diffstat (limited to 'order_cmd.c')
-rw-r--r--order_cmd.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/order_cmd.c b/order_cmd.c
index f3f1e7b4e..d7a7abb3c 100644
--- a/order_cmd.c
+++ b/order_cmd.c
@@ -13,7 +13,7 @@
*/
int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle *v = &_vehicles[p1 & 0xFFFF];
+ Vehicle *v = GetVehicle(p1 & 0xFFFF);
int sel = p1 >> 16;
Order new_order = UnpackOrder(p2);
@@ -26,8 +26,8 @@ int32 CmdInsertOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
sel != 0 && v->schedule_ptr[sel - 1].type == OT_GOTO_STATION) {
int dist = GetTileDist(
- DEREF_STATION(v->schedule_ptr[sel - 1].station)->xy,
- DEREF_STATION(new_order.station)->xy
+ GetStation(v->schedule_ptr[sel - 1].station)->xy,
+ GetStation(new_order.station)->xy
);
if (dist >= 130)
return_cmd_error(STR_0210_TOO_FAR_FROM_PREVIOUS_DESTINATIO);
@@ -94,7 +94,7 @@ static int32 DecloneOrder(Vehicle *dst, uint32 flags)
*/
int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle *v = &_vehicles[p1], *u;
+ Vehicle *v = GetVehicle(p1), *u;
uint sel = (uint)p2;
_error_message = STR_EMPTY;
@@ -141,7 +141,7 @@ int32 CmdDeleteOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
if (flags & DC_EXEC) {
- Vehicle *v = &_vehicles[p1];
+ Vehicle *v = GetVehicle(p1);
{
byte b = v->cur_order_index + 1;
@@ -168,7 +168,7 @@ int32 CmdSkipOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
*/
int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle *v = &_vehicles[p1];
+ Vehicle *v = GetVehicle(p1);
byte sel = (byte)p2;
Order *sched;
@@ -219,7 +219,7 @@ int32 CmdModifyOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
{
- Vehicle *dst = &_vehicles[p1 & 0xFFFF];
+ Vehicle *dst = GetVehicle(p1 & 0xFFFF);
if (!(dst->type && dst->owner == _current_player))
return CMD_ERROR;
@@ -228,7 +228,7 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// share vehicle orders?
case 0: {
- Vehicle *src = &_vehicles[p1 >> 16];
+ Vehicle *src = GetVehicle(p1 >> 16);
// sanity checks
if (!(src->owner == _current_player && dst->type == src->type && dst != src))
@@ -255,7 +255,7 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// copy vehicle orders?
case 1: {
- Vehicle *src = &_vehicles[p1 >> 16];
+ Vehicle *src = GetVehicle(p1 >> 16);
int delta;
// sanity checks
@@ -269,7 +269,7 @@ int32 CmdCloneOrder(int x, int y, uint32 flags, uint32 p1, uint32 p2)
for (i = src->schedule_ptr; i->type != OT_NOTHING; ++i) {
if (i->type == OT_GOTO_STATION) {
- const Station *st = DEREF_STATION(i->station);
+ const Station *st = GetStation(i->station);
required_dst = (dst->cargo_type == CT_PASSENGERS) ? st->bus_tile : st->lorry_tile;
if ( !required_dst )
return CMD_ERROR;
@@ -366,7 +366,7 @@ 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];
+ Vehicle *v = GetVehicle(p1);
v->service_interval = (uint16)(p2>>16);
v->cur_order_index = (byte)(p2&0xFFFF);
}
@@ -415,7 +415,7 @@ int CheckOrders(Vehicle *v)
//I uncommented this in order not to get two error messages
//when two identical entries are in the list
n_st++;
- st = DEREF_STATION(order.station);
+ st = GetStation(order.station);
required_tile = GetStationTileForVehicle(v,st);
if (!required_tile) problem_type = 3;
}