(1);
- c->filename = strdup(file);
+ c->full_path = strdup(filename);
+ bool added = true;
if (FillGRFDetails(c, false)) {
if (_all_grfs == NULL) {
_all_grfs = c;
@@ -312,20 +319,28 @@
* name, so the list is sorted as we go along */
GRFConfig **pd, *d;
for (pd = &_all_grfs; (d = *pd) != NULL; pd = &d->next) {
+ if (c->grfid == d->grfid && memcmp(c->md5sum, d->md5sum, sizeof(c->md5sum)) == 0) added = false;
if (strcasecmp(c->name, d->name) <= 0) break;
}
- c->next = d;
- *pd = c;
+ if (added) {
+ c->next = d;
+ *pd = c;
+ }
}
+ } else {
+ added = false;
+ }
- num++;
- } else {
+ if (!added) {
/* File couldn't be opened, or is either not a NewGRF or is a
- * 'system' NewGRF, so forget about it. */
+ * 'system' NewGRF or it's already known, so forget about it. */
free(c->filename);
+ free(c->full_path);
free(c->name);
free(c->info);
free(c);
+ } else {
+ num++;
}
}
}
@@ -344,7 +359,8 @@
ClearGRFConfigList(&_all_grfs);
DEBUG(grf, 1, "Scanning for NewGRFs");
- num = ScanPath(_paths.data_dir);
+ num = ScanPath(_paths.data_dir);
+ num += ScanPath(_paths.second_data_dir);
DEBUG(grf, 1, "Scan complete, found %d files", num);
}
diff -r 3b068c3a1c74 -r 0fa543611bbe src/newgrf_config.h
--- a/src/newgrf_config.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/newgrf_config.h Tue Jun 12 11:56:35 2007 +0000
@@ -45,6 +45,7 @@
struct GRFConfig : public GRFIdentifier {
char *filename;
+ char *full_path;
char *name;
char *info;
GRFError *error;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/newgrf_house.cpp
--- a/src/newgrf_house.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/newgrf_house.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -406,7 +406,7 @@
image = dtss->image + stage;
pal = dtss->pal;
- if (!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && ((_display_opt & DO_TRANS_BUILDINGS))) {
+ if (!HASBIT(image, SPRITE_MODIFIER_OPAQUE) && HASBIT(_transparent_opt, TO_HOUSES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/newgrf_station.cpp
--- a/src/newgrf_station.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/newgrf_station.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -184,7 +184,7 @@
for (j = 0; j < station_classes[i].stations; j++) {
const StationSpec *statspec = station_classes[i].spec[j];
if (statspec == NULL) continue;
- if (statspec->grfid == grfid && statspec->localidx == localidx) return statspec;
+ if (statspec->grffile->grfid == grfid && statspec->localidx == localidx) return statspec;
}
}
@@ -409,12 +409,7 @@
case 0x49: return GetPlatformInfoHelper(tile, false, true, false);
/* Variables which use the parameter */
- case 0x60: return GB(st->goods[parameter].waiting_acceptance, 0, 12);
- case 0x61: return st->goods[parameter].days_since_pickup;
- case 0x62: return st->goods[parameter].rating;
- case 0x63: return st->goods[parameter].enroute_time;
- case 0x64: return st->goods[parameter].last_speed | (st->goods[parameter].last_age << 8);
- case 0x65: return GB(st->goods[parameter].waiting_acceptance, 12, 4);
+ /* Variables 0x60 to 0x65 are handled separately below */
/* General station properties */
case 0x82: return 50;
@@ -430,6 +425,23 @@
case 0xFA: return max(st->build_date - DAYS_TILL_ORIGINAL_BASE_YEAR, 0);
}
+ /* Handle cargo variables with parameter, 0x60 to 0x65 */
+ if (variable >= 0x60 && variable <= 0x65) {
+ CargoID c = GetCargoTranslation(parameter, object->u.station.statspec->grffile);
+
+ if (c == CT_INVALID) return 0;
+ const GoodsEntry *ge = &st->goods[c];
+
+ switch (variable) {
+ case 0x60: return GB(ge->waiting_acceptance, 0, 12);
+ case 0x61: return ge->days_since_pickup;
+ case 0x62: return ge->rating;
+ case 0x63: return ge->enroute_time;
+ case 0x64: return ge->last_speed | (ge->last_age << 8);
+ case 0x65: return GB(ge->waiting_acceptance, 12, 4);
+ }
+ }
+
/* Handle cargo variables (deprecated) */
if (variable >= 0x8C && variable <= 0xEC) {
const GoodsEntry *g = &st->goods[GB(variable - 0x8C, 3, 4)];
@@ -638,7 +650,7 @@
}
st->speclist[i].spec = statspec;
- st->speclist[i].grfid = statspec->grfid;
+ st->speclist[i].grfid = statspec->grffile->grfid;
st->speclist[i].localidx = statspec->localidx;
}
diff -r 3b068c3a1c74 -r 0fa543611bbe src/newgrf_station.h
--- a/src/newgrf_station.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/newgrf_station.h Tue Jun 12 11:56:35 2007 +0000
@@ -28,7 +28,7 @@
typedef byte *StationLayout;
struct StationSpec {
- uint32 grfid; ///< ID of GRF file station belongs to.
+ const struct GRFFile *grffile; ///< ID of GRF file station belongs to.
int localidx; ///< Index within GRF file of station.
bool allocated; ///< Flag whether this station has been added to a station class list
diff -r 3b068c3a1c74 -r 0fa543611bbe src/news_gui.cpp
--- a/src/news_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/news_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -128,10 +128,11 @@
DrawStringMultiCenter(215, ni->display_mode == NM_NORMAL ? 76 : 56,
ni->string_id, w->width - 4);
} else {
- byte bk = _display_opt;
- _display_opt &= ~DO_TRANS_BUILDINGS;
+ /* Back up transparency options to draw news view */
+ byte to_backup = _transparent_opt;
+ _transparent_opt = 0;
DrawWindowViewport(w);
- _display_opt = bk;
+ _transparent_opt = to_backup;
/* Shade the viewport into gray, or color*/
vp = w->viewport;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/npf.cpp
--- a/src/npf.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/npf.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -7,6 +7,7 @@
#include "bridge_map.h"
#include "debug.h"
#include "functions.h"
+#include "landscape.h"
#include "npf.h"
#include "aystar.h"
#include "macros.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/openttd.cpp
--- a/src/openttd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/openttd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -24,6 +24,7 @@
#include "gfx.h"
#include "gfxinit.h"
#include "gui.h"
+#include "landscape.h"
#include "station.h"
#include "station_map.h"
#include "town_map.h"
@@ -57,6 +58,7 @@
#include "date.h"
#include "clear_map.h"
#include "fontcache.h"
+#include "newgrf.h"
#include "newgrf_config.h"
#include "newgrf_house.h"
#include "player_face.h"
@@ -303,7 +305,10 @@
char filename[256];
_game_mode = GM_MENU;
- CLRBITS(_display_opt, DO_TRANS_BUILDINGS); // don't make buildings transparent in intro
+
+ /* Clear transparency options */
+ _transparent_opt = 0;
+
_opt_ptr = &_opt_newgame;
ResetGRFConfig(false);
@@ -1583,7 +1588,7 @@
if (statspec != NULL) {
wp->stat_id = _m[wp->xy].m4 + 1;
- wp->grfid = statspec->grfid;
+ wp->grfid = statspec->grffile->grfid;
wp->localidx = statspec->localidx;
} else {
/* No custom graphics set, so set to default. */
diff -r 3b068c3a1c74 -r 0fa543611bbe src/openttd.h
--- a/src/openttd.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/openttd.h Tue Jun 12 11:56:35 2007 +0000
@@ -175,10 +175,18 @@
DO_SHOW_STATION_NAMES = 1 << 1,
DO_SHOW_SIGNS = 1 << 2,
DO_FULL_ANIMATION = 1 << 3,
- DO_TRANS_BUILDINGS = 1 << 4,
DO_FULL_DETAIL = 1 << 5,
DO_WAYPOINTS = 1 << 6,
- DO_TRANS_SIGNS = 1 << 7,
+};
+
+enum {
+ TO_SIGNS,
+ TO_TREES,
+ TO_HOUSES,
+ TO_INDUSTRIES,
+ TO_BUILDINGS,
+ TO_BRIDGES,
+ TO_STRUCTURES,
};
/* Landscape types */
@@ -409,6 +417,7 @@
WC_GENERATE_LANDSCAPE,
WC_GENERATE_PROGRESS_WINDOW,
WC_CONFIRM_POPUP_QUERY,
+ WC_TRANSPARENCY_TOOLBAR,
};
diff -r 3b068c3a1c74 -r 0fa543611bbe src/pathfind.cpp
--- a/src/pathfind.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/pathfind.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -8,6 +8,7 @@
#include "station_map.h"
#include "depot.h"
#include "functions.h"
+#include "landscape.h"
#include "map.h"
#include "tile.h"
#include "pathfind.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/players.cpp
--- a/src/players.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/players.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -821,8 +821,8 @@
}
/* This is the joining client who wants a new company */
- if (_local_player != _network_playas) {
- assert(_local_player == PLAYER_SPECTATOR && _network_playas == p->index);
+ if (_local_player != _network_playas && _network_playas == p->index) {
+ assert(_local_player == PLAYER_SPECTATOR);
SetLocalPlayer(p->index);
MarkWholeScreenDirty();
}
diff -r 3b068c3a1c74 -r 0fa543611bbe src/rail.cpp
--- a/src/rail.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/rail.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file rail.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -79,7 +81,7 @@
{TRACKDIR_RIGHT_N, TRACKDIR_RIGHT_S, INVALID_TRACKDIR, INVALID_TRACKDIR}
};
-extern const Trackdir _track_enterdir_to_trackdir[][DIAGDIR_END] = { // TODO: replace magic with enums
+extern const Trackdir _track_enterdir_to_trackdir[][DIAGDIR_END] = {
{TRACKDIR_X_NE, INVALID_TRACKDIR, TRACKDIR_X_SW, INVALID_TRACKDIR},
{INVALID_TRACKDIR, TRACKDIR_Y_SE, INVALID_TRACKDIR, TRACKDIR_Y_NW},
{INVALID_TRACKDIR, TRACKDIR_UPPER_E, TRACKDIR_UPPER_W, INVALID_TRACKDIR},
diff -r 3b068c3a1c74 -r 0fa543611bbe src/rail.h
--- a/src/rail.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/rail.h Tue Jun 12 11:56:35 2007 +0000
@@ -223,7 +223,7 @@
* 1) All the sprites in a railset MUST be in the same order. This order
* is determined by normal rail. Check sprites 1005 and following for this order
* 2) The position where the railtype is loaded must always be the same, otherwise
- * the offset will fail.
+ * the offset will fail.
* @note: Something more flexible might be desirable in the future.
*/
SpriteID total_offset;
@@ -240,10 +240,10 @@
};
-// these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block
+/** these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block */
enum {
- NUM_SSD_ENTRY = 256, // max amount of blocks
- NUM_SSD_STACK = 32, // max amount of blocks to check recursively
+ NUM_SSD_ENTRY = 256, ///< max amount of blocks
+ NUM_SSD_STACK = 32, ///< max amount of blocks to check recursively
};
/**
diff -r 3b068c3a1c74 -r 0fa543611bbe src/rail_cmd.cpp
--- a/src/rail_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/rail_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file rail_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -77,8 +79,8 @@
static bool CheckTrackCombination(TileIndex tile, TrackBits to_build, uint flags)
{
- TrackBits current; /* The current track layout */
- TrackBits future; /* The track layout we want to build */
+ TrackBits current; // The current track layout
+ TrackBits future; // The track layout we want to build
_error_message = STR_1001_IMPOSSIBLE_TRACK_COMBINATION;
if (!IsPlainRailTile(tile)) return false;
@@ -109,7 +111,7 @@
static const TrackBits _valid_tileh_slopes[][15] = {
-// set of normal ones
+/* set of normal ones */
{
TRACK_BIT_ALL,
TRACK_BIT_RIGHT,
@@ -131,7 +133,7 @@
TRACK_BIT_RIGHT,
},
-// allowed rail for an evenly raised platform
+/* allowed rail for an evenly raised platform */
{
TRACK_BIT_NONE,
TRACK_BIT_LEFT,
@@ -190,20 +192,20 @@
static uint32 CheckRailSlope(Slope tileh, TrackBits rail_bits, TrackBits existing, TileIndex tile)
{
if (IsSteepSlope(tileh)) {
- if (existing == 0) {
+ if (_patches.build_on_slopes && existing == 0) {
TrackBits valid = TRACK_BIT_CROSS | (HASBIT(1 << SLOPE_STEEP_W | 1 << SLOPE_STEEP_E, tileh) ? TRACK_BIT_VERT : TRACK_BIT_HORZ);
if (valid & rail_bits) return _eco->GetPrice(CEconomy::TERRAFORM);
}
} else {
rail_bits |= existing;
- // don't allow building on the lower side of a coast
+ /* don't allow building on the lower side of a coast */
if (IsTileType(tile, MP_WATER) &&
~_valid_tileh_slopes[1][tileh] & rail_bits) {
return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
}
- // no special foundation
+ /* no special foundation */
if ((~_valid_tileh_slopes[0][tileh] & rail_bits) == 0)
return 0;
@@ -252,12 +254,12 @@
switch (GetTileType(tile)) {
case MP_RAILWAY:
if (!CheckTrackCombination(tile, trackbit, flags) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
if (!IsTileOwner(tile, _current_player) ||
!IsCompatibleRail(GetRailType(tile), railtype)) {
- // Get detailed error message
+ /* Get detailed error message */
return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
}
@@ -288,7 +290,7 @@
}
#undef M
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
@@ -352,7 +354,7 @@
if (!IsLevelCrossing(tile) ||
GetCrossingRailBits(tile) != trackbit ||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
@@ -368,7 +370,7 @@
if (!IsPlainRailTile(tile) ||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
@@ -436,11 +438,11 @@
if (!ValParamTrackOrientation(TrackdirToTrack(*trackdir))) return CMD_ERROR;
- // calculate delta x,y from start to end tile
+ /* calculate delta x,y from start to end tile */
dx = ex - x;
dy = ey - y;
- // calculate delta x,y for the first direction
+ /* calculate delta x,y for the first direction */
trdx = _trackdelta[*trackdir].x;
trdy = _trackdelta[*trackdir].y;
@@ -449,7 +451,7 @@
trdy += _trackdelta[*trackdir ^ 1].y;
}
- // validate the direction
+ /* validate the direction */
while (
(trdx <= 0 && dx > 0) ||
(trdx >= 0 && dx < 0) ||
@@ -465,8 +467,8 @@
}
}
- // (for diagonal tracks, this is already made sure of by above test), but:
- // for non-diagonal tracks, check if the start and end tile are on 1 line
+ /* (for diagonal tracks, this is already made sure of by above test), but:
+ * for non-diagonal tracks, check if the start and end tile are on 1 line */
if (!IsDiagonalTrackdir(*trackdir)) {
trdx = _trackdelta[*trackdir].x;
trdy = _trackdelta[*trackdir].y;
@@ -519,7 +521,7 @@
tile += ToTileIndexDiff(_trackdelta[trackdir]);
- // toggle railbit for the non-diagonal tracks
+ /* toggle railbit for the non-diagonal tracks */
if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0);
}
@@ -627,7 +629,7 @@
SignalVariant sigvar = (pre_signal ^ HASBIT(p1, 4)) ? SIG_SEMAPHORE : SIG_ELECTRIC;
int32 cost;
- if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicle(tile))
+ if (!ValParamTrackOrientation(track) || !IsTileType(tile, MP_RAILWAY) || !EnsureNoVehicleOnGround(tile))
return CMD_ERROR;
/* Protect against invalid signal copying */
@@ -653,35 +655,35 @@
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (!HasSignalOnTrack(tile, track)) {
- // build new signals
+ /* build new signals */
cost = _eco->GetPrice(CEconomy::BUILD_SIGNALS);
} else {
if (p2 != 0 && sigvar != GetSignalVariant(tile)) {
- // convert signals <-> semaphores
+ /* convert signals <-> semaphores */
cost = _eco->GetPrice(CEconomy::BUILD_SIGNALS) + _eco->GetPrice(CEconomy::REMOVE_SIGNALS);
} else {
- // it is free to change orientation/pre-exit-combo signals
+ /* it is free to change orientation/pre-exit-combo signals */
cost = 0;
}
}
if (flags & DC_EXEC) {
if (!HasSignals(tile)) {
- // there are no signals at all on this tile yet
+ /* there are no signals at all on this tile yet */
SetHasSignals(tile, true);
_m[tile].m2 |= 0xF0; // all signals are on
- _m[tile].m3 &= ~0xF0; // no signals built by default
+ _m[tile].m3 &= ~0xF0; // no signals built by default
SetSignalType(tile, SIGTYPE_NORMAL);
SetSignalVariant(tile, sigvar);
}
if (p2 == 0) {
if (!HasSignalOnTrack(tile, track)) {
- // build new signals
+ /* build new signals */
_m[tile].m3 |= SignalOnTrack(track);
} else {
if (pre_signal) {
- // cycle between normal -> pre -> exit -> combo -> ...
+ /* cycle between normal -> pre -> exit -> combo -> ... */
SignalType type = GetSignalType(tile);
SetSignalType(tile, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(type + 1));
@@ -745,12 +747,12 @@
track = TrackdirToTrack(trackdir); /* trackdir might have changed, keep track in sync */
- // copy the signal-style of the first rail-piece if existing
+ /* copy the signal-style of the first rail-piece if existing */
if (HasSignals(tile)) {
signals = _m[tile].m3 & SignalOnTrack(track);
if (signals == 0) signals = SignalOnTrack(track); /* Can this actually occur? */
- // copy signal/semaphores style (independent of CTRL)
+ /* copy signal/semaphores style (independent of CTRL) */
semaphores = GetSignalVariant(tile) != SIG_ELECTRIC;
} else { // no signals exist, drag a two-way signal stretch
signals = SignalOnTrack(track);
@@ -766,7 +768,7 @@
* remove - 1 remove signals, 0 build signals */
signal_ctr = total_cost = 0;
for (;;) {
- // only build/remove signals with the specified density
+ /* only build/remove signals with the specified density */
if (signal_ctr % signal_density == 0) {
uint32 p1 = GB(TrackdirToTrack(trackdir), 0, 3);
SB(p1, 3, 1, mode);
@@ -785,7 +787,7 @@
tile += ToTileIndexDiff(_trackdelta[trackdir]);
signal_ctr++;
- // toggle railbit for the non-diagonal tracks (|, -- tracks)
+ /* toggle railbit for the non-diagonal tracks (|, -- tracks) */
if (!IsDiagonalTrackdir(trackdir)) ToggleBitT(trackdir, 0);
}
@@ -814,7 +816,7 @@
if (!ValParamTrackOrientation(track) ||
!IsTileType(tile, MP_RAILWAY) ||
- !EnsureNoVehicle(tile) ||
+ !EnsureNoVehicleOnGround(tile) ||
!HasSignalOnTrack(tile, track)) {
return CMD_ERROR;
}
@@ -871,17 +873,17 @@
if (GetRailType(tile) == totype) return CMD_ERROR;
- if (!EnsureNoVehicle(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile) && (!IsCompatibleRail(GetRailType(tile), totype) || IsPlainRailTile(tile))) return CMD_ERROR;
- // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ /* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
- // change type.
+ /* change type. */
if (exec) {
SetRailType(tile, totype);
MarkTileDirtyByTile(tile);
- // notify YAPF about the track layout change
+ /* notify YAPF about the track layout change */
TrackBits tracks = GetTrackBits(tile);
while (tracks != TRACK_BIT_NONE) {
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
@@ -927,7 +929,7 @@
if (!ValParamRailtype(p2)) return CMD_ERROR;
if (p1 >= MapSize()) return CMD_ERROR;
- // make sure sx,sy are smaller than ex,ey
+ /* make sure sx,sy are smaller than ex,ey */
ex = TileX(tile);
ey = TileY(tile);
sx = TileX(p1);
@@ -975,7 +977,7 @@
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
return CMD_ERROR;
- if (!EnsureNoVehicle(tile))
+ if (!EnsureNoVehicleOnGround(tile))
return CMD_ERROR;
if (flags & DC_EXEC) {
@@ -1192,7 +1194,7 @@
SpriteID pal = PAL_NONE;
bool junction = false;
- // Select the sprite to use.
+ /* Select the sprite to use. */
(image = rti->base_sprites.track_y, track == TRACK_BIT_Y) ||
(image++, track == TRACK_BIT_X) ||
(image++, track == TRACK_BIT_UPPER) ||
@@ -1216,8 +1218,8 @@
if (foundation != 0) DrawFoundation(ti, foundation);
- // DrawFoundation() modifies ti.
- // Default sloped sprites..
+ /* DrawFoundation() modifies it.
+ * Default sloped sprites.. */
if (ti->tileh != SLOPE_FLAT)
image = _track_sloped_sprites[ti->tileh - 1] + rti->base_sprites.track_y;
}
@@ -1230,7 +1232,7 @@
DrawGroundSprite(image, pal);
- // Draw track pieces individually for junction tiles
+ /* Draw track pieces individually for junction tiles */
if (junction) {
if (track & TRACK_BIT_X) DrawGroundSprite(rti->base_sprites.single_y, PAL_NONE);
if (track & TRACK_BIT_Y) DrawGroundSprite(rti->base_sprites.single_x, PAL_NONE);
@@ -1292,7 +1294,7 @@
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails);
} else {
- // draw depot/waypoint
+ /* draw depot/waypoint */
const DrawTileSprites* dts;
const DrawTileSeqStruct* dtss;
uint32 relocation;
@@ -1307,8 +1309,8 @@
image = dts->ground_sprite;
if (image != SPR_FLAT_GRASS_TILE) image += rti->total_offset;
- // adjust ground tile for desert
- // don't adjust for snow, because snow in depots looks weird
+ /* adjust ground tile for desert
+ * don't adjust for snow, because snow in depots looks weird */
if (IsSnowRailGround(ti->tile) && _opt.landscape == LT_TROPIC) {
if (image != SPR_FLAT_GRASS_TILE) {
image += rti->snow_offset; // tile with tracks
@@ -1317,12 +1319,12 @@
}
}
} else {
- // look for customization
+ /* look for customization */
byte stat_id = GetWaypointByTile(ti->tile)->stat_id;
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, stat_id);
if (statspec != NULL) {
- // emulate station tile - open with building
+ /* emulate station tile - open with building */
const Station* st = ComposeWaypointStation(ti->tile);
uint gfx = 2;
@@ -1352,7 +1354,7 @@
}
} else {
default_waypoint:
- // There is no custom layout, fall back to the default graphics
+ /* There is no custom layout, fall back to the default graphics */
dts = &_waypoint_gfx_table[GetWaypointAxis(ti->tile)];
relocation = 0;
image = dts->ground_sprite + rti->total_offset;
@@ -1377,7 +1379,7 @@
image += relocation;
}
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
@@ -1439,15 +1441,15 @@
bool stop;
bool has_presignal;
- // presignal info
+ /* presignal info */
int presignal_exits;
int presignal_exits_free;
- // these are used to keep track of the signals that change.
+ /* these are used to keep track of the signals that change. */
TrackdirByte bit[NUM_SSD_ENTRY];
TileIndex tile[NUM_SSD_ENTRY];
- // these are used to keep track of the stack that modifies presignals recursively
+ /* these are used to keep track of the stack that modifies presignals recursively */
TileIndex next_tile[NUM_SSD_STACK];
DiagDirectionByte next_dir[NUM_SSD_STACK];
@@ -1459,22 +1461,22 @@
if (!IsTileType(tile, MP_RAILWAY)) return false;
- // the tile has signals?
+ /* the tile has signals? */
if (HasSignalOnTrack(tile, TrackdirToTrack(trackdir))) {
if (HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir))) {
- // yes, add the signal to the list of signals
+ /* yes, add the signal to the list of signals */
if (ssd->cur != NUM_SSD_ENTRY) {
ssd->tile[ssd->cur] = tile; // remember the tile index
ssd->bit[ssd->cur] = trackdir; // and the controlling bit number
ssd->cur++;
}
- // remember if this block has a presignal.
+ /* remember if this block has a presignal. */
ssd->has_presignal |= IsPresignalEntry(tile);
}
if (HasSignalOnTrackdir(tile, trackdir) && IsPresignalExit(tile)) {
- // this is an exit signal that points out from the segment
+ /* this is an exit signal that points out from the segment */
ssd->presignal_exits++;
if (GetSignalStateByTrackdir(tile, trackdir) != SIGNAL_STATE_RED)
ssd->presignal_exits_free++;
@@ -1532,21 +1534,21 @@
dest.track = 1 << (direction & 1); // get the trackbit the vehicle would have if it has not entered the tunnel yet (ie is still visible)
- // check for a vehicle with that trackdir on the start tile of the tunnel
+ /* check for a vehicle with that trackdir on the start tile of the tunnel */
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL) return true;
- // check for a vehicle with that trackdir on the end tile of the tunnel
+ /* check for a vehicle with that trackdir on the end tile of the tunnel */
if (VehicleFromPos(end, &dest, SignalVehicleCheckProc) != NULL) return true;
- // now check all tiles from start to end for a warping vehicle
- // NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile?
+ /* now check all tiles from start to end for a warping vehicle
+ * NOTE: the hashes for tiles may overlap, so this could maybe be optimised a bit by not checking every tile? */
dest.track = 0x40; //Vehicle inside a tunnel or on a bridge
for (; tile != end; tile += TileOffsByDiagDir(direction)) {
if (VehicleFromPos(tile, &dest, SignalVehicleCheckProc) != NULL)
return true;
}
- // no vehicle found
+ /* no vehicle found */
return false;
}
@@ -1601,39 +1603,39 @@
{
int i;
- // thinking about presignals...
- // the presignal is green if,
- // if no train is in the segment AND
- // there is at least one green exit signal OR
- // there are no exit signals in the segment
+ /* thinking about presignals...
+ * the presignal is green if,
+ * if no train is in the segment AND
+ * there is at least one green exit signal OR
+ * there are no exit signals in the segment */
- // then mark the signals in the segment accordingly
+ /* then mark the signals in the segment accordingly */
for (i = 0; i != ssd->cur; i++) {
TileIndex tile = ssd->tile[i];
byte bit = SignalAgainstTrackdir(ssd->bit[i]);
uint16 m2 = _m[tile].m2;
- // presignals don't turn green if there is at least one presignal exit and none are free
+ /* presignals don't turn green if there is at least one presignal exit and none are free */
if (IsPresignalEntry(tile)) {
int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free;
- // subtract for dual combo signals so they don't count themselves
+ /* subtract for dual combo signals so they don't count themselves */
if (IsPresignalExit(tile) && HasSignalOnTrackdir(tile, ssd->bit[i])) {
ex--;
if (GetSignalStateByTrackdir(tile, ssd->bit[i]) != SIGNAL_STATE_RED) exfree--;
}
- // if we have exits and none are free, make red.
+ /* if we have exits and none are free, make red. */
if (ex && !exfree) goto make_red;
}
- // check if the signal is unaffected.
+ /* check if the signal is unaffected. */
if (ssd->stop) {
make_red:
- // turn red
+ /* turn red */
if ((bit & m2) == 0) continue;
} else {
- // turn green
+ /* turn green */
if ((bit & m2) != 0) continue;
}
@@ -1648,7 +1650,7 @@
}
}
- // it changed, so toggle it
+ /* it changed, so toggle it */
_m[tile].m2 = m2 ^ bit;
MarkTileDirtyByTile(tile);
}
@@ -1663,23 +1665,23 @@
ssd.cur_stack = 0;
for (;;) {
- // go through one segment and update all signals pointing into that segment.
+ /* go through one segment and update all signals pointing into that segment. */
ssd.cur = ssd.presignal_exits = ssd.presignal_exits_free = 0;
ssd.has_presignal = false;
FollowTrack(tile, 0xC000 | TRANSPORT_RAIL, direction, SetSignalsEnumProc, SetSignalsAfterProc, &ssd);
ChangeSignalStates(&ssd);
- // remember the result only for the first iteration.
+ /* remember the result only for the first iteration. */
if (result < 0) {
- // stay in depot while segment is occupied or while all presignal exits are blocked
+ /* stay in depot while segment is occupied or while all presignal exits are blocked */
result = ssd.stop || (ssd.presignal_exits > 0 && ssd.presignal_exits_free == 0);
}
- // if any exit signals were changed, we need to keep going to modify the stuff behind those.
+ /* if any exit signals were changed, we need to keep going to modify the stuff behind those. */
if (ssd.cur_stack == 0) break;
- // one or more exit signals were changed, so we need to update another segment too.
+ /* one or more exit signals were changed, so we need to update another segment too. */
tile = ssd.next_tile[--ssd.cur_stack];
direction = ssd.next_dir[ssd.cur_stack];
}
@@ -1772,7 +1774,7 @@
new_ground = RAIL_GROUND_GRASS;
- if (old_ground != RAIL_GROUND_BARREN) { /* wait until bottom is green */
+ if (old_ground != RAIL_GROUND_BARREN) { // wait until bottom is green
/* determine direction of fence */
TrackBits rail = GetTrackBits(tile);
@@ -1966,7 +1968,7 @@
DiagDirection dir;
int length;
- // this routine applies only to trains in depot tiles
+ /* this routine applies only to trains in depot tiles */
if (v->type != VEH_TRAIN || !IsTileDepotType(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
/* depot direction */
diff -r 3b068c3a1c74 -r 0fa543611bbe src/rail_gui.cpp
--- a/src/rail_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/rail_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -7,6 +7,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
+#include "landscape.h"
#include "date.h"
#include "map.h"
#include "tile.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/rail_map.h
--- a/src/rail_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/rail_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file rail_map.h Hides the direct accesses to the map array with map accessors */
+
#ifndef RAIL_MAP_H
#define RAIL_MAP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/railtypes.h
--- a/src/railtypes.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/railtypes.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,12 +1,12 @@
/* $Id$ */
-#ifndef RAILTYPES_H
-#define RAILTYPES_H
-
/** @file railtypes.h
* All the railtype-specific information is stored here.
*/
+#ifndef RAILTYPES_H
+#define RAILTYPES_H
+
/** Global Railtype definition
*/
RailtypeInfo _railtypes[] = {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/resource.h
--- a/src/resource.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/resource.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file resource.h */
+
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ttd.rc
diff -r 3b068c3a1c74 -r 0fa543611bbe src/road.h
--- a/src/road.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/road.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road.h */
+
#ifndef ROAD_H
#define ROAD_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/road_cmd.cpp
--- a/src/road_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/road_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -46,16 +48,16 @@
if (_game_mode == GM_EDITOR) return true;
- // Only do the special processing for actual players.
+ /* Only do the special processing for actual players. */
if (!IsValidPlayer(_current_player)) return true;
- // Only do the special processing if the road is owned
- // by a town
+ /* Only do the special processing if the road is owned
+ * by a town */
if (owner != OWNER_TOWN) return (owner == OWNER_NONE) || CheckOwnership(owner);
if (_cheats.magic_bulldozer.value) return true;
- // Get a bitmask of which neighbouring roads has a tile
+ /* Get a bitmask of which neighbouring roads has a tile */
n = ROAD_NONE;
present = GetAnyRoadBits(tile);
if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile,-1, 0)) & ROAD_SW) n |= ROAD_NE;
@@ -63,12 +65,12 @@
if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0)) & ROAD_NE) n |= ROAD_SW;
if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0,-1)) & ROAD_SE) n |= ROAD_NW;
- // If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
- // then allow it
+ /* If 0 or 1 bits are set in n, or if no bits that match the bits to remove,
+ * then allow it */
if ((n & (n - 1)) != 0 && (n & remove) != 0) {
Town *t;
*edge_road = false;
- // you can remove all kind of roads with extra dynamite
+ /* you can remove all kind of roads with extra dynamite */
if (_patches.extra_dynamite) return true;
t = ClosestTownFromTile(tile, (uint)-1);
@@ -93,7 +95,7 @@
*/
int32 CmdRemoveRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- // cost for removing inner/edge -roads
+ /* cost for removing inner/edge -roads */
static const uint16 road_remove_cost[2] = {50, 18};
Owner owner;
@@ -118,10 +120,10 @@
if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR;
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
- // check if you're allowed to remove the street owned by a town
- // removal allowance depends on difficulty setting
+ /* check if you're allowed to remove the street owned by a town
+ * removal allowance depends on difficulty setting */
if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
switch (GetRoadTileType(tile)) {
@@ -137,7 +139,7 @@
c |= (RoadBits)((c & 0x3) << 2);
}
- // limit the bits to delete to the existing bits.
+ /* limit the bits to delete to the existing bits. */
c &= present;
if (c == 0) return CMD_ERROR;
@@ -178,7 +180,7 @@
static const RoadBits _valid_tileh_slopes_road[][15] = {
- // set of normal ones
+ /* set of normal ones */
{
ROAD_ALL, ROAD_NONE, ROAD_NONE,
ROAD_X, ROAD_NONE, ROAD_NONE, // 3, 4, 5
@@ -186,7 +188,7 @@
ROAD_Y, ROAD_NONE, ROAD_NONE, // 9, 10, 11
ROAD_X, ROAD_NONE, ROAD_NONE
},
- // allowed road for an evenly raised platform
+ /* allowed road for an evenly raised platform */
{
ROAD_NONE,
ROAD_SW | ROAD_NW,
@@ -216,7 +218,7 @@
if (IsSteepSlope(tileh)) {
if (existing == 0) {
- // force full pieces.
+ /* force full pieces. */
*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
*pieces |= (RoadBits)((*pieces & 0x3) << 2);
if (*pieces == ROAD_X || *pieces == ROAD_Y) return _eco->GetPrice(CEconomy::TERRAFORM);
@@ -225,21 +227,21 @@
}
road_bits = *pieces | existing;
- // no special foundation
+ /* no special foundation */
if ((~_valid_tileh_slopes_road[0][tileh] & road_bits) == 0) {
- // force that all bits are set when we have slopes
+ /* force that all bits are set when we have slopes */
if (tileh != SLOPE_FLAT) *pieces |= _valid_tileh_slopes_road[0][tileh];
return 0; // no extra cost
}
- // foundation is used. Whole tile is leveled up
+ /* foundation is used. Whole tile is leveled up */
if ((~_valid_tileh_slopes_road[1][tileh] & road_bits) == 0) {
return existing != 0 ? 0 : _eco->GetPrice(CEconomy::TERRAFORM);
}
- // partly leveled up tile, only if there's no road on that tile
+ /* partly leveled up tile, only if there's no road on that tile */
if (existing == 0 && (tileh == SLOPE_W || tileh == SLOPE_S || tileh == SLOPE_E || tileh == SLOPE_N)) {
- // force full pieces.
+ /* force full pieces. */
*pieces |= (RoadBits)((*pieces & 0xC) >> 2);
*pieces |= (RoadBits)((*pieces & 0x3) << 2);
if (*pieces == ROAD_X || *pieces == ROAD_Y) return _eco->GetPrice(CEconomy::TERRAFORM);
@@ -279,7 +281,7 @@
if ((existing & pieces) == pieces) {
return_cmd_error(STR_1007_ALREADY_BUILT);
}
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
break;
case ROAD_TILE_CROSSING:
@@ -323,7 +325,7 @@
default: goto do_clear;
}
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (flags & DC_EXEC) {
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
@@ -350,7 +352,7 @@
cost += ret;
if (IsTileType(tile, MP_STREET)) {
- // Don't put the pieces that already exist
+ /* Don't put the pieces that already exist */
pieces &= ComplementRoadBits(existing);
cost += CountRoadBits(pieces) * _eco->GetPrice(CEconomy::BUILD_ROAD);
} else {
@@ -381,15 +383,15 @@
*/
int32 DoConvertStreetRail(TileIndex tile, RailType totype, bool exec)
{
- // not a railroad crossing?
+ /* not a railroad crossing? */
if (!IsLevelCrossing(tile)) return CMD_ERROR;
- // not owned by me?
- if (!CheckTileOwnership(tile) || !EnsureNoVehicle(tile)) return CMD_ERROR;
+ /* not owned by me? */
+ if (!CheckTileOwnership(tile) || !EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
if (GetRailType(tile) == totype) return CMD_ERROR;
- // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ /* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
if (exec) {
@@ -435,7 +437,7 @@
cost = 0;
tile = start_tile;
- // Start tile is the small number.
+ /* Start tile is the small number. */
for (;;) {
RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X;
@@ -491,14 +493,14 @@
cost = 0;
tile = start_tile;
- // Start tile is the small number.
+ /* Start tile is the small number. */
for (;;) {
RoadBits bits = HASBIT(p2, 2) ? ROAD_Y : ROAD_X;
if (tile == end_tile && !HASBIT(p2, 1)) bits &= ROAD_NW | ROAD_NE;
if (tile == start_tile && HASBIT(p2, 0)) bits &= ROAD_SE | ROAD_SW;
- // try to remove the halves.
+ /* try to remove the halves. */
if (bits != 0) {
ret = DoCommand(tile, bits, 0, flags, CMD_REMOVE_ROAD);
if (!CmdFailed(ret)) cost += ret;
@@ -627,13 +629,13 @@
{
uint i;
- // normal level sloped building
+ /* normal level sloped building */
if (!IsSteepSlope(tileh) &&
(~_valid_tileh_slopes_road[1][tileh] & bits) == 0) {
return tileh;
}
- // inclined sloped building
+ /* inclined sloped building */
switch (bits) {
case ROAD_X: i = 0; break;
case ROAD_Y: i = 1; break;
@@ -678,8 +680,8 @@
if (foundation != 0) DrawFoundation(ti, foundation);
- // DrawFoundation() modifies ti.
- // Default sloped sprites..
+ /* DrawFoundation() modifies ti.
+ * Default sloped sprites.. */
if (ti->tileh != SLOPE_FLAT) image = _road_sloped_sprites[ti->tileh - 1] + 0x53F;
}
@@ -701,15 +703,15 @@
DrawGroundSprite(image, pal);
if (HasRoadWorks(ti->tile)) {
- // Road works
+ /* Road works */
DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE);
return;
}
- // Return if full detail is disabled, or we are zoomed fully out.
+ /* Return if full detail is disabled, or we are zoomed fully out. */
if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return;
- // Draw extra details.
+ /* Draw extra details. */
for (drts = _road_display_table[roadside][road]; drts->image != 0; drts++) {
int x = ti->x | drts->subcoord_x;
int y = ti->y | drts->subcoord_y;
@@ -769,7 +771,7 @@
SpriteID image = dtss->image;
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
@@ -902,11 +904,11 @@
if (t != NULL) {
grp = t->GetRadiusGroup(tile);
- // Show an animation to indicate road work
+ /* Show an animation to indicate road work */
if (t->road_build_months != 0 &&
(DistanceManhattan(t->xy, tile) < 8 || grp != 0) &&
GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetRoadBits(tile) == ROAD_X || GetRoadBits(tile) == ROAD_Y)) {
- if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicle(tile) && CHANCE16(1, 20)) {
+ if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 20)) {
StartRoadWorks(tile);
SndPlayTileFx(SND_21_JACKHAMMER, tile);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/road_cmd.h
--- a/src/road_cmd.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/road_cmd.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road_cmd.h */
+
#ifndef ROAD_CMD_H
#define ROAD_CMD_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/road_gui.cpp
--- a/src/road_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/road_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "road_cmd.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/road_map.cpp
--- a/src/road_map.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/road_map.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,9 +1,12 @@
/* $Id$ */
+/** @file road_map.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "functions.h"
+#include "landscape.h"
#include "road_map.h"
#include "station.h"
#include "tunnel_map.h"
@@ -45,7 +48,7 @@
{
uint32 r;
- // Don't allow local authorities to build roads through road depots or road stops.
+ /* Don't allow local authorities to build roads through road depots or road stops. */
if ((IsTileType(tile, MP_STREET) && IsTileDepotType(tile, TRANSPORT_ROAD)) || (IsTileType(tile, MP_STATION) && !IsDriveThroughStopTile(tile))) {
return TRACK_BIT_NONE;
}
diff -r 3b068c3a1c74 -r 0fa543611bbe src/road_map.h
--- a/src/road_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/road_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road_map.h */
+
#ifndef ROAD_MAP_H
#define ROAD_MAP_H
@@ -171,10 +173,19 @@
* - road tunnels: entrance is treated as road piece
* - bridge ramps: start of the ramp is treated as road piece
* - bridge middle parts: bridge itself is ignored
+ * @param tile the tile to get the road bits for
+ * @return the road bits of the given tile
*/
-RoadBits GetAnyRoadBits(TileIndex);
+RoadBits GetAnyRoadBits(TileIndex tile);
-
+/**
+ * Get the accessible track bits for the given tile.
+ * Special behaviour:
+ * - road depots: no track bits
+ * - non-drive-through stations: no track bits
+ * @param tile the tile to get the track bits for
+ * @return the track bits for the given tile
+ */
TrackBits GetAnyRoadTrackBits(TileIndex tile);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/roadveh.h
--- a/src/roadveh.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/roadveh.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file src/roadveh.h Road vehicle states */
+
#ifndef ROADVEH_H
#define ROADVEH_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/roadveh_cmd.cpp
--- a/src/roadveh_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/roadveh_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,9 +1,12 @@
/* $Id$ */
+/** @file roadveh_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
#include "functions.h"
+#include "landscape.h"
#include "road_map.h"
#include "roadveh.h"
#include "station_map.h"
@@ -129,7 +132,7 @@
UnitID unit_num;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_ROAD, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_ROAD, _current_player)) return_cmd_error(STR_ROAD_VEHICLE_NOT_AVAILABLE);
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
@@ -533,7 +536,7 @@
{
byte new_z, old_z;
- // need this hint so it returns the right z coordinate on bridges.
+ /* need this hint so it returns the right z coordinate on bridges. */
v->x_pos = x;
v->y_pos = y;
new_z = GetSlopeZ(x, y);
@@ -663,7 +666,7 @@
switch (v->current_order.type) {
case OT_GOTO_DEPOT:
- // Let a depot order in the orderlist interrupt.
+ /* Let a depot order in the orderlist interrupt. */
if (!(v->current_order.flags & OF_PART_OF_ORDERS)) return;
if (v->current_order.flags & OF_SERVICE_IF_NEEDED &&
!VehicleNeedsService(v)) {
@@ -723,7 +726,7 @@
}
v->dest_tile = dest;
} else {
- // There is no stop left at the station, so don't even TRY to go there
+ /* There is no stop left at the station, so don't even TRY to go there */
v->cur_order_index++;
v->dest_tile = 0;
}
@@ -828,10 +831,10 @@
rvf.veh = v;
u = (Vehicle*)VehicleFromPos(TileVirtXY(x, y), &rvf, EnumCheckRoadVehClose);
- // This code protects a roadvehicle from being blocked for ever
- // If more than 1480 / 74 days a road vehicle is blocked, it will
- // drive just through it. The ultimate backup-code of TTD.
- // It can be disabled.
+ /* This code protects a roadvehicle from being blocked for ever
+ * If more than 1480 / 74 days a road vehicle is blocked, it will
+ * drive just through it. The ultimate backup-code of TTD.
+ * It can be disabled. */
if (u == NULL) {
v->u.road.blocked_ctr = 0;
return NULL;
@@ -881,13 +884,13 @@
uint spd = v->cur_speed + 1 + (v->u.road.overtaking != 0 ? 1 : 0);
byte t;
- // Clamp
+ /* Clamp */
spd = min(spd, v->max_speed);
if (v->u.road.state == RVSB_WORMHOLE && !(v->vehstatus & VS_HIDDEN)) {
spd = min(spd, GetBridge(GetBridgeType(v->tile))->speed * 2);
}
- //updates statusbar only if speed have changed to save CPU time
+ /* updates statusbar only if speed have changed to save CPU time */
if (spd != v->cur_speed) {
v->cur_speed = spd;
if (_patches.vehicle_speed) {
@@ -895,7 +898,7 @@
}
}
- // Decrease somewhat when turning
+ /* Decrease somewhat when turning */
if (!(v->direction & 1)) spd = spd * 3 >> 2;
if (spd == 0) return false;
@@ -1153,9 +1156,9 @@
ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE);
if (ftd.best_trackdir == INVALID_TRACKDIR) {
- /* We are already at our target. Just do something */
- //TODO: maybe display error?
- //TODO: go straight ahead if possible?
+ /* We are already at our target. Just do something
+ * @todo: maybe display error?
+ * @todo: go straight ahead if possible? */
return_track(FindFirstBit2x64(trackdirs));
} else {
/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
@@ -1223,10 +1226,10 @@
{
uint dist;
if (_patches.yapf.road_use_yapf) {
- // use YAPF
+ /* use YAPF */
dist = YapfRoadVehDistanceToTile(v, tile);
} else {
- // use NPF
+ /* use NPF */
NPFFindStationOrTileData fstd;
Trackdir trackdir = GetVehicleTrackdir(v);
assert(trackdir != INVALID_TRACKDIR);
@@ -1235,7 +1238,7 @@
fstd.station_index = INVALID_STATION; // indicates that the destination is a tile, not a station
dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE).best_path_dist;
- // change units from NPF_TILE_LENGTH to # of tiles
+ /* change units from NPF_TILE_LENGTH to # of tiles */
if (dist != UINT_MAX)
dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
}
@@ -1277,11 +1280,11 @@
int x,y;
uint32 r;
- // decrease counters
+ /* decrease counters */
v->tick_counter++;
if (v->u.road.reverse_ctr != 0) v->u.road.reverse_ctr--;
- // handle crashed
+ /* handle crashed */
if (v->u.road.crashed_ctr != 0) {
RoadVehIsCrashed(v);
return;
@@ -1289,7 +1292,7 @@
RoadVehCheckTrainCrash(v);
- // road vehicle has broken down?
+ /* road vehicle has broken down? */
if (v->breakdown_ctr != 0) {
if (v->breakdown_ctr <= 2) {
HandleBrokenRoadVeh(v);
@@ -1628,9 +1631,9 @@
/* We are leaving the correct station */
ClearSlot(v);
} else if (v->u.road.slot != NULL) {
- /* We are leaving the wrong station */
- //XXX The question is .. what to do? Actually we shouldn't be here
- //but I guess we need to clear the slot
+ /* We are leaving the wrong station
+ * XXX The question is .. what to do? Actually we shouldn't be here
+ * but I guess we need to clear the slot */
DEBUG(ms, 0, "Vehicle %d (index %d) arrived at wrong stop", v->unitnumber, v->index);
if (v->tile != v->dest_tile) {
DEBUG(ms, 2, " current tile 0x%X is not destination tile 0x%X. Route problem", v->tile, v->dest_tile);
@@ -1692,13 +1695,13 @@
if (v->vehstatus & VS_STOPPED) return;
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
- // Don't interfere with a depot visit scheduled by the user, or a
- // depot visit by the order list.
+ /* Don't interfere with a depot visit scheduled by the user, or a
+ * depot visit by the order list. */
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
return;
- // If we already got a slot at a stop, use that FIRST, and go to a depot later
+ /* If we already got a slot at a stop, use that FIRST, and go to a depot later */
if (v->u.road.slot != NULL) return;
if (IsRoadVehInDepot(v)) {
@@ -1706,7 +1709,7 @@
return;
}
- // XXX If we already have a depot order, WHY do we search over and over?
+ /* XXX If we already have a depot order, WHY do we search over and over? */
depot = FindClosestRoadDepot(v);
if (depot == NULL || DistanceManhattan(v->tile, depot->xy) > 12) {
@@ -1743,7 +1746,7 @@
CheckOrders(v);
- //Current slot has expired
+ /* Current slot has expired */
if (v->current_order.type == OT_GOTO_STATION && v->u.road.slot != NULL && v->u.road.slot_age-- == 0) {
DEBUG(ms, 3, "Slot expired for vehicle %d (index %d) at stop 0x%X",
v->unitnumber, v->index, v->u.road.slot->xy);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/roadveh_gui.cpp
--- a/src/roadveh_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/roadveh_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file roadveh_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -34,7 +36,7 @@
StringID str;
SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
- // disable service-scroller when interval is set to disabled
+ /* disable service-scroller when interval is set to disabled */
SetWindowWidgetDisabledState(w, 5, !_patches.servint_roadveh);
SetWindowWidgetDisabledState(w, 6, !_patches.servint_roadveh);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/saveload.cpp
--- a/src/saveload.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/saveload.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -412,8 +412,8 @@
/** Write the value of a setting
* @param ptr pointer to the variable
* @param conv type of variable, can be a non-clean type, eg
- * with other flags. It is parsed upon read
- * @param var the new value being given to the variable */
+ * with other flags. It is parsed upon read
+ * @param val the new value being given to the variable */
void WriteValue(void *ptr, VarType conv, int64 val)
{
switch (GetVarMemType(conv)) {
@@ -498,6 +498,7 @@
* by SlCalcNetStringLen and the length that the index will occupy.
* @param ptr pointer to the stringbuffer
* @param length maximum length of the string (buffer size, etc.)
+ * @param conv type of data been used
* @return return the gross length of the string */
static inline size_t SlCalcStringLen(const void *ptr, size_t length, VarType conv)
{
@@ -525,7 +526,7 @@
/**
* Save/Load a string.
* @param ptr the string being manipulated
- * @param the length of the string (full length)
+ * @param length of the string (full length)
* @param conv must be SLE_FILE_STRING */
static void SlString(void *ptr, size_t length, VarType conv)
{
@@ -650,7 +651,9 @@
/**
* Calculate the size of an object.
+ * @param object to be measured
* @param sld The SaveLoad description of the object so we know how to manipulate it
+ * @return size of given objetc
*/
static size_t SlCalcObjLength(const void *object, const SaveLoad *sld)
{
@@ -768,7 +771,7 @@
/**
* Save or Load (a list of) global variables
- * @param desc The global variable that is being loaded or saved
+ * @param sldg The global variable that is being loaded or saved
*/
void SlGlobList(const SaveLoadGlobVarList *sldg)
{
diff -r 3b068c3a1c74 -r 0fa543611bbe src/saveload.h
--- a/src/saveload.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/saveload.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file saveload.h */
+
#ifndef SAVELOAD_H
#define SAVELOAD_H
@@ -10,9 +12,9 @@
#define SIZE_MAX ((size_t)-1)
enum SaveOrLoadResult {
- SL_OK = 0, // completed successfully
- SL_ERROR = 1, // error that was caught before internal structures were modified
- SL_REINIT = 2, // error that was caught in the middle of updating game state, need to clear it. (can only happen during load)
+ SL_OK = 0, ///< completed successfully
+ SL_ERROR = 1, ///< error that was caught before internal structures were modified
+ SL_REINIT = 2, ///< error that was caught in the middle of updating game state, need to clear it. (can only happen during load)
};
enum SaveOrLoadMode {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/screenshot.cpp
--- a/src/screenshot.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/screenshot.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -20,7 +20,7 @@
uint _cur_screenshot_format;
ScreenshotType current_screenshot_type;
-// called by the ScreenShot proc to generate screenshot lines.
+/* called by the ScreenShot proc to generate screenshot lines. */
typedef void ScreenshotCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n);
typedef bool ScreenshotHandlerProc(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette);
@@ -62,7 +62,7 @@
};
assert_compile(sizeof(RgbQuad) == 4);
-// generic .BMP writer
+/* generic .BMP writer */
static bool MakeBmpImage(const char *name, ScreenshotCallback *callb, void *userdata, uint w, uint h, int pixelformat, const Colour *palette)
{
BitmapFileHeader bfh;
@@ -72,23 +72,23 @@
uint i, padw;
uint n, maxlines;
- // only implemented for 8bit images so far.
+ /* only implemented for 8bit images so far. */
if (pixelformat != 8)
return false;
f = fopen(name, "wb");
if (f == NULL) return false;
- // each scanline must be aligned on a 32bit boundary
+ /* each scanline must be aligned on a 32bit boundary */
padw = ALIGN(w, 4);
- // setup the file header
+ /* setup the file header */
bfh.type = TO_LE16('MB');
bfh.size = TO_LE32(sizeof(bfh) + sizeof(bih) + sizeof(RgbQuad) * 256 + padw * h);
bfh.reserved = 0;
bfh.off_bits = TO_LE32(sizeof(bfh) + sizeof(bih) + sizeof(RgbQuad) * 256);
- // setup the info header
+ /* setup the info header */
bih.size = TO_LE32(sizeof(BitmapInfoHeader));
bih.width = TO_LE32(w);
bih.height = TO_LE32(h);
@@ -101,7 +101,7 @@
bih.clrused = 0;
bih.clrimp = 0;
- // convert the palette to the windows format
+ /* convert the palette to the windows format */
for (i = 0; i != 256; i++) {
rq[i].red = palette[i].r;
rq[i].green = palette[i].g;
@@ -109,15 +109,15 @@
rq[i].reserved = 0;
}
- // write file header and info header and palette
+ /* write file header and info header and palette */
if (fwrite(&bfh, sizeof(bfh), 1, f) != 1) return false;
if (fwrite(&bih, sizeof(bih), 1, f) != 1) return false;
if (fwrite(rq, sizeof(rq), 1, f) != 1) return false;
- // use by default 64k temp memory
+ /* use by default 64k temp memory */
maxlines = clamp(65536 / padw, 16, 128);
- // now generate the bitmap bits
+ /* now generate the bitmap bits */
Pixel *buff = MallocT(padw * maxlines); // by default generate 128 lines at a time.
if (buff == NULL) {
fclose(f);
@@ -125,16 +125,16 @@
}
memset(buff, 0, padw * maxlines); // zero the buffer to have the padding bytes set to 0
- // start at the bottom, since bitmaps are stored bottom up.
+ /* start at the bottom, since bitmaps are stored bottom up. */
do {
- // determine # lines
+ /* determine # lines */
n = min(h, maxlines);
h -= n;
- // render the pixels
+ /* render the pixels */
callb(userdata, buff, h, padw, n);
- // write each line
+ /* write each line */
while (n)
if (fwrite(buff + (--n) * padw, padw, 1, f) != 1) {
free(buff);
@@ -175,7 +175,7 @@
png_structp png_ptr;
png_infop info_ptr;
- // only implemented for 8bit images so far.
+ /* only implemented for 8bit images so far. */
if (pixelformat != 8)
return false;
@@ -209,7 +209,7 @@
png_set_IHDR(png_ptr, info_ptr, w, h, pixelformat, PNG_COLOR_TYPE_PALETTE,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
- // convert the palette to the .PNG format.
+ /* convert the palette to the .PNG format. */
for (i = 0; i != 256; i++) {
rq[i].red = palette[i].r;
rq[i].green = palette[i].g;
@@ -220,10 +220,10 @@
png_write_info(png_ptr, info_ptr);
png_set_flush(png_ptr, 512);
- // use by default 64k temp memory
+ /* use by default 64k temp memory */
maxlines = clamp(65536 / w, 16, 128);
- // now generate the bitmap bits
+ /* now generate the bitmap bits */
Pixel *buff = MallocT(w * maxlines); // by default generate 128 lines at a time.
if (buff == NULL) {
png_destroy_write_struct(&png_ptr, &info_ptr);
@@ -234,14 +234,14 @@
y = 0;
do {
- // determine # lines to write
+ /* determine # lines to write */
n = min(h - y, maxlines);
- // render the pixels into the buffer
+ /* render the pixels into the buffer */
callb(userdata, buff, y, w, n);
y += n;
- // write them to png
+ /* write them to png */
for (i = 0; i != n; i++)
png_write_row(png_ptr, buff + i * w);
} while (y != h);
@@ -295,7 +295,7 @@
memset(&pcx, 0, sizeof(pcx));
- // setup pcx header
+ /* setup pcx header */
pcx.manufacturer = 10;
pcx.version = 5;
pcx.rle = 1;
@@ -310,16 +310,16 @@
pcx.width = pcx.pitch = TO_LE16(w);
pcx.height = TO_LE16(h);
- // write pcx header
+ /* write pcx header */
if (fwrite(&pcx, sizeof(pcx), 1, f) != 1) {
fclose(f);
return false;
}
- // use by default 64k temp memory
+ /* use by default 64k temp memory */
maxlines = clamp(65536 / w, 16, 128);
- // now generate the bitmap bits
+ /* now generate the bitmap bits */
Pixel *buff = MallocT(w * maxlines); // by default generate 128 lines at a time.
if (buff == NULL) {
fclose(f);
@@ -329,22 +329,22 @@
y = 0;
do {
- // determine # lines to write
+ /* determine # lines to write */
uint n = min(h - y, maxlines);
uint i;
- // render the pixels into the buffer
+ /* render the pixels into the buffer */
callb(userdata, buff, y, w, n);
y += n;
- // write them to pcx
+ /* write them to pcx */
for (i = 0; i != n; i++) {
const Pixel* bufp = buff + i * w;
byte runchar = bufp[0];
uint runcount = 1;
uint j;
- // for each pixel...
+ /* for each pixel... */
for (j = 1; j < w; j++) {
Pixel ch = bufp[j];
@@ -366,7 +366,7 @@
runcount++;
}
- // write remaining bytes..
+ /* write remaining bytes.. */
if (runcount > 1 || (runchar & 0xC0) == 0xC0)
if (fputc(0xC0 | runcount, f) == EOF) {
free(buff);
@@ -383,7 +383,7 @@
free(buff);
- // write 8-bit color palette
+ /* write 8-bit color palette */
if (fputc(12, f) == EOF) {
fclose(f);
return false;
@@ -445,7 +445,7 @@
strcpy(_screenshot_format_name, _screenshot_formats[i].extension);
}
-// screenshot generator that dumps the current video buffer
+/* screenshot generator that dumps the current video buffer */
static void CurrentScreenCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
{
for (; n > 0; --n) {
@@ -455,7 +455,7 @@
}
}
-// generate a large piece of the world
+/* generate a large piece of the world */
static void LargeWorldCallback(void *userdata, Pixel *buf, uint y, uint pitch, uint n)
{
ViewPort *vp = (ViewPort *)userdata;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/screenshot.h
--- a/src/screenshot.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/screenshot.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file screenshot.h */
+
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/sdl.cpp
--- a/src/sdl.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/sdl.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sdl.cpp */
+
#include "stdafx.h"
#ifdef WITH_SDL
diff -r 3b068c3a1c74 -r 0fa543611bbe src/sdl.h
--- a/src/sdl.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/sdl.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sdl.h */
+
#ifndef SDL_H
#define SDL_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/settings.cpp
--- a/src/settings.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/settings.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,6 +1,6 @@
/* $Id$ */
-/** @file
+/** @file settings.cpp
* All actions handling saving and loading of the settings/configuration goes on in this file.
* The file consists of four parts:
*
@@ -95,10 +95,10 @@
size = ALIGN(size, sizeof(void*));
- // first check if there's memory in the next pool
+ /* first check if there's memory in the next pool */
if (p->next && p->next->pos + size <= p->next->size) {
p = p->next;
- // then check if there's not memory in the cur pool
+ /* then check if there's not memory in the cur pool */
} else if (p->pos + size > p->size) {
SettingsMemoryPool *n = pool_new(size);
*pool = n;
@@ -130,7 +130,7 @@
}
}
-// structs describing the ini format.
+/** structs describing the ini format. */
struct IniItem {
char *name;
char *value;
@@ -139,21 +139,21 @@
};
struct IniGroup {
- char *name; // name of group
- char *comment; //comment for group
+ char *name; ///< name of group
+ char *comment; ///pool, sizeof(IniGroup));
@@ -199,7 +199,7 @@
return item;
}
-// load an ini file into the "abstract" format
+/** load an ini file into the "abstract" format */
static IniFile *ini_load(const char *filename)
{
char buffer[1024], c, *s, *t, *e;
@@ -217,23 +217,23 @@
in = fopen(filename, "r");
if (in == NULL) return ini;
- // for each line in the file
+ /* for each line in the file */
while (fgets(buffer, sizeof(buffer), in)) {
- // trim whitespace from the left side
+ /* trim whitespace from the left side */
for (s = buffer; *s == ' ' || *s == '\t'; s++);
- // trim whitespace from right side.
+ /* trim whitespace from right side. */
e = s + strlen(s);
while (e > s && ((c=e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--;
*e = '\0';
- // skip comments and empty lines
+ /* skip comments and empty lines */
if (*s == '#' || *s == ';' || *s == '\0') {
uint ns = comment_size + (e - s + 1);
uint a = comment_alloc;
uint pos;
- // add to comment
+ /* add to comment */
if (ns > a) {
a = max(a, 128U);
do a*=2; while (a < ns);
@@ -246,7 +246,7 @@
continue;
}
- // it's a group?
+ /* it's a group? */
if (s[0] == '[') {
if (e[-1] != ']') {
ShowInfoF("ini: invalid group name '%s'", buffer);
@@ -260,30 +260,36 @@
comment_size = 0;
}
} else if (group) {
- // find end of keyname
- for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
+ /* find end of keyname */
+ if (*s == '\"') {
+ s++;
+ for (t = s; *t != '\0' && *t != '\"'; t++);
+ if (*t == '\"') *t = ' ';
+ } else {
+ for (t = s; *t != '\0' && *t != '=' && *t != '\t' && *t != ' '; t++);
+ }
- // it's an item in an existing group
+ /* it's an item in an existing group */
item = ini_item_alloc(group, s, t-s);
if (comment_size) {
item->comment = (char*)pool_strdup(&ini->pool, comment, comment_size);
comment_size = 0;
}
- // find start of parameter
+ /* find start of parameter */
while (*t == '=' || *t == ' ' || *t == '\t') t++;
- // remove starting quotation marks
+ /* remove starting quotation marks */
if (*t == '\"') t++;
- // remove ending quotation marks
+ /* remove ending quotation marks */
e = t + strlen(t);
if (e > t && e[-1] == '\"') e--;
*e = '\0';
item->value = (char*)pool_strdup(&ini->pool, t, e - t);
} else {
- // it's an orphan item
+ /* it's an orphan item */
ShowInfoF("ini: '%s' outside of group", buffer);
}
}
@@ -299,25 +305,25 @@
return ini;
}
-// lookup a group or make a new one
+/** lookup a group or make a new one */
static IniGroup *ini_getgroup(IniFile *ini, const char *name, int len)
{
IniGroup *group;
if (len == -1) len = strlen(name);
- // does it exist already?
+ /* does it exist already? */
for (group = ini->group; group; group = group->next)
if (!memcmp(group->name, name, len) && group->name[len] == 0)
return group;
- // otherwise make a new one
+ /* otherwise make a new one */
group = ini_group_alloc(ini, name, len);
group->comment = (char*)pool_strdup(&ini->pool, "\n", 1);
return group;
}
-// lookup an item or make a new one
+/** lookup an item or make a new one */
static IniItem *ini_getitem(IniGroup *group, const char *name, bool create)
{
IniItem *item;
@@ -328,11 +334,11 @@
if (!create) return NULL;
- // otherwise make a new one
+ /* otherwise make a new one */
return ini_item_alloc(group, name, len);
}
-// save ini file from the "abstract" format.
+/** save ini file from the "abstract" format. */
static bool ini_save(const char *filename, IniFile *ini)
{
FILE *f;
@@ -349,11 +355,18 @@
assert(item->value != NULL);
if (item->comment != NULL) fputs(item->comment, f);
+ /* protect item->name with quotes if needed */
+ if (strchr(item->name, ' ') != NULL) {
+ fprintf(f, "\"%s\"", item->name);
+ } else {
+ fprintf(f, "%s", item->name);
+ }
+
/* Don't give an equal sign to list items that don't have a parameter */
if (group->type == IGT_LIST && *item->value == '\0') {
- fprintf(f, "%s\n", item->name);
+ fprintf(f, "\n");
} else {
- fprintf(f, "%s = %s\n", item->name, item->value);
+ fprintf(f, " = %s\n", item->value);
}
}
}
@@ -380,13 +393,13 @@
if (onelen == -1) onelen = strlen(one);
- // check if it's an integer
+ /* check if it's an integer */
if (*one >= '0' && *one <= '9')
return strtoul(one, NULL, 0);
idx = 0;
for (;;) {
- // find end of item
+ /* find end of item */
s = many;
while (*s != '|' && *s != 0) s++;
if (s - many == onelen && !memcmp(one, many, onelen)) return idx;
@@ -408,7 +421,7 @@
uint32 res = 0;
for (;;) {
- // skip "whitespace"
+ /* skip "whitespace" */
while (*str == ' ' || *str == '\t' || *str == '|') str++;
if (*str == 0) break;
@@ -522,7 +535,7 @@
{
int orig_id = id;
- // Look for the id'th element
+ /* Look for the id'th element */
while (--id >= 0) {
for (; *many != '|'; many++) {
if (*many == '\0') { // not found
@@ -533,7 +546,7 @@
many++; // pass the |-character
}
- // copy string until next item (|) or the end of the list if this is the last one
+ /* copy string until next item (|) or the end of the list if this is the last one */
while (*many != '\0' && *many != '|') *buf++ = *many++;
*buf = '\0';
}
@@ -685,7 +698,7 @@
if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
- // XXX - wtf is this?? (group override?)
+ /* XXX - wtf is this?? (group override?) */
s = strchr(sdb->name, '.');
if (s != NULL) {
group = ini_getgroup(ini, sdb->name, s - sdb->name);
@@ -761,7 +774,7 @@
if (!SlIsObjectCurrentlyValid(sld->version_from, sld->version_to)) continue;
if (sld->conv & SLF_CONFIG_NO) continue;
- // XXX - wtf is this?? (group override?)
+ /* XXX - wtf is this?? (group override?) */
s = strchr(sdb->name, '.');
if (s != NULL) {
group = ini_getgroup(ini, sdb->name, s - sdb->name);
@@ -776,7 +789,7 @@
ptr = GetVariableAddress(object, sld);
if (item->value != NULL) {
- // check if the value is the same as the old value
+ /* check if the value is the same as the old value */
const void *p = string_to_val(sdb, item->value);
/* The main type of a variable/setting is in bytes 8-15
@@ -929,7 +942,8 @@
* 2. SDT_something
* The 'G' stands for global, so this is the one you will use for a
* SettingDescGlobVarList section meaning global variables. The other uses a
- * Base/Offset and runtime variable selection mechanism, known from the saveload * convention (it also has global so it should not be hard).
+ * Base/Offset and runtime variable selection mechanism, known from the saveload
+ * convention (it also has global so it should not be hard).
* Of each type there are again two versions, the normal one and one prefixed
* with 'COND'.
* COND means that the setting is only valid in certain savegame versions
@@ -1052,7 +1066,6 @@
/* Shortcuts for macros below. Logically if we don't save the value
* we also don't sync it in a network game */
#define S SLF_SAVE_NO | SLF_NETWORK_NO
-#define NS SLF_SAVE_NO
#define C SLF_CONFIG_NO
#define N SLF_NETWORK_NO
@@ -1069,7 +1082,7 @@
#include "gui.h"
#include "town.h"
#include "gfx.h"
-// virtual PositionMainToolbar function, calls the right one.
+/* virtual PositionMainToolbar function, calls the right one.*/
static int32 v_PositionMainToolbar(int32 p1)
{
if (_game_mode != GM_MENU) PositionMainToolbar(NULL);
@@ -1205,7 +1218,7 @@
#endif /* WIN32 */
static const SettingDescGlobVarList _misc_settings[] = {
- SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_TRANS_BUILDINGS|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|TRANS_BUILDINGS|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
+ SDTG_MMANY("display_opt", SLE_UINT8, S, 0, _display_opt, (DO_SHOW_TOWN_NAMES|DO_SHOW_STATION_NAMES|DO_SHOW_SIGNS|DO_FULL_ANIMATION|DO_FULL_DETAIL|DO_WAYPOINTS), "SHOW_TOWN_NAMES|SHOW_STATION_NAMES|SHOW_SIGNS|FULL_ANIMATION|FULL_DETAIL|WAYPOINTS", STR_NULL, NULL),
SDTG_BOOL("news_ticker_sound", S, 0, _news_ticker_sound, true, STR_NULL, NULL),
SDTG_BOOL("fullscreen", S, 0, _fullscreen, false, STR_NULL, NULL),
SDTG_STR("videodriver", SLE_STRB,C|S,0, _ini_videodriver, NULL, STR_NULL, NULL),
@@ -1380,6 +1393,8 @@
SDT_VAR(Patches, ending_year, SLE_INT32,0,NC|NO,2051, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_ENDING_YEAR, NULL),
SDT_BOOL(Patches, smooth_economy, 0, 0, true, STR_CONFIG_PATCHES_SMOOTH_ECONOMY, NULL),
SDT_BOOL(Patches, allow_shares, 0, 0, false, STR_CONFIG_PATCHES_ALLOW_SHARES, NULL),
+ SDT_CONDVAR(Patches, town_growth_rate, SLE_UINT8, 54, SL_MAX_VERSION, 0, MS, 2, 0, 4, 0, STR_CONFIG_PATCHES_TOWN_GROWTH, NULL),
+ SDT_CONDVAR(Patches, larger_towns, SLE_UINT8, 54, SL_MAX_VERSION, 0, D0, 4, 0, 255, 1, STR_CONFIG_PATCHES_LARGER_TOWNS, NULL),
/***************************************************************************/
/* AI section of the GUI-configure patches window */
@@ -1461,7 +1476,7 @@
SDT_CONDVAR (Patches, npf_road_drive_through_penalty, SLE_UINT, 47, SL_MAX_VERSION, 0, 0, 8 * NPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- // The maximum number of nodes to search
+ /* The maximum number of nodes to search */
SDT_CONDBOOL(Patches, yapf.disable_node_optimization , 28, SL_MAX_VERSION, 0, 0, false , STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.max_search_nodes , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10000 , 500, 1000000, 0, STR_NULL, NULL),
SDT_CONDBOOL(Patches, yapf.rail_firstred_twoway_eol , 28, SL_MAX_VERSION, 0, 0, true , STR_NULL, NULL),
@@ -1473,22 +1488,22 @@
SDT_CONDVAR (Patches, yapf.rail_slope_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_curve45_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_curve90_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 6 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- // This penalty is applied when a train reverses inside a depot
+ /* This penalty is applied when a train reverses inside a depot */
SDT_CONDVAR (Patches, yapf.rail_depot_reverse_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 50 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- // This is the penalty for level crossings (for trains only)
+ /* This is the penalty for level crossings (for trains only) */
SDT_CONDVAR (Patches, yapf.rail_crossing_penalty , SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
- // look-ahead how many signals are checked
+ /* look-ahead how many signals are checked */
SDT_CONDVAR (Patches, yapf.rail_look_ahead_max_signals, SLE_UINT, 28, SL_MAX_VERSION, 0, 0, 10 , 1, 100, 0, STR_NULL, NULL),
- // look-ahead n-th red signal penalty polynomial: penalty = p2 * n^2 + p1 * n + p0
+ /* look-ahead n-th red signal penalty polynomial: penalty = p2 * n^2 + p1 * n + p0 */
SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p0 , SLE_INT , 28, SL_MAX_VERSION, 0, 0, 500 , -1000000, 1000000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p1 , SLE_INT , 28, SL_MAX_VERSION, 0, 0, -100 , -1000000, 1000000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_look_ahead_signal_p2 , SLE_INT , 28, SL_MAX_VERSION, 0, 0, 5 , -1000000, 1000000, 0, STR_NULL, NULL),
- // penalties for too long or too short station platforms
+ /* penalties for too long or too short station platforms */
SDT_CONDVAR (Patches, yapf.rail_longer_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 8 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_longer_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_shorter_platform_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 40 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.rail_shorter_platform_per_tile_penalty, SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 0 * YAPF_TILE_LENGTH, 0, 20000, 0, STR_NULL, NULL),
- // road vehicles - penalties
+ /* road vehicles - penalties */
SDT_CONDVAR (Patches, yapf.road_slope_penalty , SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 2 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.road_curve_penalty , SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 1 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
SDT_CONDVAR (Patches, yapf.road_crossing_penalty , SLE_UINT, 33, SL_MAX_VERSION, 0, 0, 3 * YAPF_TILE_LENGTH, 0, 1000000, 0, STR_NULL, NULL),
@@ -1577,7 +1592,7 @@
for (item = group->item; item != NULL; item = item->next) {
GRFConfig *c = CallocT(1);
- c->filename = strdup(item->name);
+ c->full_path = strdup(item->name);
/* Parse parameters */
if (*item->value != '\0') {
@@ -1654,7 +1669,7 @@
char params[512];
GRFBuildParamList(params, c, lastof(params));
- *item = ini_item_alloc(group, c->filename, strlen(c->filename));
+ *item = ini_item_alloc(group, c->full_path, strlen(c->full_path));
(*item)->value = (char*)pool_strdup(&ini->pool, params, strlen(params));
item = &(*item)->next;
}
@@ -1830,6 +1845,25 @@
name, value, (sd->desc.flags & SGF_0ISDISABLED) ? "(0) " : "", sd->desc.min, sd->desc.max);
}
+void IConsoleListPatches()
+{
+ IConsolePrintF(_icolour_warn, "All patches with their current value:");
+
+ for (const SettingDesc *sd = _patch_settings; sd->save.cmd != SL_END; sd++) {
+ char value[80];
+ const void *ptr = GetVariableAddress((_game_mode == GM_MENU) ? &_patches_newgame : &_patches, &sd->save);
+
+ if (sd->desc.cmd == SDT_BOOLX) {
+ snprintf(value, lengthof(value), (*(bool*)ptr == 1) ? "on" : "off");
+ } else {
+ snprintf(value, lengthof(value), "%d", (uint32)ReadValue(ptr, sd->save.conv));
+ }
+ IConsolePrintF(_icolour_def, "%s = %s", sd->desc.name, value);
+ }
+
+ IConsolePrintF(_icolour_warn, "Use 'patch' command to change a value");
+}
+
/** Save and load handler for patches/settings
* @param osd SettingDesc struct containing all information
* @param object can be either NULL in which case we load global variables or
diff -r 3b068c3a1c74 -r 0fa543611bbe src/settings.h
--- a/src/settings.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/settings.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file settings.h */
+
#ifndef SETTINGS_H
#define SETTINGS_H
@@ -12,12 +14,12 @@
enum SettingDescTypeLong {
/* 4 bytes allocated a maximum of 16 types for GenericType */
SDT_BEGIN = 0,
- SDT_NUMX = 0, // any number-type
- SDT_BOOLX = 1, // a boolean number
- SDT_ONEOFMANY = 2, // bitmasked number where only ONE bit may be set
- SDT_MANYOFMANY = 3, // bitmasked number where MULTIPLE bits may be set
- SDT_INTLIST = 4, // list of integers seperated by a comma ','
- SDT_STRING = 5, // string with a pre-allocated buffer
+ SDT_NUMX = 0, ///< any number-type
+ SDT_BOOLX = 1, ///< a boolean number
+ SDT_ONEOFMANY = 2, ///< bitmasked number where only ONE bit may be set
+ SDT_MANYOFMANY = 3, ///< bitmasked number where MULTIPLE bits may be set
+ SDT_INTLIST = 4, ///< list of integers seperated by a comma ','
+ SDT_STRING = 5, ///< string with a pre-allocated buffer
SDT_END,
/* 10 more possible primitives */
};
@@ -84,6 +86,7 @@
bool IConsoleSetPatchSetting(const char *name, int32 value);
void IConsoleGetPatchSetting(const char *name);
+void IConsoleListPatches();
const SettingDesc *GetPatchFromName(const char *name, uint *i);
bool SetPatchValue(uint index, const Patches *object, int32 value);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/settings_gui.cpp
--- a/src/settings_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/settings_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file settings_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
@@ -397,7 +399,7 @@
GAMEDIFF_WND_ROWSIZE = 9
};
-// Temporary holding place of values in the difficulty window until 'Save' is clicked
+/* Temporary holding place of values in the difficulty window until 'Save' is clicked */
static GameOptions _opt_mod_temp;
// 0x383E = (1 << 13) | (1 << 12) | (1 << 11) | (1 << 5) | (1 << 4) | (1 << 3) | (1 << 2) | (1 << 1)
#define DIFF_INGAME_DISABLED_BUTTONS 0x383E
@@ -461,7 +463,7 @@
uint btn, dis;
int16 val;
- // Don't allow clients to make any changes
+ /* Don't allow clients to make any changes */
if (_networking && !_network_server)
return;
@@ -473,12 +475,12 @@
if (y < 0)
return;
- // Get button from Y coord.
+ /* Get button from Y coord. */
btn = y / (GAMEDIFF_WND_ROWSIZE + 2);
if (btn >= GAME_DIFFICULTY_NUM || y % (GAMEDIFF_WND_ROWSIZE + 2) >= 9)
return;
- // Clicked disabled button?
+ /* Clicked disabled button? */
dis = (_game_mode == GM_NORMAL) ? DIFF_INGAME_DISABLED_BUTTONS : 0;
if (HASBIT(dis, btn))
@@ -639,6 +641,8 @@
"ending_year",
"smooth_economy",
"allow_shares",
+ "town_growth_rate",
+ "larger_towns",
};
static const char *_patches_ai[] = {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/ship.h
--- a/src/ship.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/ship.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file ship.h */
+
#ifndef SHIP_H
#define SHIP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/ship_cmd.cpp
--- a/src/ship_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/ship_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,10 +1,13 @@
/* $Id$ */
+/** @file ship_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "ship.h"
#include "table/strings.h"
#include "functions.h"
+#include "landscape.h"
#include "map.h"
#include "tile.h"
#include "vehicle.h"
@@ -62,8 +65,8 @@
/** Get the size of the sprite of a ship sprite heading west (used for lists)
* @param engine The engine to get the sprite from
- * @param &width The width of the sprite
- * @param &height The height of the sprite
+ * @param width The width of the sprite
+ * @param height The height of the sprite
*/
void GetShipSpriteSize(EngineID engine, uint &width, uint &height)
{
@@ -191,7 +194,7 @@
SubtractMoneyFromPlayerFract(v->owner, cost);
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
- //we need this for the profit
+ /* we need this for the profit */
InvalidateWindowClasses(WC_SHIPS_LIST);
}
@@ -376,10 +379,10 @@
tile = v->tile;
axis = GetShipDepotAxis(tile);
- // Check first side
+ /* Check first side */
if (_ship_sometracks[axis] & GetTileShipTrackStatus(TILE_ADD(tile, ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
m = (axis == AXIS_X) ? 0x101 : 0x207;
- // Check second side
+ /* Check second side */
} else if (_ship_sometracks[axis + 2] & GetTileShipTrackStatus(TILE_ADD(tile, -2 * ToTileIndexDiff(_ship_leave_depot_offs[axis])))) {
m = (axis == AXIS_X) ? 0x105 : 0x203;
} else {
@@ -405,14 +408,14 @@
spd = min(v->cur_speed + 1, v->max_speed);
- //updates statusbar only if speed have changed to save CPU time
+ /*updates statusbar only if speed have changed to save CPU time */
if (spd != v->cur_speed) {
v->cur_speed = spd;
if (_patches.vehicle_speed)
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
- // Decrease somewhat when turning
+ /* Decrease somewhat when turning */
if (!(v->direction & 1)) spd = spd * 3 / 4;
if (spd == 0) return false;
@@ -455,7 +458,7 @@
static bool ShipTrackFollower(TileIndex tile, PathFindShip *pfs, int track, uint length, byte *state)
{
- // Found dest?
+ /* Found dest? */
if (tile == pfs->dest_coords) {
pfs->best_bird_dist = 0;
@@ -463,7 +466,7 @@
return true;
}
- // Skip this tile in the calculation
+ /* Skip this tile in the calculation */
if (tile != pfs->skiptile) {
pfs->best_bird_dist = minu(pfs->best_bird_dist, DistanceMaxPlusManhattan(pfs->dest_coords, tile));
}
@@ -543,7 +546,7 @@
return ret;
}
-/* returns the track to choose on the next tile, or -1 when it's better to
+/** returns the track to choose on the next tile, or -1 when it's better to
* reverse. The tile given is the tile we are about to enter, enterdir is the
* direction in which we are entering the tile */
static Track ChooseShipTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
@@ -558,7 +561,7 @@
NPFFoundTargetData ftd;
TileIndex src_tile = TILE_ADD(tile, TileOffsByDiagDir(ReverseDiagDir(enterdir)));
Trackdir trackdir = GetVehicleTrackdir(v);
- assert(trackdir != INVALID_TRACKDIR); /* Check that we are not in a depot */
+ assert(trackdir != INVALID_TRACKDIR); // Check that we are not in a depot
NPFFillWithOrderData(&fstd, v);
@@ -731,7 +734,7 @@
/* Process station in the orderlist. */
st = GetStation(v->current_order.dest);
- if (st->facilities & FACIL_DOCK) { /* ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations */
+ if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
v->BeginLoading();
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
v->current_order.flags |= OF_NON_STOP;
@@ -743,7 +746,7 @@
MarkShipDirty(v);
}
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
- } else { /* leave stations without docks right aways */
+ } else { // leave stations without docks right aways
v->current_order.type = OT_LEAVESTATION;
v->cur_order_index++;
InvalidateVehicleOrder(v);
@@ -834,6 +837,7 @@
/** Build a ship.
* @param tile tile of depot where ship is built
+ * @param flags type of operation
* @param p1 ship type being built (engine)
* @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
*/
@@ -844,7 +848,7 @@
UnitID unit_num;
Engine *e;
- if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_SHIP, _current_player)) return_cmd_error(STR_SHIP_NOT_AVAILABLE);
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
@@ -930,6 +934,7 @@
/** Sell a ship.
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID to be sold
* @param p2 unused
*/
@@ -963,6 +968,7 @@
/** Start/Stop a ship.
* @param tile unused
+ * @param flags type of operation
* @param p1 ship ID to start/stop
* @param p2 unused
*/
@@ -1001,6 +1007,7 @@
/** Send a ship to the depot.
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID to send to the depot
* @param p2 various bitmasked elements
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
@@ -1073,6 +1080,7 @@
/** Refits a ship to the specified cargo type.
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID of the ship to refit
* @param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
diff -r 3b068c3a1c74 -r 0fa543611bbe src/ship_gui.cpp
--- a/src/ship_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/ship_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file ship_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -32,7 +34,7 @@
StringID str;
SetWindowWidgetDisabledState(w, 2, v->owner != _local_player);
- // disable service-scroller when interval is set to disabled
+ /* disable service-scroller when interval is set to disabled */
SetWindowWidgetDisabledState(w, 5, !_patches.servint_ships);
SetWindowWidgetDisabledState(w, 6, !_patches.servint_ships);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/signs.cpp
--- a/src/signs.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/signs.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,9 +1,12 @@
/* $Id$ */
+/** @file signs.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
#include "functions.h"
+#include "landscape.h"
#include "player.h"
#include "signs.h"
#include "saveload.h"
@@ -30,6 +33,7 @@
/**
*
* Update the coordinate of one sign
+ * @param si Pointer to the Sign
*
*/
static void UpdateSignVirtCoords(Sign *si)
@@ -97,6 +101,10 @@
return NULL;
}
+/**
+ * Destroy a sign placed on the map
+ * @param si Pointer to the Sign to remove
+ */
void DestroySign(Sign *si)
{
DeleteName(si->str);
@@ -107,6 +115,7 @@
* no effect whatsoever except for the colour the sign gets for easy recognition,
* but everybody is able to rename/remove it.
* @param tile tile to place sign at
+ * @param flags type of operation
* @param p1 unused
* @param p2 unused
*/
@@ -142,8 +151,10 @@
* the user wanted to delete it. So delete it. Ownership of signs
* has no meaning/effect whatsoever except for eyecandy
* @param tile unused
+ * @param flags type of operation
* @param p1 index of the sign to be renamed/removed
* @param p2 unused
+ * @return 0 if succesfull, otherwise CMD_ERROR
*/
int32 CmdRenameSign(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -175,7 +186,7 @@
/* Free the name, because we did not assign it yet */
DeleteName(str);
}
- } else { /* Delete sign */
+ } else { // Delete sign
if (flags & DC_EXEC) {
Sign *si = GetSign(p1);
@@ -191,9 +202,11 @@
}
/**
- *
* Callback function that is called after a sign is placed
- *
+ * @param success of the operation
+ * @param tile unused
+ * @param p1 unused
+ * @param p2 unused
*/
void CcPlaceSign(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
@@ -207,7 +220,7 @@
*
* PlaceProc function, called when someone pressed the button if the
* sign-tool is selected
- *
+ * @param tile on which to place the sign
*/
void PlaceProc_Sign(TileIndex tile)
{
diff -r 3b068c3a1c74 -r 0fa543611bbe src/signs.h
--- a/src/signs.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/signs.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file signs.h */
+
#ifndef SIGNS_H
#define SIGNS_H
@@ -62,7 +64,7 @@
void UpdateAllSignVirtCoords();
void PlaceProc_Sign(TileIndex tile);
-/* misc.c */
+/* misc.cpp */
void ShowRenameSignWindow(const Sign *si);
void ShowSignList();
diff -r 3b068c3a1c74 -r 0fa543611bbe src/signs_gui.cpp
--- a/src/signs_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/signs_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file signs_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/slope.h
--- a/src/slope.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/slope.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file slope.h */
+
#ifndef SLOPE_H
#define SLOPE_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/smallmap_gui.cpp
--- a/src/smallmap_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/smallmap_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file smallmap_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
@@ -9,6 +11,7 @@
#include "station_map.h"
#include "table/strings.h"
#include "table/sprites.h"
+#include "landscape.h"
#include "map.h"
#include "tile.h"
#include "gui.h"
@@ -332,13 +335,13 @@
Pixel *dst_ptr_end = _screen.dst_ptr + _screen.width * _screen.height - _screen.width;
do {
- // check if the tile (xc,yc) is within the map range
+ /* check if the tile (xc,yc) is within the map range */
if (xc < MapMaxX() && yc < MapMaxY()) {
- // check if the dst pointer points to a pixel inside the screen buffer
+ /* check if the dst pointer points to a pixel inside the screen buffer */
if (dst > _screen.dst_ptr && dst < dst_ptr_end)
WRITE_PIXELS_OR(dst, proc(TileXY(xc, yc)) & mask);
}
- // switch to next tile in the column
+ /* switch to next tile in the column */
} while (xc++, yc++, dst += pitch, --reps != 0);
}
@@ -390,32 +393,6 @@
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
}
-/* Industry colours... a total of 175 gfx - XXX - increase if more industries */
-static const byte _industry_smallmap_colors[175] = {
- 215, 215, 215, 215, 215, 215, 215, 184,
- 184, 184, 184, 194, 194, 194, 194, 194,
- 86, 86, 191, 191, 191, 191, 191, 191,
- 152, 152, 152, 152, 152, 152, 152, 152,
- 152, 48, 48, 48, 48, 48, 48, 174,
- 174, 174, 174, 174, 174, 174, 174, 10,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 10, 10, 15, 15, 55, 55, 55, 55,
- 10, 10, 10, 10, 10, 10, 10, 10,
- 194, 194, 194, 194, 194, 194, 194, 194,
- 194, 194, 194, 194, 194, 194, 194, 194,
- 194, 15, 15, 184, 184, 184, 184, 184,
- 184, 184, 184, 184, 55, 55, 55, 55,
- 55, 55, 55, 55, 55, 55, 55, 55,
- 55, 55, 55, 55, 86, 39, 37, 37,
- 208, 174, 174, 174, 174, 194, 194, 194,
- 194, 48, 48, 174, 174, 174, 174, 39,
- 39, 55, 208, 208, 208, 208, 10, 10,
- 10, 10, 10, 10, 37, 37, 37, 37,
- 37, 37, 37, 37, 184, 184, 184, 184,
- 152, 152, 152, 152, 194, 194, 194, 15,
- 15, 15, 15, 15, 15, 15, 15,
-};
-
/**
* Return the color a tile would be displayed with in the small map in mode "Industries".
*
@@ -427,7 +404,7 @@
TileType t = GetEffectiveTileType(tile);
if (t == MP_INDUSTRY) {
- return _industry_smallmap_colors[GetIndustryGfx(tile)] * 0x01010101;
+ return GetIndustrySpec(GetIndustryByTile(tile)->type)->map_colour * 0x01010101;
}
return ApplyMask(MKCOLOR(0x54545454), &_smallmap_vehicles_andor[t]);
@@ -454,7 +431,7 @@
default: bits = MKCOLOR(0xFFFFFFFF); break;
}
} else {
- // ground color
+ /* ground color */
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]);
}
return bits;
@@ -693,7 +670,7 @@
FOR_ALL_VEHICLES(v) {
if (v->type != VEH_SPECIAL &&
(v->vehstatus & (VS_HIDDEN | VS_UNCLICKABLE)) == 0) {
- // Remap into flat coordinates.
+ /* Remap into flat coordinates. */
Point pt = RemapCoords(
v->x_pos / TILE_SIZE - WP(w,smallmap_d).scroll_x / TILE_SIZE, // divide each one separately because (a-b)/c != a/c-b/c in integer world
v->y_pos / TILE_SIZE - WP(w,smallmap_d).scroll_y / TILE_SIZE, // dtto
@@ -701,32 +678,32 @@
x = pt.x;
y = pt.y;
- // Check if y is out of bounds?
+ /* Check if y is out of bounds? */
y -= dpi->top;
if (!IS_INT_INSIDE(y, 0, dpi->height)) continue;
- // Default is to draw both pixels.
+ /* Default is to draw both pixels. */
skip = false;
- // Offset X coordinate
+ /* Offset X coordinate */
x -= WP(w,smallmap_d).subscroll + 3 + dpi->left;
if (x < 0) {
- // if x+1 is 0, that means we're on the very left edge,
- // and should thus only draw a single pixel
+ /* if x+1 is 0, that means we're on the very left edge,
+ * and should thus only draw a single pixel */
if (++x != 0) continue;
skip = true;
} else if (x >= dpi->width - 1) {
- // Check if we're at the very right edge, and if so draw only a single pixel
+ /* Check if we're at the very right edge, and if so draw only a single pixel */
if (x != dpi->width - 1) continue;
skip = true;
}
- // Calculate pointer to pixel and the color
+ /* Calculate pointer to pixel and the color */
ptr = dpi->dst_ptr + y * dpi->pitch + x;
color = (type == 1) ? _vehicle_type_colors[v->type] : 0xF;
- // And draw either one or two pixels depending on clipping
+ /* And draw either one or two pixels depending on clipping */
ptr[0] = color;
if (!skip) ptr[1] = color;
}
@@ -737,7 +714,7 @@
const Town *t;
FOR_ALL_TOWNS(t) {
- // Remap the town coordinate
+ /* Remap the town coordinate */
Point pt = RemapCoords(
(int)(TileX(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_x) / TILE_SIZE,
(int)(TileY(t->xy) * TILE_SIZE - WP(w, smallmap_d).scroll_y) / TILE_SIZE,
@@ -745,23 +722,23 @@
x = pt.x - WP(w,smallmap_d).subscroll + 3 - (t->sign.width_2 >> 1);
y = pt.y;
- // Check if the town sign is within bounds
+ /* Check if the town sign is within bounds */
if (x + t->sign.width_2 > dpi->left &&
x < dpi->left + dpi->width &&
y + 6 > dpi->top &&
y < dpi->top + dpi->height) {
- // And draw it.
+ /* And draw it. */
SetDParam(0, t->index);
DrawString(x, y, STR_2056, 12);
}
}
}
- // Draw map indicators
+ /* Draw map indicators */
{
Point pt;
- // Find main viewport.
+ /* Find main viewport. */
vp = FindWindowById(WC_MAIN_WINDOW,0)->viewport;
pt = RemapCoords(WP(w, smallmap_d).scroll_x, WP(w, smallmap_d).scroll_y, 0);
@@ -1033,7 +1010,7 @@
int x = WP(w, vp_d).scrollpos_x; // Where is the main looking at
int y = WP(w, vp_d).scrollpos_y;
- // set this view to same location. Based on the center, adjusting for zoom
+ /* set this view to same location. Based on the center, adjusting for zoom */
WP(w2, vp_d).scrollpos_x = x - (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
WP(w2, vp_d).scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
} break;
@@ -1094,18 +1071,18 @@
Window *w, *v;
int i = 0;
- // find next free window number for extra viewport
+ /* find next free window number for extra viewport */
while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
w = AllocateWindowDescFront(&_extra_view_port_desc, i);
if (w != NULL) {
int x, y;
- // the main window with the main view
+ /* the main window with the main view */
v = FindWindowById(WC_MAIN_WINDOW, 0);
- // New viewport start ats (zero,zero)
+ /* New viewport start ats (zero,zero) */
AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
- // center on same place as main window (zoom is maximum, no adjustment needed)
+ /* center on same place as main window (zoom is maximum, no adjustment needed) */
x = WP(v, vp_d).scrollpos_x;
y = WP(v, vp_d).scrollpos_y;
WP(w, vp_d).scrollpos_x = x + (v->viewport->virtual_width - (294)) / 2;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/sound.cpp
--- a/src/sound.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/sound.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,8 +1,11 @@
/* $Id$ */
+/** @file sound.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
+#include "landscape.h"
#include "map.h"
#include "mixer.h"
#include "sound.h"
@@ -51,12 +54,12 @@
FioSeekTo(fe->file_offset, SEEK_SET);
- // Check for special case, see else case
+ /* Check for special case, see else case */
FioReadBlock(name, FioReadByte()); // Read the name of the sound
if (strcmp(name, "Corrupt sound") != 0) {
FioSeekTo(12, SEEK_CUR); // Skip past RIFF header
- // Read riff tags
+ /* Read riff tags */
for (;;) {
uint32 tag = FioReadDword();
uint32 size = FioReadDword();
@@ -130,7 +133,7 @@
return true;
}
-// Low level sound player
+/* Low level sound player */
static void StartSound(uint sound, int panning, uint volume)
{
MixerChannel *mc;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/sound.h
--- a/src/sound.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/sound.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sound.h */
+
#ifndef SOUND_H
#define SOUND_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/sprite.h
--- a/src/sprite.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/sprite.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sprite.h */
+
#ifndef SPRITE_H
#define SPRITE_H
@@ -40,7 +42,7 @@
byte draw_proc; /* this allows to specify a special drawing procedure.*/
};
-// Iterate through all DrawTileSeqStructs in DrawTileSprites.
+/** Iterate through all DrawTileSeqStructs in DrawTileSprites. */
#define foreach_draw_tile_seq(idx, list) for (idx = list; ((byte) idx->delta_x) != 0x80; idx++)
diff -r 3b068c3a1c74 -r 0fa543611bbe src/spritecache.cpp
--- a/src/spritecache.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/spritecache.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file spritechache.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -237,7 +239,7 @@
void IncreaseSpriteLRU()
{
- // Increase all LRU values
+ /* Increase all LRU values */
if (_sprite_lru_counter > 16384) {
SpriteID i;
@@ -256,15 +258,15 @@
_sprite_lru_counter = 0;
}
- // Compact sprite cache every now and then.
+ /* Compact sprite cache every now and then. */
if (++_compact_cache_counter >= 740) {
CompactSpriteCache();
_compact_cache_counter = 0;
}
}
-// Called when holes in the sprite cache should be removed.
-// That is accomplished by moving the cached data.
+/** Called when holes in the sprite cache should be removed.
+ * That is accomplished by moving the cached data. */
static void CompactSpriteCache()
{
MemBlock *s;
@@ -277,26 +279,26 @@
MemBlock temp;
SpriteID i;
- // Since free blocks are automatically coalesced, this should hold true.
+ /* Since free blocks are automatically coalesced, this should hold true. */
assert(!(next->size & S_FREE_MASK));
- // If the next block is the sentinel block, we can safely return
+ /* If the next block is the sentinel block, we can safely return */
if (next->size == 0)
break;
- // Locate the sprite belonging to the next pointer.
+ /* Locate the sprite belonging to the next pointer. */
for (i = 0; GetSpriteCache(i)->ptr != next->data; i++) {
assert(i != _spritecache_items);
}
GetSpriteCache(i)->ptr = s->data; // Adjust sprite array entry
- // Swap this and the next block
+ /* Swap this and the next block */
temp = *s;
memmove(s, next, next->size);
s = NextBlock(s);
*s = temp;
- // Coalesce free blocks
+ /* Coalesce free blocks */
while (NextBlock(s)->size & S_FREE_MASK) {
s->size += NextBlock(s)->size & ~S_FREE_MASK;
}
@@ -324,18 +326,18 @@
}
}
- // Display an error message and die, in case we found no sprite at all.
- // This shouldn't really happen, unless all sprites are locked.
+ /* Display an error message and die, in case we found no sprite at all.
+ * This shouldn't really happen, unless all sprites are locked. */
if (best == (uint)-1)
error("Out of sprite memory");
- // Mark the block as free (the block must be in use)
+ /* Mark the block as free (the block must be in use) */
s = (MemBlock*)GetSpriteCache(best)->ptr - 1;
assert(!(s->size & S_FREE_MASK));
s->size |= S_FREE_MASK;
GetSpriteCache(best)->ptr = NULL;
- // And coalesce adjacent free blocks
+ /* And coalesce adjacent free blocks */
for (s = _spritecache_ptr; s->size != 0; s = NextBlock(s)) {
if (s->size & S_FREE_MASK) {
while (NextBlock(s)->size & S_FREE_MASK) {
@@ -364,10 +366,10 @@
* big enough for an additional free block? */
if (cur_size == mem_req ||
cur_size >= mem_req + sizeof(MemBlock)) {
- // Set size and in use
+ /* Set size and in use */
s->size = mem_req;
- // Do we need to inject a free block too?
+ /* Do we need to inject a free block too? */
if (cur_size != mem_req) {
NextBlock(s)->size = (cur_size - mem_req) | S_FREE_MASK;
}
@@ -377,7 +379,7 @@
}
}
- // Reached sentinel, but no block found yet. Delete some old entry.
+ /* Reached sentinel, but no block found yet. Delete some old entry. */
DeleteEntryFromSpriteCache();
}
}
@@ -392,12 +394,12 @@
sc = GetSpriteCache(sprite);
- // Update LRU
+ /* Update LRU */
sc->lru = ++_sprite_lru_counter;
p = sc->ptr;
- // Load the sprite, if it is not loaded, yet
+ /* Load the sprite, if it is not loaded, yet */
if (p == NULL) p = ReadSprite(sc, sprite);
return p;
}
@@ -405,12 +407,12 @@
void GfxInitSpriteMem()
{
- // initialize sprite cache heap
+ /* initialize sprite cache heap */
if (_spritecache_ptr == NULL) _spritecache_ptr = (MemBlock*)malloc(SPRITE_CACHE_SIZE);
- // A big free block
+ /* A big free block */
_spritecache_ptr->size = (SPRITE_CACHE_SIZE - sizeof(MemBlock)) | S_FREE_MASK;
- // Sentinel block (identified by size == 0)
+ /* Sentinel block (identified by size == 0) */
NextBlock(_spritecache_ptr)->size = 0;
/* Reset the spritecache 'pool' */
diff -r 3b068c3a1c74 -r 0fa543611bbe src/spritecache.h
--- a/src/spritecache.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/spritecache.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file spritecache.h */
+
#ifndef SPRITECACHE_H
#define SPRITECACHE_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/station.cpp
--- a/src/station.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/station.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -55,12 +55,12 @@
}
/**
- * Clean up a station by clearing vehicle orders and invalidating windows.
- * Aircraft-Hangar orders need special treatment here, as the hangars are
- * actually part of a station (tiletype is STATION), but the order type
- * is OT_GOTO_DEPOT.
- * @param st Station to be deleted
- */
+ * Clean up a station by clearing vehicle orders and invalidating windows.
+ * Aircraft-Hangar orders need special treatment here, as the hangars are
+ * actually part of a station (tiletype is STATION), but the order type
+ * is OT_GOTO_DEPOT.
+ * @param st Station to be deleted
+ */
Station::~Station()
{
DEBUG(station, cDebugCtorLevel, "I-%3d", index);
@@ -106,7 +106,7 @@
}
/** Called when new facility is built on the station. If it is the first facility
- * it initializes also 'xy' and 'random_bits' members */
+ * it initializes also 'xy' and 'random_bits' members */
void Station::AddFacility(byte new_facility_bit, TileIndex facil_xy)
{
if (facilities == 0) {
@@ -182,7 +182,7 @@
/** Obtain the length of a platform
* @pre tile must be a railway station tile
* @param tile A tile that contains the platform in question
- * @returns The length of the platform
+ * @return The length of the platform
*/
uint Station::GetPlatformLength(TileIndex tile) const
{
diff -r 3b068c3a1c74 -r 0fa543611bbe src/station.h
--- a/src/station.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/station.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file station.h */
+
#ifndef STATION_H
#define STATION_H
@@ -82,8 +84,8 @@
struct StationSpecList {
const StationSpec *spec;
- uint32 grfid; /// GRF ID of this custom station
- uint8 localidx; /// Station ID within GRF of station
+ uint32 grfid; ///< GRF ID of this custom station
+ uint8 localidx; ///< Station ID within GRF of station
};
/** StationRect - used to track station spread out rectangle - cheaper than scanning whole map */
@@ -118,7 +120,7 @@
const AirportFTAClass *Airport() const
{
- assert(airport_tile != 0);
+ if (airport_tile == 0) return GetAirport(AT_DUMMY);
return GetAirport(airport_type);
}
@@ -142,7 +144,7 @@
byte facilities;
byte airport_type;
- // trainstation width/height
+ /* trainstation width/height */
byte trainst_w, trainst_h;
/** List of custom stations (StationSpecs) allocated to the station */
@@ -151,7 +153,7 @@
Date build_date;
- uint64 airport_flags; /// stores which blocks on the airport are taken. was 16 bit earlier on, then 32
+ uint64 airport_flags; ///< stores which blocks on the airport are taken. was 16 bit earlier on, then 32
StationID index;
byte last_vehicle_type;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/station_cmd.cpp
--- a/src/station_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/station_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -9,6 +9,7 @@
#include "cmd_helper.h"
#include "debug.h"
#include "functions.h"
+#include "landscape.h"
#include "station_map.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -118,7 +119,7 @@
static Station* GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
{
- // check around to see if there's any stations there
+ /* check around to see if there's any stations there */
BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
if (IsTileType(tile_cur, MP_STATION)) {
StationID t = GetStationIndex(tile_cur);
@@ -1190,9 +1191,12 @@
/* If it is a drive-through stop check for valid axis */
if (is_drive_through && !IsValidAxis((Axis)p1)) return CMD_ERROR;
/* Road bits in the wrong direction */
- if (build_over_road && (GetRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return CMD_ERROR;
+ if (build_over_road && (GetRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION);
/* Not allowed to build over this road */
- if (build_over_road && !IsTileOwner(tile, _current_player) && !(IsTileOwner(tile, OWNER_TOWN) && _patches.road_stop_on_town_road)) return CMD_ERROR;
+ if (build_over_road) {
+ if (IsTileOwner(tile, OWNER_TOWN) && !_patches.road_stop_on_town_road) return_cmd_error(STR_DRIVE_THROUGH_ERROR_ON_TOWN_ROAD);
+ if (!IsTileOwner(tile, OWNER_TOWN) && !CheckOwnership(GetTileOwner(tile))) return CMD_ERROR;
+ }
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -1600,6 +1604,13 @@
int32 cost = w * h * _eco->GetPrice(CEconomy::REMOVE_AIRPORT);
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (!(v->type == VEH_AIRCRAFT && IsNormalAircraft(v))) continue;
+
+ if (v->u.air.targetairport == st->index && v->u.air.state != FLYING) return CMD_ERROR;
+ }
+
BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
if (!EnsureNoVehicle(tile_cur)) return CMD_ERROR;
@@ -1949,7 +1960,7 @@
}
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else if (HASBIT(image, PALETTE_MODIFIER_COLOR)) {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/station_gui.cpp
--- a/src/station_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/station_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file station_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -51,7 +53,8 @@
* goes for the rating: at above 90% orso (224) it is also 'full'
* Each cargo-bar is 16 pixels wide and 6 pixels high
* Each rating 14 pixels wide and 1 pixel high and is 1 pixel below the cargo-bar
- * @param x,y X/Y coordinate to draw the box at
+ * @param x coordinate to draw the box at
+ * @param y coordinate to draw the box at
* @param type Cargo type
* @param amount Cargo amount
* @param rating ratings data for that particular cargo */
@@ -230,7 +233,7 @@
}
}
}
- //stations without waiting cargo
+ /* stations without waiting cargo */
if (num_waiting_cargo == 0 && include_empty) {
station_sort[n++] = st;
}
@@ -320,7 +323,7 @@
int cg_ofst;
int x = 89;
int y = 14;
- int xb = 2; // offset from left of widget
+ int xb = 2; ///< offset from left of widget
uint i = 0;
for (CargoID c = 0; c < NUM_CARGO; c++) {
@@ -363,7 +366,7 @@
SetDParam(1, st->facilities);
x = DrawString(xb, y, STR_3049_0, 0) + 5;
- // show cargo waiting and station ratings
+ /* show cargo waiting and station ratings */
for (CargoID j = 0; j < NUM_CARGO; j++) {
uint amount = GB(st->goods[j].waiting_acceptance, 0, 12);
if (amount != 0) {
@@ -510,7 +513,7 @@
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
if (sl->sort_type != e->we.dropdown.index) {
- // value has changed -> resort
+ /* value has changed -> resort */
sl->sort_type = e->we.dropdown.index;
station_sort.criteria = sl->sort_type;
sl->flags |= SL_RESORT;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/station_map.cpp
--- a/src/station_map.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/station_map.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file station_map.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "station_map.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/station_map.h
--- a/src/station_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/station_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file station_map.h */
+
#ifndef STATION_MAP_H
#define STATION_MAP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/stdafx.h
--- a/src/stdafx.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/stdafx.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file stdfax.h */
+
#ifndef STDAFX_H
#define STDAFX_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/string.cpp
--- a/src/string.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/string.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file string.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
@@ -123,7 +125,8 @@
* not found, this is sufficient. If more, or general functionality is
* needed, look to r7271 where it was removed because it was broken when
* using certain locales: eg in Turkish the uppercase 'I' was converted to
- * '?', so just revert to the old functionality */
+ * '?', so just revert to the old functionality
+ * @param str string to convert */
void strtolower(char *str)
{
for (; *str != '\0'; str++) *str = tolower(*str);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/string.h
--- a/src/string.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/string.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,26 +1,28 @@
/* $Id$ */
+/** @file string.h */
+
#ifndef STRING_H
#define STRING_H
#include "macros.h"
-/*
- * dst: destination buffer
- * src: string to copy/concatenate
- * size: size of the destination buffer
- * usage: ttd_strlcpy(dst, src, lengthof(dst));
+/**
+ * usage ttd_strlcpy(dst, src, lengthof(dst));
+ * @param dst destination buffer
+ * @param src string to copy/concatenate
+ * @param size size of the destination buffer
*/
void ttd_strlcat(char *dst, const char *src, size_t size);
void ttd_strlcpy(char *dst, const char *src, size_t size);
-/*
- * dst: destination buffer
- * src: string to copy
- * last: pointer to the last element in the dst array
- * if NULL no boundary check is performed
- * returns a pointer to the terminating \0 in the destination buffer
+/**
* usage: strecpy(dst, src, lastof(dst));
+ * @param dst destination buffer
+ * @param src string to copy
+ * @param last pointer to the last element in the dst array
+ * if NULL no boundary check is performed
+ * @return a pointer to the terminating \0 in the destination buffer
*/
char* strecat(char* dst, const char* src, const char* last);
char* strecpy(char* dst, const char* src, const char* last);
@@ -38,9 +40,9 @@
* Valid filter types for IsValidChar.
*/
enum CharSetFilter {
- CS_ALPHANUMERAL, //! Both numeric and alphabetic and spaces and stuff
- CS_NUMERAL, //! Only numeric ones
- CS_ALPHA, //! Only alphabetic values
+ CS_ALPHANUMERAL, ///< Both numeric and alphabetic and spaces and stuff
+ CS_NUMERAL, ///< Only numeric ones
+ CS_ALPHA, ///< Only alphabetic values
};
/** Convert the given string to lowercase, only works with ASCII! */
@@ -105,6 +107,8 @@
* Return the length of an UTF-8 encoded value based on a single char. This
* char should be the first byte of the UTF-8 encoding. If not, or encoding
* is invalid, return value is 0
+ * @param c char to query length of
+ * @return requested size
*/
static inline size_t Utf8EncodedCharLen(char c)
{
@@ -127,7 +131,7 @@
/**
* Retrieve the previous UNICODE character in an UTF-8 encoded string.
* @param s char pointer pointing to (the first char of) the next character
- * @returns a pointer in 's' to the previous UNICODE character's first byte
+ * @return a pointer in 's' to the previous UNICODE character's first byte
* @note The function should not be used to determine the length of the previous
* encoded char because it might be an invalid/corrupt start-sequence
*/
diff -r 3b068c3a1c74 -r 0fa543611bbe src/strings.cpp
--- a/src/strings.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/strings.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file strings.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
@@ -37,7 +39,7 @@
static char *FormatString(char *buff, const char *str, const int32 *argv, uint casei, const char* last);
struct LanguagePack {
- uint32 ident;
+ uint32 ident; // 32-bits identifier
uint32 version; // 32-bits of auto generated version info which is basically a hash of strings.h
char name[32]; // the international name of this language
char own_name[32]; // the localized name of this language
@@ -45,16 +47,16 @@
uint16 offsets[32]; // the offsets
byte plural_form; // how to compute plural forms
byte pad[3]; // pad header to be a multiple of 4
- char data[VARARRAY_SIZE];
+ char data[VARARRAY_SIZE]; // list of strings
};
static char **_langpack_offs;
static LanguagePack *_langpack;
-static uint _langtab_num[32]; // Offset into langpack offs
+static uint _langtab_num[32]; // Offset into langpack offs
static uint _langtab_start[32]; // Offset into langpack offs
-// Read an int64 from the argv array.
+/** Read an int64 from the argv array. */
static inline int64 GetInt64(const int32 **argv)
{
int64 result;
@@ -65,14 +67,14 @@
return result;
}
-// Read an int32 from the argv array.
+/** Read an int32 from the argv array. */
static inline int32 GetInt32(const int32 **argv)
{
assert(argv);
return *(*argv)++;
}
-// Read an array from the argv array.
+/** Read an array from the argv array. */
static inline const int32 *GetArgvPtr(const int32 **argv, int n)
{
const int32 *result;
@@ -85,13 +87,13 @@
#define NUM_BOUND_STRINGS 8
-// Array to hold the bound strings.
+/* Array to hold the bound strings. */
static const char *_bound_strings[NUM_BOUND_STRINGS];
-// This index is used to implement a "round-robin" allocating of
-// slots for BindCString. NUM_BOUND_STRINGS slots are reserved.
-// Which means that after NUM_BOUND_STRINGS calls to BindCString,
-// the indices will be reused.
+/* This index is used to implement a "round-robin" allocating of
+ * slots for BindCString. NUM_BOUND_STRINGS slots are reserved.
+ * Which means that after NUM_BOUND_STRINGS calls to BindCString,
+ * the indices will be reused. */
static int _bind_index;
static const char *GetStringPtr(StringID string)
@@ -99,10 +101,16 @@
return _langpack_offs[_langtab_start[string >> 11] + (string & 0x7FF)];
}
-// The highest 8 bits of string contain the "case index".
-// These 8 bits will only be set when FormatString wants to print
-// the string in a different case. No one else except FormatString
-// should set those bits, therefore string CANNOT be StringID, but uint32.
+/** The highest 8 bits of string contain the "case index".
+ * These 8 bits will only be set when FormatString wants to print
+ * the string in a different case. No one else except FormatString
+ * should set those bits, therefore string CANNOT be StringID, but uint32.
+ * @param buffr
+ * @param string
+ * @param argv
+ * @param last
+ * @return a formatted string of char
+ */
static char *GetStringWithArgs(char *buffr, uint string, const int32 *argv, const char* last)
{
uint index = GB(string, 0, 11);
@@ -122,8 +130,8 @@
return GetSpecialPlayerNameString(buffr, index - 0xE4, argv, last);
break;
- // User defined name
case 15:
+ /* User defined name */
return GetName(buffr, index, last);
case 26:
@@ -147,8 +155,8 @@
return FormatString(buffr, buff, argv, 0, last);
case 31:
- // dynamic strings. These are NOT to be passed through the formatter,
- // but passed through verbatim.
+ /* dynamic strings. These are NOT to be passed through the formatter,
+ * but passed through verbatim. */
if (index < (STR_SPEC_USERSTRING & 0x7FF)) {
return strecpy(buffr, _bound_strings[index], last);
}
@@ -184,7 +192,8 @@
* This function takes a C-string and allocates a temporary string ID.
* The StringID of the bound string is valid until BindCString is called
* another NUM_BOUND_STRINGS times. So be careful when using it.
- *
+ * @param str temp string to add
+ * @return the id of that temp string
* @note formatting a DATE_TINY calls BindCString twice, thus reduces the
* amount of 'user' bound strings by 2.
* @todo rewrite the BindCString system to make the limit flexible and
@@ -198,7 +207,10 @@
return idx + STR_SPEC_DYNSTRING;
}
-// This function is used to "bind" a C string to a OpenTTD dparam slot.
+/** This function is used to "bind" a C string to a OpenTTD dparam slot.
+ * @param n slot of the string
+ * @param str string to bind
+ */
void SetDParamStr(uint n, const char *str)
{
SetDParam(n, BindCString(str));
@@ -331,10 +343,10 @@
char* p;
int j;
- // multiply by exchange rate
+ /* multiply by exchange rate */
number *= spec->rate;
- // convert from negative
+ /* convert from negative */
if (number < 0) {
buff = strecpy(buff, "-", last);
number = -number;
@@ -345,7 +357,7 @@
* The only remaining value is 1 (suffix), so everything that is not 1 */
if (spec->symbol_pos != 1) buff = strecpy(buff, spec->prefix, last);
- // for huge numbers, compact the number into k or M
+ /* for huge numbers, compact the number into k or M */
if (compact) {
if (number >= 1000000000) {
number = (number + 500000) / 1000000;
@@ -356,7 +368,7 @@
}
}
- // convert to ascii number and add commas
+ /* convert to ascii number and add commas */
p = endof(buf);
*--p = '\0';
j = 4;
@@ -381,63 +393,63 @@
static int DeterminePluralForm(int32 n)
{
- // The absolute value determines plurality
+ /* The absolute value determines plurality */
if (n < 0) n = -n;
switch (_langpack->plural_form) {
- // Two forms, singular used for one only
- // Used in:
- // Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
- // Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto
+ /* Two forms, singular used for one only
+ * Used in:
+ * Danish, Dutch, English, German, Norwegian, Swedish, Estonian, Finnish,
+ * Greek, Hebrew, Italian, Portuguese, Spanish, Esperanto */
case 0:
default:
return n != 1;
- // Only one form
- // Used in:
- // Hungarian, Japanese, Korean, Turkish
+ /* Only one form
+ * Used in:
+ * Hungarian, Japanese, Korean, Turkish */
case 1:
return 0;
- // Two forms, singular used for zero and one
- // Used in:
- // French, Brazilian Portuguese
+ /* Two forms, singular used for zero and one
+ * Used in:
+ * French, Brazilian Portuguese */
case 2:
return n > 1;
- // Three forms, special case for zero
- // Used in:
- // Latvian
+ /* Three forms, special case for zero
+ * Used in:
+ * Latvian */
case 3:
return n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;
- // Three forms, special case for one and two
- // Used in:
- // Gaelige (Irish)
+ /* Three forms, special case for one and two
+ * Used in:
+ * Gaelige (Irish) */
case 4:
return n==1 ? 0 : n==2 ? 1 : 2;
- // Three forms, special case for numbers ending in 1[2-9]
- // Used in:
- // Lithuanian
+ /* Three forms, special case for numbers ending in 1[2-9]
+ * Used in:
+ * Lithuanian */
case 5:
return n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n%100<10 || n%100>=20) ? 1 : 2;
- // Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
- // Used in:
- // Croatian, Czech, Russian, Slovak, Ukrainian
+ /* Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
+ * Used in:
+ * Croatian, Czech, Russian, Slovak, Ukrainian */
case 6:
return n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
- // Three forms, special case for one and some numbers ending in 2, 3, or 4
- // Used in:
- // Polish
+ /* Three forms, special case for one and some numbers ending in 2, 3, or 4
+ * Used in:
+ * Polish */
case 7:
return n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
- // Four forms, special case for one and all numbers ending in 02, 03, or 04
- // Used in:
- // Slovenian
+ /* Four forms, special case for one and all numbers ending in 02, 03, or 04
+ * Used in:
+ * Slovenian */
case 8:
return n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;
}
@@ -561,9 +573,9 @@
break;
case SCC_CARGO_SHORT: { /* {SHORTCARGO} */
- // Short description of cargotypes. Layout:
- // 8-bit = cargo type
- // 16-bit = cargo count
+ /* Short description of cargotypes. Layout:
+ * 8-bit = cargo type
+ * 16-bit = cargo count */
StringID cargo_str = GetCargo(GetInt32(&argv))->units_volume;
switch (cargo_str) {
case STR_TONS: {
@@ -599,13 +611,13 @@
} break;
case SCC_CURRENCY_COMPACT_64: { /* {CURRCOMPACT64} */
- // 64 bit compact currency-unit
+ /* 64 bit compact currency-unit */
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), true, last);
break;
}
case SCC_STRING1: { /* {STRING1} */
- // String that consumes ONE argument
+ /* String that consumes ONE argument */
uint str = modifier + GetInt32(&argv);
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 1), last);
modifier = 0;
@@ -613,7 +625,7 @@
}
case SCC_STRING2: { /* {STRING2} */
- // String that consumes TWO arguments
+ /* String that consumes TWO arguments */
uint str = modifier + GetInt32(&argv);
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 2), last);
modifier = 0;
@@ -621,7 +633,7 @@
}
case SCC_STRING3: { /* {STRING3} */
- // String that consumes THREE arguments
+ /* String that consumes THREE arguments */
uint str = modifier + GetInt32(&argv);
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 3), last);
modifier = 0;
@@ -629,7 +641,7 @@
}
case SCC_STRING4: { /* {STRING4} */
- // String that consumes FOUR arguments
+ /* String that consumes FOUR arguments */
uint str = modifier + GetInt32(&argv);
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 4), last);
modifier = 0;
@@ -637,7 +649,7 @@
}
case SCC_STRING5: { /* {STRING5} */
- // String that consumes FIVE arguments
+ /* String that consumes FIVE arguments */
uint str = modifier + GetInt32(&argv);
buff = GetStringWithArgs(buff, str, GetArgvPtr(&argv, 5), last);
modifier = 0;
@@ -653,11 +665,11 @@
const Industry* i = GetIndustry(GetInt32(&argv));
int32 args[2];
- // industry not valid anymore?
+ /* industry not valid anymore? */
if (!IsValidIndustry(i)) break;
- // First print the town name and the industry type name
- // The string STR_INDUSTRY_PATTERN controls the formatting
+ /* First print the town name and the industry type name
+ * The string STR_INDUSTRY_PATTERN controls the formatting */
args[0] = i->town->index;
args[1] = GetIndustrySpec(i->type)->name;
buff = FormatString(buff, GetStringPtr(STR_INDUSTRY_FORMAT), args, modifier >> 24, last);
@@ -690,9 +702,9 @@
}
case SCC_CARGO: { // {CARGO}
- // Layout now is:
- // 8bit - cargo type
- // 16-bit - cargo count
+ /* Layout now is:
+ * 8bit - cargo type
+ * 16-bit - cargo count */
CargoID cargo = GetInt32(&argv);
StringID cargo_str = (cargo == CT_INVALID) ? (StringID)STR_8838_N_A : GetCargo(cargo)->quantifier;
buff = GetStringWithArgs(buff, cargo_str, argv++, last);
@@ -748,17 +760,17 @@
argv++;
break;
- // This sets up the gender for the string.
- // We just ignore this one. It's used in {G 0 Der Die Das} to determine the case.
+ /* This sets up the gender for the string.
+ * We just ignore this one. It's used in {G 0 Der Die Das} to determine the case. */
case SCC_GENDER_INDEX: // {GENDER 0}
str++;
break;
case SCC_STRING: {// {STRING}
uint str = modifier + GetInt32(&argv);
- // WARNING. It's prohibited for the included string to consume any arguments.
- // For included strings that consume argument, you should use STRING1, STRING2 etc.
- // To debug stuff you can set argv to NULL and it will tell you
+ /* WARNING. It's prohibited for the included string to consume any arguments.
+ * For included strings that consume argument, you should use STRING1, STRING2 etc.
+ * To debug stuff you can set argv to NULL and it will tell you */
buff = GetStringWithArgs(buff, str, argv, last);
modifier = 0;
break;
@@ -834,23 +846,23 @@
}
case SCC_SETCASE: { // {SETCASE}
- // This is a pseudo command, it's outputted when someone does {STRING.ack}
- // The modifier is added to all subsequent GetStringWithArgs that accept the modifier.
+ /* This is a pseudo command, it's outputted when someone does {STRING.ack}
+ * The modifier is added to all subsequent GetStringWithArgs that accept the modifier. */
modifier = (byte)*str++ << 24;
break;
}
case SCC_SWITCH_CASE: { // {Used to implement case switching}
- // <0x9E>
- // Each LEN is printed using 2 bytes in big endian order.
+ /* <0x9E>
+ * Each LEN is printed using 2 bytes in big endian order. */
uint num = (byte)*str++;
while (num) {
if ((byte)str[0] == casei) {
- // Found the case, adjust str pointer and continue
+ /* Found the case, adjust str pointer and continue */
str += 3;
break;
}
- // Otherwise skip to the next case
+ /* Otherwise skip to the next case */
str += 3 + (str[1] << 8) + str[2];
num--;
}
@@ -1018,20 +1030,20 @@
return strecpy(buff, origin_songs_specs[GetInt32(&argv) - 1].song_name, last);
}
- // town name?
+ /* town name? */
if (IS_INT_INSIDE(ind - 6, 0, SPECSTR_TOWNNAME_LAST-SPECSTR_TOWNNAME_START + 1)) {
buff = GetSpecialTownNameString(buff, ind - 6, GetInt32(&argv), last);
return strecpy(buff, " Transport", last);
}
- // language name?
+ /* language name? */
if (IS_INT_INSIDE(ind, (SPECSTR_LANGUAGE_START - 0x70E4), (SPECSTR_LANGUAGE_END - 0x70E4) + 1)) {
int i = ind - (SPECSTR_LANGUAGE_START - 0x70E4);
return strecpy(buff,
i == _dynlang.curr ? _langpack->own_name : _dynlang.ent[i].name, last);
}
- // resolution size?
+ /* resolution size? */
if (IS_INT_INSIDE(ind, (SPECSTR_RESOLUTION_START - 0x70E4), (SPECSTR_RESOLUTION_END - 0x70E4) + 1)) {
int i = ind - (SPECSTR_RESOLUTION_START - 0x70E4);
buff += snprintf(
@@ -1040,7 +1052,7 @@
return buff;
}
- // screenshot format name?
+ /* screenshot format name? */
if (IS_INT_INSIDE(ind, (SPECSTR_SCREENSHOT_START - 0x70E4), (SPECSTR_SCREENSHOT_END - 0x70E4) + 1)) {
int i = ind - (SPECSTR_SCREENSHOT_START - 0x70E4);
return strecpy(buff, GetScreenshotFormatDesc(i), last);
@@ -1050,7 +1062,10 @@
return NULL;
}
-// remap a string ID from the old format to the new format
+/**
+ * remap a string ID from the old format to the new format
+ * @param s StringID that requires remapping
+ * @return translated ID*/
StringID RemapOldStringID(StringID s)
{
switch (s) {
@@ -1103,10 +1118,10 @@
tot_count += num;
}
- // Allocate offsets
+ /* Allocate offsets */
langpack_offs = MallocT(tot_count);
- // Fill offsets
+ /* Fill offsets */
s = lang_pack->data;
for (i = 0; i != tot_count; i++) {
len = (byte)*s;
@@ -1133,7 +1148,7 @@
/** Determine the current charset based on the environment
* First check some default values, after this one we passed ourselves
* and if none exist return the value for $LANG
- * @param environment variable to check conditionally if default ones are not
+ * @param param environment variable to check conditionally if default ones are not
* set. Pass NULL if you don't want additional checks.
* @return return string containing current charset, or NULL if not-determinable */
const char *GetCurrentLocale(const char *param)
diff -r 3b068c3a1c74 -r 0fa543611bbe src/strings.h
--- a/src/strings.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/strings.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file strings.h */
+
#ifndef STRINGS_H
#define STRINGS_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/subsidy_gui.cpp
--- a/src/subsidy_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/subsidy_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file subsidy_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/table/build_industry.h
--- a/src/table/build_industry.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/table/build_industry.h Tue Jun 12 11:56:35 2007 +0000
@@ -1068,28 +1068,14 @@
#undef MK
#undef MKEND
-/* Procedures that can be run to check whether an industry may
- * build at location the given to the procedure */
-enum CheckProc {
- CHECK_NOTHING = 0,
- CHECK_FOREST = 1,
- CHECK_REFINERY = 2,
- CHECK_FARM = 3,
- CHECK_PLANTATION = 4,
- CHECK_WATER = 5,
- CHECK_LUMBERMILL = 6,
- CHECK_BUBBLEGEN = 7,
- CHECK_OIL_RIG = 8,
- CHECK_END,
-};
-
-#define MK(tbl, d, c1, c2, c3, proc, p1, r1, p2, r2, m, a1, a2, a3, pr, clim, bev, in, intx, s1, s2, s3) \
+#define MK(tbl, d, ai1, ai2, ai3, ai4, ag1, ag2, ag3, ag4, col,\
+ c1, c2, c3, proc, p1, r1, p2, r2, m, a1, a2, a3, pr, clim, bev, in, intx, s1, s2, s3) \
{tbl, lengthof(tbl), d, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m, \
- {a1, a2, a3}, pr, clim, bev, in, intx, s1, s2, s3}
+ {a1, a2, a3}, pr, clim, bev, col, in, intx, s1, s2, s3, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, 0, 0, 0, 0}
static const IndustrySpec _industry_specs[] = {
/* Format:
- tile table cost multiplier
+ tile table cost multiplier appear chances(4ingame, 4random) map colour
cannot be close to these industries (3 times) check proc
(produced cargo + rate) (twice) minimum cargo moved to station
3 accepted cargo
@@ -1097,7 +1083,7 @@
industry behaviours
industry name building text
messages : Closure production up production down */
- MK(_tile_table_coal_mine, 210,
+ MK(_tile_table_coal_mine, 210, 2, 3, 0, 0, 8, 8, 0, 0, 215,
IT_POWER_STATION, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_COAL, 15, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1106,7 +1092,7 @@
STR_4802_COAL_MINE, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4836_NEW_COAL_SEAM_FOUND_AT, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_power_station, 30,
+ MK(_tile_table_power_station, 30, 2, 2, 0, 0, 5, 5, 0, 0, 184,
IT_COAL_MINE, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_INVALID, 0, CT_INVALID, 0, 5,
CT_COAL, CT_INVALID, CT_INVALID,
@@ -1115,16 +1101,16 @@
STR_4803_POWER_STATION, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_sawmill, 28,
+ MK(_tile_table_sawmill, 28, 2, 0, 0, 0, 5, 0, 0, 0, 194,
IT_FOREST, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_GOODS, 0, CT_INVALID, 0, 5,
CT_WOOD, CT_INVALID, CT_INVALID,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TEMPERATE,
- INDUSTRYBEH_CUT_TREES,
+ INDUSTRYBEH_NONE,
STR_4804_SAWMILL, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_forest, 200,
+ MK(_tile_table_forest, 200, 3, 4, 0, 0, 5, 5, 0, 0, 86,
IT_SAWMILL, IT_PAPER_MILL, IT_INVALID, CHECK_FOREST,
CT_WOOD, 13, CT_INVALID, 0, 30,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1133,7 +1119,7 @@
STR_4805_FOREST, STR_482E_NEW_BEING_PLANTED_NEAR,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_483A_INSECT_INFESTATION_CAUSES),
- MK(_tile_table_oil_refinery, 31,
+ MK(_tile_table_oil_refinery, 31, 2, 2, 2, 0, 4, 4, 4, 0, 191,
IT_OIL_RIG, IT_INVALID, IT_INVALID, CHECK_REFINERY,
CT_GOODS, 0, CT_INVALID, 0, 5,
CT_OIL, CT_INVALID, CT_INVALID,
@@ -1142,7 +1128,7 @@
STR_4806_OIL_REFINERY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_oil_rig, 240,
+ MK(_tile_table_oil_rig, 240, 6, 0, 0, 0, 0, 0, 0, 0, 152,
IT_OIL_REFINERY, IT_INVALID, IT_INVALID, CHECK_OIL_RIG,
CT_OIL, 15, CT_PASSENGERS, 2, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1151,7 +1137,7 @@
STR_4807_OIL_RIG, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4837_NEW_OIL_RESERVES_FOUND, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_factory, 26,
+ MK(_tile_table_factory, 26, 2, 0, 0, 0, 5, 0, 0, 0, 174,
IT_FARM, IT_STEEL_MILL, IT_INVALID, CHECK_NOTHING,
CT_GOODS, 0, CT_INVALID, 0, 5,
CT_LIVESTOCK, CT_GRAIN, CT_STEEL,
@@ -1160,7 +1146,7 @@
STR_4808_FACTORY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_printing_works, 26,
+ MK(_tile_table_printing_works, 26, 0, 2, 0, 0, 0, 5, 0, 0, 174,
IT_PAPER_MILL, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_GOODS, 0, CT_INVALID, 0, 5,
CT_PAPER, CT_INVALID, CT_INVALID,
@@ -1169,7 +1155,7 @@
STR_4809_PRINTING_WORKS, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_steel_mill, 27,
+ MK(_tile_table_steel_mill, 27, 2, 0, 0, 0, 5, 0, 0, 0, 10,
IT_IRON_MINE, IT_FACTORY, IT_INVALID, CHECK_NOTHING,
CT_STEEL, 0, CT_INVALID, 0, 5,
CT_IRON_ORE, CT_INVALID, CT_INVALID,
@@ -1178,7 +1164,7 @@
STR_480A_STEEL_MILL, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_farm, 250,
+ MK(_tile_table_farm, 250, 2, 4, 0, 0, 9, 9, 0, 0, 48,
IT_FACTORY, IT_FOOD_PROCESS, IT_INVALID, CHECK_FARM,
CT_GRAIN, 10, CT_LIVESTOCK, 10, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1187,7 +1173,7 @@
STR_480B_FARM, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4838_IMPROVED_FARMING_METHODS, STR_483A_INSECT_INFESTATION_CAUSES),
- MK(_tile_table_copper_mine, 205,
+ MK(_tile_table_copper_mine, 205, 0, 0, 3, 0, 0, 0, 4, 0, 10,
IT_FACTORY_2, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_COPPER_ORE, 10, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1196,7 +1182,7 @@
STR_480C_COPPER_ORE_MINE, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_oil_well, 220,
+ MK(_tile_table_oil_well, 220, 0, 5, 3, 0, 4, 5, 5, 0, 152,
IT_OIL_REFINERY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_OIL, 12, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1205,7 +1191,7 @@
STR_480D_OIL_WELLS, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4837_NEW_OIL_RESERVES_FOUND, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_bank, 193,
+ MK(_tile_table_bank, 193, 7, 0, 0, 0, 0, 0, 0, 0, 15,
IT_BANK_TEMP, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_VALUABLES, 6, CT_INVALID, 0, 5,
CT_VALUABLES, CT_INVALID, CT_INVALID,
@@ -1214,7 +1200,7 @@
STR_480E_BANK, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_food_process, 26,
+ MK(_tile_table_food_process, 26, 0, 2, 2, 0, 0, 3, 4, 0, 55,
IT_FRUIT_PLANTATION, IT_FARM, IT_FARM_2, CHECK_NOTHING,
CT_FOOD, 0, CT_INVALID, 0, 5,
CT_FRUIT, CT_MAIZE, CT_INVALID,
@@ -1223,7 +1209,7 @@
STR_480F_FOOD_PROCESSING_PLANT, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_paper_mill, 28,
+ MK(_tile_table_paper_mill, 28, 0, 2, 0, 0, 0, 5, 0, 0, 10,
IT_FOREST, IT_PRINTING_WORKS, IT_INVALID, CHECK_NOTHING,
CT_PAPER, 0, CT_INVALID, 0, 5,
CT_WOOD, CT_INVALID, CT_INVALID,
@@ -1232,16 +1218,16 @@
STR_4810_PAPER_MILL, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_gold_mine, 208,
+ MK(_tile_table_gold_mine, 208, 0, 3, 0, 0, 0, 4, 0, 0, 194,
IT_BANK_TROPIC_ARCTIC, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_GOLD, 7, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
- INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYLIFE_PRODUCTION, 1 << LT_ARCTIC,
INDUSTRYBEH_NONE,
STR_4811_GOLD_MINE, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_bank2, 19,
+ MK(_tile_table_bank2, 19, 0, 3, 3, 0, 0, 6, 5, 0, 15,
IT_GOLD_MINE, IT_DIAMOND_MINE, IT_INVALID, CHECK_NOTHING,
CT_INVALID, 0, CT_INVALID, 0, 5,
CT_GOLD, CT_INVALID, CT_INVALID,
@@ -1250,7 +1236,7 @@
STR_4812_BANK, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_diamond_mine, 213,
+ MK(_tile_table_diamond_mine, 213, 0, 0, 3, 0, 0, 0, 4, 0, 184,
IT_BANK_TROPIC_ARCTIC, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_DIAMONDS, 7, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1259,7 +1245,7 @@
STR_4813_DIAMOND_MINE, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_iron_mine, 220,
+ MK(_tile_table_iron_mine, 220, 2, 0, 0, 0, 5, 0, 0, 0, 55,
IT_STEEL_MILL, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_IRON_ORE, 10, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1268,7 +1254,7 @@
STR_4814_IRON_ORE_MINE, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_fruit_plantation, 225,
+ MK(_tile_table_fruit_plantation, 225, 0, 0, 2, 0, 0, 0, 4, 0, 86,
IT_FOOD_PROCESS, IT_INVALID, IT_INVALID, CHECK_PLANTATION,
CT_FRUIT, 10, CT_INVALID, 0, 15,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1277,7 +1263,7 @@
STR_4815_FRUIT_PLANTATION, STR_482E_NEW_BEING_PLANTED_NEAR,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4838_IMPROVED_FARMING_METHODS, STR_483A_INSECT_INFESTATION_CAUSES),
- MK(_tile_table_rubber_plantation, 218,
+ MK(_tile_table_rubber_plantation, 218, 0, 0, 3, 0, 0, 0, 4, 0, 39,
IT_FACTORY_2, IT_INVALID, IT_INVALID, CHECK_PLANTATION,
CT_RUBBER, 10, CT_INVALID, 0, 15,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1286,7 +1272,7 @@
STR_4816_RUBBER_PLANTATION, STR_482E_NEW_BEING_PLANTED_NEAR,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4838_IMPROVED_FARMING_METHODS, STR_483A_INSECT_INFESTATION_CAUSES),
- MK(_tile_table_water_supply, 199,
+ MK(_tile_table_water_supply, 199, 0, 0, 3, 0, 0, 0, 4, 0, 37,
IT_WATER_TOWER, IT_INVALID, IT_INVALID, CHECK_WATER,
CT_WATER, 12, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1295,7 +1281,7 @@
STR_4817_WATER_SUPPLY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_water_tower, 14,
+ MK(_tile_table_water_tower, 14, 0, 0, 4, 0, 0, 0, 8, 0, 208,
IT_WATER_SUPPLY, IT_INVALID, IT_INVALID, CHECK_WATER,
CT_INVALID, 0, CT_INVALID, 0, 5,
CT_WATER, CT_INVALID, CT_INVALID,
@@ -1304,7 +1290,7 @@
STR_4818_WATER_TOWER, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_factory2, 26,
+ MK(_tile_table_factory2, 26, 0, 0, 2, 0, 0, 0, 4, 0, 174,
IT_RUBBER_PLANTATION, IT_COPPER_MINE, IT_LUMBER_MILL, CHECK_PLANTATION,
CT_GOODS, 0, CT_INVALID, 0, 5,
CT_RUBBER, CT_COPPER_ORE, CT_WOOD,
@@ -1313,7 +1299,7 @@
STR_4819_FACTORY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_farm2, 250,
+ MK(_tile_table_farm2, 250, 0, 0, 1, 0, 0, 0, 2, 0, 48,
IT_FOOD_PROCESS, IT_INVALID, IT_INVALID, CHECK_PLANTATION,
CT_MAIZE, 11, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1322,7 +1308,7 @@
STR_481A_FARM, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4838_IMPROVED_FARMING_METHODS, STR_483A_INSECT_INFESTATION_CAUSES),
- MK(_tile_table_lumber_mill, 17,
+ MK(_tile_table_lumber_mill, 17, 0, 0, 0, 0, 0, 0, 0, 0, 194,
IT_FACTORY_2, IT_INVALID, IT_INVALID, CHECK_LUMBERMILL,
CT_WOOD, 0, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1331,7 +1317,7 @@
STR_481B_LUMBER_MILL, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4834_LACK_OF_NEARBY_TREES_CAUSES, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_cotton_candy, 195,
+ MK(_tile_table_cotton_candy, 195, 0, 0, 0, 3, 0, 0, 0, 5, 48,
IT_CANDY_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_COTTON_CANDY, 13, CT_INVALID, 0, 30,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1340,7 +1326,7 @@
STR_481C_COTTON_CANDY_FOREST, STR_482E_NEW_BEING_PLANTED_NEAR,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4838_IMPROVED_FARMING_METHODS, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_candy_factory, 26,
+ MK(_tile_table_candy_factory, 26, 0, 0, 0, 3, 0, 0, 0, 5, 174,
IT_COTTON_CANDY, IT_TOFFEE_QUARRY, IT_SUGAR_MINE, CHECK_NOTHING,
CT_CANDY, 0, CT_INVALID, 0, 5,
CT_SUGAR, CT_TOFFEE, CT_COTTON_CANDY,
@@ -1349,7 +1335,7 @@
STR_481D_CANDY_FACTORY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_battery_farm, 187,
+ MK(_tile_table_battery_farm, 187, 0, 0, 0, 3, 0, 0, 0, 4, 39,
IT_TOY_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_BATTERIES, 11, CT_INVALID, 0, 30,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1358,7 +1344,7 @@
STR_481E_BATTERY_FARM, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4838_IMPROVED_FARMING_METHODS, STR_483A_INSECT_INFESTATION_CAUSES),
- MK(_tile_table_cola_wells, 193,
+ MK(_tile_table_cola_wells, 193, 0, 0, 0, 3, 0, 0, 0, 5, 55,
IT_FIZZY_DRINK_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_COLA, 12, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1367,7 +1353,7 @@
STR_481F_COLA_WELLS, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_toy_shop, 17,
+ MK(_tile_table_toy_shop, 17, 0, 0, 0, 3, 0, 0, 0, 4, 208,
IT_TOY_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_INVALID, 0, CT_INVALID, 0, 5,
CT_TOYS, CT_INVALID, CT_INVALID,
@@ -1376,7 +1362,7 @@
STR_4820_TOY_SHOP, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_toy_factory, 20,
+ MK(_tile_table_toy_factory, 20, 0, 0, 0, 3, 0, 0, 0, 5, 10,
IT_PLASTIC_FOUNTAINS, IT_BATTERY_FARM, IT_TOY_SHOP, CHECK_NOTHING,
CT_TOYS, 0, CT_INVALID, 0, 5,
CT_PLASTIC, CT_BATTERIES, CT_INVALID,
@@ -1385,7 +1371,7 @@
STR_4821_TOY_FACTORY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_plastic_fountain, 192,
+ MK(_tile_table_plastic_fountain, 192, 0, 0, 0, 3, 0, 0, 0, 5, 37,
IT_TOY_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_PLASTIC, 14, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1394,8 +1380,8 @@
STR_4822_PLASTIC_FOUNTAINS, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_fizzy_drink, 22,
- IT_COLA_WELLS, IT_BUBBLE_GENERATOR, IT_INVALID, CHECK_NOTHING,
+ MK(_tile_table_fizzy_drink, 22, 0, 0, 0, 3, 0, 0, 0, 4, 184,
+ IT_COLA_WELLS, IT_BUBBLE_GENERATOR, IT_INVALID, CHECK_NOTHING,
CT_FIZZY_DRINKS, 0, CT_INVALID, 0, 5,
CT_COLA, CT_BUBBLES, CT_INVALID,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TOYLAND,
@@ -1403,7 +1389,7 @@
STR_4823_FIZZY_DRINK_FACTORY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4833_SUPPLY_PROBLEMS_CAUSE_TO, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_bubble_generator, 203,
+ MK(_tile_table_bubble_generator, 203, 0, 0, 0, 3, 0, 0, 0, 5, 152,
IT_FIZZY_DRINK_FACTORY, IT_INVALID, IT_INVALID, CHECK_BUBBLEGEN,
CT_BUBBLES, 13, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1412,7 +1398,7 @@
STR_4824_BUBBLE_GENERATOR, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_toffee_quarry, 213,
+ MK(_tile_table_toffee_quarry, 213, 0, 0, 0, 3, 0, 0, 0, 5, 194,
IT_CANDY_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_TOFFEE, 10, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1421,7 +1407,7 @@
STR_4825_TOFFEE_QUARRY, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
- MK(_tile_table_sugar_mine, 210,
+ MK(_tile_table_sugar_mine, 210, 0, 0, 0, 2, 0, 0, 0, 4, 15,
IT_CANDY_FACTORY, IT_INVALID, IT_INVALID, CHECK_NOTHING,
CT_SUGAR, 11, CT_INVALID, 0, 5,
CT_INVALID, CT_INVALID, CT_INVALID,
@@ -1432,75 +1418,6 @@
};
#undef MK
-
-static const byte _industry_create_table_0[] = {
- 4, 4,
- 5, 3,
- 5, 2,
- 8, 0,
- 5, 1,
- 4, 11,
- 5, 18,
- 9, 9,
- 5, 8,
- 5, 6,
- 0
-};
-
-static const byte _industry_create_table_1[] = {
- 4, 4,
- 5, 3,
- 5, 14,
- 8, 0,
- 5, 1,
- 5, 11,
- 5, 13,
- 9, 9,
- 4, 15,
- 5, 7,
- 6, 16,
- 0
-};
-
-static const byte _industry_create_table_2[] = {
- 4, 4,
- 5, 11,
- 5, 16,
- 4, 13,
- 4, 17,
- 4, 10,
- 4, 19,
- 4, 20,
- 4, 21,
- 8, 22,
- 4, 13,
- 4, 23,
- 2, 24,
- 0
-};
-
-static const byte _industry_create_table_3[] = {
- 5, 26,
- 5, 27,
- 4, 28,
- 5, 29,
- 4, 30,
- 5, 31,
- 5, 32,
- 4, 33,
- 5, 34,
- 5, 35,
- 4, 36,
- 0
-};
-
-static const byte * const _industry_create_table[4] = {
- _industry_create_table_0,
- _industry_create_table_1,
- _industry_create_table_2,
- _industry_create_table_3,
-};
-
/** Writes the properties of a industry tile into the IndustryTileSpec struct.
* @param c1 first type of cargo accepted for this tile
* @param c2 second cargo
diff -r 3b068c3a1c74 -r 0fa543611bbe src/table/industry_land.h
--- a/src/table/industry_land.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/table/industry_land.h Tue Jun 12 11:56:35 2007 +0000
@@ -15,8 +15,23 @@
byte image_3;
};
+
+/**
+ * Macro to ease the declaration of the array
+ * @param s1 sprite ID of ground sprite
+ * @param p1 palette ID of ground sprite
+ * @param s2 sprite ID of building sprite
+ * @param p2 palette ID of building sprite
+ * @param sx coordinate x of the sprite
+ * @param sy coordinate y of the sprite
+ * @param w width of the sprite
+ * @param h height of the sprite
+ * @param dz virtual height of the sprite
+ * @param p this allows to specify a special drawing procedure.
+ * @see DrawBuildingsTileStruct */
#define M(s1, p1, s2, p2, sx, sy, w, h, dz, p) { { s1, p1 }, { s2, p2 }, sx, sy, w - 1, h - 1, dz, p }
+/** Structure for industry tiles drawing */
static const DrawBuildingsTileStruct _industry_draw_tile_data[NUM_INDUSTRY_GFXES * 4] = {
M( 0xf54, PAL_NONE, 0x7db, PAL_NONE, 7, 0, 9, 9, 10, 0),
M( 0xf54, PAL_NONE, 0x7dc, PAL_NONE, 7, 0, 9, 9, 30, 0),
diff -r 3b068c3a1c74 -r 0fa543611bbe src/table/namegen.h
--- a/src/table/namegen.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/table/namegen.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file table/namegen.h Namepart tables for the town name generator */
+
#include "../stdafx.h"
#include "../openttd.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/table/roadveh.h
--- a/src/table/roadveh.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/table/roadveh.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file table/roadveh.h Data about how a road vehicle must drive on a tile */
+
static const RoadDriveEntry _roadveh_drive_data_0[] = {
{15, 5},
{14, 5},
diff -r 3b068c3a1c74 -r 0fa543611bbe src/table/town_land.h
--- a/src/table/town_land.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/table/town_land.h Tue Jun 12 11:56:35 2007 +0000
@@ -5,17 +5,19 @@
/** Writes the data into the Town Tile Drawing Struct
* @param s1 The first sprite of the building, mostly the ground sprite
+ * @param p1 The first sprite's palette of the building, mostly the ground sprite
* @param s2 The second sprite of the building.
+ * @param p2 The second sprite's palette of the building.
* @param sx The x-position of the sprite within the tile
- * @param xy the y-position of the sprite within the tile
+ * @param sy the y-position of the sprite within the tile
* @param w the width of the sprite
* @param h the height of the sprite
* @param dz the virtual height of the sprite
- * @param p set to 1 if a lift is present
- * @see DrawTownTileStruct
- */
+ * @param p set to 1 if a lift is present ()
+ * @see DrawBuildingsTileStruct */
#define M(s1, p1, s2, p2, sx, sy, w, h, dz, p) { { s1, p1 }, { s2, p2 }, sx, sy, w - 1, h - 1, dz, p}
+/** structure of houses graphics*/
static const DrawBuildingsTileStruct _town_draw_tile_data[] = {
M( 0xf54, PAL_NONE, 0x58d, PAL_NONE, 0, 0, 14, 14, 8, 0),
M( 0xf54, PAL_NONE, 0x58e, PAL_NONE, 0, 0, 14, 14, 60, 0),
diff -r 3b068c3a1c74 -r 0fa543611bbe src/terraform_gui.cpp
--- a/src/terraform_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/terraform_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file terraform_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -91,11 +93,11 @@
/**
* A central place to handle all X_AND_Y dragged GUI functions.
- * @param e @WindowEvent variable holding in its higher bits (excluding the lower
+ * @param e WindowEvent variable holding in its higher bits (excluding the lower
* 4, since that defined the X_Y drag) the type of action to be performed
* @return Returns true if the action was found and handled, and false otherwise. This
* allows for additional implements that are more local. For example X_Y drag
- * of convertrail which belongs in rail_gui.c and not terraform_gui.c
+ * of convertrail which belongs in rail_gui.cpp and not terraform_gui.cpp
**/
bool GUIPlaceProcDragXY(const WindowEvent *e)
{
diff -r 3b068c3a1c74 -r 0fa543611bbe src/texteff.cpp
--- a/src/texteff.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/texteff.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,11 +1,14 @@
/* $Id$ */
+/** @file texteff.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
#include "macros.h"
#include "strings.h"
#include "gfx.h"
+#include "landscape.h"
#include "viewport.h"
#include "saveload.h"
#include "hal.h"
@@ -121,7 +124,7 @@
}
}
-/* Hide the textbox */
+/** Hide the textbox */
void UndrawTextMessage()
{
if (_textmessage_visible) {
@@ -172,7 +175,7 @@
}
}
-/* Check if a message is expired every day */
+/** Check if a message is expired every day */
void TextMessageDailyLoop()
{
uint i;
@@ -196,7 +199,7 @@
}
}
-/* Draw the textmessage-box */
+/** Draw the textmessage-box */
void DrawTextMessage()
{
if (!_textmessage_dirty) return;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tgp.cpp
--- a/src/tgp.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tgp.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tgp.cpp OTTD Perlin Noise Landscape Generator, aka TerraGenesis Perlin */
+
#include "stdafx.h"
#include
#include "openttd.h"
@@ -17,7 +19,6 @@
#include "helpers.hpp"
/*
- * OTTD Perlin Noise Landscape Generator, aka TerraGenesis Perlin
*
* Quickie guide to Perlin Noise
* Perlin noise is a predictable pseudo random number sequence. By generating
@@ -167,11 +168,11 @@
/** Height map - allocated array of heights (MapSizeX() + 1) x (MapSizeY() + 1) */
struct HeightMap
{
- height_t *h; //! array of heights
- uint dim_x; //! height map size_x MapSizeX() + 1
- uint total_size; //! height map total size
- uint size_x; //! MapSizeX()
- uint size_y; //! MapSizeY()
+ height_t *h; //< array of heights
+ uint dim_x; //< height map size_x MapSizeX() + 1
+ uint total_size; //< height map total size
+ uint size_x; //< MapSizeX()
+ uint size_y; //< MapSizeY()
};
/** Global height map instance */
@@ -200,13 +201,13 @@
/** Noise amplitudes (multiplied by 1024)
* - indexed by "smoothness setting" and log2(frequency) */
static const amplitude_t _amplitudes_by_smoothness_and_frequency[4][12] = {
- // Very smooth
+ /* Very smooth */
{1000, 350, 123, 43, 15, 1, 1, 0, 0, 0, 0, 0},
- // Smooth
+ /* Smooth */
{1000, 1000, 403, 200, 64, 8, 1, 0, 0, 0, 0, 0},
- // Rough
+ /* Rough */
{1000, 1200, 800, 500, 200, 16, 4, 0, 0, 0, 0, 0},
- // Very Rough
+ /* Very Rough */
{1500, 1000, 1200, 1000, 500, 32, 20, 0, 0, 0, 0, 0},
};
@@ -215,13 +216,17 @@
/** Desired maximum height - indexed by _opt.diff.terrain_type */
static const int8 _max_height[4] = {
- 6, // Very flat
- 9, // Flat
- 12, // Hilly
- 15 // Mountainous
+ 6, ///< Very flat
+ 9, ///< Flat
+ 12, ///< Hilly
+ 15 ///< Mountainous
};
-/** Check if a X/Y set are within the map. */
+/** Check if a X/Y set are within the map.
+ * @param x coordinate x
+ * @param y coordinate y
+ * @return true if within the map
+ */
static inline bool IsValidXY(uint x, uint y)
{
return ((int)x) >= 0 && x < _height_map.size_x && ((int)y) >= 0 && y < _height_map.size_y;
@@ -680,10 +685,10 @@
/* The following decimals are the octave power modifiers for the Perlin noise */
static const double _perlin_p_values[][7] = { // perlin frequency per power
- { 0.35, 0.35, 0.35, 0.35, 0.35, 0.25, 0.539 }, // Very smooth
- { 0.45, 0.55, 0.45, 0.45, 0.35, 0.25, 0.89 }, // Smooth
- { 0.85, 0.80, 0.70, 0.45, 0.45, 0.35, 1.825 }, // Rough 1.825
- { 0.95, 0.85, 0.80, 0.55, 0.55, 0.45, 2.245 } // Very Rough 2.25
+ { 0.35, 0.35, 0.35, 0.35, 0.35, 0.25, 0.539 }, ///< Very smooth
+ { 0.45, 0.55, 0.45, 0.45, 0.35, 0.25, 0.89 }, ///< Smooth
+ { 0.85, 0.80, 0.70, 0.45, 0.45, 0.35, 1.825 }, ///< Rough 1.825
+ { 0.95, 0.85, 0.80, 0.55, 0.55, 0.45, 2.245 } //< Very Rough 2.25
};
/**
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tgp.h
--- a/src/tgp.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tgp.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tgp.h */
+
#ifndef TGP_H
#define TGP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/thread.cpp
--- a/src/thread.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/thread.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file thread.cpp */
+
#include "stdafx.h"
#include "thread.h"
#include
diff -r 3b068c3a1c74 -r 0fa543611bbe src/thread.h
--- a/src/thread.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/thread.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file thread.h */
+
#ifndef THREAD_H
#define THREAD_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tile.cpp
--- a/src/tile.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tile.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tile.cpp */
+
#include "stdafx.h"
#include "tile.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tile.h
--- a/src/tile.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tile.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tile.h */
+
#ifndef TILE_H
#define TILE_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/town.h
--- a/src/town.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/town.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file town.h */
+
#ifndef TOWN_H
#define TOWN_H
@@ -78,34 +80,34 @@
struct Town : EconomicObject {
TileIndex xy;
- // Current population of people and amount of houses.
+ /* Current population of people and amount of houses. */
uint16 num_houses;
uint32 population;
- // Town name
+ /* Town name */
uint16 townnametype;
uint32 townnameparts;
- // NOSAVE: Location of name sign, UpdateTownVirtCoord updates this.
+ /* NOSAVE: Location of name sign, UpdateTownVirtCoord updates this. */
ViewportSign sign;
- // Makes sure we don't build certain house types twice.
- // bit 0 = Building funds received
- // bit 1 = CHURCH
- // bit 2 = STADIUM
+ /* Makes sure we don't build certain house types twice.
+ * bit 0 = Building funds received
+ * bit 1 = CHURCH
+ * bit 2 = STADIUM */
byte flags12;
- // Which players have a statue?
+ /* Which players have a statue? */
byte statues;
- // Player ratings as well as a mask that determines which players have a rating.
+ /* Player ratings as well as a mask that determines which players have a rating. */
byte have_ratings;
- uint8 unwanted[MAX_PLAYERS]; // how many months companies aren't wanted by towns (bribe)
- PlayerByte exclusivity; // which player has exslusivity
- uint8 exclusive_counter; // months till the exclusivity expires
+ uint8 unwanted[MAX_PLAYERS]; ///< how many months companies aren't wanted by towns (bribe)
+ PlayerByte exclusivity; ///< which player has exslusivity
+ uint8 exclusive_counter; ///< months till the exclusivity expires
int16 ratings[MAX_PLAYERS];
- // Maximum amount of passengers and mail that can be transported.
+ /* Maximum amount of passengers and mail that can be transported. */
uint32 max_pass;
uint32 max_mail;
uint32 new_max_pass;
@@ -115,36 +117,36 @@
uint32 new_act_pass;
uint32 new_act_mail;
- // Amount of passengers that were transported.
+ /* Amount of passengers that were transported. */
byte pct_pass_transported;
byte pct_mail_transported;
- // Amount of food and paper that was transported. Actually a bit mask would be enough.
+ /* Amount of food and paper that was transported. Actually a bit mask would be enough. */
uint16 act_food;
uint16 act_water;
uint16 new_act_food;
uint16 new_act_water;
- // Time until we rebuild a house.
- byte time_until_rebuild;
+ /* Time until we rebuild a house. */
+ uint16 time_until_rebuild;
- // When to grow town next time.
- byte grow_counter;
- byte growth_rate;
+ /* When to grow town next time. */
+ uint16 grow_counter;
+ int16 growth_rate;
- // Fund buildings program in action?
+ /* Fund buildings program in action? */
byte fund_buildings_months;
- // Fund road reconstruction in action?
+ /* Fund road reconstruction in action? */
byte road_build_months;
- // Index in town array
+ /* Index in town array */
TownID index;
- // NOSAVE: UpdateTownRadius updates this given the house count.
+ /* NOSAVE: UpdateTownRadius updates this given the house count. */
uint16 radius[5];
- // NOSAVE: The number of each type of building in the town.
+ /* NOSAVE: The number of each type of building in the town. */
BuildingCounts building_counts;
/**
@@ -267,8 +269,8 @@
};
enum {
- // These refer to the maximums, so Appalling is -1000 to -400
- // MAXIMUM RATINGS BOUNDARIES
+ /* These refer to the maximums, so Appalling is -1000 to -400
+ * MAXIMUM RATINGS BOUNDARIES */
RATING_MINIMUM = -1000,
RATING_APPALLING = -400,
RATING_VERYPOOR = -200,
@@ -277,11 +279,11 @@
RATING_GOOD = 400,
RATING_VERYGOOD = 600,
RATING_EXCELLENT = 800,
- RATING_OUTSTANDING = 1000, // OUTSTANDING
+ RATING_OUTSTANDING = 1000, ///< OUTSTANDING
RATING_MAXIMUM = RATING_OUTSTANDING,
- // RATINGS AFFECTING NUMBERS
+ /* RATINGS AFFECTING NUMBERS */
RATING_TREE_DOWN_STEP = -35,
RATING_TREE_MINIMUM = RATING_MINIMUM,
RATING_TREE_UP_STEP = 7,
@@ -302,25 +304,25 @@
RATING_BRIBE_DOWN_TO = -50 // XXX SHOULD BE SOMETHING LOWER?
};
-enum {
-/* This is the base "normal" number of towns on the 8x8 map, when
- * one town should get grown per tick. The other numbers of towns
- * are then scaled based on that. */
- TOWN_GROWTH_FREQUENCY = 23,
-/* Simple value that indicates the house has reached final stage of construction*/
- TOWN_HOUSE_COMPLETED = 3,
-};
+/** This is the number of ticks between towns being processed for building new
+ * houses or roads. This value originally came from the size of the town array
+ * in TTD. */
+static const byte TOWN_GROWTH_FREQUENCY = 70;
-/* This enum is used in conjonction with town->flags12.
+/** Simple value that indicates the house has reached the final stage of
+ * construction. */
+static const byte TOWN_HOUSE_COMPLETED = 3;
+
+/** This enum is used in conjonction with town->flags12.
* IT simply states what bit is used for.
* It is pretty unrealistic (IMHO) to only have one church/stadium
* per town, NO MATTER the population of it.
* And there are 5 more bits available on flags12...
*/
enum {
- TOWN_IS_FUNDED = 0, // Town has received some funds for
- TOWN_HAS_CHURCH = 1, // There can be only one church by town.
- TOWN_HAS_STADIUM = 2 // There can be only one stadium by town.
+ TOWN_IS_FUNDED = 0, ///< Town has received some funds for
+ TOWN_HAS_CHURCH = 1, ///< There can be only one church by town.
+ TOWN_HAS_STADIUM = 2 ///< There can be only one stadium by town.
};
bool CheckforTownRating(uint32 flags, Town *t, byte type);
@@ -337,12 +339,19 @@
/**
* Check if a Town really exists.
+ * @param town to inquiry
+ * @return true if it exists
*/
static inline bool IsValidTown(const Town* town)
{
return town->xy != 0;
}
+/**
+ * Check if a TownID is valid.
+ * @param TownID to inquiry
+ * @return true if it exists
+ */
static inline bool IsValidTownID(TownID index)
{
return index < GetTownPoolSize() && IsValidTown(GetTown(index));
diff -r 3b068c3a1c74 -r 0fa543611bbe src/town_cmd.cpp
--- a/src/town_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/town_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -152,7 +152,7 @@
/* Add a house on top of the ground? */
image = dcts->building.sprite;
if (image != 0) {
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_HOUSES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -168,7 +168,7 @@
ti->z
);
- if (_display_opt & DO_TRANS_BUILDINGS) return;
+ if (HASBIT(_transparent_opt, TO_HOUSES)) return;
}
{
@@ -199,10 +199,10 @@
if (_tick_counter & 3) return;
- // If the house is not one with a lift anymore, then stop this animating.
- // Not exactly sure when this happens, but probably when a house changes.
- // Before this was just a return...so it'd leak animated tiles..
- // That bug seems to have been here since day 1??
+ /* If the house is not one with a lift anymore, then stop this animating.
+ * Not exactly sure when this happens, but probably when a house changes.
+ * Before this was just a return...so it'd leak animated tiles..
+ * That bug seems to have been here since day 1?? */
if (!(GetHouseSpecs(GetHouseType(tile))->building_flags & BUILDING_IS_ANIMATED)) {
DeleteAnimatedTile(tile);
return;
@@ -211,7 +211,7 @@
if (!LiftHasDestination(tile)) {
int i;
- /** Building has 6 floors, number 0 .. 6, where 1 is illegal.
+ /* Building has 6 floors, number 0 .. 6, where 1 is illegal.
* This is due to the fact that the first floor is, in the graphics,
* the height of 2 'normal' floors.
* Furthermore, there are 6 lift positions from floor N (incl) to floor N + 1 (excl) */
@@ -329,7 +329,7 @@
if (house_id >= NEW_HOUSE_OFFSET && !NewHouseTileLoop(tile)) return;
if (!IsHouseCompleted(tile)) {
- /*Construction is not completed. See if we can go further in construction*/
+ /* Construction is not completed. See if we can go further in construction*/
MakeTownHouseBigger(tile);
return;
}
@@ -358,11 +358,11 @@
_current_player = OWNER_TOWN;
if (hs->building_flags & BUILDING_HAS_1_TILE && HASBIT(t->flags12, TOWN_IS_FUNDED) && CanDeleteHouse(tile) && --t->time_until_rebuild == 0) {
- t->time_until_rebuild = GB(r, 16, 6) + 130;
+ t->time_until_rebuild = GB(r, 16, 8) + 192;
ClearTownHouse(t, tile);
- // rebuild with another house?
+ /* Rebuild with another house? */
if (GB(r, 24, 8) >= 12) DoBuildTownHouse(t, tile);
}
@@ -441,8 +441,8 @@
{ 0, 1},
{-1, 0},
- // Store the first 3 elements again.
- // Lets us rotate without using &3.
+ /* Store the first 3 elements again.
+ * Lets us rotate without using &3. */
{ 0, -1},
{ 1, 0},
{ 0, 1}
@@ -505,16 +505,16 @@
Slope k;
Slope slope;
- // If this assertion fails, it might be because the world contains
- // land at the edges. This is not ok.
+ /* If this assertion fails, it might be because the world contains
+ * land at the edges. This is not ok. */
TILE_ASSERT(tile);
for (;;) {
- // Check if there already is a road at this point?
+ /* Check if there already is a road at this point? */
if (GetAnyRoadTrackBits(tile) == 0) {
- // No, try to build one in the direction.
- // if that fails clear the land, and if that fails exit.
- // This is to make sure that we can build a road here later.
+ /* No, try to build one in the direction.
+ * if that fails clear the land, and if that fails exit.
+ * This is to make sure that we can build a road here later. */
if (CmdFailed(DoCommand(tile, (dir & 1 ? ROAD_X : ROAD_Y), 0, DC_AUTO, CMD_BUILD_ROAD)) &&
CmdFailed(DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR)))
return false;
@@ -523,20 +523,20 @@
slope = GetTileSlope(tile, NULL);
if (slope == SLOPE_FLAT) {
no_slope:
- // Tile has no slope
- // Disallow the road if any neighboring tile has a road.
+ /* Tile has no slope
+ * Disallow the road if any neighboring tile has a road. */
if (HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+1]))), dir^2) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+3]))), dir^2) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+1]) + ToTileIndexDiff(_roadblock_tileadd[dir+2]))), dir) ||
HASBIT(GetTownRoadMask(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[dir+3]) + ToTileIndexDiff(_roadblock_tileadd[dir+2]))), dir))
return false;
- // Otherwise allow
+ /* Otherwise allow */
return true;
}
- // If the tile is not a slope in the right direction, then
- // maybe terraform some.
+ /* If the tile is not a slope in the right direction, then
+ * maybe terraform some. */
k = (dir & 1) ? SLOPE_NE : SLOPE_NW;
if (k != slope && ComplementSlope(k) != slope) {
uint32 r = Random();
@@ -552,7 +552,7 @@
CMD_TERRAFORM_LAND);
}
if (CmdFailed(res) && CHANCE16I(1, 3, r)) {
- // We can consider building on the slope, though.
+ /* We can consider building on the slope, though. */
goto no_slope;
}
}
@@ -580,12 +580,12 @@
TILE_ASSERT(tile);
- // Don't terraform if land is plain or if there's a house there.
+ /* Don't terraform if land is plain or if there's a house there. */
if (IsTileType(tile, MP_HOUSE)) return;
tileh = GetTileSlope(tile, NULL);
if (tileh == SLOPE_FLAT) return;
- // First try up, then down
+ /* First try up, then down */
if (!TerraformTownTile(tile, ~tileh & 0xF, 1)) {
TerraformTownTile(tile, tileh & 0xF, 0);
}
@@ -605,17 +605,17 @@
int a;
int b;
- // Tile has no road. First reset the status counter
- // to say that this is the last iteration.
+ /* Tile has no road. First reset the status counter
+ * to say that this is the last iteration. */
_grow_town_result = 0;
- // Remove hills etc
+ /* Remove hills etc */
LevelTownLand(tile);
- // Is a road allowed here?
+ /* Is a road allowed here? */
if (!IsRoadAllowedHere(tile, block)) return;
- // Randomize new road block numbers
+ /* Randomize new road block numbers */
a = block;
b = block ^ 2;
if (CHANCE16(1, 4)) {
@@ -625,29 +625,29 @@
}
if (!IsRoadAllowedHere(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a])), a)) {
- // A road is not allowed to continue the randomized road,
- // return if the road we're trying to build is curved.
+ /* A road is not allowed to continue the randomized road,
+ * return if the road we're trying to build is curved. */
if (a != (b ^ 2)) return;
- // Return if neither side of the new road is a house
+ /* Return if neither side of the new road is a house */
if (!IsTileType(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a + 1])), MP_HOUSE) &&
!IsTileType(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[a + 3])), MP_HOUSE))
return;
- // That means that the road is only allowed if there is a house
- // at any side of the new road.
+ /* That means that the road is only allowed if there is a house
+ * at any side of the new road. */
}
rcmd = (RoadBits)((1 << a) + (1 << b));
} else if (block < 5 && !HASBIT(mask,block^2)) {
- // Continue building on a partial road.
- // Always OK.
+ /* Continue building on a partial road.
+ * Always OK. */
_grow_town_result = 0;
rcmd = (RoadBits)(1 << (block ^ 2));
} else {
int i;
- // Reached a tunnel/bridge? Then continue at the other side of it.
+ /* Reached a tunnel/bridge? Then continue at the other side of it. */
if (IsTileType(tile, MP_TUNNELBRIDGE)) {
if (IsTunnel(tile) && GetTunnelTransportType(tile) == TRANSPORT_ROAD) {
*tile_ptr = GetOtherTunnelEnd(tile);
@@ -657,27 +657,27 @@
return;
}
- // Possibly extend the road in a direction.
- // Randomize a direction and if it has a road, bail out.
+ /* Possibly extend the road in a direction.
+ * Randomize a direction and if it has a road, bail out. */
i = GB(Random(), 0, 2);
if (HASBIT(mask, i)) return;
- // This is the tile we will reach if we extend to this direction.
+ /* This is the tile we will reach if we extend to this direction. */
tmptile = TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[i]));
- // Don't do it if it reaches to water.
+ /* Don't do it if it reaches to water. */
if (IsClearWaterTile(tmptile)) return;
- // Build a house at the edge. 60% chance or
- // always ok if no road allowed.
+ /* Build a house at the edge. 60% chance or
+ * always ok if no road allowed. */
if (!IsRoadAllowedHere(tmptile, i) || CHANCE16(6, 10)) {
- // But not if there already is a house there.
+ /* But not if there already is a house there. */
if (!IsTileType(tmptile, MP_HOUSE)) {
- // Level the land if possible
+ /* Level the land if possible */
LevelTownLand(tmptile);
- // And build a house.
- // Set result to -1 if we managed to build it.
+ /* And build a house.
+ * Set result to -1 if we managed to build it. */
if (BuildTownHouse(t1, tmptile)) _grow_town_result = -1;
}
return;
@@ -687,11 +687,11 @@
rcmd = (RoadBits)(1 << i);
}
- // Return if a water tile
+ /* Return if a water tile */
if (IsClearWaterTile(tile)) return;
- // Determine direction of slope,
- // and build a road if not a special slope.
+ /* Determine direction of slope,
+ * and build a road if not a special slope. */
switch (GetTileSlope(tile, NULL)) {
case SLOPE_SW: i = DIAGDIR_NE; break;
case SLOPE_SE: i = DIAGDIR_NW; break;
@@ -708,7 +708,7 @@
tmptile = tile;
- // Now it contains the direction of the slope
+ /* Now it contains the direction of the slope */
j = -11; // max 11 tile long bridges
do {
if (++j == 0)
@@ -716,11 +716,11 @@
tmptile = TILE_MASK(tmptile + TileOffsByDiagDir(i));
} while (IsClearWaterTile(tmptile));
- // no water tiles in between?
+ /* no water tiles in between? */
if (j == -10)
goto build_road_and_exit;
- // Quit if it selecting an appropiate bridge type fails a large number of times.
+ /* Quit if it selecting an appropiate bridge type fails a large number of times. */
j = 22;
{
int32 bridge_len = GetBridgeLength(tile, tmptile);
@@ -730,38 +730,42 @@
if (!CmdFailed(DoCommand(tile, tmptile, 0x8000 + bridge_type, DC_EXEC | DC_AUTO, CMD_BUILD_BRIDGE)))
_grow_town_result = -1;
- // obviously, if building any bridge would fail, there is no need to try other bridge-types
+ /* obviously, if building any bridge would fail, there is no need to try other bridge-types */
return;
}
} while (--j != 0);
}
}
-// Returns true if a house was built, or no if the build failed.
+/** Returns "growth" if a house was built, or no if the build failed.
+ * @param t town to inquiry
+ * @param tile to inquiry
+ * @return something other than zero(0)if town expansion was possible
+ */
static int GrowTownAtRoad(Town *t, TileIndex tile)
{
int block = 5; // special case
TILE_ASSERT(tile);
- // Number of times to search.
+ /* Number of times to search. */
_grow_town_result = 10 + t->num_houses * 4 / 9;
do {
- // Get a bitmask of the road blocks on a tile
+ /* Get a bitmask of the road blocks on a tile */
RoadBits mask = GetTownRoadMask(tile);
- // Try to grow the town from this point
- GrowTownInTile(&tile,mask,block,t);
+ /* Try to grow the town from this point */
+ GrowTownInTile(&tile, mask, block, t);
- // Exclude the source position from the bitmask
- // and return if no more road blocks available
+ /* Exclude the source position from the bitmask
+ * and return if no more road blocks available */
ClrBitT(mask, (block ^ 2));
if (mask == 0)
return _grow_town_result;
- // Select a random bit from the blockmask, walk a step
- // and continue the search from there.
+ /* Select a random bit from the blockmask, walk a step
+ * and continue the search from there. */
do block = Random() & 3; while (!HASBIT(mask,block));
tile += ToTileIndexDiff(_roadblock_tileadd[block]);
@@ -777,15 +781,15 @@
}
}
- // Max number of times is checked.
+ /* Max number of times is checked. */
} while (--_grow_town_result >= 0);
return (_grow_town_result == -2);
}
-// Generate a random road block
-// The probability of a straight road
-// is somewhat higher than a curved.
+/** Generate a random road block
+ * The probability of a straight road
+ * is somewhat higher than a curved. */
static RoadBits GenRandomRoadBits()
{
uint32 r = Random();
@@ -795,8 +799,8 @@
return (RoadBits)((1 << a) + (1 << b));
}
-// Grow the town
-// Returns true if a house was built, or no if the build failed.
+/** Grow the town
+ * @Return true if a house was built, or no if the build failed. */
static bool GrowTown(Town *t)
{
TileIndex tile;
@@ -819,11 +823,11 @@
{ 0, 0}
};
- // Current player is a town
+ /* Current player is a town */
old_player = _current_player;
_current_player = OWNER_TOWN;
- // Find a road that we can base the construction on.
+ /* Find a road that we can base the construction on. */
tile = t->xy;
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
if (GetAnyRoadTrackBits(tile) != 0) {
@@ -834,8 +838,8 @@
tile = TILE_ADD(tile, ToTileIndexDiff(*ptr));
}
- // No road available, try to build a random road block by
- // clearing some land and then building a road there.
+ /* No road available, try to build a random road block by
+ * clearing some land and then building a road there. */
tile = t->xy;
for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) {
/* Only work with plain land that not already has a house */
@@ -885,11 +889,11 @@
memcpy(t->radius, _town_radius_data[t->num_houses / 4], sizeof(t->radius));
} else {
int mass = t->num_houses / 8;
- // At least very roughly extrapolate. Empirical numbers dancing between
- // overwhelming by cottages and skyscrapers outskirts.
+ /* At least very roughly extrapolate. Empirical numbers dancing between
+ * overwhelming by cottages and skyscrapers outskirts. */
t->radius[0] = mass * mass;
- // Actually we are proportional to sqrt() but that's right because
- // we are covering an area.
+ /* Actually we are proportional to sqrt() but that's right because
+ * we are covering an area. */
t->radius[1] = mass * 7;
t->radius[2] = 0;
t->radius[3] = mass * 4;
@@ -921,12 +925,12 @@
SetDParam(0, r);
GetString(buf1, townnametype, lastof(buf1));
- // Check size and width
+ /* Check size and width */
if (strlen(buf1) >= 31 || GetStringBoundingBox(buf1).width > 130) continue;
FOR_ALL_TOWNS(t2) {
- // We can't just compare the numbers since
- // several numbers may map to a single name.
+ /* We can't just compare the numbers since
+ * several numbers may map to a single name. */
SetDParam(0, t2->index);
GetString(buf2, STR_TOWN, lastof(buf2));
if (strcmp(buf1, buf2) == 0) {
@@ -949,7 +953,7 @@
{
int x, i;
- // clear the town struct
+ /* clear the town struct */
i = t->index;
memset(t, 0, sizeof(Town));
t->index = i;
@@ -1057,6 +1061,7 @@
* This obviously only works in the scenario editor. Function not removed
* as it might be possible in the future to fund your own town :)
* @param tile coordinates where town is built
+ * @param flags type of operation
* @param p1 size of the town (0 = random, 1 = small, 2 = medium, 3 = large)
* @param p2 unused
*/
@@ -1070,28 +1075,28 @@
SET_EXPENSES_TYPE(EXPENSES_OTHER);
- // Check if too close to the edge of map
+ /* Check if too close to the edge of map */
if (DistanceFromEdge(tile) < 12)
return_cmd_error(STR_0237_TOO_CLOSE_TO_EDGE_OF_MAP);
- // Can only build on clear flat areas, possibly with trees.
+ /* Can only build on clear flat areas, possibly with trees. */
if ((!IsTileType(tile, MP_CLEAR) && !IsTileType(tile, MP_TREES)) || GetTileSlope(tile, NULL) != SLOPE_FLAT) {
return_cmd_error(STR_0239_SITE_UNSUITABLE);
}
- // Check distance to all other towns.
+ /* Check distance to all other towns. */
if (IsCloseToTown(tile, 20))
return_cmd_error(STR_0238_TOO_CLOSE_TO_ANOTHER_TOWN);
- // Get a unique name for the town.
+ /* Get a unique name for the town. */
if (!CreateTownName(&townnameparts))
return_cmd_error(STR_023A_TOO_MANY_TOWNS);
- // Allocate town struct
+ /* Allocate town struct */
t = AllocateTown();
if (t == NULL) return_cmd_error(STR_023A_TOO_MANY_TOWNS);
- // Create the town
+ /* Create the town */
if (flags & DC_EXEC) {
_generating_world = true;
DoCreateTown(t, tile, townnameparts, p1);
@@ -1107,20 +1112,20 @@
uint32 townnameparts;
do {
- // Generate a tile index not too close from the edge
+ /* Generate a tile index not too close from the edge */
tile = RandomTile();
if (DistanceFromEdge(tile) < 20) continue;
- // Make sure the tile is plain
+ /* Make sure the tile is plain */
if (!IsTileType(tile, MP_CLEAR) || GetTileSlope(tile, NULL) != SLOPE_FLAT) continue;
- // Check not too close to a town
+ /* Check not too close to a town */
if (IsCloseToTown(tile, 20)) continue;
- // Get a unique name for the town.
+ /* Get a unique name for the town. */
if (!CreateTownName(&townnameparts)) break;
- // Allocate a town struct
+ /* Allocate a town struct */
t = AllocateTown();
if (t == NULL) break;
@@ -1141,11 +1146,11 @@
do {
IncreaseGeneratingWorldProgress(GWP_TOWN);
- // try 20 times to create a random-sized town for the first loop.
+ /* try 20 times to create a random-sized town for the first loop. */
if (CreateRandomTown(20, 0) != NULL) num++;
} while (--n);
- // give it a last try, but now more aggressive
+ /* give it a last try, but now more aggressive */
if (num == 0 && CreateRandomTown(10000, 0) == NULL) {
if (GetNumTowns() == 0) {
/* XXX - can we handle that more gracefully? */
@@ -1219,10 +1224,10 @@
uint oneof = 0;
HouseSpec *hs;
- // Above snow?
+ /* Above snow? */
slope = GetTileSlope(tile, &z);
- // Get the town zone type
+ /* Get the town zone type */
{
uint rad = t->GetRadiusGroup(tile);
@@ -1232,16 +1237,16 @@
bitmask = (1 << rad) + (1 << (land + 12));
}
- // bits 0-4 are used
- // bits 11-15 are used
- // bits 5-10 are not used.
+ /* bits 0-4 are used
+ * bits 11-15 are used
+ * bits 5-10 are not used. */
{
HouseID houses[HOUSE_MAX];
int num = 0;
uint cumulative_probs[HOUSE_MAX];
uint probability_max = 0;
- // Generate a list of all possible houses that can be built.
+ /* Generate a list of all possible houses that can be built. */
for (i = 0; i < HOUSE_MAX; i++) {
hs = GetHouseSpecs(i);
if ((~hs->building_availability & bitmask) == 0 && hs->enabled) {
@@ -1278,7 +1283,7 @@
if (_cur_year < hs->min_date || _cur_year > hs->max_date) continue;
- // Special houses that there can be only one of.
+ /* Special houses that there can be only one of. */
if (hs->building_flags & BUILDING_IS_CHURCH) {
SETBIT(oneof, TOWN_HAS_CHURCH);
} else if (hs->building_flags & BUILDING_IS_STADIUM) {
@@ -1289,7 +1294,7 @@
if (HASBITS(t->flags12 , oneof)) continue;
- // Make sure there is no slope?
+ /* Make sure there is no slope? */
if (hs->building_flags & TILE_NOT_SLOPED && slope != SLOPE_FLAT) continue;
if (hs->building_flags & TILE_SIZE_2x2) {
@@ -1323,7 +1328,7 @@
t->num_houses++;
IncreaseBuildingCount(t, house);
- // Special houses that there can be only one of.
+ /* Special houses that there can be only one of. */
t->flags12 |= oneof;
{
@@ -1375,7 +1380,7 @@
assert(IsTileType(tile, MP_HOUSE));
- // need to align the tile to point to the upper left corner of the house
+ /* need to align the tile to point to the upper left corner of the house */
if (house >= 3) { // house id 0,1,2 MUST be single tile houses, or this code breaks.
if (GetHouseSpecs(house-1)->building_flags & TILE_SIZE_2x1) {
house--;
@@ -1394,7 +1399,7 @@
hs = GetHouseSpecs(house);
- // Remove population from the town if the house is finished.
+ /* Remove population from the town if the house is finished. */
if (IsHouseCompleted(tile)) {
ChangePopulation(t, -hs->population);
}
@@ -1402,14 +1407,14 @@
t->num_houses--;
DecreaseBuildingCount(t, house);
- // Clear flags for houses that only may exist once/town.
+ /* Clear flags for houses that only may exist once/town. */
if (hs->building_flags & BUILDING_IS_CHURCH) {
CLRBIT(t->flags12, TOWN_HAS_CHURCH);
} else if (hs->building_flags & BUILDING_IS_STADIUM) {
CLRBIT(t->flags12, TOWN_HAS_STADIUM);
}
- // Do the actual clearing of tiles
+ /* Do the actual clearing of tiles */
eflags = hs->building_flags;
DoClearTownHouseHelper(tile);
if (eflags & BUILDING_2_TILES_X) DoClearTownHouseHelper(tile + TileDiffXY(1, 0));
@@ -1419,6 +1424,7 @@
/** Rename a town (server-only).
* @param tile unused
+ * @param flags type of operation
* @param p1 town ID to rename
* @param p2 unused
*/
@@ -1448,7 +1454,7 @@
return 0;
}
-// Called from GUI
+/** Called from GUI */
void ExpandTown(Town *t)
{
int amount, n;
@@ -1551,16 +1557,16 @@
TileIndex tile = t->xy;
if (CircularTileSearch(tile, 9, SearchTileForStatue, t->index))
- SETBIT(t->statues, _current_player); ///< Once found and built, "inform" the Town
+ SETBIT(t->statues, _current_player); // Once found and built, "inform" the Town
}
static void TownActionFundBuildings(Town* t)
{
- // Build next tick
+ /* Build next tick */
t->grow_counter = 1;
- // If we were not already growing
+ /* If we were not already growing */
SETBIT(t->flags12, TOWN_IS_FUNDED);
- // And grow for 3 months
+ /* And grow for 3 months */
t->fund_buildings_months = 3;
}
@@ -1577,18 +1583,18 @@
if (!RandomRange(15)) {
Station *st;
- // set as unwanted for 6 months
+ /* set as unwanted for 6 months */
t->unwanted[_current_player] = 6;
- // set all close by station ratings to 0
+ /* set all close by station ratings to 0 */
FOR_ALL_STATIONS(st) {
if (st->town == t && st->owner == _current_player) {
for (CargoID i = 0; i < NUM_CARGO; i++) st->goods[i].rating = 0;
}
}
- // only show errormessage to the executing player. All errors are handled command.c
- // but this is special, because it can only 'fail' on a DC_EXEC
+ /* only show errormessage to the executing player. All errors are handled command.c
+ * but this is special, because it can only 'fail' on a DC_EXEC */
if (IsLocalPlayer()) ShowErrorMessage(STR_BRIBE_FAILED_2, STR_BRIBE_FAILED, 0, 0);
/* decrease by a lot!
@@ -1621,6 +1627,7 @@
* This performs an action such as advertising, building a statue, funding buildings,
* but also bribing the town-council
* @param tile unused
+ * @param flags type of operation
* @param p1 town to do the action at
* @param p2 action to perform, @see _town_action_proc for the list of available actions
*/
@@ -1651,10 +1658,10 @@
{
int n;
Station *st;
- byte m;
+ uint16 m;
Player *p;
- // Reset player ratings if they're low
+ /* Reset player ratings if they're low */
FOR_ALL_PLAYERS(p) {
if (p->is_active && t->ratings[p->index] <= 200) {
t->ratings[p->index] += 5;
@@ -1676,22 +1683,21 @@
}
CLRBIT(t->flags12, TOWN_IS_FUNDED);
+ if (_patches.town_growth_rate == 0 && t->fund_buildings_months == 0) return;
+
+ /** Towns are processed every TOWN_GROWTH_FREQUENCY ticks, and this is the
+ * number of times towns are processed before a new building is built. */
+ static const uint16 _grow_count_values[2][6] = {
+ { 120, 120, 120, 100, 80, 60 }, ///< Fund new buildings has been activated
+ { 320, 420, 300, 220, 160, 100 } ///< Normal values
+ };
if (t->fund_buildings_months != 0) {
- static const byte _grow_count_values[6] = {
- 60, 60, 60, 50, 40, 30
- };
- m = _grow_count_values[min(n, 5)];
+ m = _grow_count_values[0][min(n, 5)];
t->fund_buildings_months--;
- } else if (n == 0) {
- m = 160;
- if (!CHANCE16(1, 12))
- return;
} else {
- static const byte _grow_count_values[5] = {
- 210, 150, 110, 80, 50
- };
- m = _grow_count_values[min(n, 5) - 1];
+ m = _grow_count_values[1][min(n, 5)];
+ if (n == 0 && !CHANCE16(1, 12)) return;
}
if (_opt.landscape == LT_ARCTIC) {
@@ -1702,6 +1708,13 @@
return;
}
+ /* Use the normal growth rate values if new buildings have been funded in
+ * this town and the growth rate is set to none. */
+ uint growth_multiplier = _patches.town_growth_rate != 0 ? _patches.town_growth_rate - 1 : 1;
+
+ m >>= growth_multiplier;
+ if (_patches.larger_towns != 0 && (t->index % _patches.larger_towns) == 0) m /= 2;
+
t->growth_rate = m / (t->num_houses / 50 + 1);
if (m <= t->grow_counter)
t->grow_counter = m;
@@ -1711,7 +1724,7 @@
static void UpdateTownAmounts(Town *t)
{
- // Using +1 here to prevent overflow and division by zero
+ /* Using +1 here to prevent overflow and division by zero */
t->pct_pass_transported = t->new_act_pass * 256 / (t->new_max_pass + 1);
t->max_pass = t->new_max_pass; t->new_max_pass = 0;
@@ -1719,7 +1732,7 @@
t->act_food = t->new_act_food; t->new_act_food = 0;
t->act_water = t->new_act_water; t->new_act_water = 0;
- // Using +1 here to prevent overflow and division by zero
+ /* Using +1 here to prevent overflow and division by zero */
t->pct_mail_transported = t->new_act_mail * 256 / (t->new_max_mail + 1);
t->max_mail = t->new_max_mail; t->new_max_mail = 0;
t->act_mail = t->new_act_mail; t->new_act_mail = 0;
@@ -1789,7 +1802,7 @@
{
int rating;
- // if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff
+ /* if magic_bulldozer cheat is active, town doesn't penaltize for removing stuff */
if (t == NULL ||
!IsValidPlayer(_current_player) ||
(_cheats.magic_bulldozer.value && add < 0)) {
@@ -1816,17 +1829,17 @@
/* penalty for removing town-owned stuff */
static const int _default_rating_settings [3][3] = {
- // ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE
- { 0, 128, 384}, // Permissive
- { 48, 192, 480}, // Neutral
- { 96, 384, 768}, // Hostile
+ /* ROAD_REMOVE, TUNNELBRIDGE_REMOVE, INDUSTRY_REMOVE */
+ { 0, 128, 384}, ///< Permissive
+ { 48, 192, 480}, ///< Neutral
+ { 96, 384, 768}, ///< Hostile
};
bool CheckforTownRating(uint32 flags, Town *t, byte type)
{
int modemod;
- // if magic_bulldozer cheat is active, town doesn't restrict your destructive actions
+ /* if magic_bulldozer cheat is active, town doesn't restrict your destructive actions */
if (t == NULL || !IsValidPlayer(_current_player) || _cheats.magic_bulldozer.value)
return true;
@@ -1912,12 +1925,12 @@
SLE_VAR(Town, flags12, SLE_UINT8),
SLE_VAR(Town, statues, SLE_UINT8),
- // sort_index_obsolete was stored here in savegame format 0 - 1
+ /* sort_index_obsolete was stored here in savegame format 0 - 1 */
SLE_CONDNULL(1, 0, 1),
SLE_VAR(Town, have_ratings, SLE_UINT8),
SLE_ARR(Town, ratings, SLE_INT16, 8),
- // failed bribe attempts are stored since savegame format 4
+ /* failed bribe attempts are stored since savegame format 4 */
SLE_CONDARR(Town, unwanted, SLE_INT8, 8, 4,SL_MAX_VERSION),
SLE_CONDVAR(Town, max_pass, SLE_FILE_U16 | SLE_VAR_U32, 0, 8),
@@ -1947,15 +1960,20 @@
SLE_VAR(Town, new_act_food, SLE_UINT16),
SLE_VAR(Town, new_act_water, SLE_UINT16),
- SLE_VAR(Town, time_until_rebuild, SLE_UINT8),
- SLE_VAR(Town, grow_counter, SLE_UINT8),
- SLE_VAR(Town, growth_rate, SLE_UINT8),
+ SLE_CONDVAR(Town, time_until_rebuild, SLE_UINT8, 0, 53),
+ SLE_CONDVAR(Town, grow_counter, SLE_UINT8, 0, 53),
+ SLE_CONDVAR(Town, growth_rate, SLE_UINT8, 0, 53),
+
+ SLE_CONDVAR(Town, time_until_rebuild, SLE_UINT16, 54, SL_MAX_VERSION),
+ SLE_CONDVAR(Town, grow_counter, SLE_UINT16, 54, SL_MAX_VERSION),
+ SLE_CONDVAR(Town, growth_rate, SLE_INT16, 54, SL_MAX_VERSION),
+
SLE_VAR(Town, fund_buildings_months, SLE_UINT8),
SLE_VAR(Town, road_build_months, SLE_UINT8),
SLE_VAR(Town, exclusivity, SLE_UINT8),
SLE_VAR(Town, exclusive_counter, SLE_UINT8),
- // reserve extra space in savegame here. (currently 30 bytes)
+ /* reserve extra space in savegame here. (currently 30 bytes) */
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
SLE_END()
diff -r 3b068c3a1c74 -r 0fa543611bbe src/town_gui.cpp
--- a/src/town_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/town_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file town_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -32,9 +34,9 @@
extern const byte _town_action_costs[8];
/** Get a list of available actions to do at a town.
- * @param *nump if not NULL add put the number of available actions in it
+ * @param nump if not NULL add put the number of available actions in it
* @param pid the player that is querying the town
- * @param *t the town that is queried
+ * @param t the town that is queried
* @return bitmasked value of enabled actions
*/
uint GetMaskOfTownActions(int *nump, PlayerID pid, const Town *t)
@@ -47,9 +49,9 @@
if (pid != PLAYER_SPECTATOR) {
uint i;
- // bribe option enabled?
+ /* bribe option enabled? */
if (_patches.bribe) {
- // if unwanted, disable everything.
+ /* if unwanted, disable everything. */
if (t->unwanted[pid]) {
avail_buttons = 0;
} else if (t->ratings[pid] < RATING_BRIBE_MAXIMUM) {
@@ -57,7 +59,7 @@
}
}
- // Things worth more than this are not shown
+ /* Things worth more than this are not shown */
avail = GetPlayer(pid)->player_money + _eco->GetPrice(CEconomy::STATION_VALUE) * 200;
ref = _eco->GetPrice(CEconomy::BUILD_INDUSTRY) >> 8;
@@ -119,7 +121,7 @@
DrawString(2, 15, STR_2023_TRANSPORT_COMPANY_RATINGS, 0);
- // Draw list of players
+ /* Draw list of players */
y = 25;
FOR_ALL_PLAYERS(p) {
if (p->is_active && (HASBIT(t->have_ratings, p->index) || t->exclusivity == p->index)) {
@@ -150,7 +152,7 @@
}
}
- // Draw actions list
+ /* Draw actions list */
{
int y = 107, i;
int pos = w->vscroll.pos;
@@ -234,7 +236,7 @@
switch (e->event) {
case WE_PAINT:
- // disable renaming town in network games if you are not the server
+ /* disable renaming town in network games if you are not the server */
SetWindowWidgetDisabledState(w, 8, _networking && !_network_server);
SetDParam(0, t->index);
@@ -375,7 +377,7 @@
};
-// used to get a sorted list of the towns
+/* used to get a sorted list of the towns */
static uint _num_town_sort;
static char _bufcache[64];
diff -r 3b068c3a1c74 -r 0fa543611bbe src/town_map.h
--- a/src/town_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/town_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -127,7 +127,7 @@
/**
* Set the position of the lift on this animated house
* @param t the tile
- * @param pos, from 0 to 36
+ * @param pos position, from 0 to 36
*/
static inline void SetLiftPosition(TileIndex t, byte pos)
{
@@ -315,7 +315,8 @@
/**
* Set the activated triggers bits for this house.
* This is required for newgrf house
- * @param t the tile of this house
+ * @param t the tile of this house
+ * @param triggers the activated triggers
* @pre IsTileType(t, MP_HOUSE)
*/
static inline void SetHouseTriggers(TileIndex t, byte triggers)
diff -r 3b068c3a1c74 -r 0fa543611bbe src/train.h
--- a/src/train.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/train.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file train.h */
+
#ifndef TRAIN_H
#define TRAIN_H
@@ -14,12 +16,12 @@
*/
enum TrainSubtype {
- Train_Front = 0, // Leading engine of a train
- Train_Articulated_Part = 1, // Articulated part of an engine
- Train_Wagon = 2, // Wagon
- Train_Engine = 3, // Engine, that can be front engines, but might be placed behind another engine
- Train_Free_Wagon = 4, // First in a wagon chain (in depot)
- Train_Multiheaded = 5, // Engine is a multiheaded
+ Train_Front = 0, ///< Leading engine of a train
+ Train_Articulated_Part = 1, ///< Articulated part of an engine
+ Train_Wagon = 2, ///< Wagon
+ Train_Engine = 3, ///< Engine, that can be front engines, but might be placed behind another engine
+ Train_Free_Wagon = 4, ///< First in a wagon chain (in depot)
+ Train_Multiheaded = 5, ///< Engine is a multiheaded
};
diff -r 3b068c3a1c74 -r 0fa543611bbe src/train_cmd.cpp
--- a/src/train_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/train_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,10 +1,13 @@
/* $Id$ */
+/** @file train_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
#include "debug.h"
#include "functions.h"
+#include "landscape.h"
#include "gui.h"
#include "station_map.h"
#include "table/strings.h"
@@ -105,24 +108,24 @@
for (Vehicle *u = v; u != NULL; u = u->next) {
uint32 vweight = GetCargo(u->cargo_type)->weight * u->cargo_count * FreightWagonMult(u->cargo_type) / 16;
- // Vehicle weight is not added for articulated parts.
+ /* Vehicle weight is not added for articulated parts. */
if (!IsArticulatedPart(u)) {
- // vehicle weight is the sum of the weight of the vehicle and the weight of its cargo
+ /* vehicle weight is the sum of the weight of the vehicle and the weight of its cargo */
vweight += RailVehInfo(u->engine_type)->weight;
- // powered wagons have extra weight added
+ /* powered wagons have extra weight added */
if (HASBIT(u->u.rail.flags, VRF_POWEREDWAGON))
vweight += RailVehInfo(u->u.rail.first_engine)->pow_wag_weight;
}
- // consist weight is the sum of the weight of all vehicles in the consist
+ /* consist weight is the sum of the weight of all vehicles in the consist */
weight += vweight;
- // store vehicle weight in cache
+ /* store vehicle weight in cache */
u->u.rail.cached_veh_weight = vweight;
}
- // store consist weight in cache
+ /* store consist weight in cache */
v->u.rail.cached_weight = weight;
/* Now update train power (tractive effort is dependent on weight) */
@@ -151,10 +154,10 @@
for (Vehicle *u = v; u != NULL; u = u->next) {
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
- // Update the v->first cache. This is faster than having to brute force it later.
+ /* Update the v->first cache. This is faster than having to brute force it later. */
if (u->first == NULL) u->first = v;
- // update the 'first engine'
+ /* update the 'first engine' */
u->u.rail.first_engine = v == u ? INVALID_ENGINE : first_engine;
u->u.rail.railtype = rvi_u->railtype;
@@ -164,13 +167,13 @@
u->u.rail.cached_vis_effect = rvi_u->visual_effect;
} else {
if (IsTrainWagon(u) || IsArticulatedPart(u)) {
- // Wagons and articulated parts have no effect by default
+ /* Wagons and articulated parts have no effect by default */
u->u.rail.cached_vis_effect = 0x40;
} else if (rvi_u->engclass == 0) {
- // Steam is offset by -4 units
+ /* Steam is offset by -4 units */
u->u.rail.cached_vis_effect = 4;
} else {
- // Diesel fumes and sparks come from the centre
+ /* Diesel fumes and sparks come from the centre */
u->u.rail.cached_vis_effect = 8;
}
}
@@ -204,13 +207,13 @@
u->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL);
}
- // max speed is the minimum of the speed limits of all vehicles in the consist
+ /* max speed is the minimum of the speed limits of all vehicles in the consist */
if ((rvi_u->railveh_type != RAILVEH_WAGON || _patches.wagon_speed_limits) &&
rvi_u->max_speed != 0 && !UsesWagonOverride(u))
max_speed = min(rvi_u->max_speed, max_speed);
}
- // check the vehicle length (callback)
+ /* check the vehicle length (callback) */
uint16 veh_len = CALLBACK_FAILED;
if (HASBIT(EngInfo(u->engine_type)->callbackmask, CBM_VEHICLE_LENGTH)) {
veh_len = GetVehicleCallback(CBID_TRAIN_VEHICLE_LENGTH, 0, 0, u->engine_type, u);
@@ -221,10 +224,10 @@
v->u.rail.cached_total_length += u->u.rail.cached_veh_length;
}
- // store consist weight/max speed in cache
+ /* store consist weight/max speed in cache */
v->u.rail.cached_max_speed = max_speed;
- // recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added)
+ /* recalculate cached weights and power too (we do this *after* the rest, so it is known which wagons are powered and need extra weight added) */
TrainCargoChanged(v);
}
@@ -263,8 +266,8 @@
StationID sid = GetStationIndex(tile);
assert(v->type == VEH_TRAIN);
- //When does a train drive through a station
- //first we deal with the "new nonstop handling"
+ /* When does a train drive through a station
+ * first we deal with the "new nonstop handling" */
if (_patches.new_nonstop && o->flags & OF_NON_STOP && sid == o->dest) {
return false;
}
@@ -278,14 +281,14 @@
return true;
}
-//new acceleration
+/** new acceleration*/
static int GetTrainAcceleration(Vehicle *v, bool mode)
{
int max_speed = 2000;
int speed = v->cur_speed * 10 / 16; //[mph]
int curvecount[2] = {0, 0};
- //first find the curve speed limit
+ /*first find the curve speed limit */
int numcurve = 0;
int sum = 0;
int pos = 0;
@@ -309,7 +312,7 @@
}
}
- //if we have a 90 degree turn, fix the speed limit to 60
+ /*if we have a 90 degree turn, fix the speed limit to 60 */
if (_curve_neighbours90[dir][0] == ndir ||
_curve_neighbours90[dir][1] == ndir) {
max_speed = 61;
@@ -402,7 +405,7 @@
break;
}
} else {
- //"kickoff" acceleration
+ /* "kickoff" acceleration */
force = (mode == AM_ACCEL && v->u.rail.railtype != RAILTYPE_MAGLEV) ? min(max_te, power) : power;
force = max(force, (mass * 8) + resistance);
}
@@ -521,7 +524,7 @@
bool flip_image = HASBIT(callback, 7);
const RailVehicleInfo *rvi_artic = RailVehInfo(engine_type);
- // get common values from first engine
+ /* get common values from first engine */
u->direction = v->direction;
u->owner = v->owner;
u->tile = v->tile;
@@ -535,7 +538,7 @@
u->vehstatus = v->vehstatus & ~VS_STOPPED;
u->u.rail.first_engine = v->engine_type;
- // get more settings from rail vehicle info
+ /* get more settings from rail vehicle info */
u->spritenum = rvi_artic->image_index;
if (flip_image) u->spritenum++;
u->cargo_type = rvi_artic->cargo_type;
@@ -645,7 +648,7 @@
return value;
}
-// Move all free vehicles in the depot to the train
+/** Move all free vehicles in the depot to the train */
static void NormalizeTrainVehInDepot(const Vehicle* u)
{
const Vehicle* v;
@@ -697,6 +700,7 @@
/** Build a railroad vehicle.
* @param tile tile of the depot where rail-vehicle is built
+ * @param flags type of operation
* @param p1 engine type id
* @param p2 bit 0 when set, the train will get number 0, otherwise it will get a free number
* bit 1 prevents any free cars from being added to the train
@@ -704,7 +708,7 @@
int32 CmdBuildRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
/* Check if the engine-type is valid (for the player) */
- if (!IsEngineBuildable(p1, VEH_TRAIN, _current_player)) return_cmd_error(STR_ENGINE_NOT_BUILDABLE);
+ if (!IsEngineBuildable(p1, VEH_TRAIN, _current_player)) return_cmd_error(STR_RAIL_VEHICLE_NOT_AVAILABLE);
/* Check if the train is actually being built in a depot belonging
* to the player. Doesn't matter if only the cost is queried */
@@ -874,7 +878,7 @@
*/
static Vehicle *UnlinkWagon(Vehicle *v, Vehicle *first)
{
- // unlinking the first vehicle of the chain?
+ /* unlinking the first vehicle of the chain? */
if (v == first) {
v = GetNextVehicle(v);
if (v == NULL) return NULL;
@@ -898,7 +902,7 @@
FOR_ALL_VEHICLES(dst) {
if (dst->type == VEH_TRAIN && IsFreeWagon(dst) && dst->tile == tile) {
- // check so all vehicles in the line have the same engine.
+ /* check so all vehicles in the line have the same engine. */
Vehicle *v = dst;
while (v->engine_type == eng) {
@@ -950,6 +954,7 @@
/** Move a rail vehicle around inside the depot.
* @param tile unused
+ * @param flags type of operation
* @param p1 various bitstuffed elements
* - p1 (bit 0 - 15) source vehicle index
* - p1 (bit 16 - 31) what wagon to put the source wagon AFTER, XXX - INVALID_VEHICLE to make a new line
@@ -966,7 +971,7 @@
if (src->type != VEH_TRAIN || !CheckOwnership(src->owner)) return CMD_ERROR;
- // if nothing is selected as destination, try and find a matching vehicle to drag to.
+ /* if nothing is selected as destination, try and find a matching vehicle to drag to. */
Vehicle *dst;
if (d == INVALID_VEHICLE) {
dst = IsTrainEngine(src) ? NULL : FindGoodVehiclePos(src);
@@ -976,13 +981,13 @@
if (dst->type != VEH_TRAIN || !CheckOwnership(dst->owner)) return CMD_ERROR;
}
- // if an articulated part is being handled, deal with its parent vehicle
+ /* if an articulated part is being handled, deal with its parent vehicle */
while (IsArticulatedPart(src)) src = GetPrevVehicleInChain(src);
if (dst != NULL) {
while (IsArticulatedPart(dst)) dst = GetPrevVehicleInChain(dst);
}
- // don't move the same vehicle..
+ /* don't move the same vehicle.. */
if (src == dst) return 0;
/* locate the head of the two chains */
@@ -991,7 +996,7 @@
if (dst != NULL) {
dst_head = GetFirstVehicleInChain(dst);
if (dst_head->tile != src_head->tile) return CMD_ERROR;
- // Now deal with articulated part of destination wagon
+ /* Now deal with articulated part of destination wagon */
dst = GetLastEnginePart(dst);
} else {
dst_head = NULL;
@@ -1004,7 +1009,7 @@
dst = GetPrevVehicleInChain(dst);
/* Now if the vehicle we want to link to is the vehicle itself, drop out */
if (dst == src) return CMD_ERROR;
- // if dst is NULL, it means that dst got a rear multiheaded engine as first engine. We can't use that
+ /* if dst is NULL, it means that dst got a rear multiheaded engine as first engine. We can't use that */
if (dst == NULL) return CMD_ERROR;
} else {
/* there are more units on this train, so we will add the wagon after the next one*/
@@ -1032,51 +1037,51 @@
if (IsMultiheaded(src) && !IsTrainEngine(src)) return_cmd_error(STR_REAR_ENGINE_FOLLOW_FRONT_ERROR);
- // when moving all wagons, we can't have the same src_head and dst_head
+ /* when moving all wagons, we can't have the same src_head and dst_head */
if (HASBIT(p2, 0) && src_head == dst_head) return 0;
{
int max_len = _patches.mammoth_trains ? 100 : 9;
- // check if all vehicles in the source train are stopped inside a depot.
+ /* check if all vehicles in the source train are stopped inside a depot. */
int src_len = CheckTrainStoppedInDepot(src_head);
if (src_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
- // check the destination row if the source and destination aren't the same.
+ /* check the destination row if the source and destination aren't the same. */
if (src_head != dst_head) {
int dst_len = 0;
if (dst_head != NULL) {
- // check if all vehicles in the dest train are stopped.
+ /* check if all vehicles in the dest train are stopped. */
dst_len = CheckTrainStoppedInDepot(dst_head);
if (dst_len < 0) return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
}
- // We are moving between rows, so only count the wagons from the source
- // row that are being moved.
+ /* We are moving between rows, so only count the wagons from the source
+ * row that are being moved. */
if (HASBIT(p2, 0)) {
const Vehicle *u;
for (u = src_head; u != src && u != NULL; u = GetNextVehicle(u))
src_len--;
} else {
- // If moving only one vehicle, just count that.
+ /* If moving only one vehicle, just count that. */
src_len = 1;
}
if (src_len + dst_len > max_len) {
- // Abort if we're adding too many wagons to a train.
+ /* Abort if we're adding too many wagons to a train. */
if (dst_head != NULL && IsFrontEngine(dst_head)) return_cmd_error(STR_8819_TRAIN_TOO_LONG);
- // Abort if we're making a train on a new row.
+ /* Abort if we're making a train on a new row. */
if (dst_head == NULL && IsTrainEngine(src)) return_cmd_error(STR_8819_TRAIN_TOO_LONG);
}
} else {
- // Abort if we're creating a new train on an existing row.
+ /* Abort if we're creating a new train on an existing row. */
if (src_len > max_len && src == src_head && IsTrainEngine(GetNextVehicle(src_head)))
return_cmd_error(STR_8819_TRAIN_TOO_LONG);
}
}
- // moving a loco to a new line?, then we need to assign a unitnumber.
+ /* moving a loco to a new line?, then we need to assign a unitnumber. */
if (dst == NULL && !IsFrontEngine(src) && IsTrainEngine(src)) {
UnitID unit_num = GetFreeUnitNumber(VEH_TRAIN);
if (unit_num > _patches.max_trains)
@@ -1104,7 +1109,7 @@
for (Vehicle *u = dst_head; u != NULL; u = u->next) u->first = NULL;
if (HASBIT(p2, 0)) {
- // unlink ALL wagons
+ /* unlink ALL wagons */
if (src != src_head) {
Vehicle *v = src_head;
while (GetNextVehicle(v) != src) v = GetNextVehicle(v);
@@ -1114,9 +1119,9 @@
src_head = NULL;
}
} else {
- // if moving within the same chain, dont use dst_head as it may get invalidated
+ /* if moving within the same chain, dont use dst_head as it may get invalidated */
if (src_head == dst_head) dst_head = NULL;
- // unlink single wagon from linked list
+ /* unlink single wagon from linked list */
src_head = UnlinkWagon(src, src_head);
GetLastEnginePart(src)->next = NULL;
}
@@ -1125,10 +1130,10 @@
/* We make a new line in the depot, so we know already that we invalidate the window data */
InvalidateWindowData(WC_VEHICLE_DEPOT, src->tile);
- // move the train to an empty line. for locomotives, we set the type to TS_Front. for wagons, 4.
+ /* move the train to an empty line. for locomotives, we set the type to TS_Front. for wagons, 4. */
if (IsTrainEngine(src)) {
if (!IsFrontEngine(src)) {
- // setting the type to 0 also involves setting up the orders field.
+ /* setting the type to 0 also involves setting up the orders field. */
SetFrontEngine(src);
assert(src->orders == NULL);
src->num_orders = 0;
@@ -1139,7 +1144,7 @@
dst_head = src;
} else {
if (IsFrontEngine(src)) {
- // the vehicle was previously a loco. need to free the order list and delete vehicle windows etc.
+ /* the vehicle was previously a loco. need to free the order list and delete vehicle windows etc. */
DeleteWindowById(WC_VEHICLE_VIEW, src->index);
DeleteVehicleOrders(src);
}
@@ -1151,7 +1156,7 @@
src->unitnumber = 0; // doesn't occupy a unitnumber anymore.
}
- // link in the wagon(s) in the chain.
+ /* link in the wagon(s) in the chain. */
{
Vehicle *v;
@@ -1165,7 +1170,7 @@
src_head = src_head->next;
}
AddWagonToConsist(src->u.rail.other_multiheaded_part, src);
- // previous line set the front engine to the old front. We need to clear that
+ /* previous line set the front engine to the old front. We need to clear that */
src->u.rail.other_multiheaded_part->first = NULL;
}
@@ -1184,7 +1189,7 @@
}
if (engine != NULL && engine->u.rail.other_multiheaded_part != NULL) {
AddWagonToConsist(engine->u.rail.other_multiheaded_part, engine);
- // previous line set the front engine to the old front. We need to clear that
+ /* previous line set the front engine to the old front. We need to clear that */
engine->u.rail.other_multiheaded_part->first = NULL;
}
}
@@ -1233,6 +1238,7 @@
/** Start/Stop a train.
* @param tile unused
+ * @param flags type of operation
* @param p1 train to start/stop
* @param p2 unused
*/
@@ -1269,6 +1275,7 @@
/** Sell a (single) train wagon/engine.
* @param tile unused
+ * @param flags type of operation
* @param p1 the wagon/engine index
* @param p2 the selling mode
* - p2 = 0: only sell the single dragged wagon/engine (and any belonging rear-engines)
@@ -1290,7 +1297,7 @@
while (IsArticulatedPart(v)) v = GetPrevVehicleInChain(v);
Vehicle *first = GetFirstVehicleInChain(v);
- // make sure the vehicle is stopped in the depot
+ /* make sure the vehicle is stopped in the depot */
if (CheckTrainStoppedInDepot(first) < 0) {
return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
}
@@ -1596,8 +1603,8 @@
uint length = CountVehiclesInChain(v);
while (length > 2) {
- // find pairwise matching wagon
- // start<>end, start+1<>end-1, ...
+ /* find pairwise matching wagon
+ * start<>end, start+1<>end-1, ... */
Vehicle *last = first;
for (uint i = length - 3; i > 0; i--) last = last->next;
@@ -1605,7 +1612,7 @@
if (before) differential *= -1;
if (differential > 0) {
- // disconnect last car to make sure only this subset moves
+ /* disconnect last car to make sure only this subset moves */
Vehicle *tempnext = last->next;
last->next = NULL;
@@ -1643,7 +1650,7 @@
DisableTrainCrossing(tile);
}
- // count number of vehicles
+ /* count number of vehicles */
int r = -1;
const Vehicle *u = v;
do r++; while ( (u = u->next) != NULL );
@@ -1667,6 +1674,7 @@
/** Reverse train.
* @param tile unused
+ * @param flags type of operation
* @param p1 train to reverse
* @param p2 if true, reverse a unit in a train (needs to be in a depot)
*/
@@ -1679,14 +1687,14 @@
if (v->type != VEH_TRAIN || !CheckOwnership(v->owner)) return CMD_ERROR;
if (p2) {
- // turn a single unit around
+ /* turn a single unit around */
if (IsMultiheaded(v) || HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) {
return_cmd_error(STR_ONLY_TURN_SINGLE_UNIT);
}
Vehicle *front = GetFirstVehicleInChain(v);
- // make sure the vehicle is stopped in the depot
+ /* make sure the vehicle is stopped in the depot */
if (CheckTrainStoppedInDepot(front) < 0) {
return_cmd_error(STR_881A_TRAINS_CAN_ONLY_BE_ALTERED);
}
@@ -1697,7 +1705,7 @@
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
}
} else {
- //turn the whole train around
+ /*turn the whole train around */
if (v->u.rail.crash_anim_pos != 0 || v->breakdown_ctr != 0) return CMD_ERROR;
if (flags & DC_EXEC) {
@@ -1715,6 +1723,7 @@
/** Force a train through a red signal
* @param tile unused
+ * @param flags type of operation
* @param p1 train to ignore the red signal
* @param p2 unused
*/
@@ -1733,6 +1742,7 @@
/** Refits a train to the specified cargo type.
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID of the train to refit
* param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to
@@ -1854,8 +1864,8 @@
return false;
}
-// returns the tile of a depot to goto to. The given vehicle must not be
-// crashed!
+/** returns the tile of a depot to goto to. The given vehicle must not be
+ * crashed! */
static TrainFindDepotData FindClosestTrainDepot(Vehicle *v, int max_distance)
{
assert(!(v->vehstatus & VS_CRASHED));
@@ -1893,7 +1903,7 @@
if (NPFGetFlag(&ftd.node, NPF_FLAG_REVERSE)) tfdd.reverse = true;
}
} else {
- // search in the forward direction first.
+ /* search in the forward direction first. */
DiagDirection i = DirToDiagDir(v->direction);
if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[i]) {
i = ChangeDiagDir(i, DIAGDIRDIFF_90LEFT);
@@ -1901,7 +1911,7 @@
NewTrainPathfind(tile, 0, v->u.rail.compatible_railtypes, i, (NTPEnumProc*)NtpCallbFindDepot, &tfdd);
if (tfdd.best_length == (uint)-1){
tfdd.reverse = true;
- // search in backwards direction
+ /* search in backwards direction */
i = ReverseDiagDir(DirToDiagDir(v->direction));
if (!(v->direction & 1) && v->u.rail.track != _state_dir_table[i]) {
i = ChangeDiagDir(i, DIAGDIRDIFF_90LEFT);
@@ -1915,6 +1925,7 @@
/** Send a train to a depot
* @param tile unused
+ * @param flags type of operation
* @param p1 train to send to the depot
* @param p2 various bitmasked elements
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
@@ -2010,7 +2021,7 @@
byte effect_type = GB(v->u.rail.cached_vis_effect, 4, 2);
bool disable_effect = HASBIT(v->u.rail.cached_vis_effect, 6);
- // no smoke?
+ /* no smoke? */
if ((rvi->railveh_type == RAILVEH_WAGON && effect_type == 0) ||
disable_effect ||
rvi->railtype > RAILTYPE_ELECTRIC ||
@@ -2018,14 +2029,14 @@
continue;
}
- // No smoke in depots or tunnels
+ /* No smoke in depots or tunnels */
if (IsTileDepotType(v->tile, TRANSPORT_RAIL) || IsTunnelTile(v->tile)) continue;
- // No sparks for electric vehicles on nonelectrified tracks
+ /* No sparks for electric vehicles on nonelectrified tracks */
if (!HasPowerOnRail(v->u.rail.railtype, GetTileRailType(v->tile))) continue;
if (effect_type == 0) {
- // Use default effect type for engine class.
+ /* Use default effect type for engine class. */
effect_type = rvi->engclass;
} else {
effect_type--;
@@ -2041,7 +2052,7 @@
switch (effect_type) {
case 0:
- // steam smoke.
+ /* steam smoke. */
if (GB(v->tick_counter, 0, 4) == 0) {
CreateEffectVehicleRel(v, x, y, 10, EV_STEAM_SMOKE);
sound = true;
@@ -2049,7 +2060,7 @@
break;
case 1:
- // diesel smoke
+ /* diesel smoke */
if (u->cur_speed <= 40 && CHANCE16(15, 128)) {
CreateEffectVehicleRel(v, 0, 0, 10, EV_DIESEL_SMOKE);
sound = true;
@@ -2057,7 +2068,7 @@
break;
case 2:
- // blue spark
+ /* blue spark */
if (GB(v->tick_counter, 0, 2) == 0 && CHANCE16(1, 45)) {
CreateEffectVehicleRel(v, 0, 0, 10, EV_ELECTRIC_SPARK);
sound = true;
@@ -2094,12 +2105,12 @@
static bool CheckTrainStayInDepot(Vehicle *v)
{
- // bail out if not all wagons are in the same depot or not in a depot at all
+ /* bail out if not all wagons are in the same depot or not in a depot at all */
for (const Vehicle *u = v; u != NULL; u = u->next) {
if (u->u.rail.track != TRACK_BIT_DEPOT || u->tile != v->tile) return false;
}
- // if the train got no power, then keep it in the depot
+ /* if the train got no power, then keep it in the depot */
if (v->u.rail.cached_power == 0) {
v->vehstatus |= VS_STOPPED;
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
@@ -2151,10 +2162,10 @@
static bool NtpCallbFindStation(TileIndex tile, TrainTrackFollowerData *ttfd, Trackdir track, uint length)
{
- // heading for nowhere?
+ /* heading for nowhere? */
if (ttfd->dest_coords == 0) return false;
- // did we reach the final station?
+ /* did we reach the final station? */
if ((ttfd->station_index == INVALID_STATION && tile == ttfd->dest_coords) || (
IsTileType(tile, MP_STATION) &&
IsRailwayStation(tile) &&
@@ -2163,12 +2174,13 @@
/* We do not check for dest_coords if we have a station_index,
* because in that case the dest_coords are just an
* approximation of where the station is */
- // found station
+
+ /* found station */
ttfd->best_track = track;
ttfd->best_bird_dist = 0;
return true;
} else {
- // didn't find station, keep track of the best path so far.
+ /* didn't find station, keep track of the best path so far. */
uint dist = DistanceManhattan(tile, ttfd->dest_coords);
if (dist < ttfd->best_bird_dist) {
ttfd->best_bird_dist = dist;
@@ -2205,12 +2217,12 @@
};
static const byte _search_directions[6][4] = {
- { 0, 9, 2, 9 }, // track 1
- { 9, 1, 9, 3 }, // track 2
- { 9, 0, 3, 9 }, // track upper
- { 1, 9, 9, 2 }, // track lower
- { 3, 2, 9, 9 }, // track left
- { 9, 9, 1, 0 }, // track right
+ { 0, 9, 2, 9 }, ///< track 1
+ { 9, 1, 9, 3 }, ///< track 2
+ { 9, 0, 3, 9 }, ///< track upper
+ { 1, 9, 9, 2 }, ///< track lower
+ { 3, 2, 9, 9 }, ///< track left
+ { 9, 9, 1, 0 }, ///< track right
};
static const byte _pick_track_table[6] = {1, 3, 2, 2, 0, 0};
@@ -2219,7 +2231,7 @@
static Track ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
{
Track best_track;
- // pathfinders are able to tell that route was only 'guessed'
+ /* pathfinders are able to tell that route was only 'guessed' */
bool path_not_found = false;
#ifdef PF_BENCHMARK
@@ -2250,9 +2262,9 @@
NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes);
if (ftd.best_trackdir == 0xff) {
- /* We are already at our target. Just do something */
- //TODO: maybe display error?
- //TODO: go straight ahead if possible?
+ /* We are already at our target. Just do something
+ * @todo maybe display error?
+ * @todo: go straight ahead if possible? */
best_track = FindFirstTrack(tracks);
} else {
/* If ftd.best_bird_dist is 0, we found our target and ftd.best_trackdir contains
@@ -2280,11 +2292,11 @@
NewTrainPathfind(tile - TileOffsByDiagDir(enterdir), v->dest_tile,
v->u.rail.compatible_railtypes, enterdir, (NTPEnumProc*)NtpCallbFindStation, &fd);
- // check whether the path was found or only 'guessed'
+ /* check whether the path was found or only 'guessed' */
if (fd.best_bird_dist != 0) path_not_found = true;
if (fd.best_track == 0xff) {
- // blaha
+ /* blaha */
best_track = FindFirstTrack(tracks);
} else {
best_track = TrackdirToTrack(fd.best_track);
@@ -2293,13 +2305,13 @@
int time = NpfEndInterval(perf);
DEBUG(yapf, 4, "[NTPT] %d us - %d rounds - %d open - %d closed -- ", time, 0, 0, 0);
}
- // handle "path not found" state
+ /* handle "path not found" state */
if (path_not_found) {
- // PF didn't find the route
+ /* PF didn't find the route */
if (!HASBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
- // it is first time the problem occurred, set the "path not found" flag
+ /* it is first time the problem occurred, set the "path not found" flag */
SETBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
- // and notify user about the event
+ /* and notify user about the event */
if (_patches.lost_train_warn && v->owner == _local_player) {
SetDParam(0, v->unitnumber);
AddNewsItem(
@@ -2310,11 +2322,11 @@
}
}
} else {
- // route found, is the train marked with "path not found" flag?
+ /* route found, is the train marked with "path not found" flag? */
if (HASBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION)) {
- // clear the flag as the PF's problem was solved
+ /* clear the flag as the PF's problem was solved */
CLRBIT(v->u.rail.flags, VRF_NO_PATH_TO_DESTINATION);
- // can we also delete the "News" item somehow?
+ /* can we also delete the "News" item somehow? */
}
}
@@ -2440,14 +2452,14 @@
default: break;
}
- // check if we've reached the waypoint?
+ /* check if we've reached the waypoint? */
bool at_waypoint = false;
if (v->current_order.type == OT_GOTO_WAYPOINT && v->tile == v->dest_tile) {
v->cur_order_index++;
at_waypoint = true;
}
- // check if we've reached a non-stop station while TTDPatch nonstop is enabled..
+ /* check if we've reached a non-stop station while TTDPatch nonstop is enabled.. */
if (_patches.new_nonstop &&
v->current_order.flags & OF_NON_STOP &&
IsTileType(v->tile, MP_STATION) &&
@@ -2455,25 +2467,25 @@
v->cur_order_index++;
}
- // Get the current order
+ /* Get the current order */
if (v->cur_order_index >= v->num_orders) v->cur_order_index = 0;
const Order *order = GetVehicleOrder(v, v->cur_order_index);
- // If no order, do nothing.
+ /* If no order, do nothing. */
if (order == NULL) {
v->current_order.Free();
v->dest_tile = 0;
return false;
}
- // If it is unchanged, keep it.
+ /* If it is unchanged, keep it. */
if (order->type == v->current_order.type &&
order->flags == v->current_order.flags &&
order->dest == v->current_order.dest)
return false;
- // Otherwise set it, and determine the destination tile.
+ /* Otherwise set it, and determine the destination tile. */
v->current_order = *order;
v->dest_tile = 0;
@@ -2516,7 +2528,7 @@
case OT_LOADING: {
if (mode) return;
- // don't mark the train as lost if we're loading on the final station.
+ /* don't mark the train as lost if we're loading on the final station. */
if (v->current_order.flags & OF_NON_STOP) {
v->u.rail.days_since_order_progr = 0;
}
@@ -2527,13 +2539,13 @@
v->current_order.flags & OF_FULL_LOAD ||
(_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED))
)) {
- v->u.rail.days_since_order_progr = 0; /* Prevent a train lost message for full loading trains */
+ v->u.rail.days_since_order_progr = 0; // Prevent a train lost message for full loading trains
SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
if (LoadUnloadVehicle(v, false)) {
InvalidateWindow(WC_TRAINS_LIST, v->owner);
MarkTrainDirty(v);
- // need to update acceleration and cached values since the goods on the train changed.
+ /* need to update acceleration and cached values since the goods on the train changed. */
TrainCargoChanged(v);
UpdateTrainAcceleration(v);
}
@@ -2545,7 +2557,7 @@
Order b = v->current_order;
v->LeaveStation();
- // If this was not the final order, don't remove it from the list.
+ /* If this was not the final order, don't remove it from the list. */
if (!(b.flags & OF_NON_STOP)) return;
break;
}
@@ -2614,16 +2626,16 @@
);
}
- // Did we reach the final destination?
+ /* Did we reach the final destination? */
if (v->current_order.type == OT_GOTO_STATION &&
v->current_order.dest == station) {
- // Yeah, keep the load/unload flags
- // Non Stop now means if the order should be increased.
+ /* Yeah, keep the load/unload flags
+ * Non Stop now means if the order should be increased. */
v->BeginLoading();
v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
v->current_order.flags |= OF_NON_STOP;
} else {
- // No, just do a simple load
+ /* No, just do a simple load */
v->BeginLoading();
v->current_order.flags = 0;
}
@@ -2641,7 +2653,7 @@
static byte AfterSetTrainPos(Vehicle *v, bool new_tile)
{
- // need this hint so it returns the right z coordinate on bridges.
+ /* need this hint so it returns the right z coordinate on bridges. */
byte new_z = GetSlopeZ(v->x_pos, v->y_pos);
byte old_z = v->z_pos;
@@ -2654,7 +2666,7 @@
if (new_z != old_z) {
TileIndex tile = TileVirtXY(v->x_pos, v->y_pos);
- // XXX workaround, whole UP/DOWN detection needs overhaul
+ /* XXX workaround, whole UP/DOWN detection needs overhaul */
if (!IsTunnelTile(tile)) {
SETBIT(v->u.rail.flags, (new_z > old_z) ? VRF_GOINGUP : VRF_GOINGDOWN);
}
@@ -2727,13 +2739,13 @@
static const RailtypeSlowdownParams _railtype_slowdown[] = {
// normal accel
- {256 / 4, 256 / 2, 256 / 4, 2}, // normal
- {256 / 4, 256 / 2, 256 / 4, 2}, // electrified
- {256 / 4, 256 / 2, 256 / 4, 2}, // monorail
- {0, 256 / 2, 256 / 4, 2}, // maglev
+ {256 / 4, 256 / 2, 256 / 4, 2}, ///< normal
+ {256 / 4, 256 / 2, 256 / 4, 2}, ///< electrified
+ {256 / 4, 256 / 2, 256 / 4, 2}, ///< monorail
+ {0, 256 / 2, 256 / 4, 2}, ///< maglev
};
-/* Modify the speed of the vehicle due to a turn */
+/** Modify the speed of the vehicle due to a turn */
static void AffectSpeedByDirChange(Vehicle* v, Direction new_dir)
{
if (_patches.realistic_acceleration) return;
@@ -2745,7 +2757,7 @@
v->cur_speed -= (diff == DIRDIFF_45RIGHT || diff == DIRDIFF_45LEFT ? rsp->small_turn : rsp->large_turn) * v->cur_speed >> 8;
}
-/* Modify the speed of the vehicle due to a change in altitude */
+/** Modify the speed of the vehicle due to a change in altitude */
static void AffectSpeedByZChange(Vehicle *v, byte old_z)
{
if (old_z == v->z_pos || _patches.realistic_acceleration) return;
@@ -2820,7 +2832,7 @@
return num;
}
-/*
+/**
* Checks whether the specified train has a collision with another vehicle. If
* so, destroys this vehicle, and the other vehicle if its subtype has TS_Front.
* Reports the incident in a flashy news item, modifies station ratings and
@@ -2848,10 +2860,10 @@
(v->u.rail.track == TRACK_BIT_WORMHOLE && (v->direction & 2) != (realcoll->direction & 2)))
return;
- //two drivers + passangers killed in train v
+ /* two drivers + passangers killed in train v */
uint num = 2 + CountPassengersInTrain(v);
if (!(coll->vehstatus & VS_CRASHED))
- //two drivers + passangers killed in train coll (if it was not crashed already)
+ /* two drivers + passangers killed in train coll (if it was not crashed already) */
num += 2 + CountPassengersInTrain(coll);
SetVehicleCrashed(v);
@@ -2959,8 +2971,8 @@
/* Check if it's a red signal and that force proceed is not clicked. */
if ((tracks >> 16) & chosen_track && v->u.rail.force_proceed == 0) {
- // In front of a red signal
- /* find the first set bit in ts. need to do it in 2 steps, since
+ /* In front of a red signal
+ * find the first set bit in ts. need to do it in 2 steps, since
* FIND_FIRST_BIT only handles 6 bits at a time. */
Trackdir i = FindFirstTrackdir((TrackdirBits)(uint16)ts);
@@ -3300,7 +3312,7 @@
return false;
}
if ((ts &= (ts >> 16)) == 0) {
- // make a rail/road crossing red
+ /* make a rail/road crossing red */
if (IsLevelCrossingTile(tile)) {
if (!IsCrossingBarred(tile)) {
BarCrossing(tile);
@@ -3316,7 +3328,7 @@
return false;
}
- // slow down
+ /* slow down */
v->vehstatus |= VS_TRAIN_SLOWING;
uint16 break_speed = _breakdown_speeds[x & 0xF];
if (!(v->direction & 1)) break_speed >>= 1;
@@ -3369,7 +3381,7 @@
int j = UpdateTrainSpeed(v);
if (j == 0) {
- // if the vehicle has speed 0, update the last_speed field.
+ /* if the vehicle has speed 0, update the last_speed field. */
if (v->cur_speed != 0) return;
} else {
TrainCheckIfLineEnds(v);
@@ -3396,11 +3408,11 @@
if (IsFrontEngine(v)) {
TrainLocoHandler(v, false);
- // make sure vehicle wasn't deleted.
+ /* make sure vehicle wasn't deleted. */
if (v->type == VEH_TRAIN && IsFrontEngine(v))
TrainLocoHandler(v, true);
} else if (IsFreeWagon(v) && HASBITS(v->vehstatus, VS_CRASHED)) {
- // Delete flooded standalone wagon
+ /* Delete flooded standalone wagon */
if (++v->u.rail.crash_anim_pos >= 4400)
DeleteVehicle(v);
}
@@ -3415,8 +3427,8 @@
if (v->vehstatus & VS_STOPPED) return;
if (_patches.gotodepot && VehicleHasDepotOrders(v)) return;
- // Don't interfere with a depot visit scheduled by the user, or a
- // depot visit by the order list.
+ /* Don't interfere with a depot visit scheduled by the user, or a
+ * depot visit by the order list. */
if (v->current_order.type == OT_GOTO_DEPOT &&
(v->current_order.flags & (OF_HALT_IN_DEPOT | OF_PART_OF_ORDERS)) != 0)
return;
@@ -3515,7 +3527,7 @@
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFrontEngine(v)) {
- // show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list)
+ /* show warning if train is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
if (_patches.train_income_warn && v->owner == _local_player && v->age >= 730 && v->profit_this_year < 0) {
SetDParam(1, v->profit_this_year);
SetDParam(0, v->unitnumber);
@@ -3587,7 +3599,7 @@
}
}
-/*
+/**
* Converts all trains to the new subtype format introduced in savegame 16.2
* It also links multiheaded engines or make them forget they are multiheaded if no suitable partner is found
*/
diff -r 3b068c3a1c74 -r 0fa543611bbe src/train_gui.cpp
--- a/src/train_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/train_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file train_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -22,7 +24,7 @@
if (!success) return;
- // find a locomotive in the depot.
+ /* find a locomotive in the depot. */
found = NULL;
FOR_ALL_VEHICLES(v) {
if (v->type == VEH_TRAIN && IsFrontEngine(v) &&
@@ -33,10 +35,10 @@
}
}
- // if we found a loco,
+ /* if we found a loco, */
if (found != NULL) {
found = GetLastVehicleInChain(found);
- // put the new wagon at the end of the loco.
+ /* put the new wagon at the end of the loco. */
DoCommandP(0, _new_vehicle_id | (found->index << 16), 0, NULL, CMD_MOVE_RAIL_VEHICLE);
RebuildVehicleLists();
}
@@ -447,7 +449,7 @@
y = 57;
sel = w->vscroll.pos;
- // draw the first 3 details tabs
+ /* draw the first 3 details tabs */
if (det_tab != 3) {
x = 1;
for (;;) {
@@ -470,7 +472,7 @@
default: NOT_REACHED();
case 0: TrainDetailsCargoTab( v, px, py); break;
case 1:
- // Only show name and value for the 'real' part
+ /* Only show name and value for the 'real' part */
if (!IsArticulatedPart(v)) {
TrainDetailsInfoTab(v, px, py);
}
@@ -481,7 +483,7 @@
v = u;
} else {
- // Move to the next line
+ /* Move to the next line */
do {
v = v->next;
} while (v != NULL && IsArticulatedPart(v) && v->cargo_cap == 0);
@@ -489,7 +491,7 @@
if (v == NULL) return;
}
} else {
- // draw total cargo tab
+ /* draw total cargo tab */
DrawString(x, y + 2, STR_013F_TOTAL_CAPACITY_TEXT, 0);
for (CargoID i = 0; i < NUM_CARGO; i++) {
if (max_cargo[i] > 0 && --sel < 0 && sel > -w->vscroll.cap) {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/transparency_gui.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/transparency_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -0,0 +1,68 @@
+/* $Id$ */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "table/sprites.h"
+#include "table/strings.h"
+#include "functions.h"
+#include "window.h"
+#include "gui.h"
+#include "viewport.h"
+#include "gfx.h"
+#include "sound.h"
+#include "variables.h"
+
+static void Transparent_Click(byte widget)
+{
+ TOGGLEBIT(_transparent_opt, widget);
+ SndPlayFx(SND_15_BEEP);
+}
+
+static void TransparencyToolbWndProc(Window *w, WindowEvent *e)
+{
+ switch (e->event) {
+ case WE_PAINT:
+ for (uint i = 0; i < 7; i++) {
+ SetWindowWidgetLoweredState(w, i + 3, HASBIT(_transparent_opt, i));
+ }
+ DrawWindowWidgets(w);
+ break;
+
+ case WE_CLICK:
+ if (e->we.click.widget >= 3) {
+ Transparent_Click(e->we.click.widget - 3);
+ MarkWholeScreenDirty();
+ }
+ break;
+ }
+}
+
+static const Widget _transparency_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 162, 0, 13, STR_TRANSPARENCY_TOOLB, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{WWT_STICKYBOX, RESIZE_NONE, 7, 163, 174, 0, 13, STR_NULL, STR_STICKY_BUTTON},
+
+/* transparency widgets: transparent signs, trees, houses, industries, player's buildings */
+{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_PLACE_SIGN, STR_TRANSPARENT_SIGNS_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_PLANTTREES, STR_TRANSPARENT_TREES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_TOWN, STR_TRANSPARENT_HOUSES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_INDUSTRY, STR_TRANSPARENT_INDUSTRIES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_COMPANY_LIST, STR_TRANSPARENT_BUILDINGS_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 152, 14, 35, SPR_IMG_BRIDGE, STR_TRANSPARENT_BRIDGES_DESC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 153, 174, 14, 35, SPR_IMG_TRANSMITTER, STR_TRANSPARENT_STRUCTURES_DESC},
+
+{ WIDGETS_END},
+};
+
+static const WindowDesc _transparency_desc = {
+ WDP_ALIGN_TBR, 58+36, 175, 36,
+ WC_TRANSPARENCY_TOOLBAR, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
+ _transparency_widgets,
+ TransparencyToolbWndProc
+};
+
+void ShowTransparencyToolbar(void)
+{
+ AllocateWindowDescFront(&_transparency_desc, 0);
+}
diff -r 3b068c3a1c74 -r 0fa543611bbe src/transparency_gui.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/transparency_gui.h Tue Jun 12 11:56:35 2007 +0000
@@ -0,0 +1,8 @@
+/* $Id$ */
+
+#ifndef TRANSPARENCY_GUI_H
+#define TRANSPARENCY_GUI_H
+
+void ShowTransparencyToolbar();
+
+#endif /* TRANSPARENCY_GUI_H */
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tree_cmd.cpp
--- a/src/tree_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tree_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tree_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -53,7 +55,7 @@
if (tree != TREE_INVALID) {
MakeTree(tile, tree, GB(r, 22, 2), min(GB(r, 16, 3), 6), TREE_GROUND_GRASS, 0);
- // above snowline?
+ /* above snowline? */
if (_opt.landscape == LT_ARCTIC && GetTileZ(tile) > GetSnowLine()) {
SetTreeGroundDensity(tile, TREE_GROUND_SNOW_DESERT, 3);
SetTreeCounter(tile, (TreeGround)GB(r, 24, 3));
@@ -207,6 +209,7 @@
/** Plant a tree.
* @param tile start tile of area-drag of tree plantation
+ * @param flags type of operation
* @param p1 tree type, -1 means random.
* @param p2 end tile of area-drag
*/
@@ -240,7 +243,7 @@
switch (GetTileType(tile)) {
case MP_TREES:
- // no more space for trees?
+ /* no more space for trees? */
if (_game_mode != GM_EDITOR && GetTreeCount(tile) == 3) {
msg = STR_2803_TREE_ALREADY_HERE;
continue;
@@ -250,7 +253,7 @@
AddTreeCount(tile, 1);
MarkTileDirtyByTile(tile);
}
- // 2x as expensive to add more trees to an existing tile
+ /* 2x as expensive to add more trees to an existing tile */
cost += _eco->GetPrice(CEconomy::BUILD_TREES) * 2;
break;
@@ -365,7 +368,7 @@
StartSpriteCombine();
- if (!(_display_opt & DO_TRANS_BUILDINGS) || !_patches.invisible_trees) {
+ if (!HASBIT(_transparent_opt, TO_TREES) || !_patches.invisible_trees) {
TreeListEnt te[4];
uint i;
@@ -374,7 +377,7 @@
do {
SpriteID image = s[0].sprite + (--i == 0 ? GetTreeGrowth(ti->tile) : 3);
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_TREES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -622,7 +625,7 @@
MakeTree(tile, tree, 0, 0, ct == CLEAR_ROUGH ? TREE_GROUND_ROUGH : TREE_GROUND_GRASS, 0);
}
- // byte underflow
+ /* byte underflow */
if (--_trees_tick_ctr != 0) return;
/* place a tree at a random spot */
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tree_map.h
--- a/src/tree_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tree_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tree_map.h */
+
#ifndef TREE_MAP_H
#define TREE_MAP_H
@@ -26,9 +28,9 @@
/* ground type, m2 bits 4...5
* valid densities (bits 6...7) in comments after the enum */
enum TreeGround {
- TREE_GROUND_GRASS = 0, // 0
- TREE_GROUND_ROUGH = 1, // 0
- TREE_GROUND_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert
+ TREE_GROUND_GRASS = 0, ///< 0
+ TREE_GROUND_ROUGH = 1, ///< 0
+ TREE_GROUND_SNOW_DESERT = 2 ///< 0-3 for snow, 3 for desert
};
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tunnel_map.cpp
--- a/src/tunnel_map.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tunnel_map.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tunnel_map.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "tile.h"
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tunnel_map.h
--- a/src/tunnel_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tunnel_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tunnel_map.h */
+
#ifndef TUNNEL_MAP_H
#define TUNNEL_MAP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/tunnelbridge_cmd.cpp
--- a/src/tunnelbridge_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/tunnelbridge_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -61,8 +61,9 @@
Bridge _bridge[MAX_BRIDGES];
-// calculate the price factor for building a long bridge.
-// basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,
+/** calculate the price factor for building a long bridge.
+ * basically the cost delta is 1,1, 1, 2,2, 3,3,3, 4,4,4,4, 5,5,5,5,5, 6,6,6,6,6,6, 7,7,7,7,7,7,7, 8,8,8,8,8,8,8,8,
+ */
int CalcBridgeLenCostFactor(int x)
{
int n;
@@ -79,11 +80,11 @@
#define M(x) (1 << (x))
enum BridgeFoundation {
- // foundation, whole tile is leveled up --> 3 corners raised
+ /* foundation, whole tile is leveled up --> 3 corners raised */
BRIDGE_FULL_LEVELED_FOUNDATION = M(SLOPE_WSE) | M(SLOPE_NWS) | M(SLOPE_ENW) | M(SLOPE_SEN),
- // foundation, tile is partly leveled up --> 1 corner raised
+ /* foundation, tile is partly leveled up --> 1 corner raised */
BRIDGE_PARTLY_LEVELED_FOUNDATION = M(SLOPE_W) | M(SLOPE_S) | M(SLOPE_E) | M(SLOPE_N),
- // no foundations (X,Y direction)
+ /* no foundations (X,Y direction) */
BRIDGE_NO_FOUNDATION = M(SLOPE_FLAT) | M(SLOPE_SW) | M(SLOPE_SE) | M(SLOPE_NW) | M(SLOPE_NE),
BRIDGE_HORZ_RAMP = (BRIDGE_PARTLY_LEVELED_FOUNDATION | BRIDGE_NO_FOUNDATION) & ~M(SLOPE_FLAT)
};
@@ -167,6 +168,7 @@
/** Build a Bridge
* @param end_tile end tile
+ * @param flags type of operation
* @param p1 packed start tile coords (~ dx)
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 7) - bridge type (hi bh)
@@ -202,7 +204,7 @@
if (p1 >= MapSize()) return CMD_ERROR;
- // type of bridge
+ /* type of bridge */
if (HASBIT(p2, 15)) {
railtype = INVALID_RAILTYPE; // road bridge
} else {
@@ -255,7 +257,7 @@
if (z_start != z_end) return_cmd_error(STR_5009_LEVEL_LAND_OR_WATER_REQUIRED);
- // Towns are not allowed to use bridges on slopes.
+ /* Towns are not allowed to use bridges on slopes. */
allow_on_slopes = (!_is_old_ai_player
&& _current_player != OWNER_TOWN && _patches.build_on_slopes);
@@ -315,7 +317,7 @@
if (CmdFailed(ret)) return ret;
cost += ret;
- // false - end tile slope check
+ /* false - end tile slope check */
terraformcost = CheckBridgeSlopeSouth(direction, tileh_end);
if (CmdFailed(terraformcost) || (terraformcost != 0 && !allow_on_slopes))
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
@@ -439,6 +441,7 @@
/** Build Tunnel.
* @param tile start tile of tunnel
+ * @param flags type of operation
* @param p1 railtype, 0x200 for road tunnel
* @param p2 unused
*/
@@ -496,10 +499,10 @@
/* Add the cost of the entrance */
cost += _eco->GetPrice(CEconomy::BUILD_TUNNEL) + ret;
- // if the command fails from here on we want the end tile to be highlighted
+ /* if the command fails from here on we want the end tile to be highlighted */
_build_tunnel_endtile = end_tile;
- // slope of end tile must be complementary to the slope of the start tile
+ /* slope of end tile must be complementary to the slope of the start tile */
if (end_tileh != ComplementSlope(start_tileh)) {
ret = DoCommand(end_tile, end_tileh & start_tileh, 0, flags, CMD_TERRAFORM_LAND);
if (CmdFailed(ret)) return_cmd_error(STR_5005_UNABLE_TO_EXCAVATE_LAND);
@@ -591,12 +594,12 @@
}
if (flags & DC_EXEC) {
- // We first need to request the direction before calling DoClearSquare
- // else the direction is always 0.. dah!! ;)
+ /* We first need to request the direction before calling DoClearSquare
+ * else the direction is always 0.. dah!! ;) */
DiagDirection dir = GetTunnelDirection(tile);
Track track;
- // Adjust the town's player rating. Do this before removing the tile owner info.
+ /* Adjust the town's player rating. Do this before removing the tile owner info. */
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
@@ -637,8 +640,8 @@
endtile = GetOtherBridgeEnd(tile);
- if (!EnsureNoVehicle(tile) ||
- !EnsureNoVehicle(endtile) ||
+ if (!EnsureNoVehicleOnGround(tile) ||
+ !EnsureNoVehicleOnGround(endtile) ||
IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
return CMD_ERROR;
}
@@ -661,8 +664,8 @@
TileIndex c;
Track track;
- //checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
- // you have a "Poor" (0) town rating
+ /* checks if the owner is town then decrease town rating by RATING_TUNNEL_BRIDGE_DOWN_STEP until
+ * you have a "Poor" (0) town rating */
if (IsTileOwner(tile, OWNER_TOWN) && _game_mode != GM_EDITOR)
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM);
@@ -717,7 +720,7 @@
if (GetRailType(tile) == totype) return CMD_ERROR;
- // 'hidden' elrails can't be downgraded to normal rail when elrails are disabled
+ /* 'hidden' elrails can't be downgraded to normal rail when elrails are disabled */
if (_patches.disable_elrails && totype == RAILTYPE_RAIL && GetRailType(tile) == RAILTYPE_ELECTRIC) return CMD_ERROR;
endtile = CheckTunnelBusy(tile, &length);
@@ -741,8 +744,8 @@
endtile = GetOtherBridgeEnd(tile);
- if (!EnsureNoVehicle(tile) ||
- !EnsureNoVehicle(endtile) ||
+ if (!EnsureNoVehicleOnGround(tile) ||
+ !EnsureNoVehicleOnGround(endtile) ||
IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
return CMD_ERROR;
}
@@ -792,7 +795,7 @@
{ 2, 4, 8, 1, 2, 16, 9, 0 }
};
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -829,7 +832,7 @@
if (HASBIT(BRIDGE_FULL_LEVELED_FOUNDATION, tileh)) return tileh;
- // inclined sloped building
+ /* inclined sloped building */
switch (tileh) {
case SLOPE_W:
case SLOPE_STEEP_W: i = 0; break;
@@ -850,6 +853,7 @@
* 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
* and it works a bit like a bitmask. For bridge heads:
+ * @param ti TileInfo of the structure to draw
*
- Bit 0: direction
* - Bit 1: northern or southern heads
* - Bit 2: Set if the bridge head is sloped
@@ -884,7 +888,7 @@
if (GetBridgeTransportType(ti->tile) == TRANSPORT_RAIL) {
base_offset = GetRailTypeInfo(GetRailType(ti->tile))->bridge_offset;
- assert(base_offset != 8); /* This one is used for roads */
+ assert(base_offset != 8); // This one is used for roads
} else {
base_offset = 8;
}
@@ -897,7 +901,7 @@
if (f != 0) DrawFoundation(ti, f);
}
- // HACK Wizardry to convert the bridge ramp direction into a sprite offset
+ /* HACK Wizardry to convert the bridge ramp direction into a sprite offset */
base_offset += (6 - GetBridgeRampDirection(ti->tile)) % 4;
if (ti->tileh == SLOPE_FLAT) base_offset += 4; // sloped bridge head
@@ -915,8 +919,8 @@
image = psid->sprite;
- // draw ramp
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ /* draw ramp */
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -1008,7 +1012,7 @@
z = GetBridgeHeight(rampsouth) - 3;
image = psid->sprite;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -1023,14 +1027,14 @@
psid++;
image = psid->sprite;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
pal = psid->pal;
}
- // draw roof, the component of the bridge which is logically between the vehicle and the camera
+ /* draw roof, the component of the bridge which is logically between the vehicle and the camera */
if (axis == AXIS_X) {
y += 12;
if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 16, 1, 0x28, z);
@@ -1043,10 +1047,10 @@
psid++;
if (ti->z + 5 == z) {
- // draw poles below for small bridges
+ /* draw poles below for small bridges */
if (psid->sprite != 0) {
image = psid->sprite;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BRIDGES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -1056,7 +1060,7 @@
DrawGroundSpriteAt(image, pal, x, y, z);
}
} else if (_patches.bridge_pillars) {
- // draw pillars below for high bridges
+ /* draw pillars below for high bridges */
DrawBridgePillars(psid, ti, axis, type, x, y, z);
}
}
@@ -1073,13 +1077,13 @@
if (IsTunnel(tile)) {
uint pos = (DiagDirToAxis(GetTunnelDirection(tile)) == AXIS_X ? y : x);
- // In the tunnel entrance?
+ /* In the tunnel entrance? */
if (5 <= pos && pos <= 10) return z;
} else {
DiagDirection dir = GetBridgeRampDirection(tile);
uint pos = (DiagDirToAxis(dir) == AXIS_X ? y : x);
- // On the bridge ramp?
+ /* On the bridge ramp? */
if (5 <= pos && pos <= 10) {
uint delta;
@@ -1302,7 +1306,7 @@
dir = GetTunnelDirection(tile);
vdir = DirToDiagDir(v->direction);
- // Enter tunnel?
+ /* Enter tunnel? */
if (v->u.road.state != RVSB_WORMHOLE && dir == vdir) {
if (fc == _tunnel_fractcoord_4[dir] ||
fc == _tunnel_fractcoord_5[dir]) {
diff -r 3b068c3a1c74 -r 0fa543611bbe src/unix.cpp
--- a/src/unix.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/unix.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file unix.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
@@ -27,7 +29,7 @@
#include
ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;)
-// The system supplied definition of SIG_IGN does not match
+/* The system supplied definition of SIG_IGN does not match */
#undef SIG_IGN
#define SIG_IGN (void (*)(int))1
#endif /* __MORPHOS__ */
@@ -39,7 +41,7 @@
#if defined(__APPLE__)
#if defined(WITH_SDL)
- //the mac implementation needs this file included in the same file as main()
+ /*the mac implementation needs this file included in the same file as main() */
#include
#endif
#endif
@@ -104,11 +106,11 @@
void ShowOSErrorBox(const char *buf)
{
#if defined(__APPLE__)
- // this creates an NSAlertPanel with the contents of 'buf'
- // this is the native and nicest way to do this on OSX
+ /* this creates an NSAlertPanel with the contents of 'buf'
+ * this is the native and nicest way to do this on OSX */
ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" );
#else
- // all systems, but OSX
+ /* all systems, but OSX */
fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf);
#endif
}
@@ -151,10 +153,10 @@
}
-// multi os compatible sleep function
+/* multi os compatible sleep function */
#ifdef __AMIGA__
-// usleep() implementation
+/* usleep() implementation */
# include
# include
@@ -174,7 +176,7 @@
ULONG signals;
ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
- // send IORequest
+ /* send IORequest */
TimerRequest->tr_node.io_Command = TR_ADDREQUEST;
TimerRequest->tr_time.tv_secs = (milliseconds * 1000) / 1000000;
TimerRequest->tr_time.tv_micro = (milliseconds * 1000) % 1000000;
@@ -243,7 +245,7 @@
}
*outbuf = '\0';
- // FIX: invalid characters will abort conversion, but they shouldn't occur?
+ /* FIX: invalid characters will abort conversion, but they shouldn't occur? */
return buf;
}
diff -r 3b068c3a1c74 -r 0fa543611bbe src/unmovable.h
--- a/src/unmovable.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/unmovable.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file unmovable.h */
+
#ifndef UNMOVABLE_H
#define UNMOVABLE_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/unmovable_cmd.cpp
--- a/src/unmovable_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/unmovable_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,10 +1,13 @@
/* $Id$ */
+/** @file unmovable_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
#include "table/sprites.h"
#include "functions.h"
+#include "landscape.h"
#include "map.h"
#include "tile.h"
#include "command.h"
@@ -44,7 +47,7 @@
InvalidateWindow(WC_COMPANY, pid);
}
- // cost of relocating company is 1% of company value
+ /* cost of relocating company is 1% of company value */
return CalculateCompanyValue(p) / 100;
}
@@ -69,12 +72,14 @@
MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
}
+extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station);
+
/** Build or relocate the HQ. This depends if the HQ is already built or not
* @param tile tile where the HQ will be built or relocated to
+ * @param flags type of operation
* @param p1 unused
* @param p2 unused
*/
-extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station);
int32 CmdBuildCompanyHQ(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Player *p = GetPlayer(_current_player);
@@ -87,7 +92,7 @@
if (CmdFailed(ret)) return ret;
cost = ret;
- if (p->location_of_house != 0) { /* Moving HQ */
+ if (p->location_of_house != 0) { // Moving HQ
cost += DestroyCompanyHQ(_current_player, flags);
}
@@ -121,7 +126,7 @@
dtus = &_draw_tile_unmovable_data[GetUnmovableType(ti->tile)];
image = dtus->image;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -139,7 +144,7 @@
DrawGroundSprite(SPR_CONCRETE_GROUND, PAL_NONE);
image = SPR_STATUE_COMPANY;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -175,7 +180,7 @@
foreach_draw_tile_seq(dtss, t->seq) {
image = dtss->image;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_STRUCTURES)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -225,7 +230,7 @@
return DoCommand(tile, 0, 0, flags, CMD_SELL_LAND_AREA);
}
- // checks if you're allowed to remove unmovable things
+ /* checks if you're allowed to remove unmovable things */
if (_game_mode != GM_EDITOR && _current_player != OWNER_WATER && ((flags & DC_AUTO || !_cheats.magic_bulldozer.value)) )
return_cmd_error(STR_5800_OBJECT_IN_THE_WAY);
@@ -253,14 +258,14 @@
level = GetCompanyHQSize(tile) + 1;
- // Top town building generates 10, so to make HQ interesting, the top
- // type makes 20.
+ /* Top town building generates 10, so to make HQ interesting, the top
+ * type makes 20. */
ac[CT_PASSENGERS] = max(1U, level);
- // Top town building generates 4, HQ can make up to 8. The
- // proportion passengers:mail is different because such a huge
- // commercial building generates unusually high amount of mail
- // correspondence per physical visitor.
+ /* Top town building generates 4, HQ can make up to 8. The
+ * proportion passengers:mail is different because such a huge
+ * commercial building generates unusually high amount of mail
+ * correspondence per physical visitor. */
ac[CT_MAIL] = max(1U, level / 2);
}
@@ -296,16 +301,16 @@
assert(level < 6);
r = Random();
- // Top town buildings generate 250, so the top HQ type makes 256.
+ /* Top town buildings generate 250, so the top HQ type makes 256. */
if (GB(r, 0, 8) < (256 / 4 / (6 - level))) {
uint amt = GB(r, 0, 8) / 8 / 4 + 1;
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
MoveGoodsToStation(tile, 2, 2, CT_PASSENGERS, amt);
}
- // Top town building generates 90, HQ can make up to 196. The
- // proportion passengers:mail is about the same as in the acceptance
- // equations.
+ /* Top town building generates 90, HQ can make up to 196. The
+ * proportion passengers:mail is about the same as in the acceptance
+ * equations. */
if (GB(r, 8, 8) < (196 / 4 / (6 - level))) {
uint amt = GB(r, 8, 8) / 8 / 4 + 1;
if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/unmovable_map.h
--- a/src/unmovable_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/unmovable_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file unmovable_map.h */
+
#ifndef UNMOVABLE_MAP_H
#define UNMOVABLE_MAP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/variables.h
--- a/src/variables.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/variables.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,11 +1,13 @@
/* $Id$ */
+/** @file variables.h */
+
#ifndef VARIABLES_H
#define VARIABLES_H
#include "yapf/yapf_settings.h"
-// ********* START OF SAVE REGION
+/* ********* START OF SAVE REGION */
#if !defined(MAX_PATH)
# define MAX_PATH 260
#endif
@@ -34,47 +36,47 @@
/* These are the default options for a new game */
VARDEF GameOptions _opt_newgame;
-// Pointer to one of the two _opt OR _opt_newgame structs
+/* Pointer to one of the two _opt OR _opt_newgame structs */
VARDEF GameOptions *_opt_ptr;
-// Amount of game ticks
+/* Amount of game ticks */
VARDEF uint16 _tick_counter;
-// This one is not used anymore.
+/* This one is not used anymore. */
VARDEF VehicleID _vehicle_id_ctr_day;
-// Skip aging of cargo?
+/* Skip aging of cargo? */
VARDEF byte _age_cargo_skip_counter;
-// Position in tile loop
+/* Position in tile loop */
VARDEF TileIndex _cur_tileloop_tile;
-// Also save scrollpos_x, scrollpos_y and zoom
+/* Also save scrollpos_x, scrollpos_y and zoom */
VARDEF uint16 _disaster_delay;
-// Determines what station to operate on in the
-// tick handler.
+/* Determines what station to operate on in the
+ * tick handler. */
VARDEF uint16 _station_tick_ctr;
VARDEF uint32 _random_seeds[2][2];
-// Iterator through all towns in OnTick_Town
+/* Iterator through all towns in OnTick_Town */
VARDEF uint32 _cur_town_ctr;
-// Frequency iterator at the same place
+/* Frequency iterator at the same place */
VARDEF uint32 _cur_town_iter;
VARDEF uint _cur_player_tick_index;
VARDEF uint _next_competitor_start;
-// Determines how often to run the tree loop
+/* Determines how often to run the tree loop */
VARDEF byte _trees_tick_ctr;
-// Keep track of current game position
+/* Keep track of current game position */
VARDEF int _saved_scrollpos_x;
VARDEF int _saved_scrollpos_y;
VARDEF byte _saved_scrollpos_zoom;
-// ********* END OF SAVE REGION
+/* ********* END OF SAVE REGION */
struct Patches {
bool modified_catchment; // different-size catchment areas
@@ -197,28 +199,31 @@
*/
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_exit_penalty; /* The penalty for when the first signal is red (and it is an exit or combo signal) */
- uint32 npf_rail_lastred_penalty; /* The penalty for when the last signal is red */
- uint32 npf_rail_station_penalty; /* The penalty for station tiles */
- uint32 npf_rail_slope_penalty; /* The penalty for sloping upwards */
- uint32 npf_rail_curve_penalty; /* The penalty for curves */
- uint32 npf_rail_depot_reverse_penalty; /* The penalty for reversing in depots */
- uint32 npf_buoy_penalty; /* The penalty for going over (through) a buoy */
- uint32 npf_water_curve_penalty; /* The penalty for curves */
- uint32 npf_road_curve_penalty; /* The penalty for curves */
- uint32 npf_crossing_penalty; /* The penalty for level crossings */
- uint32 npf_road_drive_through_penalty; /* The penalty for going through a drive-through road stop */
+ 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_exit_penalty; // The penalty for when the first signal is red (and it is an exit or combo signal)
+ uint32 npf_rail_lastred_penalty; // The penalty for when the last signal is red
+ uint32 npf_rail_station_penalty; // The penalty for station tiles
+ uint32 npf_rail_slope_penalty; // The penalty for sloping upwards
+ uint32 npf_rail_curve_penalty; // The penalty for curves
+ uint32 npf_rail_depot_reverse_penalty; // The penalty for reversing in depots
+ uint32 npf_buoy_penalty; // The penalty for going over (through) a buoy
+ uint32 npf_water_curve_penalty; // The penalty for curves
+ uint32 npf_road_curve_penalty; // The penalty for curves
+ uint32 npf_crossing_penalty; // The penalty for level crossings
+ uint32 npf_road_drive_through_penalty; // The penalty for going through a drive-through road stop
bool population_in_label; // Show the population of a town in his label?
- uint8 freight_trains; ///< Value to multiply the weight of cargo by
+ uint8 freight_trains; // Value to multiply the weight of cargo by
/** YAPF settings */
YapfSettings yapf;
uint8 scrollwheel_scrolling;
uint8 scrollwheel_multiplier;
+
+ uint8 town_growth_rate; ///< Town growth rate
+ uint8 larger_towns; ///< 1 in the specified number of towns will grow twice as fast
};
VARDEF Patches _patches;
@@ -230,9 +235,9 @@
};
-// WARNING! Do _not_ remove entries in Cheats struct or change the order
-// of the existing ones! Would break downward compatibility.
-// Only add new entries at the end of the struct!
+/* WARNING! Do _not_ remove entries in Cheats struct or change the order
+ * of the existing ones! Would break downward compatibility.
+ * Only add new entries at the end of the struct! */
struct Cheats {
Cheat magic_bulldozer; // dynamite industries, unmovables
@@ -264,7 +269,7 @@
VARDEF Paths _paths;
-// NOSAVE: Used in palette animations only, not really important.
+/* NOSAVE: Used in palette animations only, not really important. */
VARDEF int _timer_counter;
@@ -276,6 +281,7 @@
VARDEF int _autosave_ctr;
VARDEF byte _display_opt;
+VARDEF byte _transparent_opt;
VARDEF int _caret_timer;
VARDEF uint32 _news_display_opt;
VARDEF bool _news_ticker_sound;
@@ -287,20 +293,20 @@
VARDEF bool _rightclick_emulate;
-// IN/OUT parameters to commands
+/* IN/OUT parameters to commands */
VARDEF byte _yearly_expenses_type;
VARDEF TileIndex _terraform_err_tile;
VARDEF TileIndex _build_tunnel_endtile;
VARDEF bool _generating_world;
-// Deals with the type of the savegame, independent of extension
+/* Deals with the type of the savegame, independent of extension */
struct SmallFiosItem {
int mode; // savegame/scenario type (old, new)
char name[MAX_PATH]; // name
char title[255]; // internal name of the game
};
-// Used when switching from the intro menu.
+/* Used when switching from the intro menu. */
VARDEF byte _switch_mode;
VARDEF StringID _switch_mode_errorstr;
VARDEF SmallFiosItem _file_to_saveload;
@@ -368,14 +374,14 @@
return _decode_parameters[n];
}
-// Used to bind a C string name to a dparam number.
-// NOTE: This has a short lifetime. You can't
-// use this string much later or it will be gone.
+/* Used to bind a C string name to a dparam number.
+ * NOTE: This has a short lifetime. You can't
+ * use this string much later or it will be gone. */
void SetDParamStr(uint n, const char *str);
-// This function takes a C-string and allocates a temporary string ID.
-// The duration of the bound string is valid only until the next acll to GetString,
-// so be careful.
+/** This function takes a C-string and allocates a temporary string ID.
+ * The duration of the bound string is valid only until the next acll to GetString,
+ * so be careful. */
StringID BindCString(const char *str);
@@ -385,7 +391,7 @@
#define SET_EXPENSES_TYPE(x) _yearly_expenses_type = x;
-/* landscape.c */
+/* landscape.cpp */
extern const byte _tileh_to_sprite[32];
extern const Slope _inclined_tileh[16];
diff -r 3b068c3a1c74 -r 0fa543611bbe src/vehicle.cpp
--- a/src/vehicle.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/vehicle.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file vehicle.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "road_map.h"
@@ -9,6 +11,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
+#include "landscape.h"
#include "map.h"
#include "tile.h"
#include "vehicle.h"
@@ -104,7 +107,7 @@
bool VehicleNeedsService(const Vehicle *v)
{
if (v->vehstatus & VS_CRASHED)
- return false; /* Crashed vehicles don't need service anymore */
+ return false; // Crashed vehicles don't need service anymore
if (_patches.no_servicing_if_no_breakdowns && _opt.diff.vehicle_breakdowns == 0) {
return EngineHasReplacementForPlayer(GetPlayer(v->owner), v->engine_type); /* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off */
@@ -215,7 +218,7 @@
v->bottom_coord = pt.y + spr->height + 2;
}
-// Called after load to update coordinates
+/** Called after load to update coordinates */
void AfterLoadVehicles()
{
Vehicle *v;
@@ -311,7 +314,7 @@
return NULL;
}
-/*
+/**
* finds a free vehicle in the memory or allocates a new one
* returns a pointer to the first free vehicle or NULL if all vehicles are in use
* *skip_vehicles is an offset to where in the array we should begin looking
@@ -327,7 +330,7 @@
const int offset = (1 << Vehicle_POOL_BLOCK_SIZE_BITS) * BLOCKS_FOR_SPECIAL_VEHICLES;
/* We don't use FOR_ALL here, because FOR_ALL skips invalid items.
- * TODO - This is just a temporary stage, this will be removed. */
+ * @todo - This is just a temporary stage, this will be removed. */
if (*skip_vehicles < (_Vehicle_pool.total_items - offset)) { // make sure the offset in the array is not larger than the array itself
for (v = GetVehicle(offset + *skip_vehicles); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) {
(*skip_vehicles)++;
@@ -381,7 +384,7 @@
{
Point pt = RemapCoords(TileX(tile) * TILE_SIZE, TileY(tile) * TILE_SIZE, 0);
- // The hash area to scan
+ /* The hash area to scan */
const int xl = GB(pt.x - 174, 7, 6);
const int xu = GB(pt.x + 104, 7, 6);
const int yl = GB(pt.y - 294, 6, 6) << 6;
@@ -498,7 +501,7 @@
u = GetFirstVehicleInChain(v);
- // Check to see if this is the first
+ /* Check to see if this is the first */
if (v == u) return NULL;
for (; u->next != v; u = u->next) assert(u->next != NULL);
@@ -606,7 +609,7 @@
static void EffectVehicle_Tick(Vehicle *v);
void DisasterVehicle_Tick(Vehicle *v);
-// head of the linked list to tell what vehicles that visited a depot in a tick
+/** head of the linked list to tell what vehicles that visited a depot in a tick */
static Vehicle* _first_veh_in_depot_list;
/** Adds a vehicle to the list of vehicles, that visited a depot this tick
@@ -614,14 +617,14 @@
*/
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 */
if (HASBIT(v->current_order.flags, OFB_HALT_IN_DEPOT) && !HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS) && v->current_order.type == OT_GOTO_DEPOT) {
- // we keep the vehicle in the depot since the user ordered it to stay
+ /* we keep the vehicle in the depot since the user ordered it to stay */
v->leave_depot_instantly = false;
} else {
- // the vehicle do not plan on stopping in the depot, so we stop it to ensure that it will not reserve the path
- // out of the depot before we might autoreplace it to a different engine. The new engine would not own the reserved path
- // we store that we stopped the vehicle, so autoreplace can start it again
+ /* the vehicle do not plan on stopping in the depot, so we stop it to ensure that it will not reserve the path
+ * out of the depot before we might autoreplace it to a different engine. The new engine would not own the reserved path
+ * we store that we stopped the vehicle, so autoreplace can start it again */
v->vehstatus |= VS_STOPPED;
v->leave_depot_instantly = true;
}
@@ -650,8 +653,8 @@
Vehicle *v;
#ifdef ENABLE_NETWORK
- // hotfix for desync problem:
- // for MP games invalidate the YAPF cache every tick to keep it exactly the same on the server and all clients
+ /* hotfix for desync problem:
+ * for MP games invalidate the YAPF cache every tick to keep it exactly the same on the server and all clients */
if (_networking) {
YapfNotifyTrackLayoutChange(INVALID_TILE, INVALID_TRACK);
}
@@ -679,7 +682,7 @@
}
}
- // now we handle all the vehicles that entered a depot this tick
+ /* now we handle all the vehicles that entered a depot this tick */
v = _first_veh_in_depot_list;
while (v != NULL) {
Vehicle *w = v->depot_list;
@@ -695,19 +698,19 @@
bool keep_loading = false;
const GoodsEntry *ge = GetStation(v->last_station_visited)->goods;
- //special handling of aircraft
-
- //if the aircraft carries passengers and is NOT full, then
- //continue loading, no matter how much mail is in
+ /* special handling of aircraft */
+
+ /* if the aircraft carries passengers and is NOT full, then
+ *continue loading, no matter how much mail is in */
if (v->type == VEH_AIRCRAFT &&
IsCargoInClass(v->cargo_type, CC_PASSENGERS) &&
v->cargo_cap != v->cargo_count) {
return true;
}
- // patch should return "true" to continue loading, i.e. when there is no cargo type that is fully loaded.
+ /* patch should return "true" to continue loading, i.e. when there is no cargo type that is fully loaded. */
do {
- //Should never happen, but just in case future additions change this
+ /* Should never happen, but just in case future additions change this */
assert(v->cargo_type<32);
if (v->cargo_cap != 0) {
@@ -726,7 +729,7 @@
}
} while ((v = v->next) != NULL);
- // continue loading if there is a non full cargo type and no cargo type that is full
+ /* continue loading if there is a non full cargo type and no cargo type that is full */
return keep_loading || (not_full && (full & ~not_full) == 0);
}
@@ -743,7 +746,7 @@
IsTileType(TILE_ADDXY(tile, -2, 0), MP_STATION)
))) {
- // If patch is active, use alternative CanFillVehicle-function
+ /* If patch is active, use alternative CanFillVehicle-function */
if (_patches.full_load_any && v->current_order.flags & OF_FULL_LOAD) return CanFillVehicle_FullLoadAny(v);
do {
@@ -821,13 +824,13 @@
void ViewportAddVehicles(DrawPixelInfo *dpi)
{
- // The bounding rectangle
+ /* The bounding rectangle */
const int l = dpi->left;
const int r = dpi->left + dpi->width;
const int t = dpi->top;
const int b = dpi->top + dpi->height;
- // The hash area to scan
+ /* The hash area to scan */
const int xl = GB(l - 70, 7, 6);
const int xu = GB(r, 7, 6);
const int yl = GB(t - 70, 6, 6) << 6;
@@ -1567,7 +1570,7 @@
{
if (v->owner != _local_player) return;
- // Do not show getting-old message if autorenew is active
+ /* Do not show getting-old message if autorenew is active */
if (GetPlayer(v->owner)->engine_renew) return;
SetDParam(0, _vehicle_type_names[v->type]);
@@ -1599,6 +1602,7 @@
/** Starts or stops a lot of vehicles
* @param tile Tile of the depot where the vehicles are started/stopped (only used for depots)
+ * @param flags type of operation
* @param p1 Station/Order/Depot ID (only used for vehicle list windows)
* @param p2 bitmask
* - bit 0-4 Vehicle type
@@ -1665,10 +1669,11 @@
}
/** Sells all vehicles in a depot
-* @param tile Tile of the depot where the depot is
-* @param p1 Vehicle type
-* @param p2 unused
-*/
+ * @param tile Tile of the depot where the depot is
+ * @param flags type of operation
+ * @param p1 Vehicle type
+ * @param p2 unused
+ */
int32 CmdDepotSellAllVehicles(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle **engines = NULL;
@@ -1717,10 +1722,11 @@
}
/** Autoreplace all vehicles in the depot
-* @param tile Tile of the depot where the vehicles are
-* @param p1 Type of vehicle
-* @param p2 Unused
-*/
+ * @param tile Tile of the depot where the vehicles are
+ * @param flags type of operation
+ * @param p1 Type of vehicle
+ * @param p2 Unused
+ */
int32 CmdDepotMassAutoReplace(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
Vehicle **vl = NULL;
@@ -1784,6 +1790,7 @@
/** 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 flags type of operation
* @param p1 the original vehicle's index
* @param p2 1 = shared orders, else copied orders
*/
@@ -1814,7 +1821,7 @@
if (v->type == VEH_TRAIN && (!IsFrontEngine(v) || v->u.rail.crash_anim_pos >= 4400)) return CMD_ERROR;
- // check that we can allocate enough vehicles
+ /* check that we can allocate enough vehicles */
if (!(flags & DC_EXEC)) {
int veh_counter = 0;
do {
@@ -1862,11 +1869,11 @@
}
if (v->type == VEH_TRAIN && !IsFrontEngine(v)) {
- // this s a train car
- // add this unit to the end of the train
+ /* this s a train car
+ * add this unit to the end of the train */
DoCommand(0, (w_rear->index << 16) | w->index, 1, flags, CMD_MOVE_RAIL_VEHICLE);
} else {
- // this is a front engine or not a train. It need orders
+ /* this is a front engine or not a train. It need orders */
w_front = w;
w->service_interval = v->service_interval;
DoCommand(0, (v->index << 16) | w->index, p2 & 1 ? CO_SHARE : CO_COPY, flags, CMD_CLONE_ORDER);
@@ -1876,7 +1883,7 @@
} while (v->type == VEH_TRAIN && (v = GetNextVehicle(v)) != NULL);
if (flags & DC_EXEC && v_front->type == VEH_TRAIN) {
- // for trains this needs to be the front engine due to the callback function
+ /* for trains this needs to be the front engine due to the callback function */
_new_vehicle_id = w_front->index;
}
@@ -2220,6 +2227,7 @@
/** Give a custom name to your vehicle
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID to name
* @param p2 unused
*/
@@ -2253,6 +2261,7 @@
/** Change the service interval of a vehicle
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID that is being service-interval-changed
* @param p2 new service interval
*/
@@ -2349,27 +2358,27 @@
switch (v->type) {
case VEH_TRAIN:
- if (v->u.rail.track == TRACK_BIT_DEPOT) /* We'll assume the train is facing outwards */
- return DiagdirToDiagTrackdir(GetRailDepotDirection(v->tile)); /* Train in depot */
-
- if (v->u.rail.track == TRACK_BIT_WORMHOLE) /* train in tunnel, so just use his direction and assume a diagonal track */
+ if (v->u.rail.track == TRACK_BIT_DEPOT) // We'll assume the train is facing outwards
+ return DiagdirToDiagTrackdir(GetRailDepotDirection(v->tile)); // Train in depot
+
+ if (v->u.rail.track == TRACK_BIT_WORMHOLE) // train in tunnel, so just use his direction and assume a diagonal track
return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
return TrackDirectionToTrackdir(FindFirstTrack(v->u.rail.track), v->direction);
case VEH_SHIP:
if (IsShipInDepot(v))
- /* We'll assume the ship is facing outwards */
+ // We'll assume the ship is facing outwards
return DiagdirToDiagTrackdir(GetShipDepotDirection(v->tile));
return TrackDirectionToTrackdir(FindFirstTrack(v->u.ship.state), v->direction);
case VEH_ROAD:
- if (IsRoadVehInDepot(v)) /* We'll assume the road vehicle is facing outwards */
+ if (IsRoadVehInDepot(v)) // We'll assume the road vehicle is facing outwards
return DiagdirToDiagTrackdir(GetRoadDepotDirection(v->tile));
- if (IsStandardRoadStopTile(v->tile)) /* We'll assume the road vehicle is facing outwards */
- return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); /* Road vehicle in a station */
+ if (IsStandardRoadStopTile(v->tile)) // We'll assume the road vehicle is facing outwards
+ return DiagdirToDiagTrackdir(GetRoadStopDir(v->tile)); // Road vehicle in a station
if (IsDriveThroughStopTile(v->tile)) return DiagdirToDiagTrackdir(DirToDiagDir(v->direction));
@@ -2422,16 +2431,16 @@
cache = MallocT(max + 1);
}
- // Clear the cache
+ /* Clear the cache */
memset(cache, 0, (max + 1) * sizeof(*cache));
- // Fill the cache
+ /* Fill the cache */
FOR_ALL_VEHICLES(u) {
if (u->type == type && u->owner == _current_player && u->unitnumber != 0 && u->unitnumber <= max)
cache[u->unitnumber] = true;
}
- // Find the first unused unit number
+ /* Find the first unused unit number */
for (unit = 1; unit <= max; unit++) {
if (!cache[unit]) break;
}
@@ -2562,7 +2571,7 @@
return GetEngineColourMap(v->engine_type, v->owner, INVALID_ENGINE, v);
}
-// Save and load of vehicles
+/** Save and load of vehicles */
extern const SaveLoad _common_veh_desc[] = {
SLE_VAR(Vehicle, subtype, SLE_UINT8),
@@ -2667,7 +2676,7 @@
SLE_REF(Vehicle, next_shared, REF_VEHICLE),
SLE_REF(Vehicle, prev_shared, REF_VEHICLE),
- // reserve extra space in savegame here. (currently 10 bytes)
+ /* reserve extra space in savegame here. (currently 10 bytes) */
SLE_CONDNULL(10, 2, SL_MAX_VERSION),
SLE_END()
@@ -2686,7 +2695,7 @@
SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRail, days_since_order_progr), SLE_UINT16, 2, SL_MAX_VERSION),
SLE_CONDNULL(2, 2, 19),
- // reserve extra space in savegame here. (currently 11 bytes)
+ /* reserve extra space in savegame here. (currently 11 bytes) */
SLE_CONDNULL(11, 2, SL_MAX_VERSION),
SLE_END()
@@ -2706,7 +2715,7 @@
SLE_CONDREFX(offsetof(Vehicle, u) + offsetof(VehicleRoad, slot), REF_ROADSTOPS, 6, SL_MAX_VERSION),
SLE_CONDNULL(1, 6, SL_MAX_VERSION),
SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, slot_age), SLE_UINT8, 6, SL_MAX_VERSION),
- // reserve extra space in savegame here. (currently 16 bytes)
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2717,7 +2726,7 @@
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleShip, state), SLE_UINT8),
- // reserve extra space in savegame here. (currently 16 bytes)
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2736,7 +2745,7 @@
SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, previous_pos), SLE_UINT8, 2, SL_MAX_VERSION),
- // reserve extra space in savegame here. (currently 15 bytes)
+ /* reserve extra space in savegame here. (currently 15 bytes) */
SLE_CONDNULL(15, 2, SL_MAX_VERSION),
SLE_END()
@@ -2768,7 +2777,7 @@
SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleSpecial, unk0), SLE_UINT16),
SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleSpecial, unk2), SLE_UINT8),
- // reserve extra space in savegame here. (currently 16 bytes)
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2810,7 +2819,7 @@
SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleDisaster, image_override), SLE_UINT16),
SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleDisaster, unk2), SLE_UINT16),
- // reserve extra space in savegame here. (currently 16 bytes)
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2826,18 +2835,18 @@
_disaster_desc,
};
-// Will be called when the vehicles need to be saved.
+/** Will be called when the vehicles need to be saved. */
static void Save_VEHS()
{
Vehicle *v;
- // Write the vehicles
+ /* Write the vehicles */
FOR_ALL_VEHICLES(v) {
SlSetArrayIndex(v->index);
SlObject(v, (SaveLoad*)_veh_descs[v->type]);
}
}
-// Will be called when vehicles need to be loaded.
+/** Will be called when vehicles need to be loaded. */
static void Load_VEHS()
{
int index;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/vehicle.h
--- a/src/vehicle.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/vehicle.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @vehicle.h */
+
#ifndef VEHICLE_H
#define VEHICLE_H
@@ -108,13 +110,13 @@
uint16 crash_anim_pos;
uint16 days_since_order_progr;
- // cached values, recalculated on load and each time a vehicle is added to/removed from the consist.
+ /* cached values, recalculated on load and each time a vehicle is added to/removed from the consist. */
uint16 cached_max_speed; // max speed of the consist. (minimum of the max speed of all vehicles in the consist)
uint32 cached_power; // total power of the consist.
uint8 cached_veh_length; // length of this vehicle in units of 1/8 of normal length, cached because this can be set by a callback
uint16 cached_total_length; ///< Length of the whole train, valid only for first engine.
- // cached values, recalculated when the cargo on a train changes (in addition to the conditions above)
+ /* cached values, recalculated when the cargo on a train changes (in addition to the conditions above) */
uint32 cached_weight; // total weight of the consist.
uint32 cached_veh_weight; // weight of the vehicle.
uint32 cached_max_te; // max tractive effort of consist
@@ -127,8 +129,8 @@
*/
byte cached_vis_effect;
- // NOSAVE: for wagon override - id of the first engine in train
- // 0xffff == not in train
+ /* NOSAVE: for wagon override - id of the first engine in train
+ * 0xffff == not in train */
EngineID first_engine;
TrackBitsByte track;
@@ -138,27 +140,27 @@
byte flags;
- // Link between the two ends of a multiheaded engine
+ /* Link between the two ends of a multiheaded engine */
Vehicle *other_multiheaded_part;
};
enum {
VRF_REVERSING = 0,
- // used to calculate if train is going up or down
+ /* used to calculate if train is going up or down */
VRF_GOINGUP = 1,
VRF_GOINGDOWN = 2,
- // used to store if a wagon is powered or not
+ /* used to store if a wagon is powered or not */
VRF_POWEREDWAGON = 3,
- // used to reverse the visible direction of the vehicle
+ /* used to reverse the visible direction of the vehicle */
VRF_REVERSE_DIRECTION = 4,
- // used to mark train as lost because PF can't find the route
+ /* used to mark train as lost because PF can't find the route */
VRF_NO_PATH_TO_DESTINATION = 5,
- // used to mark that electric train engine is allowed to run on normal rail
+ /* used to mark that electric train engine is allowed to run on normal rail */
VRF_EL_ENGINE_ALLOWED_NORMAL_RAIL = 6,
};
@@ -171,7 +173,7 @@
};
struct VehicleRoad {
- byte state; /// @see RoadVehicleStates
+ byte state; ///< @see RoadVehicleStates
byte frame;
uint16 blocked_ctr;
byte overtaking;
@@ -210,7 +212,7 @@
StringID string_id; // Displayed string
UnitID unitnumber; // unit number, for display purposes only
- PlayerByte owner; // which player owns the vehicle?
+ PlayerByte owner; // which player owns the vehicle?
TileIndex tile; // Current tile index
TileIndex dest_tile; // Heading for this tile
@@ -231,9 +233,9 @@
int8 y_offs; // y offset for vehicle sprite
EngineID engine_type;
- // for randomized variational spritegroups
- // bitmask used to resolve them; parts of it get reseeded when triggers
- // of corresponding spritegroups get matched
+ /* for randomized variational spritegroups
+ * bitmask used to resolve them; parts of it get reseeded when triggers
+ * of corresponding spritegroups get matched */
byte random_bits;
byte waiting_triggers; // triggers to be yet matched
@@ -269,15 +271,15 @@
Vehicle *prev_shared; ///< If not NULL, this points to the prev vehicle that shared the order
/* End Order-stuff */
- // Boundaries for the current position in the world and a next hash link.
- // NOSAVE: All of those can be updated with VehiclePositionChanged()
+ /* Boundaries for the current position in the world and a next hash link.
+ * NOSAVE: All of those can be updated with VehiclePositionChanged() */
int32 left_coord;
int32 top_coord;
int32 right_coord;
int32 bottom_coord;
Vehicle *next_hash;
- // Related to age and service time
+ /* Related to age and service time */
Date age; // Age in days
Date max_age; // Maximum age
Date date_of_last_service;
@@ -492,7 +494,7 @@
/**
* Check if an index is a vehicle-index (so between 0 and max-vehicles)
- *
+ * @param index of the vehicle to query
* @return Returns true if the vehicle-id is in range
*/
static inline bool IsValidVehicleID(uint index)
@@ -513,7 +515,11 @@
return order;
}
-/* Returns the last order of a vehicle, or NULL if it doesn't exists */
+/**
+ * Returns the last order of a vehicle, or NULL if it doesn't exists
+ * @param v Vehicle to query
+ * @return last order of a vehicle, if available
+ */
static inline Order *GetLastVehicleOrder(const Vehicle *v)
{
Order *order = v->orders;
@@ -526,7 +532,10 @@
return order;
}
-/* Get the first vehicle of a shared-list, so we only have to walk forwards */
+/** Get the first vehicle of a shared-list, so we only have to walk forwards
+ * @param v Vehicle to query
+ * @return first vehicle of a shared-list
+ */
static inline Vehicle *GetFirstVehicleFromSharedList(const Vehicle *v)
{
Vehicle *u = (Vehicle *)v;
@@ -535,7 +544,7 @@
return u;
}
-// NOSAVE: Return values from various commands.
+/* NOSAVE: Return values from various commands. */
VARDEF VehicleID _new_vehicle_id;
VARDEF uint16 _returned_refit_capacity;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/vehicle_gui.cpp
--- a/src/vehicle_gui.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/vehicle_gui.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file vehicle_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -162,12 +164,12 @@
qsort((void*)v, length, sizeof(v[0]), _vehicle_sorter[0]);
}
-// draw the vehicle profit button in the vehicle list window.
+/** draw the vehicle profit button in the vehicle list window. */
void DrawVehicleProfitButton(const Vehicle *v, int x, int y)
{
SpriteID pal;
- // draw profit-based colored icons
+ /* draw profit-based colored icons */
if (v->age <= 365 * 2) {
pal = PALETTE_TO_GREY;
} else if (v->profit_last_year < 0) {
@@ -421,6 +423,7 @@
/** Show the refit window for a vehicle
* @param *v The vehicle to show the refit window for
+* @param order of the vehicle (?)
*/
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
{
@@ -466,18 +469,18 @@
}
}
-/* Display additional text from NewGRF in the purchase information window */
+/** Display additional text from NewGRF in the purchase information window */
uint ShowAdditionalText(int x, int y, uint w, EngineID engine)
{
uint16 callback = GetVehicleCallback(CBID_VEHICLE_ADDITIONAL_TEXT, 0, 0, engine, NULL);
if (callback == CALLBACK_FAILED) return 0;
- // STR_02BD is used to start the string with {BLACK}
+ /* STR_02BD is used to start the string with {BLACK} */
SetDParam(0, GetGRFStringID(GetEngineGRFID(engine), 0xD000 + callback));
return DrawStringMultiLine(x, y, STR_02BD, w);
}
-/* Count the number of bits that are set in a mask */
+/** Count the number of bits that are set in a mask */
static uint CountBits(uint32 mask)
{
uint c = 0;
@@ -485,7 +488,7 @@
return c;
}
-/* Display list of cargo types of the engine, for the purchase information window */
+/** Display list of cargo types of the engine, for the purchase information window */
uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine)
{
/* List of cargo types of this engine */
@@ -529,7 +532,7 @@
}
-// if the sorting criteria had the same value, sort vehicle by unitnumber
+/* if the sorting criteria had the same value, sort vehicle by unitnumber */
#define VEHICLEUNITNUMBERSORTER(r, a, b) {if (r == 0) {r = a->unitnumber - b->unitnumber;}}
static int CDECL VehicleNumberSorter(const void *a, const void *b)
@@ -1140,7 +1143,7 @@
switch (e->we.dropdown.button) {
case VLW_WIDGET_SORT_BY_PULLDOWN:
if (vl->l.sort_type != e->we.dropdown.index) {
- // value has changed -> resort
+ /* value has changed -> resort */
vl->l.flags |= VL_RESORT;
vl->l.sort_type = e->we.dropdown.index;
vl->_sorting->criteria = vl->l.sort_type;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/vehicle_gui.h
--- a/src/vehicle_gui.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/vehicle_gui.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file vehicle_gui.h */
+
#ifndef VEHICLE_GUI_H
#define VEHICLE_GUI_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/viewport.cpp
--- a/src/viewport.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/viewport.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -11,6 +11,7 @@
#include "strings.h"
#include "table/sprites.h"
#include "table/strings.h"
+#include "landscape.h"
#include "map.h"
#include "viewport.h"
#include "window.h"
@@ -25,7 +26,7 @@
#define VIEWPORT_DRAW_MEM (65536 * 2)
-// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
+/* XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar) */
static ViewPort _viewports[25 - 2];
static uint32 _active_viewports; ///< bitmasked variable where each bit signifies if a viewport is in use or not
assert_compile(lengthof(_viewports) < sizeof(_active_viewports) * 8);
@@ -91,8 +92,8 @@
byte zmax;
};
-// Quick hack to know how much memory to reserve when allocating from the spritelist
-// to prevent a buffer overflow.
+/* Quick hack to know how much memory to reserve when allocating from the spritelist
+ * to prevent a buffer overflow. */
#define LARGEST_SPRITELIST_STRUCT ParentSpriteToDraw
struct ViewportDrawer {
@@ -397,7 +398,7 @@
/** Update the status of the zoom-buttons according to the zoom-level
* of the viewport. This will update their status and invalidate accordingly
- * @param window pointer to the window that has the zoom buttons
+ * @param w Window pointer to the window that has the zoom buttons
* @param vp pointer to the viewport whose zoom-level the buttons represent
* @param widget_zoom_in widget index for window with zoom-in button
* @param widget_zoom_out widget index for window with zoom-out button */
@@ -438,7 +439,7 @@
void DrawGroundSprite(SpriteID image, SpriteID pal)
{
if (_offset_ground_sprites) {
- // offset ground sprite because of foundation?
+ /* offset ground sprite because of foundation? */
AddChildSpriteScreen(image, pal, _cur_vd->offs_x, _cur_vd->offs_y);
} else {
_added_tile_sprite = true;
@@ -493,12 +494,12 @@
ps = (ParentSpriteToDraw*)vd->spritelist_mem;
if (vd->parent_list >= vd->eof_parent_list) {
- // This can happen rarely, mostly when you zoom out completely
- // and have a lot of stuff that moves (and is added to the
- // sort-list, this function). To solve it, increase
- // parent_list somewhere below to a higher number.
- // This can not really hurt you, it just gives some black
- // spots on the screen ;)
+ /* This can happen rarely, mostly when you zoom out completely
+ * and have a lot of stuff that moves (and is added to the
+ * sort-list, this function). To solve it, increase
+ * parent_list somewhere below to a higher number.
+ * This can not really hurt you, it just gives some black
+ * spots on the screen ;) */
DEBUG(sprite, 0, "Out of sprite memory (parent_list)");
return;
}
@@ -646,23 +647,23 @@
SpriteID image;
SpriteID pal;
- // Draw a red error square?
+ /* Draw a red error square? */
if (_thd.redsq != 0 && _thd.redsq == ti->tile) {
DrawSelectionSprite(SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh], PALETTE_TILE_RED_PULSATING, ti);
return;
}
- // no selection active?
+ /* no selection active? */
if (_thd.drawstyle == 0) return;
- // Inside the inner area?
+ /* Inside the inner area? */
if (IS_INSIDE_1D(ti->x, _thd.pos.x, _thd.size.x) &&
IS_INSIDE_1D(ti->y, _thd.pos.y, _thd.size.y)) {
if (_thd.drawstyle & HT_RECT) {
image = SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh];
DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : PAL_NONE, ti);
} else if (_thd.drawstyle & HT_POINT) {
- // Figure out the Z coordinate for the single dot.
+ /* Figure out the Z coordinate for the single dot. */
byte z = ti->z;
if (ti->tileh & SLOPE_N) {
z += TILE_HEIGHT;
@@ -670,7 +671,7 @@
}
DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
} else if (_thd.drawstyle & HT_RAIL /*&& _thd.place_mode == VHM_RAIL*/) {
- // autorail highlight piece under cursor
+ /* autorail highlight piece under cursor */
uint type = _thd.drawstyle & 0xF;
int offset;
@@ -688,7 +689,7 @@
DrawSelectionSprite(image, _thd.make_square_red ? PALETTE_SEL_TILE_RED : pal, ti);
} else if (IsPartOfAutoLine(ti->x, ti->y)) {
- // autorail highlighting long line
+ /* autorail highlighting long line */
int dir = _thd.drawstyle & ~0xF0;
int offset;
uint side;
@@ -714,12 +715,12 @@
return;
}
- // Check if it's inside the outer area?
+ /* Check if it's inside the outer area? */
if (_thd.outersize.x &&
_thd.size.x < _thd.size.x + _thd.outersize.x &&
IS_INSIDE_1D(ti->x, _thd.pos.x + _thd.offs.x, _thd.size.x + _thd.outersize.x) &&
IS_INSIDE_1D(ti->y, _thd.pos.y + _thd.offs.y, _thd.size.y + _thd.outersize.y)) {
- // Draw a blue rect.
+ /* Draw a blue rect. */
DrawSelectionSprite(SPR_SELECT_TILE + _tileh_to_sprite[ti->tileh], PALETTE_SEL_TILE_BLUE, ti);
return;
}
@@ -734,11 +735,11 @@
_cur_ti = &ti;
- // Transform into tile coordinates and round to closest full tile
+ /* Transform into tile coordinates and round to closest full tile */
x = ((vd->dpi.top >> 1) - (vd->dpi.left >> 2)) & ~0xF;
y = ((vd->dpi.top >> 1) + (vd->dpi.left >> 2) - 0x10) & ~0xF;
- // determine size of area
+ /* determine size of area */
{
Point pt = RemapCoords(x, y, 241);
width = (vd->dpi.left + vd->dpi.width - pt.x + 95) >> 6;
@@ -1128,7 +1129,7 @@
}
}
- // Swap the two sprites ps and ps2 using bubble-sort algorithm.
+ /* Swap the two sprites ps and ps2 using bubble-sort algorithm. */
psd3 = psd;
do {
ParentSpriteToDraw* temp = *psd3;
@@ -1193,21 +1194,19 @@
/* Draw the rectangle if 'tranparent station signs' is off,
* or if we are drawing a general text sign (STR_2806) */
- if (!(_display_opt & DO_TRANS_SIGNS) || ss->string == STR_2806)
+ if (!HASBIT(_transparent_opt, TO_SIGNS) || ss->string == STR_2806) {
DrawFrameRect(
x, y, x + w, bottom, ss->color,
- (_display_opt & DO_TRANS_BUILDINGS) ? FR_TRANSPARENT : FR_NONE
+ HASBIT(_transparent_opt, TO_SIGNS) ? FR_TRANSPARENT : FR_NONE
);
+ }
}
SetDParam(0, ss->params[0]);
SetDParam(1, ss->params[1]);
/* if we didn't draw a rectangle, or if transparant building is on,
* draw the text in the color the rectangle would have */
- if ((
- (_display_opt & DO_TRANS_BUILDINGS) ||
- (_display_opt & DO_TRANS_SIGNS && ss->string != STR_2806)
- ) && ss->width != 0) {
+ if (HASBIT(_transparent_opt, TO_SIGNS) && ss->string != STR_2806 && ss->width != 0) {
/* Real colors need the IS_PALETTE_COLOR flag
* otherwise colors from _string_colormap are assumed. */
colour = _colour_gradient[ss->color][6] | IS_PALETTE_COLOR;
@@ -1273,8 +1272,8 @@
ViewportAddSigns(&vd.dpi);
ViewportAddWaypoints(&vd.dpi);
- // This assert should never happen (because the length of the parent_list
- // is checked)
+ /* This assert should never happen (because the length of the parent_list
+ * is checked) */
assert(vd.parent_list <= endof(parent_list));
if (vd.first_tile != NULL) ViewportDrawTileSprites(vd.first_tile);
@@ -1290,8 +1289,8 @@
_cur_dpi = old_dpi;
}
-// Make sure we don't draw a too big area at a time.
-// If we do, the sprite memory will overflow.
+/** Make sure we don't draw a too big area at a time.
+ * If we do, the sprite memory will overflow. */
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom)
{
if (((bottom - top) * (right - left) << (2 * vp->zoom)) > 180000) {
@@ -1359,20 +1358,20 @@
int vx;
int vy;
- // Center of the viewport is hot spot
+ /* Center of the viewport is hot spot */
x = WP(w,vp_d).scrollpos_x + vp->virtual_width / 2;
y = WP(w,vp_d).scrollpos_y + vp->virtual_height / 2;
- // Convert viewport coordinates to map coordinates
- // Calculation is scaled by 4 to avoid rounding errors
+ /* Convert viewport coordinates to map coordinates
+ * Calculation is scaled by 4 to avoid rounding errors */
vx = -x + y * 2;
vy = x + y * 2;
- // clamp to size of map
+ /* clamp to size of map */
vx = clamp(vx, 0 * 4, MapMaxX() * TILE_SIZE * 4);
vy = clamp(vy, 0 * 4, MapMaxY() * TILE_SIZE * 4);
- // Convert map coordinates to viewport coordinates
+ /* Convert map coordinates to viewport coordinates */
x = (-vx + vy) / 2;
y = ( vx + vy) / 4;
- // Set position
+ /* Set position */
WP(w, vp_d).scrollpos_x = x - vp->virtual_width / 2;
WP(w, vp_d).scrollpos_y = y - vp->virtual_height / 2;
@@ -1859,13 +1858,13 @@
_thd.new_outersize.y = sy * TILE_SIZE;
}
-/* returns the best autorail highlight type from map coordinates */
+/** returns the best autorail highlight type from map coordinates */
static byte GetAutorailHT(int x, int y)
{
return HT_RAIL | _AutorailPiece[x & 0xF][y & 0xF];
}
-// called regular to update tile highlighting in all cases
+/** called regular to update tile highlighting in all cases */
void UpdateTileSelection()
{
int x1;
@@ -1912,13 +1911,13 @@
}
}
- // redraw selection
+ /* redraw selection */
if (_thd.drawstyle != _thd.new_drawstyle ||
_thd.pos.x != _thd.new_pos.x || _thd.pos.y != _thd.new_pos.y ||
_thd.size.x != _thd.new_size.x || _thd.size.y != _thd.new_size.y ||
_thd.outersize.x != _thd.new_outersize.x ||
_thd.outersize.y != _thd.new_outersize.y) {
- // clear the old selection?
+ /* clear the old selection? */
if (_thd.drawstyle) SetSelectionTilesDirty();
_thd.drawstyle = _thd.new_drawstyle;
@@ -1927,12 +1926,12 @@
_thd.outersize = _thd.new_outersize;
_thd.dirty = 0xff;
- // draw the new selection?
+ /* draw the new selection? */
if (_thd.new_drawstyle) SetSelectionTilesDirty();
}
}
-// highlighting tiles while only going over them with the mouse
+/** highlighting tiles while only going over them with the mouse */
void VpStartPlaceSizing(TileIndex tile, int user)
{
_thd.userdata = user;
@@ -1982,7 +1981,7 @@
_special_mouse_mode = WSM_PRESIZE;
}
-/* returns information about the 2x1 piece to be build.
+/** returns information about the 2x1 piece to be build.
* The lower bits (0-3) are the track type. */
static byte Check2x1AutoRail(int mode)
{
@@ -2133,7 +2132,7 @@
static const StringID measure_strings_length[] = {STR_NULL, STR_MEASURE_LENGTH, STR_MEASURE_LENGTH_HEIGHTDIFF};
-// while dragging
+/** while dragging */
static void CalcRaildirsDrawstyle(TileHighlightData *thd, int x, int y, int method)
{
HighLightStyle b;
@@ -2384,7 +2383,7 @@
_thd.selend.y = y;
}
-// while dragging
+/** while dragging */
bool VpHandlePlaceSizingDrag()
{
Window *w;
@@ -2394,14 +2393,14 @@
e.we.place.userdata = _thd.userdata;
- // stop drag mode if the window has been closed
+ /* stop drag mode if the window has been closed */
w = FindWindowById(_thd.window_class,_thd.window_number);
if (w == NULL) {
ResetObjectToPlace();
return false;
}
- // while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() )
+ /* while dragging execute the drag procedure of the corresponding window (mostly VpSelectTilesWithMethod() ) */
if (_left_button_down) {
e.event = WE_PLACE_DRAG;
e.we.place.pt = GetTileBelowCursor();
@@ -2409,8 +2408,8 @@
return false;
}
- // mouse button released..
- // keep the selected tool, but reset it to the original mode.
+ /* mouse button released..
+ * keep the selected tool, but reset it to the original mode. */
_special_mouse_mode = WSM_NONE;
if (_thd.next_drawstyle == HT_RECT) {
_thd.place_mode = VHM_RECT;
@@ -2425,7 +2424,7 @@
}
SetTileSelectSize(1, 1);
- // and call the mouseup event.
+ /* and call the mouseup event. */
e.event = WE_PLACE_MOUSEUP;
e.we.place.pt = _thd.selend;
e.we.place.tile = TileVirtXY(e.we.place.pt.x, e.we.place.pt.y);
@@ -2446,7 +2445,7 @@
{
Window *w;
- // undo clicking on button
+ /* undo clicking on button */
if (_thd.place_mode != 0) {
_thd.place_mode = 0;
w = FindWindowById(_thd.window_class, _thd.window_number);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/viewport.h
--- a/src/viewport.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/viewport.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file viewport.h */
+
#ifndef VIEWPORT_H
#define VIEWPORT_H
@@ -15,7 +17,7 @@
void SetSelectionRed(bool);
-/* viewport.c */
+/* viewport.cpp */
void InitViewports();
void DeleteWindowViewport(Window *w);
void AssignWindowViewport(Window *w, int x, int y,
@@ -74,28 +76,28 @@
VPM_SIGNALDIRS = 6
};
-// viewport highlight mode (for highlighting tiles below cursor)
+/* viewport highlight mode (for highlighting tiles below cursor) */
enum {
- VHM_NONE = 0, // default
- VHM_RECT = 1, // rectangle (stations, depots, ...)
- VHM_POINT = 2, // point (lower land, raise land, level land, ...)
- VHM_SPECIAL = 3, // special mode used for highlighting while dragging (and for tunnels/docks)
- VHM_DRAG = 4, // dragging items in the depot windows
- VHM_RAIL = 5, // rail pieces
+ VHM_NONE = 0, ///< default
+ VHM_RECT = 1, ///< rectangle (stations, depots, ...)
+ VHM_POINT = 2, ///< point (lower land, raise land, level land, ...)
+ VHM_SPECIAL = 3, ///< special mode used for highlighting while dragging (and for tunnels/docks)
+ VHM_DRAG = 4, ///< dragging items in the depot windows
+ VHM_RAIL = 5, ///< rail pieces
};
void VpSelectTilesWithMethod(int x, int y, int method);
-// highlighting draw styles
+/* highlighting draw styles */
typedef byte HighLightStyle;
enum HighLightStyles {
HT_NONE = 0x00,
HT_RECT = 0x80,
HT_POINT = 0x40,
- HT_LINE = 0x20, /* used for autorail highlighting (longer streches)
- * (uses lower bits to indicate direction) */
- HT_RAIL = 0x10, /* autorail (one piece)
- * (uses lower bits to indicate direction) */
+ HT_LINE = 0x20, ///< used for autorail highlighting (longer streches)
+ ///< (uses lower bits to indicate direction)
+ HT_RAIL = 0x10, ///< autorail (one piece)
+ ///< (uses lower bits to indicate direction)
HT_DRAG_MASK = 0xF0, ///< masks the drag-type
/* lower bits (used with HT_LINE and HT_RAIL):
@@ -138,7 +140,7 @@
};
-// common button handler
+/* common button handler */
bool HandlePlacePushButton(Window *w, int widget, CursorID cursor, int mode, PlaceProc *placeproc);
VARDEF Point _tile_fract_coords;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/void_map.h
--- a/src/void_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/void_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file void_map.h */
+
#ifndef VOID_MAP_H
#define VOID_MAP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/water_cmd.cpp
--- a/src/water_cmd.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/water_cmd.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file water_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -9,6 +11,7 @@
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
+#include "landscape.h"
#include "map.h"
#include "tile.h"
#include "vehicle.h"
@@ -47,6 +50,7 @@
/** Build a ship depot.
* @param tile tile where ship depot is built
+ * @param flags type of operation
* @param p1 bit 0 depot orientation (Axis)
* @param p2 unused
*/
@@ -76,7 +80,7 @@
ret = DoCommand(tile2, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
- // pretend that we're not making land from the water even though we actually are.
+ /* pretend that we're not making land from the water even though we actually are. */
cost = 0;
depot = AllocateDepot();
@@ -120,25 +124,25 @@
return _eco->GetPrice(CEconomy::REMOVE_SHIP_DEPOT);
}
-// build a shiplift
+/** build a shiplift */
static int32 DoBuildShiplift(TileIndex tile, DiagDirection dir, uint32 flags)
{
int32 ret;
int delta;
- // middle tile
+ /* middle tile */
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
delta = TileOffsByDiagDir(dir);
- // lower tile
+ /* lower tile */
ret = DoCommand(tile - delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
if (GetTileSlope(tile - delta, NULL) != SLOPE_FLAT) {
return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
}
- // upper tile
+ /* upper tile */
ret = DoCommand(tile + delta, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
if (CmdFailed(ret)) return CMD_ERROR;
if (GetTileSlope(tile + delta, NULL) != SLOPE_FLAT) {
@@ -167,7 +171,7 @@
if (!CheckTileOwnership(tile)) return CMD_ERROR;
- // make sure no vehicle is on the tile.
+ /* make sure no vehicle is on the tile. */
if (!EnsureNoVehicle(tile) || !EnsureNoVehicle(tile + delta) || !EnsureNoVehicle(tile - delta))
return CMD_ERROR;
@@ -190,6 +194,7 @@
/** Builds a lock (ship-lift)
* @param tile tile where to place the lock
+ * @param flags type of operation
* @param p1 unused
* @param p2 unused
*/
@@ -211,6 +216,7 @@
/** Build a piece of canal.
* @param tile end tile of stretch-dragging
+ * @param flags type of operation
* @param p1 start tile of stretch-dragging
* @param p2 ctrl pressed - toggles ocean / canals at sealevel (ocean only allowed in the scenario editor)
*/
@@ -249,7 +255,7 @@
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
- // can't make water of water!
+ /* can't make water of water! */
if (IsTileType(tile, MP_WATER) && (!IsTileOwner(tile, OWNER_WATER) || HASBIT(p2, 0))) continue;
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -282,10 +288,10 @@
case WATER_TILE_CLEAR:
if (flags & DC_NO_WATER) return_cmd_error(STR_3807_CAN_T_BUILD_ON_WATER);
- // Make sure no vehicle is on the tile
+ /* Make sure no vehicle is on the tile */
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
- // Make sure it's not an edge tile.
+ /* Make sure it's not an edge tile. */
if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
@@ -299,10 +305,10 @@
case WATER_TILE_COAST: {
Slope slope = GetTileSlope(tile, NULL);
- // Make sure no vehicle is on the tile
+ /* Make sure no vehicle is on the tile */
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
- // Make sure it's not an edge tile.
+ /* Make sure it's not an edge tile. */
if (!IS_INT_INSIDE(TileX(tile), 1, MapMaxX() - 1) ||
!IS_INT_INSIDE(TileY(tile), 1, MapMaxY() - 1)) {
return_cmd_error(STR_0002_TOO_CLOSE_TO_EDGE_OF_MAP);
@@ -325,7 +331,7 @@
if (flags & DC_AUTO) return_cmd_error(STR_2004_BUILDING_MUST_BE_DEMOLISHED);
if (_current_player == OWNER_WATER) return CMD_ERROR;
- // move to the middle tile..
+ /* move to the middle tile.. */
return RemoveShiplift(tile + ToTileIndexDiff(_shiplift_tomiddle_offs[GetSection(tile)]), flags);
}
@@ -339,7 +345,7 @@
}
}
-// return true if a tile is a water tile.
+/** return true if a tile is a water tile. */
static bool IsWateredTile(TileIndex tile)
{
switch (GetTileType(tile)) {
@@ -362,12 +368,12 @@
}
}
-// draw a canal styled water tile with dikes around
+/** draw a canal styled water tile with dikes around */
void DrawCanalWater(TileIndex tile)
{
uint wa;
- // determine the edges around with water.
+ /* determine the edges around with water. */
wa = IsWateredTile(TILE_ADDXY(tile, -1, 0)) << 0;
wa += IsWateredTile(TILE_ADDXY(tile, 0, 1)) << 1;
wa += IsWateredTile(TILE_ADDXY(tile, 1, 0)) << 2;
@@ -378,25 +384,25 @@
if (!(wa & 4)) DrawGroundSprite(SPR_CANALS_BASE + 59, PAL_NONE);
if (!(wa & 8)) DrawGroundSprite(SPR_CANALS_BASE + 60, PAL_NONE);
- // right corner
+ /* right corner */
switch (wa & 0x03) {
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 4, PAL_NONE); break;
case 3: if (!IsWateredTile(TILE_ADDXY(tile, -1, 1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 8, PAL_NONE); break;
}
- // bottom corner
+ /* bottom corner */
switch (wa & 0x06) {
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 5, PAL_NONE); break;
case 6: if (!IsWateredTile(TILE_ADDXY(tile, 1, 1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 9, PAL_NONE); break;
}
- // left corner
+ /* left corner */
switch (wa & 0x0C) {
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 6, PAL_NONE); break;
case 12: if (!IsWateredTile(TILE_ADDXY(tile, 1, -1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 10, PAL_NONE); break;
}
- // upper corner
+ /* upper corner */
switch (wa & 0x09) {
case 0: DrawGroundSprite(SPR_CANALS_BASE + 57 + 7, PAL_NONE); break;
case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1))) DrawGroundSprite(SPR_CANALS_BASE + 57 + 11, PAL_NONE); break;
@@ -421,7 +427,7 @@
SpriteID image = wdts->image + base;
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -524,7 +530,7 @@
{
TileIndex target = TILE_ADD(tile, ToTileIndexDiff(offs[0]));
- // type of this tile mustn't be water already.
+ /* type of this tile mustn't be water already. */
if (IsTileType(target, MP_WATER)) return;
if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[1]))) != 0 ||
@@ -534,7 +540,7 @@
if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 ||
TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) {
- // make coast..
+ /* make coast.. */
switch (GetTileType(target)) {
case MP_RAILWAY: {
TrackBits tracks;
@@ -626,7 +632,7 @@
u = v;
if (IsFrontEngine(v)) pass = 4; // driver
- // crash all wagons, and count passangers
+ /* crash all wagons, and count passangers */
BEGIN_ENUM_WAGONS(v)
if (IsCargoInClass(v->cargo_type, CC_PASSENGERS)) pass += v->cargo_count;
v->vehstatus |= VS_CRASHED;
@@ -653,7 +659,7 @@
}
}
-// called from tunnelbridge_cmd, and by TileLoop_Industry()
+/** called from tunnelbridge_cmd, and by TileLoop_Industry() */
void TileLoop_Water(TileIndex tile)
{
static const TileIndexDiffC _tile_loop_offs_array[][5] = {
@@ -675,11 +681,10 @@
TileLoopWaterHelper(tile, _tile_loop_offs_array[i]);
}
}
- // _current_player can be changed by TileLoopWaterHelper.. reset it back
- // here
+ /* _current_player can be changed by TileLoopWaterHelper.. reset it back here */
_current_player = OWNER_NONE;
- // edges
+ /* edges */
if (TileX(tile) == 0 && IS_INT_INSIDE(TileY(tile), 1, MapSizeY() - 3 + 1)) { //NE
TileLoopWaterHelper(tile, _tile_loop_offs_array[2]);
}
@@ -713,11 +718,11 @@
default: return 0;
}
if (TileX(tile) == 0) {
- // NE border: remove tracks that connects NE tile edge
+ /* NE border: remove tracks that connects NE tile edge */
ts &= ~(TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT);
}
if (TileY(tile) == 0) {
- // NW border: remove tracks that connects NW tile edge
+ /* NW border: remove tracks that connects NW tile edge */
ts &= ~(TRACK_BIT_Y | TRACK_BIT_LEFT | TRACK_BIT_UPPER);
}
return ts * 0x101;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/water_map.h
--- a/src/water_map.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/water_map.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file water_map.h */
+
#ifndef WATER_MAP_H
#define WATER_MAP_H
diff -r 3b068c3a1c74 -r 0fa543611bbe src/waypoint.cpp
--- a/src/waypoint.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/waypoint.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,11 +1,14 @@
/* $Id$ */
+/** @file waypoint.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "command.h"
#include "functions.h"
#include "gfx.h"
+#include "landscape.h"
#include "map.h"
#include "order.h"
#include "rail_map.h"
@@ -20,6 +23,7 @@
#include "vehicle.h"
#include "yapf/yapf.h"
#include "date.h"
+#include "newgrf.h"
enum {
MAX_WAYPOINTS_PER_TOWN = 64,
@@ -39,7 +43,9 @@
DEFINE_OLD_POOL(Waypoint, Waypoint, WaypointPoolNewBlock, NULL)
-/* Create a new waypoint */
+/**
+ * Create a new waypoint
+ * @return a pointer to the newly created Waypoint */
static Waypoint* AllocateWaypoint()
{
Waypoint *wp;
@@ -63,7 +69,9 @@
return NULL;
}
-/* Update the sign for the waypoint */
+/**
+ * Update the sign for the waypoint
+ * @param wp Waypoint to update sign */
static void UpdateWaypointSign(Waypoint* wp)
{
Point pt = RemapCoords2(TileX(wp->xy) * TILE_SIZE, TileY(wp->xy) * TILE_SIZE);
@@ -71,7 +79,9 @@
UpdateViewportSignPos(&wp->sign, pt.x, pt.y - 0x20, STR_WAYPOINT_VIEWPORT);
}
-/* Redraw the sign of a waypoint */
+/**
+ * Redraw the sign of a waypoint
+ * @param wp Waypoint to redraw sign */
static void RedrawWaypointSign(const Waypoint* wp)
{
MarkAllViewportsDirty(
@@ -81,7 +91,9 @@
wp->sign.top + 48);
}
-/* Update all signs */
+/**
+ * Update all signs
+ */
void UpdateAllWaypointSigns()
{
Waypoint *wp;
@@ -91,7 +103,10 @@
}
}
-/* Internal handler to delete a waypoint */
+/**
+ * Internal handler to delete a waypoint
+ * @param wp Waypoint to delete
+ */
void DestroyWaypoint(Waypoint *wp)
{
RemoveOrderFromAllVehicles(OT_GOTO_WAYPOINT, wp->index);
@@ -101,7 +116,10 @@
RedrawWaypointSign(wp);
}
-/* Set the default name for a waypoint */
+/**
+ * Set the default name for a waypoint
+ * @param wp Waypoint to work on
+ */
static void MakeDefaultWaypointName(Waypoint* wp)
{
Waypoint *local_wp;
@@ -127,7 +145,10 @@
wp->town_cn = i;
}
-/* Find a deleted waypoint close to a tile. */
+/**
+ * Find a deleted waypoint close to a tile.
+ * @param tile to search from
+ */
static Waypoint *FindDeletedWaypointCloseTo(TileIndex tile)
{
Waypoint *wp, *best = NULL;
@@ -162,7 +183,7 @@
for (i = 0; i < GetNumCustomStations(STAT_CLASS_WAYP); i++) {
const StationSpec *statspec = GetCustomStationSpec(STAT_CLASS_WAYP, i);
- if (statspec != NULL && statspec->grfid == wp->grfid && statspec->localidx == wp->localidx) {
+ if (statspec != NULL && statspec->grffile->grfid == wp->grfid && statspec->localidx == wp->localidx) {
wp->stat_id = i;
break;
}
@@ -173,6 +194,7 @@
/** Convert existing rail to waypoint. Eg build a waypoint station over
* piece of rail
* @param tile tile where waypoint will be built
+ * @param flags type of operation
* @param p1 graphics for waypoint type, 0 indicates standard graphics
* @param p2 unused
*
@@ -230,10 +252,10 @@
if (statspec != NULL) {
wp->stat_id = p1;
- wp->grfid = statspec->grfid;
+ wp->grfid = statspec->grffile->grfid;
wp->localidx = statspec->localidx;
} else {
- // Specified custom graphics do not exist, so use default.
+ /* Specified custom graphics do not exist, so use default. */
wp->stat_id = 0;
wp->grfid = 0;
wp->localidx = 0;
@@ -253,7 +275,9 @@
return _eco->GetPrice(CEconomy::BUILD_TRAIN_DEPOT);
}
-/* Daily loop for waypoints */
+/**
+ * Daily loop for waypoints
+ */
void WaypointsDailyLoop()
{
Waypoint *wp;
@@ -264,7 +288,13 @@
}
}
-/* Remove a waypoint */
+/**
+ * Remove a waypoint
+ * @param tile from which to remove waypoint
+ * @param flags type of operation
+ * @param justremove will indicate if it is removed from rail or if rails are removed too
+ * @return cost of operation or error
+ */
int32 RemoveTrainWaypoint(TileIndex tile, uint32 flags, bool justremove)
{
Waypoint *wp;
@@ -297,10 +327,13 @@
return _eco->GetPrice(CEconomy::REMOVE_TRAIN_DEPOT);
}
-/** Delete a waypoint
+/**
+ * Delete a waypoint
* @param tile tile where waypoint is to be deleted
+ * @param flags type of operation
* @param p1 unused
* @param p2 unused
+ * @return cost of operation or error
*/
int32 CmdRemoveTrainWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -308,10 +341,13 @@
return RemoveTrainWaypoint(tile, flags, true);
}
-/** Rename a waypoint.
+/**
+ * Rename a waypoint.
* @param tile unused
+ * @param flags type of operation
* @param p1 id of waypoint
* @param p2 unused
+ * @return cost of operation or error
*/
int32 CmdRenameWaypoint(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -349,7 +385,11 @@
return 0;
}
-/* This hacks together some dummy one-shot Station structure for a waypoint. */
+/**
+ * This hacks together some dummy one-shot Station structure for a waypoint.
+ * @param tile on which to work
+ * @return pointer to a Station
+ */
Station *ComposeWaypointStation(TileIndex tile)
{
Waypoint *wp = GetWaypointByTile(tile);
@@ -367,7 +407,13 @@
return &stat;
}
-/* Draw a waypoint */
+/**
+ * Draw a waypoint
+ * @param x coordinate
+ * @param y coordinate
+ * @param stat_id station id
+ * @param railtype RailType to use for
+ */
void DrawWaypointSprite(int x, int y, int stat_id, RailType railtype)
{
x += 33;
@@ -378,7 +424,9 @@
}
}
-/* Fix savegames which stored waypoints in their old format */
+/**
+ * Fix savegames which stored waypoints in their old format
+ */
void FixOldWaypoints()
{
Waypoint *wp;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/waypoint.h
--- a/src/waypoint.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/waypoint.h Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file waypoint.h */
+
#ifndef WAYPOINT_H
#define WAYPOINT_H
@@ -28,6 +30,8 @@
/**
* Check if a Waypoint really exists.
+ * @param wp Waypoint to query
+ * @return the validity of the waypoint
*/
static inline bool IsValidWaypoint(const Waypoint *wp)
{
diff -r 3b068c3a1c74 -r 0fa543611bbe src/widget.cpp
--- a/src/widget.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/widget.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file widget.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
@@ -52,7 +54,7 @@
switch (wi->type) {
case WWT_SCROLLBAR: {
- // vertical scroller
+ /* vertical scroller */
w->flags4 &= ~WF_HSCROLL;
w->flags4 &= ~WF_SCROLL2;
mi = wi->top;
@@ -62,7 +64,7 @@
break;
}
case WWT_SCROLL2BAR: {
- // 2nd vertical scroller
+ /* 2nd vertical scroller */
w->flags4 &= ~WF_HSCROLL;
w->flags4 |= WF_SCROLL2;
mi = wi->top;
@@ -72,7 +74,7 @@
break;
}
case WWT_HSCROLLBAR: {
- // horizontal scroller
+ /* horizontal scroller */
w->flags4 &= ~WF_SCROLL2;
w->flags4 |= WF_HSCROLL;
mi = wi->left;
@@ -84,7 +86,7 @@
default: return; //this should never happen
}
if (pos <= mi+9) {
- // Pressing the upper button?
+ /* Pressing the upper button? */
w->flags4 |= WF_SCROLL_UP;
if (_scroller_click_timeout == 0) {
_scroller_click_timeout = 6;
@@ -92,7 +94,7 @@
}
_left_button_clicked = false;
} else if (pos >= ma-10) {
- // Pressing the lower button?
+ /* Pressing the lower button? */
w->flags4 |= WF_SCROLL_DOWN;
if (_scroller_click_timeout == 0) {
@@ -102,7 +104,6 @@
}
_left_button_clicked = false;
} else {
- //
Point pt = HandleScrollbarHittest(sb, mi, ma);
if (pos < pt.x) {
@@ -127,7 +128,8 @@
/** Returns the index for the widget located at the given position
* relative to the window. It includes all widget-corner pixels as well.
* @param *w Window to look inside
- * @param x,y Window client coordinates
+ * @param x
+ * @param y Window client coordinates
* @return A widget index, or -1 if no widget was found.
*/
int GetWidgetFromPos(const Window *w, int x, int y)
@@ -135,8 +137,8 @@
uint index;
int found_index = -1;
- // Go through the widgets and check if we find the widget that the coordinate is
- // inside.
+ /* Go through the widgets and check if we find the widget that the coordinate is
+ * inside. */
for (index = 0; index < w->widget_count; index++) {
const Widget *wi = &w->widget[index];
if (wi->type == WWT_EMPTY || wi->type == WWT_FRAME) continue;
@@ -294,14 +296,14 @@
goto draw_default;
}
- // vertical scrollbar
+ /* vertical scrollbar */
case WWT_SCROLLBAR: {
Point pt;
int c1,c2;
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
- // draw up/down buttons
+ /* draw up/down buttons */
clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == WF_SCROLL_UP);
DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10);
@@ -313,11 +315,11 @@
c1 = _colour_gradient[wi->color&0xF][3];
c2 = _colour_gradient[wi->color&0xF][7];
- // draw "shaded" background
+ /* draw "shaded" background */
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
- // draw shaded lines
+ /* draw shaded lines */
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
@@ -333,7 +335,7 @@
assert(r.right - r.left == 11); // XXX - to ensure the same sizes are used everywhere!
- // draw up/down buttons
+ /* draw up/down buttons */
clicked = ((w->flags4 & (WF_SCROLL_UP | WF_HSCROLL | WF_SCROLL2)) == (WF_SCROLL_UP | WF_SCROLL2));
DrawFrameRect(r.left, r.top, r.right, r.top + 9, wi->color, (clicked) ? FR_LOWERED : FR_NONE);
DoDrawString(UPARROW, r.left + 2 + clicked, r.top + clicked, 0x10);
@@ -345,11 +347,11 @@
c1 = _colour_gradient[wi->color&0xF][3];
c2 = _colour_gradient[wi->color&0xF][7];
- // draw "shaded" background
+ /* draw "shaded" background */
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c2);
GfxFillRect(r.left, r.top+10, r.right, r.bottom-10, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
- // draw shaded lines
+ /* draw shaded lines */
GfxFillRect(r.left+2, r.top+10, r.left+2, r.bottom-10, c1);
GfxFillRect(r.left+3, r.top+10, r.left+3, r.bottom-10, c2);
GfxFillRect(r.left+7, r.top+10, r.left+7, r.bottom-10, c1);
@@ -360,7 +362,7 @@
break;
}
- // horizontal scrollbar
+ /* horizontal scrollbar */
case WWT_HSCROLLBAR: {
Point pt;
int c1,c2;
@@ -378,17 +380,17 @@
c1 = _colour_gradient[wi->color&0xF][3];
c2 = _colour_gradient[wi->color&0xF][7];
- // draw "shaded" background
+ /* draw "shaded" background */
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c2);
GfxFillRect(r.left+10, r.top, r.right-10, r.bottom, c1 | (1 << PALETTE_MODIFIER_GREYOUT));
- // draw shaded lines
+ /* draw shaded lines */
GfxFillRect(r.left+10, r.top+2, r.right-10, r.top+2, c1);
GfxFillRect(r.left+10, r.top+3, r.right-10, r.top+3, c2);
GfxFillRect(r.left+10, r.top+7, r.right-10, r.top+7, c1);
GfxFillRect(r.left+10, r.top+8, r.right-10, r.top+8, c2);
- // draw actual scrollbar
+ /* draw actual scrollbar */
pt = HandleScrollbarHittest(&w->hscroll, r.left, r.right);
DrawFrameRect(pt.x, r.top, pt.y, r.bottom, wi->color, (w->flags4 & (WF_SCROLL_MIDDLE | WF_HSCROLL)) == (WF_SCROLL_MIDDLE | WF_HSCROLL) ? FR_LOWERED : FR_NONE);
@@ -404,19 +406,19 @@
c1 = _colour_gradient[wi->color][3];
c2 = _colour_gradient[wi->color][7];
- //Line from upper left corner to start of text
+ /*Line from upper left corner to start of text */
GfxFillRect(r.left, r.top+4, r.left+4,r.top+4, c1);
GfxFillRect(r.left+1, r.top+5, r.left+4,r.top+5, c2);
- // Line from end of text to upper right corner
+ /* Line from end of text to upper right corner */
GfxFillRect(x2, r.top+4, r.right-1,r.top+4,c1);
GfxFillRect(x2, r.top+5, r.right-2,r.top+5,c2);
- // Line from upper left corner to bottom left corner
+ /* Line from upper left corner to bottom left corner */
GfxFillRect(r.left, r.top+5, r.left, r.bottom-1, c1);
GfxFillRect(r.left+1, r.top+6, r.left+1, r.bottom-2, c2);
- //Line from upper right corner to bottom right corner
+ /*Line from upper right corner to bottom right corner */
GfxFillRect(r.right-1, r.top+5, r.right-1, r.bottom-2, c1);
GfxFillRect(r.right, r.top+4, r.right, r.bottom-1, c2);
@@ -501,7 +503,7 @@
if (item >= WP(w,dropdown_d).num_items || (HASBIT(WP(w,dropdown_d).disabled_state, item) && !HASBIT(WP(w,dropdown_d).hidden_state, item)) || WP(w,dropdown_d).items[item] == 0)
return - 1;
- // Skip hidden items -- +1 for each hidden item before the clicked item.
+ /* Skip hidden items -- +1 for each hidden item before the clicked item. */
for (counter = 0; item >= counter; ++counter)
if (HASBIT(WP(w,dropdown_d).hidden_state, counter)) item++;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/win32.cpp
--- a/src/win32.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/win32.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -84,7 +84,7 @@
MyShowCursor(true);
MessageBox(GetActiveWindow(), MB_TO_WIDE(buf), _T("Error!"), MB_ICONSTOP);
-// if exception tracker is enabled, we crash here to let the exception handler handle it.
+/* if exception tracker is enabled, we crash here to let the exception handler handle it. */
#if defined(WIN32_EXCEPTION_TRACKER) && !defined(_DEBUG)
if (*buf == '!') {
_exception_string = buf;
@@ -747,7 +747,7 @@
bool FiosIsValidFile(const char *path, const struct dirent *ent, struct stat *sb)
{
- // hectonanoseconds between Windows and POSIX epoch
+ /* hectonanoseconds between Windows and POSIX epoch */
static const int64 posix_epoch_hns = 0x019DB1DED53E8000LL;
const WIN32_FIND_DATA *fd = &ent->dir->fd;
@@ -790,13 +790,13 @@
int n = 0;
do {
- // skip whitespace
+ /* skip whitespace */
while (*line == ' ' || *line == '\t') line++;
- // end?
+ /* end? */
if (*line == '\0') break;
- // special handling when quoted
+ /* special handling when quoted */
if (*line == '"') {
argv[n++] = ++line;
while (*line != '"') {
@@ -831,13 +831,13 @@
coninfo.dwSize.Y = 500;
SetConsoleScreenBufferSize(hand, coninfo.dwSize);
- // redirect unbuffered STDIN, STDOUT, STDERR to the console
+ /* redirect unbuffered STDIN, STDOUT, STDERR to the console */
#if !defined(__CYGWIN__)
*stdout = *_fdopen( _open_osfhandle((intptr_t)hand, _O_TEXT), "w" );
*stdin = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_INPUT_HANDLE), _O_TEXT), "r" );
*stderr = *_fdopen(_open_osfhandle((intptr_t)GetStdHandle(STD_ERROR_HANDLE), _O_TEXT), "w" );
#else
- // open_osfhandle is not in cygwin
+ /* open_osfhandle is not in cygwin */
*stdout = *fdopen(1, "w" );
*stdin = *fdopen(0, "r" );
*stderr = *fdopen(2, "w" );
@@ -946,6 +946,7 @@
void DetermineBasePaths(const char *exe)
{
_paths.personal_dir = _paths.game_data_dir = MallocT(MAX_PATH);
+ _paths.second_data_dir = NULL;
#if defined(UNICODE)
TCHAR path[MAX_PATH];
GetCurrentDirectory(MAX_PATH - 1, path);
@@ -962,8 +963,8 @@
* Insert a chunk of text from the clipboard onto the textbuffer. Get TEXT clipboard
* and append this up to the maximum length (either absolute or screenlength). If maxlength
* is zero, we don't care about the screenlength but only about the physical length of the string
- * @param tb @Textbuf type to be changed
- * @return Return true on successfull change of Textbuf, or false otherwise
+ * @param tb Textbuf type to be changed
+ * @return true on successfull change of Textbuf, or false otherwise
*/
bool InsertTextBufferClipboard(Textbuf *tb)
{
@@ -1036,8 +1037,8 @@
}
-// Utility function to get the current timestamp in milliseconds
-// Useful for profiling
+/** Utility function to get the current timestamp in milliseconds
+ * Useful for profiling */
int64 GetTS()
{
static double freq;
diff -r 3b068c3a1c74 -r 0fa543611bbe src/window.cpp
--- a/src/window.cpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/window.cpp Tue Jun 12 11:56:35 2007 +0000
@@ -18,7 +18,7 @@
#include "genworld.h"
#include "helpers.hpp"
-// delta between mouse cursor and upper left corner of dragged window
+/* delta between mouse cursor and upper left corner of dragged window */
static Point _drag_delta;
static Window _windows[25];
@@ -101,7 +101,7 @@
if (w->desc_flags & WDF_DEF_WIDGET) {
e.we.click.widget = GetWidgetFromPos(w, x, y);
- if (e.we.click.widget < 0) return; /* exit if clicked outside of widgets */
+ if (e.we.click.widget < 0) return; // exit if clicked outside of widgets
/* don't allow any interaction if the button has been disabled */
if (IsWindowWidgetDisabled(w, e.we.click.widget)) return;
@@ -157,7 +157,7 @@
if (w->desc_flags & WDF_STD_TOOLTIPS) {
e.we.click.widget = GetWidgetFromPos(w, x, y);
if (e.we.click.widget < 0)
- return; /* exit if clicked outside of widgets */
+ return; // exit if clicked outside of widgets
if (w->widget[e.we.click.widget].tooltips != 0) {
GuiShowTooltips(w->widget[e.we.click.widget].tooltips);
@@ -291,8 +291,8 @@
}
/** Find the Window whose parent pointer points to this window
- * @parent w Window to find child of
- * @return return a Window pointer that is the child of w, or NULL otherwise */
+ * @param w parent Window to find child of
+ * @return a Window pointer that is the child of w, or NULL otherwise */
static Window *FindChildWindow(const Window *w)
{
Window* const *wz;
@@ -306,7 +306,9 @@
}
/** Find the z-value of a window. A window must already be open
- * or the behaviour is undefined but function should never fail */
+ * or the behaviour is undefined but function should never fail
+ * @param w window to query Z Position
+ * @return the window that matches it */
Window **FindWindowZPosition(const Window *w)
{
Window **wz;
@@ -441,8 +443,9 @@
static void BringWindowToFront(const Window *w);
/** Find a window and make it the top-window on the screen. The window
- * gets a white border for a brief period of time to visualize its
- * "activation"
+ * gets a white border for a brief period of time to visualize its "activation"
+ * @param cls WindowClass of the window to activate
+ * @param number WindowNumber of the window to activate
* @return a pointer to the window thus activated */
Window *BringWindowToFrontById(WindowClass cls, WindowNumber number)
{
@@ -535,7 +538,9 @@
return (w->original_widget == widget);
}
-/* Copies 'widget' to 'w->widget' to allow for resizable windows */
+/** Copies 'widget' to 'w->widget' to allow for resizable windows
+ * @param w Window on which to attach the widget array
+ * @param widget pointer of widget array to fill the window with */
void AssignWidgetToWindow(Window *w, const Widget *widget)
{
w->original_widget = widget;
@@ -577,12 +582,20 @@
return NULL;
}
-/* Open a new window.
+/** Open a new window.
* This function is called from AllocateWindow() or AllocateWindowDesc()
* See descriptions for those functions for usage
* See AllocateWindow() for description of arguments.
* Only addition here is window_number, which is the window_number being assigned to the new window
- */
+ * @param x offset in pixels from the left of the screen
+ * @param y offset in pixels from the top of the screen
+ * @param width width in pixels of the window
+ * @param height height in pixels of the window
+ * @param *proc see WindowProc function to call when any messages/updates happen to the window
+ * @param cls see WindowClass class of the window, used for identification and grouping
+ * @param *widget see Widget pointer to the window layout and various elements
+ * @param window_number number being assigned to the new window
+ * @return Window pointer of the newly created window */
static Window *LocalAllocateWindow(
int x, int y, int width, int height,
WindowProc *proc, WindowClass cls, const Widget *widget, int window_number)
@@ -596,7 +609,7 @@
DeleteWindow(w);
}
- // Set up window properties
+ /* Set up window properties */
memset(w, 0, sizeof(*w));
w->window_class = cls;
w->flags4 = WF_WHITE_BORDER_MASK; // just opened windows have a white border
@@ -653,11 +666,10 @@
* @param y offset in pixels from the top of the screen
* @param width width in pixels of the window
* @param height height in pixels of the window
- * @param *proc @see WindowProc function to call when any messages/updates happen to the window
- * @param cls @see WindowClass class of the window, used for identification and grouping
- * @param *widget @see Widget pointer to the window layout and various elements
- * @return @see Window pointer of the newly created window
- */
+ * @param *proc see WindowProc function to call when any messages/updates happen to the window
+ * @param cls see WindowClass class of the window, used for identification and grouping
+ * @param *widget see Widget pointer to the window layout and various elements
+ * @return Window pointer of the newly created window */
Window *AllocateWindow(
int x, int y, int width, int height,
WindowProc *proc, WindowClass cls, const Widget *widget)
@@ -685,7 +697,7 @@
if (left < 0 || top < 22 || right > _screen.width || bottom > _screen.height)
return false;
- // Make sure it is not obscured by any window.
+ /* Make sure it is not obscured by any window. */
FOR_ALL_WINDOWS(wz) {
const Window *w = *wz;
if (w->window_class == WC_MAIN_WINDOW) continue;
@@ -714,7 +726,7 @@
if (left < -(width>>2) || left > _screen.width - (width>>1)) return false;
if (top < 22 || top > _screen.height - (height>>2)) return false;
- // Make sure it is not obscured by any window.
+ /* Make sure it is not obscured by any window. */
FOR_ALL_WINDOWS(wz) {
const Window *w = *wz;
if (w->window_class == WC_MAIN_WINDOW) continue;
@@ -852,7 +864,7 @@
/**
* Open a new window.
* @param *desc The pointer to the WindowDesc to be created
- * @return @see Window pointer of the newly created window
+ * @return Window pointer of the newly created window
*/
Window *AllocateWindowDesc(const WindowDesc *desc)
{
@@ -863,7 +875,7 @@
* Open a new window.
* @param *desc The pointer to the WindowDesc to be created
* @param window_number the window number of the new window
- * @return @see Window pointer of the newly created window
+ * @return see Window pointer of the newly created window
*/
Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number)
{
@@ -876,6 +888,8 @@
/** Do a search for a window at specific coordinates. For this we start
* at the topmost window, obviously and work our way down to the bottom
+ * @param x position x to query
+ * @param y position y to query
* @return a pointer to the found window if any, NULL otherwise */
Window *FindWindowFromPt(int x, int y)
{
@@ -936,7 +950,7 @@
for (wz = _last_z_window; wz != _z_windows;) {
w = *--wz;
- // Unclick scrollbar buttons if they are pressed.
+ /* Unclick scrollbar buttons if they are pressed. */
if (w->flags4 & (WF_SCROLL_DOWN | WF_SCROLL_UP)) {
w->flags4 &= ~(WF_SCROLL_DOWN | WF_SCROLL_UP);
SetWindowDirty(w);
@@ -993,7 +1007,7 @@
ResetObjectToPlace();
if (w != NULL) {
- // send an event in client coordinates.
+ /* send an event in client coordinates. */
e.event = WE_DRAGDROP;
e.we.dragdrop.pt.x = _cursor.pos.x - w->left;
e.we.dragdrop.pt.y = _cursor.pos.y - w->top;
@@ -1038,7 +1052,7 @@
w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
- // We changed window, put a MOUSEOVER event to the last window
+ /* We changed window, put a MOUSEOVER event to the last window */
if (last_w != NULL && last_w != w) {
e.event = WE_MOUSEOVER;
e.we.mouseover.pt.x = -1;
@@ -1048,7 +1062,7 @@
last_w = w;
if (w != NULL) {
- // send an event in client coordinates.
+ /* send an event in client coordinates. */
e.event = WE_MOUSEOVER;
e.we.mouseover.pt.x = _cursor.pos.x - w->left;
e.we.mouseover.pt.y = _cursor.pos.y - w->top;
@@ -1058,7 +1072,7 @@
w->wndproc(w, &e);
}
- // Mouseover never stops execution
+ /* Mouseover never stops execution */
return true;
}
@@ -1117,10 +1131,10 @@
static bool HandleWindowDragging()
{
Window* const *wz;
- // Get out immediately if no window is being dragged at all.
+ /* Get out immediately if no window is being dragged at all. */
if (!_dragging_window) return true;
- // Otherwise find the window...
+ /* Otherwise find the window... */
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
@@ -1132,7 +1146,7 @@
int nx;
int ny;
- // Stop the dragging if the left mouse button was released
+ /* Stop the dragging if the left mouse button was released */
if (!_left_button_down) {
w->flags4 &= ~WF_DRAGGING;
break;
@@ -1158,14 +1172,14 @@
if (v == w) continue; // Don't snap at yourself
if (y + w->height > v->top && y < v->top + v->height) {
- // Your left border <-> other right border
+ /* Your left border <-> other right border */
delta = abs(v->left + v->width - x);
if (delta <= hsnap) {
nx = v->left + v->width;
hsnap = delta;
}
- // Your right border <-> other left border
+ /* Your right border <-> other left border */
delta = abs(v->left - x - w->width);
if (delta <= hsnap) {
nx = v->left - w->width;
@@ -1174,14 +1188,14 @@
}
if (w->top + w->height >= v->top && w->top <= v->top + v->height) {
- // Your left border <-> other left border
+ /* Your left border <-> other left border */
delta = abs(v->left - x);
if (delta <= hsnap) {
nx = v->left;
hsnap = delta;
}
- // Your right border <-> other right border
+ /* Your right border <-> other right border */
delta = abs(v->left + v->width - x - w->width);
if (delta <= hsnap) {
nx = v->left + v->width - w->width;
@@ -1190,14 +1204,14 @@
}
if (x + w->width > v->left && x < v->left + v->width) {
- // Your top border <-> other bottom border
+ /* Your top border <-> other bottom border */
delta = abs(v->top + v->height - y);
if (delta <= vsnap) {
ny = v->top + v->height;
vsnap = delta;
}
- // Your bottom border <-> other top border
+ /* Your bottom border <-> other top border */
delta = abs(v->top - y - w->height);
if (delta <= vsnap) {
ny = v->top - w->height;
@@ -1206,14 +1220,14 @@
}
if (w->left + w->width >= v->left && w->left <= v->left + v->width) {
- // Your top border <-> other top border
+ /* Your top border <-> other top border */
delta = abs(v->top - y);
if (delta <= vsnap) {
ny = v->top;
vsnap = delta;
}
- // Your bottom border <-> other bottom border
+ /* Your bottom border <-> other bottom border */
delta = abs(v->top + v->height - y - w->height);
if (delta <= vsnap) {
ny = v->top + v->height - w->height;
@@ -1223,12 +1237,12 @@
}
}
- // Make sure the window doesn't leave the screen
- // 13 is the height of the title bar
+ /* Make sure the window doesn't leave the screen
+ * 13 is the height of the title bar */
nx = clamp(nx, 13 - t->right, _screen.width - 13 - t->left);
ny = clamp(ny, 0, _screen.height - 13);
- // Make sure the title bar isn't hidden by behind the main tool bar
+ /* Make sure the title bar isn't hidden by behind the main tool bar */
v = FindWindowById(WC_MAIN_TOOLBAR, 0);
if (v != NULL) {
int v_bottom = v->top + v->height;
@@ -1345,15 +1359,15 @@
int pos;
Scrollbar *sb;
- // Get out quickly if no item is being scrolled
+ /* Get out quickly if no item is being scrolled */
if (!_scrolling_scrollbar) return true;
- // Find the scrolling window
+ /* Find the scrolling window */
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
if (w->flags4 & WF_SCROLL_MIDDLE) {
- // Abort if no button is clicked any more.
+ /* Abort if no button is clicked any more. */
if (!_left_button_down) {
w->flags4 &= ~WF_SCROLL_MIDDLE;
SetWindowDirty(w);
@@ -1371,7 +1385,7 @@
i = _cursor.pos.y - _cursorpos_drag_start.y;
}
- // Find the item we want to move to and make sure it's inside bounds.
+ /* Find the item we want to move to and make sure it's inside bounds. */
pos = min(max(0, i + _scrollbar_start_pos) * sb->count / _scrollbar_size, max(0, sb->count - sb->cap));
if (pos != sb->pos) {
sb->pos = pos;
@@ -1482,7 +1496,7 @@
}
/** Send a message from one window to another. The receiving window is found by
- * @param w @see Window pointer pointing to the other window
+ * @param w Window pointer pointing to the other window
* @param msg Specifies the message to be sent
* @param wparam Specifies additional message-specific information
* @param lparam Specifies additional message-specific information
@@ -1500,8 +1514,8 @@
}
/** Send a message from one window to another. The receiving window is found by
- * @param wnd_class @see WindowClass class AND
- * @param wnd_num @see WindowNumber number, mostly 0
+ * @param wnd_class see WindowClass class AND
+ * @param wnd_num see WindowNumber number, mostly 0
* @param msg Specifies the message to be sent
* @param wparam Specifies additional message-specific information
* @param lparam Specifies additional message-specific information
@@ -1514,7 +1528,7 @@
/** Send a message from one window to another. The message will be sent
* to ALL windows of the windowclass specified in the first parameter
- * @param wnd_class @see WindowClass class
+ * @param wnd_class see WindowClass class
* @param msg Specifies the message to be sent
* @param wparam Specifies additional message-specific information
* @param lparam Specifies additional message-specific information
@@ -1551,13 +1565,13 @@
*/
if (!IsGeneratingWorld()) _current_player = _local_player;
- // Setup event
+ /* Setup event */
e.event = WE_KEYPRESS;
e.we.keypress.key = GB(key, 0, 16);
e.we.keypress.keycode = GB(key, 16, 16);
e.we.keypress.cont = true;
- // check if we have a query string window open before allowing hotkeys
+ /* check if we have a query string window open before allowing hotkeys */
if (FindWindowById(WC_QUERY_STRING, 0) != NULL ||
FindWindowById(WC_SEND_NETWORK_MSG, 0) != NULL ||
FindWindowById(WC_GENERATE_LANDSCAPE, 0) != NULL ||
@@ -1566,11 +1580,11 @@
query_open = true;
}
- // Call the event, start with the uppermost window.
+ /* Call the event, start with the uppermost window. */
for (wz = _last_z_window; wz != _z_windows;) {
Window *w = *--wz;
- // if a query window is open, only call the event for certain window types
+ /* if a query window is open, only call the event for certain window types */
if (query_open &&
w->window_class != WC_QUERY_STRING &&
w->window_class != WC_SEND_NETWORK_MSG &&
@@ -1585,7 +1599,7 @@
if (e.we.keypress.cont) {
Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
- // When there is no toolbar w is null, check for that
+ /* When there is no toolbar w is null, check for that */
if (w != NULL) w->wndproc(w, &e);
}
}
@@ -1616,7 +1630,7 @@
if (vp != NULL) {
x -= vp->left;
y -= vp->top;
- //here allows scrolling in both x and y axis
+ /* here allows scrolling in both x and y axis */
#define scrollspeed 3
if (x - 15 < 0) {
WP(w, vp_d).scrollpos_x += (x - 15) * scrollspeed << vp->zoom;
@@ -1685,7 +1699,7 @@
case 1:
DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite);
if (_thd.place_mode != 0 &&
- // query button and place sign button work in pause mode
+ /* query button and place sign button work in pause mode */
_cursor.sprite != SPR_CURSOR_QUERY &&
_cursor.sprite != SPR_CURSOR_SIGN &&
_pause_game != 0 &&
@@ -1736,7 +1750,7 @@
*/
if (!IsGeneratingWorld()) _current_player = _local_player;
- // Mouse event?
+ /* Mouse event? */
click = 0;
if (_left_button_down && !_left_button_clicked) {
_left_button_clicked = true;
@@ -1793,7 +1807,7 @@
if ((*wz)->viewport != NULL) UpdateViewportPosition(*wz);
}
DrawTextMessage();
- // Redraw mouse cursor in case it was hidden
+ /* Redraw mouse cursor in case it was hidden */
DrawMouseCursor();
}
@@ -1910,7 +1924,7 @@
}
}
-/* It is possible that a stickied window gets to a position where the
+/** It is possible that a stickied window gets to a position where the
* 'close' button is outside the gaming area. You cannot close it then; except
* with this function. It closes all windows calling the standard function,
* then, does a little hacked loop of closing all stickied windows. Note
@@ -1934,7 +1948,7 @@
}
}
-/* Delete all always on-top windows to get an empty screen */
+/** Delete all always on-top windows to get an empty screen */
void HideVitalWindows()
{
DeleteWindowById(WC_TOOLBAR_MENU, 0);
diff -r 3b068c3a1c74 -r 0fa543611bbe src/window.h
--- a/src/window.h Thu Apr 19 14:48:10 2007 +0000
+++ b/src/window.h Tue Jun 12 11:56:35 2007 +0000
@@ -659,7 +659,7 @@
* Sets the lowered/raised status of a widget.
* @param w : Window on which the widget is located
* @param widget_index : index of this widget in the window
- * @param hidden_stat : status to use ie: lowered = true, raised = false
+ * @param lowered_stat : status to use ie: lowered = true, raised = false
*/
static inline void SetWindowWidgetLoweredState(Window *w, byte widget_index, bool lowered_stat)
{
diff -r 3b068c3a1c74 -r 0fa543611bbe src/yapf/yapf.hpp
--- a/src/yapf/yapf.hpp Thu Apr 19 14:48:10 2007 +0000
+++ b/src/yapf/yapf.hpp Tue Jun 12 11:56:35 2007 +0000
@@ -17,6 +17,7 @@
#include "../vehicle.h"
#include "../date.h"
#include "../functions.h"
+#include "../landscape.h"
#include "yapf.h"
#include "../pathfind.h"
#include "../waypoint.h"