src/fsmport.h
author richk
Tue, 17 Jun 2008 13:41:57 +0000
branchNewGRF_ports
changeset 10995 311b38c7f9a7
parent 6883 8a09982aebc5
permissions -rw-r--r--
(svn r13549) [NewGRF_ports] -Change: Make recolouring of groundtile (0x0f80) specific to NewGRF_ports only.
Also base groundsprite on airport_tile of station. This prevents mixed colour groundtiles in an airport.
/* $Id$ */

/** @file fsmport.h Various (base) declarations for FSM built ports */

#ifndef FSMPORT_H
#define FSMPORT_H

#include "direction_type.h"
#include "map_type.h"
#include "fsmblockmap.h"

struct FSMPortMovingData {
	int16 x;
	int16 y;
	int16 z;
	uint16 flag;
	Direction direction;
	byte state;
	byte block;  //block number for this specific location

	FSMPortMovingData() {}

	FSMPortMovingData(const FSMPortMovingData *md) {
		this->x = md->x;
		this->y = md->y;
		this->z = md->z;
		this->direction = md->direction;
		this->flag      = md->flag;
		this->state     = md->state;
		this->block     = md->block;
	}
};

struct FSMCommand {
	FSMCommand *next;         ///< Possible extra movement choices from this position
	FSMblockmap reserveblock; ///< The blocks to reserve at this state
	FSMblockmap releaseblock; ///< The blocks to release at this state
	byte position;            ///< The position that a vehicle is at
	byte next_position;       ///< Next position from this position
	byte heading;             ///< Heading (current orders), guiding a vehicle to its target on a port
	byte special;             ///< Used as extra data for special orders 7B, 7C, 7D, 7E
};

struct FSMDepots {
	TileIndexDiffC tile_pos;  ///< position of depot on port
	byte FSMposition;         ///< position of main depot location in state machine
							  ///< (used to identify location from which vehicles emerge in multi tile depots)
};

/** Forward declaration, as we need a circular dependancy */
struct FSMportsSpec;

struct FSMPortClass {
public:
	FSMPortClass(FSMportsSpec *spec_) : moving_data(NULL), layout(NULL), num_positions(0), depots(NULL),
			num_depots(0), size_x(0), size_y(0), catchment(0), spec(spec_) {}

	~FSMPortClass();

	const FSMPortMovingData *MovingData(byte position) const
	{
		assert(position < this->num_positions);
		return &this->moving_data[position];
	}

	FSMPortMovingData *moving_data;
	FSMCommand *layout;
	byte num_positions;                   // number of positions the airport consists of

	FSMDepots *depots;                    // gives the position of the depots on the airports
	byte num_depots;                      // number of depots this airport has

	byte size_x;
	byte size_y;
	byte catchment;

	FSMportsSpec *spec;
};

#endif /* FSMPORT_H */