mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
-Cleanup: whitespace alignment of a few tables.
This commit is contained in:
parent
a7cfb80c40
commit
63687763e9
|
@ -515,7 +515,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
|
||||||
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
||||||
/* We called with a different DEPOT_SERVICE setting.
|
/* We called with a different DEPOT_SERVICE setting.
|
||||||
* Now we change the setting to apply the new one and let the vehicle head for the same hangar.
|
* Now we change the setting to apply the new one and let the vehicle head for the same hangar.
|
||||||
* Note: the if is (true for requesting service == true for ordered to stop in hangar) */
|
* Note: the if is (true for requesting service == true for ordered to stop in hangar) */
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
||||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||||
|
@ -1915,15 +1915,15 @@ static bool AirportFindFreeTerminal(Vehicle *v, const AirportFTAClass *Airport)
|
||||||
Station *st;
|
Station *st;
|
||||||
|
|
||||||
/* example of more terminalgroups
|
/* example of more terminalgroups
|
||||||
{0,HANGAR,NOTHING_block,1}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER_block,1}, {0,0,N,1},
|
* {0,HANGAR,NOTHING_block,1}, {0,255,TERM_GROUP1_block,0}, {0,255,TERM_GROUP2_ENTER_block,1}, {0,0,N,1},
|
||||||
Heading 255 denotes a group. We see 2 groups here:
|
* Heading 255 denotes a group. We see 2 groups here:
|
||||||
1. group 0 -- TERM_GROUP1_block (check block)
|
* 1. group 0 -- TERM_GROUP1_block (check block)
|
||||||
2. group 1 -- TERM_GROUP2_ENTER_block (check block)
|
* 2. group 1 -- TERM_GROUP2_ENTER_block (check block)
|
||||||
First in line is checked first, group 0. If the block (TERM_GROUP1_block) is free, it
|
* First in line is checked first, group 0. If the block (TERM_GROUP1_block) is free, it
|
||||||
looks at the corresponding terminals of that group. If no free ones are found, other
|
* looks at the corresponding terminals of that group. If no free ones are found, other
|
||||||
possible groups are checked (in this case group 1, since that is after group 0). If that
|
* possible groups are checked (in this case group 1, since that is after group 0). If that
|
||||||
fails, then attempt fails and plane waits
|
* fails, then attempt fails and plane waits
|
||||||
*/
|
*/
|
||||||
if (Airport->terminals[0] > 1) {
|
if (Airport->terminals[0] > 1) {
|
||||||
st = GetStation(v->u.air.targetairport);
|
st = GetStation(v->u.air.targetairport);
|
||||||
temp = Airport->layout[v->u.air.pos].next_in_chain;
|
temp = Airport->layout[v->u.air.pos].next_in_chain;
|
||||||
|
|
2
depot.h
2
depot.h
|
@ -4,7 +4,7 @@
|
||||||
#define DEPOT_H
|
#define DEPOT_H
|
||||||
|
|
||||||
/** @file depot.h Header files for depots (not hangars)
|
/** @file depot.h Header files for depots (not hangars)
|
||||||
* @see depot.c */
|
* @see depot.c */
|
||||||
|
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
|
|
|
@ -246,8 +246,8 @@ void ChangeOwnershipOfPlayerItems(PlayerID old_player, PlayerID new_player)
|
||||||
_current_player = old_player;
|
_current_player = old_player;
|
||||||
|
|
||||||
/* Temporarily increase the player's money, to be sure that
|
/* Temporarily increase the player's money, to be sure that
|
||||||
* removing his/her property doesn't fail because of lack of money.
|
* removing his/her property doesn't fail because of lack of money.
|
||||||
* Not too drastically though, because it could overflow */
|
* Not too drastically though, because it could overflow */
|
||||||
if (new_player == OWNER_SPECTATOR) {
|
if (new_player == OWNER_SPECTATOR) {
|
||||||
GetPlayer(old_player)->money64 = MAX_UVALUE(uint64) >>2; // jackpot ;p
|
GetPlayer(old_player)->money64 = MAX_UVALUE(uint64) >>2; // jackpot ;p
|
||||||
UpdatePlayerMoney32(GetPlayer(old_player));
|
UpdatePlayerMoney32(GetPlayer(old_player));
|
||||||
|
|
132
elrail.c
132
elrail.c
|
@ -1,49 +1,49 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
/** @file elrail.c
|
/** @file elrail.c
|
||||||
This file deals with displaying wires and pylons for electric railways.
|
* This file deals with displaying wires and pylons for electric railways.
|
||||||
<h2>Basics</h2>
|
* <h2>Basics</h2>
|
||||||
|
*
|
||||||
<h3>Tile Types</h3>
|
* <h3>Tile Types</h3>
|
||||||
|
*
|
||||||
We have two different types of tiles in the drawing code:
|
* We have two different types of tiles in the drawing code:
|
||||||
Normal Railway Tiles (NRTs) which can have more than one track on it, and
|
* Normal Railway Tiles (NRTs) which can have more than one track on it, and
|
||||||
Special Railways tiles (SRTs) which have only one track (like crossings, depots
|
* Special Railways tiles (SRTs) which have only one track (like crossings, depots
|
||||||
stations, etc).
|
* stations, etc).
|
||||||
|
*
|
||||||
<h3>Location Categories</h3>
|
* <h3>Location Categories</h3>
|
||||||
|
*
|
||||||
All tiles are categorized into three location groups (TLG):
|
* All tiles are categorized into three location groups (TLG):
|
||||||
Group 0: Tiles with both an even X coordinate and an even Y coordinate
|
* Group 0: Tiles with both an even X coordinate and an even Y coordinate
|
||||||
Group 1: Tiles with an even X and an odd Y coordinate
|
* Group 1: Tiles with an even X and an odd Y coordinate
|
||||||
Group 2: Tiles with an odd X and an even Y coordinate
|
* Group 2: Tiles with an odd X and an even Y coordinate
|
||||||
Group 3: Tiles with both an odd X and Y coordnate.
|
* Group 3: Tiles with both an odd X and Y coordnate.
|
||||||
|
*
|
||||||
<h3>Pylon Points</h3>
|
* <h3>Pylon Points</h3>
|
||||||
<h4>Control Points</h4>
|
* <h4>Control Points</h4>
|
||||||
A Pylon Control Point (PCP) is a position where a wire (or rather two)
|
* A Pylon Control Point (PCP) is a position where a wire (or rather two)
|
||||||
is mounted onto a pylon.
|
* is mounted onto a pylon.
|
||||||
Each NRT does contain 4 PCPs which are bitmapped to a byte
|
* Each NRT does contain 4 PCPs which are bitmapped to a byte
|
||||||
variable and are represented by the DiagDirection enum
|
* variable and are represented by the DiagDirection enum
|
||||||
|
*
|
||||||
Each track ends on two PCPs and thus requires one pylon on each end. However,
|
* Each track ends on two PCPs and thus requires one pylon on each end. However,
|
||||||
there is one exception: Straight-and-level tracks only have one pylon every
|
* there is one exception: Straight-and-level tracks only have one pylon every
|
||||||
other tile.
|
* other tile.
|
||||||
|
*
|
||||||
Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs
|
* Now on each edge there are two PCPs: One from each adjacent tile. Both PCPs
|
||||||
are merged using an OR operation (i. e. if one tile needs a PCP at the postion
|
* are merged using an OR operation (i. e. if one tile needs a PCP at the postion
|
||||||
in question, both tiles get it).
|
* in question, both tiles get it).
|
||||||
|
*
|
||||||
<h4>Position Points</h4>
|
* <h4>Position Points</h4>
|
||||||
A Pylon Position Point (PPP) is a position where a pylon is located on the
|
* A Pylon Position Point (PPP) is a position where a pylon is located on the
|
||||||
ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around
|
* ground. Each PCP owns 8 in (45 degree steps) PPPs that are located around
|
||||||
it. PPPs are represented using the Direction enum. Each track bit has PPPs
|
* it. PPPs are represented using the Direction enum. Each track bit has PPPs
|
||||||
that are impossible (because the pylon would be situated on the track) and
|
* that are impossible (because the pylon would be situated on the track) and
|
||||||
some that are preferred (because the pylon would be rectangular to the track).
|
* some that are preferred (because the pylon would be rectangular to the track).
|
||||||
|
*
|
||||||
<img src="../../elrail_tile.png">
|
* <img src="../../elrail_tile.png">
|
||||||
<img src="../../elrail_track.png">
|
* <img src="../../elrail_track.png">
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
|
@ -68,8 +68,8 @@ static inline TLG GetTLG(TileIndex t)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Finds which Rail Bits are present on a given tile. For bridge tiles,
|
/** Finds which Rail Bits are present on a given tile. For bridge tiles,
|
||||||
* returns track bits under the bridge
|
* returns track bits under the bridge
|
||||||
*/
|
*/
|
||||||
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||||
{
|
{
|
||||||
switch (GetTileType(t)) {
|
switch (GetTileType(t)) {
|
||||||
|
@ -123,9 +123,9 @@ static TrackBits GetRailTrackBitsUniversal(TileIndex t, byte *override)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile.
|
/** Corrects the tileh for certain tile types. Returns an effective tileh for the track on the tile.
|
||||||
* @param tile The tile to analyse
|
* @param tile The tile to analyse
|
||||||
* @param *tileh the tileh
|
* @param *tileh the tileh
|
||||||
*/
|
*/
|
||||||
static void AdjustTileh(TileIndex tile, Slope *tileh)
|
static void AdjustTileh(TileIndex tile, Slope *tileh)
|
||||||
{
|
{
|
||||||
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
||||||
|
@ -150,13 +150,13 @@ static void AdjustTileh(TileIndex tile, Slope *tileh)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Draws wires and, if required, pylons on a given tile
|
/** Draws wires and, if required, pylons on a given tile
|
||||||
* @param ti The Tileinfo to draw the tile for
|
* @param ti The Tileinfo to draw the tile for
|
||||||
*/
|
*/
|
||||||
static void DrawCatenaryRailway(const TileInfo *ti)
|
static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
{
|
{
|
||||||
/* Pylons are placed on a tile edge, so we need to take into account
|
/* Pylons are placed on a tile edge, so we need to take into account
|
||||||
the track configuration of 2 adjacent tiles. trackconfig[0] stores the
|
* the track configuration of 2 adjacent tiles. trackconfig[0] stores the
|
||||||
current tile (home tile) while [1] holds the neighbour */
|
* current tile (home tile) while [1] holds the neighbour */
|
||||||
TrackBits trackconfig[TS_END];
|
TrackBits trackconfig[TS_END];
|
||||||
bool isflat[TS_END];
|
bool isflat[TS_END];
|
||||||
/* Note that ti->tileh has already been adjusted for Foundations */
|
/* Note that ti->tileh has already been adjusted for Foundations */
|
||||||
|
@ -171,11 +171,11 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
Track t;
|
Track t;
|
||||||
|
|
||||||
/* Find which rail bits are present, and select the override points.
|
/* Find which rail bits are present, and select the override points.
|
||||||
We don't draw a pylon:
|
* We don't draw a pylon:
|
||||||
1) INSIDE a tunnel (we wouldn't see it anyway)
|
* 1) INSIDE a tunnel (we wouldn't see it anyway)
|
||||||
2) on the "far" end of a bridge head (the one that connects to bridge middle),
|
* 2) on the "far" end of a bridge head (the one that connects to bridge middle),
|
||||||
because that one is drawn on the bridge. Exception is for length 0 bridges
|
* because that one is drawn on the bridge. Exception is for length 0 bridges
|
||||||
which have no middle tiles */
|
* which have no middle tiles */
|
||||||
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP);
|
trackconfig[TS_HOME] = GetRailTrackBitsUniversal(ti->tile, &OverridePCP);
|
||||||
/* If a track bit is present that is not in the main direction, the track is level */
|
/* If a track bit is present that is not in the main direction, the track is level */
|
||||||
isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT);
|
isflat[TS_HOME] = trackconfig[TS_HOME] & (TRACK_BIT_HORZ | TRACK_BIT_VERT);
|
||||||
|
@ -188,7 +188,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
int k;
|
int k;
|
||||||
|
|
||||||
/* Here's one of the main headaches. GetTileSlope does not correct for possibly
|
/* Here's one of the main headaches. GetTileSlope does not correct for possibly
|
||||||
existing foundataions, so we do have to do that manually later on.*/
|
* existing foundataions, so we do have to do that manually later on.*/
|
||||||
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL);
|
tileh[TS_NEIGHBOUR] = GetTileSlope(neighbour, NULL);
|
||||||
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
|
trackconfig[TS_NEIGHBOUR] = GetRailTrackBitsUniversal(neighbour, NULL);
|
||||||
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0;
|
if (IsTunnelTile(neighbour) && i != GetTunnelDirection(neighbour)) trackconfig[TS_NEIGHBOUR] = 0;
|
||||||
|
@ -198,7 +198,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
PPPallowed[i] = AllowedPPPonPCP[i];
|
PPPallowed[i] = AllowedPPPonPCP[i];
|
||||||
|
|
||||||
/* We cycle through all the existing tracks at a PCP and see what
|
/* We cycle through all the existing tracks at a PCP and see what
|
||||||
PPPs we want to have, or may not have at all */
|
* PPPs we want to have, or may not have at all */
|
||||||
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) {
|
for (k = 0; k < NUM_TRACKS_AT_PCP; k++) {
|
||||||
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
|
/* Next to us, we have a bridge head, don't worry about that one, if it shows away from us */
|
||||||
if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
|
if (TrackSourceTile[i][k] == TS_NEIGHBOUR &&
|
||||||
|
@ -208,10 +208,10 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We check whether the track in question (k) is present in the tile
|
/* We check whether the track in question (k) is present in the tile
|
||||||
(TrackSourceTile) */
|
* (TrackSourceTile) */
|
||||||
if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
|
if (HASBIT(trackconfig[TrackSourceTile[i][k]], TracksAtPCP[i][k])) {
|
||||||
/* track found, if track is in the neighbour tile, adjust the number
|
/* track found, if track is in the neighbour tile, adjust the number
|
||||||
of the PCP for preferred/allowed determination*/
|
* of the PCP for preferred/allowed determination*/
|
||||||
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i);
|
DiagDirection PCPpos = (TrackSourceTile[i][k] == TS_HOME) ? i : ReverseDiagDir(i);
|
||||||
SETBIT(PCPstatus, i); /* This PCP is in use */
|
SETBIT(PCPstatus, i); /* This PCP is in use */
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]);
|
AdjustTileh(neighbour, &tileh[TS_NEIGHBOUR]);
|
||||||
|
|
||||||
/* If we have a straight (and level) track, we want a pylon only every 2 tiles
|
/* If we have a straight (and level) track, we want a pylon only every 2 tiles
|
||||||
Delete the PCP if this is the case. */
|
* Delete the PCP if this is the case. */
|
||||||
/* Level means that the slope is the same, or the track is flat */
|
/* Level means that the slope is the same, or the track is flat */
|
||||||
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) {
|
if (tileh[TS_HOME] == tileh[TS_NEIGHBOUR] || (isflat[TS_HOME] && isflat[TS_NEIGHBOUR])) {
|
||||||
for (k = 0; k < NUM_IGNORE_GROUPS; k++)
|
for (k = 0; k < NUM_IGNORE_GROUPS; k++)
|
||||||
|
@ -252,9 +252,9 @@ static void DrawCatenaryRailway(const TileInfo *ti)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist.
|
/* Now decide where we draw our pylons. First try the preferred PPPs, but they may not exist.
|
||||||
In that case, we try the any of the allowed ones. if they don't exist either, don't draw
|
* In that case, we try the any of the allowed ones. if they don't exist either, don't draw
|
||||||
anything. Note that the preferred PPPs still contain the end-of-line markers.
|
* anything. Note that the preferred PPPs still contain the end-of-line markers.
|
||||||
Remove those (simply by ANDing with allowed, since these markers are never allowed) */
|
* Remove those (simply by ANDing with allowed, since these markers are never allowed) */
|
||||||
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
|
if ((PPPallowed[i] & PPPpreferred[i]) != 0) PPPallowed[i] &= PPPpreferred[i];
|
||||||
|
|
||||||
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
|
if (PPPallowed[i] != 0 && HASBIT(PCPstatus, i) && !HASBIT(OverridePCP, i)) {
|
||||||
|
|
8
engine.c
8
engine.c
|
@ -191,10 +191,10 @@ void StartupEngines(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This sets up type for the engine
|
/* This sets up type for the engine
|
||||||
It is needed if you want to ask the engine what type it is
|
* It is needed if you want to ask the engine what type it is
|
||||||
It should hopefully be the same as when you ask a vehicle what it is
|
* It should hopefully be the same as when you ask a vehicle what it is
|
||||||
but using this, you can ask what type an engine number is
|
* but using this, you can ask what type an engine number is
|
||||||
even if it is not a vehicle (yet)*/
|
* even if it is not a vehicle (yet)*/
|
||||||
}
|
}
|
||||||
|
|
||||||
AdjustAvailAircraft();
|
AdjustAvailAircraft();
|
||||||
|
|
7
engine.h
7
engine.h
|
@ -3,8 +3,7 @@
|
||||||
#ifndef ENGINE_H
|
#ifndef ENGINE_H
|
||||||
#define ENGINE_H
|
#define ENGINE_H
|
||||||
|
|
||||||
/** @file engine.h
|
/** @file engine.h */
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pool.h"
|
#include "pool.h"
|
||||||
|
|
||||||
|
@ -71,8 +70,8 @@ typedef struct RoadVehicleInfo {
|
||||||
} RoadVehicleInfo;
|
} RoadVehicleInfo;
|
||||||
|
|
||||||
/** Information about a vehicle
|
/** Information about a vehicle
|
||||||
* @see table/engines.h
|
* @see table/engines.h
|
||||||
*/
|
*/
|
||||||
typedef struct EngineInfo {
|
typedef struct EngineInfo {
|
||||||
Date base_intro;
|
Date base_intro;
|
||||||
byte unk2; ///< Carriages have the highest bit set in this one
|
byte unk2; ///< Carriages have the highest bit set in this one
|
||||||
|
|
|
@ -121,7 +121,7 @@ static bool ReadHeightmapPNG(char *filename, uint *x, uint *y, byte **map)
|
||||||
png_init_io(png_ptr, fp);
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
/* Allocate memory and read image, without alpha or 16-bit samples
|
/* Allocate memory and read image, without alpha or 16-bit samples
|
||||||
* (result is either 8-bit indexed/grayscale or 24-bit RGB) */
|
* (result is either 8-bit indexed/grayscale or 24-bit RGB) */
|
||||||
png_set_packing(png_ptr);
|
png_set_packing(png_ptr);
|
||||||
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_ALPHA | PNG_TRANSFORM_STRIP_16, NULL);
|
png_read_png(png_ptr, info_ptr, PNG_TRANSFORM_PACKING | PNG_TRANSFORM_STRIP_ALPHA | PNG_TRANSFORM_STRIP_16, NULL);
|
||||||
|
|
||||||
|
|
26
news_gui.c
26
news_gui.c
|
@ -17,18 +17,18 @@
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
|
|
||||||
/* News system
|
/* News system
|
||||||
News system is realized as a FIFO queue (in an array)
|
* News system is realized as a FIFO queue (in an array)
|
||||||
The positions in the queue can't be rearranged, we only access
|
* The positions in the queue can't be rearranged, we only access
|
||||||
the array elements through pointers to the elements. Once the
|
* the array elements through pointers to the elements. Once the
|
||||||
array is full, the oldest entry (_oldest_news) is being overwritten
|
* array is full, the oldest entry (_oldest_news) is being overwritten
|
||||||
by the newest (_latest news).
|
* by the newest (_latest news).
|
||||||
|
*
|
||||||
oldest current lastest
|
* oldest current lastest
|
||||||
| | |
|
* | | |
|
||||||
[O------------F-------------C---------L ]
|
* [O------------F-------------C---------L ]
|
||||||
|
|
* |
|
||||||
forced
|
* forced
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define MAX_NEWS 30
|
#define MAX_NEWS 30
|
||||||
|
|
||||||
|
@ -524,7 +524,7 @@ void ShowLastNewsMessage(void)
|
||||||
|
|
||||||
|
|
||||||
/* return news by number, with 0 being the most
|
/* return news by number, with 0 being the most
|
||||||
recent news. Returns INVALID_NEWS if end of queue reached. */
|
* recent news. Returns INVALID_NEWS if end of queue reached. */
|
||||||
static byte getNews(byte i)
|
static byte getNews(byte i)
|
||||||
{
|
{
|
||||||
if (i >= _total_news) return INVALID_NEWS;
|
if (i >= _total_news) return INVALID_NEWS;
|
||||||
|
|
|
@ -1519,7 +1519,7 @@ static bool LoadOldMain(LoadgameState *ls)
|
||||||
_m[i].m4 = (_m[i].m4 >> 1) & 7;
|
_m[i].m4 = (_m[i].m4 >> 1) & 7;
|
||||||
}
|
}
|
||||||
/* TTDPatch stores PBS things in L6 and all elsewhere; so we'll just
|
/* TTDPatch stores PBS things in L6 and all elsewhere; so we'll just
|
||||||
* clear it for ourselves and let OTTD's rebuild PBS itself */
|
* clear it for ourselves and let OTTD's rebuild PBS itself */
|
||||||
_m[i].m4 &= 0xF; /* Only keep the lower four bits; upper four is PBS */
|
_m[i].m4 &= 0xF; /* Only keep the lower four bits; upper four is PBS */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
14
openttd.c
14
openttd.c
|
@ -1068,13 +1068,13 @@ static void UpdateExclusiveRights(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
|
/* FIXME old exclusive rights status is not being imported (stored in s->blocked_months_obsolete)
|
||||||
could be implemented this way:
|
* could be implemented this way:
|
||||||
1.) Go through all stations
|
* 1.) Go through all stations
|
||||||
Build an array town_blocked[ town_id ][ player_id ]
|
* Build an array town_blocked[ town_id ][ player_id ]
|
||||||
that stores if at least one station in that town is blocked for a player
|
* that stores if at least one station in that town is blocked for a player
|
||||||
2.) Go through that array, if you find a town that is not blocked for
|
* 2.) Go through that array, if you find a town that is not blocked for
|
||||||
one player, but for all others, then give him exclusivity.
|
* one player, but for all others, then give him exclusivity.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static const byte convert_currency[] = {
|
static const byte convert_currency[] = {
|
||||||
|
|
3
order.h
3
order.h
|
@ -1,7 +1,6 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** @file order.h
|
/** @file order.h */
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef ORDER_H
|
#ifndef ORDER_H
|
||||||
#define ORDER_H
|
#define ORDER_H
|
||||||
|
|
18
order_cmd.c
18
order_cmd.c
|
@ -817,9 +817,9 @@ void RestoreVehicleOrders(const Vehicle* v, const BackuppedOrders* bak)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
|
/* CMD_NO_TEST_IF_IN_NETWORK is used here, because CMD_INSERT_ORDER checks if the
|
||||||
order number is one more than the current amount of orders, and because
|
* order number is one more than the current amount of orders, and because
|
||||||
in network the commands are queued before send, the second insert always
|
* in network the commands are queued before send, the second insert always
|
||||||
fails in test mode. By bypassing the test-mode, that no longer is a problem. */
|
* fails in test mode. By bypassing the test-mode, that no longer is a problem. */
|
||||||
for (i = 0; bak->order[i].type != OT_NOTHING; i++) {
|
for (i = 0; bak->order[i].type != OT_NOTHING; i++) {
|
||||||
if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
|
if (!DoCommandP(0, v->index + (i << 16), PackOrder(&bak->order[i]), NULL, CMD_INSERT_ORDER | CMD_NO_TEST_IF_IN_NETWORK))
|
||||||
break;
|
break;
|
||||||
|
@ -1055,10 +1055,10 @@ void DeleteVehicleOrders(Vehicle *v)
|
||||||
v->next_shared = NULL;
|
v->next_shared = NULL;
|
||||||
|
|
||||||
/* We only need to update this-one, because if there is a third
|
/* We only need to update this-one, because if there is a third
|
||||||
vehicle which shares the same order-list, nothing will change. If
|
* vehicle which shares the same order-list, nothing will change. If
|
||||||
this is the last vehicle, the last line of the order-window
|
* this is the last vehicle, the last line of the order-window
|
||||||
will change from Shared order list, to Order list, so it needs
|
* will change from Shared order list, to Order list, so it needs
|
||||||
an update */
|
* an update */
|
||||||
InvalidateVehicleOrder(u);
|
InvalidateVehicleOrder(u);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1175,8 +1175,8 @@ static void Load_ORDR(void)
|
||||||
/* Update all the next pointer */
|
/* Update all the next pointer */
|
||||||
for (i = 1; i < len; ++i) {
|
for (i = 1; i < len; ++i) {
|
||||||
/* The orders were built like this:
|
/* The orders were built like this:
|
||||||
Vehicle one had order[0], and as long as order++.type was not
|
* Vehicle one had order[0], and as long as order++.type was not
|
||||||
OT_NOTHING, it was part of the order-list of that vehicle */
|
* OT_NOTHING, it was part of the order-list of that vehicle */
|
||||||
if (GetOrder(i)->type != OT_NOTHING)
|
if (GetOrder(i)->type != OT_NOTHING)
|
||||||
GetOrder(i - 1)->next = GetOrder(i);
|
GetOrder(i - 1)->next = GetOrder(i);
|
||||||
}
|
}
|
||||||
|
|
3
player.h
3
player.h
|
@ -229,8 +229,7 @@ static inline bool IsLocalPlayer(void)
|
||||||
void DeletePlayerWindows(PlayerID pi);
|
void DeletePlayerWindows(PlayerID pi);
|
||||||
byte GetPlayerRailtypes(PlayerID p);
|
byte GetPlayerRailtypes(PlayerID p);
|
||||||
|
|
||||||
/** Finds out if a Player has a certain railtype available
|
/** Finds out if a Player has a certain railtype available */
|
||||||
*/
|
|
||||||
static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
|
static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
|
||||||
{
|
{
|
||||||
return HASBIT(p->avail_railtypes, Railtype);
|
return HASBIT(p->avail_railtypes, Railtype);
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** @file players.c
|
/** @file players.c
|
||||||
* @todo Cleanup the messy DrawPlayerFace function asap
|
* @todo Cleanup the messy DrawPlayerFace function asap
|
||||||
*/
|
*/
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
|
|
4
rail.h
4
rail.h
|
@ -82,7 +82,7 @@ static inline TrackBits AxisToTrackBits(Axis a)
|
||||||
|
|
||||||
|
|
||||||
/** These are a combination of tracks and directions. Values are 0-5 in one
|
/** These are a combination of tracks and directions. Values are 0-5 in one
|
||||||
direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
* direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
||||||
typedef enum Trackdirs {
|
typedef enum Trackdirs {
|
||||||
TRACKDIR_X_NE = 0,
|
TRACKDIR_X_NE = 0,
|
||||||
TRACKDIR_Y_SE = 1,
|
TRACKDIR_Y_SE = 1,
|
||||||
|
@ -103,7 +103,7 @@ typedef enum Trackdirs {
|
||||||
} Trackdir;
|
} Trackdir;
|
||||||
|
|
||||||
/** These are a combination of tracks and directions. Values are 0-5 in one
|
/** These are a combination of tracks and directions. Values are 0-5 in one
|
||||||
direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
* direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
||||||
typedef enum TrackdirBits {
|
typedef enum TrackdirBits {
|
||||||
TRACKDIR_BIT_NONE = 0x0000,
|
TRACKDIR_BIT_NONE = 0x0000,
|
||||||
TRACKDIR_BIT_X_NE = 0x0001,
|
TRACKDIR_BIT_X_NE = 0x0001,
|
||||||
|
|
17
rail_cmd.c
17
rail_cmd.c
|
@ -586,13 +586,12 @@ int32 CmdBuildTrainDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
tileh = GetTileSlope(tile, NULL);
|
tileh = GetTileSlope(tile, NULL);
|
||||||
|
|
||||||
/* Prohibit construction if
|
/* Prohibit construction if
|
||||||
The tile is non-flat AND
|
* The tile is non-flat AND
|
||||||
1) The AI is "old-school"
|
* 1) The AI is "old-school"
|
||||||
2) build-on-slopes is disabled
|
* 2) build-on-slopes is disabled
|
||||||
3) the tile is steep i.e. spans two height levels
|
* 3) the tile is steep i.e. spans two height levels
|
||||||
4) the exit points in the wrong direction
|
* 4) the exit points in the wrong direction
|
||||||
|
*/
|
||||||
*/
|
|
||||||
|
|
||||||
if (tileh != SLOPE_FLAT && (
|
if (tileh != SLOPE_FLAT && (
|
||||||
_is_old_ai_player ||
|
_is_old_ai_player ||
|
||||||
|
@ -753,7 +752,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
|
||||||
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
|
||||||
|
|
||||||
/* for vertical/horizontal tracks, double the given signals density
|
/* for vertical/horizontal tracks, double the given signals density
|
||||||
* since the original amount will be too dense (shorter tracks) */
|
* since the original amount will be too dense (shorter tracks) */
|
||||||
if (!IsDiagonalTrack(track)) signal_density *= 2;
|
if (!IsDiagonalTrack(track)) signal_density *= 2;
|
||||||
|
|
||||||
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
if (CmdFailed(ValidateAutoDrag(&trackdir, tile, end_tile))) return CMD_ERROR;
|
||||||
|
@ -777,7 +776,7 @@ static int32 CmdSignalTrackHelper(TileIndex tile, uint32 flags, uint32 p1, uint3
|
||||||
* trackdir - trackdir to build with autorail
|
* trackdir - trackdir to build with autorail
|
||||||
* semaphores - semaphores or signals
|
* semaphores - semaphores or signals
|
||||||
* signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way)
|
* signals - is there a signal/semaphore on the first tile, copy its style (two-way/single-way)
|
||||||
and convert all others to semaphore/signal
|
* and convert all others to semaphore/signal
|
||||||
* mode - 1 remove signals, 0 build signals */
|
* mode - 1 remove signals, 0 build signals */
|
||||||
signal_ctr = total_cost = 0;
|
signal_ctr = total_cost = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
|
|
@ -386,8 +386,8 @@ int32 CmdSendRoadVehToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (v->current_order.type == OT_GOTO_DEPOT) {
|
if (v->current_order.type == OT_GOTO_DEPOT) {
|
||||||
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
||||||
/* We called with a different DEPOT_SERVICE setting.
|
/* We called with a different DEPOT_SERVICE setting.
|
||||||
* Now we change the setting to apply the new one and let the vehicle head for the same depot.
|
* Now we change the setting to apply the new one and let the vehicle head for the same depot.
|
||||||
* Note: the if is (true for requesting service == true for ordered to stop in depot) */
|
* Note: the if is (true for requesting service == true for ordered to stop in depot) */
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
||||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||||
|
|
10
saveload.c
10
saveload.c
|
@ -688,10 +688,10 @@ bool SlObjectMember(void *ptr, const SaveLoad *sld)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* SL_WRITEBYTE translates a value of a variable to another one upon
|
/* SL_WRITEBYTE translates a value of a variable to another one upon
|
||||||
* saving or loading.
|
* saving or loading.
|
||||||
* XXX - variable renaming abuse
|
* XXX - variable renaming abuse
|
||||||
* game_value: the value of the variable ingame is abused by sld->version_from
|
* game_value: the value of the variable ingame is abused by sld->version_from
|
||||||
* file_value: the value of the variable in the savegame is abused by sld->version_to */
|
* file_value: the value of the variable in the savegame is abused by sld->version_to */
|
||||||
case SL_WRITEBYTE:
|
case SL_WRITEBYTE:
|
||||||
if (_sl.save) {
|
if (_sl.save) {
|
||||||
SlWriteByte(sld->version_to);
|
SlWriteByte(sld->version_to);
|
||||||
|
@ -1606,7 +1606,7 @@ SaveOrLoadResult SaveOrLoad(const char *filename, int mode)
|
||||||
fclose(_sl.fh);
|
fclose(_sl.fh);
|
||||||
|
|
||||||
/* After loading fix up savegame for any internal changes that
|
/* After loading fix up savegame for any internal changes that
|
||||||
* might've occured since then. If it fails, load back the old game */
|
* might've occured since then. If it fails, load back the old game */
|
||||||
if (!AfterLoadGame()) return SL_REINIT;
|
if (!AfterLoadGame()) return SL_REINIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,7 +768,7 @@ static void ini_save_settings(IniFile *ini, const SettingDesc *sd, const char *g
|
||||||
const void *p = string_to_val(sdb, item->value);
|
const void *p = string_to_val(sdb, item->value);
|
||||||
|
|
||||||
/* The main type of a variable/setting is in bytes 8-15
|
/* The main type of a variable/setting is in bytes 8-15
|
||||||
* The subtype (what kind of numbers do we have there) is in 0-7 */
|
* The subtype (what kind of numbers do we have there) is in 0-7 */
|
||||||
switch (sdb->cmd) {
|
switch (sdb->cmd) {
|
||||||
case SDT_BOOLX:
|
case SDT_BOOLX:
|
||||||
case SDT_NUMX:
|
case SDT_NUMX:
|
||||||
|
|
|
@ -328,25 +328,25 @@ static inline bool GetBitAndShift(uint32 *b)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
A: competitors
|
* A: competitors
|
||||||
B: start time in months / 3
|
* B: start time in months / 3
|
||||||
C: town count (2 = high, 0 = low)
|
* C: town count (2 = high, 0 = low)
|
||||||
D: industry count (3 = high, 0 = none)
|
* D: industry count (3 = high, 0 = none)
|
||||||
E: inital loan / 1000 (in GBP)
|
* E: inital loan / 1000 (in GBP)
|
||||||
F: interest rate
|
* F: interest rate
|
||||||
G: running costs (0 = low, 2 = high)
|
* G: running costs (0 = low, 2 = high)
|
||||||
H: construction speed of competitors (0 = very slow, 4 = very fast)
|
* H: construction speed of competitors (0 = very slow, 4 = very fast)
|
||||||
I: intelligence (0-2)
|
* I: intelligence (0-2)
|
||||||
J: breakdowns(0 = off, 2 = normal)
|
* J: breakdowns (0 = off, 2 = normal)
|
||||||
K: subsidy multiplier (0 = 1.5, 3 = 4.0)
|
* K: subsidy multiplier (0 = 1.5, 3 = 4.0)
|
||||||
L: construction cost (0-2)
|
* L: construction cost (0-2)
|
||||||
M: terrain type (0 = very flat, 3 = mountainous)
|
* M: terrain type (0 = very flat, 3 = mountainous)
|
||||||
N: amount of water (0 = very low, 3 = high)
|
* N: amount of water (0 = very low, 3 = high)
|
||||||
O: economy (0 = steady, 1 = fluctuating)
|
* O: economy (0 = steady, 1 = fluctuating)
|
||||||
P: Train reversing (0 = end of line + stations, 1 = end of line)
|
* P: Train reversing (0 = end of line + stations, 1 = end of line)
|
||||||
Q: disasters
|
* Q: disasters
|
||||||
R: area restructuring (0 = permissive, 2 = hostile)
|
* R: area restructuring (0 = permissive, 2 = hostile)
|
||||||
*/
|
*/
|
||||||
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
|
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
|
||||||
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
|
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
|
||||||
{2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, //easy
|
{2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, //easy
|
||||||
|
@ -987,7 +987,7 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
/* Parameter edit box not used yet
|
#if 0 /* Parameter edit box not used yet */
|
||||||
case WE_TIMEOUT:
|
case WE_TIMEOUT:
|
||||||
WP(w,def_d).data_2 = 0;
|
WP(w,def_d).data_2 = 0;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
|
@ -999,7 +999,8 @@ static void NewgrfWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*/
|
#endif
|
||||||
|
|
||||||
case WE_DESTROY:
|
case WE_DESTROY:
|
||||||
_sel_grffile = NULL;
|
_sel_grffile = NULL;
|
||||||
DeleteWindowById(WC_QUERY_STRING, 0);
|
DeleteWindowById(WC_QUERY_STRING, 0);
|
||||||
|
|
|
@ -230,8 +230,8 @@ static const uint16 * const _legend_table[] = {
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define WRITE_PIXELS(dst, val) *(uint32*)(dst) = (val);
|
# define WRITE_PIXELS(dst, val) *(uint32*)(dst) = (val);
|
||||||
# define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val);
|
# define WRITE_PIXELS_OR(dst,val) *(uint32*)(dst) |= (val);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MKCOLOR(x) TO_LE32X(x)
|
#define MKCOLOR(x) TO_LE32X(x)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** @file station_cmd.c
|
/** @file station_cmd.c */
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
|
@ -169,7 +168,7 @@ RoadStop *AllocateRoadStop(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate the radius of the station. Basicly it is the biggest
|
/* Calculate the radius of the station. Basicly it is the biggest
|
||||||
radius that is available within the station */
|
* radius that is available within the station */
|
||||||
static uint FindCatchmentRadius(const Station* st)
|
static uint FindCatchmentRadius(const Station* st)
|
||||||
{
|
{
|
||||||
uint ret = 0;
|
uint ret = 0;
|
||||||
|
@ -783,13 +782,13 @@ int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invali
|
||||||
tileh = GetTileSlope(tile_cur, &z);
|
tileh = GetTileSlope(tile_cur, &z);
|
||||||
|
|
||||||
/* Prohibit building if
|
/* Prohibit building if
|
||||||
1) The tile is "steep" (i.e. stretches two height levels)
|
* 1) The tile is "steep" (i.e. stretches two height levels)
|
||||||
-OR-
|
* -OR-
|
||||||
2) The tile is non-flat if
|
* 2) The tile is non-flat if
|
||||||
a) the player building is an "old-school" AI
|
* a) the player building is an "old-school" AI
|
||||||
-OR-
|
* -OR-
|
||||||
b) the build_on_slopes switch is disabled
|
* b) the build_on_slopes switch is disabled
|
||||||
*/
|
*/
|
||||||
if (IsSteepSlope(tileh) ||
|
if (IsSteepSlope(tileh) ||
|
||||||
((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) {
|
((_is_old_ai_player || !_patches.build_on_slopes) && tileh != SLOPE_FLAT)) {
|
||||||
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
|
||||||
|
@ -1252,11 +1251,11 @@ uint GetStationPlatforms(const Station *st, TileIndex tile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Determines the REMAINING length of a platform, starting at (and including)
|
/** Determines the REMAINING length of a platform, starting at (and including)
|
||||||
* the given tile.
|
* the given tile.
|
||||||
* @param tile the tile from which to start searching. Must be a railway station tile
|
* @param tile the tile from which to start searching. Must be a railway station tile
|
||||||
* @param dir The direction in which to search.
|
* @param dir The direction in which to search.
|
||||||
* @return The platform length
|
* @return The platform length
|
||||||
*/
|
*/
|
||||||
uint GetPlatformLength(TileIndex tile, DiagDirection dir)
|
uint GetPlatformLength(TileIndex tile, DiagDirection dir)
|
||||||
{
|
{
|
||||||
TileIndex start_tile = tile;
|
TileIndex start_tile = tile;
|
||||||
|
@ -1353,23 +1352,23 @@ int32 DoConvertStationRail(TileIndex tile, RailType totype, bool exec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Heavy wizardry used to add a roadstop to a station.
|
/** Heavy wizardry used to add a roadstop to a station.
|
||||||
* To understand the function, lets first look at what is passed around,
|
* To understand the function, lets first look at what is passed around,
|
||||||
* especially the last two parameters. CmdBuildRoadStop allocates a road
|
* especially the last two parameters. CmdBuildRoadStop allocates a road
|
||||||
* stop and needs to put that stop into the linked list of road stops.
|
* stop and needs to put that stop into the linked list of road stops.
|
||||||
* It (CmdBuildRoadStop) has a **currstop pointer which points to element
|
* It (CmdBuildRoadStop) has a **currstop pointer which points to element
|
||||||
* in the linked list of stops (each element in this list being a pointer
|
* in the linked list of stops (each element in this list being a pointer
|
||||||
* in itself, hence the double pointer). We (FindRoadStopSpot) need to
|
* in itself, hence the double pointer). We (FindRoadStopSpot) need to
|
||||||
* modify this pointer (**currstop) thus we need to pass by reference,
|
* modify this pointer (**currstop) thus we need to pass by reference,
|
||||||
* obtaining a triple pointer (***currstop). When finished, **currstop
|
* obtaining a triple pointer (***currstop). When finished, **currstop
|
||||||
* in CmdBuildRoadStop will contain the address of the pointer which will
|
* in CmdBuildRoadStop will contain the address of the pointer which will
|
||||||
* then point into the global roadstop array. *prev (in CmdBuildRoadStop)
|
* then point into the global roadstop array. *prev (in CmdBuildRoadStop)
|
||||||
* is the pointer tino the global roadstop array which has *currstop in
|
* is the pointer tino the global roadstop array which has *currstop in
|
||||||
* its ->next element.
|
* its ->next element.
|
||||||
* @param[in] truck_station Determines whether a stop is RS_BUS or RS_TRUCK
|
* @param[in] truck_station Determines whether a stop is RS_BUS or RS_TRUCK
|
||||||
* @param[in] station The station to do the whole procedure for
|
* @param[in] station The station to do the whole procedure for
|
||||||
* @param[out] currstop See the detailed function description
|
* @param[out] currstop See the detailed function description
|
||||||
* @param prev See the detailed function description
|
* @param prev See the detailed function description
|
||||||
*/
|
*/
|
||||||
static void FindRoadStopSpot(bool truck_station, Station* st, RoadStop*** currstop, RoadStop** prev)
|
static void FindRoadStopSpot(bool truck_station, Station* st, RoadStop*** currstop, RoadStop** prev)
|
||||||
{
|
{
|
||||||
RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops;
|
RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops;
|
||||||
|
@ -2367,12 +2366,12 @@ void DestroyRoadStop(RoadStop* rs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up a station by clearing vehicle orders and invalidating windows.
|
* Clean up a station by clearing vehicle orders and invalidating windows.
|
||||||
* Aircraft-Hangar orders need special treatment here, as the hangars are
|
* Aircraft-Hangar orders need special treatment here, as the hangars are
|
||||||
* actually part of a station (tiletype is STATION), but the order type
|
* actually part of a station (tiletype is STATION), but the order type
|
||||||
* is OT_GOTO_DEPOT.
|
* is OT_GOTO_DEPOT.
|
||||||
* @param st Station to be deleted
|
* @param st Station to be deleted
|
||||||
*/
|
*/
|
||||||
void DestroyStation(Station *st)
|
void DestroyStation(Station *st)
|
||||||
{
|
{
|
||||||
StationID index;
|
StationID index;
|
||||||
|
|
|
@ -247,7 +247,7 @@ static void PlayerStationsWndProc(Window *w, WindowEvent *e)
|
||||||
switch (e->event) {
|
switch (e->event) {
|
||||||
case WE_PAINT: {
|
case WE_PAINT: {
|
||||||
/* Set up cargo click-states. Toggle the all-vehicle and all-cargo types button
|
/* Set up cargo click-states. Toggle the all-vehicle and all-cargo types button
|
||||||
* depending on if all types are clicked or not */
|
* depending on if all types are clicked or not */
|
||||||
SB(w->click_state, 6, 5, facilities);
|
SB(w->click_state, 6, 5, facilities);
|
||||||
SB(w->click_state, 26, 1, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
|
SB(w->click_state, 26, 1, facilities == (FACIL_TRAIN | FACIL_TRUCK_STOP | FACIL_BUS_STOP | FACIL_AIRPORT | FACIL_DOCK));
|
||||||
SB(w->click_state, 12, NUM_CARGO + 1, cargo_filter);
|
SB(w->click_state, 12, NUM_CARGO + 1, cargo_filter);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/* Rail selection types (directions):
|
/* Rail selection types (directions):
|
||||||
/ \ / \ / \ / \ / \ / \
|
* / \ / \ / \ / \ / \ / \
|
||||||
/ /\ /\ \ /===\ / \ /| \ / |\
|
* / /\ /\ \ /===\ / \ /| \ / |\
|
||||||
\/ / \ \/ \ / \===/ \| / \ |/
|
* \/ / \ \/ \ / \===/ \| / \ |/
|
||||||
\ / \ / \ / \ / \ / \ /
|
* \ / \ / \ / \ / \ / \ /
|
||||||
0 1 2 3 4 5
|
* 0 1 2 3 4 5
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// mark invalid tiles red
|
// mark invalid tiles red
|
||||||
#define RED(c) c | PALETTE_SEL_TILE_RED
|
#define RED(c) c | PALETTE_SEL_TILE_RED
|
||||||
|
|
|
@ -1,27 +1,27 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** @file bridge_land.h This file contains all the sprites for bridges
|
/** @file bridge_land.h This file contains all the sprites for bridges
|
||||||
* It consists of a number of arrays.
|
* It consists of a number of arrays.
|
||||||
* <ul><li>_bridge_sprite_table_n_m. Defines all the sprites of a bridge besides the pylons.
|
* <ul><li>_bridge_sprite_table_n_m. Defines all the sprites of a bridge besides the pylons.
|
||||||
* n defines the number of the bridge type, m the number of the section. the highest m for
|
* n defines the number of the bridge type, m the number of the section. the highest m for
|
||||||
* each bridge set defines the heads.<br>
|
* each bridge set defines the heads.<br>
|
||||||
* Sprites for middle secionts are arranged in groups of four, the elements are:
|
* Sprites for middle secionts are arranged in groups of four, the elements are:
|
||||||
* <ol><li>Element containing the track. This element is logically behind the vehicle.</li>
|
* <ol><li>Element containing the track. This element is logically behind the vehicle.</li>
|
||||||
* <li>Element containing the structure that is logically between the vehicle and the camera</li>
|
* <li>Element containing the structure that is logically between the vehicle and the camera</li>
|
||||||
* <li>Element containing the pylons.</li></ol>
|
* <li>Element containing the pylons.</li></ol>
|
||||||
* First group is for railway in X direction, second for railway in Y direction, two groups each follow for road, monorail and maglev<p>
|
* First group is for railway in X direction, second for railway in Y direction, two groups each follow for road, monorail and maglev<p>
|
||||||
* <br>Elements for heads are arranged in groups of eight:
|
* <br>Elements for heads are arranged in groups of eight:
|
||||||
* <ol><li>X direction, north end, flat</li>
|
* <ol><li>X direction, north end, flat</li>
|
||||||
* <li>Y direction, north end, flat</li>
|
* <li>Y direction, north end, flat</li>
|
||||||
* <li>X direction, south end, flat</li>
|
* <li>X direction, south end, flat</li>
|
||||||
* <li>Y direction, south end, flat</li>
|
* <li>Y direction, south end, flat</li>
|
||||||
* <li>X direction, north end, sloped</li>
|
* <li>X direction, north end, sloped</li>
|
||||||
* <li>Y direction, north end, sloped</li>
|
* <li>Y direction, north end, sloped</li>
|
||||||
* <li>X direction, south end, sloped</li>
|
* <li>X direction, south end, sloped</li>
|
||||||
* <li>Y direction, south end, sloped</li></ol>
|
* <li>Y direction, south end, sloped</li></ol>
|
||||||
* This is repeated 4 times, for rail, road, monorail, maglev</li>
|
* This is repeated 4 times, for rail, road, monorail, maglev</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static const PalSpriteID _bridge_sprite_table_2_0[] = {
|
static const PalSpriteID _bridge_sprite_table_2_0[] = {
|
||||||
0x9C3, 0x9C7, 0x9C9, 0x0, 0x9C4, 0x9C8, 0x9CA, 0x0,
|
0x9C3, 0x9C7, 0x9C9, 0x0, 0x9C4, 0x9C8, 0x9CA, 0x0,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/* $Id */
|
/* $Id */
|
||||||
/** @file elrail_data.h Stores all the data for overhead wire and pylon drawing.
|
/** @file elrail_data.h Stores all the data for overhead wire and pylon drawing.
|
||||||
@see elrail.c */
|
* @see elrail.c */
|
||||||
|
|
||||||
#ifndef ELRAIL_DATA_H
|
#ifndef ELRAIL_DATA_H
|
||||||
#define ELRAIL_DATA_H
|
#define ELRAIL_DATA_H
|
||||||
|
|
||||||
/** Tile Location group.
|
/** Tile Location group.
|
||||||
This defines whether the X and or Y coordinate of a tile is even */
|
* This defines whether the X and or Y coordinate of a tile is even */
|
||||||
typedef enum TLG {
|
typedef enum TLG {
|
||||||
XEVEN_YEVEN = 0,
|
XEVEN_YEVEN = 0,
|
||||||
XEVEN_YODD = 1,
|
XEVEN_YODD = 1,
|
||||||
|
@ -16,8 +16,8 @@ typedef enum TLG {
|
||||||
} TLG;
|
} TLG;
|
||||||
|
|
||||||
/** When determining the pylon configuration on the edge, two tiles are taken
|
/** When determining the pylon configuration on the edge, two tiles are taken
|
||||||
into account: the tile being drawn itself (the home tile, the one in
|
* into account: the tile being drawn itself (the home tile, the one in
|
||||||
ti->tile), and the neighbouring tile */
|
* ti->tile), and the neighbouring tile */
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TS_HOME = 0,
|
TS_HOME = 0,
|
||||||
TS_NEIGHBOUR = 1,
|
TS_NEIGHBOUR = 1,
|
||||||
|
@ -38,8 +38,8 @@ static byte AllowedPPPonPCP[DIAGDIR_END] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Which of the PPPs are inside the tile. For the two PPPs on the tile border
|
/** Which of the PPPs are inside the tile. For the two PPPs on the tile border
|
||||||
the following system is used: if you rotate the PCP so that it is in the
|
* the following system is used: if you rotate the PCP so that it is in the
|
||||||
north, the eastern PPP belongs to the tile. */
|
* north, the eastern PPP belongs to the tile. */
|
||||||
static byte OwnedPPPonPCP[DIAGDIR_END] = {
|
static byte OwnedPPPonPCP[DIAGDIR_END] = {
|
||||||
1 << DIR_SE | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
|
1 << DIR_SE | 1 << DIR_S | 1 << DIR_SW | 1 << DIR_W,
|
||||||
1 << DIR_N | 1 << DIR_SW | 1 << DIR_W | 1 << DIR_NW,
|
1 << DIR_N | 1 << DIR_SW | 1 << DIR_W | 1 << DIR_NW,
|
||||||
|
@ -59,9 +59,9 @@ static const DiagDirection PCPpositions[TRACK_END][2] = {
|
||||||
|
|
||||||
#define PCP_NOT_ON_TRACK 0xFF
|
#define PCP_NOT_ON_TRACK 0xFF
|
||||||
/** Preferred points of each trackbit. Those are the ones perpendicular to the
|
/** Preferred points of each trackbit. Those are the ones perpendicular to the
|
||||||
track, plus the point in extension of the track (to mark end-of-track). PCPs
|
* track, plus the point in extension of the track (to mark end-of-track). PCPs
|
||||||
which are not on either end of the track are fully preferred.
|
* which are not on either end of the track are fully preferred.
|
||||||
@see PCPpositions */
|
* @see PCPpositions */
|
||||||
static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
|
static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
|
||||||
{ /* X */
|
{ /* X */
|
||||||
1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, /* NE */
|
1 << DIR_NE | 1 << DIR_SE | 1 << DIR_NW, /* NE */
|
||||||
|
@ -101,8 +101,8 @@ static byte PreferredPPPofTrackAtPCP[TRACK_END][DIAGDIR_END] = {
|
||||||
#define NUM_IGNORE_GROUPS 3
|
#define NUM_IGNORE_GROUPS 3
|
||||||
#define IGNORE_NONE 0xFF
|
#define IGNORE_NONE 0xFF
|
||||||
/** In case we have a staight line, we place pylon only every two tiles,
|
/** In case we have a staight line, we place pylon only every two tiles,
|
||||||
so there are certain tiles which we ignore. A straight line is found if
|
* so there are certain tiles which we ignore. A straight line is found if
|
||||||
we have exactly two PPPs. */
|
* we have exactly two PPPs. */
|
||||||
static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = {
|
static byte IgnoredPCP[NUM_IGNORE_GROUPS][TLG_END][DIAGDIR_END] = {
|
||||||
{ /* Ignore group 1, X and Y tracks */
|
{ /* Ignore group 1, X and Y tracks */
|
||||||
{ /* X even, Y even */
|
{ /* X even, Y even */
|
||||||
|
@ -196,7 +196,7 @@ static const Track TracksAtPCP[DIAGDIR_END][NUM_TRACKS_AT_PCP] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/* takes each of the 6 track bits from the array above and
|
/* takes each of the 6 track bits from the array above and
|
||||||
assigns it to the home tile or neighbour tile */
|
* assigns it to the home tile or neighbour tile */
|
||||||
static const TileSource TrackSourceTile[DIAGDIR_END][NUM_TRACKS_AT_PCP] = {
|
static const TileSource TrackSourceTile[DIAGDIR_END][NUM_TRACKS_AT_PCP] = {
|
||||||
{TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME },
|
{TS_HOME, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME },
|
||||||
{TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME },
|
{TS_HOME, TS_NEIGHBOUR, TS_NEIGHBOUR, TS_HOME , TS_NEIGHBOUR, TS_HOME },
|
||||||
|
@ -232,8 +232,8 @@ static const Direction PPPorder[DIAGDIR_END][TLG_END][DIR_END] = { /* X -
|
||||||
static const int8 x_pcp_offsets[DIAGDIR_END] = {0, 8, 15, 8};
|
static const int8 x_pcp_offsets[DIAGDIR_END] = {0, 8, 15, 8};
|
||||||
static const int8 y_pcp_offsets[DIAGDIR_END] = {8, 15, 8, 0};
|
static const int8 y_pcp_offsets[DIAGDIR_END] = {8, 15, 8, 0};
|
||||||
/* Geometric placement of the PPP relative to the PCP*/
|
/* Geometric placement of the PPP relative to the PCP*/
|
||||||
static const int8 x_ppp_offsets[DIR_END] = {-3, -4, -3, 0, +3, +4, +3, 0};
|
static const int8 x_ppp_offsets[DIR_END] = {-3, -4, -3, 0, 3, 4, 3, 0};
|
||||||
static const int8 y_ppp_offsets[DIR_END] = {-3, 0, +3, +4, +3, 0, -3, -4};
|
static const int8 y_ppp_offsets[DIR_END] = {-3, 0, 3, 4, 3, 0, -3, -4};
|
||||||
/* The type of pylon to draw at each PPP */
|
/* The type of pylon to draw at each PPP */
|
||||||
static const SpriteID pylons_normal[] = {
|
static const SpriteID pylons_normal[] = {
|
||||||
SPR_PYLON_EW_N,
|
SPR_PYLON_EW_N,
|
||||||
|
@ -341,16 +341,16 @@ static const SortableSpriteStruct CatenarySpriteData_Depot[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Refers to a certain element of the catenary.
|
/** Refers to a certain element of the catenary.
|
||||||
* Identifiers for Wires:
|
* Identifiers for Wires:
|
||||||
* <ol><li>Direction of the wire</li>
|
* <ol><li>Direction of the wire</li>
|
||||||
* <li>Slope of the tile for diagonals, placement inside the track for horiz/vertical pieces</li>
|
* <li>Slope of the tile for diagonals, placement inside the track for horiz/vertical pieces</li>
|
||||||
* <li>Place where a pylon shoule be</li></ol>
|
* <li>Place where a pylon shoule be</li></ol>
|
||||||
* Identifiers for Pylons:
|
* Identifiers for Pylons:
|
||||||
* <ol><li>Direction of the wire</li>
|
* <ol><li>Direction of the wire</li>
|
||||||
* <li>Slope of the tile</li>
|
* <li>Slope of the tile</li>
|
||||||
* <li>Position of the Pylon relative to the track</li>
|
* <li>Position of the Pylon relative to the track</li>
|
||||||
* <li>Position of the Pylon inside the tile</li></ol>
|
* <li>Position of the Pylon inside the tile</li></ol>
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
WIRE_X_FLAT_SW,
|
WIRE_X_FLAT_SW,
|
||||||
WIRE_X_FLAT_NE,
|
WIRE_X_FLAT_NE,
|
||||||
|
@ -398,11 +398,11 @@ typedef enum {
|
||||||
} CatenarySprite;
|
} CatenarySprite;
|
||||||
|
|
||||||
/* Selects a Wire (with white and grey ends) depending on whether:
|
/* Selects a Wire (with white and grey ends) depending on whether:
|
||||||
a) none (should never happen)
|
* a) none (should never happen)
|
||||||
b) the first
|
* b) the first
|
||||||
c) the second
|
* c) the second
|
||||||
d) both
|
* d) both
|
||||||
PCP exists.*/
|
* PCP exists.*/
|
||||||
static const CatenarySprite Wires[5][TRACK_END][4] = {
|
static const CatenarySprite Wires[5][TRACK_END][4] = {
|
||||||
{ /* Tileh == 0 */
|
{ /* Tileh == 0 */
|
||||||
{INVALID_CATENARY, WIRE_X_FLAT_NE, WIRE_X_FLAT_SW, WIRE_X_FLAT_BOTH},
|
{INVALID_CATENARY, WIRE_X_FLAT_NE, WIRE_X_FLAT_SW, WIRE_X_FLAT_BOTH},
|
||||||
|
|
|
@ -4,25 +4,25 @@
|
||||||
#define ENGINES_H
|
#define ENGINES_H
|
||||||
|
|
||||||
/** @file table/engines.h
|
/** @file table/engines.h
|
||||||
* This file contains all the data for vehicles
|
* This file contains all the data for vehicles
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../sound.h"
|
#include "../sound.h"
|
||||||
|
|
||||||
/** Writes the properties of a vehicle into the EngineInfo struct.
|
/** Writes the properties of a vehicle into the EngineInfo struct.
|
||||||
* @see EngineInfo
|
* @see EngineInfo
|
||||||
* @param a Introduction date
|
* @param a Introduction date
|
||||||
* @param e Rail Type of the vehicle
|
* @param e Rail Type of the vehicle
|
||||||
* @param f Bitmask of the climates
|
* @param f Bitmask of the climates
|
||||||
*/
|
*/
|
||||||
#define MK(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, e, f, 0, 8, 0, 0 }
|
#define MK(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b, c, d, e, f, 0, 8, 0, 0 }
|
||||||
/** Writes the properties of a train carriage into the EngineInfo struct.
|
/** Writes the properties of a train carriage into the EngineInfo struct.
|
||||||
* @see EngineInfo
|
* @see EngineInfo
|
||||||
* @param a Introduction date
|
* @param a Introduction date
|
||||||
* @param e Rail Type of the vehicle
|
* @param e Rail Type of the vehicle
|
||||||
* @param f Bitmask of the climates
|
* @param f Bitmask of the climates
|
||||||
* @note the 0x80 in parameter b sets the "is carriage bit"
|
* @note the 0x80 in parameter b sets the "is carriage bit"
|
||||||
*/
|
*/
|
||||||
#define MW(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b | 0x80, c, d, e, f, 0, 8, 0, 0 }
|
#define MW(a, b, c, d, e, f) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, b | 0x80, c, d, e, f, 0, 8, 0, 0 }
|
||||||
|
|
||||||
// Rail types
|
// Rail types
|
||||||
|
|
|
@ -4,36 +4,36 @@
|
||||||
#define SPRITES_H
|
#define SPRITES_H
|
||||||
|
|
||||||
/** @file sprites.h
|
/** @file sprites.h
|
||||||
This file contails all sprite-related enums and defines. These consist mainly of
|
* This file contails all sprite-related enums and defines. These consist mainly of
|
||||||
the sprite numbers and a bunch of masks and macros to handle sprites and to get
|
* the sprite numbers and a bunch of masks and macros to handle sprites and to get
|
||||||
rid of all the magic numbers in the code.
|
* rid of all the magic numbers in the code.
|
||||||
|
*
|
||||||
@NOTE:
|
* @NOTE:
|
||||||
ALL SPRITE NUMBERS BELOW 5126 are in the main files
|
* ALL SPRITE NUMBERS BELOW 5126 are in the main files
|
||||||
SPR_CANALS_BASE is in canalsw.grf
|
* SPR_CANALS_BASE is in canalsw.grf
|
||||||
SPR_SLOPES_BASE is in trkfoundw.grf
|
* SPR_SLOPES_BASE is in trkfoundw.grf
|
||||||
SPR_OPENTTD_BASE is in openttd.grf
|
* SPR_OPENTTD_BASE is in openttd.grf
|
||||||
|
*
|
||||||
All elements which consist of two elements should
|
* All elements which consist of two elements should
|
||||||
have the same name and then suffixes
|
* have the same name and then suffixes
|
||||||
_GROUND and _BUILD for building-type sprites
|
* _GROUND and _BUILD for building-type sprites
|
||||||
_REAR and _FRONT for transport-type sprites (tiles where vehicles are on)
|
* _REAR and _FRONT for transport-type sprites (tiles where vehicles are on)
|
||||||
These sprites are split because of the Z order of the elements
|
* These sprites are split because of the Z order of the elements
|
||||||
(like some parts of a bridge are behind the vehicle, while others are before)
|
* (like some parts of a bridge are behind the vehicle, while others are before)
|
||||||
|
*
|
||||||
|
*
|
||||||
All sprites which are described here are referenced only one to a handful of times
|
* All sprites which are described here are referenced only one to a handful of times
|
||||||
throughout the code. When introducing new sprite enums, use meaningful names.
|
* throughout the code. When introducing new sprite enums, use meaningful names.
|
||||||
Don't be lazy and typing, and only use abbrevations when their meaning is clear or
|
* Don't be lazy and typing, and only use abbrevations when their meaning is clear or
|
||||||
the length of the enum would get out of hand. In that case EXPLAIN THE ABBREVATION
|
* the length of the enum would get out of hand. In that case EXPLAIN THE ABBREVATION
|
||||||
IN THIS FILE, and perhaps add some comments in the code where it is used.
|
* IN THIS FILE, and perhaps add some comments in the code where it is used.
|
||||||
Now, don't whine about this being too much typing work if the enums are like
|
* Now, don't whine about this being too much typing work if the enums are like
|
||||||
30 characters in length. If your editor doen't help you simplifying your work,
|
* 30 characters in length. If your editor doen't help you simplifying your work,
|
||||||
get a proper editor. If your Operating Systems don't have any decent editors,
|
* get a proper editor. If your Operating Systems don't have any decent editors,
|
||||||
get a proper Operating System.
|
* get a proper Operating System.
|
||||||
|
*
|
||||||
@todo Split the "Sprites" enum into smaller chunks and document them
|
* @todo Split the "Sprites" enum into smaller chunks and document them
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
enum Sprites {
|
enum Sprites {
|
||||||
|
@ -226,8 +226,8 @@ enum Sprites {
|
||||||
|
|
||||||
/* Elrail stuff */
|
/* Elrail stuff */
|
||||||
/* Wires. First identifier is the direction of the track, second is the required placement of the pylon.
|
/* Wires. First identifier is the direction of the track, second is the required placement of the pylon.
|
||||||
"short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope
|
* "short" denotes a wire that requires a pylon on each end. Third identifier is the direction of the slope
|
||||||
(in positive coordinate direction) */
|
* (in positive coordinate direction) */
|
||||||
SPR_WIRE_X_SHORT = SPR_ELRAIL_BASE + 3,
|
SPR_WIRE_X_SHORT = SPR_ELRAIL_BASE + 3,
|
||||||
SPR_WIRE_Y_SHORT = SPR_ELRAIL_BASE + 4,
|
SPR_WIRE_Y_SHORT = SPR_ELRAIL_BASE + 4,
|
||||||
SPR_WIRE_EW_SHORT = SPR_ELRAIL_BASE + 5,
|
SPR_WIRE_EW_SHORT = SPR_ELRAIL_BASE + 5,
|
||||||
|
@ -561,19 +561,18 @@ enum Sprites {
|
||||||
|
|
||||||
/* BTSUS == Suspension bridge */
|
/* BTSUS == Suspension bridge */
|
||||||
/* TILE_* denotes the different tiles a suspension bridge
|
/* TILE_* denotes the different tiles a suspension bridge
|
||||||
can have
|
* can have
|
||||||
TILE_A and TILE_B are the "beginnings" and "ends" of the
|
* TILE_A and TILE_B are the "beginnings" and "ends" of the
|
||||||
suspension system. they have small rectangluar endcaps
|
* suspension system. they have small rectangluar endcaps
|
||||||
TILE_C and TILE_D look almost identical to TILE_A and
|
* TILE_C and TILE_D look almost identical to TILE_A and
|
||||||
TILE_B, but they do not have the "endcaps". They form the
|
* TILE_B, but they do not have the "endcaps". They form the
|
||||||
middle part
|
* middle part
|
||||||
TILE_E is a condensed configuration of two pillars. while they
|
* TILE_E is a condensed configuration of two pillars. while they
|
||||||
are usually 2 pillars apart, they only have 1 pillar separation
|
* are usually 2 pillars apart, they only have 1 pillar separation
|
||||||
here
|
* here
|
||||||
TILE_F is an extended configuration of pillars. they are
|
* TILE_F is an extended configuration of pillars. they are
|
||||||
plugged in when pillars should be 3 tiles apart
|
* plugged in when pillars should be 3 tiles apart
|
||||||
|
*/
|
||||||
*/
|
|
||||||
SPR_BTSUS_ROAD_Y_REAR_TILE_A = 2453,
|
SPR_BTSUS_ROAD_Y_REAR_TILE_A = 2453,
|
||||||
SPR_BTSUS_ROAD_Y_REAR_TILE_B = 2454,
|
SPR_BTSUS_ROAD_Y_REAR_TILE_B = 2454,
|
||||||
SPR_BTSUS_Y_FRONT_TILE_A = 2455,
|
SPR_BTSUS_Y_FRONT_TILE_A = 2455,
|
||||||
|
@ -713,10 +712,10 @@ enum Sprites {
|
||||||
|
|
||||||
/* tubular bridges */
|
/* tubular bridges */
|
||||||
/* tubular bridges have 3 kinds of tiles:
|
/* tubular bridges have 3 kinds of tiles:
|
||||||
a start tile (with only half a tube on the far side, marked _BEG
|
* a start tile (with only half a tube on the far side, marked _BEG
|
||||||
a middle tile (full tunnel), marked _MID
|
* a middle tile (full tunnel), marked _MID
|
||||||
and an end tile (half a tube on the near side, maked _END
|
* and an end tile (half a tube on the near side, maked _END
|
||||||
*/
|
*/
|
||||||
SPR_BTTUB_X_FRONT_BEG = 2559,
|
SPR_BTTUB_X_FRONT_BEG = 2559,
|
||||||
SPR_BTTUB_X_FRONT_MID = 2660,
|
SPR_BTTUB_X_FRONT_MID = 2660,
|
||||||
SPR_BTTUB_X_FRONT_END = 2561,
|
SPR_BTTUB_X_FRONT_END = 2561,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
/* $Id$ */
|
/* $Id$ */
|
||||||
|
|
||||||
/** @file town_land.h
|
/** @file town_land.h */
|
||||||
*/
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
HOUSE_TEMP_CHURCH = 0x03,
|
HOUSE_TEMP_CHURCH = 0x03,
|
||||||
|
@ -16,16 +15,16 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Writes the data into the Town Tile Drawing Struct
|
/** Writes the data into the Town Tile Drawing Struct
|
||||||
* @param s1 The first sprite of the building, mostly the ground sprite
|
* @param s1 The first sprite of the building, mostly the ground sprite
|
||||||
* @param s2 The second sprite of the building.
|
* @param s2 The second sprite of the building.
|
||||||
* @param sx The x-position of the sprite within the tile
|
* @param sx The x-position of the sprite within the tile
|
||||||
* @param xy the y-position of the sprite within the tile
|
* @param xy the y-position of the sprite within the tile
|
||||||
* @param w the width of the sprite
|
* @param w the width of the sprite
|
||||||
* @param h the height of the sprite
|
* @param h the height of the sprite
|
||||||
* @param dz the virtual height of the sprite
|
* @param dz the virtual height of the sprite
|
||||||
* @param p set to 1 if a lift is present
|
* @param p set to 1 if a lift is present
|
||||||
* @see DrawTownTileStruct
|
* @see DrawTownTileStruct
|
||||||
*/
|
*/
|
||||||
#define M(s1, s2, sx, sy, w, h, dz, p) {s1, s2, sx, sy, w - 1, h - 1, dz, p}
|
#define M(s1, s2, sx, sy, w, h, dz, p) {s1, s2, sx, sy, w - 1, h - 1, dz, p}
|
||||||
|
|
||||||
static const DrawBuildingsTileStruct _town_draw_tile_data[] = {
|
static const DrawBuildingsTileStruct _town_draw_tile_data[] = {
|
||||||
|
@ -1928,20 +1927,20 @@ static const uint16 _housetype_flags[] = {
|
||||||
assert_compile(lengthof(_housetype_flags) == HOUSE_MAX);
|
assert_compile(lengthof(_housetype_flags) == HOUSE_MAX);
|
||||||
|
|
||||||
static const byte _housetype_extra_flags[] = {
|
static const byte _housetype_extra_flags[] = {
|
||||||
0, 0, 0, 0,32,32, 0, 8,
|
0, 0, 0, 0, 32, 32, 0, 8,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0,16, 0, 0, 0,
|
0, 0, 0, 0, 16, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
16, 0, 0, 0, 0, 0, 0, 0,
|
16, 0, 0, 0, 0, 0, 0, 0,
|
||||||
16, 0, 0, 0, 0, 0, 0, 0,
|
16, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 8, 0, 8, 0, 0, 0,
|
0, 0, 8, 0, 8, 0, 0, 0,
|
||||||
0, 0, 4, 0, 4, 0, 0, 0,
|
0, 0, 4, 0, 4, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 4,
|
0, 0, 0, 0, 0, 0, 0, 4,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 8, 0, 0, 0, 0,
|
0, 0, 0, 8, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0,
|
||||||
};
|
};
|
||||||
assert_compile(lengthof(_housetype_extra_flags) == HOUSE_MAX);
|
assert_compile(lengthof(_housetype_extra_flags) == HOUSE_MAX);
|
||||||
|
|
||||||
|
@ -2137,20 +2136,20 @@ static const HousetypeYear _housetype_years[] = {
|
||||||
assert_compile(lengthof(_housetype_years) == HOUSE_MAX);
|
assert_compile(lengthof(_housetype_years) == HOUSE_MAX);
|
||||||
|
|
||||||
static const byte _housetype_cargo_passengers[] = {
|
static const byte _housetype_cargo_passengers[] = {
|
||||||
8, 8, 8, 2, 10,10,4, 6,
|
8, 8, 8, 2, 10, 10, 4, 6,
|
||||||
6, 2, 2, 2, 2, 8, 6, 6,
|
6, 2, 2, 2, 2, 8, 6, 6,
|
||||||
6, 10,6, 6, 4, 4, 4, 4,
|
6, 10, 6, 6, 4, 4, 4, 4,
|
||||||
3, 3, 3, 7, 8, 6, 8, 8,
|
3, 3, 3, 7, 8, 6, 8, 8,
|
||||||
4, 4, 4, 4, 8, 3, 3, 8,
|
4, 4, 4, 4, 8, 3, 3, 8,
|
||||||
8, 8, 8, 8, 5, 5, 3, 3,
|
8, 8, 8, 8, 5, 5, 3, 3,
|
||||||
3, 3, 8, 8, 9, 9,10, 10,
|
3, 3, 8, 8, 9, 9, 10, 10,
|
||||||
2, 2, 3, 3, 2, 2, 3, 3,
|
2, 2, 3, 3, 2, 2, 3, 3,
|
||||||
6, 6, 6, 6, 6, 6, 7, 7,
|
6, 6, 6, 6, 6, 6, 7, 7,
|
||||||
9, 9, 7, 7, 7, 7, 3, 3,
|
9, 9, 7, 7, 7, 7, 3, 3,
|
||||||
3, 3, 6, 2, 3, 6, 6, 8,
|
3, 3, 6, 2, 3, 6, 6, 8,
|
||||||
8, 6, 8, 2, 6, 3, 3, 3,
|
8, 6, 8, 2, 6, 3, 3, 3,
|
||||||
3, 3, 8, 4, 4, 8, 3, 3,
|
3, 3, 8, 4, 4, 8, 3, 3,
|
||||||
8, 8, 8, 4, 3, 3,
|
8, 8, 8, 4, 3, 3,
|
||||||
};
|
};
|
||||||
assert_compile(lengthof(_housetype_cargo_passengers) == HOUSE_MAX);
|
assert_compile(lengthof(_housetype_cargo_passengers) == HOUSE_MAX);
|
||||||
|
|
||||||
|
|
50
tgp.c
50
tgp.c
|
@ -505,25 +505,25 @@ static void HeightMapAdjustWaterLevel(amplitude_t water_percent, height_t h_max_
|
||||||
static double perlin_coast_noise_2D(const double x, const double y, const double p, const int prime);
|
static double perlin_coast_noise_2D(const double x, const double y, const double p, const int prime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine sculpts in from the edge a random amount, again a Perlin
|
* This routine sculpts in from the edge a random amount, again a Perlin
|
||||||
* sequence, to avoid the rigid flat-edge slopes that were present before. The
|
* sequence, to avoid the rigid flat-edge slopes that were present before. The
|
||||||
* Perlin noise map doesnt know where we are going to slice across, and so we
|
* Perlin noise map doesnt know where we are going to slice across, and so we
|
||||||
* often cut straight through high terrain. the smoothing routine makes it
|
* often cut straight through high terrain. the smoothing routine makes it
|
||||||
* legal, gradually increasing up from the edge to the original terrain height.
|
* legal, gradually increasing up from the edge to the original terrain height.
|
||||||
* By cutting parts of this away, it gives a far more irregular edge to the
|
* By cutting parts of this away, it gives a far more irregular edge to the
|
||||||
* map-edge. Sometimes it works beautifully with the existing sea & lakes, and
|
* map-edge. Sometimes it works beautifully with the existing sea & lakes, and
|
||||||
* creates a very realistic coastline. Other times the variation is less, and
|
* creates a very realistic coastline. Other times the variation is less, and
|
||||||
* the map-edge shows its cliff-like roots.
|
* the map-edge shows its cliff-like roots.
|
||||||
*
|
*
|
||||||
* This routine may be extended to randomly sculpt the height of the terrain
|
* This routine may be extended to randomly sculpt the height of the terrain
|
||||||
* near the edge. This will have the coast edge at low level (1-3), rising in
|
* near the edge. This will have the coast edge at low level (1-3), rising in
|
||||||
* smoothed steps inland to about 15 tiles in. This should make it look as
|
* smoothed steps inland to about 15 tiles in. This should make it look as
|
||||||
* though the map has been built for the map size, rather than a slice through
|
* though the map has been built for the map size, rather than a slice through
|
||||||
* a larger map.
|
* a larger map.
|
||||||
*
|
*
|
||||||
* Please note that all the small numbers; 53, 101, 167, etc. are small primes
|
* Please note that all the small numbers; 53, 101, 167, etc. are small primes
|
||||||
* to help give the perlin noise a bit more of a random feel.
|
* to help give the perlin noise a bit more of a random feel.
|
||||||
*/
|
*/
|
||||||
static void HeightMapCoastLines(void)
|
static void HeightMapCoastLines(void)
|
||||||
{
|
{
|
||||||
int smallest_size = min(_patches.map_x, _patches.map_y);
|
int smallest_size = min(_patches.map_x, _patches.map_y);
|
||||||
|
@ -626,12 +626,12 @@ static void HeightMapSmoothCoasts(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This routine provides the essential cleanup necessary before OTTD can
|
* This routine provides the essential cleanup necessary before OTTD can
|
||||||
* display the terrain. When generated, the terrain heights can jump more than
|
* display the terrain. When generated, the terrain heights can jump more than
|
||||||
* one level between tiles. This routine smooths out those differences so that
|
* one level between tiles. This routine smooths out those differences so that
|
||||||
* the most it can change is one level. When OTTD can support cliffs, this
|
* the most it can change is one level. When OTTD can support cliffs, this
|
||||||
* routine may not be necessary.
|
* routine may not be necessary.
|
||||||
*/
|
*/
|
||||||
static void HeightMapSmoothSlopes(height_t dh_max)
|
static void HeightMapSmoothSlopes(height_t dh_max)
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
|
@ -738,7 +738,7 @@ static int GrowTownAtRoad(Town *t, TileIndex tile)
|
||||||
_grow_town_result = -1;
|
_grow_town_result = -1;
|
||||||
} else if (_game_mode == GM_EDITOR) {
|
} else if (_game_mode == GM_EDITOR) {
|
||||||
/* If we are in the SE, and this road-piece has no town owner yet, it just found an
|
/* If we are in the SE, and this road-piece has no town owner yet, it just found an
|
||||||
* owner :) (happy happy happy road now) */
|
* owner :) (happy happy happy road now) */
|
||||||
SetTileOwner(tile, OWNER_TOWN);
|
SetTileOwner(tile, OWNER_TOWN);
|
||||||
SetTownIndex(tile, t->index);
|
SetTownIndex(tile, t->index);
|
||||||
}
|
}
|
||||||
|
|
14
train_cmd.c
14
train_cmd.c
|
@ -1343,8 +1343,8 @@ int32 CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
for (tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL;
|
for (tmp = first; tmp != NULL; tmp = tmp->next) tmp->first = NULL;
|
||||||
|
|
||||||
/* 2.2 If there are wagons present after the deleted front engine, check
|
/* 2.2 If there are wagons present after the deleted front engine, check
|
||||||
* if the second wagon (which will be first) is an engine. If it is one,
|
* if the second wagon (which will be first) is an engine. If it is one,
|
||||||
* promote it as a new train, retaining the unitnumber, orders */
|
* promote it as a new train, retaining the unitnumber, orders */
|
||||||
if (new_f != NULL) {
|
if (new_f != NULL) {
|
||||||
if (IsTrainEngine(new_f)) {
|
if (IsTrainEngine(new_f)) {
|
||||||
switch_engine = true;
|
switch_engine = true;
|
||||||
|
@ -1902,9 +1902,9 @@ static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance)
|
||||||
/* Found target */
|
/* Found target */
|
||||||
tfdd.tile = ftd.node.tile;
|
tfdd.tile = ftd.node.tile;
|
||||||
/* Our caller expects a number of tiles, so we just approximate that
|
/* Our caller expects a number of tiles, so we just approximate that
|
||||||
* number by this. It might not be completely what we want, but it will
|
* number by this. It might not be completely what we want, but it will
|
||||||
* work for now :-) We can possibly change this when the old pathfinder
|
* work for now :-) We can possibly change this when the old pathfinder
|
||||||
* is removed. */
|
* is removed. */
|
||||||
tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH;
|
tfdd.best_length = ftd.best_path_dist / NPF_TILE_LENGTH;
|
||||||
if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
|
if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
|
||||||
}
|
}
|
||||||
|
@ -1960,8 +1960,8 @@ int32 CmdSendTrainToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
if (v->current_order.type == OT_GOTO_DEPOT) {
|
if (v->current_order.type == OT_GOTO_DEPOT) {
|
||||||
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
if (!!(p2 & DEPOT_SERVICE) == HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT)) {
|
||||||
/* We called with a different DEPOT_SERVICE setting.
|
/* We called with a different DEPOT_SERVICE setting.
|
||||||
* Now we change the setting to apply the new one and let the vehicle head for the same depot.
|
* Now we change the setting to apply the new one and let the vehicle head for the same depot.
|
||||||
* Note: the if is (true for requesting service == true for ordered to stop in depot) */
|
* Note: the if is (true for requesting service == true for ordered to stop in depot) */
|
||||||
if (flags & DC_EXEC) {
|
if (flags & DC_EXEC) {
|
||||||
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
TOGGLEBIT(v->current_order.flags, OFB_HALT_IN_DEPOT);
|
||||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
|
||||||
|
|
|
@ -918,22 +918,22 @@ uint GetBridgeFoundation(Slope tileh, Axis axis)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a tunnel of bridge tile.
|
* Draws a tunnel of bridge tile.
|
||||||
* For tunnels, this is rather simple, as you only needa draw the entrance.
|
* For tunnels, this is rather simple, as you only needa draw the entrance.
|
||||||
* Bridges are a bit more complex. base_offset is where the sprite selection comes into play
|
* Bridges are a bit more complex. base_offset is where the sprite selection comes into play
|
||||||
* and it works a bit like a bitmask.<p> For bridge heads:
|
* and it works a bit like a bitmask.<p> For bridge heads:
|
||||||
* <ul><li>Bit 0: direction</li>
|
* <ul><li>Bit 0: direction</li>
|
||||||
* <li>Bit 1: northern or southern heads</li>
|
* <li>Bit 1: northern or southern heads</li>
|
||||||
* <li>Bit 2: Set if the bridge head is sloped</li>
|
* <li>Bit 2: Set if the bridge head is sloped</li>
|
||||||
* <li>Bit 3 and more: Railtype Specific subset</li>
|
* <li>Bit 3 and more: Railtype Specific subset</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* For middle parts:
|
* For middle parts:
|
||||||
* <ul><li>Bits 0-1: need to be 0</li>
|
* <ul><li>Bits 0-1: need to be 0</li>
|
||||||
* <li>Bit 2: direction</li>
|
* <li>Bit 2: direction</li>
|
||||||
* <li>Bit 3 and above: Railtype Specific subset</li>
|
* <li>Bit 3 and above: Railtype Specific subset</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
|
* Please note that in this code, "roads" are treated as railtype 1, whilst the real railtypes are 0, 2 and 3
|
||||||
*/
|
*/
|
||||||
static void DrawTile_TunnelBridge(TileInfo *ti)
|
static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
{
|
{
|
||||||
uint32 image;
|
uint32 image;
|
||||||
|
|
14
variables.h
14
variables.h
|
@ -184,16 +184,16 @@ typedef struct Patches {
|
||||||
bool ai_in_multiplayer; // Do we allow AIs in multiplayer
|
bool ai_in_multiplayer; // Do we allow AIs in multiplayer
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* New Path Finding
|
* New Path Finding
|
||||||
*/
|
*/
|
||||||
bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */
|
bool new_pathfinding_all; /* Use the newest pathfinding algorithm for all */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The maximum amount of search nodes a single NPF run should take. This
|
* The maximum amount of search nodes a single NPF run should take. This
|
||||||
* limit should make sure performance stays at acceptable levels at the cost
|
* limit should make sure performance stays at acceptable levels at the cost
|
||||||
* of not being perfect anymore. This will probably be fixed in a more
|
* of not being perfect anymore. This will probably be fixed in a more
|
||||||
* sophisticated way sometime soon
|
* sophisticated way sometime soon
|
||||||
*/
|
*/
|
||||||
uint32 npf_max_search_nodes;
|
uint32 npf_max_search_nodes;
|
||||||
|
|
||||||
uint32 npf_rail_firstred_penalty; /* The penalty for when the first signal is red (and it is not an exit or combo signal) */
|
uint32 npf_rail_firstred_penalty; /* The penalty for when the first signal is red (and it is not an exit or combo signal) */
|
||||||
|
|
60
vehicle.c
60
vehicle.c
|
@ -344,10 +344,10 @@ Vehicle *AllocateVehicle(void)
|
||||||
|
|
||||||
|
|
||||||
/** Allocates a lot of vehicles and frees them again
|
/** Allocates a lot of vehicles and frees them again
|
||||||
* @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
|
* @param vl pointer to an array of vehicles to get allocated. Can be NULL if the vehicles aren't needed (makes it test only)
|
||||||
* @param num number of vehicles to allocate room for
|
* @param num number of vehicles to allocate room for
|
||||||
* @return true if there is room to allocate all the vehicles
|
* @return true if there is room to allocate all the vehicles
|
||||||
*/
|
*/
|
||||||
bool AllocateVehicles(Vehicle **vl, int num)
|
bool AllocateVehicles(Vehicle **vl, int num)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -514,9 +514,9 @@ Vehicle *GetFirstVehicleInChain(const Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* It is the fact (currently) that newly built vehicles do not have
|
/* It is the fact (currently) that newly built vehicles do not have
|
||||||
* their ->first pointer set. When this is the case, go up to the
|
* their ->first pointer set. When this is the case, go up to the
|
||||||
* first engine and set the pointers correctly. Also the first pointer
|
* first engine and set the pointers correctly. Also the first pointer
|
||||||
* is not saved in a savegame, so this has to be fixed up after loading */
|
* is not saved in a savegame, so this has to be fixed up after loading */
|
||||||
|
|
||||||
/* Find the 'locomotive' or the first wagon in a chain */
|
/* Find the 'locomotive' or the first wagon in a chain */
|
||||||
while ((u = GetPrevVehicleInChain_bruteforce(v)) != NULL) v = u;
|
while ((u = GetPrevVehicleInChain_bruteforce(v)) != NULL) v = u;
|
||||||
|
@ -574,8 +574,8 @@ static void MaybeReplaceVehicle(Vehicle *v);
|
||||||
static Vehicle* _first_veh_in_depot_list;
|
static Vehicle* _first_veh_in_depot_list;
|
||||||
|
|
||||||
/** Adds a vehicle to the list of vehicles, that visited a depot this tick
|
/** Adds a vehicle to the list of vehicles, that visited a depot this tick
|
||||||
* @param *v vehicle to add
|
* @param *v vehicle to add
|
||||||
*/
|
*/
|
||||||
void VehicleEnteredDepotThisTick(Vehicle *v)
|
void VehicleEnteredDepotThisTick(Vehicle *v)
|
||||||
{
|
{
|
||||||
// we need to set v->leave_depot_instantly as we have no control of it's contents at this time
|
// we need to set v->leave_depot_instantly as we have no control of it's contents at this time
|
||||||
|
@ -1537,10 +1537,10 @@ void AgeVehicle(Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Clone a vehicle. If it is a train, it will clone all the cars too
|
/** Clone a vehicle. If it is a train, it will clone all the cars too
|
||||||
* @param tile tile of the depot where the cloned vehicle is build
|
* @param tile tile of the depot where the cloned vehicle is build
|
||||||
* @param p1 the original vehicle's index
|
* @param p1 the original vehicle's index
|
||||||
* @param p2 1 = shared orders, else copied orders
|
* @param p2 1 = shared orders, else copied orders
|
||||||
*/
|
*/
|
||||||
int32 CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
int32 CmdCloneVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
|
||||||
{
|
{
|
||||||
Vehicle *v_front, *v;
|
Vehicle *v_front, *v;
|
||||||
|
@ -1919,14 +1919,14 @@ static void MaybeReplaceVehicle(Vehicle *v)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param sort_list list to store the list in. Note: it's presumed that it is big enough to store all vehicles in the game (worst case) and it will not check size
|
* @param sort_list list to store the list in. Note: it's presumed that it is big enough to store all vehicles in the game (worst case) and it will not check size
|
||||||
* @param type type of vehicle
|
* @param type type of vehicle
|
||||||
* @param owner PlayerID of owner to generate a list for
|
* @param owner PlayerID of owner to generate a list for
|
||||||
* @param station index of station to generate a list for. INVALID_STATION when not used
|
* @param station index of station to generate a list for. INVALID_STATION when not used
|
||||||
* @param order index of oder to generate a list for. INVALID_ORDER when not used
|
* @param order index of oder to generate a list for. INVALID_ORDER when not used
|
||||||
* @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h
|
* @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h
|
||||||
* @return the number of vehicles added to the list
|
* @return the number of vehicles added to the list
|
||||||
*/
|
*/
|
||||||
uint GenerateVehicleSortList(const Vehicle** sort_list, byte type, PlayerID owner, StationID station, OrderID order, uint16 window_type)
|
uint GenerateVehicleSortList(const Vehicle** sort_list, byte type, PlayerID owner, StationID station, OrderID order, uint16 window_type)
|
||||||
{
|
{
|
||||||
const uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
|
const uint subtype = (type != VEH_Aircraft) ? Train_Front : 2;
|
||||||
|
@ -1985,13 +1985,13 @@ uint GenerateVehicleSortList(const Vehicle** sort_list, byte type, PlayerID owne
|
||||||
}
|
}
|
||||||
|
|
||||||
/** send all vehicles of type to depots
|
/** send all vehicles of type to depots
|
||||||
* @param type type of vehicle
|
* @param type type of vehicle
|
||||||
* @param flags the flags used for DoCommand()
|
* @param flags the flags used for DoCommand()
|
||||||
* @param service should the vehicles only get service in the depots
|
* @param service should the vehicles only get service in the depots
|
||||||
* @param owner PlayerID of owner of the vehicles to send
|
* @param owner PlayerID of owner of the vehicles to send
|
||||||
* @param VLW_flag tells what kind of list requested the goto depot
|
* @param VLW_flag tells what kind of list requested the goto depot
|
||||||
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
|
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
|
||||||
*/
|
*/
|
||||||
int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
|
int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
|
||||||
{
|
{
|
||||||
const Vehicle** sort_list;
|
const Vehicle** sort_list;
|
||||||
|
@ -2544,7 +2544,7 @@ static void Load_VEHS(void)
|
||||||
|
|
||||||
if (CheckSavegameVersion(5)) {
|
if (CheckSavegameVersion(5)) {
|
||||||
/* Convert the current_order.type (which is a mix of type and flags, because
|
/* Convert the current_order.type (which is a mix of type and flags, because
|
||||||
in those versions, they both were 4 bits big) to type and flags */
|
* in those versions, they both were 4 bits big) to type and flags */
|
||||||
v->current_order.flags = (v->current_order.type & 0xF0) >> 4;
|
v->current_order.flags = (v->current_order.type & 0xF0) >> 4;
|
||||||
v->current_order.type = v->current_order.type & 0x0F;
|
v->current_order.type = v->current_order.type & 0x0F;
|
||||||
}
|
}
|
||||||
|
@ -2557,7 +2557,7 @@ static void Load_VEHS(void)
|
||||||
|
|
||||||
FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
|
FOR_ALL_VEHICLES_FROM(u, v->index + 1) {
|
||||||
/* If a vehicle has the same orders, add the link to eachother
|
/* If a vehicle has the same orders, add the link to eachother
|
||||||
in both vehicles */
|
* in both vehicles */
|
||||||
if (v->orders == u->orders) {
|
if (v->orders == u->orders) {
|
||||||
v->next_shared = u;
|
v->next_shared = u;
|
||||||
u->prev_shared = v;
|
u->prev_shared = v;
|
||||||
|
|
|
@ -625,10 +625,10 @@ static void DrawEngineArrayInReplaceWindow(Window *w, int x, int y, int x2, int
|
||||||
/* draw sorting criteria string */
|
/* draw sorting criteria string */
|
||||||
|
|
||||||
/* Ensure that custom engines which substituted wagons
|
/* Ensure that custom engines which substituted wagons
|
||||||
* are sorted correctly.
|
* are sorted correctly.
|
||||||
* XXX - DO NOT EVER DO THIS EVER AGAIN! GRRR hacking in wagons as
|
* XXX - DO NOT EVER DO THIS EVER AGAIN! GRRR hacking in wagons as
|
||||||
* engines to get more types.. Stays here until we have our own format
|
* engines to get more types.. Stays here until we have our own format
|
||||||
* then it is exit!!! */
|
* then it is exit!!! */
|
||||||
if (WP(w,replaceveh_d).wagon_btnstate) {
|
if (WP(w,replaceveh_d).wagon_btnstate) {
|
||||||
train_engine_drawing_loop(&x, &y, &pos, &sel[0], &selected_id[0], railtype, w->vscroll.cap, true, false, true, true); // True engines
|
train_engine_drawing_loop(&x, &y, &pos, &sel[0], &selected_id[0], railtype, w->vscroll.cap, true, false, true, true); // True engines
|
||||||
train_engine_drawing_loop(&x2, &y2, &pos2, &sel[1], &selected_id[1], railtype, w->vscroll.cap, true, false, false, false); // True engines
|
train_engine_drawing_loop(&x2, &y2, &pos2, &sel[1], &selected_id[1], railtype, w->vscroll.cap, true, false, false, false); // True engines
|
||||||
|
|
|
@ -1177,7 +1177,7 @@ static const char* QZ_SetVideoWindowed(uint width, uint height)
|
||||||
|
|
||||||
/* _cocoa_video_data.realpixels now points to the window's pixels
|
/* _cocoa_video_data.realpixels now points to the window's pixels
|
||||||
* We want it to point to the *view's* pixels
|
* We want it to point to the *view's* pixels
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int vOffset = [ _cocoa_video_data.window frame ].size.height - [ _cocoa_video_data.qdview frame ].size.height - [ _cocoa_video_data.qdview frame ].origin.y;
|
int vOffset = [ _cocoa_video_data.window frame ].size.height - [ _cocoa_video_data.qdview frame ].size.height - [ _cocoa_video_data.qdview frame ].origin.y;
|
||||||
int hOffset = [ _cocoa_video_data.qdview frame ].origin.x;
|
int hOffset = [ _cocoa_video_data.qdview frame ].origin.x;
|
||||||
|
|
6
window.c
6
window.c
|
@ -1271,9 +1271,9 @@ static void HandleKeypress(uint32 key)
|
||||||
{
|
{
|
||||||
Window *w;
|
Window *w;
|
||||||
WindowEvent we;
|
WindowEvent we;
|
||||||
/* Stores if a window with a textfield for typing is open
|
/* Stores if a window with a textfield for typing is open
|
||||||
* If this is the case, keypress events are only passed to windows with text fields and
|
* If this is the case, keypress events are only passed to windows with text fields and
|
||||||
* to thein this main toolbar. */
|
* to thein this main toolbar. */
|
||||||
bool query_open = false;
|
bool query_open = false;
|
||||||
|
|
||||||
// Setup event
|
// Setup event
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
#include "fixedsizearray.hpp"
|
#include "fixedsizearray.hpp"
|
||||||
|
|
||||||
/** Flexible array with size limit. Implemented as fixed size
|
/** Flexible array with size limit. Implemented as fixed size
|
||||||
array of fixed size arrays */
|
* array of fixed size arrays */
|
||||||
template <class Titem_, int Tblock_size_ = 1024, int Tnum_blocks_ = Tblock_size_>
|
template <class Titem_, int Tblock_size_ = 1024, int Tnum_blocks_ = Tblock_size_>
|
||||||
class CArrayT {
|
class CArrayT {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
#define AUTOCOPYPTR_HPP
|
#define AUTOCOPYPTR_HPP
|
||||||
|
|
||||||
/** CAutoCopyPtrT - kind of CoW (Copy on Write) pointer.
|
/** CAutoCopyPtrT - kind of CoW (Copy on Write) pointer.
|
||||||
It is non-invasive smart pointer (reference counter is held outside
|
* It is non-invasive smart pointer (reference counter is held outside
|
||||||
of Tdata).
|
* of Tdata).
|
||||||
When copied, its new copy shares the same underlaying structure Tdata.
|
* When copied, its new copy shares the same underlaying structure Tdata.
|
||||||
When dereferenced, its behavior depends on 2 factors:
|
* When dereferenced, its behavior depends on 2 factors:
|
||||||
- whether the data is shared (used by more than one pointer)
|
* - whether the data is shared (used by more than one pointer)
|
||||||
- type of access (read/write)
|
* - type of access (read/write)
|
||||||
When shared pointer is dereferenced for write, new clone of Tdata
|
* When shared pointer is dereferenced for write, new clone of Tdata
|
||||||
is made first.
|
* is made first.
|
||||||
Can't be used for polymorphic data types (interfaces).
|
* Can't be used for polymorphic data types (interfaces).
|
||||||
*/
|
*/
|
||||||
template <class Tdata_>
|
template <class Tdata_>
|
||||||
class CAutoCopyPtrT {
|
class CAutoCopyPtrT {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -10,22 +10,22 @@
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Binary Heap as C++ template.
|
* Binary Heap as C++ template.
|
||||||
*
|
*
|
||||||
* For information about Binary Heap algotithm,
|
* For information about Binary Heap algotithm,
|
||||||
* see: http://www.policyalmanac.org/games/binaryHeaps.htm
|
* see: http://www.policyalmanac.org/games/binaryHeaps.htm
|
||||||
*
|
*
|
||||||
* Implementation specific notes:
|
* Implementation specific notes:
|
||||||
*
|
*
|
||||||
* 1) It allocates space for item pointers (array). Items are allocated elsewhere.
|
* 1) It allocates space for item pointers (array). Items are allocated elsewhere.
|
||||||
*
|
*
|
||||||
* 2) ItemPtr [0] is never used. Total array size is max_items + 1, because we
|
* 2) ItemPtr [0] is never used. Total array size is max_items + 1, because we
|
||||||
* use indices 1..max_items instead of zero based C indexing.
|
* use indices 1..max_items instead of zero based C indexing.
|
||||||
*
|
*
|
||||||
* 3) Item of the binary heap should support these public members:
|
* 3) Item of the binary heap should support these public members:
|
||||||
* - 'lower-then' operator '<' - used for comparing items before moving
|
* - 'lower-then' operator '<' - used for comparing items before moving
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template <class Titem_>
|
template <class Titem_>
|
||||||
class CBinaryHeapT {
|
class CBinaryHeapT {
|
||||||
|
@ -53,23 +53,23 @@ public:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Return the number of items stored in the priority queue.
|
/** Return the number of items stored in the priority queue.
|
||||||
* @return number of items in the queue */
|
* @return number of items in the queue */
|
||||||
FORCEINLINE int Size() const {return m_size;};
|
FORCEINLINE int Size() const {return m_size;};
|
||||||
|
|
||||||
/** Test if the priority queue is empty.
|
/** Test if the priority queue is empty.
|
||||||
* @return true if empty */
|
* @return true if empty */
|
||||||
FORCEINLINE bool IsEmpty() const {return (m_size == 0);};
|
FORCEINLINE bool IsEmpty() const {return (m_size == 0);};
|
||||||
|
|
||||||
/** Test if the priority queue is full.
|
/** Test if the priority queue is full.
|
||||||
* @return true if full. */
|
* @return true if full. */
|
||||||
FORCEINLINE bool IsFull() const {return (m_size >= m_max_size);};
|
FORCEINLINE bool IsFull() const {return (m_size >= m_max_size);};
|
||||||
|
|
||||||
/** Find the smallest item in the priority queue.
|
/** Find the smallest item in the priority queue.
|
||||||
* Return the smallest item, or throw assert if empty. */
|
* Return the smallest item, or throw assert if empty. */
|
||||||
FORCEINLINE Titem_& GetHead() {assert(!IsEmpty()); return *m_items[1];}
|
FORCEINLINE Titem_& GetHead() {assert(!IsEmpty()); return *m_items[1];}
|
||||||
|
|
||||||
/** Insert new item into the priority queue, maintaining heap order.
|
/** Insert new item into the priority queue, maintaining heap order.
|
||||||
* @return false if the queue is full. */
|
* @return false if the queue is full. */
|
||||||
bool Push(Titem_& new_item);
|
bool Push(Titem_& new_item);
|
||||||
|
|
||||||
/** Remove and return the smallest item from the priority queue. */
|
/** Remove and return the smallest item from the priority queue. */
|
||||||
|
@ -85,7 +85,7 @@ public:
|
||||||
int FindLinear(const Titem_& item) const;
|
int FindLinear(const Titem_& item) const;
|
||||||
|
|
||||||
/** Make the priority queue empty.
|
/** Make the priority queue empty.
|
||||||
* All remaining items will remain untouched. */
|
* All remaining items will remain untouched. */
|
||||||
void Clear() {m_size = 0;};
|
void Clear() {m_size = 0;};
|
||||||
|
|
||||||
/** verifies the heap consistency (added during first YAPF debug phase) */
|
/** verifies the heap consistency (added during first YAPF debug phase) */
|
||||||
|
|
|
@ -11,14 +11,14 @@ FORCEINLINE void MemCpyT(Titem_* d, const Titem_* s, int num_items = 1)
|
||||||
|
|
||||||
|
|
||||||
/** Base class for simple binary blobs.
|
/** Base class for simple binary blobs.
|
||||||
Item is byte.
|
* Item is byte.
|
||||||
The word 'simple' means:
|
* The word 'simple' means:
|
||||||
- no configurable allocator type (always made from heap)
|
* - no configurable allocator type (always made from heap)
|
||||||
- no smart deallocation - deallocation must be called from the same
|
* - no smart deallocation - deallocation must be called from the same
|
||||||
module (DLL) where the blob was allocated
|
* module (DLL) where the blob was allocated
|
||||||
- no configurable allocation policy (how big blocks should be allocated)
|
* - no configurable allocation policy (how big blocks should be allocated)
|
||||||
- no extra ownership policy (i.e. 'copy on write') when blob is copied
|
* - no extra ownership policy (i.e. 'copy on write') when blob is copied
|
||||||
- no thread synchronization at all */
|
* - no thread synchronization at all */
|
||||||
class CBlobBaseSimple {
|
class CBlobBaseSimple {
|
||||||
protected:
|
protected:
|
||||||
struct CHdr {
|
struct CHdr {
|
||||||
|
@ -78,7 +78,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Reallocate if there is no free space for num_bytes bytes.
|
/** Reallocate if there is no free space for num_bytes bytes.
|
||||||
@return pointer to the new data to be added */
|
* @return pointer to the new data to be added */
|
||||||
FORCEINLINE int8* MakeRawFreeSpace(int num_bytes)
|
FORCEINLINE int8* MakeRawFreeSpace(int num_bytes)
|
||||||
{
|
{
|
||||||
assert(num_bytes >= 0);
|
assert(num_bytes >= 0);
|
||||||
|
@ -89,7 +89,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Increase RawSize() by num_bytes.
|
/** Increase RawSize() by num_bytes.
|
||||||
@return pointer to the new data added */
|
* @return pointer to the new data added */
|
||||||
FORCEINLINE int8* GrowRawSize(int num_bytes)
|
FORCEINLINE int8* GrowRawSize(int num_bytes)
|
||||||
{
|
{
|
||||||
int8* pNewData = MakeRawFreeSpace(num_bytes);
|
int8* pNewData = MakeRawFreeSpace(num_bytes);
|
||||||
|
|
|
@ -6,15 +6,15 @@
|
||||||
/** @file CCountedPtr - smart pointer implementation */
|
/** @file CCountedPtr - smart pointer implementation */
|
||||||
|
|
||||||
/** CCountedPtr - simple reference counting smart pointer.
|
/** CCountedPtr - simple reference counting smart pointer.
|
||||||
*
|
*
|
||||||
* One of the standard ways how to maintain object's lifetime.
|
* One of the standard ways how to maintain object's lifetime.
|
||||||
*
|
*
|
||||||
* See http://ootips.org/yonat/4dev/smart-pointers.html for more
|
* See http://ootips.org/yonat/4dev/smart-pointers.html for more
|
||||||
* general info about smart pointers.
|
* general info about smart pointers.
|
||||||
*
|
*
|
||||||
* This class implements ref-counted pointer for objects/interfaces that
|
* This class implements ref-counted pointer for objects/interfaces that
|
||||||
* support AddRef() and Release() methods.
|
* support AddRef() and Release() methods.
|
||||||
*/
|
*/
|
||||||
template <class Tcls_>
|
template <class Tcls_>
|
||||||
class CCountedPtr {
|
class CCountedPtr {
|
||||||
/** redefine the template argument to make it visible for derived classes */
|
/** redefine the template argument to make it visible for derived classes */
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
|
|
||||||
/** fixed size array
|
/** fixed size array
|
||||||
Upon construction it preallocates fixed size block of memory
|
* Upon construction it preallocates fixed size block of memory
|
||||||
for all items, but doesn't construct them. Item's construction
|
* for all items, but doesn't construct them. Item's construction
|
||||||
is delayed. */
|
* is delayed. */
|
||||||
template <class Titem_, int Tcapacity_>
|
template <class Titem_, int Tcapacity_>
|
||||||
struct CFixedSizeArrayT {
|
struct CFixedSizeArrayT {
|
||||||
/** the only member of fixed size array is pointer to the block
|
/** the only member of fixed size array is pointer to the block
|
||||||
of C array of items. Header can be found on the offset -sizeof(CHdr). */
|
* of C array of items. Header can be found on the offset -sizeof(CHdr). */
|
||||||
Titem_ *m_items;
|
Titem_ *m_items;
|
||||||
|
|
||||||
/** header for fixed size array */
|
/** header for fixed size array */
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
#include "yapf.hpp"
|
#include "yapf.hpp"
|
||||||
|
|
||||||
/** Track follower helper template class (can serve pathfinders and vehicle
|
/** Track follower helper template class (can serve pathfinders and vehicle
|
||||||
controllers). See 6 different typedefs below for 3 different transport
|
* controllers). See 6 different typedefs below for 3 different transport
|
||||||
types w/ of w/o 90-deg turns allowed */
|
* types w/ of w/o 90-deg turns allowed */
|
||||||
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true>
|
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true>
|
||||||
struct CFollowTrackT : public FollowTrack_t
|
struct CFollowTrackT : public FollowTrack_t
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ struct CFollowTrackT : public FollowTrack_t
|
||||||
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
|
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;}
|
||||||
|
|
||||||
/** main follower routine. Fills all members and return true on success.
|
/** main follower routine. Fills all members and return true on success.
|
||||||
Otherwise returns false if track can't be followed. */
|
* Otherwise returns false if track can't be followed. */
|
||||||
FORCEINLINE bool Follow(TileIndex old_tile, Trackdir old_td)
|
FORCEINLINE bool Follow(TileIndex old_tile, Trackdir old_td)
|
||||||
{
|
{
|
||||||
m_old_tile = old_tile;
|
m_old_tile = old_tile;
|
||||||
|
|
|
@ -95,26 +95,26 @@ struct CHashTableSlotT
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @class CHashTableT<Titem, Thash_bits> - simple hash table
|
/** @class CHashTableT<Titem, Thash_bits> - simple hash table
|
||||||
of pointers allocated elsewhere.
|
* of pointers allocated elsewhere.
|
||||||
|
*
|
||||||
Supports: Add/Find/Remove of Titems.
|
* Supports: Add/Find/Remove of Titems.
|
||||||
|
*
|
||||||
Your Titem must meet some extra requirements to be CHashTableT
|
* Your Titem must meet some extra requirements to be CHashTableT
|
||||||
compliant:
|
* compliant:
|
||||||
- its constructor/destructor (if any) must be public
|
* - its constructor/destructor (if any) must be public
|
||||||
- if the copying of item requires an extra resource management,
|
* - if the copying of item requires an extra resource management,
|
||||||
you must define also copy constructor
|
* you must define also copy constructor
|
||||||
- must support nested type (struct, class or typedef) Titem::Key
|
* - must support nested type (struct, class or typedef) Titem::Key
|
||||||
that defines the type of key class for that item
|
* that defines the type of key class for that item
|
||||||
- must support public method:
|
* - must support public method:
|
||||||
const Key& GetKey() const; // return the item's key object
|
* const Key& GetKey() const; // return the item's key object
|
||||||
|
*
|
||||||
In addition, the Titem::Key class must support:
|
* In addition, the Titem::Key class must support:
|
||||||
- public method that calculates key's hash:
|
* - public method that calculates key's hash:
|
||||||
int CalcHash() const;
|
* int CalcHash() const;
|
||||||
- public 'equality' operator to compare the key with another one
|
* - public 'equality' operator to compare the key with another one
|
||||||
bool operator == (const Key& other) const;
|
* bool operator == (const Key& other) const;
|
||||||
*/
|
*/
|
||||||
template <class Titem_, int Thash_bits_>
|
template <class Titem_, int Thash_bits_>
|
||||||
class CHashTableT {
|
class CHashTableT {
|
||||||
public:
|
public:
|
||||||
|
@ -125,7 +125,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** each slot contains pointer to the first item in the list,
|
/** each slot contains pointer to the first item in the list,
|
||||||
Titem contains pointer to the next item - GetHashNext(), SetHashNext() */
|
* Titem contains pointer to the next item - GetHashNext(), SetHashNext() */
|
||||||
typedef CHashTableSlotT<Titem_> Slot;
|
typedef CHashTableSlotT<Titem_> Slot;
|
||||||
|
|
||||||
Slot* m_slots; // here we store our data (array of blobs)
|
Slot* m_slots; // here we store our data (array of blobs)
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
#include "binaryheap.hpp"
|
#include "binaryheap.hpp"
|
||||||
|
|
||||||
/** Hash table based node list multi-container class.
|
/** Hash table based node list multi-container class.
|
||||||
Implements open list, closed list and priority queue for A-star
|
* Implements open list, closed list and priority queue for A-star
|
||||||
path finder. */
|
* path finder. */
|
||||||
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
|
template <class Titem_, int Thash_bits_open_, int Thash_bits_closed_>
|
||||||
class CNodeList_HashTableT {
|
class CNodeList_HashTableT {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -160,8 +160,8 @@ struct CYapfTestBaseT
|
||||||
FORCEINLINE char TransportTypeChar() const {return 'T';}
|
FORCEINLINE char TransportTypeChar() const {return 'T';}
|
||||||
|
|
||||||
/** Called by YAPF to move from the given node to the next tile. For each
|
/** Called by YAPF to move from the given node to the next tile. For each
|
||||||
* reachable trackdir on the new tile creates new node, initializes it
|
* reachable trackdir on the new tile creates new node, initializes it
|
||||||
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
||||||
FORCEINLINE void PfFollowNode(Node& org)
|
FORCEINLINE void PfFollowNode(Node& org)
|
||||||
{
|
{
|
||||||
int x_org = org.m_key.m_x;
|
int x_org = org.m_key.m_x;
|
||||||
|
@ -207,8 +207,8 @@ struct CYapfTestBaseT
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate the cost from the origin to the given node.
|
/** Called by YAPF to calculate the cost from the origin to the given node.
|
||||||
* Calculates only the cost of given node, adds it to the parent node cost
|
* Calculates only the cost of given node, adds it to the parent node cost
|
||||||
* and stores the result into Node::m_cost member */
|
* and stores the result into Node::m_cost member */
|
||||||
FORCEINLINE bool PfCalcCost(Node& n)
|
FORCEINLINE bool PfCalcCost(Node& n)
|
||||||
{
|
{
|
||||||
// base tile cost depending on distance
|
// base tile cost depending on distance
|
||||||
|
@ -225,7 +225,7 @@ struct CYapfTestBaseT
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
||||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||||
{
|
{
|
||||||
int dx = abs(n.m_key.m_x - m_x2);
|
int dx = abs(n.m_key.m_x - m_x2);
|
||||||
|
|
|
@ -109,23 +109,23 @@ const TileIndexDiffC _tileoffs_by_dir[] = {
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
const byte _ffb_64[128] = {
|
const byte _ffb_64[128] = {
|
||||||
0,0,1,0,2,0,1,0,
|
0, 0, 1, 0, 2, 0, 1, 0,
|
||||||
3,0,1,0,2,0,1,0,
|
3, 0, 1, 0, 2, 0, 1, 0,
|
||||||
4,0,1,0,2,0,1,0,
|
4, 0, 1, 0, 2, 0, 1, 0,
|
||||||
3,0,1,0,2,0,1,0,
|
3, 0, 1, 0, 2, 0, 1, 0,
|
||||||
5,0,1,0,2,0,1,0,
|
5, 0, 1, 0, 2, 0, 1, 0,
|
||||||
3,0,1,0,2,0,1,0,
|
3, 0, 1, 0, 2, 0, 1, 0,
|
||||||
4,0,1,0,2,0,1,0,
|
4, 0, 1, 0, 2, 0, 1, 0,
|
||||||
3,0,1,0,2,0,1,0,
|
3, 0, 1, 0, 2, 0, 1, 0,
|
||||||
|
|
||||||
0,0,0,2,0,4,4,6,
|
0, 0, 0, 2, 0, 4, 4, 6,
|
||||||
0,8,8,10,8,12,12,14,
|
0, 8, 8, 10, 8, 12, 12, 14,
|
||||||
0,16,16,18,16,20,20,22,
|
0, 16, 16, 18, 16, 20, 20, 22,
|
||||||
16,24,24,26,24,28,28,30,
|
16, 24, 24, 26, 24, 28, 28, 30,
|
||||||
0,32,32,34,32,36,36,38,
|
0, 32, 32, 34, 32, 36, 36, 38,
|
||||||
32,40,40,42,40,44,44,46,
|
32, 40, 40, 42, 40, 44, 44, 46,
|
||||||
32,48,48,50,48,52,52,54,
|
32, 48, 48, 50, 48, 52, 52, 54,
|
||||||
48,56,56,58,56,60,60,62,
|
48, 56, 56, 58, 56, 60, 60, 62,
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Maps a trackdir to the (4-way) direction the tile is exited when following
|
/* Maps a trackdir to the (4-way) direction the tile is exited when following
|
||||||
|
|
86
yapf/yapf.h
86
yapf/yapf.h
|
@ -6,54 +6,54 @@
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
|
|
||||||
/** Finds the best path for given ship.
|
/** Finds the best path for given ship.
|
||||||
@param v - the ship that needs to find a path
|
* @param v the ship that needs to find a path
|
||||||
@param tile - the tile to find the path from (should be next tile the ship is about to enter)
|
* @param tile the tile to find the path from (should be next tile the ship is about to enter)
|
||||||
@param enterdir - diagonal direction which the ship will enter this new tile from
|
* @param enterdir diagonal direction which the ship will enter this new tile from
|
||||||
@param tracks - available tracks on the new tile (to choose from)
|
* @param tracks available tracks on the new tile (to choose from)
|
||||||
@return - the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
||||||
*/
|
*/
|
||||||
Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
|
Trackdir YapfChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks);
|
||||||
|
|
||||||
/** Finds the best path for given road vehicle.
|
/** Finds the best path for given road vehicle.
|
||||||
@param v - the RV that needs to find a path
|
* @param v the RV that needs to find a path
|
||||||
@param tile - the tile to find the path from (should be next tile the RV is about to enter)
|
* @param tile the tile to find the path from (should be next tile the RV is about to enter)
|
||||||
@param enterdir - diagonal direction which the RV will enter this new tile from
|
* @param enterdir diagonal direction which the RV will enter this new tile from
|
||||||
@param tracks - available tracks on the new tile (to choose from)
|
* @param tracks available tracks on the new tile (to choose from)
|
||||||
@return - the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
||||||
*/
|
*/
|
||||||
Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
|
Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
|
||||||
|
|
||||||
/** Finds the best path for given train.
|
/** Finds the best path for given train.
|
||||||
@param v - the train that needs to find a path
|
* @param v the train that needs to find a path
|
||||||
@param tile - the tile to find the path from (should be next tile the train is about to enter)
|
* @param tile the tile to find the path from (should be next tile the train is about to enter)
|
||||||
@param enterdir - diagonal direction which the RV will enter this new tile from
|
* @param enterdir diagonal direction which the RV will enter this new tile from
|
||||||
@param tracks - available tracks on the new tile (to choose from)
|
* @param tracks available tracks on the new tile (to choose from)
|
||||||
@return - the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
|
||||||
*/
|
*/
|
||||||
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs);
|
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirs);
|
||||||
|
|
||||||
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
|
/** Used by RV multistop feature to find the nearest road stop that has a free slot.
|
||||||
@param v - RV (its current tile will be the origin)
|
* @param v RV (its current tile will be the origin)
|
||||||
@param tile - destination tile
|
* @param tile destination tile
|
||||||
@return - distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
|
* @return distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found
|
||||||
*/
|
*/
|
||||||
uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile);
|
uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile);
|
||||||
|
|
||||||
/** Used when user sends RV to the nearest depot or if RV needs servicing.
|
/** Used when user sends RV to the nearest depot or if RV needs servicing.
|
||||||
Returns the nearest depot (or NULL if depot was not found).
|
* Returns the nearest depot (or NULL if depot was not found).
|
||||||
*/
|
*/
|
||||||
Depot* YapfFindNearestRoadDepot(const Vehicle *v);
|
Depot* YapfFindNearestRoadDepot(const Vehicle *v);
|
||||||
|
|
||||||
/** Used when user sends train to the nearest depot or if train needs servicing.
|
/** Used when user sends train to the nearest depot or if train needs servicing.
|
||||||
@v - train that needs to go to some depot
|
* @v train that needs to go to some depot
|
||||||
@max_distance - max distance (number of track tiles) from the current train position
|
* @max_distance max distance (number of track tiles) from the current train position
|
||||||
(used also as optimization - the pathfinder can stop path finding if max_distance
|
* (used also as optimization - the pathfinder can stop path finding if max_distance
|
||||||
was reached and no depot was seen)
|
* was reached and no depot was seen)
|
||||||
@reverse_penalty - penalty that should be added for the path that requires reversing the train first
|
* @reverse_penalty penalty that should be added for the path that requires reversing the train first
|
||||||
@depot_tile - receives the depot tile if depot was found
|
* @depot_tile receives the depot tile if depot was found
|
||||||
@reversed - receives true if train needs to reversed first
|
* @reversed receives true if train needs to reversed first
|
||||||
@return - the true if depot was found.
|
* @return the true if depot was found.
|
||||||
*/
|
*/
|
||||||
bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed);
|
bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed);
|
||||||
|
|
||||||
/** Returns true if it is better to reverse the train before leaving station */
|
/** Returns true if it is better to reverse the train before leaving station */
|
||||||
|
@ -72,17 +72,17 @@ extern int _aystar_stats_closed_size;
|
||||||
|
|
||||||
|
|
||||||
/** Track followers. They should help whenever any new code will need to walk through
|
/** Track followers. They should help whenever any new code will need to walk through
|
||||||
tracks, road or water tiles (pathfinders, signal controllers, vehicle controllers).
|
* tracks, road or water tiles (pathfinders, signal controllers, vehicle controllers).
|
||||||
It is an attempt to introduce API that should simplify tasks listed above.
|
* It is an attempt to introduce API that should simplify tasks listed above.
|
||||||
If you will need to use it:
|
* If you will need to use it:
|
||||||
1. allocate/declare FollowTrack_t structure;
|
* 1. allocate/declare FollowTrack_t structure;
|
||||||
2. call FollowTrackInit() and provide vehicle (if relevant)
|
* 2. call FollowTrackInit() and provide vehicle (if relevant)
|
||||||
3. call one of 6 FollowTrackXxxx() APIs below
|
* 3. call one of 6 FollowTrackXxxx() APIs below
|
||||||
4. check return value (if true then continue else stop)
|
* 4. check return value (if true then continue else stop)
|
||||||
5. look at FollowTrack_t structure for the result
|
* 5. look at FollowTrack_t structure for the result
|
||||||
6. optionally repeat steps 3..5
|
* 6. optionally repeat steps 3..5
|
||||||
7. in case of troubles contact KUDr
|
* 7. in case of troubles contact KUDr
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** Base struct for track followers. */
|
/** Base struct for track followers. */
|
||||||
typedef struct FollowTrack_t
|
typedef struct FollowTrack_t
|
||||||
|
|
|
@ -14,34 +14,34 @@ EXTERN_C_END
|
||||||
extern int _total_pf_time_us;
|
extern int _total_pf_time_us;
|
||||||
|
|
||||||
/** CYapfBaseT - A-star type path finder base class.
|
/** CYapfBaseT - A-star type path finder base class.
|
||||||
Derive your own pathfinder from it. You must provide the following template argument:
|
* Derive your own pathfinder from it. You must provide the following template argument:
|
||||||
Types - used as collection of local types used in pathfinder
|
* Types - used as collection of local types used in pathfinder
|
||||||
|
*
|
||||||
Requirements for the Types struct:
|
* Requirements for the Types struct:
|
||||||
----------------------------------
|
* ----------------------------------
|
||||||
The following types must be defined in the 'Types' argument:
|
* The following types must be defined in the 'Types' argument:
|
||||||
- Types::Tpf - your pathfinder derived from CYapfBaseT
|
* - Types::Tpf - your pathfinder derived from CYapfBaseT
|
||||||
- Types::NodeList - open/closed node list (look at CNodeList_HashTableT)
|
* - Types::NodeList - open/closed node list (look at CNodeList_HashTableT)
|
||||||
NodeList needs to have defined local type Titem - defines the pathfinder node type.
|
* NodeList needs to have defined local type Titem - defines the pathfinder node type.
|
||||||
Node needs to define local type Key - the node key in the collection ()
|
* Node needs to define local type Key - the node key in the collection ()
|
||||||
|
*
|
||||||
For node list you can use template class CNodeList_HashTableT, for which
|
* For node list you can use template class CNodeList_HashTableT, for which
|
||||||
you need to declare only your node type. Look at test_yapf.h for an example.
|
* you need to declare only your node type. Look at test_yapf.h for an example.
|
||||||
|
*
|
||||||
|
*
|
||||||
Requrements to your pathfinder class derived from CYapfBaseT:
|
* Requrements to your pathfinder class derived from CYapfBaseT:
|
||||||
-------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
Your pathfinder derived class needs to implement following methods:
|
* Your pathfinder derived class needs to implement following methods:
|
||||||
FORCEINLINE void PfSetStartupNodes()
|
* FORCEINLINE void PfSetStartupNodes()
|
||||||
FORCEINLINE void PfFollowNode(Node& org)
|
* FORCEINLINE void PfFollowNode(Node& org)
|
||||||
FORCEINLINE bool PfCalcCost(Node& n)
|
* FORCEINLINE bool PfCalcCost(Node& n)
|
||||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
* FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||||
FORCEINLINE bool PfDetectDestination(Node& n)
|
* FORCEINLINE bool PfDetectDestination(Node& n)
|
||||||
|
*
|
||||||
For more details about those methods, look at the end of CYapfBaseT
|
* For more details about those methods, look at the end of CYapfBaseT
|
||||||
declaration. There are some examples. For another example look at
|
* declaration. There are some examples. For another example look at
|
||||||
test_yapf.h (part or unittest project).
|
* test_yapf.h (part or unittest project).
|
||||||
*/
|
*/
|
||||||
template <class Types>
|
template <class Types>
|
||||||
class CYapfBaseT {
|
class CYapfBaseT {
|
||||||
public:
|
public:
|
||||||
|
@ -105,12 +105,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Main pathfinder routine:
|
/** Main pathfinder routine:
|
||||||
- set startup node(s)
|
* - set startup node(s)
|
||||||
- main loop that stops if:
|
* - main loop that stops if:
|
||||||
- the destination was found
|
* - the destination was found
|
||||||
- or the open list is empty (no route to destination).
|
* - or the open list is empty (no route to destination).
|
||||||
- or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
|
* - or the maximum amount of loops reached - m_max_search_nodes (default = 10000)
|
||||||
@return true if the path was found */
|
* @return true if the path was found */
|
||||||
inline bool FindPath(const Vehicle* v)
|
inline bool FindPath(const Vehicle* v)
|
||||||
{
|
{
|
||||||
m_veh = v;
|
m_veh = v;
|
||||||
|
@ -160,16 +160,16 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** If path was found return the best node that has reached the destination. Otherwise
|
/** If path was found return the best node that has reached the destination. Otherwise
|
||||||
return the best visited node (which was nearest to the destination).
|
* return the best visited node (which was nearest to the destination).
|
||||||
*/
|
*/
|
||||||
FORCEINLINE Node& GetBestNode()
|
FORCEINLINE Node& GetBestNode()
|
||||||
{
|
{
|
||||||
return (m_pBestDestNode != NULL) ? *m_pBestDestNode : *m_pBestIntermediateNode;
|
return (m_pBestDestNode != NULL) ? *m_pBestDestNode : *m_pBestIntermediateNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used
|
/** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used
|
||||||
as argument for AddStartupNode() or AddNewNode()
|
* as argument for AddStartupNode() or AddNewNode()
|
||||||
*/
|
*/
|
||||||
FORCEINLINE Node& CreateNewNode()
|
FORCEINLINE Node& CreateNewNode()
|
||||||
{
|
{
|
||||||
Node& node = *m_nodes.CreateNewNode();
|
Node& node = *m_nodes.CreateNewNode();
|
||||||
|
@ -203,7 +203,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** AddNewNode() - called by Tderived::PfFollowNode() for each child node.
|
/** AddNewNode() - called by Tderived::PfFollowNode() for each child node.
|
||||||
Nodes are evaluated here and added into open list */
|
* Nodes are evaluated here and added into open list */
|
||||||
void AddNewNode(Node& n)
|
void AddNewNode(Node& n)
|
||||||
{
|
{
|
||||||
// evaluate the node
|
// evaluate the node
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
||||||
inline bool PfCalcEstimate(Node& n)
|
inline bool PfCalcEstimate(Node& n)
|
||||||
{
|
{
|
||||||
int dx = abs(TileX(n.GetTile()) - TileX(m_destTile));
|
int dx = abs(TileX(n.GetTile()) - TileX(m_destTile));
|
||||||
|
@ -144,9 +144,9 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** YAPF template that uses Ttypes template argument to determine all YAPF
|
/** YAPF template that uses Ttypes template argument to determine all YAPF
|
||||||
* components (base classes) from which the actual YAPF is composed.
|
* components (base classes) from which the actual YAPF is composed.
|
||||||
* For example classes consult: CYapfRail_TypesT template and its instantiations:
|
* For example classes consult: CYapfRail_TypesT template and its instantiations:
|
||||||
* CYapfRail1, CYapfRail2, CYapfRail3, CYapfAnyDepotRail1, CYapfAnyDepotRail2, CYapfAnyDepotRail3 */
|
* CYapfRail1, CYapfRail2, CYapfRail3, CYapfAnyDepotRail1, CYapfAnyDepotRail2, CYapfAnyDepotRail3 */
|
||||||
template <class Ttypes>
|
template <class Ttypes>
|
||||||
class CYapfT
|
class CYapfT
|
||||||
: public Ttypes::PfBase ///< Instance of CYapfBaseT - main YAPF loop and support base class
|
: public Ttypes::PfBase ///< Instance of CYapfBaseT - main YAPF loop and support base class
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
|
|
||||||
/** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements
|
/** CYapfSegmentCostCacheNoneT - the formal only yapf cost cache provider that implements
|
||||||
PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData
|
* PfNodeCacheFetch() and PfNodeCacheFlush() callbacks. Used when nodes don't have CachedData
|
||||||
defined (they don't count with any segment cost caching).
|
* defined (they don't count with any segment cost caching).
|
||||||
*/
|
*/
|
||||||
template <class Types>
|
template <class Types>
|
||||||
class CYapfSegmentCostCacheNoneT
|
class CYapfSegmentCostCacheNoneT
|
||||||
{
|
{
|
||||||
|
@ -15,14 +15,14 @@ public:
|
||||||
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
typedef typename Types::NodeList::Titem Node; ///< this will be our node type
|
||||||
|
|
||||||
/** Called by YAPF to attach cached or local segment cost data to the given node.
|
/** Called by YAPF to attach cached or local segment cost data to the given node.
|
||||||
* @return true if globally cached data were used or false if local data was used */
|
* @return true if globally cached data were used or false if local data was used */
|
||||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Called by YAPF to flush the cached segment cost data back into cache storage.
|
/** Called by YAPF to flush the cached segment cost data back into cache storage.
|
||||||
* Current cache implementation doesn't use that. */
|
* Current cache implementation doesn't use that. */
|
||||||
FORCEINLINE void PfNodeCacheFlush(Node& n)
|
FORCEINLINE void PfNodeCacheFlush(Node& n)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
@ -30,9 +30,9 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/** CYapfSegmentCostCacheLocalT - the yapf cost cache provider that implements fake segment
|
/** CYapfSegmentCostCacheLocalT - the yapf cost cache provider that implements fake segment
|
||||||
cost caching functionality for yapf. Used when node needs caching, but you don't want to
|
* cost caching functionality for yapf. Used when node needs caching, but you don't want to
|
||||||
cache the segment costs.
|
* cache the segment costs.
|
||||||
*/
|
*/
|
||||||
template <class Types>
|
template <class Types>
|
||||||
class CYapfSegmentCostCacheLocalT
|
class CYapfSegmentCostCacheLocalT
|
||||||
{
|
{
|
||||||
|
@ -52,7 +52,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to attach cached or local segment cost data to the given node.
|
/** Called by YAPF to attach cached or local segment cost data to the given node.
|
||||||
* @return true if globally cached data were used or false if local data was used */
|
* @return true if globally cached data were used or false if local data was used */
|
||||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||||
{
|
{
|
||||||
CacheKey key(n.GetKey());
|
CacheKey key(n.GetKey());
|
||||||
|
@ -61,7 +61,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Called by YAPF to flush the cached segment cost data back into cache storage.
|
/** Called by YAPF to flush the cached segment cost data back into cache storage.
|
||||||
* Current cache implementation doesn't use that. */
|
* Current cache implementation doesn't use that. */
|
||||||
FORCEINLINE void PfNodeCacheFlush(Node& n)
|
FORCEINLINE void PfNodeCacheFlush(Node& n)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
@ -69,10 +69,10 @@ public:
|
||||||
|
|
||||||
|
|
||||||
/** Base class for segment cost cache providers. Contains global counter
|
/** Base class for segment cost cache providers. Contains global counter
|
||||||
* of track layout changes and static notification function called whenever
|
* of track layout changes and static notification function called whenever
|
||||||
* the track layout changes. It is implemented as base class because it needs
|
* the track layout changes. It is implemented as base class because it needs
|
||||||
* to be shared between all rail YAPF types (one shared counter, one notification
|
* to be shared between all rail YAPF types (one shared counter, one notification
|
||||||
* function. */
|
* function. */
|
||||||
struct CSegmentCostCacheBase
|
struct CSegmentCostCacheBase
|
||||||
{
|
{
|
||||||
static int s_rail_change_counter;
|
static int s_rail_change_counter;
|
||||||
|
@ -82,13 +82,13 @@ struct CSegmentCostCacheBase
|
||||||
|
|
||||||
|
|
||||||
/** CSegmentCostCacheT - template class providing hash-map and storage (heap)
|
/** CSegmentCostCacheT - template class providing hash-map and storage (heap)
|
||||||
of Tsegment structures. Each rail node contains pointer to the segment
|
* of Tsegment structures. Each rail node contains pointer to the segment
|
||||||
that contains cached (or non-cached) segment cost information. Nodes can
|
* that contains cached (or non-cached) segment cost information. Nodes can
|
||||||
differ by key type, but they use the same segment type. Segment key should
|
* differ by key type, but they use the same segment type. Segment key should
|
||||||
be always the same (TileIndex + DiagDirection) that represent the beginning
|
* be always the same (TileIndex + DiagDirection) that represent the beginning
|
||||||
of the segment (origin tile and exit-dir from this tile).
|
* of the segment (origin tile and exit-dir from this tile).
|
||||||
Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT.
|
* Different CYapfCachedCostT types can share the same type of CSegmentCostCacheT.
|
||||||
Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */
|
* Look at CYapfRailSegment (yapf_node_rail.hpp) for the segment example */
|
||||||
template <class Tsegment>
|
template <class Tsegment>
|
||||||
struct CSegmentCostCacheT
|
struct CSegmentCostCacheT
|
||||||
: public CSegmentCostCacheBase
|
: public CSegmentCostCacheBase
|
||||||
|
@ -119,8 +119,8 @@ struct CSegmentCostCacheT
|
||||||
};
|
};
|
||||||
|
|
||||||
/** CYapfSegmentCostCacheGlobalT - the yapf cost cache provider that adds the segment cost
|
/** CYapfSegmentCostCacheGlobalT - the yapf cost cache provider that adds the segment cost
|
||||||
caching functionality to yapf. Using this class as base of your will provide the global
|
* caching functionality to yapf. Using this class as base of your will provide the global
|
||||||
segment cost caching services for your Nodes.
|
* segment cost caching services for your Nodes.
|
||||||
*/
|
*/
|
||||||
template <class Types>
|
template <class Types>
|
||||||
class CYapfSegmentCostCacheGlobalT
|
class CYapfSegmentCostCacheGlobalT
|
||||||
|
@ -173,7 +173,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to attach cached or local segment cost data to the given node.
|
/** Called by YAPF to attach cached or local segment cost data to the given node.
|
||||||
* @return true if globally cached data were used or false if local data was used */
|
* @return true if globally cached data were used or false if local data was used */
|
||||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||||
{
|
{
|
||||||
if (!Yapf().CanUseGlobalCache(n)) {
|
if (!Yapf().CanUseGlobalCache(n)) {
|
||||||
|
@ -187,7 +187,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Called by YAPF to flush the cached segment cost data back into cache storage.
|
/** Called by YAPF to flush the cached segment cost data back into cache storage.
|
||||||
* Current cache implementation doesn't use that. */
|
* Current cache implementation doesn't use that. */
|
||||||
FORCEINLINE void PfNodeCacheFlush(Node& n)
|
FORCEINLINE void PfNodeCacheFlush(Node& n)
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
|
@ -160,8 +160,8 @@ public:
|
||||||
FORCEINLINE void SetMaxCost(int max_cost) {m_max_cost = max_cost;}
|
FORCEINLINE void SetMaxCost(int max_cost) {m_max_cost = max_cost;}
|
||||||
|
|
||||||
/** Called by YAPF to calculate the cost from the origin to the given node.
|
/** Called by YAPF to calculate the cost from the origin to the given node.
|
||||||
* Calculates only the cost of given node, adds it to the parent node cost
|
* Calculates only the cost of given node, adds it to the parent node cost
|
||||||
* and stores the result into Node::m_cost member */
|
* and stores the result into Node::m_cost member */
|
||||||
FORCEINLINE bool PfCalcCost(Node& n)
|
FORCEINLINE bool PfCalcCost(Node& n)
|
||||||
{
|
{
|
||||||
assert(!n.flags_u.flags_s.m_targed_seen);
|
assert(!n.flags_u.flags_s.m_targed_seen);
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
||||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||||
{
|
{
|
||||||
n.m_estimate = n.m_cost;
|
n.m_estimate = n.m_cost;
|
||||||
|
@ -118,7 +118,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
||||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||||
{
|
{
|
||||||
static int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
static int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
||||||
|
|
|
@ -28,8 +28,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to move from the given node to the next tile. For each
|
/** Called by YAPF to move from the given node to the next tile. For each
|
||||||
* reachable trackdir on the new tile creates new node, initializes it
|
* reachable trackdir on the new tile creates new node, initializes it
|
||||||
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
||||||
inline void PfFollowNode(Node& old_node)
|
inline void PfFollowNode(Node& old_node)
|
||||||
{
|
{
|
||||||
TrackFollower F(Yapf().GetVehicle());
|
TrackFollower F(Yapf().GetVehicle());
|
||||||
|
@ -91,8 +91,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to move from the given node to the next tile. For each
|
/** Called by YAPF to move from the given node to the next tile. For each
|
||||||
* reachable trackdir on the new tile creates new node, initializes it
|
* reachable trackdir on the new tile creates new node, initializes it
|
||||||
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
||||||
inline void PfFollowNode(Node& old_node)
|
inline void PfFollowNode(Node& old_node)
|
||||||
{
|
{
|
||||||
TrackFollower F(Yapf().GetVehicle());
|
TrackFollower F(Yapf().GetVehicle());
|
||||||
|
|
|
@ -64,8 +64,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to calculate the cost from the origin to the given node.
|
/** Called by YAPF to calculate the cost from the origin to the given node.
|
||||||
* Calculates only the cost of given node, adds it to the parent node cost
|
* Calculates only the cost of given node, adds it to the parent node cost
|
||||||
* and stores the result into Node::m_cost member */
|
* and stores the result into Node::m_cost member */
|
||||||
FORCEINLINE bool PfCalcCost(Node& n)
|
FORCEINLINE bool PfCalcCost(Node& n)
|
||||||
{
|
{
|
||||||
int segment_cost = 0;
|
int segment_cost = 0;
|
||||||
|
@ -144,7 +144,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
||||||
FORCEINLINE bool PfCalcEstimate(Node& n)
|
FORCEINLINE bool PfCalcEstimate(Node& n)
|
||||||
{
|
{
|
||||||
n.m_estimate = n.m_cost;
|
n.m_estimate = n.m_cost;
|
||||||
|
@ -186,7 +186,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
/** Called by YAPF to calculate cost estimate. Calculates distance to the destination
|
||||||
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
* adds it to the actual cost from origin and stores the sum to the Node::m_estimate */
|
||||||
inline bool PfCalcEstimate(Node& n)
|
inline bool PfCalcEstimate(Node& n)
|
||||||
{
|
{
|
||||||
static int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
static int dg_dir_to_x_offs[] = {-1, 0, 1, 0};
|
||||||
|
@ -231,8 +231,8 @@ protected:
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/** Called by YAPF to move from the given node to the next tile. For each
|
/** Called by YAPF to move from the given node to the next tile. For each
|
||||||
* reachable trackdir on the new tile creates new node, initializes it
|
* reachable trackdir on the new tile creates new node, initializes it
|
||||||
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
||||||
inline void PfFollowNode(Node& old_node)
|
inline void PfFollowNode(Node& old_node)
|
||||||
{
|
{
|
||||||
TrackFollower F(Yapf().GetVehicle());
|
TrackFollower F(Yapf().GetVehicle());
|
||||||
|
|
|
@ -7,15 +7,15 @@
|
||||||
|
|
||||||
# ifndef YS_DEF
|
# ifndef YS_DEF
|
||||||
/*
|
/*
|
||||||
* if YS_DEF is not defined, we will only do following declaration:
|
* if YS_DEF is not defined, we will only do following declaration:
|
||||||
* typedef struct YapfSettings {
|
* typedef struct YapfSettings {
|
||||||
* bool disable_node_optimization;
|
* bool disable_node_optimization;
|
||||||
* uint32 max_search_nodes;
|
* uint32 max_search_nodes;
|
||||||
* .... all other yapf related settings ...
|
* .... all other yapf related settings ...
|
||||||
* } YapfSettings;
|
* } YapfSettings;
|
||||||
*
|
*
|
||||||
* otherwise we will just expand YS_DEF_xx macros and then #undef them
|
* otherwise we will just expand YS_DEF_xx macros and then #undef them
|
||||||
*/
|
*/
|
||||||
# define YS_DEF_BEGIN typedef struct YapfSettings {
|
# define YS_DEF_BEGIN typedef struct YapfSettings {
|
||||||
# define YS_DEF(type, name) type name;
|
# define YS_DEF(type, name) type name;
|
||||||
# define YS_DEF_END } YapfSettings;
|
# define YS_DEF_END } YapfSettings;
|
||||||
|
|
|
@ -20,8 +20,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to move from the given node to the next tile. For each
|
/** Called by YAPF to move from the given node to the next tile. For each
|
||||||
* reachable trackdir on the new tile creates new node, initializes it
|
* reachable trackdir on the new tile creates new node, initializes it
|
||||||
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
* and adds it to the open list by calling Yapf().AddNewNode(n) */
|
||||||
inline void PfFollowNode(Node& old_node)
|
inline void PfFollowNode(Node& old_node)
|
||||||
{
|
{
|
||||||
TrackFollower F;
|
TrackFollower F;
|
||||||
|
@ -95,8 +95,8 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** Called by YAPF to calculate the cost from the origin to the given node.
|
/** Called by YAPF to calculate the cost from the origin to the given node.
|
||||||
* Calculates only the cost of given node, adds it to the parent node cost
|
* Calculates only the cost of given node, adds it to the parent node cost
|
||||||
* and stores the result into Node::m_cost member */
|
* and stores the result into Node::m_cost member */
|
||||||
FORCEINLINE bool PfCalcCost(Node& n)
|
FORCEINLINE bool PfCalcCost(Node& n)
|
||||||
{
|
{
|
||||||
// base tile cost depending on distance
|
// base tile cost depending on distance
|
||||||
|
@ -110,8 +110,8 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Config struct of YAPF for ships.
|
/** Config struct of YAPF for ships.
|
||||||
Defines all 6 base YAPF modules as classes providing services for CYapfBaseT.
|
* Defines all 6 base YAPF modules as classes providing services for CYapfBaseT.
|
||||||
*/
|
*/
|
||||||
template <class Tpf_, class Ttrack_follower, class Tnode_list>
|
template <class Tpf_, class Ttrack_follower, class Tnode_list>
|
||||||
struct CYapfShip_TypesT
|
struct CYapfShip_TypesT
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue