src/fsmport.h
author rubidium
Tue, 22 Jan 2008 21:00:30 +0000
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6863 13335bf10adb
child 6878 7d1ff2f621c7
permissions -rw-r--r--
(svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     1
/* $Id$ */
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     2
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     3
/** @file fsmport.h Various (base) declarations for FSM built ports */
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     4
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     5
#ifndef FSMPORT_H
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     6
#define FSMPORT_H
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
     7
6872
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6863
diff changeset
     8
#include "direction_type.h"
1c4a4a609f85 (svn r11950) [NewGRF_ports] -Sync with trunk r11566:11949.
rubidium
parents: 6863
diff changeset
     9
#include "map_type.h"
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    10
#include "fsmblockmap.h"
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    11
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    12
struct FSMPortMovingData {
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    13
	int16 x;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    14
	int16 y;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    15
	int16 z;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    16
	uint16 flag;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    17
	Direction direction;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    18
	byte state;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    19
	byte block;  //block number for this specific location
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    20
};
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    21
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    22
struct FSMCommand {
6863
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    23
	FSMCommand *next;         ///< Possible extra movement choices from this position
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    24
	FSMblockmap reserveblock; ///< The blocks to reserve at this state
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    25
	FSMblockmap releaseblock; ///< The blocks to release at this state
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    26
	byte position;            ///< The position that a vehicle is at
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    27
	byte next_position;       ///< Next position from this position
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    28
	byte heading;             ///< Heading (current orders), guiding a vehicle to its target on a port
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    29
	byte special;             ///< Used as extra data for special orders 7B, 7C, 7D, 7E
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    30
};
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    31
6863
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    32
struct FSMDepots {
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    33
	TileIndexDiffC tile_pos;  ///< position of depot on port
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    34
	byte FSMposition;         ///< position of main depot location in state machine
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    35
							  ///< (used to identify location from which vehicles emerge in multi tile depots)
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    36
};
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    37
6854
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    38
/** Forward declaration, as we need a circular dependancy */
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    39
struct FSMportsSpec;
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    40
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    41
struct FSMPortClass {
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    42
public:
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    43
	FSMPortClass(FSMportsSpec *spec_) : moving_data(NULL), layout(NULL), num_positions(0), depots(NULL),
6857
5012c47e576b (svn r10960) [NewGRF_ports] -Change: Remove delta_z from the FSMport class. Will need to replace code at places marked with TODO.
richk
parents: 6856
diff changeset
    44
			num_depots(0), size_x(0), size_y(0), catchment(0), spec(spec_) {}
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    45
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    46
	~FSMPortClass();
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    47
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    48
	const FSMPortMovingData *MovingData(byte position) const
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    49
	{
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    50
		assert(position < this->num_positions);
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    51
		return &this->moving_data[position];
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    52
	}
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    53
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    54
	FSMPortMovingData *moving_data;
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    55
	FSMCommand *layout;
6863
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    56
	byte num_positions;                   // number of positions the airport consists of
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    57
6863
13335bf10adb (svn r10977) [NewGRF_ports] -Feature: Added multi-tile depot support.
richk
parents: 6857
diff changeset
    58
	FSMDepots *depots;                    // gives the position of the depots on the airports
6856
0e8e4ebf23ff (svn r10959) [NewGRF_ports] -Change: Rename FSMState to FSMCommand. nof_elements changed to num_positions. nof_depots changed to num_depots.
richk
parents: 6854
diff changeset
    59
	byte num_depots;                      // number of depots this airport has
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    60
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    61
	byte size_x;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    62
	byte size_y;
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    63
	byte catchment;
6854
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    64
92ca286e9466 (svn r10957) [NewGRF_ports] -Codechange: reduce the dependency on AT_XXX enums and airport_type.
rubidium
parents: 6853
diff changeset
    65
	FSMportsSpec *spec;
6853
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    66
};
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    67
b3b8bb6c0a48 (svn r10956) [NewGRF_ports] -Codechange: start refactoring the airport specific code to be more generic so it can be used for non-aircraft ports too.
rubidium
parents:
diff changeset
    68
#endif /* FSMPORT_H */