author | richk |
Sat, 04 Aug 2007 21:33:27 +0000 | |
branch | NewGRF_ports |
changeset 6746 | 837a9ca5a2f0 |
parent 6745 | f45a41940079 |
child 6760 | d7a806a9aa44 |
permissions | -rw-r--r-- |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
1 |
/* $Id$ */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
2 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
3 |
/** @file newgrf_station.cpp Functions for dealing with station classes and custom stations. */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
4 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
5 |
#include "stdafx.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
6 |
#include "openttd.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
7 |
#include "variables.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
8 |
#include "functions.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
9 |
#include "landscape.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
10 |
#include "debug.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
11 |
#include "sprite.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
12 |
#include "table/sprites.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
13 |
#include "table/strings.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
14 |
#include "station.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
15 |
#include "station_map.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
16 |
#include "newgrf.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
17 |
#include "newgrf_callbacks.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
18 |
#include "newgrf_commons.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
19 |
#include "newgrf_station.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
20 |
#include "newgrf_spritegroup.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
21 |
#include "date.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
22 |
#include "helpers.hpp" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
23 |
#include "cargotype.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
24 |
#include "town_map.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
25 |
#include "newgrf_town.h" |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
26 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
27 |
static FSMportsClass fsmports_classes[FSMPORTS_CLASS_MAX]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
28 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
29 |
enum { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
30 |
MAX_SPECLIST = 255, |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
31 |
}; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
32 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
33 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
34 |
* Reset station classes to their default state. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
35 |
* This includes initialising the Default and Waypoint classes with an empty |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
36 |
* entry, for standard stations and waypoints. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
37 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
38 |
void ResetFSMportsClasses() |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
39 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
40 |
for (FSMportsClassID i = FSMPORTS_CLASS_BEGIN; i < FSMPORTS_CLASS_MAX; i++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
41 |
fsmports_classes[i].id = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
42 |
fsmports_classes[i].name = STR_EMPTY; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
43 |
fsmports_classes[i].FSMports = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
44 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
45 |
free(fsmports_classes[i].spec); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
46 |
fsmports_classes[i].spec = NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
47 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
48 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
49 |
/* Set up initial data */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
50 |
//fsmports_classes[0].id = 'DFLT'; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
51 |
//fsmports_classes[0].name = STR_STAT_CLASS_DFLT; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
52 |
//fsmports_classes[0].FSMports = 1; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
53 |
//fsmports_classes[0].spec = MallocT<FSMportsSpec*>(1); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
54 |
//fsmports_classes[0].spec[0] = NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
55 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
56 |
//fsmports_classes[1].id = 'WAYP'; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
57 |
//fsmports_classes[1].name = STR_STAT_CLASS_WAYP; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
58 |
//fsmports_classes[1].FSMports = 1; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
59 |
//fsmports_classes[1].spec = MallocT<FSMportsSpec*>(1); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
60 |
//fsmports_classes[1].spec[0] = NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
61 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
62 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
63 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
64 |
* Allocate a station class for the given class id. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
65 |
* @param cls A 32 bit value identifying the class. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
66 |
* @return Index into station_classes of allocated class. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
67 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
68 |
FSMportsClassID AllocateFSMportsClass(uint32 cls) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
69 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
70 |
for (FSMportsClassID i = FSMPORTS_CLASS_BEGIN; i < FSMPORTS_CLASS_MAX; i++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
71 |
if (fsmports_classes[i].id == cls) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
72 |
/* ClassID is already allocated, so reuse it. */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
73 |
return i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
74 |
} else if (fsmports_classes[i].id == 0) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
75 |
/* This class is empty, so allocate it to the ClassID. */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
76 |
fsmports_classes[i].id = cls; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
77 |
return i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
78 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
79 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
80 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
81 |
grfmsg(2, "FSMportsClassAllocate: already allocated %d classes, using default", FSMPORTS_CLASS_MAX); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
82 |
return FSMPORTS_CLASS_DFLT; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
83 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
84 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
85 |
/** Set the name of a custom station class */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
86 |
void SetFSMportsClassName(FSMportsClassID sclass, StringID name) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
87 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
88 |
assert(sclass < FSMPORTS_CLASS_MAX); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
89 |
fsmports_classes[sclass].name = name; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
90 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
91 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
92 |
/** Retrieve the name of a custom station class */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
93 |
StringID GetFSMportsClassName(FSMportsClassID sclass) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
94 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
95 |
assert(sclass < FSMPORTS_CLASS_MAX); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
96 |
return fsmports_classes[sclass].name; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
97 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
98 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
99 |
/** Build a list of station class name StringIDs to use in a dropdown list |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
100 |
* @return Pointer to a (static) array of StringIDs |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
101 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
102 |
StringID *BuildFSMportsClassDropdown() |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
103 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
104 |
/* Allow room for all station classes, plus a terminator entry */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
105 |
static StringID names[FSMPORTS_CLASS_MAX + 1]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
106 |
uint i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
107 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
108 |
/* Add each name */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
109 |
for (i = 0; i < FSMPORTS_CLASS_MAX && fsmports_classes[i].id != 0; i++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
110 |
names[i] = fsmports_classes[i].name; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
111 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
112 |
/* Terminate the list */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
113 |
names[i] = INVALID_STRING_ID; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
114 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
115 |
return names; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
116 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
117 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
118 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
119 |
* Get the number of station classes in use. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
120 |
* @return Number of station classes. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
121 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
122 |
uint GetNumFSMportsClasses() |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
123 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
124 |
uint i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
125 |
for (i = 0; i < FSMPORTS_CLASS_MAX && fsmports_classes[i].id != 0; i++); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
126 |
return i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
127 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
128 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
129 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
130 |
* Return the number of stations for the given station class. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
131 |
* @param sclass Index of the station class. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
132 |
* @return Number of stations in the class. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
133 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
134 |
uint GetNumCustomFSMports(FSMportsClassID sclass) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
135 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
136 |
assert(sclass < FSMPORTS_CLASS_MAX); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
137 |
return fsmports_classes[sclass].FSMports; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
138 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
139 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
140 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
141 |
* Tie a fsmport spec to its class. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
142 |
* @param fsmportspec The station spec. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
143 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
144 |
void SetCustomFSMportsSpec(FSMportsSpec *fsmportspec) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
145 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
146 |
FSMportsClass *fsmports_class; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
147 |
int i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
148 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
149 |
/* If the station has already been allocated, don't reallocate it. */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
150 |
if (fsmportspec->allocated) return; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
151 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
152 |
assert(fsmportspec->sclass < FSMPORTS_CLASS_MAX); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
153 |
fsmports_class = &fsmports_classes[fsmportspec->sclass]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
154 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
155 |
i = fsmports_class->FSMports++; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
156 |
fsmports_class->spec = ReallocT(fsmports_class->spec, fsmports_class->FSMports); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
157 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
158 |
fsmports_class->spec[i] = fsmportspec; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
159 |
fsmportspec->allocated = true; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
160 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
161 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
162 |
/** |
6734
6e4db2fda167
(svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents:
6730
diff
changeset
|
163 |
* Retrieve a fsmspec from a class. |
6e4db2fda167
(svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents:
6730
diff
changeset
|
164 |
* @param sclass Index of the fsm class. |
6e4db2fda167
(svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents:
6730
diff
changeset
|
165 |
* @param fsport The index with the class. |
6e4db2fda167
(svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents:
6730
diff
changeset
|
166 |
* @return The fsmspec. |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
167 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
168 |
const FSMportsSpec *GetCustomFSMportsSpec(FSMportsClassID sclass, uint fsmport) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
169 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
170 |
assert(sclass < FSMPORTS_CLASS_MAX); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
171 |
if (fsmport < fsmports_classes[sclass].FSMports) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
172 |
return fsmports_classes[sclass].spec[fsmport]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
173 |
|
6734
6e4db2fda167
(svn r10666) [NewGRF_ports] -Change: portFSM added to FSMportsSpec.
richk
parents:
6730
diff
changeset
|
174 |
/* If the custom fsmport isn't defined any more, then the GRF file |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
175 |
* probably was not loaded. */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
176 |
return NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
177 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
178 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
179 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
180 |
const FSMportsSpec *GetCustomFSMportsSpecByGrf(uint32 grfid, byte localidx) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
181 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
182 |
uint j; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
183 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
184 |
for (FSMportsClassID i = FSMPORTS_CLASS_BEGIN; i < FSMPORTS_CLASS_MAX; i++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
185 |
for (j = 0; j < fsmports_classes[i].FSMports; j++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
186 |
const FSMportsSpec *fsmportspec = fsmports_classes[i].spec[j]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
187 |
if (fsmportspec == NULL) continue; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
188 |
if (fsmportspec->grffile->grfid == grfid && fsmportspec->localidx == localidx) return fsmportspec; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
189 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
190 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
191 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
192 |
return NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
193 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
194 |
|
6746
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
195 |
TileIndexDiffC RotateFSMPosition(TileIndexDiffC position, byte size_x, byte size_y, byte FSM_orientation) |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
196 |
{ |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
197 |
TileIndexDiffC new_position; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
198 |
|
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
199 |
switch (FSM_orientation) { |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
200 |
case DIR_NE: |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
201 |
new_position = position; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
202 |
break; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
203 |
case DIR_SE: |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
204 |
new_position.x = position.y; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
205 |
new_position.y = size_y - (position.x + 1); |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
206 |
/*note that size_y is used here, because the size_x is the size_x of the set, which is size_y in the 01 orientation */ |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
207 |
break; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
208 |
case DIR_SW: |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
209 |
new_position.x = size_x - (position.x + 1); |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
210 |
new_position.y = size_y - (position.y + 1); |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
211 |
break; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
212 |
case DIR_NW: |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
213 |
new_position.x = size_x - (position.y + 1); |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
214 |
/*note that size_x is used here, because the size_y is the size_y of the set, which is size_x in the 01 orientation */ |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
215 |
new_position.y = position.x; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
216 |
break; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
217 |
default: |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
218 |
new_position = position; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
219 |
break; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
220 |
} |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
221 |
|
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
222 |
return new_position; |
837a9ca5a2f0
(svn r10784) [NewGRF_ports] -Feature: Added rotation of FSMport movement.
richk
parents:
6745
diff
changeset
|
223 |
} |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
224 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
225 |
/* FSMports Resolver Functions */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
226 |
static uint32 FSMportsGetRandomBits(const ResolverObject *object) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
227 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
228 |
const Station *st = object->u.station.st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
229 |
const TileIndex tile = object->u.station.tile; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
230 |
return (st == NULL ? 0 : st->random_bits) | (tile == INVALID_TILE ? 0 : GetStationTileRandomBits(tile) << 16); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
231 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
232 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
233 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
234 |
static uint32 FSMportsGetTriggers(const ResolverObject *object) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
235 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
236 |
const Station *st = object->u.station.st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
237 |
return st == NULL ? 0 : st->waiting_triggers; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
238 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
239 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
240 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
241 |
static void FSMportsSetTriggers(const ResolverObject *object, int triggers) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
242 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
243 |
Station *st = (Station*)object->u.station.st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
244 |
assert(st != NULL); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
245 |
st->waiting_triggers = triggers; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
246 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
247 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
248 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
249 |
* FSMports variable cache |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
250 |
* This caches 'expensive' station variable lookups which iterate over |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
251 |
* several tiles that may be called multiple times per Resolve(). |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
252 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
253 |
static struct { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
254 |
uint32 v40; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
255 |
uint32 v41; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
256 |
uint32 v45; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
257 |
uint32 v46; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
258 |
uint32 v47; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
259 |
uint32 v49; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
260 |
uint8 valid; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
261 |
} _svc; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
262 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
263 |
static uint32 FSMportsGetVariable(const ResolverObject *object, byte variable, byte parameter, bool *available) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
264 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
265 |
const Station *st = object->u.station.st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
266 |
TileIndex tile = object->u.station.tile; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
267 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
268 |
if (object->scope == VSG_SCOPE_PARENT) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
269 |
/* Pass the request on to the town of the station */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
270 |
Town *t; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
271 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
272 |
if (st != NULL) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
273 |
t = st->town; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
274 |
} else if (tile != INVALID_TILE) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
275 |
t = GetTownByTile(tile); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
276 |
} else { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
277 |
*available = false; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
278 |
return UINT_MAX; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
279 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
280 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
281 |
return TownGetVariable(variable, parameter, available, t); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
282 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
283 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
284 |
if (st == NULL) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
285 |
/* Station does not exist, so we're in a purchase list */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
286 |
switch (variable) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
287 |
case 0x40: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
288 |
case 0x41: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
289 |
case 0x46: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
290 |
case 0x47: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
291 |
case 0x49: return 0x2110000; // Platforms, tracks & position |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
292 |
case 0x42: return 0; // Rail type (XXX Get current type from GUI?) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
293 |
case 0x43: return _current_player; // Station owner |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
294 |
case 0x44: return 2; // PBS status |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
295 |
case 0xFA: return clamp(_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); // Build date, clamped to a 16 bit value |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
296 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
297 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
298 |
*available = false; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
299 |
return UINT_MAX; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
300 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
301 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
302 |
switch (variable) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
303 |
/* Calculated station variables */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
304 |
case 0x42: return GetTerrainType(tile) | (GetRailType(tile) << 8); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
305 |
case 0x43: return st->owner; // Station owner |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
306 |
case 0x48: { // Accepted cargo types |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
307 |
CargoID cargo_type; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
308 |
uint32 value = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
309 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
310 |
for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
311 |
if (st->goods[cargo_type].acceptance) SETBIT(value, cargo_type); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
312 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
313 |
return value; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
314 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
315 |
/* Variables which use the parameter */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
316 |
/* Variables 0x60 to 0x65 are handled separately below */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
317 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
318 |
/* General station properties */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
319 |
case 0x82: return 50; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
320 |
case 0x84: return st->string_id; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
321 |
case 0x86: return 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
322 |
case 0x8A: return st->had_vehicle_of_type; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
323 |
case 0xF0: return st->facilities; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
324 |
case 0xF1: return st->airport_type; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
325 |
case 0xF2: return st->truck_stops->status; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
326 |
case 0xF3: return st->bus_stops->status; |
6739
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
6734
diff
changeset
|
327 |
//TODO: need to decide how/what to return |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
6734
diff
changeset
|
328 |
//case 0xF6: return st->airport_flags; |
3f2ca4d0abda
(svn r10738) [NewGRF_ports] -Feature: FSMblockmap class added. Basic FSM import complete. Need to handle multiple blocks on import. Aircraft controller recoded to work with new 128 bit blocks. Still need to write saveload for new blocks.
richk
parents:
6734
diff
changeset
|
329 |
//case 0xF7: return GB(st->airport_flags, 8, 8); |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
330 |
case 0xFA: return clamp(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0, 65535); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
331 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
332 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
333 |
/* Handle cargo variables with parameter, 0x60 to 0x65 */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
334 |
if (variable >= 0x60 && variable <= 0x65) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
335 |
CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
336 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
337 |
if (c == CT_INVALID) return 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
338 |
const GoodsEntry *ge = &st->goods[c]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
339 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
340 |
switch (variable) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
341 |
case 0x60: return min(ge->cargo.Count(), 4095); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
342 |
case 0x61: return ge->days_since_pickup; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
343 |
case 0x62: return ge->rating; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
344 |
case 0x63: return ge->cargo.DaysInTransit(); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
345 |
case 0x64: return ge->last_speed | (ge->last_age << 8); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
346 |
case 0x65: return ge->acceptance << 3; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
347 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
348 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
349 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
350 |
/* Handle cargo variables (deprecated) */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
351 |
if (variable >= 0x8C && variable <= 0xEC) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
352 |
const GoodsEntry *g = &st->goods[GB(variable - 0x8C, 3, 4)]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
353 |
switch (GB(variable - 0x8C, 0, 3)) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
354 |
case 0: return g->cargo.Count(); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
355 |
case 1: return GB(min(g->cargo.Count(), 4095), 0, 4) | (g->acceptance << 7); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
356 |
case 2: return g->days_since_pickup; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
357 |
case 3: return g->rating; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
358 |
case 4: return g->cargo.Source(); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
359 |
case 5: return g->cargo.DaysInTransit(); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
360 |
case 6: return g->last_speed; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
361 |
case 7: return g->last_age; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
362 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
363 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
364 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
365 |
DEBUG(grf, 1, "Unhandled station property 0x%X", variable); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
366 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
367 |
*available = false; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
368 |
return UINT_MAX; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
369 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
370 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
371 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
372 |
static const SpriteGroup *FSMportsResolveReal(const ResolverObject *object, const SpriteGroup *group) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
373 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
374 |
const Station *st = object->u.station.st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
375 |
const FSMportsSpec *fsmportspec = object->u.station.fsmportspec; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
376 |
uint set; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
377 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
378 |
uint cargo = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
379 |
CargoID cargo_type = object->u.station.cargo_type; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
380 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
381 |
if (st == NULL || fsmportspec->sclass == FSMPORTS_CLASS_WAYP) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
382 |
return group->g.real.loading[0]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
383 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
384 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
385 |
switch (cargo_type) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
386 |
case CT_INVALID: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
387 |
case CT_DEFAULT_NA: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
388 |
case CT_PURCHASE: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
389 |
cargo = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
390 |
break; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
391 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
392 |
case CT_DEFAULT: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
393 |
for (cargo_type = 0; cargo_type < NUM_CARGO; cargo_type++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
394 |
cargo += st->goods[cargo_type].cargo.Count(); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
395 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
396 |
break; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
397 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
398 |
default: |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
399 |
cargo = st->goods[cargo_type].cargo.Count(); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
400 |
break; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
401 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
402 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
403 |
if (HASBIT(fsmportspec->flags, 1)) cargo /= (st->trainst_w + st->trainst_h); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
404 |
cargo = min(0xfff, cargo); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
405 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
406 |
if (cargo > fsmportspec->cargo_threshold) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
407 |
if (group->g.real.num_loading > 0) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
408 |
set = ((cargo - fsmportspec->cargo_threshold) * group->g.real.num_loading) / (4096 - fsmportspec->cargo_threshold); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
409 |
return group->g.real.loading[set]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
410 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
411 |
} else { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
412 |
if (group->g.real.num_loaded > 0) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
413 |
set = (cargo * group->g.real.num_loaded) / (fsmportspec->cargo_threshold + 1); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
414 |
return group->g.real.loaded[set]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
415 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
416 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
417 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
418 |
return group->g.real.loading[0]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
419 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
420 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
421 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
422 |
static void NewFSMportsResolver(ResolverObject *res, const FSMportsSpec *fsmportspec, const Station *st, TileIndex tile) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
423 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
424 |
res->GetRandomBits = FSMportsGetRandomBits; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
425 |
res->GetTriggers = FSMportsGetTriggers; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
426 |
res->SetTriggers = FSMportsSetTriggers; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
427 |
res->GetVariable = FSMportsGetVariable; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
428 |
res->ResolveReal = FSMportsResolveReal; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
429 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
430 |
res->u.station.st = st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
431 |
res->u.station.fsmportspec = fsmportspec; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
432 |
res->u.station.tile = tile; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
433 |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6739
diff
changeset
|
434 |
res->callback = CBID_NO_CALLBACK; |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
435 |
res->callback_param1 = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
436 |
res->callback_param2 = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
437 |
res->last_value = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
438 |
res->trigger = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
439 |
res->reseed = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
440 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
441 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
442 |
static const SpriteGroup *ResolveFSMports(ResolverObject *object) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
443 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
444 |
const SpriteGroup *group; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
445 |
CargoID ctype = CT_DEFAULT_NA; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
446 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
447 |
if (object->u.station.st == NULL) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
448 |
/* No station, so we are in a purchase list */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
449 |
ctype = CT_PURCHASE; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
450 |
} else { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
451 |
/* Pick the first cargo that we have waiting */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
452 |
for (CargoID cargo = 0; cargo < NUM_CARGO; cargo++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
453 |
const CargoSpec *cs = GetCargo(cargo); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
454 |
if (cs->IsValid() && object->u.station.fsmportspec->spritegroup[cargo] != NULL && |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
455 |
!object->u.station.st->goods[cargo].cargo.Empty()) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
456 |
ctype = cargo; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
457 |
break; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
458 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
459 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
460 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
461 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
462 |
group = object->u.station.fsmportspec->spritegroup[ctype]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
463 |
if (group == NULL) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
464 |
ctype = CT_DEFAULT; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
465 |
group = object->u.station.fsmportspec->spritegroup[ctype]; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
466 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
467 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
468 |
if (group == NULL) return NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
469 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
470 |
/* Remember the cargo type we've picked */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
471 |
object->u.station.cargo_type = ctype; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
472 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
473 |
/* Invalidate all cached vars */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
474 |
_svc.valid = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
475 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
476 |
return Resolve(group, object); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
477 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
478 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
479 |
SpriteID GetCustomFSMportsRelocation(const FSMportsSpec *fsmportspec, const Station *st, TileIndex tile) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
480 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
481 |
const SpriteGroup *group; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
482 |
ResolverObject object; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
483 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
484 |
NewFSMportsResolver(&object, fsmportspec, st, tile); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
485 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
486 |
group = ResolveFSMports(&object); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
487 |
if (group == NULL || group->type != SGT_RESULT) return 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
488 |
return group->g.result.sprite - 0x42D; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
489 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
490 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
491 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
492 |
SpriteID GetCustomFSMportsGroundRelocation(const FSMportsSpec *fsmportspec, const Station *st, TileIndex tile) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
493 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
494 |
const SpriteGroup *group; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
495 |
ResolverObject object; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
496 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
497 |
NewFSMportsResolver(&object, fsmportspec, st, tile); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
498 |
object.callback_param1 = 1; // Indicate we are resolving the ground sprite |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
499 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
500 |
group = ResolveFSMports(&object); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
501 |
if (group == NULL || group->type != SGT_RESULT) return 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
502 |
return group->g.result.sprite - 0x42D; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
503 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
504 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
505 |
|
6743
cabfaa4a0295
(svn r10766) [NewGRF_ports] -Sync: with trunk r10651-10765
richk
parents:
6739
diff
changeset
|
506 |
uint16 GetFSMportsCallback(CallbackID callback, uint32 param1, uint32 param2, const FSMportsSpec *fsmportspec, const Station *st, TileIndex tile) |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
507 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
508 |
const SpriteGroup *group; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
509 |
ResolverObject object; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
510 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
511 |
NewFSMportsResolver(&object, fsmportspec, st, tile); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
512 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
513 |
object.callback = callback; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
514 |
object.callback_param1 = param1; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
515 |
object.callback_param2 = param2; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
516 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
517 |
group = ResolveFSMports(&object); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
518 |
if (group == NULL || group->type != SGT_CALLBACK) return CALLBACK_FAILED; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
519 |
return group->g.callback.result; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
520 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
521 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
522 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
523 |
/** |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
524 |
* Allocate a FSMportsSpec to a Station. This is called once per build operation. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
525 |
* @param statspec FSMportsSpec to allocate. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
526 |
* @param st Station to allocate it to. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
527 |
* @param exec Whether to actually allocate the spec. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
528 |
* @return Index within the FSMports's spec list, or -1 if the allocation failed. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
529 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
530 |
int AllocateFSMportsSpecToStation(const FSMportsSpec *fsmportspec, Station *st, bool exec) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
531 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
532 |
uint i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
533 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
534 |
if (fsmportspec == NULL) return 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
535 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
536 |
/* Check if this spec has already been allocated */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
537 |
for (i = 1; i < st->num_fsmportsspecs && i < MAX_SPECLIST; i++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
538 |
if (st->fsmportsspeclist[i].spec == fsmportspec) return i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
539 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
540 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
541 |
for (i = 1; i < st->num_fsmportsspecs && i < MAX_SPECLIST; i++) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
542 |
if (st->fsmportsspeclist[i].spec == NULL && st->fsmportsspeclist[i].grfid == 0) break; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
543 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
544 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
545 |
if (i == MAX_SPECLIST) return -1; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
546 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
547 |
if (exec) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
548 |
if (i >= st->num_fsmportsspecs) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
549 |
st->num_fsmportsspecs = i + 1; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
550 |
st->fsmportsspeclist = ReallocT(st->fsmportsspeclist, st->num_fsmportsspecs); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
551 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
552 |
if (st->num_fsmportsspecs == 2) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
553 |
/* Initial allocation */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
554 |
st->fsmportsspeclist[0].spec = NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
555 |
st->fsmportsspeclist[0].grfid = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
556 |
st->fsmportsspeclist[0].localidx = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
557 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
558 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
559 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
560 |
st->fsmportsspeclist[i].spec = fsmportspec; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
561 |
st->fsmportsspeclist[i].grfid = fsmportspec->grffile->grfid; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
562 |
st->fsmportsspeclist[i].localidx = fsmportspec->localidx; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
563 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
564 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
565 |
return i; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
566 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
567 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
568 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
569 |
/** Deallocate a FSMportsSpec from a Station. Called when removing a single station tile. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
570 |
* @param st Station to work with. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
571 |
* @param specindex Index of the custom station within the FSMports's spec list. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
572 |
* @return Indicates whether the FSMportsSpec was deallocated. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
573 |
*/ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
574 |
void DeallocateSpecFromFSMports(Station* st, byte specindex) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
575 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
576 |
/* specindex of 0 (default) is never freeable */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
577 |
if (specindex == 0) return; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
578 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
579 |
/* Check all tiles over the station to check if the specindex is still in use */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
580 |
BEGIN_TILE_LOOP(tile, st->trainst_w, st->trainst_h, st->train_tile) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
581 |
if (IsTileType(tile, MP_STATION) && GetStationIndex(tile) == st->index && GetCustomStationSpecIndex(tile) == specindex) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
582 |
return; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
583 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
584 |
} END_TILE_LOOP(tile, st->trainst_w, st->trainst_h, st->train_tile) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
585 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
586 |
/* This specindex is no longer in use, so deallocate it */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
587 |
st->speclist[specindex].spec = NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
588 |
st->speclist[specindex].grfid = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
589 |
st->speclist[specindex].localidx = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
590 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
591 |
/* If this was the highest spec index, reallocate */ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
592 |
if (specindex == st->num_specs - 1) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
593 |
for (; st->speclist[st->num_specs - 1].grfid == 0 && st->num_specs > 1; st->num_specs--); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
594 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
595 |
if (st->num_specs > 1) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
596 |
st->speclist = ReallocT(st->speclist, st->num_specs); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
597 |
} else { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
598 |
free(st->speclist); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
599 |
st->num_specs = 0; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
600 |
st->speclist = NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
601 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
602 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
603 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
604 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
605 |
/** Draw representation of a station tile for GUI purposes. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
606 |
* @param x Position x of image. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
607 |
* @param y Position y of image. |
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
608 |
* @param tile tile ID from action 1 set |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
609 |
* @param sclass, station Type of station. |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
610 |
* @param station station ID |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
611 |
* @return True if the tile was drawn (allows for fallback to default graphic) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
612 |
*/ |
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
613 |
bool DrawFSMportsTile(int x, int y, byte tile, FSMportsClassID sclass, uint FSMports) |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
614 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
615 |
const FSMportsSpec *fsmportsspec; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
616 |
const DrawTileSprites *sprites; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
617 |
const DrawTileSeqStruct *seq; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
618 |
SpriteID relocation; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
619 |
SpriteID image; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
620 |
SpriteID pal = PLAYER_SPRITE_COLOR(_local_player); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
621 |
|
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
622 |
fsmportsspec = GetCustomFSMportsSpec(sclass, FSMports); |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
623 |
if (fsmportsspec == NULL) return false; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
624 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
625 |
relocation = GetCustomFSMportsRelocation(fsmportsspec, NULL, INVALID_TILE); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
626 |
|
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
627 |
assert(fsmportsspec->renderdata != NULL); |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
628 |
|
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
629 |
sprites = &fsmportsspec->renderdata[tile]; |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
630 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
631 |
image = sprites->ground_sprite; |
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
632 |
image += relocation; |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
633 |
DrawSprite(image, PAL_NONE, x, y); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
634 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
635 |
foreach_draw_tile_seq(seq, sprites->seq) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
636 |
Point pt; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
637 |
image = seq->image; |
6745
f45a41940079
(svn r10783) [NewGRF_ports] -Feature: Added placing FSMport in any of up to 4 different orientations. GUI now has a preview image for each orientation - not interactive, just a screenshot stored.
richk
parents:
6743
diff
changeset
|
638 |
image += relocation; |
6722
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
639 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
640 |
if ((byte)seq->delta_z != 0x80) { |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
641 |
pt = RemapCoords(seq->delta_x, seq->delta_y, seq->delta_z); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
642 |
DrawSprite(image, pal, x + pt.x, y + pt.y); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
643 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
644 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
645 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
646 |
return true; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
647 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
648 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
649 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
650 |
static const FSMportsSpec* GetFSMportsSpec(TileIndex t) |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
651 |
{ |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
652 |
const Station* st; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
653 |
uint specindex; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
654 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
655 |
if (!IsCustomStationSpecIndex(t)) return NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
656 |
|
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
657 |
st = GetStationByTile(t); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
658 |
specindex = GetCustomStationSpecIndex(t); |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
659 |
return specindex < st->num_fsmportsspecs ? st->fsmportsspeclist[specindex].spec : NULL; |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
660 |
} |
72f280229ee1
(svn r10586) [NewGRF_ports] -Feature: Load an airport via a newgrf file. Currently, only graphics support provided.
richk
parents:
diff
changeset
|
661 |