summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpeter1138 <peter1138@openttd.org>2006-04-11 13:00:06 +0000
committerpeter1138 <peter1138@openttd.org>2006-04-11 13:00:06 +0000
commit96e794be2d2dadfeb98244daaaea993c92a46eb5 (patch)
tree23b61f781c681567c927de43017d5085cbb9d230
parent64a237b192161878e9bab2f3f4da62ab0c8d81a3 (diff)
downloadopenttd-96e794be2d2dadfeb98244daaaea993c92a46eb5.tar.xz
(svn r4356) - NewGRF: Load more newstation properties.
-rw-r--r--newgrf.c113
-rw-r--r--newgrf_callbacks.h8
-rw-r--r--newgrf_station.h19
3 files changed, 71 insertions, 69 deletions
diff --git a/newgrf.c b/newgrf.c
index 7ef56b662..6f9b7ec2b 100644
--- a/newgrf.c
+++ b/newgrf.c
@@ -758,9 +758,10 @@ static bool AircraftVehicleChangeInfo(uint engine, int numinfo, int prop, byte *
static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int len)
{
+ StationSpec *stat;
byte *buf = *bufp;
int i;
- int ret = 0;
+ bool ret = false;
/* Allocate station specs if necessary */
if (_cur_grffile->num_stations < stid + numinfo) {
@@ -773,25 +774,24 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int
}
}
+ stat = &_cur_grffile->stations[stid];
+
switch (prop) {
- case 0x08:
- { /* Class ID */
+ case 0x08: /* Class ID */
FOR_EACH_OBJECT {
- StationSpec *stat = &_cur_grffile->stations[stid + i];
uint32 classid;
- /* classid, for a change, is always little-endian */
+ /* classid, for a change, is big-endian */
classid = *(buf++) << 24;
classid |= *(buf++) << 16;
classid |= *(buf++) << 8;
classid |= *(buf++);
- stat->sclass = AllocateStationClass(classid);
+ stat[i].sclass = AllocateStationClass(classid);
}
break;
- }
- case 0x09:
- { /* Define sprite layout */
+
+ case 0x09: /* Define sprite layout */
FOR_EACH_OBJECT {
StationSpec *stat = &_cur_grffile->stations[stid + i];
int t;
@@ -838,9 +838,8 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int
}
}
break;
- }
- case 0x0a:
- { /* Copy sprite layout */
+
+ case 0x0A: /* Copy sprite layout */
FOR_EACH_OBJECT {
StationSpec *stat = &_cur_grffile->stations[stid + i];
byte srcid = grf_load_byte(&buf);
@@ -876,36 +875,20 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int
}
}
break;
- }
- case 0x0b:
- { /* Callback */
- /* TODO */
- FOR_EACH_OBJECT {
- grf_load_byte(&buf);
- }
- ret = 1;
+
+ case 0x0B: /* Callback mask */
+ FOR_EACH_OBJECT stat[i].callbackmask = grf_load_byte(&buf);
break;
- }
- case 0x0C:
- { /* Platforms number */
- FOR_EACH_OBJECT {
- StationSpec *stat = &_cur_grffile->stations[stid + i];
- stat->allowed_platforms = ~grf_load_byte(&buf);
- }
+ case 0x0C: /* Disallowed number of platforms */
+ FOR_EACH_OBJECT stat[i].disallowed_platforms = grf_load_byte(&buf);
break;
- }
- case 0x0D:
- { /* Platforms length */
- FOR_EACH_OBJECT {
- StationSpec *stat = &_cur_grffile->stations[stid + i];
- stat->allowed_lengths = ~grf_load_byte(&buf);
- }
+ case 0x0D: /* Disallowed platform lengths */
+ FOR_EACH_OBJECT stat[i].disallowed_lengths = grf_load_byte(&buf);
break;
- }
- case 0x0e:
- { /* Define custom layout */
+
+ case 0x0E: /* Define custom layout */
FOR_EACH_OBJECT {
StationSpec *stat = &_cur_grffile->stations[stid + i];
@@ -957,45 +940,41 @@ static bool StationChangeInfo(uint stid, int numinfo, int prop, byte **bufp, int
}
}
break;
- }
- case 0x0f:
- { /* Copy custom layout */
+
+ case 0x0F: /* Copy custom layout */
/* TODO */
FOR_EACH_OBJECT {
grf_load_byte(&buf);
}
- ret = 1;
+ ret = true;
break;
- }
- case 0x10:
- { /* Little/lots cargo threshold */
- /* TODO */
- FOR_EACH_OBJECT {
- grf_load_word(&buf);
- }
- ret = 1;
+
+ case 0x10: /* Little/lots cargo threshold */
+ FOR_EACH_OBJECT stat[i].cargo_threshold = grf_load_word(&buf);
break;
- }
- case 0x11:
- { /* Pylon placement */
- /* TODO; makes sense only for electrified tracks */
- FOR_EACH_OBJECT {
- grf_load_word(&buf);
- }
- ret = 1;
+
+ case 0x11: /* Pylon placement */
+ FOR_EACH_OBJECT stat[i].pylons = grf_load_byte(&buf);
break;
- }
- case 0x12:
- { /* Cargo types for random triggers */
- /* TODO */
- FOR_EACH_OBJECT {
- grf_load_dword(&buf);
- }
- ret = 1;
+
+ case 0x12: /* Cargo types for random triggers */
+ FOR_EACH_OBJECT stat[i].cargo_triggers = grf_load_dword(&buf);
break;
- }
+
+ case 0x13: /* General flags */
+ FOR_EACH_OBJECT stat[i].flags = grf_load_byte(&buf);
+ break;
+
+ case 0x14: /* Overhead wire placement */
+ FOR_EACH_OBJECT stat[i].wires = grf_load_byte(&buf);
+ break;
+
+ case 0x15: /* Blocked tiles */
+ FOR_EACH_OBJECT stat[i].blocked = grf_load_byte(&buf);
+ break;
+
default:
- ret = 1;
+ ret = true;
break;
}
diff --git a/newgrf_callbacks.h b/newgrf_callbacks.h
index 3439d51cf..228b46af2 100644
--- a/newgrf_callbacks.h
+++ b/newgrf_callbacks.h
@@ -42,6 +42,14 @@ enum VehicleCallbackMask {
};
/**
+ * Callback masks for stations.
+ */
+enum StationCallbackMask {
+ CBM_STATION_AVAIL = 0, ///< Availability of station in construction window
+ CBM_CUSTOM_LAYOUT = 1, ///< Use callback to select a tile layout to use
+};
+
+/**
* Result of a failed callback.
*/
enum {
diff --git a/newgrf_station.h b/newgrf_station.h
index 12515c5af..2463d2a26 100644
--- a/newgrf_station.h
+++ b/newgrf_station.h
@@ -27,12 +27,12 @@ typedef struct stationspec {
* Bitmask of number of platforms available for the station.
* 0..6 correpsond to 1..7, while bit 7 corresponds to >7 platforms.
*/
- byte allowed_platforms;
+ byte disallowed_platforms;
/**
* Bitmask of platform lengths available for the station.
* 0..6 correpsond to 1..7, while bit 7 corresponds to >7 tiles long.
*/
- byte allowed_lengths;
+ byte disallowed_lengths;
/** Number of tile layouts.
* A minimum of 8 is required is required for stations.
@@ -44,6 +44,21 @@ typedef struct stationspec {
int tiles;
DrawTileSprites *renderdata; ///< Array of tile layouts.
+ /** Cargo threshold for choosing between little and lots of cargo
+ * @note little/lots are equivalent to the moving/loading states for vehicles
+ */
+ uint16 cargo_threshold;
+
+ uint32 cargo_triggers; ///< Bitmask of cargo types which cause trigger re-randomizing
+
+ byte callbackmask; ///< Bitmask of callbacks to use, @see newgrf_callbacks.h
+
+ byte flags; ///< Bitmask of flags, bit 0: use different sprite set; bit 1: divide cargo about by station size
+
+ byte pylons; ///< Bitmask of base tiles (0 - 7) which should contain elrail pylons
+ byte wires; ///< Bitmask of base tiles (0 - 7) which should contain elrail wires
+ byte blocked; ///< Bitmask of base tiles (0 - 7) which are blocked to trains
+
byte lengths;
byte *platforms;
StationLayout **layouts;