TownLayoutByte; //typedefing-enumification of TownLayout
+
enum {
NUM_PRICES = 49,
};
@@ -281,13 +309,13 @@
CT_IRON_ORE = 8,
CT_STEEL = 9,
CT_VALUABLES = 10,
- CT_FOOD = 11,
// Arctic
CT_WHEAT = 6,
CT_HILLY_UNUSED = 8,
CT_PAPER = 9,
CT_GOLD = 10,
+ CT_FOOD = 11,
// Tropic
CT_RUBBER = 1,
@@ -309,7 +337,7 @@
CT_PLASTIC = 10,
CT_FIZZY_DRINKS = 11,
- NUM_CARGO = 12,
+ NUM_CARGO = 32,
CT_NO_REFIT = 0xFE,
CT_INVALID = 0xFF
@@ -336,7 +364,8 @@
typedef int32 ClearTileProc(TileIndex tile, byte flags);
typedef void GetAcceptedCargoProc(TileIndex tile, AcceptedCargo res);
typedef void GetTileDescProc(TileIndex tile, TileDesc *td);
-/* GetTileTrackStatusProcs return a value that contains the possible tracks
+/**
+ * GetTileTrackStatusProcs return a value that contains the possible tracks
* that can be taken on a given tile by a given transport. The return value is
* composed as follows: 0xaabbccdd. ccdd and aabb are bitmasks of trackdirs,
* where bit n corresponds to trackdir n. ccdd are the trackdirs that are
@@ -354,8 +383,12 @@
* are a track, the fourth bit is the direction. these give 12 (or 14)
* possible options: 0-5 and 8-13, so we need 14 bits for a trackdir bitmask
* above.
+ * @param tile the tile to get the track status from
+ * @param mode the mode of transportation
+ * @param sub_mode used to differentiate between different kinds within the mode
+ * @return the above mentions track status information
*/
-typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode);
+typedef uint32 GetTileTrackStatusProc(TileIndex tile, TransportType mode, uint sub_mode);
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
typedef void ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile);
@@ -461,10 +494,11 @@
WC_GENERATE_LANDSCAPE,
WC_GENERATE_PROGRESS_WINDOW,
WC_CONFIRM_POPUP_QUERY,
+ WC_TRANSPARENCY_TOOLBAR,
};
-enum {
+enum ExpensesType {
EXPENSES_CONSTRUCTION = 0,
EXPENSES_NEW_VEHICLES = 1,
EXPENSES_TRAIN_RUN = 2,
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/order_cmd.cpp
--- a/src/order_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/order_cmd.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -6,10 +6,10 @@
#include "openttd.h"
#include "order.h"
#include "airport.h"
+#include "vehicle.h"
#include "depot.h"
#include "functions.h"
#include "table/strings.h"
-#include "vehicle.h"
#include "waypoint.h"
#include "command.h"
#include "station.h"
@@ -182,6 +182,7 @@
/** Add an order to the orderlist of a vehicle.
* @param tile unused
+ * @param flags operation to perform
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 15) - ID of the vehicle
* - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given,
@@ -478,6 +479,7 @@
/** Delete an order from the orderlist of a vehicle.
* @param tile unused
+ * @param flags operation to perform
* @param p1 the ID of the vehicle
* @param p2 the order to delete (max 255)
*/
@@ -557,6 +559,7 @@
/** Goto next order of order-list.
* @param tile unused
+ * @param flags operation to perform
* @param p1 The ID of the vehicle which order is skipped
* @param p2 unused
*/
@@ -578,14 +581,14 @@
v->cur_order_index = b;
- if (v->type == VEH_TRAIN) v->u.rail.days_since_order_progr = 0;
-
if (v->type == VEH_ROAD) ClearSlot(v);
- /* NON-stop flag is misused to see if a train is in a station that is
- * on his order list or not */
- if (v->current_order.type == OT_LOADING && HASBIT(v->current_order.flags, OFB_NON_STOP))
- v->current_order.flags = 0;
+ if (v->current_order.type == OT_LOADING) {
+ v->LeaveStation();
+ /* NON-stop flag is misused to see if a train is in a station that is
+ * on his order list or not */
+ if (HASBIT(v->current_order.flags, OFB_NON_STOP)) v->current_order.flags = 0;
+ }
InvalidateVehicleOrder(v);
}
@@ -600,6 +603,7 @@
/** Modify an order in the orderlist of a vehicle.
* @param tile unused
+ * @param flags operation to perform
* @param p1 various bitstuffed elements
* - p1 = (bit 0 - 15) - ID of the vehicle
* - p1 = (bit 16 - 31) - the selected order (if any). If the last order is given,
@@ -680,6 +684,8 @@
}
/** Clone/share/copy an order-list of an other vehicle.
+ * @param tile unused
+ * @param flags operation to perform
* @param p1 various bitstuffed elements
* - p1 = (bit 0-15) - destination vehicle to clone orders to (p1 & 0xFFFF)
* - p1 = (bit 16-31) - source vehicle to clone orders from, if any (none for CO_UNSHARE)
@@ -812,6 +818,7 @@
/** Add/remove refit orders from an order
* @param tile Not used
+ * @param flags operation to perform
* @param p1 VehicleIndex of the vehicle having the order
* @param p2 bitmask
* - bit 0-7 CargoID
@@ -937,6 +944,7 @@
/** Restore the current order-index of a vehicle and sets service-interval.
* @param tile unused
+ * @param flags operation to perform
* @param p1 the ID of the vehicle
* @param p2 various bistuffed elements
* - p2 = (bit 0-15) - current order-index (p2 & 0xFFFF)
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/order_gui.cpp
--- a/src/order_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/order_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -320,9 +320,9 @@
{
if (u->type != v->type) return false;
- if (u->type == VEH_TRAIN && !IsFrontEngine(u)) {
+ if (u->HasFront() && !u->IsPrimaryVehicle()) {
u = GetFirstVehicleInChain(u);
- if (!IsFrontEngine(u)) return false;
+ if (!u->IsPrimaryVehicle()) return false;
}
// v is vehicle getting orders. Only copy/clone orders if vehicle doesn't have any orders yet
@@ -478,7 +478,7 @@
if (sel == WP(w,order_d).sel) sel = -1;
WP(w,order_d).sel = sel;
SetWindowDirty(w);
- } break;
+ } break;
case ORDER_WIDGET_SKIP:
OrderClick_Skip(w, v);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/os2.cpp
--- a/src/os2.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/os2.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -169,7 +169,7 @@
* 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
+ * @param tb Textbuf type to be changed
* @return Return true on successfull change of Textbuf, or false otherwise
*/
bool InsertTextBufferClipboard(Textbuf *tb)
@@ -222,7 +222,7 @@
void CSleep(int milliseconds)
{
#ifndef __INNOTEK_LIBC__
- delay(milliseconds);
+ delay(milliseconds);
#else
usleep(milliseconds * 1000);
#endif
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/pathfind.cpp
--- a/src/pathfind.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/pathfind.cpp Sat Jun 02 19:59:29 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"
@@ -152,7 +153,7 @@
if (++tpf->rd.cur_length > 50)
return;
- bits = GetTileTrackStatus(tile, tpf->tracktype);
+ bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type);
bits = (byte)((bits | (bits >> 8)) & _bits_mask[direction]);
if (bits == 0)
return;
@@ -321,7 +322,7 @@
tpf->rd.cur_length++;
- bits = GetTileTrackStatus(tile, tpf->tracktype);
+ bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type);
if ((byte)bits != tpf->var2) {
bits &= _tpfmode1_and[direction];
@@ -362,7 +363,7 @@
direction = ReverseDiagDir(direction);
tile += TileOffsByDiagDir(direction);
- bits = GetTileTrackStatus(tile, tpf->tracktype);
+ bits = GetTileTrackStatus(tile, tpf->tracktype, tpf->sub_type);
bits |= (bits >> 8);
if ( (byte)bits != tpf->var2) {
@@ -387,7 +388,7 @@
} while (bits != 0);
}
-void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data)
+void FollowTrack(TileIndex tile, uint16 flags, uint sub_type, DiagDirection direction, TPFEnumProc *enum_proc, TPFAfterProc *after_proc, void *data)
{
TrackPathFinder tpf;
@@ -410,6 +411,7 @@
tpf.tracktype = (TransportType)(flags & 0xFF);
+ tpf.sub_type = sub_type;
if (HASBIT(flags, 11)) {
tpf.rd.pft_var6 = 0xFF;
@@ -782,7 +784,7 @@
if (!IsTileType(tile, MP_RAILWAY) || !IsPlainRailTile(tile)) {
/* We found a tile which is not a normal railway tile.
* Determine which tracks that exist on this tile. */
- uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _tpfmode1_and[direction];
+ uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _tpfmode1_and[direction];
bits = TrackdirBitsToTrackBits((TrackdirBits)(ts & TRACKDIR_BIT_MASK));
/* Check that the tile contains exactly one track */
@@ -820,7 +822,7 @@
}
/* If we reach here, the tile has exactly one track, and this
- track is reachable => Rail segment continues */
+ track is reachable = > Rail segment continues */
track = _new_trackdir[FIND_FIRST_BIT(bits)][direction];
assert(track != INVALID_TRACKDIR);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/pathfind.h
--- a/src/pathfind.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/pathfind.h Sat Jun 02 19:59:29 2007 +0000
@@ -57,6 +57,8 @@
TrackdirByte the_dir;
TransportTypeByte tracktype;
+ uint sub_type;
+
byte var2;
bool disable_tile_hash;
bool hasbit_13;
@@ -67,7 +69,7 @@
TrackPathFinderLink links[0x400]; ///< hopefully, this is enough.
};
-void FollowTrack(TileIndex tile, uint16 flags, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data);
+void FollowTrack(TileIndex tile, uint16 flags, uint sub_type, DiagDirection direction, TPFEnumProc* enum_proc, TPFAfterProc* after_proc, void* data);
struct FindLengthOfTunnelResult {
TileIndex tile;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/player.h
--- a/src/player.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/player.h Sat Jun 02 19:59:29 2007 +0000
@@ -168,6 +168,7 @@
Livery livery[LS_END];
byte player_money_fraction;
byte avail_railtypes;
+ byte avail_roadtypes;
byte block_preview;
PlayerByte index;
@@ -248,6 +249,7 @@
}
byte GetPlayerRailtypes(PlayerID p);
+byte GetPlayerRoadtypes(PlayerID p);
/** Finds out if a Player has a certain railtype available */
static inline bool HasRailtypeAvail(const Player *p, RailType Railtype)
@@ -311,7 +313,7 @@
* @return The engine type to replace with, or INVALID_ENGINE if no
* replacement is in the list.
*/
-static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine) { return EngineReplacement(p->engine_renew_list, engine); }
+static inline EngineID EngineReplacementForPlayer(const Player *p, EngineID engine, GroupID group) { return EngineReplacement(p->engine_renew_list, engine, group); }
/**
* Check if a player has a replacement set up for the given engine.
@@ -319,7 +321,7 @@
* @param engine Engine type to be replaced.
* @return true if a replacement was set up, false otherwise.
*/
-static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine) { return EngineReplacementForPlayer(p, engine) != INVALID_ENGINE; }
+static inline bool EngineHasReplacementForPlayer(const Player *p, EngineID engine, GroupID group) { return EngineReplacementForPlayer(p, engine, group) != INVALID_ENGINE; }
/**
* Add an engine replacement for the player.
@@ -329,7 +331,7 @@
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
-static inline int32 AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, flags); }
+static inline int32 AddEngineReplacementForPlayer(Player *p, EngineID old_engine, EngineID new_engine, GroupID group, uint32 flags) { return AddEngineReplacement(&p->engine_renew_list, old_engine, new_engine, group, flags); }
/**
* Remove an engine replacement for the player.
@@ -338,7 +340,7 @@
* @param flags The calling command flags.
* @return 0 on success, CMD_ERROR on failure.
*/
-static inline int32 RemoveEngineReplacementForPlayer(Player *p, EngineID engine, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, flags); }
+static inline int32 RemoveEngineReplacementForPlayer(Player *p, EngineID engine, GroupID group, uint32 flags) {return RemoveEngineReplacement(&p->engine_renew_list, engine, group, flags); }
/**
* Reset the livery schemes to the player's primary colour.
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/player_gui.cpp
--- a/src/player_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/player_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -29,7 +29,7 @@
static void DrawPlayerEconomyStats(const Player *p, byte mode)
{
- int x,y,i,j,year;
+ int x, y, i, j, year;
const int64 (*tbl)[13];
int64 sum, cost;
StringID str;
@@ -38,8 +38,8 @@
/* draw categories */
DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0);
for (i = 0; i != 13; i++)
- DrawString(2, 27 + i*10, STR_7011_CONSTRUCTION + i, 0);
- DrawStringRightAligned(111, 27 + 10*13 + 2, STR_7020_TOTAL, 0);
+ DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, 0);
+ DrawStringRightAligned(111, 27 + 10 * 13 + 2, STR_7020_TOTAL, 0);
/* draw the price columns */
year = _cur_year - 2;
@@ -60,16 +60,16 @@
str = STR_701E;
if (cost < 0) { cost = -cost; str++; }
SetDParam64(0, cost);
- DrawStringRightAligned(x, 27+i*10, str, 0);
+ DrawStringRightAligned(x, 27 + i * 10, str, 0);
}
}
str = STR_701E;
if (sum < 0) { sum = -sum; str++; }
SetDParam64(0, sum);
- DrawStringRightAligned(x, 27 + 13*10 + 2, str, 0);
+ DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, 0);
- GfxFillRect(x - 75, 27 + 10*13, x, 27 + 10*13, 215);
+ GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215);
x += 95;
}
year++;
@@ -80,7 +80,7 @@
/* draw max loan aligned to loan below (y += 10) */
SetDParam64(0, (uint64)_economy.max_loan);
- DrawString(202, y+10, STR_MAX_LOAN, 0);
+ DrawString(202, y + 10, STR_MAX_LOAN, 0);
} else {
y = 15;
}
@@ -97,7 +97,7 @@
y += 12;
- GfxFillRect(182 - 75, y-2, 182, y-2, 215);
+ GfxFillRect(182 - 75, y - 2, 182, y - 2, 215);
SetDParam64(0, p->money64 - p->current_loan);
DrawStringRightAligned(182, y, STR_7028, 0);
@@ -166,13 +166,13 @@
SetDParam(4, 10000);
DrawWindowWidgets(w);
- DrawPlayerEconomyStats(p, (byte)WP(w,def_d).data_1);
+ DrawPlayerEconomyStats(p, (byte)WP(w, def_d).data_1);
} break;
case WE_CLICK:
switch (e->we.click.widget) {
case 2: {/* toggle size */
- byte mode = (byte)WP(w,def_d).data_1;
+ byte mode = (byte)WP(w, def_d).data_1;
bool stickied = !!(w->flags4 & WF_STICKY);
PlayerID player = (PlayerID)w->window_number;
DeleteWindow(w);
@@ -239,7 +239,7 @@
w = AllocateWindowDescFront(desc_table[mode], player);
if (w != NULL) {
w->caption_color = w->window_number;
- WP(w,def_d).data_1 = mode;
+ WP(w, def_d).data_1 = mode;
if (show_stickied) w->flags4 |= WF_STICKY;
}
}
@@ -277,13 +277,14 @@
LC_ROAD, LC_ROAD,
LC_SHIP, LC_SHIP,
LC_AIRCRAFT, LC_AIRCRAFT, LC_AIRCRAFT,
+ LC_ROAD, LC_ROAD,
};
/* Number of liveries in each class, used to determine the height of the livery window */
static const byte livery_height[] = {
1,
11,
- 2,
+ 4,
2,
3,
};
@@ -323,7 +324,7 @@
switch (e->event) {
case WE_CREATE:
LowerWindowWidget(w, WP(w, livery_d).livery_class + 2);
- if (!_have_2cc) {
+ if (!HASBIT(_loaded_newgrf_features, GRFLOADED_2CC)) {
HideWindowWidget(w, 11);
HideWindowWidget(w, 12);
}
@@ -365,7 +366,7 @@
DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour1), 152, y);
DrawString(165, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour1, sel ? 0xC : 2);
- if (_have_2cc) {
+ if (HASBIT(_loaded_newgrf_features, GRFLOADED_2CC)) {
DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOR(p->livery[scheme].colour2), 277, y);
DrawString(290, y, STR_00D1_DARK_BLUE + p->livery[scheme].colour2, sel ? 0xC : 2);
}
@@ -554,14 +555,14 @@
LowerWindowWidget(w, WP(w, facesel_d).gender + 5);
DrawWindowWidgets(w);
p = GetPlayer((PlayerID)w->window_number);
- DrawPlayerFace(WP(w,facesel_d).face, p->player_color, 2, 16);
+ DrawPlayerFace(WP(w, facesel_d).face, p->player_color, 2, 16);
} break;
case WE_CLICK:
switch (e->we.click.widget) {
case 3: DeleteWindow(w); break;
case 4: /* ok click */
- DoCommandP(0, 0, WP(w,facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
+ DoCommandP(0, 0, WP(w, facesel_d).face, NULL, CMD_SET_PLAYER_FACE);
DeleteWindow(w);
break;
case 5: /* male click */
@@ -572,7 +573,7 @@
SetWindowDirty(w);
break;
case 7:
- WP(w,facesel_d).face = ConvertFromOldPlayerFace((WP(w, facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31));
+ WP(w, facesel_d).face = ConvertFromOldPlayerFace((WP(w, facesel_d).gender << 31) + GB(InteractiveRandom(), 0, 31));
SetWindowDirty(w);
break;
}
@@ -656,8 +657,8 @@
}
}
- if (train+road+air+ship == 0) {
- DrawString(x+70, y, STR_7042_NONE, 0);
+ if (train + road + air + ship == 0) {
+ DrawString(x + 70, y, STR_7042_NONE, 0);
} else {
if (train != 0) {
SetDParam(0, train);
@@ -762,7 +763,7 @@
DrawPlayerVehiclesAmount((PlayerID)w->window_number);
- DrawString(110,48, STR_7006_COLOR_SCHEME, 0);
+ DrawString(110, 48, STR_7006_COLOR_SCHEME, 0);
/* Draw company-colour bus */
DrawSprite(SPR_VEH_BUS_SW_VIEW, PLAYER_SPRITE_COLOR(p->index), 215, 49);
@@ -786,18 +787,18 @@
Window *wf = AllocateWindowDescFront(&_select_player_face_desc, w->window_number);
if (wf != NULL) {
wf->caption_color = w->window_number;
- WP(wf,facesel_d).face = GetPlayer((PlayerID)wf->window_number)->face;
- WP(wf,facesel_d).gender = 0;
+ WP(wf, facesel_d).face = GetPlayer((PlayerID)wf->window_number)->face;
+ WP(wf, facesel_d).gender = 0;
}
break;
}
case PCW_WIDGET_COLOR_SCHEME: {
- Window *wf = AllocateWindowDescFront(_have_2cc ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
+ Window *wf = AllocateWindowDescFront(HASBIT(_loaded_newgrf_features, GRFLOADED_2CC) ? &_select_player_livery_2cc_desc : &_select_player_livery_desc, w->window_number);
if (wf != NULL) {
wf->caption_color = wf->window_number;
- WP(wf,livery_d).livery_class = LC_OTHER;
- WP(wf,livery_d).sel = 1;
+ WP(wf, livery_d).livery_class = LC_OTHER;
+ WP(wf, livery_d).sel = 1;
LowerWindowWidget(wf, 2);
}
break;
@@ -813,7 +814,7 @@
case PCW_WIDGET_COMPANY_NAME: {
Player *p = GetPlayer((PlayerID)w->window_number);
- WP(w,def_d).byte_1 = 1;
+ WP(w, def_d).byte_1 = 1;
SetDParam(0, p->name_2);
ShowQueryString(p->name_1, STR_700A_COMPANY_NAME, 31, 150, w, CS_ALPHANUMERAL);
break;
@@ -852,7 +853,7 @@
#ifdef ENABLE_NETWORK
case PCW_WIDGET_COMPANY_PASSWORD:
if (w->window_number == _local_player) {
- WP(w,def_d).byte_1 = 2;
+ WP(w, def_d).byte_1 = 2;
ShowQueryString(BindCString(_network_player_info[_local_player].password),
STR_SET_COMPANY_PASSWORD, sizeof(_network_player_info[_local_player].password), 250, w, CS_ALPHANUMERAL);
}
@@ -885,10 +886,10 @@
char *b = e->we.edittext.str;
/* empty string is allowed for password */
- if (*b == '\0' && WP(w,def_d).byte_1 != 2) return;
+ if (*b == '\0' && WP(w, def_d).byte_1 != 2) return;
_cmd_text = b;
- switch (WP(w,def_d).byte_1) {
+ switch (WP(w, def_d).byte_1) {
case 0: /* Change president name */
DoCommandP(0, 0, 0, NULL, CMD_CHANGE_PRESIDENT_NAME | CMD_MSG(STR_700D_CAN_T_CHANGE_PRESIDENT));
break;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/players.cpp
--- a/src/players.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/players.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -27,6 +27,7 @@
#include "date.h"
#include "window.h"
#include "player_face.h"
+#include "group.h"
/**
* Sets the local player and updates the patch settings that are set on a
@@ -471,6 +472,7 @@
p->share_owners[0] = p->share_owners[1] = p->share_owners[2] = p->share_owners[3] = PLAYER_SPECTATOR;
p->avail_railtypes = GetPlayerRailtypes(p->index);
+ p->avail_roadtypes = GetPlayerRoadtypes(p->index);
p->inaugurated_year = _cur_year;
p->face = ConvertFromOldPlayerFace(Random());
@@ -608,6 +610,24 @@
return rt;
}
+byte GetPlayerRoadtypes(PlayerID p)
+{
+ byte rt = 0;
+ EngineID i;
+
+ for (i = 0; i != TOTAL_NUM_ENGINES; i++) {
+ const Engine* e = GetEngine(i);
+ const EngineInfo *ei = EngInfo(i);
+
+ if (e->type == VEH_ROAD && HASBIT(ei->climates, _opt.landscape) &&
+ (HASBIT(e->player_avail, p) || _date >= e->intro_date + 365)) {
+ SETBIT(rt, HASBIT(ei->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD);
+ }
+ }
+
+ return rt;
+}
+
static void DeletePlayerStuff(PlayerID pi)
{
Player *p;
@@ -622,6 +642,7 @@
/** Change engine renewal parameters
* @param tile unused
+ * @param flags operation to perform
* @param p1 bits 0-3 command
* - p1 = 0 - change auto renew bool
* - p1 = 1 - change auto renew months
@@ -637,6 +658,7 @@
* if p1 = 2, then
* - p2 = minimum amount of money available
* if p1 = 3, then:
+ * - p1 bits 8-15 = engine group
* - p2 bits 0-15 = old engine type
* - p2 bits 16-31 = new engine type
* if p1 = 4, then:
@@ -692,8 +714,10 @@
case 3: {
EngineID old_engine_type = GB(p2, 0, 16);
EngineID new_engine_type = GB(p2, 16, 16);
+ GroupID id_g = GB(p1, 16, 16);
int32 cost;
+ if (!IsValidGroupID(id_g) && !IsDefaultGroupID(id_g)) return CMD_ERROR;
if (new_engine_type != INVALID_ENGINE) {
/* First we make sure that it's a valid type the user requested
* check that it's an engine that is in the engine array */
@@ -713,9 +737,9 @@
if (!HASBIT(GetEngine(new_engine_type)->player_avail, _current_player))
return CMD_ERROR;
- cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, flags);
+ cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, id_g, flags);
} else {
- cost = RemoveEngineReplacementForPlayer(p, old_engine_type, flags);
+ cost = RemoveEngineReplacementForPlayer(p, old_engine_type,id_g, flags);
}
if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type);
@@ -755,6 +779,7 @@
/** Control the players: add, delete, etc.
* @param tile unused
+ * @param flags operation to perform
* @param p1 various functionality
* - p1 = 0 - create a new player, Which player (network) it will be is in p2
* - p1 = 1 - create a new AI player
@@ -821,8 +846,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();
}
@@ -899,6 +924,7 @@
p->is_active = false;
}
RemoveAllEngineReplacementForPlayer(p);
+ RemoveAllGroupsForPlayer(p);
} break;
@@ -1107,7 +1133,7 @@
SLE_VAR(Player, player_color, SLE_UINT8),
SLE_VAR(Player, player_money_fraction, SLE_UINT8),
- SLE_VAR(Player, avail_railtypes, SLE_UINT8),
+ SLE_CONDVAR(Player, avail_railtypes, SLE_UINT8, 0, 57),
SLE_VAR(Player, block_preview, SLE_UINT8),
SLE_VAR(Player, cargo_types, SLE_UINT16),
@@ -1253,9 +1279,16 @@
}
/* Write each livery entry. */
- for (i = 0; i < LS_END; i++) {
+ int num_liveries = CheckSavegameVersion(63) ? LS_END - 2 : LS_END;
+ for (i = 0; i < num_liveries; i++) {
SlObject(&p->livery[i], _player_livery_desc);
}
+
+ if (num_liveries == LS_END - 2) {
+ /* Copy bus/truck liveries over to trams */
+ p->livery[LS_PASSENGER_TRAM] = p->livery[LS_BUS];
+ p->livery[LS_FREIGHT_TRAM] = p->livery[LS_TRUCK];
+ }
}
static void Save_PLYR()
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/rail.cpp
--- a/src/rail.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/rail.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file rail.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -11,21 +13,21 @@
/* Maps a trackdir to the bit that stores its status in the map arrays, in the
* direction along with the trackdir */
extern const byte _signal_along_trackdir[] = {
- 0x80, 0x80, 0x80, 0x20, 0x40, 0x10, 0, 0,
- 0x40, 0x40, 0x40, 0x10, 0x80, 0x20
+ 0x8, 0x8, 0x8, 0x2, 0x4, 0x1, 0, 0,
+ 0x4, 0x4, 0x4, 0x1, 0x8, 0x2
};
/* Maps a trackdir to the bit that stores its status in the map arrays, in the
* direction against the trackdir */
extern const byte _signal_against_trackdir[] = {
- 0x40, 0x40, 0x40, 0x10, 0x80, 0x20, 0, 0,
- 0x80, 0x80, 0x80, 0x20, 0x40, 0x10
+ 0x4, 0x4, 0x4, 0x1, 0x8, 0x2, 0, 0,
+ 0x8, 0x8, 0x8, 0x2, 0x4, 0x1
};
/* Maps a Track to the bits that store the status of the two signals that can
* be present on the given track */
extern const byte _signal_on_track[] = {
- 0xC0, 0xC0, 0xC0, 0x30, 0xC0, 0x30
+ 0xC, 0xC, 0xC, 0x3, 0xC, 0x3
};
/* Maps a diagonal direction to the all trackdirs that are connected to any
@@ -66,8 +68,8 @@
/* Maps a trackdir to the (4-way) direction the tile is exited when following
* that trackdir */
extern const DiagDirection _trackdir_to_exitdir[] = {
- DIAGDIR_NE,DIAGDIR_SE,DIAGDIR_NE,DIAGDIR_SE,DIAGDIR_SW,DIAGDIR_SE, DIAGDIR_NE,DIAGDIR_NE,
- DIAGDIR_SW,DIAGDIR_NW,DIAGDIR_NW,DIAGDIR_SW,DIAGDIR_NW,DIAGDIR_NE,
+ DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_SE, DIAGDIR_SW, DIAGDIR_SE, DIAGDIR_NE, DIAGDIR_NE,
+ DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NW, DIAGDIR_SW, DIAGDIR_NW, DIAGDIR_NE,
};
extern const Trackdir _track_exitdir_to_trackdir[][DIAGDIR_END] = {
@@ -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 5a8b295aa345 -r 4cc327ad39d5 src/rail.h
--- a/src/rail.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/rail.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/rail_cmd.cpp
--- a/src/rail_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/rail_cmd.cpp Sat Jun 02 19:59:29 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 _price.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;
@@ -228,6 +230,7 @@
/** Build a single piece of rail
* @param tile tile to build on
+ * @param flags operation to perform
* @param p1 railtype of being built piece (normal, mono, maglev)
* @param p2 rail track to build
*/
@@ -252,12 +255,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);
}
@@ -287,15 +290,36 @@
}
#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);
- if ((track == TRACK_X && GetRoadBits(tile) == ROAD_Y) ||
- (track == TRACK_Y && GetRoadBits(tile) == ROAD_X)) {
+ RoadTypes roadtypes = GetRoadTypes(tile);
+ RoadBits road = GetRoadBits(tile, ROADTYPE_ROAD);
+ RoadBits tram = GetRoadBits(tile, ROADTYPE_TRAM);
+ switch (roadtypes) {
+ default: break;
+ case ROADTYPES_TRAM:
+ /* Tram crossings must always have road. */
+ SetRoadOwner(tile, ROADTYPE_ROAD, _current_player);
+ roadtypes |= ROADTYPES_ROAD;
+ break;
+
+ case ROADTYPES_ROADTRAM: if (road == tram) break;
+ /* FALL THROUGH */
+ case ROADTYPES_ROADHWAY: // Road and highway are incompatible in this case
+ case ROADTYPES_TRAMHWAY: // Tram and highway are incompatible in this case
+ case ROADTYPES_ALL: // Also incompatible
+ return CMD_ERROR;
+ }
+
+ road |= tram | GetRoadBits(tile, ROADTYPE_HWAY);
+
+ if ((track == TRACK_X && road == ROAD_Y) ||
+ (track == TRACK_Y && road == ROAD_X)) {
if (flags & DC_EXEC) {
- MakeRoadCrossing(tile, GetTileOwner(tile), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, GetTownIndex(tile));
+ MakeRoadCrossing(tile, GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY), _current_player, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile));
}
break;
}
@@ -330,6 +354,7 @@
/** Remove a single piece of track
* @param tile tile to remove track from
+ * @param flags operation to perform
* @param p1 unused
* @param p2 rail orientation
*/
@@ -350,12 +375,12 @@
if (!IsLevelCrossing(tile) ||
GetCrossingRailBits(tile) != trackbit ||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
if (flags & DC_EXEC) {
- MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile));
+ MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY));
}
break;
}
@@ -365,7 +390,7 @@
if (!IsPlainRailTile(tile) ||
(_current_player != OWNER_WATER && !CheckTileOwnership(tile)) ||
- !EnsureNoVehicle(tile)) {
+ !EnsureNoVehicleOnGround(tile)) {
return CMD_ERROR;
}
@@ -432,11 +457,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;
@@ -445,7 +470,7 @@
trdy += _trackdelta[*trackdir ^ 1].y;
}
- // validate the direction
+ /* validate the direction */
while (
(trdx <= 0 && dx > 0) ||
(trdx >= 0 && dx < 0) ||
@@ -461,8 +486,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;
@@ -475,6 +500,7 @@
/** Build a stretch of railroad tracks.
* @param tile start tile of drag
+ * @param flags operation to perform
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
@@ -515,7 +541,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);
}
@@ -524,6 +550,13 @@
/** Build rail on a stretch of track.
* Stub for the unified rail builder/remover
+ * @param tile start tile of drag
+ * @param flags operation to perform
+ * @param p1 end tile of drag
+ * @param p2 various bitstuffed elements
+ * - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
+ * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 7) - 0 = build, 1 = remove tracks
* @see CmdRailTrackHelper
*/
int32 CmdBuildRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -533,6 +566,13 @@
/** Build rail on a stretch of track.
* Stub for the unified rail builder/remover
+ * @param tile start tile of drag
+ * @param flags operation to perform
+ * @param p1 end tile of drag
+ * @param p2 various bitstuffed elements
+ * - p2 = (bit 0-3) - railroad type normal/maglev (0 = normal, 1 = mono, 2 = maglev)
+ * - p2 = (bit 4-6) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 7) - 0 = build, 1 = remove tracks
* @see CmdRailTrackHelper
*/
int32 CmdRemoveRailroadTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -542,6 +582,7 @@
/** Build a train depot
* @param tile position of the train depot
+ * @param flags operation to perform
* @param p1 rail type
* @param p2 bit 0..1 entrance direction (DiagDirection)
*
@@ -607,6 +648,7 @@
* pre/exit/combo-signals, and what-else not. If the rail piece does not
* have any signals, bit 4 (cycle signal-type) is ignored
* @param tile tile where to build the signals
+ * @param flags operation to perform
* @param p1 various bitstuffed elements
* - p1 = (bit 0-2) - track-orientation, valid values: 0-5 (Track enum)
* - p1 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
@@ -621,7 +663,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 */
@@ -647,38 +689,40 @@
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (!HasSignalOnTrack(tile, track)) {
- // build new signals
+ /* build new signals */
cost = _price.build_signals;
} else {
- if (p2 != 0 && sigvar != GetSignalVariant(tile)) {
- // convert signals <-> semaphores
+ if (p2 != 0 && sigvar != GetSignalVariant(tile, track)) {
+ /* convert signals <-> semaphores */
cost = _price.build_signals + _price.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
- SetSignalType(tile, SIGTYPE_NORMAL);
- SetSignalVariant(tile, sigvar);
+ SetSignalStates(tile, 0xF); // all signals are on
+ SetPresentSignals(tile, 0); // no signals built by default
+ SetSignalType(tile, track, SIGTYPE_NORMAL);
+ SetSignalVariant(tile, track, sigvar);
}
if (p2 == 0) {
if (!HasSignalOnTrack(tile, track)) {
- // build new signals
- _m[tile].m3 |= SignalOnTrack(track);
+ /* build new signals */
+ SetPresentSignals(tile, GetPresentSignals(tile) | SignalOnTrack(track));
+ SetSignalType(tile, track, SIGTYPE_NORMAL);
+ SetSignalVariant(tile, track, sigvar);
} else {
if (pre_signal) {
- // cycle between normal -> pre -> exit -> combo -> ...
- SignalType type = GetSignalType(tile);
+ /* cycle between normal -> pre -> exit -> combo -> ... */
+ SignalType type = GetSignalType(tile, track);
- SetSignalType(tile, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(type + 1));
+ SetSignalType(tile, track, type == SIGTYPE_COMBO ? SIGTYPE_NORMAL : (SignalType)(type + 1));
} else {
CycleSignalSide(tile, track);
}
@@ -686,9 +730,8 @@
} else {
/* If CmdBuildManySignals is called with copying signals, just copy the
* direction of the first signal given as parameter by CmdBuildManySignals */
- _m[tile].m3 &= ~SignalOnTrack(track);
- _m[tile].m3 |= p2 & SignalOnTrack(track);
- SetSignalVariant(tile, sigvar);
+ SetPresentSignals(tile, (GetPresentSignals(tile) & ~SignalOnTrack(track)) | (p2 & SignalOnTrack(track)));
+ SetSignalVariant(tile, track, sigvar);
}
MarkTileDirtyByTile(tile);
@@ -701,6 +744,7 @@
/** Build many signals by dragging; AutoSignals
* @param tile start tile of drag
+ * @param flags operation to perform
* @param p1 end tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
@@ -739,13 +783,13 @@
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);
+ signals = GetPresentSignals(tile) & SignalOnTrack(track);
if (signals == 0) signals = SignalOnTrack(track); /* Can this actually occur? */
- // copy signal/semaphores style (independent of CTRL)
- semaphores = GetSignalVariant(tile) != SIG_ELECTRIC;
+ /* copy signal/semaphores style (independent of CTRL) */
+ semaphores = GetSignalVariant(tile, track) != SIG_ELECTRIC;
} else { // no signals exist, drag a two-way signal stretch
signals = SignalOnTrack(track);
}
@@ -760,7 +804,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);
@@ -779,7 +823,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);
}
@@ -788,6 +832,15 @@
/** Build signals on a stretch of track.
* Stub for the unified signal builder/remover
+ * @param tile start tile of drag
+ * @param flags operation to perform
+ * @param p1 end tile of drag
+ * @param p2 various bitstuffed elements
+ * - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
+ * - p2 = (bit 4) - 0 = signals, 1 = semaphores
+ * - p2 = (bit 5) - 0 = build, 1 = remove signals
+ * - p2 = (bit 24-31) - user defined signals_density
* @see CmdSignalTrackHelper
*/
int32 CmdBuildSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -797,10 +850,12 @@
/** Remove signals
* @param tile coordinates where signal is being deleted from
- * @param various bitstuffed elements, only track information is used
- * - p1 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
- * - p1 = (bit 3) - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
- * - p1 = (bit 4) - 0 = signals, 1 = semaphores
+ * @param flags operation to perform
+ * @param p1 various bitstuffed elements, only track information is used
+ * - (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
+ * - (bit 3) - override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
+ * - (bit 4) - 0 = signals, 1 = semaphores
+ * @param p2 unused
*/
int32 CmdRemoveSingleSignal(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -808,7 +863,7 @@
if (!ValParamTrackOrientation(track) ||
!IsTileType(tile, MP_RAILWAY) ||
- !EnsureNoVehicle(tile) ||
+ !EnsureNoVehicleOnGround(tile) ||
!HasSignalOnTrack(tile, track)) {
return CMD_ERROR;
}
@@ -820,13 +875,13 @@
/* Do it? */
if (flags & DC_EXEC) {
- _m[tile].m3 &= ~SignalOnTrack(track);
+ SetPresentSignals(tile, GetPresentSignals(tile) & ~SignalOnTrack(track));
/* removed last signal from tile? */
- if (GB(_m[tile].m3, 4, 4) == 0) {
- SB(_m[tile].m2, 4, 4, 0);
+ if (GetPresentSignals(tile) == 0) {
+ SetSignalStates(tile, 0);
SetHasSignals(tile, false);
- SetSignalVariant(tile, SIG_ELECTRIC); // remove any possible semaphores
+ SetSignalVariant(tile, INVALID_TRACK, SIG_ELECTRIC); // remove any possible semaphores
}
SetSignalsOnBothDir(tile, track);
@@ -840,6 +895,15 @@
/** Remove signals on a stretch of track.
* Stub for the unified signal builder/remover
+ * @param tile start tile of drag
+ * @param flags operation to perform
+ * @param p1 end tile of drag
+ * @param p2 various bitstuffed elements
+ * - p2 = (bit 0- 2) - track-orientation, valid values: 0-5 (Track enum)
+ * - p2 = (bit 3) - 1 = override signal/semaphore, or pre/exit/combo signal (CTRL-toggle)
+ * - p2 = (bit 4) - 0 = signals, 1 = semaphores
+ * - p2 = (bit 5) - 0 = build, 1 = remove signals
+ * - p2 = (bit 24-31) - user defined signals_density
* @see CmdSignalTrackHelper
*/
int32 CmdRemoveSignalTrack(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -865,17 +929,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));
@@ -906,6 +970,7 @@
/** Convert one rail type to the other. You can convert normal rail to
* monorail/maglev easily or vice-versa.
* @param tile end tile of rail conversion drag
+ * @param flags operation to perform
* @param p1 start tile of drag
* @param p2 new railtype to convert to
*/
@@ -921,7 +986,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);
@@ -969,7 +1034,7 @@
if (!CheckTileOwnership(tile) && _current_player != OWNER_WATER)
return CMD_ERROR;
- if (!EnsureNoVehicle(tile))
+ if (!EnsureNoVehicleOnGround(tile))
return CMD_ERROR;
if (flags & DC_EXEC) {
@@ -1027,7 +1092,7 @@
#include "table/track_land.h"
-static void DrawSingleSignal(TileIndex tile, byte condition, uint image, uint pos)
+static void DrawSingleSignal(TileIndex tile, Track track, byte condition, uint image, uint pos)
{
bool side = (_opt.road_side != 0) && _patches.signal_side;
static const Point SignalPositions[2][12] = {
@@ -1064,10 +1129,10 @@
/* _signal_base is set by our NewGRF Action 5 loader. If it is 0 then we
* just draw the standard signals, else we get the offset from _signal_base
* and draw that sprite. All the signal sprites are loaded sequentially. */
- if (_signal_base == 0 || (GetSignalType(tile) == 0 && GetSignalVariant(tile) == SIG_ELECTRIC)) {
- sprite = SignalBase[side][GetSignalVariant(tile)][GetSignalType(tile)] + image + condition;
+ if (_signal_base == 0 || (GetSignalType(tile, track) == SIGTYPE_NORMAL && GetSignalVariant(tile, track) == SIG_ELECTRIC)) {
+ sprite = SignalBase[side][GetSignalVariant(tile, track)][GetSignalType(tile, track)] + image + condition;
} else {
- sprite = _signal_base + (GetSignalType(tile) - 1) * 16 + GetSignalVariant(tile) * 64 + image + condition;
+ sprite = _signal_base + (GetSignalType(tile, track) - 1) * 16 + GetSignalVariant(tile, track) * 64 + image + condition;
}
AddSortableSpriteToDraw(sprite, PAL_NONE, x, y, 1, 1, 10, GetSlopeZ(x,y));
@@ -1175,9 +1240,6 @@
* Draw ground sprite and track bits
* @param ti TileInfo
* @param track TrackBits to draw
- * @param earth Draw as earth
- * @param snow Draw as snow
- * @param flat Always draw foundation
*/
static void DrawTrackBits(TileInfo* ti, TrackBits track)
{
@@ -1186,7 +1248,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) ||
@@ -1210,8 +1272,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;
}
@@ -1224,7 +1286,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);
@@ -1240,33 +1302,33 @@
static void DrawSignals(TileIndex tile, TrackBits rails)
{
-#define MAYBE_DRAW_SIGNAL(x,y,z) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, GetSingleSignalState(tile, x), y - 0x4FB, z)
+#define MAYBE_DRAW_SIGNAL(x,y,z,t) if (IsSignalPresent(tile, x)) DrawSingleSignal(tile, t, GetSingleSignalState(tile, x), y - 0x4FB, z)
if (!(rails & TRACK_BIT_Y)) {
if (!(rails & TRACK_BIT_X)) {
if (rails & TRACK_BIT_LEFT) {
- MAYBE_DRAW_SIGNAL(2, 0x509, 0);
- MAYBE_DRAW_SIGNAL(3, 0x507, 1);
+ MAYBE_DRAW_SIGNAL(2, 0x509, 0, TRACK_LEFT);
+ MAYBE_DRAW_SIGNAL(3, 0x507, 1, TRACK_LEFT);
}
if (rails & TRACK_BIT_RIGHT) {
- MAYBE_DRAW_SIGNAL(0, 0x509, 2);
- MAYBE_DRAW_SIGNAL(1, 0x507, 3);
+ MAYBE_DRAW_SIGNAL(0, 0x509, 2, TRACK_RIGHT);
+ MAYBE_DRAW_SIGNAL(1, 0x507, 3, TRACK_RIGHT);
}
if (rails & TRACK_BIT_UPPER) {
- MAYBE_DRAW_SIGNAL(3, 0x505, 4);
- MAYBE_DRAW_SIGNAL(2, 0x503, 5);
+ MAYBE_DRAW_SIGNAL(3, 0x505, 4, TRACK_UPPER);
+ MAYBE_DRAW_SIGNAL(2, 0x503, 5, TRACK_UPPER);
}
if (rails & TRACK_BIT_LOWER) {
- MAYBE_DRAW_SIGNAL(1, 0x505, 6);
- MAYBE_DRAW_SIGNAL(0, 0x503, 7);
+ MAYBE_DRAW_SIGNAL(1, 0x505, 6, TRACK_LOWER);
+ MAYBE_DRAW_SIGNAL(0, 0x503, 7, TRACK_LOWER);
}
} else {
- MAYBE_DRAW_SIGNAL(3, 0x4FB, 8);
- MAYBE_DRAW_SIGNAL(2, 0x4FD, 9);
+ MAYBE_DRAW_SIGNAL(3, 0x4FB, 8, TRACK_X);
+ MAYBE_DRAW_SIGNAL(2, 0x4FD, 9, TRACK_X);
}
} else {
- MAYBE_DRAW_SIGNAL(3, 0x4FF, 10);
- MAYBE_DRAW_SIGNAL(2, 0x501, 11);
+ MAYBE_DRAW_SIGNAL(3, 0x4FF, 10, TRACK_Y);
+ MAYBE_DRAW_SIGNAL(2, 0x501, 11, TRACK_Y);
}
}
@@ -1282,11 +1344,11 @@
DrawTrackBits(ti, rails);
- if (_display_opt & DO_FULL_DETAIL) DrawTrackDetails(ti);
+ if (HASBIT(_display_opt, DO_FULL_DETAIL)) DrawTrackDetails(ti);
if (HasSignals(ti->tile)) DrawSignals(ti->tile, rails);
} else {
- // draw depot/waypoint
+ /* draw depot/waypoint */
const DrawTileSprites* dts;
const DrawTileSeqStruct* dtss;
uint32 relocation;
@@ -1301,8 +1363,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
@@ -1311,12 +1373,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;
@@ -1346,7 +1408,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;
@@ -1371,7 +1433,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)) {
@@ -1433,15 +1495,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];
@@ -1450,25 +1512,26 @@
static bool SetSignalsEnumProc(TileIndex tile, void* data, Trackdir trackdir, uint length, byte* state)
{
SetSignalsData* ssd = (SetSignalsData*)data;
+ Track track = TrackdirToTrack(trackdir);
if (!IsTileType(tile, MP_RAILWAY)) return false;
- // the tile has signals?
- if (HasSignalOnTrack(tile, TrackdirToTrack(trackdir))) {
+ /* the tile has signals? */
+ if (HasSignalOnTrack(tile, track)) {
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.
- ssd->has_presignal |= IsPresignalEntry(tile);
+ /* remember if this block has a presignal. */
+ ssd->has_presignal |= IsPresignalEntry(tile, track);
}
- if (HasSignalOnTrackdir(tile, trackdir) && IsPresignalExit(tile)) {
- // this is an exit signal that points out from the segment
+ if (HasSignalOnTrackdir(tile, trackdir) && IsPresignalExit(tile, track)) {
+ /* 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++;
@@ -1526,21 +1589,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;
}
@@ -1595,44 +1658,45 @@
{
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;
+ uint signals = GetSignalStates(tile);
+ Track track = TrackdirToTrack(ssd->bit[i]);
- // presignals don't turn green if there is at least one presignal exit and none are free
- if (IsPresignalEntry(tile)) {
+ /* presignals don't turn green if there is at least one presignal exit and none are free */
+ if (IsPresignalEntry(tile, track)) {
int ex = ssd->presignal_exits, exfree = ssd->presignal_exits_free;
- // subtract for dual combo signals so they don't count themselves
- if (IsPresignalExit(tile) && HasSignalOnTrackdir(tile, ssd->bit[i])) {
+ /* subtract for dual combo signals so they don't count themselves */
+ if (IsPresignalExit(tile, track) && 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
- if ((bit & m2) == 0) continue;
+ /* turn red */
+ if ((bit & signals) == 0) continue;
} else {
- // turn green
- if ((bit & m2) != 0) continue;
+ /* turn green */
+ if ((bit & signals) != 0) continue;
}
/* Update signals on the other side of this exit-combo signal; it changed. */
- if (IsPresignalExit(tile)) {
+ if (IsPresignalExit(tile, track)) {
if (ssd->cur_stack != NUM_SSD_STACK) {
ssd->next_tile[ssd->cur_stack] = tile;
ssd->next_dir[ssd->cur_stack] = _dir_from_track[ssd->bit[i]];
@@ -1642,8 +1706,8 @@
}
}
- // it changed, so toggle it
- _m[tile].m2 = m2 ^ bit;
+ /* it changed, so toggle it */
+ SetSignalStates(tile, signals ^ bit);
MarkTileDirtyByTile(tile);
}
}
@@ -1657,23 +1721,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);
+ FollowTrack(tile, 0xC000 | TRANSPORT_RAIL, 0, 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];
}
@@ -1766,7 +1830,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);
@@ -1853,7 +1917,7 @@
}
-static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Track(TileIndex tile, TransportType mode, uint sub_mode)
{
if (mode != TRANSPORT_RAIL) return 0;
@@ -1867,11 +1931,8 @@
case RAIL_TILE_SIGNALS: {
uint32 ret = GetTrackBits(tile) * 0x101;
- byte a;
- uint16 b;
-
- a = _m[tile].m3;
- b = _m[tile].m2;
+ byte a = GetPresentSignals(tile);
+ uint b = GetSignalStates(tile);
b &= a;
@@ -1879,13 +1940,13 @@
* direction), we pretend them to be green. (So if
* signals are only one way, the other way will
* implicitely become `red' */
- if ((a & 0xC0) == 0) b |= 0xC0;
- if ((a & 0x30) == 0) b |= 0x30;
+ if ((a & 0xC) == 0) b |= 0xC;
+ if ((a & 0x3) == 0) b |= 0x3;
- if ((b & 0x80) == 0) ret |= 0x10070000;
- if ((b & 0x40) == 0) ret |= 0x07100000;
- if ((b & 0x20) == 0) ret |= 0x20080000;
- if ((b & 0x10) == 0) ret |= 0x08200000;
+ if ((b & 0x8) == 0) ret |= 0x10070000;
+ if ((b & 0x4) == 0) ret |= 0x07100000;
+ if ((b & 0x2) == 0) ret |= 0x20080000;
+ if ((b & 0x1) == 0) ret |= 0x08200000;
return ret;
}
@@ -1913,14 +1974,34 @@
break;
case RAIL_TILE_SIGNALS: {
- const StringID signal_type[] = {
- STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS,
- STR_RAILROAD_TRACK_WITH_PRESIGNALS,
- STR_RAILROAD_TRACK_WITH_EXITSIGNALS,
- STR_RAILROAD_TRACK_WITH_COMBOSIGNALS
+ const StringID signal_type[4][4] = {
+ {
+ STR_RAILROAD_TRACK_WITH_NORMAL_SIGNALS,
+ STR_RAILROAD_TRACK_WITH_NORMAL_PRESIGNALS,
+ STR_RAILROAD_TRACK_WITH_NORMAL_EXITSIGNALS,
+ STR_RAILROAD_TRACK_WITH_NORMAL_COMBOSIGNALS
+ },
+ {
+ STR_RAILROAD_TRACK_WITH_NORMAL_PRESIGNALS,
+ STR_RAILROAD_TRACK_WITH_PRESIGNALS,
+ STR_RAILROAD_TRACK_WITH_PRE_EXITSIGNALS,
+ STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS
+ },
+ {
+ STR_RAILROAD_TRACK_WITH_NORMAL_EXITSIGNALS,
+ STR_RAILROAD_TRACK_WITH_PRE_EXITSIGNALS,
+ STR_RAILROAD_TRACK_WITH_EXITSIGNALS,
+ STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS
+ },
+ {
+ STR_RAILROAD_TRACK_WITH_NORMAL_COMBOSIGNALS,
+ STR_RAILROAD_TRACK_WITH_PRE_COMBOSIGNALS,
+ STR_RAILROAD_TRACK_WITH_EXIT_COMBOSIGNALS,
+ STR_RAILROAD_TRACK_WITH_COMBOSIGNALS
+ }
};
- td->str = signal_type[GetSignalType(tile)];
+ td->str = signal_type[GetSignalType(tile, TRACK_UPPER)][GetSignalType(tile, TRACK_LOWER)];
break;
}
@@ -1960,7 +2041,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 5a8b295aa345 -r 4cc327ad39d5 src/rail_gui.cpp
--- a/src/rail_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/rail_gui.cpp Sat Jun 02 19:59:29 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"
@@ -71,7 +72,7 @@
static void PlaceRail_NE(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_FIX_Y);
+ VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_RAIL_NE);
}
static void PlaceRail_E(TileIndex tile)
@@ -82,12 +83,12 @@
static void PlaceRail_NW(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_FIX_X);
+ VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_RAIL_NW);
}
static void PlaceRail_AutoRail(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_RAILDIRS);
+ VpStartPlaceSizing(tile, VPM_RAILDIRS, DDSP_PLACE_AUTORAIL);
}
static void PlaceExtraDepotRail(TileIndex tile, uint16 extra)
@@ -150,13 +151,13 @@
static void PlaceRail_Station(TileIndex tile)
{
if (_remove_button_clicked) {
- DoCommandP(tile, 0, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_REMOVE_STATION);
} else if (_railstation.dragdrop) {
- VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y_LIMITED, DDSP_BUILD_STATION);
VpSetPlaceSizingLimit(_patches.station_spread);
} else {
DoCommandP(tile,
- _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16),
+ _railstation.orientation | (_railstation.numtracks << 8) | (_railstation.platlength << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
}
@@ -167,7 +168,7 @@
byte trackstat;
uint i;
- trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL);
+ trackstat = (byte)GetTileTrackStatus(tile, TRANSPORT_RAIL, 0);
if (trackstat & TRACK_BIT_VERT) // N-S direction
trackstat = (_tile_fract_coords.x <= _tile_fract_coords.y) ? TRACK_BIT_RIGHT : TRACK_BIT_LEFT;
@@ -196,7 +197,7 @@
static void PlaceRail_Bridge(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_OR_Y);
+ VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
}
void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2)
@@ -222,12 +223,12 @@
static void PlaceRail_ConvertRail(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_ConvertRailArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_CONVERT_RAIL);
}
static void PlaceRail_AutoSignals(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_SIGNALDIRS);
+ VpStartPlaceSizing(tile, VPM_SIGNALDIRS, DDSP_BUILD_SIGNALS);
}
@@ -491,7 +492,7 @@
return;
case WE_PLACE_DRAG: {
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
return;
}
@@ -500,25 +501,44 @@
TileIndex start_tile = e->we.place.starttile;
TileIndex end_tile = e->we.place.tile;
- if (e->we.place.userdata == VPM_X_OR_Y) {
- ResetObjectToPlace();
- ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
- } else if (e->we.place.userdata == VPM_RAILDIRS) {
- bool old = _remove_button_clicked;
- if (_ctrl_pressed) _remove_button_clicked = true;
- HandleAutodirPlacement();
- _remove_button_clicked = old;
- } else if (e->we.place.userdata == VPM_SIGNALDIRS) {
- HandleAutoSignalPlacement();
- } else if ((e->we.place.userdata & 0xF) == VPM_X_AND_Y) {
- if (GUIPlaceProcDragXY(e)) break;
+ switch (e->we.place.select_proc) {
+ case DDSP_BUILD_BRIDGE:
+ ResetObjectToPlace();
+ ShowBuildBridgeWindow(start_tile, end_tile, _cur_railtype);
+ break;
- if ((e->we.place.userdata >> 4) == GUI_PlaceProc_ConvertRailArea >> 4)
+ case DDSP_PLACE_AUTORAIL: {
+ bool old = _remove_button_clicked;
+ if (_ctrl_pressed) _remove_button_clicked = true;
+ HandleAutodirPlacement();
+ _remove_button_clicked = old;
+ break;
+ }
+
+ case DDSP_BUILD_SIGNALS:
+ HandleAutoSignalPlacement();
+ break;
+
+ case DDSP_DEMOLISH_AREA:
+ GUIPlaceProcDragXY(e);
+ break;
+
+ case DDSP_REMOVE_STATION:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound1E, CMD_REMOVE_FROM_RAILROAD_STATION | CMD_MSG(STR_CANT_REMOVE_PART_OF_STATION));
+ break;
+
+ case DDSP_CONVERT_RAIL:
DoCommandP(end_tile, start_tile, _cur_railtype, CcPlaySound10, CMD_CONVERT_RAIL | CMD_MSG(STR_CANT_CONVERT_RAIL));
- } else if (e->we.place.userdata == VPM_X_AND_Y_LIMITED) {
- HandleStationPlacement(start_tile, end_tile);
- } else {
- DoRailroadTrack(e->we.place.userdata & 1);
+ break;
+
+ case DDSP_BUILD_STATION:
+ HandleStationPlacement(start_tile, end_tile);
+ break;
+
+ case DDSP_PLACE_RAIL_NE:
+ case DDSP_PLACE_RAIL_NW:
+ DoRailroadTrack(e->we.place.select_proc == DDSP_PLACE_RAIL_NE ? TRACK_X : TRACK_Y);
+ break;
}
}
break;
@@ -645,7 +665,7 @@
if (!_railstation.orientation) Swap(w, h);
DoCommandP(TileXY(sx, sy),
- _railstation.orientation | (w << 8) | (h << 16),
+ _railstation.orientation | (w << 8) | (h << 16) | (_ctrl_pressed << 24),
_cur_railtype | (_railstation.station_class << 8) | (_railstation.station_type << 16), CcStation,
CMD_BUILD_RAILROAD_STATION | CMD_NO_WATER | CMD_AUTO | CMD_MSG(STR_100F_CAN_T_BUILD_RAILROAD_STATION));
}
@@ -737,7 +757,7 @@
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_X, _railstation.station_class, _railstation.station_type)) {
- StationPickerDrawSprite(32, 16, _cur_railtype, 2);
+ StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 2);
}
_cur_dpi = old_dpi;
}
@@ -747,7 +767,7 @@
old_dpi = _cur_dpi;
_cur_dpi = &tmp_dpi;
if (!DrawStationTile(32, 16, _cur_railtype, AXIS_Y, _railstation.station_class, _railstation.station_type)) {
- StationPickerDrawSprite(32, 16, _cur_railtype, 3);
+ StationPickerDrawSprite(32, 16, _cur_railtype, INVALID_ROADTYPE, 3);
}
_cur_dpi = old_dpi;
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/rail_map.h
--- a/src/rail_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/rail_map.h Sat Jun 02 19:59:29 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
@@ -8,13 +10,21 @@
#include "tile.h"
+/** Different types of Rail-related tiles */
enum RailTileType {
- RAIL_TILE_NORMAL = 0,
- RAIL_TILE_SIGNALS = 1,
- RAIL_TILE_WAYPOINT = 2,
- RAIL_TILE_DEPOT = 3,
+ RAIL_TILE_NORMAL = 0, ///< Normal rail tile without signals
+ RAIL_TILE_SIGNALS = 1, ///< Normal rail tile with signals
+ RAIL_TILE_WAYPOINT = 2, ///< Waypoint (X or Y direction)
+ RAIL_TILE_DEPOT = 3, ///< Depot (one entrance)
};
+/**
+ * Returns the RailTileType (normal with or without signals,
+ * waypoint or depot).
+ * @param t the tile to get the information from
+ * @pre IsTileType(t, MP_RAILWAY)
+ * @return the RailTileType
+ */
static inline RailTileType GetRailTileType(TileIndex t)
{
assert(IsTileType(t, MP_RAILWAY));
@@ -24,23 +34,32 @@
/**
* Returns whether this is plain rails, with or without signals. Iow, if this
* tiles RailTileType is RAIL_TILE_NORMAL or RAIL_TILE_SIGNALS.
+ * @param t the tile to get the information from
+ * @pre IsTileType(t, MP_RAILWAY)
+ * @return true if and only if the tile is normal rail (with or without signals)
*/
-static inline bool IsPlainRailTile(TileIndex tile)
+static inline bool IsPlainRailTile(TileIndex t)
{
- RailTileType rtt = GetRailTileType(tile);
+ RailTileType rtt = GetRailTileType(t);
return rtt == RAIL_TILE_NORMAL || rtt == RAIL_TILE_SIGNALS;
}
/**
* Checks if a rail tile has signals.
+ * @param t the tile to get the information from
+ * @pre IsTileType(t, MP_RAILWAY)
+ * @return true if and only if the tile has signals
*/
-static inline bool HasSignals(TileIndex tile)
+static inline bool HasSignals(TileIndex t)
{
- return GetRailTileType(tile) == RAIL_TILE_SIGNALS;
+ return GetRailTileType(t) == RAIL_TILE_SIGNALS;
}
/**
* Add/remove the 'has signal' bit from the RailTileType
+ * @param tile the tile to add/remove the signals to/from
+ * @param signals whether the rail tile should have signals or not
+ * @pre IsPlainRailTile(tile)
*/
static inline void SetHasSignals(TileIndex tile, bool signals)
{
@@ -48,135 +67,198 @@
SB(_m[tile].m5, 6, 1, signals);
}
-
+/**
+ * Is this tile a rail depot?
+ * @param t the tile to get the information from
+ * @pre IsTileType(t, MP_RAILWAY)
+ * @return true if and only if the tile is a rail depot
+ */
static inline bool IsRailDepot(TileIndex t)
{
return GetRailTileType(t) == RAIL_TILE_DEPOT;
}
-
+/**
+ * Is this tile a rail waypoint?
+ * @param t the tile to get the information from
+ * @pre IsTileType(t, MP_RAILWAY)
+ * @return true if and only if the tile is a rail waypoint
+ */
static inline bool IsRailWaypoint(TileIndex t)
{
return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
}
+/**
+ * Gets the rail type of the given tile
+ * @param t the tile to get the rail type from
+ * @return the rail type of the tile
+ */
static inline RailType GetRailType(TileIndex t)
{
return (RailType)GB(_m[t].m3, 0, 4);
}
+/**
+ * Sets the track bits of the given tile
+ * @param t the tile to set the track bits of
+ * @param r the new track bits for the tile
+ */
static inline void SetRailType(TileIndex t, RailType r)
{
SB(_m[t].m3, 0, 4, r);
}
+/**
+ * Gets the rail type of the given tile
+ * @param t the tile to get the rail type from
+ * @return the rail type of the tile
+ */
static inline TrackBits GetTrackBits(TileIndex tile)
{
return (TrackBits)GB(_m[tile].m5, 0, 6);
}
+/**
+ * Sets the track bits of the given tile
+ * @param t the tile to set the track bits of
+ * @param b the new track bits for the tile
+ */
static inline void SetTrackBits(TileIndex t, TrackBits b)
{
SB(_m[t].m5, 0, 6, b);
}
/**
- * Returns whether the given track is present on the given tile. Tile must be
- * a plain rail tile (IsPlainRailTile()).
+ * Returns whether the given track is present on the given tile.
+ * @param tile the tile to check the track presence of
+ * @param track the track to search for on the tile
+ * @pre IsPlainRailTile(tile)
+ * @return true if and only if the given track exists on the tile
*/
static inline bool HasTrack(TileIndex tile, Track track)
{
return HASBIT(GetTrackBits(tile), track);
}
-
+/**
+ * Returns the direction the depot is facing to
+ * @param t the tile to get the depot facing from
+ * @pre IsRailDepotTile(t)
+ * @return the direction the depot is facing
+ */
static inline DiagDirection GetRailDepotDirection(TileIndex t)
{
return (DiagDirection)GB(_m[t].m5, 0, 2);
}
+/**
+ * Returns the axis of the waypoint
+ * @param t the tile to get the waypoint axis from
+ * @pre IsRailWaypointTile(t)
+ * @return the axis of the waypoint
+ */
static inline Axis GetWaypointAxis(TileIndex t)
{
return (Axis)GB(_m[t].m5, 0, 1);
}
+/**
+ * Returns the track of the waypoint
+ * @param t the tile to get the waypoint track from
+ * @pre IsRailWaypointTile(t)
+ * @return the track of the waypoint
+ */
static inline Track GetRailWaypointTrack(TileIndex t)
{
return AxisToTrack(GetWaypointAxis(t));
}
+/**
+ * Returns the track bits of the waypoint
+ * @param t the tile to get the waypoint track bits from
+ * @pre IsRailWaypointTile(t)
+ * @return the track bits of the waypoint
+ */
static inline TrackBits GetRailWaypointBits(TileIndex t)
{
return TrackToTrackBits(GetRailWaypointTrack(t));
}
+/**
+ * Returns waypoint index (for the waypoint pool)
+ * @param t the tile to get the waypoint index from
+ * @pre IsRailWaypointTile(t)
+ * @return the waypoint index
+ */
static inline WaypointID GetWaypointIndex(TileIndex t)
{
return (WaypointID)_m[t].m2;
}
+/** Type of signal, i.e. how does the signal behave? */
enum SignalType {
- SIGTYPE_NORMAL = 0, // normal signal
- SIGTYPE_ENTRY = 1, // presignal block entry
- SIGTYPE_EXIT = 2, // presignal block exit
- SIGTYPE_COMBO = 3 // presignal inter-block
+ SIGTYPE_NORMAL = 0, ///< normal signal
+ SIGTYPE_ENTRY = 1, ///< presignal block entry
+ SIGTYPE_EXIT = 2, ///< presignal block exit
+ SIGTYPE_COMBO = 3 ///< presignal inter-block
};
-static inline SignalType GetSignalType(TileIndex t)
+static inline SignalType GetSignalType(TileIndex t, Track track)
{
assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
- return (SignalType)GB(_m[t].m2, 0, 2);
+ byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
+ return (SignalType)GB(_m[t].m2, pos, 2);
}
-static inline void SetSignalType(TileIndex t, SignalType s)
+static inline void SetSignalType(TileIndex t, Track track, SignalType s)
{
assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
- SB(_m[t].m2, 0, 2, s);
+ byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
+ SB(_m[t].m2, pos, 2, s);
+ if (track == INVALID_TRACK) SB(_m[t].m2, 4, 2, s);
}
-static inline bool IsPresignalEntry(TileIndex t)
+static inline bool IsPresignalEntry(TileIndex t, Track track)
{
- return GetSignalType(t) == SIGTYPE_ENTRY || GetSignalType(t) == SIGTYPE_COMBO;
+ return GetSignalType(t, track) == SIGTYPE_ENTRY || GetSignalType(t, track) == SIGTYPE_COMBO;
}
-static inline bool IsPresignalExit(TileIndex t)
+static inline bool IsPresignalExit(TileIndex t, Track track)
{
- return GetSignalType(t) == SIGTYPE_EXIT || GetSignalType(t) == SIGTYPE_COMBO;
+ return GetSignalType(t, track) == SIGTYPE_EXIT || GetSignalType(t, track) == SIGTYPE_COMBO;
}
static inline void CycleSignalSide(TileIndex t, Track track)
{
byte sig;
- byte pos = 6;
- if (track == TRACK_LOWER || track == TRACK_RIGHT) pos = 4;
+ byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 6;
sig = GB(_m[t].m3, pos, 2);
if (--sig == 0) sig = 3;
SB(_m[t].m3, pos, 2, sig);
}
-
+/** Variant of the signal, i.e. how does the signal look? */
enum SignalVariant {
- SIG_ELECTRIC = 0,
- SIG_SEMAPHORE = 1
+ SIG_ELECTRIC = 0, ///< Light signal
+ SIG_SEMAPHORE = 1 ///< Old-fashioned semaphore signal
};
-static inline SignalVariant GetSignalVariant(TileIndex t)
+static inline SignalVariant GetSignalVariant(TileIndex t, Track track)
{
- return (SignalVariant)GB(_m[t].m2, 2, 1);
+ byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 6 : 2;
+ return (SignalVariant)GB(_m[t].m2, pos, 1);
}
-static inline void SetSignalVariant(TileIndex t, SignalVariant v)
+static inline void SetSignalVariant(TileIndex t, Track track, SignalVariant v)
{
- SB(_m[t].m2, 2, 1, v);
-}
-
-static inline bool IsSignalPresent(TileIndex t, byte signalbit)
-{
- return HASBIT(_m[t].m3, signalbit + 4);
+ byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 6 : 2;
+ SB(_m[t].m2, pos, 1, v);
+ if (track == INVALID_TRACK) SB(_m[t].m2, 6, 1, v);
}
/** These are states in which a signal can be. Currently these are only two, so
@@ -184,15 +266,71 @@
* normal boolean evaluation, since that will make future additions easier.
*/
enum SignalState {
- SIGNAL_STATE_RED = 0,
- SIGNAL_STATE_GREEN = 1,
+ SIGNAL_STATE_RED = 0, ///< The signal is red
+ SIGNAL_STATE_GREEN = 1, ///< The signal is green
};
+/**
+ * Set the states of the signals (Along/AgainstTrackDir)
+ * @param tile the tile to set the states for
+ * @param state the new state
+ */
+static inline void SetSignalStates(TileIndex tile, uint state)
+{
+ SB(_m[tile].m4, 4, 4, state);
+}
+
+/**
+ * Set the states of the signals (Along/AgainstTrackDir)
+ * @param tile the tile to set the states for
+ * @param state the new state
+ */
+static inline uint GetSignalStates(TileIndex tile)
+{
+ return GB(_m[tile].m4, 4, 4);
+}
+
+/**
+ * Get the state of a single signal
+ * @param t the tile to get the signal state for
+ * @param signalbit the signal
+ * @return the state of the signal
+ */
static inline SignalState GetSingleSignalState(TileIndex t, byte signalbit)
{
- return (SignalState)HASBIT(_m[t].m2, signalbit + 4);
+ return (SignalState)HASBIT(GetSignalStates(t), signalbit);
}
+/**
+ * Set whether the given signals are present (Along/AgainstTrackDir)
+ * @param tile the tile to set the present signals for
+ * @param signals the signals that have to be present
+ */
+static inline void SetPresentSignals(TileIndex tile, uint signals)
+{
+ SB(_m[tile].m3, 4, 4, signals);
+}
+
+/**
+ * Get whether the given signals are present (Along/AgainstTrackDir)
+ * @param tile the tile to get the present signals for
+ * @return the signals that are present
+ */
+static inline uint GetPresentSignals(TileIndex tile)
+{
+ return GB(_m[tile].m3, 4, 4);
+}
+
+/**
+ * Checks whether the given signals is present
+ * @param t the tile to check on
+ * @param signalbit the signal
+ * @return true if and only if the signal is present
+ */
+static inline bool IsSignalPresent(TileIndex t, byte signalbit)
+{
+ return HASBIT(GetPresentSignals(t), signalbit);
+}
/**
* Checks for the presence of signals (either way) on the given track on the
@@ -203,7 +341,7 @@
assert(IsValidTrack(track));
return
GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
- (_m[tile].m3 & SignalOnTrack(track)) != 0;
+ (GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
}
/**
@@ -218,7 +356,7 @@
assert (IsValidTrackdir(trackdir));
return
GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
- _m[tile].m3 & SignalAlongTrackdir(trackdir);
+ GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
}
/**
@@ -231,7 +369,7 @@
{
assert(IsValidTrackdir(trackdir));
assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
- return _m[tile].m2 & SignalAlongTrackdir(trackdir) ?
+ return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
}
@@ -241,21 +379,21 @@
*/
RailType GetTileRailType(TileIndex tile);
-
+/** The ground 'under' the rail */
enum RailGroundType {
- RAIL_GROUND_BARREN = 0,
- RAIL_GROUND_GRASS = 1,
- RAIL_GROUND_FENCE_NW = 2,
- RAIL_GROUND_FENCE_SE = 3,
- RAIL_GROUND_FENCE_SENW = 4,
- RAIL_GROUND_FENCE_NE = 5,
- RAIL_GROUND_FENCE_SW = 6,
- RAIL_GROUND_FENCE_NESW = 7,
- RAIL_GROUND_FENCE_VERT1 = 8,
- RAIL_GROUND_FENCE_VERT2 = 9,
- RAIL_GROUND_FENCE_HORIZ1 = 10,
- RAIL_GROUND_FENCE_HORIZ2 = 11,
- RAIL_GROUND_ICE_DESERT = 12,
+ RAIL_GROUND_BARREN = 0, ///< Nothing (dirt)
+ RAIL_GROUND_GRASS = 1, ///< Grassy
+ RAIL_GROUND_FENCE_NW = 2, ///< Grass with a fence at the NW edge
+ RAIL_GROUND_FENCE_SE = 3, ///< Grass with a fence at the SE edge
+ RAIL_GROUND_FENCE_SENW = 4, ///< Grass with a fence at the NW and SE edges
+ RAIL_GROUND_FENCE_NE = 5, ///< Grass with a fence at the NE edge
+ RAIL_GROUND_FENCE_SW = 6, ///< Grass with a fence at the SW edge
+ RAIL_GROUND_FENCE_NESW = 7, ///< Grass with a fence at the NE and SW edges
+ RAIL_GROUND_FENCE_VERT1 = 8, ///< Grass with a fence at the western side
+ RAIL_GROUND_FENCE_VERT2 = 9, ///< Grass with a fence at the eastern side
+ RAIL_GROUND_FENCE_HORIZ1 = 10, ///< Grass with a fence at the southern side
+ RAIL_GROUND_FENCE_HORIZ2 = 11, ///< Grass with a fence at the northern side
+ RAIL_GROUND_ICE_DESERT = 12, ///< Icy or sandy
};
static inline void SetRailGroundType(TileIndex t, RailGroundType rgt)
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/railtypes.h
--- a/src/railtypes.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/railtypes.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/resource.h
--- a/src/resource.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/resource.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file resource.h */
+
//{{NO_DEPENDENCIES}}
// Microsoft Developer Studio generated include file.
// Used by ttd.rc
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/road.h
--- a/src/road.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/road.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,10 +1,74 @@
/* $Id$ */
+/** @file road.h */
+
#ifndef ROAD_H
#define ROAD_H
#include "helpers.hpp"
+/**
+ * The different roadtypes we support
+ * @note currently only ROADTYPE_ROAD is supported.
+ */
+enum RoadType {
+ ROADTYPE_ROAD = 0,
+ ROADTYPE_TRAM = 1,
+ ROADTYPE_HWAY = 2, ///< Only a placeholder. Not sure what we are going to do with this road type.
+ ROADTYPE_END,
+ INVALID_ROADTYPE = 0xFF
+};
+DECLARE_POSTFIX_INCREMENT(RoadType);
+
+/**
+ * The different roadtypes we support, but then a bitmask of them
+ * @note currently only ROADTYPES_ROAD is supported.
+ */
+enum RoadTypes {
+ ROADTYPES_NONE = 0,
+ ROADTYPES_ROAD = 1 << ROADTYPE_ROAD,
+ ROADTYPES_TRAM = 1 << ROADTYPE_TRAM,
+ ROADTYPES_HWAY = 1 << ROADTYPE_HWAY,
+ ROADTYPES_ROADTRAM = ROADTYPES_ROAD | ROADTYPES_TRAM,
+ ROADTYPES_ROADHWAY = ROADTYPES_ROAD | ROADTYPES_HWAY,
+ ROADTYPES_TRAMHWAY = ROADTYPES_TRAM | ROADTYPES_HWAY,
+ ROADTYPES_ALL = ROADTYPES_ROAD | ROADTYPES_TRAM | ROADTYPES_HWAY,
+};
+DECLARE_ENUM_AS_BIT_SET(RoadTypes);
+
+/**
+ * Whether the given roadtype is valid.
+ * @param rt the roadtype to check for validness
+ * @return true if and only if valid
+ */
+static inline bool IsValidRoadType(RoadType rt)
+{
+ return rt == ROADTYPE_ROAD || rt == ROADTYPE_TRAM;
+}
+
+/**
+ * Are the given bits pointing to valid roadtypes?
+ * @param rts the roadtypes to check for validness
+ * @return true if and only if valid
+ */
+static inline bool AreValidRoadTypes(RoadTypes rts)
+{
+ return HASBIT(rts, ROADTYPE_ROAD) || HASBIT(rts, ROADTYPE_TRAM);
+}
+
+/**
+ * Maps a RoadType to the corresponding RoadTypes value
+ */
+static inline RoadTypes RoadTypeToRoadTypes(RoadType rt)
+{
+ return (RoadTypes)(1 << rt);
+}
+
+static inline RoadTypes ComplementRoadTypes(RoadTypes r)
+{
+ return (RoadTypes)(ROADTYPES_ALL ^ r);
+}
+
enum RoadBits {
ROAD_NONE = 0U,
ROAD_NW = 1U,
@@ -46,8 +110,11 @@
* @param remove the roadbits that are going to be removed
* @param owner the actual owner of the roadbits of the tile
* @param edge_road are the removed bits from a town?
+ * @param rt the road type to remove the bits from
* @return true when it is allowed to remove the road bits
*/
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road);
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt);
+
+void DrawTramCatenary(TileInfo *ti, RoadBits tram);
#endif /* ROAD_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/road_cmd.cpp
--- a/src/road_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/road_cmd.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road_cmd.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -24,6 +26,9 @@
#include "sound.h"
#include "yapf/yapf.h"
#include "depot.h"
+#include "newgrf.h"
+#include "station_map.h"
+#include "tunnel_map.h"
static uint CountRoadBits(RoadBits r)
@@ -38,37 +43,40 @@
}
-bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road)
+bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road, RoadType rt)
{
RoadBits present;
RoadBits n;
*edge_road = true;
- if (_game_mode == GM_EDITOR) return true;
+ if (_game_mode == GM_EDITOR || remove == ROAD_NONE) return true;
- // Only do the special processing for actual players.
- if (!IsValidPlayer(_current_player)) return true;
+ /* Water can always flood and towns can always remove "normal" road pieces.
+ * Towns are not be allowed to remove non "normal" road pieces, like tram
+ * tracks as that would result in trams that cannot turn. */
+ if (_current_player == OWNER_WATER ||
+ (rt == ROADTYPE_ROAD && !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;
- if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1)) & ROAD_NW) n |= ROAD_SE;
- 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;
+ present = GetAnyRoadBits(tile, rt);
+ if (present & ROAD_NE && GetAnyRoadBits(TILE_ADDXY(tile, -1, 0), rt) & ROAD_SW) n |= ROAD_NE;
+ if (present & ROAD_SE && GetAnyRoadBits(TILE_ADDXY(tile, 0, 1), rt) & ROAD_NW) n |= ROAD_SE;
+ if (present & ROAD_SW && GetAnyRoadBits(TILE_ADDXY(tile, 1, 0), rt) & ROAD_NE) n |= ROAD_SW;
+ if (present & ROAD_NW && GetAnyRoadBits(TILE_ADDXY(tile, 0, -1), rt) & 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);
@@ -81,22 +89,23 @@
return true;
}
-static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road)
+static bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, bool *edge_road, RoadType rt)
{
- return CheckAllowRemoveRoad(tile, remove, IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile), edge_road);
+ return CheckAllowRemoveRoad(tile, remove, GetRoadOwner(tile, rt), edge_road, rt);
}
/** Delete a piece of road.
* @param tile tile where to remove road from
+ * @param flags operation to perform
* @param p1 bit 0..3 road pieces to remove (RoadBits)
+ * bit 4..5 road type
* @param p2 unused
*/
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;
Town *t;
/* true if the roadpiece was always removeable,
* false if it was a center piece. Affects town ratings drop */
@@ -104,9 +113,29 @@
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- if (!IsTileType(tile, MP_STREET)) return CMD_ERROR;
+ RoadType rt = (RoadType)GB(p1, 4, 2);
+ if (!IsValidRoadType(rt)) return CMD_ERROR;
- owner = IsLevelCrossingTile(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile);
+ Owner owner;
+ switch (GetTileType(tile)) {
+ case MP_STREET:
+ owner = GetRoadOwner(tile, rt);
+ break;
+
+ case MP_STATION:
+ if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
+ owner = GetTileOwner(tile);
+ break;
+
+ case MP_TUNNELBRIDGE:
+ if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) ||
+ (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR;
+ owner = GetTileOwner(tile);
+ break;
+
+ default:
+ return CMD_ERROR;
+ }
if (owner == OWNER_TOWN && _game_mode != GM_EDITOR) {
t = GetTownByTile(tile);
@@ -115,18 +144,53 @@
}
RoadBits pieces = Extract(p1);
-
- if (!CheckAllowRemoveRoad(tile, pieces, &edge_road)) return CMD_ERROR;
+ RoadTypes rts = GetRoadTypes(tile);
+ /* The tile doesn't have the given road type */
+ if (!HASBIT(rts, rt)) return CMD_ERROR;
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
+ if (!CheckAllowRemoveRoad(tile, pieces, &edge_road, rt)) return CMD_ERROR;
- // check if you're allowed to remove the street owned by a town
- // removal allowance depends on difficulty setting
+ 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 */
if (!CheckforTownRating(flags, t, ROAD_REMOVE)) return CMD_ERROR;
+ if (!IsTileType(tile, MP_STREET)) {
+ /* If it's the last roadtype, just clear the whole tile */
+ if (rts == RoadTypeToRoadTypes(rt)) return DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
+
+ int32 cost;
+ if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+ TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
+ /* Pay for *every* tile of the bridge or tunnel */
+ cost = (DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile) + 1) * _price.remove_road;
+ if (flags & DC_EXEC) {
+ SetRoadTypes(other_end, GetRoadTypes(other_end) & ~RoadTypeToRoadTypes(rt));
+ SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
+
+ /* Mark tiles diry that have been repaved */
+ MarkTileDirtyByTile(tile);
+ MarkTileDirtyByTile(other_end);
+ if (IsBridge(tile)) {
+ TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
+
+ for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
+ }
+ }
+ } else {
+ cost = _price.remove_road;
+ if (flags & DC_EXEC) {
+ SetRoadTypes(tile, GetRoadTypes(tile) & ~RoadTypeToRoadTypes(rt));
+ MarkTileDirtyByTile(tile);
+ }
+ }
+ return cost;
+ }
+
switch (GetRoadTileType(tile)) {
case ROAD_TILE_NORMAL: {
- RoadBits present = GetRoadBits(tile);
+ RoadBits present = GetRoadBits(tile, rt);
RoadBits c = pieces;
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
@@ -137,18 +201,28 @@
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;
+ if (c == ROAD_NONE) return CMD_ERROR;
if (flags & DC_EXEC) {
ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
present ^= c;
- if (present == 0) {
- DoClearSquare(tile);
+ if (present == ROAD_NONE) {
+ RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
+ if (rts == ROADTYPES_NONE) {
+ DoClearSquare(tile);
+ } else {
+ SetRoadBits(tile, ROAD_NONE, rt);
+ SetRoadTypes(tile, rts);
+ }
} else {
- SetRoadBits(tile, present);
+ /* When bits are removed, you *always* end up with something that
+ * is not a complete straight road tile. However, trams do not have
+ * onewayness, so they cannot remove it either. */
+ if (rt != ROADTYPE_TRAM) SetDisallowedRoadDirections(tile, DRD_NONE);
+ SetRoadBits(tile, present, rt);
MarkTileDirtyByTile(tile);
}
}
@@ -160,10 +234,21 @@
return CMD_ERROR;
}
+ /* Don't allow road to be removed from the crossing when there is tram;
+ * we can't draw the crossing without trambits ;) */
+ if (rt == ROADTYPE_ROAD && HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM)) return CMD_ERROR;
+
if (flags & DC_EXEC) {
- ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
+ if (rt == ROADTYPE_ROAD) {
+ ChangeTownRating(t, -road_remove_cost[(byte)edge_road], RATING_ROAD_MINIMUM);
+ }
- MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
+ RoadTypes rts = GetRoadTypes(tile) & ComplementRoadTypes(RoadTypeToRoadTypes(rt));
+ if (rts == ROADTYPES_NONE) {
+ MakeRailNormal(tile, GetTileOwner(tile), GetCrossingRailBits(tile), GetRailType(tile));
+ } else {
+ SetRoadTypes(tile, rts);
+ }
MarkTileDirtyByTile(tile);
YapfNotifyTrackLayoutChange(tile, FindFirstTrack(GetTrackBits(tile)));
}
@@ -178,7 +263,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 +271,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 +301,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 _price.terraform;
@@ -225,21 +310,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 : _price.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 _price.terraform;
@@ -249,7 +334,10 @@
/** Build a piece of road.
* @param tile tile where to build road
+ * @param flags operation to perform
* @param p1 bit 0..3 road pieces to build (RoadBits)
+ * bit 4..5 road type
+ * bit 6..7 disallowed directions to toggle
* @param p2 the town that is building the road (0 if not applicable)
*/
int32 CmdBuildRoad(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -257,6 +345,7 @@
int32 cost = 0;
int32 ret;
RoadBits existing = ROAD_NONE;
+ RoadBits all_bits = ROAD_NONE;
Slope tileh;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -267,26 +356,51 @@
RoadBits pieces = Extract(p1);
+ RoadType rt = (RoadType)GB(p1, 4, 2);
+ if (!IsValidRoadType(rt)) return CMD_ERROR;
+
+ DisallowedRoadDirections toggle_drd = (DisallowedRoadDirections)GB(p1, 6, 2);
+
tileh = GetTileSlope(tile, NULL);
switch (GetTileType(tile)) {
case MP_STREET:
switch (GetRoadTileType(tile)) {
- case ROAD_TILE_NORMAL:
+ case ROAD_TILE_NORMAL: {
if (HasRoadWorks(tile)) return_cmd_error(STR_ROAD_WORKS_IN_PROGRESS);
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
- existing = GetRoadBits(tile);
+ all_bits = GetAllRoadBits(tile);
+ if (!HASBIT(GetRoadTypes(tile), rt)) break;
+
+ existing = GetRoadBits(tile, rt);
+ RoadBits merged = existing | pieces;
+ bool crossing = (merged != ROAD_X && merged != ROAD_Y);
+ if (rt != ROADTYPE_TRAM && (GetDisallowedRoadDirections(tile) != DRD_NONE || toggle_drd != DRD_NONE) && crossing) {
+ /* Junctions cannot be one-way */
+ return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
+ }
if ((existing & pieces) == pieces) {
+ /* We only want to set the (dis)allowed road directions */
+ if (toggle_drd != DRD_NONE && rt != ROADTYPE_TRAM && GetRoadOwner(tile, ROADTYPE_ROAD) == _current_player) {
+ if (crossing) return_cmd_error(STR_ERR_ONEWAY_ROADS_CAN_T_HAVE_JUNCTION);
+
+ /* Ignore half built tiles */
+ if (flags & DC_EXEC && rt != ROADTYPE_TRAM && (existing == ROAD_X || existing == ROAD_Y)) {
+ SetDisallowedRoadDirections(tile, GetDisallowedRoadDirections(tile) ^ toggle_drd);
+ MarkTileDirtyByTile(tile);
+ }
+ return 0;
+ }
return_cmd_error(STR_1007_ALREADY_BUILT);
}
- if (!EnsureNoVehicle(tile)) return CMD_ERROR;
- break;
+ } break;
case ROAD_TILE_CROSSING:
- if (pieces != GetCrossingRoadBits(tile)) { // XXX is this correct?
- return_cmd_error(STR_1007_ALREADY_BUILT);
- }
- goto do_clear;
+ if (HASBIT(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+ all_bits = GetCrossingRoadBits(tile);
+ if (pieces & ComplementRoadBits(all_bits)) goto do_clear;
+ break;
default:
case ROAD_TILE_DEPOT:
@@ -323,16 +437,32 @@
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)));
- MakeRoadCrossing(tile, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), p2);
+ /* Always add road to the roadtypes (can't draw without it) */
+ MakeRoadCrossing(tile, _current_player, _current_player, _current_player, GetTileOwner(tile), roaddir, GetRailType(tile), RoadTypeToRoadTypes(rt) | ROADTYPES_ROAD, p2);
MarkTileDirtyByTile(tile);
}
- return _price.build_road * 2;
+ return _price.build_road * (rt == ROADTYPE_ROAD ? 2 : 4);
}
+ case MP_STATION:
+ if (!IsDriveThroughStopTile(tile)) return CMD_ERROR;
+ if (HASBIT(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+ /* Don't allow "upgrading" the roadstop when vehicles are already driving on it */
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+ break;
+
+ case MP_TUNNELBRIDGE:
+ if ((IsTunnel(tile) && GetTunnelTransportType(tile) != TRANSPORT_ROAD) ||
+ (IsBridge(tile) && GetBridgeTransportType(tile) != TRANSPORT_ROAD)) return CMD_ERROR;
+ if (HASBIT(GetRoadTypes(tile), rt)) return_cmd_error(STR_1007_ALREADY_BUILT);
+ /* Don't allow "upgrading" the bridge/tunnel when vehicles are already driving on it */
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+ break;
+
default:
do_clear:;
ret = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
@@ -340,26 +470,68 @@
cost += ret;
}
- ret = CheckRoadSlope(tileh, &pieces, existing);
- /* Return an error if we need to build a foundation (ret != 0) but the
- * current patch-setting is turned off (or stupid AI@work) */
- if (CmdFailed(ret) || (ret != 0 && (!_patches.build_on_slopes || _is_old_ai_player)))
- return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
-
- cost += ret;
+ if (all_bits != pieces) {
+ /* Check the foundation/slopes when adding road/tram bits */
+ ret = CheckRoadSlope(tileh, &pieces, all_bits | existing);
+ /* Return an error if we need to build a foundation (ret != 0) but the
+ * current patch-setting is turned off (or stupid AI@work) */
+ if (CmdFailed(ret) || (ret != 0 && (!_patches.build_on_slopes || _is_old_ai_player))) {
+ return_cmd_error(STR_1000_LAND_SLOPED_IN_WRONG_DIRECTION);
+ }
+ 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) * _price.build_road;
+ if (IsTileType(tile, MP_TUNNELBRIDGE)) {
+ /* Pay for *every* tile of the bridge or tunnel */
+ cost *= DistanceManhattan(IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile), tile);
+ }
if (flags & DC_EXEC) {
- if (IsTileType(tile, MP_STREET)) {
- SetRoadBits(tile, existing | pieces);
- } else {
- MakeRoadNormal(tile, _current_player, pieces, p2);
+ switch (GetTileType(tile)) {
+ case MP_STREET: {
+ RoadTileType rtt = GetRoadTileType(tile);
+ if (existing == ROAD_NONE || rtt == ROAD_TILE_CROSSING) {
+ SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
+ SetRoadOwner(tile, rt, _current_player);
+ }
+ if (rtt != ROAD_TILE_CROSSING) SetRoadBits(tile, existing | pieces, rt);
+ } break;
+
+ case MP_TUNNELBRIDGE: {
+ TileIndex other_end = IsTunnel(tile) ? GetOtherTunnelEnd(tile) : GetOtherBridgeEnd(tile);
+
+ SetRoadTypes(other_end, GetRoadTypes(other_end) | RoadTypeToRoadTypes(rt));
+ SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
+
+ /* Mark tiles diry that have been repaved */
+ MarkTileDirtyByTile(other_end);
+ MarkTileDirtyByTile(tile);
+ if (IsBridge(tile)) {
+ TileIndexDiff delta = TileOffsByDiagDir(GetBridgeRampDirection(tile));
+
+ for (TileIndex t = tile + delta; t != other_end; t += delta) MarkTileDirtyByTile(t);
+ }
+ } break;
+
+ case MP_STATION:
+ SetRoadTypes(tile, GetRoadTypes(tile) | RoadTypeToRoadTypes(rt));
+ break;
+
+ default:
+ MakeRoadNormal(tile, pieces, RoadTypeToRoadTypes(rt), p2, _current_player, _current_player, _current_player);
+ break;
+ }
+
+ if (rt != ROADTYPE_TRAM && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
+ existing |= pieces;
+ SetDisallowedRoadDirections(tile, (existing == ROAD_X || existing == ROAD_Y) ?
+ GetDisallowedRoadDirections(tile) ^ toggle_drd : DRD_NONE);
}
MarkTileDirtyByTile(tile);
@@ -377,15 +549,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) {
@@ -400,22 +572,30 @@
/** Build a long piece of road.
* @param end_tile end tile of drag
+ * @param flags operation to perform
* @param p1 start tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
+ * - p2 = (bit 3 + 4) - road type
+ * - p2 = (bit 5) - set road direction
*/
int32 CmdBuildLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
TileIndex start_tile, tile;
int32 cost, ret;
+ bool had_bridge = false;
+ bool had_success = false;
+ DisallowedRoadDirections drd = DRD_NORTHBOUND;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
if (p1 >= MapSize()) return CMD_ERROR;
start_tile = p1;
+ RoadType rt = (RoadType)GB(p2, 3, 2);
+ if (!IsValidRoadType(rt)) return CMD_ERROR;
/* Only drag in X or Y direction dictated by the direction variable */
if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis
@@ -426,24 +606,41 @@
TileIndex t = start_tile;
start_tile = end_tile;
end_tile = t;
- p2 ^= IS_INT_INSIDE(p2&3, 1, 3) ? 3 : 0;
+ p2 ^= IS_INT_INSIDE(p2 & 3, 1, 3) ? 3 : 0;
+ drd = DRD_SOUTHBOUND;
}
+ /* On the X-axis, we have to swap the initial bits, so they
+ * will be interpreted correctly in the GTTS. Futhermore
+ * when you just 'click' on one tile to build them. */
+ if (HASBIT(p2, 2) == (start_tile == end_tile)) drd ^= DRD_BOTH;
+ /* No disallowed direction bits have to be toggled */
+ if (!HASBIT(p2, 5)) drd = DRD_NONE;
+
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;
- ret = DoCommand(tile, bits, 0, flags, CMD_BUILD_ROAD);
+ ret = DoCommand(tile, drd << 6 | rt << 4 | bits, 0, flags, CMD_BUILD_ROAD);
if (CmdFailed(ret)) {
if (_error_message != STR_1007_ALREADY_BUILT) return CMD_ERROR;
_error_message = INVALID_STRING_ID;
} else {
- cost += ret;
+ had_success = true;
+ /* Only pay for the upgrade on one side of the bridge */
+ if (IsBridgeTile(tile)) {
+ if ((!had_bridge || GetBridgeRampDirection(tile) == DIAGDIR_SE || GetBridgeRampDirection(tile) == DIAGDIR_SW)) {
+ cost += ret;
+ }
+ had_bridge = true;
+ } else {
+ cost += ret;
+ }
}
if (tile == end_tile) break;
@@ -451,16 +648,18 @@
tile += HASBIT(p2, 2) ? TileDiffXY(0, 1) : TileDiffXY(1, 0);
}
- return (cost == 0) ? CMD_ERROR : cost;
+ return !had_success ? CMD_ERROR : cost;
}
/** Remove a long piece of road.
* @param end_tile end tile of drag
+ * @param flags operation to perform
* @param p1 start tile of drag
* @param p2 various bitstuffed elements
* - p2 = (bit 0) - start tile starts in the 2nd half of tile (p2 & 1)
* - p2 = (bit 1) - end tile starts in the 2nd half of tile (p2 & 2)
* - p2 = (bit 2) - direction: 0 = along x-axis, 1 = along y-axis (p2 & 4)
+ * - p2 = (bit 3 + 4) - road type
*/
int32 CmdRemoveLongRoad(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -472,6 +671,8 @@
if (p1 >= MapSize()) return CMD_ERROR;
start_tile = p1;
+ RoadType rt = (RoadType)GB(p2, 3, 2);
+ if (!IsValidRoadType(rt)) return CMD_ERROR;
/* Only drag in X or Y direction dictated by the direction variable */
if (!HASBIT(p2, 2) && TileY(start_tile) != TileY(end_tile)) return CMD_ERROR; // x-axis
@@ -487,16 +688,16 @@
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);
+ ret = DoCommand(tile, rt << 4 | bits, 0, flags, CMD_REMOVE_ROAD);
if (!CmdFailed(ret)) cost += ret;
}
@@ -510,7 +711,9 @@
/** Build a road depot.
* @param tile tile where to build the depot
+ * @param flags operation to perform
* @param p1 bit 0..1 entrance direction (DiagDirection)
+ * bit 2..3 road type
* @param p2 unused
*
* @todo When checking for the tile slope,
@@ -525,6 +728,9 @@
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
DiagDirection dir = Extract(p1);
+ RoadType rt = (RoadType)GB(p1, 2, 2);
+
+ if (!IsValidRoadType(rt)) return CMD_ERROR;
tileh = GetTileSlope(tile, NULL);
if (tileh != SLOPE_FLAT && (
@@ -547,7 +753,7 @@
dep->xy = tile;
dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index;
- MakeRoadDepot(tile, _current_player, dir);
+ MakeRoadDepot(tile, _current_player, dir, rt);
MarkTileDirtyByTile(tile);
}
return cost + _price.build_road_depot;
@@ -569,7 +775,7 @@
{
switch (GetRoadTileType(tile)) {
case ROAD_TILE_NORMAL: {
- RoadBits b = GetRoadBits(tile);
+ RoadBits b = GetAllRoadBits(tile);
#define M(x) (1 << (x))
/* Clear the road if only one piece is on the tile OR the AI tries
@@ -578,7 +784,16 @@
((flags & DC_AI_BUILDING) && IsTileOwner(tile, OWNER_TOWN)) ||
!(flags & DC_AUTO)
) {
- return DoCommand(tile, b, 0, flags, CMD_REMOVE_ROAD);
+ RoadTypes rts = GetRoadTypes(tile);
+ int32 ret = 0;
+ for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
+ if (HASBIT(rts, rt)) {
+ int32 tmp_ret = DoCommand(tile, rt << 4 | GetRoadBits(tile, rt), 0, flags, CMD_REMOVE_ROAD);
+ if (CmdFailed(tmp_ret)) return tmp_ret;
+ ret += tmp_ret;
+ }
+ }
+ return ret;
}
return_cmd_error(STR_1801_MUST_REMOVE_ROAD_FIRST);
}
@@ -621,13 +836,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;
@@ -655,33 +870,104 @@
};
/**
+ * Whether to draw unpaved roads regardless of the town zone.
+ * By default, OpenTTD always draws roads as unpaved if they are on a desert
+ * tile or above the snowline. Newgrf files, however, can set a bit that allows
+ * paved roads to be built on desert tiles as they would be on grassy tiles.
+ *
+ * @param tile The tile the road is on
+ * @param roadside What sort of road this is
+ * @return True if the road should be drawn unpaved regardless of the roadside.
+ */
+static bool AlwaysDrawUnpavedRoads(TileIndex tile, Roadside roadside)
+{
+ return (IsOnSnow(tile) &&
+ !(_opt.landscape == LT_TROPIC && HasGrfMiscBit(GMB_DESERT_PAVED_ROADS) &&
+ roadside != ROADSIDE_BARREN && roadside != ROADSIDE_GRASS && roadside != ROADSIDE_GRASS_ROAD_WORKS));
+}
+
+/**
+ * Draws the catenary for the given tile
+ * @param ti information about the tile (slopes, height etc)
+ * @param tram the roadbits for the tram
+ */
+void DrawTramCatenary(TileInfo *ti, RoadBits tram)
+{
+ /* Don't draw the catenary under a low bridge */
+ if (MayHaveBridgeAbove(ti->tile) && IsBridgeAbove(ti->tile) && !HASBIT(_transparent_opt, TO_BUILDINGS)) {
+ uint height = GetBridgeHeight(GetNorthernBridgeEnd(ti->tile));
+
+ if (height <= GetTileMaxZ(ti->tile) + TILE_HEIGHT) return;
+ }
+
+ SpriteID front;
+ SpriteID back;
+
+ if (ti->tileh != SLOPE_FLAT) {
+ back = SPR_TRAMWAY_BACK_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1];
+ front = SPR_TRAMWAY_FRONT_WIRES_SLOPED + _road_sloped_sprites[ti->tileh - 1];
+ } else {
+ back = SPR_TRAMWAY_BASE + _road_backpole_sprites_1[tram];
+ front = SPR_TRAMWAY_BASE + _road_frontwire_sprites_1[tram];
+ }
+
+ SpriteID pal = PAL_NONE;
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
+ SETBIT(front, PALETTE_MODIFIER_TRANSPARENT);
+ SETBIT(back, PALETTE_MODIFIER_TRANSPARENT);
+ pal = PALETTE_TO_TRANSPARENT;
+ }
+
+ AddSortableSpriteToDraw(back, pal, ti->x, ti->y, 16, 16, 0x1F, ti->z);
+ AddSortableSpriteToDraw(front, pal, ti->x, ti->y, 16, 16, 0x1F, ti->z);
+}
+
+/**
+ * Draws details on/around the road
+ * @param img the sprite to draw
+ * @param ti the tile to draw on
+ * @param dx the offset from the top of the BB of the tile
+ * @param dy the offset from the top of the BB of the tile
+ * @param h the height of the sprite to draw
+ */
+static void DrawRoadDetail(SpriteID img, TileInfo *ti, int dx, int dy, int h)
+{
+ int x = ti->x | dx;
+ int y = ti->y | dy;
+ byte z = ti->z;
+ if (ti->tileh != SLOPE_FLAT) z = GetSlopeZ(x, y);
+ AddSortableSpriteToDraw(img, PAL_NONE, x, y, 2, 2, h, z);
+}
+
+/**
* Draw ground sprite and road pieces
* @param ti TileInfo
- * @param road RoadBits to draw
*/
static void DrawRoadBits(TileInfo* ti)
{
- RoadBits road = GetRoadBits(ti->tile);
+ RoadBits road = GetRoadBits(ti->tile, ROADTYPE_ROAD);
+ RoadBits tram = GetRoadBits(ti->tile, ROADTYPE_TRAM);
+
const DrawRoadTileStruct *drts;
SpriteID image = 0;
SpriteID pal = PAL_NONE;
Roadside roadside;
if (ti->tileh != SLOPE_FLAT) {
- int foundation = GetRoadFoundation(ti->tileh, road);
+ int foundation = GetRoadFoundation(ti->tileh, road | tram);
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;
}
- if (image == 0) image = _road_tile_sprites_1[road];
+ if (image == 0) image = _road_tile_sprites_1[road != ROAD_NONE ? road : tram];
roadside = GetRoadside(ti->tile);
- if (IsOnSnow(ti->tile)) {
+ if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
image += 19;
} else {
switch (roadside) {
@@ -694,22 +980,40 @@
DrawGroundSprite(image, pal);
+ if (road != ROAD_NONE) {
+ DisallowedRoadDirections drd = GetDisallowedRoadDirections(ti->tile);
+ if (drd != DRD_NONE) {
+ DrawRoadDetail(SPR_ONEWAY_BASE + drd - 1 + ((road == ROAD_X) ? 0 : 3), ti, 8, 8, 0);
+ }
+ }
+
+ /* For tram we overlay the road graphics with either tram tracks only
+ * (when there is actual road beneath the trams) or with tram tracks
+ * and some dirts which hides the road graphics */
+ if (tram != ROAD_NONE) {
+ if (ti->tileh != SLOPE_FLAT) {
+ image = _road_sloped_sprites[ti->tileh - 1] + SPR_TRAMWAY_SLOPED_OFFSET;
+ } else {
+ image = _road_tile_sprites_1[tram] - SPR_ROAD_Y;
+ }
+ image += (road == ROAD_NONE) ? SPR_TRAMWAY_TRAM : SPR_TRAMWAY_OVERLAY;
+ DrawGroundSprite(image, pal);
+ }
+
if (HasRoadWorks(ti->tile)) {
- // Road works
- DrawGroundSprite(road & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE);
+ /* Road works */
+ DrawGroundSprite((road | tram) & ROAD_X ? SPR_EXCAVATION_X : SPR_EXCAVATION_Y, PAL_NONE);
return;
}
- // Return if full detail is disabled, or we are zoomed fully out.
- if (!(_display_opt & DO_FULL_DETAIL) || _cur_dpi->zoom == 2) return;
+ if (tram != ROAD_NONE) DrawTramCatenary(ti, tram);
- // Draw extra details.
+ /* Return if full detail is disabled, or we are zoomed fully out. */
+ if (!HASBIT(_display_opt, DO_FULL_DETAIL) || _cur_dpi->zoom > ZOOM_LVL_DETAIL) return;
+
+ /* 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;
- byte z = ti->z;
- if (ti->tileh != SLOPE_FLAT) z = GetSlopeZ(x, y);
- AddSortableSpriteToDraw(drts->image, PAL_NONE, x, y, 2, 2, 0x10, z);
+ DrawRoadDetail(drts->image, ti, drts->subcoord_x, drts->subcoord_y, 0x10);
}
}
@@ -723,6 +1027,7 @@
case ROAD_TILE_CROSSING: {
SpriteID image;
SpriteID pal = PAL_NONE;
+ Roadside roadside = GetRoadside(ti->tile);
if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, ti->tileh);
@@ -731,10 +1036,10 @@
if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++;
if (IsCrossingBarred(ti->tile)) image += 2;
- if (IsOnSnow(ti->tile)) {
+ if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) {
image += 8;
} else {
- switch (GetRoadside(ti->tile)) {
+ switch (roadside) {
case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break;
case ROADSIDE_GRASS: break;
default: image += 4; break; // Paved
@@ -742,6 +1047,10 @@
}
DrawGroundSprite(image, pal);
+ if (HASBIT(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) {
+ DrawGroundSprite(SPR_TRAMWAY_OVERLAY + (GetCrossingRoadAxis(ti->tile) ^ 1), pal);
+ DrawTramCatenary(ti, GetCrossingRoadBits(ti->tile));
+ }
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
break;
}
@@ -756,14 +1065,19 @@
palette = PLAYER_SPRITE_COLOR(GetTileOwner(ti->tile));
- dts = &_road_depot[GetRoadDepotDirection(ti->tile)];
+ if (HASBIT(GetRoadTypes(ti->tile), ROADTYPE_TRAM)) {
+ dts = &_tram_depot[GetRoadDepotDirection(ti->tile)];
+ } else {
+ dts = &_road_depot[GetRoadDepotDirection(ti->tile)];
+ }
+
DrawGroundSprite(dts->ground_sprite, PAL_NONE);
for (dtss = dts->seq; dtss->image != 0; dtss++) {
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)) {
@@ -785,10 +1099,10 @@
DrawBridgeMiddle(ti);
}
-void DrawRoadDepotSprite(int x, int y, DiagDirection dir)
+void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt)
{
SpriteID palette = PLAYER_SPRITE_COLOR(_local_player);
- const DrawTileSprites* dts = &_road_depot[dir];
+ const DrawTileSprites* dts = (rt == ROADTYPE_TRAM) ? &_tram_depot[dir] : &_road_depot[dir];
const DrawTileSeqStruct* dtss;
x += 33;
@@ -811,7 +1125,7 @@
if (tileh == SLOPE_FLAT) return z;
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
- uint f = GetRoadFoundation(tileh, GetRoadBits(tile));
+ uint f = GetRoadFoundation(tileh, GetAllRoadBits(tile));
if (f != 0) {
if (IsSteepSlope(tileh)) {
@@ -831,7 +1145,7 @@
{
if (tileh == SLOPE_FLAT) return SLOPE_FLAT;
if (GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
- uint f = GetRoadFoundation(tileh, GetRoadBits(tile));
+ uint f = GetRoadFoundation(tileh, GetAllRoadBits(tile));
if (f == 0) return tileh;
if (f < 15) return SLOPE_FLAT; // leveled foundation
@@ -896,11 +1210,11 @@
if (t != NULL) {
grp = GetTownRadiusGroup(t, 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)) {
+ GetRoadTileType(tile) == ROAD_TILE_NORMAL && (GetAllRoadBits(tile) == ROAD_X || GetAllRoadBits(tile) == ROAD_Y)) {
+ if (GetTileSlope(tile, NULL) == SLOPE_FLAT && EnsureNoVehicleOnGround(tile) && CHANCE16(1, 20)) {
StartRoadWorks(tile);
SndPlayTileFx(SND_21_JACKHAMMER, tile);
@@ -951,17 +1265,23 @@
0x0, 0x0, 0x0, 0x10, 0x0, 0x2, 0x8, 0x1A, 0x0, 0x4, 0x1, 0x15, 0x20, 0x26, 0x29, 0x3F,
};
-static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Road(TileIndex tile, TransportType mode, uint sub_mode)
{
+
switch (mode) {
case TRANSPORT_RAIL:
if (!IsLevelCrossing(tile)) return 0;
return GetCrossingRailBits(tile) * 0x101;
case TRANSPORT_ROAD:
+ if ((GetRoadTypes(tile) & sub_mode) == 0) return 0;
switch (GetRoadTileType(tile)) {
- case ROAD_TILE_NORMAL:
- return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile)] * 0x101;
+ case ROAD_TILE_NORMAL: {
+ RoadType rt = (RoadType)FindFirstBit(sub_mode);
+ const uint drd_to_multiplier[DRD_END] = { 0x101, 0x100, 0x1, 0x0 };
+ uint multiplier = drd_to_multiplier[rt == ROADTYPE_TRAM ? DRD_NONE : GetDisallowedRoadDirections(tile)];
+ return HasRoadWorks(tile) ? 0 : _road_trackbits[GetRoadBits(tile, rt)] * multiplier;
+ }
case ROAD_TILE_CROSSING: {
uint32 r = AxisToTrackBits(GetCrossingRoadAxis(tile)) * 0x101;
@@ -1002,8 +1322,12 @@
}
}
-static const byte _roadveh_enter_depot_unk0[4] = {
- 8, 9, 0, 1
+/**
+ * Given the direction the road depot is pointing, this is the direction the
+ * vehicle should be travelling in in order to enter the depot.
+ */
+static const byte _roadveh_enter_depot_dir[4] = {
+ TRACKDIR_X_SW, TRACKDIR_Y_NW, TRACKDIR_X_NE, TRACKDIR_Y_SE
};
static uint32 VehicleEnter_Road(Vehicle *v, TileIndex tile, int x, int y)
@@ -1021,7 +1345,7 @@
case ROAD_TILE_DEPOT:
if (v->type == VEH_ROAD &&
v->u.road.frame == 11 &&
- _roadveh_enter_depot_unk0[GetRoadDepotDirection(tile)] == v->u.road.state) {
+ _roadveh_enter_depot_dir[GetRoadDepotDirection(tile)] == v->u.road.state) {
VehicleEnterDepot(v);
return VETSB_ENTERED_WORMHOLE;
}
@@ -1035,28 +1359,32 @@
static void ChangeTileOwner_Road(TileIndex tile, PlayerID old_player, PlayerID new_player)
{
- if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) == old_player) {
- SetCrossingRoadOwner(tile, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
+ if (GetRoadTileType(tile) == ROAD_TILE_DEPOT) {
+ if (GetTileOwner(tile) == old_player) {
+ if (new_player == PLAYER_SPECTATOR) {
+ DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ } else {
+ SetTileOwner(tile, new_player);
+ }
+ }
+ return;
}
- if (!IsTileOwner(tile, old_player)) return;
+ for (RoadType rt = ROADTYPE_ROAD; rt < ROADTYPE_END; rt++) {
+ if (!HASBIT(GetRoadTypes(tile), rt)) continue;
- if (new_player != PLAYER_SPECTATOR) {
- SetTileOwner(tile, new_player);
- } else {
- switch (GetRoadTileType(tile)) {
- case ROAD_TILE_NORMAL:
- SetTileOwner(tile, OWNER_NONE);
- break;
+ if (GetRoadOwner(tile, rt) == old_player) {
+ SetRoadOwner(tile, rt, new_player == PLAYER_SPECTATOR ? OWNER_NONE : new_player);
+ }
+ }
- case ROAD_TILE_CROSSING:
- MakeRoadNormal(tile, GetCrossingRoadOwner(tile), GetCrossingRoadBits(tile), GetTownIndex(tile));
- break;
-
- default:
- case ROAD_TILE_DEPOT:
- DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
- break;
+ if (IsLevelCrossing(tile)) {
+ if (GetTileOwner(tile) == old_player) {
+ if (new_player == PLAYER_SPECTATOR) {
+ MakeRoadNormal(tile, GetCrossingRoadBits(tile), GetRoadTypes(tile), GetTownIndex(tile), GetRoadOwner(tile, ROADTYPE_ROAD), GetRoadOwner(tile, ROADTYPE_TRAM), GetRoadOwner(tile, ROADTYPE_HWAY));
+ } else {
+ SetTileOwner(tile, new_player);
+ }
}
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/road_cmd.h
--- a/src/road_cmd.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/road_cmd.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,10 +1,12 @@
/* $Id$ */
+/** @file road_cmd.h */
+
#ifndef ROAD_CMD_H
#define ROAD_CMD_H
#include "direction.h"
-void DrawRoadDepotSprite(int x, int y, DiagDirection dir);
+void DrawRoadDepotSprite(int x, int y, DiagDirection dir, RoadType rt);
#endif /* ROAD_CMD_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/road_gui.cpp
--- a/src/road_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/road_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,9 +1,9 @@
/* $Id$ */
+/** @file road_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
-#include "road_cmd.h"
-#include "road_map.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "functions.h"
@@ -16,19 +16,23 @@
#include "sound.h"
#include "command.h"
#include "variables.h"
+#include "road.h"
+#include "road_cmd.h"
+#include "road_map.h"
#include "station_map.h"
//needed for catchments
#include "station.h"
-static void ShowBusStationPicker();
-static void ShowTruckStationPicker();
+static void ShowRVStationPicker(RoadStop::Type rs);
static void ShowRoadDepotPicker();
static bool _remove_button_clicked;
static byte _place_road_flag;
+static RoadType _cur_roadtype;
+
static DiagDirection _road_depot_orientation;
static DiagDirection _road_station_picker_orientation;
@@ -40,18 +44,18 @@
static void PlaceRoad_NE(TileIndex tile)
{
_place_road_flag = (_tile_fract_coords.y >= 8) + 4;
- VpStartPlaceSizing(tile, VPM_FIX_X);
+ VpStartPlaceSizing(tile, VPM_FIX_X, DDSP_PLACE_ROAD_NE);
}
static void PlaceRoad_NW(TileIndex tile)
{
_place_road_flag = (_tile_fract_coords.x >= 8) + 0;
- VpStartPlaceSizing(tile, VPM_FIX_Y);
+ VpStartPlaceSizing(tile, VPM_FIX_Y, DDSP_PLACE_ROAD_NW);
}
static void PlaceRoad_Bridge(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_OR_Y);
+ VpStartPlaceSizing(tile, VPM_X_OR_Y, DDSP_BUILD_BRIDGE);
}
@@ -65,9 +69,52 @@
}
}
+/** Structure holding information per roadtype for several functions */
+struct RoadTypeInfo {
+ StringID err_build_road; ///< Building a normal piece of road
+ StringID err_remove_road; ///< Removing a normal piece of road
+ StringID err_depot; ///< Building a depot
+ StringID err_build_station[2]; ///< Building a bus or truck station
+ StringID err_remove_station[2]; ///< Removing of a bus or truck station
+
+ StringID picker_title[2]; ///< Title for the station picker for bus or truck stations
+ StringID picker_tooltip[2]; ///< Tooltip for the station picker for bus or truck stations
+
+ SpriteID cursor_nesw; ///< Cursor for building NE and SW bits
+ SpriteID cursor_nwse; ///< Cursor for building NW and SE bits
+};
+
+/** What errors/cursors must be shown for several types of roads */
+static const RoadTypeInfo _road_type_infos[] = {
+ {
+ STR_1804_CAN_T_BUILD_ROAD_HERE,
+ STR_1805_CAN_T_REMOVE_ROAD_FROM,
+ STR_1807_CAN_T_BUILD_ROAD_VEHICLE,
+ { STR_1808_CAN_T_BUILD_BUS_STATION, STR_1809_CAN_T_BUILD_TRUCK_STATION },
+ { STR_CAN_T_REMOVE_BUS_STATION, STR_CAN_T_REMOVE_TRUCK_STATION },
+ { STR_3042_BUS_STATION_ORIENTATION, STR_3043_TRUCK_STATION_ORIENT },
+ { STR_3051_SELECT_BUS_STATION_ORIENTATION, STR_3052_SELECT_TRUCK_LOADING_BAY },
+
+ SPR_CURSOR_ROAD_NESW,
+ SPR_CURSOR_ROAD_NWSE,
+ },
+ {
+ STR_1804_CAN_T_BUILD_TRAMWAY_HERE,
+ STR_1805_CAN_T_REMOVE_TRAMWAY_FROM,
+ STR_1807_CAN_T_BUILD_TRAM_VEHICLE,
+ { STR_1808_CAN_T_BUILD_PASSENGER_TRAM_STATION, STR_1809_CAN_T_BUILD_CARGO_TRAM_STATION },
+ { STR_CAN_T_REMOVE_PASSENGER_TRAM_STATION, STR_CAN_T_REMOVE_CARGO_TRAM_STATION },
+ { STR_3042_PASSENGER_TRAM_STATION_ORIENTATION, STR_3043_CARGO_TRAM_STATION_ORIENT },
+ { STR_3051_SELECT_PASSENGER_TRAM_STATION_ORIENTATION, STR_3052_SELECT_CARGO_TRAM_STATION_ORIENTATION },
+
+ SPR_CURSOR_TRAMWAY_NESW,
+ SPR_CURSOR_TRAMWAY_NWSE,
+ },
+};
+
static void PlaceRoad_Tunnel(TileIndex tile)
{
- DoCommandP(tile, 0x200, 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
+ DoCommandP(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, CcBuildRoadTunnel, CMD_BUILD_TUNNEL | CMD_AUTO | CMD_MSG(STR_5016_CAN_T_BUILD_TUNNEL_HERE));
}
static void BuildRoadOutsideStation(TileIndex tile, DiagDirection direction)
@@ -75,24 +122,27 @@
tile += TileOffsByDiagDir(direction);
// if there is a roadpiece just outside of the station entrance, build a connecting route
if (IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL) {
- DoCommandP(tile, DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
+ if (GetRoadBits(tile, _cur_roadtype) != ROAD_NONE) {
+ DoCommandP(tile, _cur_roadtype << 4 | DiagDirToRoadBits(ReverseDiagDir(direction)), 0, NULL, CMD_BUILD_ROAD);
+ }
}
}
void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
if (success) {
+ DiagDirection dir = (DiagDirection)GB(p1, 0, 2);
SndPlayTileFx(SND_1F_SPLAT, tile);
ResetObjectToPlace();
- BuildRoadOutsideStation(tile, (DiagDirection)p1);
+ BuildRoadOutsideStation(tile, dir);
/* For a drive-through road stop build connecting road for other entrance */
- if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir((DiagDirection)p1));
+ if (HASBIT(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir));
}
}
static void PlaceRoad_Depot(TileIndex tile)
{
- DoCommandP(tile, _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1807_CAN_T_BUILD_ROAD_VEHICLE));
+ DoCommandP(tile, _cur_roadtype << 2 | _road_depot_orientation, 0, CcRoadDepot, CMD_BUILD_ROAD_DEPOT | CMD_AUTO | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_depot));
}
static void PlaceRoadStop(TileIndex tile, uint32 p2, uint32 cmd)
@@ -109,24 +159,24 @@
static void PlaceRoad_BusStation(TileIndex tile)
{
if (_remove_button_clicked) {
- DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(STR_CAN_T_REMOVE_BUS_STATION));
+ DoCommandP(tile, 0, RoadStop::BUS, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_station[RoadStop::BUS]));
} else {
- PlaceRoadStop(tile, RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1808_CAN_T_BUILD_BUS_STATION));
+ PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::BUS, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::BUS]));
}
}
static void PlaceRoad_TruckStation(TileIndex tile)
{
if (_remove_button_clicked) {
- DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(STR_CAN_T_REMOVE_TRUCK_STATION));
+ DoCommandP(tile, 0, RoadStop::TRUCK, CcPlaySound1D, CMD_REMOVE_ROAD_STOP | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::TRUCK]));
} else {
- PlaceRoadStop(tile, RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1809_CAN_T_BUILD_TRUCK_STATION));
+ PlaceRoadStop(tile, (_ctrl_pressed << 5) | RoadTypeToRoadTypes(_cur_roadtype) << 2 | RoadStop::TRUCK, CMD_BUILD_ROAD_STOP | CMD_AUTO | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_station[RoadStop::TRUCK]));
}
}
static void PlaceRoad_DemolishArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, 4);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
}
@@ -147,12 +197,12 @@
static void BuildRoadClick_NE(Window *w)
{
- HandlePlacePushButton(w, RTW_ROAD_X, SPR_CURSOR_ROAD_NESW, 1, PlaceRoad_NE);
+ HandlePlacePushButton(w, RTW_ROAD_X, _road_type_infos[_cur_roadtype].cursor_nesw, 1, PlaceRoad_NE);
}
static void BuildRoadClick_NW(Window *w)
{
- HandlePlacePushButton(w, RTW_ROAD_Y, SPR_CURSOR_ROAD_NWSE, 1, PlaceRoad_NW);
+ HandlePlacePushButton(w, RTW_ROAD_Y, _road_type_infos[_cur_roadtype].cursor_nwse, 1, PlaceRoad_NW);
}
@@ -170,13 +220,13 @@
static void BuildRoadClick_BusStation(Window *w)
{
if (_game_mode == GM_EDITOR) return;
- if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowBusStationPicker();
+ if (HandlePlacePushButton(w, RTW_BUS_STATION, SPR_CURSOR_BUS_STATION, 1, PlaceRoad_BusStation)) ShowRVStationPicker(RoadStop::BUS);
}
static void BuildRoadClick_TruckStation(Window *w)
{
if (_game_mode == GM_EDITOR) return;
- if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowTruckStationPicker();
+ if (HandlePlacePushButton(w, RTW_TRUCK_STATION, SPR_CURSOR_TRUCK_STATION, 1, PlaceRoad_TruckStation)) ShowRVStationPicker(RoadStop::TRUCK);
}
static void BuildRoadClick_Bridge(Window *w)
@@ -225,7 +275,7 @@
case WE_CLICK: {
if (e->we.click.widget >= 3) _build_road_button_proc[e->we.click.widget - 3](w);
- } break;
+ } break;
case WE_KEYPRESS:
switch (e->we.keypress.keycode) {
@@ -255,54 +305,49 @@
InvalidateWidget(w, RTW_REMOVE);
w = FindWindowById(WC_BUS_STATION, 0);
- if (w != NULL) WP(w,def_d).close = true;
+ if (w != NULL) WP(w, def_d).close = true;
w = FindWindowById(WC_TRUCK_STATION, 0);
- if (w != NULL) WP(w,def_d).close = true;
+ if (w != NULL) WP(w, def_d).close = true;
w = FindWindowById(WC_BUILD_DEPOT, 0);
- if (w != NULL) WP(w,def_d).close = true;
+ if (w != NULL) WP(w, def_d).close = true;
break;
- case WE_PLACE_DRAG: {
- int sel_method;
- switch (e->we.place.userdata) {
- case 1:
- sel_method = VPM_FIX_X;
+ case WE_PLACE_DRAG:
+ switch (e->we.place.select_proc) {
+ case DDSP_PLACE_ROAD_NE:
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.y & 8) >> 2);
break;
- case 2:
- sel_method = VPM_FIX_Y;
+ case DDSP_PLACE_ROAD_NW:
_place_road_flag = (_place_road_flag & ~2) | ((e->we.place.pt.x & 8) >> 2);
break;
-
- case 4:
- sel_method = VPM_X_AND_Y;
- break;
-
- default:
- sel_method = VPM_X_OR_Y;
- break;
}
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, sel_method);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
return;
- }
case WE_PLACE_MOUSEUP:
if (e->we.place.pt.x != -1) {
TileIndex start_tile = e->we.place.starttile;
TileIndex end_tile = e->we.place.tile;
- if (e->we.place.userdata == 0) {
- ResetObjectToPlace();
- ShowBuildBridgeWindow(start_tile, end_tile, 0x80);
- } else if (e->we.place.userdata != 4) {
- DoCommandP(end_tile, start_tile, _place_road_flag, CcPlaySound1D,
- _remove_button_clicked ?
- CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1805_CAN_T_REMOVE_ROAD_FROM) :
- CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(STR_1804_CAN_T_BUILD_ROAD_HERE));
- } else {
- DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+ switch (e->we.place.select_proc) {
+ case DDSP_BUILD_BRIDGE:
+ ResetObjectToPlace();
+ ShowBuildBridgeWindow(start_tile, end_tile, 0x80 | RoadTypeToRoadTypes(_cur_roadtype));
+ break;
+
+ case DDSP_DEMOLISH_AREA:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+ break;
+
+ case DDSP_PLACE_ROAD_NE:
+ case DDSP_PLACE_ROAD_NW:
+ DoCommandP(end_tile, start_tile, _place_road_flag | (_cur_roadtype << 3) | _ctrl_pressed << 5, CcPlaySound1D,
+ _remove_button_clicked ?
+ CMD_REMOVE_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_remove_road) :
+ CMD_BUILD_LONG_ROAD | CMD_AUTO | CMD_NO_WATER | CMD_MSG(_road_type_infos[_cur_roadtype].err_build_road));
+ break;
}
}
break;
@@ -310,7 +355,7 @@
case WE_PLACE_PRESIZE: {
TileIndex tile = e->we.place.tile;
- DoCommand(tile, 0x200, 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ DoCommand(tile, 0x200 | RoadTypeToRoadTypes(_cur_roadtype), 0, DC_AUTO, CMD_BUILD_TUNNEL);
VpSetPresizeRange(tile, _build_tunnel_endtile == 0 ? tile : _build_tunnel_endtile);
break;
}
@@ -346,12 +391,39 @@
BuildRoadToolbWndProc
};
-void ShowBuildRoadToolbar()
+static const Widget _build_tramway_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 205, 0, 13, STR_1802_TRAMWAY_CONSTRUCTION, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_STICKYBOX, RESIZE_NONE, 7, 206, 217, 0, 13, 0x0, STR_STICKY_BUTTON},
+
+{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_TRAMWAY_NW, STR_180B_BUILD_TRAMWAY_SECTION},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 22, 43, 14, 35, SPR_IMG_TRAMWAY_NE, STR_180B_BUILD_TRAMWAY_SECTION},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 44, 65, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 66, 87, 14, 35, SPR_IMG_ROAD_DEPOT, STR_180C_BUILD_TRAM_VEHICLE_DEPOT},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 88, 109, 14, 35, SPR_IMG_BUS_STATION, STR_180D_BUILD_PASSENGER_TRAM_STATION},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 110, 131, 14, 35, SPR_IMG_TRUCK_BAY, STR_180E_BUILD_CARGO_TRAM_STATION},
+
+{ WWT_IMGBTN, RESIZE_NONE, 7, 132, 173, 14, 35, SPR_IMG_BRIDGE, STR_180F_BUILD_TRAMWAY_BRIDGE},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 174, 195, 14, 35, SPR_IMG_ROAD_TUNNEL, STR_1810_BUILD_TRAMWAY_TUNNEL},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 196, 217, 14, 35, SPR_IMG_REMOVE, STR_1811_TOGGLE_BUILD_REMOVE_FOR_TRAMWAYS},
+{ WIDGETS_END},
+};
+
+static const WindowDesc _build_tramway_desc = {
+ WDP_ALIGN_TBR, 22, 218, 36,
+ WC_BUILD_TOOLBAR, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
+ _build_tramway_widgets,
+ BuildRoadToolbWndProc
+};
+
+void ShowBuildRoadToolbar(RoadType roadtype)
{
if (!IsValidPlayer(_current_player)) return;
+ _cur_roadtype = roadtype;
DeleteWindowById(WC_BUILD_TOOLBAR, 0);
- Window *w = AllocateWindowDesc(&_build_road_desc);
+ Window *w = AllocateWindowDesc(roadtype == ROADTYPE_ROAD ? &_build_road_desc : &_build_tramway_desc);
if (_patches.link_terraform_toolbar) ShowTerraformToolbar(w);
}
@@ -382,6 +454,7 @@
void ShowBuildRoadScenToolbar()
{
+ _cur_roadtype = ROADTYPE_ROAD;
AllocateWindowDescFront(&_build_road_scen_desc, 0);
}
@@ -393,10 +466,10 @@
case WE_PAINT:
DrawWindowWidgets(w);
- DrawRoadDepotSprite(70, 17, DIAGDIR_NE);
- DrawRoadDepotSprite(70, 69, DIAGDIR_SE);
- DrawRoadDepotSprite( 2, 69, DIAGDIR_SW);
- DrawRoadDepotSprite( 2, 17, DIAGDIR_NW);
+ DrawRoadDepotSprite(70, 17, DIAGDIR_NE, _cur_roadtype);
+ DrawRoadDepotSprite(70, 69, DIAGDIR_SE, _cur_roadtype);
+ DrawRoadDepotSprite( 2, 69, DIAGDIR_SW, _cur_roadtype);
+ DrawRoadDepotSprite( 2, 17, DIAGDIR_NW, _cur_roadtype);
break;
case WE_CLICK: {
@@ -409,14 +482,14 @@
SetWindowDirty(w);
break;
}
- } break;
+ } break;
case WE_MOUSELOOP:
- if (WP(w,def_d).close) DeleteWindow(w);
+ if (WP(w, def_d).close) DeleteWindow(w);
break;
case WE_DESTROY:
- if (!WP(w,def_d).close) ResetObjectToPlace();
+ if (!WP(w, def_d).close) ResetObjectToPlace();
break;
}
}
@@ -432,6 +505,17 @@
{ WIDGETS_END},
};
+static const Widget _build_tram_depot_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 139, 0, 13, STR_1806_TRAM_DEPOT_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_PANEL, RESIZE_NONE, 7, 0, 139, 14, 121, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
+{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
+{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
+{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_1813_SELECT_TRAM_VEHICLE_DEPOT},
+{ WIDGETS_END},
+};
+
static const WindowDesc _build_road_depot_desc = {
WDP_AUTO, WDP_AUTO, 140, 122,
WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
@@ -440,15 +524,29 @@
BuildRoadDepotWndProc
};
+static const WindowDesc _build_tram_depot_desc = {
+ WDP_AUTO, WDP_AUTO, 140, 122,
+ WC_BUILD_DEPOT, WC_BUILD_TOOLBAR,
+ WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
+ _build_tram_depot_widgets,
+ BuildRoadDepotWndProc
+};
+
static void ShowRoadDepotPicker()
{
- AllocateWindowDesc(&_build_road_depot_desc);
+ AllocateWindowDesc(_cur_roadtype == ROADTYPE_ROAD ? &_build_road_depot_desc : &_build_tram_depot_desc);
}
static void RoadStationPickerWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_CREATE:
+ /* Trams don't have non-drivethrough stations */
+ if (_cur_roadtype == ROADTYPE_TRAM && _road_station_picker_orientation < DIAGDIR_END) {
+ _road_station_picker_orientation = DIAGDIR_END;
+ }
+ SetWindowWidgetsDisabledState(w, _cur_roadtype == ROADTYPE_TRAM, 3, 4, 5, 6, WIDGET_LIST_END);
+
LowerWindowWidget(w, _road_station_picker_orientation + 3);
LowerWindowWidget(w, _station_show_coverage + 9);
break;
@@ -456,7 +554,7 @@
case WE_PAINT: {
int image;
- if (WP(w,def_d).close) return;
+ if (WP(w, def_d).close) return;
DrawWindowWidgets(w);
@@ -471,18 +569,18 @@
image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE : GFX_TRUCK_BASE;
- StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, image);
- StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, image+1);
- StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, image+2);
- StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, image+3);
+ StationPickerDrawSprite(103, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image);
+ StationPickerDrawSprite(103, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 1);
+ StationPickerDrawSprite(35, 85, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 2);
+ StationPickerDrawSprite(35, 35, RAILTYPE_BEGIN, ROADTYPE_ROAD, image + 3);
image = (w->window_class == WC_BUS_STATION) ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT;
- StationPickerDrawSprite(171, 35, RAILTYPE_BEGIN, image);
- StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, image + 1);
+ StationPickerDrawSprite(171, 35, RAILTYPE_BEGIN, _cur_roadtype, image);
+ StationPickerDrawSprite(171, 85, RAILTYPE_BEGIN, _cur_roadtype, image + 1);
DrawStationCoverageAreaText(2, 146,
- ((w->window_class == WC_BUS_STATION) ? (1<window_class == WC_BUS_STATION) ? (1 << CT_PASSENGERS) : ~(1 << CT_PASSENGERS)),
3);
} break;
@@ -507,7 +605,7 @@
} break;
case WE_MOUSELOOP: {
- if (WP(w,def_d).close) {
+ if (WP(w, def_d).close) {
DeleteWindow(w);
return;
}
@@ -516,67 +614,43 @@
} break;
case WE_DESTROY:
- if (!WP(w,def_d).close) ResetObjectToPlace();
+ if (!WP(w, def_d).close) ResetObjectToPlace();
break;
}
}
-static const Widget _bus_station_picker_widgets[] = {
+static const Widget _rv_station_picker_widgets[] = {
{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 7, 11, 206, 0, 13, STR_3042_BUS_STATION_ORIENTATION, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_CAPTION, RESIZE_NONE, 7, 11, 206, 0, 13, STR_NULL, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_PANEL, RESIZE_NONE, 7, 0, 206, 14, 176, 0x0, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
-{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
-{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
-{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
-{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 17, 66, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
-{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 69, 118, 0x0, STR_3051_SELECT_BUS_STATION_ORIENTATION},
+{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 17, 66, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 69, 118, 0x0, STR_NULL},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
{ WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
{ WWT_LABEL, RESIZE_NONE, 7, 0, 139, 120, 133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},
{ WIDGETS_END},
};
-static const WindowDesc _bus_station_picker_desc = {
+static const WindowDesc _rv_station_picker_desc = {
WDP_AUTO, WDP_AUTO, 207, 177,
WC_BUS_STATION, WC_BUILD_TOOLBAR,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
- _bus_station_picker_widgets,
+ _rv_station_picker_widgets,
RoadStationPickerWndProc
};
-static void ShowBusStationPicker()
+static void ShowRVStationPicker(RoadStop::Type rs)
{
- AllocateWindowDesc(&_bus_station_picker_desc);
-}
+ Window *w = AllocateWindowDesc(&_rv_station_picker_desc);
+ if (w == NULL) return;
-static const Widget _truck_station_picker_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 7, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 7, 11, 206, 0, 13, STR_3043_TRUCK_STATION_ORIENT, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_NONE, 7, 0, 206, 14, 176, 0x0, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
-{ WWT_PANEL, RESIZE_NONE, 14, 71, 136, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
-{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
-{ WWT_PANEL, RESIZE_NONE, 14, 3, 68, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
-{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 17, 66, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
-{ WWT_PANEL, RESIZE_NONE, 14, 139, 204, 69, 118, 0x0, STR_3052_SELECT_TRUCK_LOADING_BAY},
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 10, 69, 133, 144, STR_02DB_OFF, STR_3065_DON_T_HIGHLIGHT_COVERAGE},
-{ WWT_TEXTBTN, RESIZE_NONE, 14, 70, 129, 133, 144, STR_02DA_ON, STR_3064_HIGHLIGHT_COVERAGE_AREA},
-{ WWT_LABEL, RESIZE_NONE, 7, 0, 139, 120, 133, STR_3066_COVERAGE_AREA_HIGHLIGHT, STR_NULL},
-{ WIDGETS_END},
-};
-
-static const WindowDesc _truck_station_picker_desc = {
- WDP_AUTO, WDP_AUTO, 207, 177,
- WC_TRUCK_STATION, WC_BUILD_TOOLBAR,
- WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET,
- _truck_station_picker_widgets,
- RoadStationPickerWndProc
-};
-
-static void ShowTruckStationPicker()
-{
- AllocateWindowDesc(&_truck_station_picker_desc);
+ w->window_class = (rs == RoadStop::BUS) ? WC_BUS_STATION : WC_TRUCK_STATION;
+ w->widget[1].data = _road_type_infos[_cur_roadtype].picker_title[rs];
+ for (uint i = 3; i < 9; i++) w->widget[i].tooltips = _road_type_infos[_cur_roadtype].picker_tooltip[rs];
}
void InitializeRoadGui()
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/road_map.cpp
--- a/src/road_map.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/road_map.cpp Sat Jun 02 19:59:29 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"
@@ -11,13 +14,15 @@
#include "depot.h"
-RoadBits GetAnyRoadBits(TileIndex tile)
+RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt)
{
+ if (!HASBIT(GetRoadTypes(tile), rt)) return ROAD_NONE;
+
switch (GetTileType(tile)) {
case MP_STREET:
switch (GetRoadTileType(tile)) {
default:
- case ROAD_TILE_NORMAL: return GetRoadBits(tile);
+ case ROAD_TILE_NORMAL: return GetRoadBits(tile, rt);
case ROAD_TILE_CROSSING: return GetCrossingRoadBits(tile);
case ROAD_TILE_DEPOT: return DiagDirToRoadBits(GetRoadDepotDirection(tile));
}
@@ -41,15 +46,16 @@
}
-TrackBits GetAnyRoadTrackBits(TileIndex tile)
+TrackBits GetAnyRoadTrackBits(TileIndex tile, RoadType rt)
{
uint32 r;
- // 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))) {
+ /* 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)) || !HASBIT(GetRoadTypes(tile), rt)) {
return TRACK_BIT_NONE;
}
- r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
+ r = GetTileTrackStatus(tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(rt));
+
return (TrackBits)(byte)(r | (r >> 8));
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/road_map.h
--- a/src/road_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/road_map.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file road_map.h */
+
#ifndef ROAD_MAP_H
#define ROAD_MAP_H
@@ -16,9 +18,9 @@
};
static inline RoadTileType GetRoadTileType(TileIndex t)
-{
+ {
assert(IsTileType(t, MP_STREET));
- return (RoadTileType)GB(_m[t].m5, 4, 4);
+ return (RoadTileType)GB(_m[t].m5, 6, 2);
}
static inline bool IsLevelCrossing(TileIndex t)
@@ -31,23 +33,151 @@
return IsTileType(t, MP_STREET) && IsLevelCrossing(t);
}
-static inline RoadBits GetRoadBits(TileIndex t)
+static inline RoadBits GetRoadBits(TileIndex t, RoadType rt)
{
assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
- return (RoadBits)GB(_m[t].m5, 0, 4);
+ switch (rt) {
+ default: NOT_REACHED();
+ case ROADTYPE_ROAD: return (RoadBits)GB(_m[t].m4, 0, 4);
+ case ROADTYPE_TRAM: return (RoadBits)GB(_m[t].m4, 4, 4);
+ case ROADTYPE_HWAY: return (RoadBits)GB(_m[t].m6, 2, 4);
+ }
}
-static inline void SetRoadBits(TileIndex t, RoadBits r)
+static inline RoadBits GetAllRoadBits(TileIndex tile)
+{
+ return GetRoadBits(tile, ROADTYPE_ROAD) | GetRoadBits(tile, ROADTYPE_TRAM) | GetRoadBits(tile, ROADTYPE_HWAY);
+}
+
+static inline void SetRoadBits(TileIndex t, RoadBits r, RoadType rt)
{
assert(GetRoadTileType(t) == ROAD_TILE_NORMAL); // XXX incomplete
- SB(_m[t].m5, 0, 4, r);
+ switch (rt) {
+ default: NOT_REACHED();
+ case ROADTYPE_ROAD: SB(_m[t].m4, 0, 4, r); break;
+ case ROADTYPE_TRAM: SB(_m[t].m4, 4, 4, r); break;
+ case ROADTYPE_HWAY: SB(_m[t].m6, 2, 4, r); break;
+ }
}
+static inline RoadTypes GetRoadTypes(TileIndex t)
+{
+ if (IsTileType(t, MP_STREET)) {
+ return (RoadTypes)GB(_me[t].m7, 5, 3);
+ } else {
+ return (RoadTypes)GB(_m[t].m3, 0, 3);
+ }
+}
+
+static inline void SetRoadTypes(TileIndex t, RoadTypes rt)
+{
+ if (IsTileType(t, MP_STREET)) {
+ SB(_me[t].m7, 5, 3, rt);
+ } else {
+ assert(IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
+ SB(_m[t].m3, 0, 2, rt);
+ }
+}
+
+static inline Owner GetRoadOwner(TileIndex t, RoadType rt)
+{
+ if (!IsTileType(t, MP_STREET)) return GetTileOwner(t);
+
+ switch (GetRoadTileType(t)) {
+ default: NOT_REACHED();
+ case ROAD_TILE_NORMAL:
+ switch (rt) {
+ default: NOT_REACHED();
+ case ROADTYPE_ROAD: return (Owner)GB( _m[t].m1, 0, 5);
+ case ROADTYPE_TRAM: {
+ /* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
+ * to OWNER_TOWN makes it use one bit less */
+ Owner o = (Owner)GB( _m[t].m5, 0, 4);
+ return o == OWNER_TOWN ? OWNER_NONE : o;
+ }
+ case ROADTYPE_HWAY: return (Owner)GB(_me[t].m7, 0, 5);
+ }
+ case ROAD_TILE_CROSSING:
+ switch (rt) {
+ default: NOT_REACHED();
+ case ROADTYPE_ROAD: return (Owner)GB( _m[t].m4, 0, 5);
+ case ROADTYPE_TRAM: {
+ /* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
+ * to OWNER_TOWN makes it use one bit less */
+ Owner o = (Owner)GB( _m[t].m5, 0, 4);
+ return o == OWNER_TOWN ? OWNER_NONE : o;
+ }
+ case ROADTYPE_HWAY: return (Owner)GB(_me[t].m7, 0, 5);
+ }
+ case ROAD_TILE_DEPOT: return GetTileOwner(t);
+ }
+}
+
+static inline void SetRoadOwner(TileIndex t, RoadType rt, Owner o)
+{
+ if (!IsTileType(t, MP_STREET)) return SetTileOwner(t, o);
+
+ switch (GetRoadTileType(t)) {
+ default: NOT_REACHED();
+ case ROAD_TILE_NORMAL:
+ switch (rt) {
+ default: NOT_REACHED();
+ case ROADTYPE_ROAD: SB( _m[t].m1, 0, 5, o); break;
+ case ROADTYPE_TRAM: SB( _m[t].m5, 0, 4, o == OWNER_NONE ? OWNER_TOWN : o); break;
+ case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break;
+ }
+ break;
+ case ROAD_TILE_CROSSING:
+ switch (rt) {
+ default: NOT_REACHED();
+ case ROADTYPE_ROAD: SB( _m[t].m4, 0, 5, o); break;
+ /* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
+ * to OWNER_TOWN makes it use one bit less */
+ case ROADTYPE_TRAM: SB( _m[t].m5, 0, 4, o == OWNER_NONE ? OWNER_TOWN : o); break;
+ case ROADTYPE_HWAY: SB(_me[t].m7, 0, 5, o); break;
+ }
+ break;
+ case ROAD_TILE_DEPOT: return SetTileOwner(t, o);
+ }
+}
+
+/** Which directions are disallowed ? */
+enum DisallowedRoadDirections {
+ DRD_NONE, ///< None of the directions are disallowed
+ DRD_SOUTHBOUND, ///< All southbound traffic is disallowed
+ DRD_NORTHBOUND, ///< All northbound traffic is disallowed
+ DRD_BOTH, ///< All directions are disallowed
+ DRD_END
+};
+DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDirections);
+
+/**
+ * Gets the disallowed directions
+ * @param t the tile to get the directions from
+ * @return the disallowed directions
+ */
+static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
+{
+ assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
+ return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
+}
+
+/**
+ * Sets the disallowed directions
+ * @param t the tile to set the directions for
+ * @param drd the disallowed directions
+ */
+static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
+{
+ assert(GetRoadTileType(t) == ROAD_TILE_NORMAL);
+ assert(drd < DRD_END);
+ SB(_m[t].m5, 4, 2, drd);
+}
static inline Axis GetCrossingRoadAxis(TileIndex t)
{
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- return (Axis)GB(_m[t].m5, 3, 1);
+ return (Axis)GB(_m[t].m4, 6, 1);
}
static inline RoadBits GetCrossingRoadBits(TileIndex tile)
@@ -61,35 +191,22 @@
}
-// TODO swap owner of road and rail
-static inline Owner GetCrossingRoadOwner(TileIndex t)
-{
- assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- return (Owner)_m[t].m4;
-}
-
-static inline void SetCrossingRoadOwner(TileIndex t, Owner o)
-{
- assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- _m[t].m4 = o;
-}
-
static inline void UnbarCrossing(TileIndex t)
{
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- CLRBIT(_m[t].m5, 2);
+ CLRBIT(_m[t].m4, 5);
}
static inline void BarCrossing(TileIndex t)
{
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- SETBIT(_m[t].m5, 2);
+ SETBIT(_m[t].m4, 5);
}
static inline bool IsCrossingBarred(TileIndex t)
{
assert(GetRoadTileType(t) == ROAD_TILE_CROSSING);
- return HASBIT(_m[t].m5, 2);
+ return HASBIT(_m[t].m4, 5);
}
#define IsOnDesert IsOnSnow
@@ -166,48 +283,66 @@
/**
* Returns the RoadBits on an arbitrary tile
- * Special behavior:
+ * Special behaviour:
* - road depots: entrance is treated as road piece
* - 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
+ * @param rt the road type to get the road bits form
+ * @return the road bits of the given tile
*/
-RoadBits GetAnyRoadBits(TileIndex);
+RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt);
-
-TrackBits GetAnyRoadTrackBits(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, RoadType rt);
-static inline void MakeRoadNormal(TileIndex t, Owner owner, RoadBits bits, TownID town)
+static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram, Owner hway)
{
SetTileType(t, MP_STREET);
- SetTileOwner(t, owner);
+ SetTileOwner(t, road);
_m[t].m2 = town;
- _m[t].m3 = 0 << 7 | 0 << 4 | 0;
- _m[t].m4 = 0;
- _m[t].m5 = ROAD_TILE_NORMAL << 4 | bits;
+ _m[t].m3 = 0;
+ _m[t].m4 = (HASBIT(rot, ROADTYPE_TRAM) ? bits : 0) << 4 | (HASBIT(rot, ROADTYPE_ROAD) ? bits : 0);
+ _m[t].m5 = ROAD_TILE_NORMAL << 6;
+ SetRoadOwner(t, ROADTYPE_TRAM, tram);
+ SB(_m[t].m6, 2, 4, HASBIT(rot, ROADTYPE_HWAY) ? bits : 0);
+ _me[t].m7 = rot << 5 | hway;
}
-static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner rail, Axis roaddir, RailType rt, uint town)
+static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner hway, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town)
{
SetTileType(t, MP_STREET);
SetTileOwner(t, rail);
_m[t].m2 = town;
- _m[t].m3 = 0 << 7 | 0 << 4 | rt;
- _m[t].m4 = road;
- _m[t].m5 = ROAD_TILE_CROSSING << 4 | roaddir << 3 | 0 << 2;
+ _m[t].m3 = rat;
+ _m[t].m4 = roaddir << 6 | road;
+ _m[t].m5 = ROAD_TILE_CROSSING << 6;
+ SetRoadOwner(t, ROADTYPE_TRAM, tram);
+ SB(_m[t].m6, 2, 4, 0);
+ _me[t].m7 = rot << 5 | hway;
}
-static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir)
+static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir, RoadType rt)
{
SetTileType(t, MP_STREET);
SetTileOwner(t, owner);
_m[t].m2 = 0;
_m[t].m3 = 0;
_m[t].m4 = 0;
- _m[t].m5 = ROAD_TILE_DEPOT << 4 | dir;
+ _m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;
+ SB(_m[t].m6, 2, 4, 0);
+ _me[t].m7 = RoadTypeToRoadTypes(rt) << 5;
}
#endif /* ROAD_MAP_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/roadveh.h
--- a/src/roadveh.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/roadveh.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file src/roadveh.h Road vehicle states */
+
#ifndef ROADVEH_H
#define ROADVEH_H
@@ -20,4 +22,28 @@
void CcBuildRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2);
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ * v = new (v) RoadVehicle();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct RoadVehicle : public Vehicle {
+ /** Initializes the Vehicle to a road vehicle */
+ RoadVehicle() { this->type = VEH_ROAD; }
+
+ /** We want to 'destruct' the right class. */
+ virtual ~RoadVehicle() {}
+
+ const char *GetTypeString() const { return "road vehicle"; }
+ void MarkDirty();
+ void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_ROADVEH_INC : EXPENSES_ROADVEH_RUN; }
+ WindowClass GetVehicleListWindowClass() const { return WC_ROADVEH_LIST; }
+ bool IsPrimaryVehicle() const { return true; }
+};
+
#endif /* ROADVEH_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/roadveh_cmd.cpp
--- a/src/roadveh_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/roadveh_cmd.cpp Sat Jun 02 19:59:29 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"
@@ -114,11 +117,12 @@
static int32 EstimateRoadVehCost(EngineID engine_type)
{
- return ((_price.roadveh_base >> 3) * RoadVehInfo(engine_type)->base_cost) >> 5;
+ return ((_price.roadveh_base >> 3) * GetEngineProperty(engine_type, 0x11, RoadVehInfo(engine_type)->base_cost)) >> 5;
}
/** Build a road vehicle.
* @param tile tile of depot where road vehicle is built
+ * @param flags operation to perform
* @param p1 bus/truck type being built (engine)
* @param p2 bit 0 when set, the unitnumber will be 0, otherwise it will be a free number
*/
@@ -129,7 +133,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);
@@ -141,6 +145,8 @@
if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
+ if (HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM) != HASBIT(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
+
v = AllocateVehicle();
if (v == NULL) return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME);
@@ -164,11 +170,10 @@
y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
v->x_pos = x;
v->y_pos = y;
- v->z_pos = GetSlopeZ(x,y);
- v->z_height = 6;
+ v->z_pos = GetSlopeZ(x, y);
v->u.road.state = RVSB_IN_DEPOT;
- v->vehstatus = VS_HIDDEN|VS_STOPPED|VS_DEFPAL;
+ v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
v->spritenum = rvi->image_index;
v->cargo_type = rvi->cargo_type;
@@ -188,6 +193,9 @@
v->max_speed = rvi->max_speed;
v->engine_type = (byte)p1;
+ v->u.road.roadtype = HASBIT(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
+ v->u.road.compatible_roadtypes = RoadTypeToRoadTypes(v->u.road.roadtype);
+
e = GetEngine(p1);
v->reliability = e->reliability;
v->reliability_spd_dec = e->reliability_spd_dec;
@@ -201,13 +209,15 @@
v->date_of_last_service = _date;
v->build_year = _cur_year;
- v->type = VEH_ROAD;
+ v = new (v) RoadVehicle();
v->cur_image = 0xC15;
v->random_bits = VehicleRandomBits();
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+ v->cargo_cap = GetVehicleProperty(v, 0x0F, rvi->capacity);
+
VehiclePositionChanged(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@@ -224,6 +234,7 @@
/** Start/Stop a road vehicle.
* @param tile unused
+ * @param flags operation to perform
* @param p1 road vehicle ID to start/stop
* @param p2 unused
*/
@@ -252,6 +263,7 @@
}
v->vehstatus ^= VS_STOPPED;
+ v->cur_speed = 0;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
@@ -275,6 +287,7 @@
/** Sell a road vehicle.
* @param tile unused
+ * @param flags operation to perform
* @param p1 vehicle ID to be sold
* @param p2 unused
*/
@@ -346,7 +359,7 @@
/* See where we are now */
Trackdir trackdir = GetVehicleTrackdir(v);
- ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE);
+ ftd = NPFRouteToDepotBreadthFirst(v->tile, trackdir, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE);
if (ftd.best_bird_dist == 0) {
return GetDepotByTile(ftd.node.tile); /* Target found */
} else {
@@ -361,7 +374,7 @@
/* search in all directions */
for (DiagDirection i = DIAGDIR_BEGIN; i != DIAGDIR_END; i++) {
- FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, i, EnumRoadSignalFindDepot, NULL, &rfdd);
+ FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, v->u.road.compatible_roadtypes, i, EnumRoadSignalFindDepot, NULL, &rfdd);
}
if (rfdd.best_length == (uint)-1) return NULL;
@@ -372,6 +385,7 @@
/** Send a road vehicle to the depot.
* @param tile unused
+ * @param flags operation to perform
* @param p1 vehicle ID to send to the depot
* @param p2 various bitmasked elements
* - p2 bit 0-3 - DEPOT_ flags (see vehicle.h)
@@ -429,6 +443,8 @@
if (dep == NULL) return_cmd_error(STR_9019_UNABLE_TO_FIND_LOCAL_DEPOT);
if (flags & DC_EXEC) {
+ if (v->current_order.type == OT_LOADING) v->LeaveStation();
+
ClearSlot(v);
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
@@ -444,6 +460,7 @@
/** Turn a roadvehicle around.
* @param tile unused
+ * @param flags operation to perform
* @param p1 vehicle ID to turn
* @param p2 unused
*/
@@ -458,6 +475,7 @@
if (v->type != VEH_ROAD || !CheckOwnership(v->owner)) return CMD_ERROR;
if (v->vehstatus & VS_STOPPED ||
+ v->u.road.roadtype == ROADTYPE_TRAM ||
v->u.road.crashed_ctr != 0 ||
v->breakdown_ctr != 0 ||
v->u.road.overtaking != 0 ||
@@ -467,6 +485,8 @@
return CMD_ERROR;
}
+ if (IsTileType(v->tile, MP_STREET) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) return CMD_ERROR;
+
if (IsTunnelTile(v->tile) && DirToDiagDir(v->direction) == GetTunnelDirection(v->tile)) return CMD_ERROR;
if (IsBridgeTile(v->tile) && DirToDiagDir(v->direction) == GetBridgeRampDirection(v->tile)) return CMD_ERROR;
@@ -476,15 +496,15 @@
}
-static void MarkRoadVehDirty(Vehicle *v)
+void RoadVehicle::MarkDirty()
{
- v->cur_image = GetRoadVehImage(v, v->direction);
- MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
+ this->cur_image = GetRoadVehImage(this, this->direction);
+ MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
}
-static void UpdateRoadVehDeltaXY(Vehicle *v)
+void RoadVehicle::UpdateDeltaXY(Direction direction)
{
-#define MKIT(a,b,c,d) ((a&0xFF)<<24) | ((b&0xFF)<<16) | ((c&0xFF)<<8) | ((d&0xFF)<<0)
+#define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0)
static const uint32 _delta_xy_table[8] = {
MKIT(3, 3, -1, -1),
MKIT(3, 7, -1, -3),
@@ -496,11 +516,13 @@
MKIT(7, 3, -3, -1),
};
#undef MKIT
- uint32 x = _delta_xy_table[v->direction];
- v->x_offs = GB(x, 0, 8);
- v->y_offs = GB(x, 8, 8);
- v->sprite_width = GB(x, 16, 8);
- v->sprite_height = GB(x, 24, 8);
+
+ uint32 x = _delta_xy_table[direction];
+ this->x_offs = GB(x, 0, 8);
+ this->y_offs = GB(x, 8, 8);
+ this->sprite_width = GB(x, 16, 8);
+ this->sprite_height = GB(x, 24, 8);
+ this->z_height = 6;
}
static void ClearCrashedStation(Vehicle *v)
@@ -533,7 +555,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);
@@ -556,7 +578,7 @@
v->direction = ChangeDir(v->direction, delta[r & 3]);
BeginVehicleMove(v);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
v->cur_image = GetRoadVehImage(v, v->direction);
SetRoadVehPosition(v, v->x_pos, v->y_pos);
}
@@ -663,7 +685,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)) {
@@ -709,11 +731,14 @@
IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK
);
+ TileIndex dest = INVALID_TILE;
if (rs != NULL) {
- TileIndex dest = rs->xy;
- uint mindist = DistanceManhattan(v->tile, rs->xy);
+ uint mindist = MAX_UVALUE(uint);
- for (rs = rs->next; rs != NULL; rs = rs->next) {
+ for (; rs != NULL; rs = rs->next) {
+ /* The vehicle cannot go to this roadstop */
+ if ((GetRoadTypes(rs->xy) & v->u.road.compatible_roadtypes) == ROADTYPES_NONE) continue;
+
uint dist = DistanceManhattan(v->tile, rs->xy);
if (dist < mindist) {
@@ -721,9 +746,12 @@
dest = rs->xy;
}
}
- v->dest_tile = dest;
+ }
+
+ if (dest != INVALID_TILE) {
+ 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;
}
@@ -742,39 +770,6 @@
InvalidateVehicleOrder(v);
}
-static void HandleRoadVehLoading(Vehicle *v)
-{
- switch (v->current_order.type) {
- case OT_LOADING: {
- Order b;
-
- if (--v->load_unload_time_rem != 0) return;
-
- if (CanFillVehicle(v) && (v->current_order.flags & OF_FULL_LOAD ||
- (_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED)))) {
- SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
- if (LoadUnloadVehicle(v, false)) {
- InvalidateWindow(WC_ROADVEH_LIST, v->owner);
- MarkRoadVehDirty(v);
- }
- return;
- }
-
- b = v->current_order;
- v->LeaveStation();
- if (!(b.flags & OF_NON_STOP)) return;
- break;
- }
-
- case OT_DUMMY: break;
-
- default: return;
- }
-
- v->cur_order_index++;
- InvalidateVehicleOrder(v);
-}
-
static void StartRoadVehSound(const Vehicle* v)
{
if (!PlayVehicleSound(v, VSE_START)) {
@@ -828,10 +823,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;
@@ -853,7 +848,7 @@
SetDParam(0, st->index);
flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
- STR_902F_CITIZENS_CELEBRATE_FIRST,
+ v->u.road.roadtype == ROADTYPE_ROAD ? STR_902F_CITIZENS_CELEBRATE_FIRST : STR_902F_CITIZENS_CELEBRATE_FIRST_TRAM,
flags,
v->index,
0);
@@ -867,7 +862,7 @@
SetDParam(0, st->index);
flags = (v->owner == _local_player) ? NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_PLAYER, 0) : NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ARRIVAL_OTHER, 0);
AddNewsItem(
- STR_9030_CITIZENS_CELEBRATE_FIRST,
+ v->u.road.roadtype == ROADTYPE_ROAD ? STR_9030_CITIZENS_CELEBRATE_FIRST : STR_9030_CITIZENS_CELEBRATE_FIRST_TRAM,
flags,
v->index,
0
@@ -881,13 +876,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 +890,7 @@
}
}
- // Decrease somewhat when turning
+ /* Decrease somewhat when turning */
if (!(v->direction & 1)) spd = spd * 3 >> 2;
if (spd == 0) return false;
@@ -953,7 +948,7 @@
{
uint32 bits;
- bits = GetTileTrackStatus(od->tile, TRANSPORT_ROAD) & 0x3F;
+ bits = GetTileTrackStatus(od->tile, TRANSPORT_ROAD, od->v->u.road.compatible_roadtypes) & 0x3F;
if (!(od->tilebits & bits) || (bits & 0x3C) || (bits & 0x3F3F0000))
return true;
@@ -974,12 +969,15 @@
return;
}
+ /* Trams can't overtake other trams */
+ if (v->u.road.roadtype == ROADTYPE_TRAM) return;
+
if (v->direction != u->direction || !(v->direction & 1)) return;
/* Check if vehicle is in a road stop, depot, tunnel or bridge or not on a straight road */
if (v->u.road.state >= RVSB_IN_ROAD_STOP || !IsStraightRoadTrackdir((Trackdir)(v->u.road.state & RVSB_TRACKDIR_MASK))) return;
- tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD) & 0x3F;
+ tt = GetTileTrackStatus(v->tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & 0x3F;
if ((tt & 3) == 0) return;
if ((tt & 0x3C) != 0) return;
@@ -1050,11 +1048,11 @@
return false;
}
-static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, Owner owner, RailTypeMask railtypes)
+static inline NPFFoundTargetData PerfNPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypeMask railtypes)
{
void* perf = NpfBeginInterval();
- NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes);
+ NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, sub_type, owner, railtypes);
int t = NpfEndInterval(perf);
DEBUG(yapf, 4, "[NPFR] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
return ret;
@@ -1063,10 +1061,10 @@
/**
* Returns direction to for a road vehicle to take or
* INVALID_TRACKDIR if the direction is currently blocked
- * @param v the vehicle to do the pathfinding for
+ * @param v the Vehicle to do the pathfinding for
* @param tile the where to start the pathfinding
* @param enterdir the direction the vehicle enters the tile from
- * @return the trackdir to take
+ * @return the Trackdir to take
*/
static Trackdir RoadFindPathToDest(Vehicle* v, TileIndex tile, DiagDirection enterdir)
{
@@ -1076,12 +1074,12 @@
FindRoadToChooseData frd;
Trackdir best_track;
- uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD);
+ uint32 r = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
TrackdirBits signal = (TrackdirBits)GB(r, 16, 16);
TrackdirBits trackdirs = (TrackdirBits)GB(r, 0, 16);
if (IsTileType(tile, MP_STREET)) {
- if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir)) {
+ if (GetRoadTileType(tile) == ROAD_TILE_DEPOT && (!IsTileOwner(tile, v->owner) || GetRoadDepotDirection(tile) == enterdir || (GetRoadTypes(tile) & v->u.road.compatible_roadtypes) == 0)) {
/* Road depot owned by another player or with the wrong orientation */
trackdirs = TRACKDIR_BIT_NONE;
}
@@ -1151,11 +1149,11 @@
trackdir = DiagdirToDiagTrackdir(enterdir);
//debug("Finding path. Enterdir: %d, Trackdir: %d", enterdir, trackdir);
- ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->owner, INVALID_RAILTYPE);
+ ftd = PerfNPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, 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
@@ -1201,7 +1199,7 @@
if (best_track == INVALID_TRACKDIR) best_track = (Trackdir)i; // in case we don't find the path, just pick a track
frd.maxtracklen = (uint)-1;
frd.mindist = (uint)-1;
- FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd);
+ FollowTrack(tile, 0x2000 | TRANSPORT_ROAD, v->u.road.compatible_roadtypes, _road_pf_directions[i], EnumRoadTrackFindDist, NULL, &frd);
if (frd.mindist < best_dist || (frd.mindist == best_dist && frd.maxtracklen < best_maxlen)) {
best_dist = frd.mindist;
@@ -1223,10 +1221,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);
@@ -1234,8 +1232,8 @@
fstd.dest_coords = tile;
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
+ dist = NPFRouteToStationOrTile(v->tile, trackdir, &fstd, TRANSPORT_ROAD, v->u.road.compatible_roadtypes, v->owner, INVALID_RAILTYPE).best_path_dist;
+ /* change units from NPF_TILE_LENGTH to # of tiles */
if (dist != UINT_MAX)
dist = (dist + NPF_TILE_LENGTH - 1) / NPF_TILE_LENGTH;
}
@@ -1277,11 +1275,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 +1287,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);
@@ -1301,7 +1299,7 @@
if (v->vehstatus & VS_STOPPED) return;
ProcessRoadVehOrder(v);
- HandleRoadVehLoading(v);
+ v->HandleLoading();
if (v->current_order.type == OT_LOADING) return;
@@ -1317,7 +1315,7 @@
v->direction = DiagDirToDir(dir);
tdir = _roadveh_depot_exit_trackdir[dir];
- rdp = _road_drive_data[(_opt.road_side << RVS_DRIVE_SIDE) + tdir];
+ rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + tdir];
x = TileX(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].x & 0xF);
y = TileY(v->tile) * TILE_SIZE + (rdp[RVC_DEPOT_START_FRAME].y & 0xF);
@@ -1335,7 +1333,7 @@
v->u.road.frame = RVC_DEPOT_START_FRAME;
v->cur_image = GetRoadVehImage(v, v->direction);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
SetRoadVehPosition(v,x,y);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@@ -1371,7 +1369,7 @@
if ((IsTunnelTile(gp.new_tile) || IsBridgeTile(gp.new_tile)) && HASBIT(VehicleEnterTile(v, gp.new_tile, gp.x, gp.y), VETS_ENTERED_WORMHOLE)) {
/* Vehicle has just entered a bridge or tunnel */
v->cur_image = GetRoadVehImage(v, v->direction);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
SetRoadVehPosition(v,gp.x,gp.y);
return;
}
@@ -1386,7 +1384,7 @@
/* Get move position data for next frame.
* For a drive-through road stop use 'straight road' move data.
* In this case v->u.road.state is masked to give the road stop entry direction. */
- rd = _road_drive_data[(
+ rd = _road_drive_data[v->u.road.roadtype][(
(HASBIT(v->u.road.state, RVS_IN_DT_ROAD_STOP) ? v->u.road.state & RVSB_ROAD_STOP_TRACKDIR_MASK : v->u.road.state) +
(_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking][v->u.road.frame + 1];
@@ -1405,11 +1403,30 @@
again:
if (IsReversingRoadTrackdir(dir)) {
/* Turning around */
- tile = v->tile;
+ if (v->u.road.roadtype == ROADTYPE_TRAM) {
+ RoadBits needed; // The road bits the tram needs to be able to turn around
+ switch (dir) {
+ default: NOT_REACHED();
+ case TRACKDIR_RVREV_NE: needed = ROAD_SW; break;
+ case TRACKDIR_RVREV_SE: needed = ROAD_NW; break;
+ case TRACKDIR_RVREV_SW: needed = ROAD_NE; break;
+ case TRACKDIR_RVREV_NW: needed = ROAD_SE; break;
+ }
+ if (!IsTileType(tile, MP_STREET) || GetRoadTileType(tile) != ROAD_TILE_NORMAL || (needed & GetRoadBits(tile, ROADTYPE_TRAM)) == ROAD_NONE) {
+ /* The tram cannot turn here */
+ v->cur_speed = 0;
+ return;
+ }
+ } else if (IsTileType(v->tile, MP_STREET) && GetRoadTileType(v->tile) == ROAD_TILE_NORMAL && GetDisallowedRoadDirections(v->tile) != DRD_NONE) {
+ v->cur_speed = 0;
+ return;
+ } else {
+ tile = v->tile;
+ }
}
/* Get position data for first frame on the new tile */
- rdp = _road_drive_data[(dir + (_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking];
+ rdp = _road_drive_data[v->u.road.roadtype][(dir + (_opt.road_side << RVS_DRIVE_SIDE)) ^ v->u.road.overtaking];
x = TileX(tile) * TILE_SIZE + rdp[RVC_DEFAULT_START_FRAME].x;
y = TileY(tile) * TILE_SIZE + rdp[RVC_DEFAULT_START_FRAME].y;
@@ -1459,7 +1476,7 @@
}
v->cur_image = GetRoadVehImage(v, newdir);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
return;
}
@@ -1476,7 +1493,7 @@
return;
}
- rdp = _road_drive_data[(_opt.road_side << RVS_DRIVE_SIDE) + dir];
+ rdp = _road_drive_data[v->u.road.roadtype][(_opt.road_side << RVS_DRIVE_SIDE) + dir];
x = TileX(v->tile) * TILE_SIZE + rdp[RVC_TURN_AROUND_START_FRAME].x;
y = TileY(v->tile) * TILE_SIZE + rdp[RVC_TURN_AROUND_START_FRAME].y;
@@ -1499,7 +1516,7 @@
}
v->cur_image = GetRoadVehImage(v, newdir);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
return;
}
@@ -1516,6 +1533,7 @@
Vehicle* u = RoadVehFindCloseTo(v, x, y, new_dir);
if (u != NULL) {
+ v->cur_speed = u->cur_speed;
/* There is a vehicle in front overtake it if possible */
if (v->u.road.overtaking == 0) RoadVehCheckOvertake(v, u);
return;
@@ -1529,7 +1547,7 @@
if (old_dir != v->u.road.state) {
/* The vehicle is in a road stop */
v->cur_image = GetRoadVehImage(v, new_dir);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
SetRoadVehPosition(v, v->x_pos, v->y_pos);
/* Note, return here means that the frame counter is not incremented
* for vehicles changing direction in a road stop. This causes frames to
@@ -1559,14 +1577,11 @@
if (v->current_order.type != OT_LEAVESTATION &&
v->current_order.type != OT_GOTO_DEPOT) {
/* Vehicle has arrived at a bay in a road stop */
- Order old_order;
if (IsDriveThroughStopTile(v->tile)) {
TileIndex next_tile = TILE_ADD(v->tile, TileOffsByDir(v->direction));
RoadStop::Type type = IsCargoInClass(v->cargo_type, CC_PASSENGERS) ? RoadStop::BUS : RoadStop::TRUCK;
- assert(HASBIT(v->u.road.state, RVS_IS_STOPPING));
-
/* Check if next inline bay is free */
if (IsDriveThroughStopTile(next_tile) && (GetRoadStopType(next_tile) == type)) {
RoadStop *rs_n = GetRoadStopByTile(next_tile, type);
@@ -1591,23 +1606,8 @@
v->last_station_visited = GetStationIndex(v->tile);
RoadVehArrivesAt(v, st);
-
- old_order = v->current_order;
v->BeginLoading();
- v->current_order.flags = 0;
- if (old_order.type == OT_GOTO_STATION &&
- v->current_order.dest == v->last_station_visited) {
- v->current_order.flags =
- (old_order.flags & (OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER)) | OF_NON_STOP;
- }
-
- SET_EXPENSES_TYPE(EXPENSES_ROADVEH_INC);
- if (LoadUnloadVehicle(v, true)) {
- InvalidateWindow(WC_ROADVEH_LIST, v->owner);
- MarkRoadVehDirty(v);
- }
- InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
return;
}
@@ -1628,9 +1628,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);
@@ -1667,7 +1667,7 @@
if (!HASBIT(r, VETS_ENTERED_WORMHOLE)) v->u.road.frame++;
v->cur_image = GetRoadVehImage(v, v->direction);
- UpdateRoadVehDeltaXY(v);
+ v->UpdateDeltaXY(v->direction);
RoadZPosAffectSpeed(v, SetRoadVehPosition(v, x, y));
}
@@ -1692,13 +1692,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 +1706,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) {
@@ -1724,6 +1724,9 @@
return;
}
+ if (v->current_order.type == OT_LOADING) v->LeaveStation();
+ ClearSlot(v);
+
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
v->current_order.dest = depot->index;
@@ -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);
@@ -1838,10 +1841,13 @@
/** Refit a road vehicle to the specified cargo type
* @param tile unused
+ * @param flags operation to perform
* @param p1 Vehicle ID of the vehicle to refit
* @param p2 Bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to
* - p2 = (bit 8-15) - the new cargo subtype to refit to
+ * - p2 = (bit 16) - refit only this vehicle (ignored)
+ * @return cost of refit or error
*/
int32 CmdRefitRoadVeh(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -1886,7 +1892,7 @@
* carry twice as much mail/goods as normal cargo, and four times as
* many passengers
*/
- capacity = rvi->capacity;
+ capacity = GetVehicleProperty(v, 0x0F, rvi->capacity);
switch (old_cid) {
case CT_PASSENGERS: break;
case CT_MAIL:
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/roadveh_gui.cpp
--- a/src/roadveh_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/roadveh_gui.cpp Sat Jun 02 19:59:29 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);
@@ -190,7 +192,7 @@
bool is_localplayer = v->owner == _local_player;
SetWindowWidgetDisabledState(w, 7, !is_localplayer);
- SetWindowWidgetDisabledState(w, 8, !is_localplayer);
+ SetWindowWidgetDisabledState(w, 8, !is_localplayer || v->u.road.roadtype == ROADTYPE_TRAM);
SetWindowWidgetDisabledState(w, 11, !is_localplayer);
/* Disable refit button if vehicle not refittable */
SetWindowWidgetDisabledState(w, 12, !is_localplayer ||
@@ -344,7 +346,7 @@
if (w != NULL) {
w->caption_color = v->owner;
- AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
+ AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_ROADVEH);
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/saveload.cpp
--- a/src/saveload.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/saveload.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -27,8 +27,9 @@
#include "network/network.h"
#include "variables.h"
#include
+#include
-extern const uint16 SAVEGAME_VERSION = 53;
+extern const uint16 SAVEGAME_VERSION = 64;
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
@@ -251,14 +252,14 @@
if (i >= (1 << 14)) {
if (i >= (1 << 21)) {
assert(i < (1 << 28));
- SlWriteByte((byte)0xE0 | (i>>24));
- SlWriteByte((byte)(i>>16));
+ SlWriteByte((byte)0xE0 | (i >> 24));
+ SlWriteByte((byte)(i >> 16));
} else {
- SlWriteByte((byte)0xC0 | (i>>16));
+ SlWriteByte((byte)0xC0 | (i >> 16));
}
- SlWriteByte((byte)(i>>8));
+ SlWriteByte((byte)(i >> 8));
} else {
- SlWriteByte((byte)(0x80 | (i>>8)));
+ SlWriteByte((byte)(0x80 | (i >> 8)));
}
}
SlWriteByte(i);
@@ -412,8 +413,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 +499,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 +527,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)
{
@@ -626,6 +628,61 @@
}
}
+
+static uint ReferenceToInt(const void* obj, SLRefType rt);
+static void* IntToReference(uint index, SLRefType rt);
+
+
+/**
+ * Return the size in bytes of a list
+ * @param list The std::list to find the size of
+ */
+static inline size_t SlCalcListLen(const void *list)
+{
+ std::list *l = (std::list *) list;
+
+ /* Each entry is saved as 2 bytes, plus 2 bytes are used for the length
+ * of the list */
+ return l->size() * 2 + 2;
+}
+
+
+/**
+ * Save/Load a list.
+ * @param list The list being manipulated
+ * @param conv SLRefType type of the list (Vehicle *, Station *, etc)
+ */
+void SlList(void *list, SLRefType conv)
+{
+ /* Automatically calculate the length? */
+ if (_sl.need_length != NL_NONE) {
+ SlSetLength(SlCalcListLen(list));
+ /* Determine length only? */
+ if (_sl.need_length == NL_CALCLENGTH) return;
+ }
+
+ std::list *l = (std::list *) list;
+
+ if (_sl.save) {
+ SlWriteUint16(l->size());
+
+ std::list::iterator iter;
+ for (iter = l->begin(); iter != l->end(); ++iter) {
+ void *ptr = *iter;
+ SlWriteUint16(ReferenceToInt(ptr, conv));
+ }
+ } else {
+ uint length = SlReadUint16();
+
+ /* Load each reference and push to the end of the list */
+ for (uint i = 0; i < length; i++) {
+ void *ptr = IntToReference(SlReadUint16(), conv);
+ l->push_back(ptr);
+ }
+ }
+}
+
+
/** Are we going to save this object or not? */
static inline bool SlIsObjectValidInSavegame(const SaveLoad *sld)
{
@@ -650,7 +707,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)
{
@@ -672,6 +731,7 @@
case SL_REF:
case SL_ARR:
case SL_STR:
+ case SL_LST:
/* CONDITIONAL saveload types depend on the savegame version */
if (!SlIsObjectValidInSavegame(sld)) break;
@@ -680,6 +740,7 @@
case SL_REF: return SlCalcRefLen();
case SL_ARR: return SlCalcArrayLen(sld->length, sld->conv);
case SL_STR: return SlCalcStringLen(GetVariableAddress(object, sld), sld->length, sld->conv);
+ case SL_LST: return SlCalcListLen(GetVariableAddress(object, sld));
default: NOT_REACHED();
}
break;
@@ -691,10 +752,6 @@
}
-static uint ReferenceToInt(const void* obj, SLRefType rt);
-static void* IntToReference(uint index, SLRefType rt);
-
-
bool SlObjectMember(void *ptr, const SaveLoad *sld)
{
VarType conv = GB(sld->conv, 0, 8);
@@ -703,6 +760,7 @@
case SL_REF:
case SL_ARR:
case SL_STR:
+ case SL_LST:
/* CONDITIONAL saveload types depend on the savegame version */
if (!SlIsObjectValidInSavegame(sld)) return false;
if (SlSkipVariableOnLoad(sld)) return false;
@@ -719,6 +777,7 @@
break;
case SL_ARR: SlArray(ptr, sld->length, conv); break;
case SL_STR: SlString(ptr, sld->length, conv); break;
+ case SL_LST: SlList(ptr, (SLRefType)conv); break;
default: NOT_REACHED();
}
break;
@@ -768,7 +827,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)
{
@@ -922,7 +981,7 @@
{
const ChunkHandler *ch;
const ChunkHandler *const *chsc;
- for (chsc = _sl.chs; (ch=*chsc++) != NULL;) {
+ for (chsc = _sl.chs; (ch = *chsc++) != NULL;) {
for (;;) {
if (ch->id == id) return ch;
if (ch->flags & CH_LAST) break;
@@ -1027,7 +1086,7 @@
static bool InitNoComp()
{
_sl.bufsize = LZO_SIZE;
- _sl.buf = _sl.buf_ori =(byte*)malloc(LZO_SIZE);
+ _sl.buf = _sl.buf_ori = (byte*)malloc(LZO_SIZE);
return true;
}
@@ -1198,6 +1257,7 @@
extern const ChunkHandler _economy_chunk_handlers[];
extern const ChunkHandler _animated_tile_chunk_handlers[];
extern const ChunkHandler _newgrf_chunk_handlers[];
+extern const ChunkHandler _group_chunk_handlers[];
static const ChunkHandler * const _chunk_handlers[] = {
_misc_chunk_handlers,
@@ -1215,6 +1275,7 @@
_player_chunk_handlers,
_animated_tile_chunk_handlers,
_newgrf_chunk_handlers,
+ _group_chunk_handlers,
NULL,
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/saveload.h
--- a/src/saveload.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/saveload.h Sat Jun 02 19:59:29 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 {
@@ -157,6 +159,7 @@
SL_REF = 1,
SL_ARR = 2,
SL_STR = 3,
+ SL_LST = 4,
// non-normal save-load types
SL_WRITEBYTE = 8,
SL_INCLUDE = 9,
@@ -188,11 +191,13 @@
#define SLE_CONDREF(base, variable, type, from, to) SLE_GENERAL(SL_REF, base, variable, type, 0, from, to)
#define SLE_CONDARR(base, variable, type, length, from, to) SLE_GENERAL(SL_ARR, base, variable, type, length, from, to)
#define SLE_CONDSTR(base, variable, type, length, from, to) SLE_GENERAL(SL_STR, base, variable, type, length, from, to)
+#define SLE_CONDLST(base, variable, type, from, to) SLE_GENERAL(SL_LST, base, variable, type, 0, from, to)
#define SLE_VAR(base, variable, type) SLE_CONDVAR(base, variable, type, 0, SL_MAX_VERSION)
#define SLE_REF(base, variable, type) SLE_CONDREF(base, variable, type, 0, SL_MAX_VERSION)
#define SLE_ARR(base, variable, type, length) SLE_CONDARR(base, variable, type, length, 0, SL_MAX_VERSION)
#define SLE_STR(base, variable, type, length) SLE_CONDSTR(base, variable, type, length, 0, SL_MAX_VERSION)
+#define SLE_LST(base, variable, type) SLE_CONDLST(base, variable, type, 0, SL_MAX_VERSION)
#define SLE_CONDNULL(length, from, to) SLE_CONDARR(NullStruct, null, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to)
@@ -222,11 +227,13 @@
#define SLEG_CONDREF(variable, type, from, to) SLEG_GENERAL(SL_REF, variable, type, 0, from, to)
#define SLEG_CONDARR(variable, type, length, from, to) SLEG_GENERAL(SL_ARR, variable, type, length, from, to)
#define SLEG_CONDSTR(variable, type, length, from, to) SLEG_GENERAL(SL_STR, variable, type, length, from, to)
+#define SLEG_CONDLST(variable, type, from, to) SLEG_GENERAL(SL_LST, variable, type, 0, from, to)
#define SLEG_VAR(variable, type) SLEG_CONDVAR(variable, type, 0, SL_MAX_VERSION)
#define SLEG_REF(variable, type) SLEG_CONDREF(variable, type, 0, SL_MAX_VERSION)
#define SLEG_ARR(variable, type) SLEG_CONDARR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
#define SLEG_STR(variable, type) SLEG_CONDSTR(variable, type, lengthof(variable), 0, SL_MAX_VERSION)
+#define SLEG_LST(variable, type) SLEG_CONDLST(variable, type, 0, SL_MAX_VERSION)
#define SLEG_CONDNULL(length, from, to) {SL_ARR, SLE_FILE_U8 | SLE_VAR_NULL | SLF_CONFIG_NO, length, from, to, (void*)NULL}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/screenshot.cpp
--- a/src/screenshot.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/screenshot.cpp Sat Jun 02 19:59:29 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);
@@ -268,7 +268,7 @@
uint32 unused;
uint16 xmax, ymax;
uint16 hdpi, vdpi;
- byte pal_small[16*3];
+ byte pal_small[16 * 3];
byte reserved;
byte planes;
uint16 pitch;
@@ -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,17 +445,17 @@
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) {
- memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width);
+ memcpy(buf, _screen.dst_ptr + y * _screen.pitch, _screen.width * sizeof(Pixel));
++y;
buf += pitch;
}
}
-// 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;
@@ -469,7 +469,7 @@
dpi.height = n;
dpi.width = vp->width;
dpi.pitch = pitch;
- dpi.zoom = 0;
+ dpi.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
dpi.left = 0;
dpi.top = y;
@@ -479,10 +479,10 @@
left += wx;
ViewportDoDraw(vp,
- ((left - wx - vp->left) << vp->zoom) + vp->virtual_left,
- ((y - vp->top) << vp->zoom) + vp->virtual_top,
- ((left - vp->left) << vp->zoom) + vp->virtual_left,
- (((y + n) - vp->top) << vp->zoom) + vp->virtual_top
+ ScaleByZoom(left - wx - vp->left, vp->zoom) + vp->virtual_left,
+ ScaleByZoom(y - vp->top, vp->zoom) + vp->virtual_top,
+ ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
+ ScaleByZoom((y + n) - vp->top, vp->zoom) + vp->virtual_top
);
}
@@ -540,7 +540,7 @@
ViewPort vp;
const ScreenshotFormat *sf;
- vp.zoom = 0;
+ vp.zoom = ZOOM_LVL_WORLD_SCREENSHOT;
vp.left = 0;
vp.top = 0;
vp.virtual_left = -(int)MapMaxX() * TILE_PIXELS;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/screenshot.h
--- a/src/screenshot.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/screenshot.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file screenshot.h */
+
#ifndef SCREENSHOT_H
#define SCREENSHOT_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/sdl.cpp
--- a/src/sdl.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/sdl.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sdl.cpp */
+
#include "stdafx.h"
#ifdef WITH_SDL
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/sdl.h
--- a/src/sdl.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/sdl.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sdl.h */
+
#ifndef SDL_H
#define SDL_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/settings.cpp
--- a/src/settings.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/settings.cpp Sat Jun 02 19:59:29 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;
@@ -399,7 +412,7 @@
/** Find the set-integer value MANYofMANY type in a string
* @param many full domain of values the MANYofMANY setting can have
* @param str the current string value of the setting, each individual
- * of seperated by a whitespace\tab or | character
+ * of seperated by a whitespace,tab or | character
* @return the 'fully' set integer, or -1 if a set is not found */
static uint32 lookup_manyofmany(const char *many, const char *str)
{
@@ -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';
}
@@ -669,7 +682,8 @@
* @param ini pointer to IniFile structure that holds administrative information
* @param sd pointer to SettingDesc structure whose internally pointed variables will
* be given values
- * @param grpname the group of the IniFile to search in for the new values */
+ * @param grpname the group of the IniFile to search in for the new values
+ * @param object pointer to the object been loaded */
static void ini_load_settings(IniFile *ini, const SettingDesc *sd, const char *grpname, void *object)
{
IniGroup *group;
@@ -685,7 +699,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);
@@ -739,6 +753,7 @@
* @param sd read-only SettingDesc structure which contains the unmodified,
* loaded values of the configuration file and various information about it
* @param grpname holds the name of the group (eg. [network]) where these will be saved
+ * @param object pointer to the object been saved
* The function works as follows: for each item in the SettingDesc structure we
* have a look if the value has changed since we started the game (the original
* values are reloaded when saving). If settings indeed have changed, we get
@@ -761,7 +776,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 +791,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
@@ -852,7 +867,7 @@
* The list parameter can be a NULL pointer, in this case nothing will be
* saved and a callback function should be defined that will take over the
* list-handling and store the data itself somewhere.
- * @param IniFile handle to the ini file with the source data
+ * @param ini IniFile handle to the ini file with the source data
* @param grpname character string identifying the section-header of the ini
* file that will be parsed
* @param list pointer to an string(pointer) array that will store the parsed
@@ -882,10 +897,10 @@
/** Saves all items from a list into the 'grpname' section
* The list parameter can be a NULL pointer, in this case a callback function
* should be defined that will provide the source data to be saved.
- * @param IniFile handle to the ini file where the destination data is saved
+ * @param ini IniFile handle to the ini file where the destination data is saved
* @param grpname character string identifying the section-header of the ini file
* @param list pointer to an string(pointer) array that will be used as the
- * source to be saved into the relevant ini section
+ * source to be saved into the relevant ini section
* @param len the maximum number of items available for the above list
* @param proc callback function that can will provide the source data if defined */
static void ini_save_setting_list(IniFile *ini, const char *grpname, char **list, uint len, SettingListCallbackProc proc)
@@ -929,7 +944,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
@@ -988,7 +1004,7 @@
#define SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, from, to)\
SDTG_GENERAL(name, SDT_ONEOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, max, 0, full, str, proc, from, to)
#define SDTG_OMANY(name, type, flags, guiflags, var, def, max, full, str, proc)\
- SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max full, str, proc, 0, SL_MAX_VERSION)
+ SDTG_CONDOMANY(name, type, flags, guiflags, var, def, max, full, str, proc, 0, SL_MAX_VERSION)
#define SDTG_CONDMMANY(name, type, flags, guiflags, var, def, full, str, proc, from, to)\
SDTG_GENERAL(name, SDT_MANYOFMANY, SL_VAR, type, flags, guiflags, var, 0, def, 0, 0, 0, full, str, proc, from, to)
@@ -1052,7 +1068,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 +1084,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);
@@ -1125,15 +1140,15 @@
const Patches *ptc = (_game_mode == GM_MENU) ? &_patches_newgame : &_patches;
if (p1) {
- warning = ( (IS_INT_INSIDE(ptc->servint_trains, 5, 90+1) || ptc->servint_trains == 0) &&
- (IS_INT_INSIDE(ptc->servint_roadveh, 5, 90+1) || ptc->servint_roadveh == 0) &&
- (IS_INT_INSIDE(ptc->servint_aircraft, 5, 90+1) || ptc->servint_aircraft == 0) &&
- (IS_INT_INSIDE(ptc->servint_ships, 5, 90+1) || ptc->servint_ships == 0) );
+ warning = ( (IS_INT_INSIDE(ptc->servint_trains, 5, 90 + 1) || ptc->servint_trains == 0) &&
+ (IS_INT_INSIDE(ptc->servint_roadveh, 5, 90 + 1) || ptc->servint_roadveh == 0) &&
+ (IS_INT_INSIDE(ptc->servint_aircraft, 5, 90 + 1) || ptc->servint_aircraft == 0) &&
+ (IS_INT_INSIDE(ptc->servint_ships, 5, 90 + 1) || ptc->servint_ships == 0) );
} else {
- warning = ( (IS_INT_INSIDE(ptc->servint_trains, 30, 800+1) || ptc->servint_trains == 0) &&
- (IS_INT_INSIDE(ptc->servint_roadveh, 30, 800+1) || ptc->servint_roadveh == 0) &&
- (IS_INT_INSIDE(ptc->servint_aircraft, 30, 800+1) || ptc->servint_aircraft == 0) &&
- (IS_INT_INSIDE(ptc->servint_ships, 30, 800+1) || ptc->servint_ships == 0) );
+ warning = ( (IS_INT_INSIDE(ptc->servint_trains, 30, 800 + 1) || ptc->servint_trains == 0) &&
+ (IS_INT_INSIDE(ptc->servint_roadveh, 30, 800 + 1) || ptc->servint_roadveh == 0) &&
+ (IS_INT_INSIDE(ptc->servint_aircraft, 30, 800 + 1) || ptc->servint_aircraft == 0) &&
+ (IS_INT_INSIDE(ptc->servint_ships, 30, 800 + 1) || ptc->servint_ships == 0) );
}
if (!warning)
@@ -1159,6 +1174,24 @@
DoCommandP(0, 2, _patches.autorenew_money, NULL, CMD_SET_AUTOREPLACE);
return 0;
}
+
+/**
+ * Check for right TownLayout usage in editor mode.
+ * The No Road mode is not desirable since towns have to be
+ * able to grow. If a user desires to have a town with no road,
+ * he can easily remove them himself. This would create less confusion
+ * @param p1 unused
+ * @return always 0
+ */
+static int32 CheckTownLayout(int32 p1)
+{
+ if (_patches.town_layout == TL_NO_ROADS && _game_mode == GM_EDITOR) {
+ ShowErrorMessage(INVALID_STRING_ID, STR_CONFIG_PATCHES_TOWN_LAYOUT_INVALID, 0, 0);
+ _patches.town_layout = TL_ORIGINAL;
+ }
+ return 0;
+}
+
/** Conversion callback for _gameopt_settings.landscape
* It converts (or try) between old values and the new ones,
* without loosing initial setting of the user
@@ -1205,7 +1238,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, (1 << DO_SHOW_TOWN_NAMES | 1 << DO_SHOW_STATION_NAMES | 1 << DO_SHOW_SIGNS | 1 << DO_FULL_ANIMATION | 1 << DO_FULL_DETAIL | 1 << 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),
@@ -1229,29 +1262,30 @@
#ifdef ENABLE_NETWORK
static const SettingDescGlobVarList _network_settings[] = {
- SDTG_VAR("sync_freq", SLE_UINT16,C|S,0, _network_sync_freq, 100, 0, 100, 0, STR_NULL, NULL),
- SDTG_VAR("frame_freq", SLE_UINT8,C|S,0, _network_frame_freq, 0, 0, 100, 0, STR_NULL, NULL),
- SDTG_VAR("max_join_time", SLE_UINT16, S, 0, _network_max_join_time, 500, 0, 32000, 0, STR_NULL, NULL),
- SDTG_BOOL("pause_on_join", S, 0, _network_pause_on_join, true, STR_NULL, NULL),
- SDTG_STR("server_bind_ip", SLE_STRB, S, 0, _network_server_bind_ip_host, "0.0.0.0", STR_NULL, NULL),
- SDTG_VAR("server_port", SLE_UINT16, S, 0, _network_server_port, NETWORK_DEFAULT_PORT, 0, 65535, 0, STR_NULL, NULL),
- SDTG_BOOL("server_advertise", S, 0, _network_advertise, false, STR_NULL, NULL),
- SDTG_VAR("lan_internet", SLE_UINT8, S, 0, _network_lan_internet, 0, 0, 1, 0, STR_NULL, NULL),
- SDTG_STR("player_name", SLE_STRB, S, 0, _network_player_name, NULL, STR_NULL, NULL),
- SDTG_STR("server_password", SLE_STRB, S, 0, _network_server_password, NULL, STR_NULL, NULL),
- SDTG_STR("rcon_password", SLE_STRB, S, 0, _network_rcon_password, NULL, STR_NULL, NULL),
- SDTG_STR("server_name", SLE_STRB, S, 0, _network_server_name, NULL, STR_NULL, NULL),
- SDTG_STR("connect_to_ip", SLE_STRB, S, 0, _network_default_ip, NULL, STR_NULL, NULL),
- SDTG_STR("network_id", SLE_STRB, S, 0, _network_unique_id, NULL, STR_NULL, NULL),
- SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL),
- SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, 0, STR_NULL, NULL),
- SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, 0, STR_NULL, NULL),
- SDTG_VAR("max_companies", SLE_UINT8, S, 0, _network_game_info.companies_max, 8, 0, 8, 0, STR_NULL, NULL),
- SDTG_VAR("max_clients", SLE_UINT8, S, 0, _network_game_info.clients_max, 10, 0, 10, 0, STR_NULL, NULL),
- SDTG_VAR("max_spectators", SLE_UINT8, S, 0, _network_game_info.spectators_max, 10, 0, 10, 0, STR_NULL, NULL),
- SDTG_VAR("restart_game_year", SLE_INT32, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
- SDTG_VAR("min_players", SLE_UINT8, S, 0, _network_min_players, 0, 0, 10, 0, STR_NULL, NULL),
- SDTG_END()
+ SDTG_VAR("sync_freq", SLE_UINT16,C|S,0, _network_sync_freq, 100, 0, 100, 0, STR_NULL, NULL),
+ SDTG_VAR("frame_freq", SLE_UINT8,C|S,0, _network_frame_freq, 0, 0, 100, 0, STR_NULL, NULL),
+ SDTG_VAR("max_join_time", SLE_UINT16, S, 0, _network_max_join_time, 500, 0, 32000, 0, STR_NULL, NULL),
+ SDTG_BOOL("pause_on_join", S, 0, _network_pause_on_join, true, STR_NULL, NULL),
+ SDTG_STR("server_bind_ip", SLE_STRB, S, 0, _network_server_bind_ip_host, "0.0.0.0", STR_NULL, NULL),
+ SDTG_VAR("server_port", SLE_UINT16, S, 0, _network_server_port, NETWORK_DEFAULT_PORT, 0, 65535, 0, STR_NULL, NULL),
+ SDTG_BOOL("server_advertise", S, 0, _network_advertise, false, STR_NULL, NULL),
+ SDTG_VAR("lan_internet", SLE_UINT8, S, 0, _network_lan_internet, 0, 0, 1, 0, STR_NULL, NULL),
+ SDTG_STR("player_name", SLE_STRB, S, 0, _network_player_name, NULL, STR_NULL, NULL),
+ SDTG_STR("server_password", SLE_STRB, S, 0, _network_server_password, NULL, STR_NULL, NULL),
+ SDTG_STR("rcon_password", SLE_STRB, S, 0, _network_rcon_password, NULL, STR_NULL, NULL),
+ SDTG_STR("server_name", SLE_STRB, S, 0, _network_server_name, NULL, STR_NULL, NULL),
+ SDTG_STR("connect_to_ip", SLE_STRB, S, 0, _network_default_ip, NULL, STR_NULL, NULL),
+ SDTG_STR("network_id", SLE_STRB, S, 0, _network_unique_id, NULL, STR_NULL, NULL),
+ SDTG_BOOL("autoclean_companies", S, 0, _network_autoclean_companies, false, STR_NULL, NULL),
+ SDTG_VAR("autoclean_unprotected",SLE_UINT8, S, 0, _network_autoclean_unprotected,12, 0, 60, 0, STR_NULL, NULL),
+ SDTG_VAR("autoclean_protected", SLE_UINT8, S, 0, _network_autoclean_protected, 36, 0, 180, 0, STR_NULL, NULL),
+ SDTG_VAR("max_companies", SLE_UINT8, S, 0, _network_game_info.companies_max, 8, 0, 8, 0, STR_NULL, NULL),
+ SDTG_VAR("max_clients", SLE_UINT8, S, 0, _network_game_info.clients_max, 10, 0, 10, 0, STR_NULL, NULL),
+ SDTG_VAR("max_spectators", SLE_UINT8, S, 0, _network_game_info.spectators_max, 10, 0, 10, 0, STR_NULL, NULL),
+ SDTG_VAR("restart_game_year", SLE_INT32, S,D0, _network_restart_game_year, 0, MIN_YEAR, MAX_YEAR, 1, STR_NULL, NULL),
+ SDTG_VAR("min_players", SLE_UINT8, S, 0, _network_min_players, 0, 0, 10, 0, STR_NULL, NULL),
+ SDTG_OMANY("server_lang", SLE_UINT8, S, 0, _network_game_info.server_lang, 0, 28, "ANY|ENGLISH|GERMAN|FRENCH|BRAZILIAN|BULGARIAN|CHINESE|CZECH|DANISH|DUTCH|ESPERANTO|FINNISH|HUNGARIAN|ICELANDIC|ITALIAN|JAPANESE|KOREAN|LITHUANIAN|NORWEGIAN|POLISH|PORTUGUESE|ROMANIAN|RUSSIAN|SLOVAK|SLOVENIAN|SPANISH|SWEDISH|TURKISH|UKRAINIAN", STR_NULL, NULL),
+ SDTG_END()
};
#endif /* ENABLE_NETWORK */
@@ -1265,7 +1299,7 @@
* and why not byte for example? */
SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 17, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 0, 3),
SDT_GENERAL("diff_custom", SDT_INTLIST, SL_ARR, (SLE_FILE_I16 | SLE_VAR_I32), 0, 0, GameOptions, diff, 18, 0, 0, 0, 0, NULL, STR_NULL, NULL, NULL, 4, SL_MAX_VERSION),
- SDT_VAR(GameOptions, diff_level,SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
+ SDT_VAR(GameOptions, diff_level, SLE_UINT8, 0, 0, 0, 0, 3, 0, STR_NULL, NULL),
SDT_OMANY(GameOptions, currency, SLE_UINT8, N, 0, 0, CUSTOM_CURRENCY_ID, "GBP|USD|EUR|YEN|ATS|BEF|CHF|CZK|DEM|DKK|ESP|FIM|FRF|GRD|HUF|ISK|ITL|NLG|NOK|PLN|ROL|RUR|SIT|SEK|YTL|SKK|BRR|custom", STR_NULL, NULL, NULL),
SDT_OMANY(GameOptions, units, SLE_UINT8, N, 0, 1, 2, "imperial|metric|si", STR_NULL, NULL, NULL),
SDT_OMANY(GameOptions, town_name, SLE_UINT8, 0, 0, 0, 20, "english|french|german|american|latin|silly|swedish|dutch|finnish|polish|slovakish|norwegian|hungarian|austrian|romanian|czech|swiss|danish|turkish|italian|catalan", STR_NULL, NULL, NULL),
@@ -1294,6 +1328,7 @@
SDT_BOOL(Patches, show_finances, S, 0, true, STR_CONFIG_PATCHES_SHOWFINANCES, NULL),
SDT_BOOL(Patches, autoscroll, S, 0, false, STR_CONFIG_PATCHES_AUTOSCROLL, NULL),
SDT_BOOL(Patches, reverse_scroll, S, 0, false, STR_CONFIG_PATCHES_REVERSE_SCROLLING, NULL),
+ SDT_BOOL(Patches, smooth_scroll, S, 0, false, STR_CONFIG_PATCHES_SMOOTH_SCROLLING, NULL),
SDT_BOOL(Patches, measure_tooltip, S, 0, false, STR_CONFIG_PATCHES_MEASURE_TOOLTIP, NULL),
SDT_VAR(Patches, errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, NULL),
SDT_VAR(Patches, toolbar_pos, SLE_UINT8, S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS, v_PositionMainToolbar),
@@ -1307,6 +1342,8 @@
SDT_BOOL(Patches, prefer_teamchat, S, 0, false, STR_CONFIG_PATCHES_PREFER_TEAMCHAT, NULL),
SDT_VAR(Patches, scrollwheel_scrolling,SLE_UINT8,S,MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_SCROLLWHEEL_SCROLLING, NULL),
SDT_VAR(Patches,scrollwheel_multiplier,SLE_UINT8,S, 0, 5, 1, 15, 1, STR_CONFIG_PATCHES_SCROLLWHEEL_MULTIPLIER,NULL),
+ SDT_BOOL(Patches, pause_on_newgame, S, 0, false, STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME, NULL),
+ SDT_BOOL(Patches, advanced_vehicle_list, S, 0, true, STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS, NULL),
/***************************************************************************/
/* Construction section of the GUI-configure patches window */
@@ -1317,6 +1354,7 @@
SDT_BOOL(Patches, always_small_airport, 0, 0, false, STR_CONFIG_PATCHES_SMALL_AIRPORTS, NULL),
SDT_VAR(Patches, drag_signals_density,SLE_UINT8,S, 0, 4, 1, 20, 0, STR_CONFIG_PATCHES_DRAG_SIGNALS_DENSITY,NULL),
SDT_VAR(Patches, semaphore_build_before,SLE_INT32, S, NC, 1975, MIN_YEAR, MAX_YEAR, 1, STR_CONFIG_PATCHES_SEMAPHORE_BUILD_BEFORE_DATE, NULL),
+ SDT_CONDVAR(Patches, town_layout, SLE_UINT8, 59, SL_MAX_VERSION, 0, MS, TL_ORIGINAL, TL_NO_ROADS, NUM_TLS - 1, 1, STR_CONFIG_PATCHES_TOWN_LAYOUT, CheckTownLayout),
/***************************************************************************/
/* Vehicle section of the GUI-configure patches window */
@@ -1365,6 +1403,7 @@
SDT_BOOL(Patches, modified_catchment, 0, 0, true, STR_CONFIG_PATCHES_CATCHMENT, NULL),
SDT_CONDBOOL(Patches, gradual_loading, 40, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_GRADUAL_LOADING, NULL),
SDT_CONDBOOL(Patches, road_stop_on_town_road, 47, SL_MAX_VERSION, 0, 0, false, STR_CONFIG_PATCHES_STOP_ON_TOWN_ROAD, NULL),
+ SDT_CONDBOOL(Patches, adjacent_stations, 62, SL_MAX_VERSION, 0, 0, true, STR_CONFIG_PATCHES_ADJACENT_STATIONS, NULL),
/***************************************************************************/
/* Economy section of the GUI-configure patches window */
@@ -1379,6 +1418,9 @@
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),
+ SDT_CONDVAR(Patches, initial_city_size, SLE_UINT8, 56, SL_MAX_VERSION, 0, 0, 2, 1, 10, 1, STR_CONFIG_PATCHES_CITY_SIZE_MULTIPLIER, NULL),
/***************************************************************************/
/* AI section of the GUI-configure patches window */
@@ -1460,7 +1502,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),
@@ -1472,22 +1514,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),
@@ -1509,7 +1551,7 @@
static const SettingDesc _currency_settings[] = {
SDT_VAR(CurrencySpec, rate, SLE_UINT16, S, 0, 1, 0, 100, 0, STR_NULL, NULL),
SDT_CHR(CurrencySpec, separator, S, 0, ".", STR_NULL, NULL),
- SDT_VAR(CurrencySpec, to_euro, SLE_INT32, S, 0, 0, 0,3000, 0, STR_NULL, NULL),
+ SDT_VAR(CurrencySpec, to_euro, SLE_INT32, S, 0, 0, 0, 3000, 0, STR_NULL, NULL),
SDT_STR(CurrencySpec, prefix, SLE_STRBQ, S, 0, NULL, STR_NULL, NULL),
SDT_STR(CurrencySpec, suffix, SLE_STRBQ, S, 0, " credits", STR_NULL, NULL),
SDT_END()
@@ -1576,7 +1618,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') {
@@ -1653,7 +1695,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;
}
@@ -1713,6 +1755,8 @@
}
/** Network-safe changing of patch-settings (server-only).
+ * @param tile unused
+ * @param flags operation to perform
* @param p1 the index of the patch in the SettingDesc array which identifies it
* @param p2 the new value for the patch
* The new value is properly clamped to its minimum/maximum when setting
@@ -1829,6 +1873,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
@@ -1844,6 +1907,7 @@
}
/** Loadhandler for a list of global variables
+ * @param sdg pointer for the global variable list SettingDescGlobVarList
* @note this is actually a stub for LoadSettings with the
* object pointer set to NULL */
static inline void LoadSettingsGlobList(const SettingDescGlobVarList *sdg)
@@ -1852,7 +1916,7 @@
}
/** Save and load handler for patches/settings
- * @param osd SettingDesc struct containing all information
+ * @param sd SettingDesc struct containing all information
* @param object can be either NULL in which case we load global variables or
* a pointer to a struct which is getting saved */
static void SaveSettings(const SettingDesc *sd, void *object)
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/settings.h
--- a/src/settings.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/settings.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/settings_gui.cpp
--- a/src/settings_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/settings_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file settings_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
@@ -113,7 +115,7 @@
DrawWindowWidgets(w);
DrawString(20, 175, STR_OPTIONS_FULLSCREEN, 0); // fullscreen
- } break;
+ } break;
case WE_CLICK:
switch (e->we.click.widget) {
@@ -201,6 +203,7 @@
break;
case 24: /* Change interface language */
ReadLanguagePack(e->we.dropdown.index);
+ UpdateAllStationVirtCoord();
MarkWholeScreenDirty();
break;
case 27: /* Change resolution */
@@ -223,6 +226,7 @@
/** Change the side of the road vehicles drive on (server only).
* @param tile unused
+ * @param flags operation to perform
* @param p1 the side of the road; 0 = left side and 1 = right side
* @param p2 unused
*/
@@ -305,8 +309,8 @@
static const GameSettingData _game_setting_info[] = {
{ 0, 7, 1, STR_NULL},
{ 0, 3, 1, STR_6830_IMMEDIATE},
- { 0, 2, 1, STR_6816_LOW},
- { 0, 3, 1, STR_26816_NONE},
+ { 0, 3, 1, STR_NUM_VERY_LOW},
+ { 0, 4, 1, STR_26816_NONE},
{100, 500, 50, STR_NULL},
{ 2, 4, 1, STR_NULL},
{ 0, 2, 1, STR_6820_LOW},
@@ -323,18 +327,11 @@
{ 0, 2, 1, STR_6839_PERMISSIVE},
};
-static inline bool GetBitAndShift(uint32 *b)
-{
- uint32 x = *b;
- *b >>= 1;
- return HASBIT(x, 0);
-}
-
/*
* A: competitors
* B: start time in months / 3
- * C: town count (2 = high, 0 = low)
- * D: industry count (3 = high, 0 = none)
+ * C: town count (2 = high, 0 = very low)
+ * D: industry count (4 = high, 0 = none)
* E: inital loan / 1000 (in GBP)
* F: interest rate
* G: running costs (0 = low, 2 = high)
@@ -352,9 +349,9 @@
*/
static const int16 _default_game_diff[3][GAME_DIFFICULTY_NUM] = { /*
A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R*/
- {2, 2, 1, 3, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, //easy
- {4, 1, 1, 2, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, //medium
- {7, 0, 2, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, //hard
+ {2, 2, 1, 4, 300, 2, 0, 2, 0, 1, 2, 0, 1, 0, 0, 0, 0, 0}, ///< easy
+ {4, 1, 1, 3, 150, 3, 1, 3, 1, 2, 1, 1, 2, 1, 1, 1, 1, 1}, ///< medium
+ {7, 0, 0, 2, 100, 4, 1, 3, 2, 2, 0, 2, 3, 2, 1, 1, 1, 2}, ///< hard
};
void SetDifficultyLevel(int mode, GameOptions *gm_opt)
@@ -393,7 +390,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
@@ -428,9 +425,9 @@
y = GAMEDIFF_WND_TOP_OFFSET;
for (i = 0; i != GAME_DIFFICULTY_NUM; i++) {
- DrawFrameRect( 5, y, 5 + 8, y + 8, 3, GetBitAndShift(&click_a) ? FR_LOWERED : FR_NONE);
- DrawFrameRect(15, y, 15 + 8, y + 8, 3, GetBitAndShift(&click_b) ? FR_LOWERED : FR_NONE);
- if (GetBitAndShift(&disabled) || (_networking && !_network_server)) {
+ DrawFrameRect( 5, y, 5 + 8, y + 8, 3, HASBIT(click_a, i) ? FR_LOWERED : FR_NONE);
+ DrawFrameRect(15, y, 15 + 8, y + 8, 3, HASBIT(click_b, i) ? FR_LOWERED : FR_NONE);
+ if (HASBIT(disabled, i) || (_networking && !_network_server)) {
int color = (1 << PALETTE_MODIFIER_GREYOUT) | _colour_gradient[COLOUR_YELLOW][2];
GfxFillRect( 6, y + 1, 6 + 8, y + 8, color);
GfxFillRect(16, y + 1, 16 + 8, y + 8, color);
@@ -457,7 +454,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;
@@ -469,12 +466,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))
@@ -498,9 +495,11 @@
// save value in temporary variable
((int*)&_opt_mod_temp.diff)[btn] = val;
+ RaiseWindowWidget(w, _opt_mod_temp.diff_level + 3);
SetDifficultyLevel(3, &_opt_mod_temp); // set difficulty level to custom
+ LowerWindowWidget(w, _opt_mod_temp.diff_level + 3);
SetWindowDirty(w);
- } break;
+ } break;
case 3: case 4: case 5: case 6: /* Easy / Medium / Hard / Custom */
// temporarily change difficulty level
RaiseWindowWidget(w, _opt_mod_temp.diff_level + 3);
@@ -584,6 +583,7 @@
"show_finances",
"autoscroll",
"reverse_scroll",
+ "smooth_scroll",
"errmsg_duration",
"toolbar_pos",
"measure_tooltip",
@@ -598,6 +598,8 @@
* Since it's also able to completely disable the scrollwheel will we display it on all platforms anyway */
"scrollwheel_scrolling",
"scrollwheel_multiplier",
+ "pause_on_newgame",
+ "advanced_vehicle_list",
};
static const char *_patches_construction[] = {
@@ -609,6 +611,7 @@
"drag_signals_density",
"oil_refinery_limit",
"semaphore_build_before",
+ "town_layout",
};
static const char *_patches_stations[] = {
@@ -623,6 +626,7 @@
"modified_catchment",
"gradual_loading",
"road_stop_on_town_road",
+ "adjacent_stations",
};
static const char *_patches_economy[] = {
@@ -635,6 +639,9 @@
"ending_year",
"smooth_economy",
"allow_shares",
+ "town_growth_rate",
+ "larger_towns",
+ "initial_city_size",
};
static const char *_patches_ai[] = {
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/ship.h
--- a/src/ship.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/ship.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file ship.h */
+
#ifndef SHIP_H
#define SHIP_H
@@ -21,4 +23,29 @@
return IsShipInDepot(v) && v->vehstatus & VS_STOPPED;
}
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ * v = new (v) Ship();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct Ship: public Vehicle {
+ /** Initializes the Vehicle to a ship */
+ Ship() { this->type = VEH_SHIP; }
+
+ /** We want to 'destruct' the right class. */
+ virtual ~Ship() {}
+
+ const char *GetTypeString() const { return "ship"; }
+ void MarkDirty();
+ void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
+ WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; }
+ void PlayLeaveStationSound() const;
+ bool IsPrimaryVehicle() const { return true; }
+};
+
#endif /* SHIP_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/ship_cmd.cpp
--- a/src/ship_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/ship_cmd.cpp Sat Jun 02 19:59:29 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"
@@ -40,7 +43,7 @@
static TrackBits GetTileShipTrackStatus(TileIndex tile)
{
- uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
+ uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
return TrackdirBitsToTrackBits((TrackdirBits)(TRACKDIR_BIT_MASK & (r | r >> 8)));
}
@@ -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)
{
@@ -111,7 +114,7 @@
if (_patches.new_pathfinding_all) {
NPFFoundTargetData ftd;
Trackdir trackdir = GetVehicleTrackdir(v);
- ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, v->owner, INVALID_RAILTYPE);
+ ftd = NPFRouteToDepotTrialError(v->tile, trackdir, TRANSPORT_WATER, 0, v->owner, INVALID_RAILTYPE);
if (ftd.best_bird_dist == 0) {
best_depot = GetDepotByTile(ftd.node.tile); /* Found target */
} else {
@@ -162,6 +165,7 @@
return;
}
+ if (v->current_order.type == OT_LOADING) v->LeaveStation();
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
v->current_order.dest = depot->index;
@@ -184,14 +188,14 @@
if (v->vehstatus & VS_STOPPED) return;
- cost = ShipVehInfo(v->engine_type)->running_cost * _price.ship_running / 364;
+ cost = GetVehicleProperty(v, 0x0F, ShipVehInfo(v->engine_type)->running_cost) * _price.ship_running / 364;
v->profit_this_year -= cost >> 8;
SET_EXPENSES_TYPE(EXPENSES_SHIP_RUN);
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);
}
@@ -226,19 +230,24 @@
}
}
-static void MarkShipDirty(Vehicle *v)
+void Ship::MarkDirty()
{
- v->cur_image = GetShipImage(v, v->direction);
- MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
+ this->cur_image = GetShipImage(this, this->direction);
+ MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
}
-static void PlayShipSound(Vehicle *v)
+static void PlayShipSound(const Vehicle *v)
{
if (!PlayVehicleSound(v, VSE_START)) {
SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
}
}
+void Ship::PlayLeaveStationSound() const
+{
+ PlayShipSound(this);
+}
+
static void ProcessShipOrder(Vehicle *v)
{
const Order *order;
@@ -297,66 +306,34 @@
InvalidateWindowClasses(WC_SHIPS_LIST);
}
-static void HandleShipLoading(Vehicle *v)
+void Ship::UpdateDeltaXY(Direction direction)
{
- switch (v->current_order.type) {
- case OT_LOADING: {
- if (--v->load_unload_time_rem) return;
-
- if (CanFillVehicle(v) && (
- v->current_order.flags & OF_FULL_LOAD ||
- (_patches.gradual_loading && !HASBIT(v->vehicle_flags, VF_LOADING_FINISHED))
- )) {
- SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
- if (LoadUnloadVehicle(v, false)) {
- InvalidateWindow(WC_SHIPS_LIST, v->owner);
- MarkShipDirty(v);
- }
- return;
- }
- PlayShipSound(v);
-
- Order b = v->current_order;
- v->LeaveStation();
- if (!(b.flags & OF_NON_STOP)) return;
- break;
- }
-
- case OT_DUMMY: break;
-
- default: return;
- }
-
- v->cur_order_index++;
- InvalidateVehicleOrder(v);
-}
-
-static void UpdateShipDeltaXY(Vehicle *v, int dir)
-{
-#define MKIT(d,c,b,a) ((a&0xFF)<<24) | ((b&0xFF)<<16) | ((c&0xFF)<<8) | ((d&0xFF)<<0)
+#define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0)
static const uint32 _delta_xy_table[8] = {
- MKIT( -3, -3, 6, 6),
- MKIT(-16, -3, 32, 6),
- MKIT( -3, -3, 6, 6),
- MKIT( -3, -16, 6, 32),
- MKIT( -3, -3, 6, 6),
- MKIT(-16, -3, 32, 6),
- MKIT( -3, -3, 6, 6),
- MKIT( -3, -16, 6, 32),
+ MKIT( 6, 6, -3, -3),
+ MKIT( 6, 32, -3, -16),
+ MKIT( 6, 6, -3, -3),
+ MKIT(32, 6, -16, -3),
+ MKIT( 6, 6, -3, -3),
+ MKIT( 6, 32, -3, -16),
+ MKIT( 6, 6, -3, -3),
+ MKIT(32, 6, -16, -3),
};
#undef MKIT
- uint32 x = _delta_xy_table[dir];
- v->x_offs = GB(x, 0, 8);
- v->y_offs = GB(x, 8, 8);
- v->sprite_width = GB(x, 16, 8);
- v->sprite_height = GB(x, 24, 8);
+
+ uint32 x = _delta_xy_table[direction];
+ this->x_offs = GB(x, 0, 8);
+ this->y_offs = GB(x, 8, 8);
+ this->sprite_width = GB(x, 16, 8);
+ this->sprite_height = GB(x, 24, 8);
+ this->z_height = 6;
}
void RecalcShipStuff(Vehicle *v)
{
- UpdateShipDeltaXY(v, v->direction);
+ v->UpdateDeltaXY(v->direction);
v->cur_image = GetShipImage(v, v->direction);
- MarkShipDirty(v);
+ v->MarkDirty();
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
@@ -376,10 +353,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 {
@@ -403,16 +380,16 @@
uint spd;
byte t;
- spd = min(v->cur_speed + 1, v->max_speed);
+ spd = min(v->cur_speed + 1, GetVehicleProperty(v, 0x0B, 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;
@@ -425,7 +402,7 @@
static int32 EstimateShipCost(EngineID engine_type)
{
- return ShipVehInfo(engine_type)->base_cost * (_price.ship_base>>3)>>5;
+ return GetEngineProperty(engine_type, 0x0A, ShipVehInfo(engine_type)->base_cost) * (_price.ship_base>>3)>>5;
}
static void ShipArrivesAt(const Vehicle* v, Station* st)
@@ -455,7 +432,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 +440,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));
}
@@ -502,7 +479,7 @@
pfs.best_bird_dist = (uint)-1;
pfs.best_length = (uint)-1;
- FollowTrack(tile, 0x3800 | TRANSPORT_WATER, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs);
+ FollowTrack(tile, 0x3800 | TRANSPORT_WATER, 0, (DiagDirection)_ship_search_directions[i][dir], (TPFEnumProc*)ShipTrackFollower, NULL, &pfs);
if (best_track != INVALID_TRACK) {
if (pfs.best_bird_dist != 0) {
@@ -537,18 +514,18 @@
{
void* perf = NpfBeginInterval();
- NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, owner, railtypes);
+ NPFFoundTargetData ret = NPFRouteToStationOrTile(tile, trackdir, target, type, 0, owner, railtypes);
int t = NpfEndInterval(perf);
DEBUG(yapf, 4, "[NPFW] %d us - %d rounds - %d open - %d closed -- ", t, 0, _aystar_stats_open_size, _aystar_stats_closed_size);
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)
{
- assert(enterdir>=0 && enterdir<=3);
+ assert(enterdir >= 0 && enterdir <= 3);
if (_patches.yapf.ship_use_yapf) {
Trackdir trackdir = YapfChooseShipTrack(v, tile, enterdir, tracks);
@@ -558,7 +535,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);
@@ -620,7 +597,7 @@
static TrackBits GetAvailShipTracks(TileIndex tile, int dir)
{
- uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER);
+ uint32 r = GetTileTrackStatus(tile, TRANSPORT_WATER, 0);
return (TrackBits)((r | r >> 8) & _ship_sometracks[dir]);
}
@@ -651,11 +628,11 @@
},
{
{ 0, 0, 0},
- { 8,15, 7},
+ { 8, 15, 7},
{ 0, 0, 0},
- { 8,15, 6},
+ { 8, 15, 6},
{ 0, 0, 0},
- { 7,15, 0},
+ { 7, 15, 0},
}
};
@@ -680,7 +657,7 @@
if (v->vehstatus & VS_STOPPED) return;
ProcessShipOrder(v);
- HandleShipLoading(v);
+ v->HandleLoading();
if (v->current_order.type == OT_LOADING) return;
@@ -731,19 +708,10 @@
/* 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 */
- v->BeginLoading();
- v->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
- v->current_order.flags |= OF_NON_STOP;
+ if (st->facilities & FACIL_DOCK) { // ugly, ugly workaround for problem with ships able to drop off cargo at wrong stations
ShipArrivesAt(v, st);
-
- SET_EXPENSES_TYPE(EXPENSES_SHIP_INC);
- if (LoadUnloadVehicle(v, true)) {
- InvalidateWindow(WC_SHIPS_LIST, v->owner);
- MarkShipDirty(v);
- }
- InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
- } else { /* leave stations without docks right aways */
+ v->BeginLoading();
+ } else { // leave stations without docks right aways
v->current_order.type = OT_LEAVESTATION;
v->cur_order_index++;
InvalidateVehicleOrder(v);
@@ -794,7 +762,7 @@
v->z_pos = GetSlopeZ(gp.x, gp.y);
getout:
- UpdateShipDeltaXY(v, dir);
+ v->UpdateDeltaXY(dir);
v->cur_image = GetShipImage(v, dir);
VehiclePositionChanged(v);
EndVehicleMove(v);
@@ -834,6 +802,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 +813,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);
@@ -876,13 +845,9 @@
y = TileY(tile) * TILE_SIZE + TILE_SIZE / 2;
v->x_pos = x;
v->y_pos = y;
- v->z_pos = GetSlopeZ(x,y);
+ v->z_pos = GetSlopeZ(x, y);
- v->z_height = 6;
- v->sprite_width = 6;
- v->sprite_height = 6;
- v->x_offs = -3;
- v->y_offs = -3;
+ v->UpdateDeltaXY(v->direction);
v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
v->spritenum = svi->image_index;
@@ -908,12 +873,14 @@
v->date_of_last_service = _date;
v->build_year = _cur_year;
v->cur_image = 0x0E5E;
- v->type = VEH_SHIP;
+ v = new (v) Ship();
v->random_bits = VehicleRandomBits();
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+ v->cargo_cap = GetVehicleProperty(v, 0x0D, svi->capacity);
+
VehiclePositionChanged(v);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@@ -930,6 +897,7 @@
/** Sell a ship.
* @param tile unused
+ * @param flags type of operation
* @param p1 vehicle ID to be sold
* @param p2 unused
*/
@@ -963,6 +931,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 +970,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)
@@ -1058,6 +1028,8 @@
if (dep == NULL) return_cmd_error(STR_981A_UNABLE_TO_FIND_LOCAL_DEPOT);
if (flags & DC_EXEC) {
+ if (v->current_order.type == OT_LOADING) v->LeaveStation();
+
v->dest_tile = dep->xy;
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
@@ -1073,10 +1045,13 @@
/** 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)
* - p2 = (bit 8-15) - the new cargo subtype to refit to
+ * - p2 = (bit 16) - refit only this vehicle (ignored)
+ * @return cost of refit or error
*/
int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -1118,7 +1093,7 @@
}
if (capacity == CALLBACK_FAILED) {
- capacity = ShipVehInfo(v->engine_type)->capacity;
+ capacity = GetVehicleProperty(v, 0x0D, ShipVehInfo(v->engine_type)->capacity);
}
_returned_refit_capacity = capacity;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/ship_gui.cpp
--- a/src/ship_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/ship_gui.cpp Sat Jun 02 19:59:29 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);
@@ -76,7 +78,7 @@
{
SetDParam(0, v->service_interval);
SetDParam(1, v->date_of_last_service);
- DrawString(13, 102, _patches.servint_ispercent?STR_SERVICING_INTERVAL_PERCENT:STR_883C_SERVICING_INTERVAL_DAYS, 0);
+ DrawString(13, 102, _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, 0);
}
DrawShipImage(v, 3, 57, INVALID_VEHICLE);
@@ -118,7 +120,7 @@
mod = _ctrl_pressed? 5 : 10;
goto do_change_service_int;
case 6: /* decrease int */
- mod = _ctrl_pressed?- 5 : -10;
+ mod = _ctrl_pressed ? - 5 : -10;
do_change_service_int:
v = GetVehicle(w->window_number);
@@ -155,7 +157,7 @@
static const WindowDesc _ship_details_desc = {
WDP_AUTO, WDP_AUTO, 405, 113,
- WC_VEHICLE_DETAILS,WC_VEHICLE_VIEW,
+ WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
_ship_details_widgets,
ShipDetailsWndProc
@@ -324,7 +326,7 @@
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_SEND_SHIP_TODEPOT, STR_982A_SEND_SHIP_TO_DEPOT},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 50, 67, SPR_REFIT_VEHICLE, STR_983A_REFIT_CARGO_SHIP_TO_CARRY},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 68, 85, SPR_SHOW_ORDERS, STR_9828_SHOW_SHIP_S_ORDERS},
-{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, SPR_SHOW_VEHICLE_DETAILS,STR_982B_SHOW_SHIP_DETAILS},
+{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 86, 103, SPR_SHOW_VEHICLE_DETAILS, STR_982B_SHOW_SHIP_DETAILS},
{ WWT_PUSHIMGBTN, RESIZE_LR, 14, 232, 249, 32, 49, SPR_CLONE_SHIP, STR_CLONE_SHIP_INFO},
{ WWT_PANEL, RESIZE_LRB, 14, 232, 249, 104, 103, 0x0, STR_NULL },
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 238, 249, 104, 115, 0x0, STR_NULL },
@@ -345,6 +347,6 @@
if (w != NULL) {
w->caption_color = v->owner;
- AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
+ AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), ZOOM_LVL_SHIP);
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/signs.cpp
--- a/src/signs.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/signs.cpp Sat Jun 02 19:59:29 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)
@@ -60,11 +64,14 @@
*/
static void MarkSignDirty(Sign *si)
{
+ /* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
+ * and there is no way for us to know which is the biggest. So make the
+ * biggest area dirty, and we are safe for sure. */
MarkAllViewportsDirty(
si->sign.left - 6,
si->sign.top - 3,
- si->sign.left + si->sign.width_1 * 4 + 12,
- si->sign.top + 45);
+ si->sign.left + ScaleByZoom(si->sign.width_1 + 12, ZOOM_LVL_MAX),
+ si->sign.top + ScaleByZoom(12, ZOOM_LVL_MAX));
}
/**
@@ -97,6 +104,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 +118,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
*/
@@ -127,7 +139,7 @@
si->x = x;
si->y = y;
si->owner = _current_player; // owner of the sign; just eyecandy
- si->z = GetSlopeZ(x,y);
+ si->z = GetSlopeZ(x, y);
UpdateSignVirtCoords(si);
MarkSignDirty(si);
InvalidateWindow(WC_SIGN_LIST, 0);
@@ -142,8 +154,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 +189,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 +205,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 +223,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 5a8b295aa345 -r 4cc327ad39d5 src/signs.h
--- a/src/signs.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/signs.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/signs_gui.cpp
--- a/src/signs_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/signs_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file signs_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/slope.h
--- a/src/slope.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/slope.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file slope.h */
+
#ifndef SLOPE_H
#define SLOPE_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/smallmap_gui.cpp
--- a/src/smallmap_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/smallmap_gui.cpp Sat Jun 02 19:59:29 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"
@@ -46,12 +49,24 @@
static int _smallmap_type;
static bool _smallmap_show_towns = true;
-#define MK(a,b) a, b
-#define MKEND() 0xFFFF
-#define MS(a,b) (a | 0x100), b
+/** Macro for ordinary entry of LegendAndColor */
+#define MK(a,b) {a, b, false, false}
+/** Macro for end of list marker in arrays of LegendAndColor */
+#define MKEND() {0, STR_NULL, true, false}
+/** Macro for break marker in arrays of LegendAndColor.
+ * It will have valid data, though */
+#define MS(a,b) {a, b, false, true}
-/* Legend text giving the colours to look for on the minimap */
-static const uint16 _legend_land_contours[] = {
+/** Structure for holding relevant data for legends in small map */
+struct LegendAndColour {
+ uint16 colour; ///< color of the item on the map
+ StringID legend; ///< string corresponding to the colored item
+ bool end; ///< this is the end of the list
+ bool col_break; ///< perform a break and go one collumn further
+};
+
+/** Legend text giving the colours to look for on the minimap */
+static const LegendAndColour _legend_land_contours[] = {
MK(0x5A, STR_00F0_100M),
MK(0x5C, STR_00F1_200M),
MK(0x5E, STR_00F2_300M),
@@ -66,7 +81,7 @@
MKEND()
};
-static const uint16 _legend_vehicles[] = {
+static const LegendAndColour _legend_vehicles[] = {
MK(0xB8, STR_00F5_TRAINS),
MK(0xBF, STR_00F6_ROAD_VEHICLES),
MK(0x98, STR_00F7_SHIPS),
@@ -76,73 +91,7 @@
MKEND()
};
-static const uint16 _legend_industries_normal[] = {
- MK(0xD7, STR_00FA_COAL_MINE),
- MK(0xB8, STR_00FB_POWER_STATION),
- MK(0x56, STR_00FC_FOREST),
- MK(0xC2, STR_00FD_SAWMILL),
- MK(0xBF, STR_00FE_OIL_REFINERY),
- MK(0x0F, STR_0105_BANK),
-
- MS(0x30, STR_00FF_FARM),
- MK(0xAE, STR_0100_FACTORY),
- MK(0x98, STR_0102_OIL_WELLS),
- MK(0x37, STR_0103_IRON_ORE_MINE),
- MK(0x0A, STR_0104_STEEL_MILL),
- MKEND()
-};
-
-static const uint16 _legend_industries_hilly[] = {
- MK(0xD7, STR_00FA_COAL_MINE),
- MK(0xB8, STR_00FB_POWER_STATION),
- MK(0x56, STR_00FC_FOREST),
- MK(0x0A, STR_0106_PAPER_MILL),
- MK(0xBF, STR_00FE_OIL_REFINERY),
- MK(0x37, STR_0108_FOOD_PROCESSING_PLANT),
- MS(0x30, STR_00FF_FARM),
-
- MK(0xAE, STR_0101_PRINTING_WORKS),
- MK(0x98, STR_0102_OIL_WELLS),
- MK(0xC2, STR_0107_GOLD_MINE),
- MK(0x0F, STR_0105_BANK),
- MKEND()
-};
-
-static const uint16 _legend_industries_desert[] = {
- MK(0xBF, STR_00FE_OIL_REFINERY),
- MK(0x98, STR_0102_OIL_WELLS),
- MK(0x0F, STR_0105_BANK),
- MK(0xB8, STR_0109_DIAMOND_MINE),
- MK(0x37, STR_0108_FOOD_PROCESSING_PLANT),
- MK(0x0A, STR_010A_COPPER_ORE_MINE),
- MK(0x30, STR_00FF_FARM),
- MS(0x56, STR_010B_FRUIT_PLANTATION),
-
- MK(0x27, STR_010C_RUBBER_PLANTATION),
- MK(0x25, STR_010D_WATER_SUPPLY),
- MK(0xD0, STR_010E_WATER_TOWER),
- MK(0xAE, STR_0100_FACTORY),
- MK(0xC2, STR_010F_LUMBER_MILL),
- MKEND()
-};
-
-static const uint16 _legend_industries_candy[] = {
- MK(0x30, STR_0110_COTTON_CANDY_FOREST),
- MK(0xAE, STR_0111_CANDY_FACTORY),
- MK(0x27, STR_0112_BATTERY_FARM),
- MK(0x37, STR_0113_COLA_WELLS),
- MK(0xD0, STR_0114_TOY_SHOP),
- MK(0x0A, STR_0115_TOY_FACTORY),
- MS(0x25, STR_0116_PLASTIC_FOUNTAINS),
-
- MK(0xB8, STR_0117_FIZZY_DRINK_FACTORY),
- MK(0x98, STR_0118_BUBBLE_GENERATOR),
- MK(0xC2, STR_0119_TOFFEE_QUARRY),
- MK(0x0F, STR_011A_SUGAR_MINE),
- MKEND()
-};
-
-static const uint16 _legend_routes[] = {
+static const LegendAndColour _legend_routes[] = {
MK(0xD7, STR_00EB_ROADS),
MK(0x0A, STR_00EC_RAILROADS),
MK(0xB5, STR_00EE_BUILDINGS_INDUSTRIES),
@@ -155,7 +104,7 @@
MKEND()
};
-static const uint16 _legend_vegetation[] = {
+static const LegendAndColour _legend_vegetation[] = {
MK(0x52, STR_0120_ROUGH_LAND),
MK(0x54, STR_0121_GRASS_LAND),
MK(0x37, STR_0122_BARE_LAND),
@@ -171,7 +120,7 @@
MKEND()
};
-static const uint16 _legend_land_owners[] = {
+static const LegendAndColour _legend_land_owners[] = {
MK(0xCA, STR_0126_WATER),
MK(0x54, STR_0127_NO_OWNER),
MK(0xB4, STR_0128_TOWNS),
@@ -182,20 +131,40 @@
#undef MS
#undef MKEND
+/** Allow room for all industries, plus a terminator entry
+ * This is required in order to have the indutry slots all filled up */
+static LegendAndColour _legend_from_industries[NUM_INDUSTRYTYPES+1];
-enum { IND_OFFS = 6 };
-static const uint16 * const _legend_table[] = {
+/**
+ * Fills an array for the industries legends.
+ */
+void BuildIndustriesLegend()
+{
+ const IndustrySpec *indsp;
+ uint j = 0;
+
+ /* Add each name */
+ for (IndustryType i = 0; i < NUM_INDUSTRYTYPES; i++) {
+ indsp = GetIndustrySpec(i);
+ if (indsp->enabled) {
+ _legend_from_industries[j].legend = indsp->name;
+ _legend_from_industries[j].colour = indsp->map_colour;
+ _legend_from_industries[j].col_break = (j % 6) == 0; // break is performed on the 7th item
+ _legend_from_industries[j].end = false;
+ j++;
+ }
+ }
+ /* Terminate the list */
+ _legend_from_industries[j].end = true;
+}
+
+static const LegendAndColour * const _legend_table[] = {
_legend_land_contours,
_legend_vehicles,
- NULL,
+ _legend_from_industries,
_legend_routes,
_legend_vegetation,
_legend_land_owners,
-
- _legend_industries_normal,
- _legend_industries_hilly,
- _legend_industries_desert,
- _legend_industries_candy,
};
#if defined(OTTD_ALIGNMENT)
@@ -332,13 +301,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);
}
@@ -380,7 +349,7 @@
/**
* Return the color a tile would be displayed with in the small map in mode "Vehicles".
*
- * @param t The tile of which we would like to get the color.
+ * @param tile The tile of which we would like to get the color.
* @return The color of tile in the small map in mode "Vehicles"
*/
static inline uint32 GetSmallMapVehiclesPixels(TileIndex tile)
@@ -390,32 +359,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 +370,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]);
@@ -436,7 +379,7 @@
/**
* Return the color a tile would be displayed with in the small map in mode "Routes".
*
- * @param t The tile of which we would like to get the color.
+ * @param tile The tile of which we would like to get the color.
* @return The color of tile in the small map in mode "Routes"
*/
static inline uint32 GetSmallMapRoutesPixels(TileIndex tile)
@@ -454,7 +397,7 @@
default: bits = MKCOLOR(0xFFFFFFFF); break;
}
} else {
- // ground color
+ /* ground color */
bits = ApplyMask(MKCOLOR(0x54545454), &_smallmap_contours_andor[t]);
}
return bits;
@@ -487,7 +430,7 @@
break;
case MP_INDUSTRY:
- bits = GetIndustryType(tile) == IT_FOREST ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5);
+ bits = GetIndustrySpec(GetIndustryByTile(tile)->type)->check_proc == CHECK_FOREST ? MKCOLOR(0xD0D0D0D0) : MKCOLOR(0xB5B5B5B5);
break;
case MP_TREES:
@@ -512,7 +455,7 @@
/**
* Return the color a tile would be displayed with in the small map in mode "Owner".
*
- * @param t The tile of which we would like to get the color.
+ * @param tile The tile of which we would like to get the color.
* @return The color of tile in the small map in mode "Owner"
*/
static inline uint32 GetSmallMapOwnerPixels(TileIndex tile)
@@ -576,7 +519,7 @@
* are drawn directly into the screen buffer. The final map is drawn in multiple passes.
* The passes are:
* - The colors of tiles in the different modes.
- * - Town names (optional)
+ * - Town names (optional)
*
* @param dpi pointer to pixel to write onto
* @param w pointer to Window struct
@@ -693,7 +636,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 +644,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 +680,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 +688,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);
@@ -802,7 +745,7 @@
{
switch (e->event) {
case WE_PAINT: {
- const uint16 *tbl;
+ const LegendAndColour *tbl;
int x, y, y_org;
DrawPixelInfo new_dpi;
@@ -810,22 +753,31 @@
SetDParam(0, STR_00E5_CONTOURS + _smallmap_type);
DrawWindowWidgets(w);
- /* draw the legend */
- tbl = _legend_table[(_smallmap_type != 2) ? _smallmap_type : (_opt.landscape + IND_OFFS)];
+ tbl = _legend_table[_smallmap_type];
+
x = 4;
y_org = w->height - 44 - 11;
y = y_org;
for (;;) {
GfxFillRect(x, y + 1, x + 8, y + 5, 0);
- GfxFillRect(x + 1, y + 2, x + 7, y + 4, (byte)tbl[0]);
- DrawString(x + 11, y, tbl[1], 0);
+ GfxFillRect(x + 1, y + 2, x + 7, y + 4, tbl->colour);
- tbl += 2;
+ if (_smallmap_type == 2) {
+ /* Industry name must be formated, since it's not in tiny font in the specs.
+ * So, draw with a parameter and use the STR_7065 string, which is tiny, black */
+ SetDParam(0, tbl->legend);
+ DrawString(x + 11, y, STR_7065, 0);
+ } else {
+ DrawString(x + 11, y, tbl->legend, 0);
+ }
+
+ tbl += 1;
y += 6;
- if (tbl[0] == 0xFFFF) {
+ if (tbl->end) { // end of the list
break;
- } else if (tbl[0] & 0x100) {
+ } else if (tbl->col_break) {
+ /* break asked, continue at top, 123 pixels (one "row") to the right */
x += 123;
y = y_org;
}
@@ -854,8 +806,8 @@
_left_button_clicked = false;
pt = RemapCoords(WP(w,smallmap_d).scroll_x, WP(w,smallmap_d).scroll_y, 0);
- WP(w2, vp_d).scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
- WP(w2, vp_d).scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
+ WP(w2, vp_d).dest_scrollpos_x = pt.x + ((_cursor.pos.x - w->left + 2) << 4) - (w2->viewport->virtual_width >> 1);
+ WP(w2, vp_d).dest_scrollpos_y = pt.y + ((_cursor.pos.y - w->top - 16) << 4) - (w2->viewport->virtual_height >> 1);
SetWindowDirty(w);
} break;
@@ -1033,9 +985,9 @@
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
- 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;
+ /* set this view to same location. Based on the center, adjusting for zoom */
+ WP(w2, vp_d).dest_scrollpos_x = x - (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
+ WP(w2, vp_d).dest_scrollpos_y = y - (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
} break;
case 8: { /* inverse location button (move this view to same spot as main view) 'Copy Location' */
@@ -1043,8 +995,8 @@
int x = WP(w2, const vp_d).scrollpos_x;
int y = WP(w2, const vp_d).scrollpos_y;
- WP(w, vp_d).scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
- WP(w, vp_d).scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
+ WP(w, vp_d).dest_scrollpos_x = x + (w2->viewport->virtual_width - w->viewport->virtual_width) / 2;
+ WP(w, vp_d).dest_scrollpos_y = y + (w2->viewport->virtual_height - w->viewport->virtual_height) / 2;
} break;
}
break;
@@ -1064,8 +1016,10 @@
_scrolling_viewport = false;
}
- WP(w, vp_d).scrollpos_x += e->we.scroll.delta.x << vp->zoom;
- WP(w, vp_d).scrollpos_y += e->we.scroll.delta.y << vp->zoom;
+ WP(w, vp_d).scrollpos_x += ScaleByZoom(e->we.scroll.delta.x, vp->zoom);
+ WP(w, vp_d).scrollpos_y += ScaleByZoom(e->we.scroll.delta.y, vp->zoom);
+ WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
+ WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
} break;
case WE_MOUSEWHEEL:
@@ -1094,21 +1048,23 @@
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)
- AssignWindowViewport(w, 3, 17, 294, 214, 0 , 0);
+ /* New viewport start ats (zero,zero) */
+ AssignWindowViewport(w, 3, 17, 294, 214, 0 , ZOOM_LVL_VIEWPORT);
- // 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;
WP(w, vp_d).scrollpos_y = y + (v->viewport->virtual_height - (214)) / 2;
+ WP(w, vp_d).dest_scrollpos_x = WP(w, vp_d).scrollpos_x;
+ WP(w, vp_d).dest_scrollpos_y = WP(w, vp_d).scrollpos_y;
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/sound.cpp
--- a/src/sound.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/sound.cpp Sat Jun 02 19:59:29 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;
@@ -149,7 +152,8 @@
}
-static const byte _vol_factor_by_zoom[] = {255, 190, 134};
+static const byte _vol_factor_by_zoom[] = {255, 190, 134, 87, 49};
+assert_compile(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
static const byte _sound_base_vol[] = {
128, 90, 128, 128, 128, 128, 128, 128,
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/sound.h
--- a/src/sound.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/sound.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file sound.h */
+
#ifndef SOUND_H
#define SOUND_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/sprite.h
--- a/src/sprite.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/sprite.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/spritecache.cpp
--- a/src/spritecache.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/spritecache.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file spritecache.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 5a8b295aa345 -r 4cc327ad39d5 src/spritecache.h
--- a/src/spritecache.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/spritecache.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file spritecache.h */
+
#ifndef SPRITECACHE_H
#define SPRITECACHE_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/station.cpp
--- a/src/station.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/station.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -55,12 +55,11 @@
}
/**
- * 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.
+ */
Station::~Station()
{
DEBUG(station, cDebugCtorLevel, "I-%3d", index);
@@ -106,7 +105,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) {
@@ -123,11 +122,14 @@
if (sign.width_1 != 0) {
InvalidateWindowWidget(WC_STATION_VIEW, index, 1);
+ /* We use ZOOM_LVL_MAX here, as every viewport can have an other zoom,
+ * and there is no way for us to know which is the biggest. So make the
+ * biggest area dirty, and we are safe for sure. */
MarkAllViewportsDirty(
sign.left - 6,
sign.top,
- sign.left + (sign.width_1 << 2) + 12,
- sign.top + 48);
+ sign.left + ScaleByZoom(sign.width_1 + 12, ZOOM_LVL_MAX),
+ sign.top + ScaleByZoom(12, ZOOM_LVL_MAX));
}
}
@@ -182,7 +184,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 5a8b295aa345 -r 4cc327ad39d5 src/station.h
--- a/src/station.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/station.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file station.h */
+
#ifndef STATION_H
#define STATION_H
@@ -8,7 +10,9 @@
#include "oldpool.h"
#include "sprite.h"
#include "tile.h"
+#include "road.h"
#include "newgrf_station.h"
+#include
static const StationID INVALID_STATION = 0xFFFF;
static const byte INITIAL_STATION_RATING = 175;
@@ -82,8 +86,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 +122,7 @@
const AirportFTAClass *Airport() const
{
- assert(airport_tile != 0);
+ if (airport_tile == 0) return GetAirport(AT_DUMMY);
return GetAirport(airport_type);
}
@@ -142,7 +146,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,10 +155,11 @@
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;
+ std::list loading_vehicles;
GoodsEntry goods[NUM_CARGO];
uint16 random_bits;
@@ -267,7 +272,7 @@
const DrawTileSprites *GetStationTileLayout(byte gfx);
-void StationPickerDrawSprite(int x, int y, RailType railtype, int image);
+void StationPickerDrawSprite(int x, int y, RailType railtype, RoadType roadtype, int image);
RoadStop * GetRoadStopByTile(TileIndex tile, RoadStop::Type type);
uint GetNumRoadStops(const Station* st, RoadStop::Type type);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/station_cmd.cpp
--- a/src/station_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/station_cmd.cpp Sat Jun 02 19:59:29 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"
@@ -40,6 +41,7 @@
#include "road.h"
#include "cargotype.h"
#include "table/station_air.h"
+#include "airport_states.h"
/**
* Called if a new block is added to the station-pool
@@ -119,7 +121,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);
@@ -199,7 +201,7 @@
Station *s;
FOR_ALL_STATIONS(s) {
- if (s != st && s->town==t) {
+ if (s != st && s->town == t) {
uint str = M(s->string_id);
if (str <= 0x20) {
if (str == M(STR_SV_STNAME_FOREST))
@@ -230,7 +232,7 @@
}
/* check close enough to town to get central as name? */
- if (DistanceMax(tile,t->xy) < 8) {
+ if (DistanceMax(tile, t->xy) < 8) {
found = M(STR_SV_STNAME);
if (HASBIT(free_names, M(STR_SV_STNAME))) goto done;
@@ -272,10 +274,10 @@
/* check direction compared to town */
{
static const int8 _direction_and_table[] = {
- ~( (1<xy)) * 2];
}
- tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30));
+ tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30));
if (tmp == 0) {
_error_message = STR_3007_TOO_MANY_STATIONS_LOADING;
return false;
@@ -368,7 +370,7 @@
}
SetDParam(0, st->index);
- AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
+ AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0);
}
// Get a list of the cargo types being produced around the tile.
@@ -615,7 +617,7 @@
// Tries to clear the given area. Returns the cost in case of success.
// Or an error code if it failed.
-int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station)
+int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true)
{
int32 cost = 0;
int allowed_z = -1;
@@ -655,10 +657,10 @@
int flat_z = z;
if (tileh != SLOPE_FLAT) {
// need to check so the entrance to the station is not pointing at a slope.
- if ((invalid_dirs&1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
- (invalid_dirs&2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
- (invalid_dirs&4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
- (invalid_dirs&8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
+ if ((invalid_dirs & 1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
+ (invalid_dirs & 2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
+ (invalid_dirs & 4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
+ (invalid_dirs & 8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
cost += _price.terraform;
@@ -767,7 +769,7 @@
{
int i = n;
do *layout++ = 0; while (--i);
- layout[((n-1) >> 1)-n] = 2;
+ layout[((n - 1) >> 1) - n] = 2;
return layout;
}
@@ -776,8 +778,8 @@
int i = n;
do *layout++ = b; while (--i);
if (n > 4) {
- layout[0-n] = 0;
- layout[n-1-n] = 0;
+ layout[0 - n] = 0;
+ layout[n - 1 - n] = 0;
}
return layout;
}
@@ -808,10 +810,12 @@
/** Build railroad station
* @param tile_org starting position of station dragging/placement
+ * @param flags operation to perform
* @param p1 various bitstuffed elements
* - p1 = (bit 0) - orientation (Axis)
* - p1 = (bit 8-15) - number of tracks
* - p1 = (bit 16-23) - platform length
+ * - p1 = (bit 24) - allow stations directly adjacent to other stations.
* @param p2 various bitstuffed elements
* - p2 = (bit 0- 3) - railtype (p2 & 0xF)
* - p2 = (bit 8-15) - custom station class
@@ -856,9 +860,33 @@
if (CmdFailed(ret)) return ret;
int32 cost = ret + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len;
- // Make sure there are no similar stations around us.
- Station *st = GetStationAround(tile_org, w_org, h_org, est);
- if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ Station *st = NULL;
+ bool check_surrounding = true;
+
+ if (_patches.adjacent_stations) {
+ if (est != INVALID_STATION) {
+ if (HASBIT(p1, 24)) {
+ /* You can't build an adjacent station over the top of one that
+ * already exists. */
+ return_cmd_error(STR_MUST_REMOVE_RAILWAY_STATION_FIRST);
+ } else {
+ /* Extend the current station, and don't check whether it will
+ * be near any other stations. */
+ st = GetStation(est);
+ check_surrounding = false;
+ }
+ } else {
+ /* There's no station here. Don't check the tiles surrounding this
+ * one if the player wanted to build an adjacent station. */
+ if (HASBIT(p1, 24)) check_surrounding = false;
+ }
+ }
+
+ if (check_surrounding) {
+ // Make sure there are no similar stations around us.
+ st = GetStationAround(tile_org, w_org, h_org, est);
+ if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ }
// See if there is a deleted station close to us.
if (st == NULL) st = GetClosestStationFromTile(tile_org);
@@ -953,7 +981,7 @@
int w = plat_len;
do {
byte layout = *layout_ptr++;
- MakeRailStation(tile, st->owner, st->index, axis, layout, (RailType)GB(p2, 0, 4));
+ MakeRailStation(tile, st->owner, st->index, axis, layout & ~1, (RailType)GB(p2, 0, 4));
SetCustomStationSpecIndex(tile, specindex);
SetStationTileRandomBits(tile, GB(Random(), 0, 4));
@@ -961,7 +989,7 @@
/* Use a fixed axis for GetPlatformInfo as our platforms / numtracks are always the right way around */
uint32 platinfo = GetPlatformInfo(AXIS_X, 0, plat_len, numtracks_orig, plat_len - w, numtracks_orig - numtracks, false);
uint16 callback = GetStationCallback(CBID_STATION_TILE_LAYOUT, platinfo, 0, statspec, st, tile);
- if (callback != CALLBACK_FAILED && callback < 8) SetStationGfx(tile, callback + axis);
+ if (callback != CALLBACK_FAILED && callback < 8) SetStationGfx(tile, (callback & ~1) + axis);
}
tile += tile_delta;
@@ -1042,43 +1070,78 @@
/** Remove a single tile from a railroad station.
* This allows for custom-built station with holes and weird layouts
* @param tile tile of station piece to remove
- * @param p1 unused
+ * @param flags operation to perform
+ * @param p1 start_tile
* @param p2 unused
*/
int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
+ TileIndex start = p1 == 0 ? tile : p1;
+
+ /* Count of the number of tiles removed */
+ int quantity = 0;
+
+ if (tile >= MapSize() || start >= MapSize()) return CMD_ERROR;
+
+ /* make sure sx,sy are smaller than ex,ey */
+ int ex = TileX(tile);
+ int ey = TileY(tile);
+ int sx = TileX(start);
+ int sy = TileY(start);
+ if (ex < sx) Swap(ex, sx);
+ if (ey < sy) Swap(ey, sy);
+ tile = TileXY(sx, sy);
+
+ int size_x = ex - sx + 1;
+ int size_y = ey - sy + 1;
+
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- // make sure the specified tile belongs to the current player, and that it is a railroad station.
- if (!IsTileType(tile, MP_STATION) || !IsRailwayStation(tile) || !_patches.nonuniform_stations) return CMD_ERROR;
- Station *st = GetStationByTile(tile);
- if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile))) return CMD_ERROR;
-
- // if we reached here, it means we can actually delete it. do that.
- if (flags & DC_EXEC) {
- uint specindex = GetCustomStationSpecIndex(tile);
- Track track = GetRailStationTrack(tile);
- DoClearSquare(tile);
- st->rect.AfterRemoveTile(st, tile);
- SetSignalsOnBothDir(tile, track);
- YapfNotifyTrackLayoutChange(tile, track);
-
- DeallocateSpecFromStation(st, specindex);
-
- // now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges.
- // we also need to adjust train_tile.
- MakeRailwayStationAreaSmaller(st);
- st->MarkTilesDirty();
- UpdateStationSignCoord(st);
-
- // if we deleted the whole station, delete the train facility.
- if (st->train_tile == 0) {
- st->facilities &= ~FACIL_TRAIN;
- UpdateStationVirtCoordDirty(st);
- DeleteStationIfEmpty(st);
+ /* Do the action for every tile into the area */
+ BEGIN_TILE_LOOP(tile2, size_x, size_y, tile) {
+ /* Make sure the specified tile belongs to the current player, and that it is a railroad station. */
+ if (!IsTileType(tile2, MP_STATION) || !IsRailwayStation(tile2) || !_patches.nonuniform_stations) {
+ continue;
}
- }
- return _price.remove_rail_station;
+
+ /* Check ownership of station */
+ Station *st = GetStationByTile(tile2);
+ if (_current_player != OWNER_WATER && (!CheckOwnership(st->owner) || !EnsureNoVehicle(tile2))) {
+ continue;
+ }
+
+ /* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
+ quantity++;
+
+ if (flags & DC_EXEC) {
+ uint specindex = GetCustomStationSpecIndex(tile2);
+ Track track = GetRailStationTrack(tile2);
+ DoClearSquare(tile2);
+ st->rect.AfterRemoveTile(st, tile2);
+ SetSignalsOnBothDir(tile2, track);
+ YapfNotifyTrackLayoutChange(tile2, track);
+
+ DeallocateSpecFromStation(st, specindex);
+
+ // now we need to make the "spanned" area of the railway station smaller if we deleted something at the edges.
+ // we also need to adjust train_tile.
+ MakeRailwayStationAreaSmaller(st);
+ st->MarkTilesDirty();
+ UpdateStationSignCoord(st);
+
+ // if we deleted the whole station, delete the train facility.
+ if (st->train_tile == 0) {
+ st->facilities &= ~FACIL_TRAIN;
+ UpdateStationVirtCoordDirty(st);
+ DeleteStationIfEmpty(st);
+ }
+ }
+ } END_TILE_LOOP(tile2, size_x, size_y, tile)
+
+ /* If we've not removed any tiles, give an error */
+ if (quantity == 0) return CMD_ERROR;
+
+ return _price.remove_rail_station * quantity;
}
@@ -1172,8 +1235,8 @@
}
/**
- * @param[in] truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
- * @param[in] station The station to do the whole procedure for
+ * @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK
+ * @param st The Station to do the whole procedure for
* @return a pointer to where to link a new RoadStop*
*/
static RoadStop **FindRoadStopSpot(bool truck_station, Station* st)
@@ -1181,10 +1244,10 @@
RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops;
if (*primary_stop == NULL) {
- //we have no roadstop of the type yet, so write a "primary stop"
+ /* we have no roadstop of the type yet, so write a "primary stop" */
return primary_stop;
} else {
- //there are stops already, so append to the end of the list
+ /* there are stops already, so append to the end of the list */
RoadStop *stop = *primary_stop;
while (stop->next != NULL) stop = stop->next;
return &stop->next;
@@ -1193,9 +1256,12 @@
/** Build a bus or truck stop
* @param tile tile to build the stop at
+ * @param flags operation to perform
* @param p1 entrance direction (DiagDirection)
* @param p2 bit 0: 0 for Bus stops, 1 for truck stops
* bit 1: 0 for normal, 1 for drive-through
+ * bit 2..4: the roadtypes
+ * bit 5: allow stations directly adjacent to other stations.
*/
int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -1203,32 +1269,50 @@
bool is_drive_through = HASBIT(p2, 1);
bool build_over_road = is_drive_through && IsTileType(tile, MP_STREET) && GetRoadTileType(tile) == ROAD_TILE_NORMAL;
bool town_owned_road = build_over_road && IsTileOwner(tile, OWNER_TOWN);
- Owner cur_owner = _current_player;
+ RoadTypes rts = (RoadTypes)GB(p2, 2, 3);
+
+ if (rts == ROADTYPES_NONE || HASBIT(rts, ROADTYPE_HWAY)) return CMD_ERROR;
+
+ /* Trams only have drive through stops */
+ if (!is_drive_through && HASBIT(rts, ROADTYPE_TRAM)) return CMD_ERROR;
/* Saveguard the parameters */
if (!IsValidDiagDirection((DiagDirection)p1)) return CMD_ERROR;
/* 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;
- /* 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 && (GetAllRoadBits(tile) & ((Axis)p1 == AXIS_X ? ROAD_Y : ROAD_X)) != 0) return_cmd_error(STR_DRIVE_THROUGH_ERROR_DIRECTION);
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
- if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
- return CMD_ERROR;
-
- if (build_over_road) flags ^= DC_AUTO;
-
- if (town_owned_road) _current_player = OWNER_TOWN;
- int32 ret = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL);
- _current_player = cur_owner;
- if (CmdFailed(ret)) return ret;
- int32 cost = build_over_road ? 0 : ret; // Don't add cost of clearing road when overbuilding
-
- Station *st = GetStationAround(tile, 1, 1, INVALID_STATION);
- if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
+
+ int32 cost = 0;
+
+ /* Not allowed to build over this road */
+ 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 (GetRoadTileType(tile) != ROAD_TILE_NORMAL) return CMD_ERROR;
+
+ /* Don't allow building the roadstop when vehicles are already driving on it */
+ if (!EnsureNoVehicleOnGround(tile)) return CMD_ERROR;
+
+ RoadTypes cur_rts = GetRoadTypes(tile);
+ if (GetRoadOwner(tile, ROADTYPE_ROAD) != OWNER_TOWN && HASBIT(cur_rts, ROADTYPE_ROAD) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_ROAD))) return CMD_ERROR;
+ if (HASBIT(cur_rts, ROADTYPE_TRAM) && !CheckOwnership(GetRoadOwner(tile, ROADTYPE_TRAM))) return CMD_ERROR;
+
+ /* Do not remove roadtypes! */
+ rts |= cur_rts;
+ }
+ cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, !build_over_road);
+ if (CmdFailed(cost)) return cost;
+
+ Station *st = NULL;
+
+ if (!_patches.adjacent_stations || !HASBIT(p2, 5)) {
+ st = GetStationAround(tile, 1, 1, INVALID_STATION);
+ if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ }
/* Find a station close to us */
if (st == NULL) st = GetClosestStationFromTile(tile);
@@ -1290,9 +1374,9 @@
RoadStop::Type rs_type = type ? RoadStop::TRUCK : RoadStop::BUS;
if (is_drive_through) {
- MakeDriveThroughRoadStop(tile, st->owner, st->index, rs_type, (Axis)p1, town_owned_road);
+ MakeDriveThroughRoadStop(tile, st->owner, st->index, rs_type, rts, (Axis)p1, town_owned_road);
} else {
- MakeRoadStop(tile, st->owner, st->index, rs_type, (DiagDirection)p1);
+ MakeRoadStop(tile, st->owner, st->index, rs_type, rts, (DiagDirection)p1);
}
UpdateStationVirtCoordDirty(st);
@@ -1357,6 +1441,7 @@
/** Remove a bus or truck stop
* @param tile tile to remove the stop from
+ * @param flags operation to perform
* @param p1 not used
* @param p2 bit 0: 0 for Bus stops, 1 for truck stops
*/
@@ -1367,22 +1452,21 @@
Station *st = GetStationByTile(tile);
/* Save the stop info before it is removed */
bool is_drive_through = IsDriveThroughStopTile(tile);
- RoadBits road_bits = GetAnyRoadBits(tile);
+ RoadTypes rts = GetRoadTypes(tile);
+ RoadBits road_bits = IsDriveThroughStopTile(tile) ?
+ ((GetRoadStopDir(tile) == DIAGDIR_NE) ? ROAD_X : ROAD_Y) :
+ DiagDirToRoadBits(GetRoadStopDir(tile));
bool is_towns_road = is_drive_through && GetStopBuiltOnTownRoad(tile);
int32 ret = RemoveRoadStop(st, flags, tile);
/* If the stop was a drive-through stop replace the road */
if ((flags & DC_EXEC) && !CmdFailed(ret) && is_drive_through) {
- uint index = 0;
- Owner cur_owner = _current_player;
-
- if (is_towns_road) {
- index = ClosestTownFromTile(tile, (uint)-1)->index;
- _current_player = OWNER_TOWN;
- }
- DoCommand(tile, road_bits, index, DC_EXEC, CMD_BUILD_ROAD);
- _current_player = cur_owner;
+ /* Rebuild the drive throuhg road stop. As a road stop can only be
+ * removed by the owner of the roadstop, _current_player is the
+ * owner of the road stop. */
+ MakeRoadNormal(tile, road_bits, rts, is_towns_road ? ClosestTownFromTile(tile, (uint)-1)->index : 0,
+ is_towns_road ? OWNER_TOWN : _current_player, _current_player, _current_player);
}
return ret;
@@ -1390,8 +1474,9 @@
/** Place an Airport.
* @param tile tile where airport will be built
+ * @param flags operation to perform
* @param p1 airport type, @see airport.h
- * @param p2 unused
+ * @param p2 (bit 0) - allow airports directly adjacent to other airports.
*/
int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -1430,8 +1515,12 @@
if (CmdFailed(ret)) return ret;
int32 cost = ret;
- Station *st = GetStationAround(tile, w, h, INVALID_STATION);
- if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ Station *st = NULL;
+
+ if (!_patches.adjacent_stations || !HASBIT(p2, 0)) {
+ st = GetStationAround(tile, w, h, INVALID_STATION);
+ if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ }
/* Find a station close to us */
if (st == NULL) st = GetClosestStationFromTile(tile);
@@ -1529,6 +1618,13 @@
int32 cost = w * h * _price.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;
+ }
+
{
const byte *b = _airport_sections[st->airport_type];
BEGIN_TILE_LOOP(tile_cur, w, h, tile)
@@ -1565,6 +1661,7 @@
/** Build a buoy.
* @param tile tile where to place the bouy
+ * @param flags operation to perform
* @param p1 unused
* @param p2 unused
*/
@@ -1673,7 +1770,8 @@
/** Build a dock/haven.
* @param tile tile where dock will be built
- * @param p1 unused
+ * @param flags operation to perform
+ * @param p1 (bit 0) - allow docks directly adjacent to other docks.
* @param p2 unused
*/
int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
@@ -1715,10 +1813,14 @@
}
/* middle */
- Station *st = GetStationAround(
- tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
- _dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION);
- if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ Station *st = NULL;
+
+ if (!_patches.adjacent_stations || !HASBIT(p1, 0)) {
+ st = GetStationAround(
+ tile + ToTileIndexDiff(_dock_tileoffs_chkaround[direction]),
+ _dock_w_chk[direction], _dock_h_chk[direction], INVALID_STATION);
+ if (st == CHECK_STATIONS_ERR) return CMD_ERROR;
+ }
/* Find a station close to us */
if (st == NULL) st = GetClosestStationFromTile(tile);
@@ -1813,7 +1915,15 @@
static void DrawTile_Station(TileInfo *ti)
{
const DrawTileSprites *t = NULL;
- RailType railtype = GetRailType(ti->tile);
+ RailType railtype;
+ RoadTypes roadtypes;
+ if (IsRailwayStation(ti->tile)) {
+ railtype = GetRailType(ti->tile);
+ roadtypes = ROADTYPES_NONE;
+ } else {
+ roadtypes = GetRoadTypes(ti->tile);
+ railtype = RAILTYPE_BEGIN;
+ }
const RailtypeInfo *rti = GetRailTypeInfo(railtype);
uint32 relocation = 0;
const Station *st = NULL;
@@ -1872,6 +1982,12 @@
if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC && IsStationTileElectrifiable(ti->tile)) DrawCatenary(ti);
+ if (HASBIT(roadtypes, ROADTYPE_TRAM)) {
+ Axis axis = GetRoadStopDir(ti->tile) == DIAGDIR_NE ? AXIS_X : AXIS_Y;
+ DrawGroundSprite((HASBIT(roadtypes, ROADTYPE_ROAD) ? SPR_TRAMWAY_OVERLAY : SPR_TRAMWAY_TRAM) + (axis ^ 1), PAL_NONE);
+ DrawTramCatenary(ti, axis == AXIS_X ? ROAD_X : ROAD_Y);
+ }
+
if (IsBuoyTile(ti->tile) && (ti->z != 0 || !IsTileOwner(ti->tile, OWNER_WATER))) DrawCanalWater(ti->tile);
const DrawTileSeqStruct *dtss;
@@ -1884,7 +2000,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)) {
@@ -1906,7 +2022,7 @@
}
}
-void StationPickerDrawSprite(int x, int y, RailType railtype, int image)
+void StationPickerDrawSprite(int x, int y, RailType railtype, RoadType roadtype, int image)
{
const RailtypeInfo *rti = GetRailTypeInfo(railtype);
SpriteID pal = PLAYER_SPRITE_COLOR(_local_player);
@@ -1915,6 +2031,10 @@
SpriteID img = t->ground_sprite;
DrawSprite(img + rti->total_offset, HASBIT(img, PALETTE_MODIFIER_COLOR) ? pal : PAL_NONE, x, y);
+ if (roadtype == ROADTYPE_TRAM) {
+ DrawSprite(SPR_TRAMWAY_TRAM + (t->ground_sprite == SPR_ROAD_PAVED_STRAIGHT_X ? 1 : 0), PAL_NONE, x, y);
+ }
+
const DrawTileSeqStruct *dtss;
foreach_draw_tile_seq(dtss, t->seq) {
Point pt = RemapCoords(dtss->delta_x, dtss->delta_y, dtss->delta_z);
@@ -1959,7 +2079,7 @@
}
-static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Station(TileIndex tile, TransportType mode, uint sub_mode)
{
switch (mode) {
case TRANSPORT_RAIL:
@@ -1981,7 +2101,7 @@
break;
case TRANSPORT_ROAD:
- if (IsRoadStopTile(tile)) {
+ if ((GetRoadTypes(tile) & sub_mode) != 0 && IsRoadStopTile(tile)) {
return AxisToTrackBits(DiagDirToAxis(GetRoadStopDir(tile))) * 0x101;
}
break;
@@ -2305,6 +2425,7 @@
/** Rename a station
* @param tile unused
+ * @param flags operation to perform
* @param p1 station ID that is to be renamed
* @param p2 unused
*/
@@ -2558,7 +2679,8 @@
if (!GetStopBuiltOnTownRoad(tile)) return true;
bool edge_road;
- return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile), OWNER_TOWN, &edge_road);
+ return CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_ROAD), OWNER_TOWN, &edge_road, ROADTYPE_ROAD) &&
+ CheckAllowRemoveRoad(tile, GetAnyRoadBits(tile, ROADTYPE_TRAM), OWNER_TOWN, &edge_road, ROADTYPE_TRAM);
}
static int32 ClearTile_Station(TileIndex tile, byte flags)
@@ -2567,8 +2689,8 @@
switch (GetStationType(tile)) {
case STATION_RAIL: return_cmd_error(STR_300B_MUST_DEMOLISH_RAILROAD);
case STATION_AIRPORT: return_cmd_error(STR_300E_MUST_DEMOLISH_AIRPORT_FIRST);
- case STATION_TRUCK: return_cmd_error(STR_3047_MUST_DEMOLISH_TRUCK_STATION);
- case STATION_BUS: return_cmd_error(STR_3046_MUST_DEMOLISH_BUS_STATION);
+ case STATION_TRUCK: return_cmd_error(HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_3047_MUST_DEMOLISH_CARGO_TRAM_STATION : STR_3047_MUST_DEMOLISH_TRUCK_STATION);
+ case STATION_BUS: return_cmd_error(HASBIT(GetRoadTypes(tile), ROADTYPE_TRAM) ? STR_3046_MUST_DEMOLISH_PASSENGER_TRAM_STATION : STR_3046_MUST_DEMOLISH_BUS_STATION);
case STATION_BUOY: return_cmd_error(STR_306A_BUOY_IN_THE_WAY);
case STATION_DOCK: return_cmd_error(STR_304D_MUST_DEMOLISH_DOCK_FIRST);
case STATION_OILRIG:
@@ -2711,6 +2833,8 @@
SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, 27, SL_MAX_VERSION),
SLE_CONDVAR(Station, num_specs, SLE_UINT8, 27, SL_MAX_VERSION),
+ SLE_CONDLST(Station, loading_vehicles, REF_VEHICLE, 57, SL_MAX_VERSION),
+
// reserve extra space in savegame here. (currently 32 bytes)
SLE_CONDNULL(32, 2, SL_MAX_VERSION),
@@ -2744,7 +2868,9 @@
static void SaveLoad_STNS(Station *st)
{
SlObject(st, _station_desc);
- for (CargoID i = 0; i < NUM_CARGO; i++) {
+
+ uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO;
+ for (CargoID i = 0; i < num_cargo; i++) {
SlObject(&st->goods[i], _goods_desc);
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/station_gui.cpp
--- a/src/station_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/station_gui.cpp Sat Jun 02 19:59:29 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;
@@ -683,7 +686,7 @@
sprite = cs->sprite;
}
- if (sprite == 0) return;
+ if (sprite == 0) sprite = SPR_CARGO_GOODS;
do {
DrawSprite(sprite, PAL_NONE, x, y);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/station_map.cpp
--- a/src/station_map.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/station_map.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,10 +1,17 @@
/* $Id$ */
+/** @file station_map.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "station_map.h"
-
+/**
+ * Get the station type (rail, airport, truck etc) for the given tile.
+ * @param t the tile to get the station type of.
+ * @pre IsTileType(t, MP_STATION)
+ * @return the station type of the given tile.
+ */
StationType GetStationType(TileIndex t)
{
assert(IsTileType(t, MP_STATION));
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/station_map.h
--- a/src/station_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/station_map.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,9 +1,12 @@
/* $Id$ */
+/** @file station_map.h */
+
#ifndef STATION_MAP_H
#define STATION_MAP_H
#include "rail_map.h"
+#include "road_map.h"
#include "station.h"
typedef byte StationGfx;
@@ -307,15 +310,17 @@
SetRailType(t, rt);
}
-static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, DiagDirection d)
+static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, DiagDirection d)
{
MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE : GFX_TRUCK_BASE) + d);
+ SetRoadTypes(t, rt);
}
-static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, Axis a, bool on_town_road)
+static inline void MakeDriveThroughRoadStop(TileIndex t, Owner o, StationID sid, RoadStop::Type rst, RoadTypes rt, Axis a, bool on_town_road)
{
MakeStation(t, o, sid, (rst == RoadStop::BUS ? GFX_BUS_BASE_EXT : GFX_TRUCK_BASE_EXT) + a);
SB(_m[t].m6, 3, 1, on_town_road);
+ SetRoadTypes(t, rt);
}
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section)
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/stdafx.h
--- a/src/stdafx.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/stdafx.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file stdafx.h */
+
#ifndef STDAFX_H
#define STDAFX_H
@@ -76,6 +78,9 @@
# ifdef amiga
# undef amiga
# endif
+/* Act like we already included this file, as it somehow gives linkage problems
+ * (mismatch linkage of C++ and C between this include and unistd.h). */
+#define CLIB_USERGROUP_PROTOS_H
#endif /* __MORPHOS__ */
#ifdef __APPLE__
@@ -107,7 +112,6 @@
# define FORCEINLINE inline
# define CDECL
# define __int64 long long
-# define NOT_REACHED() assert(0)
# define GCC_PACK __attribute__((packed))
# if (__GNUC__ == 2)
@@ -120,7 +124,6 @@
# define NORETURN
# define FORCEINLINE inline
# define CDECL
-# define NOT_REACHED() assert(0)
# define GCC_PACK
# include
#endif /* __WATCOMC__ */
@@ -158,11 +161,6 @@
# define FORCEINLINE __forceinline
# define inline _inline
# define CDECL _cdecl
-# if defined(_DEBUG)
-# define NOT_REACHED() assert(0)
-# else
-# define NOT_REACHED() _assume(0)
-# endif /* _DEBUG */
int CDECL snprintf(char *str, size_t size, const char *format, ...);
# if _MSC_VER < 1400
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
@@ -329,4 +327,12 @@
# define Point OTTD_AMIGA_POINT
#endif
+void
+#ifndef STRGEN
+/* In strgen error is not fatal and returns */
+NORETURN
+#endif /* STRGEN */
+CDECL error(const char *str, ...);
+#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
+
#endif /* STDAFX_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/strgen/strgen.cpp
--- a/src/strgen/strgen.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/strgen/strgen.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -506,6 +506,7 @@
{"WAYPOINT", EmitSingleChar, SCC_WAYPOINT_NAME, 1, 0}, // waypoint name
{"STATION", EmitSingleChar, SCC_STATION_NAME, 1, 0},
{"TOWN", EmitSingleChar, SCC_TOWN_NAME, 1, 0},
+ {"GROUP", EmitSingleChar, SCC_GROUP_NAME, 1, 0},
// 0x9D is used for the pseudo command SETCASE
// 0x9E is used for case switching
@@ -730,7 +731,7 @@
{
ParsedCommandStruct templ;
ParsedCommandStruct lang;
- int i,j;
+ int i, j;
bool result = true;
ExtractCommandString(&templ, b, true);
@@ -914,7 +915,7 @@
in = fopen(file, "r");
if (in == NULL) fatal("Cannot open file");
_cur_line = 1;
- while (fgets(buf, sizeof(buf),in) != NULL) {
+ while (fgets(buf, sizeof(buf), in) != NULL) {
rstrip(buf);
HandleString(buf, english);
_cur_line++;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/string.cpp
--- a/src/string.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/string.cpp Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/string.h
--- a/src/string.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/string.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/strings.cpp
--- a/src/strings.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/strings.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file strings.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "currency.h"
@@ -23,6 +25,8 @@
#include "industry.h"
#include "helpers.hpp"
#include "cargotype.h"
+#include "group.h"
+#include "debug.h"
/* for opendir/readdir/closedir */
# include "fios.h"
@@ -37,7 +41,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,34 +49,34 @@
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;
assert(argv);
result = (uint32)(*argv)[0] + ((uint64)(uint32)(*argv)[1] << 32);
- (*argv)+=2;
+ (*argv) += 2;
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 +89,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 +103,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 +132,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 +157,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 +194,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 +209,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 +345,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 +359,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 +370,7 @@
}
}
- // convert to ascii number and add commas
+ /* convert to ascii number and add commas */
p = endof(buf);
*--p = '\0';
j = 4;
@@ -381,65 +395,65 @@
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;
+ 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;
+ 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
- case 6:
- return n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
+ return n % 10 == 1 && n % 100 != 11 ? 0 : n % 10 >= 2 && (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 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 */
case 7:
- return n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;
+ 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;
+ return n % 100 == 1 ? 0 : n % 100 == 2 ? 1 : n % 100 == 3 || n % 100 == 4 ? 2 : 3;
}
}
@@ -447,7 +461,7 @@
{
// {Length of each string} {each string}
uint n = (byte)*b++;
- uint pos,i, mylen=0,mypos=0;
+ uint pos, i, mylen = 0, mypos = 0;
for (i = pos = 0; i != n; i++) {
uint len = (byte)*b++;
@@ -561,9 +575,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 +613,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 +627,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 +635,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 +643,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 +651,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 +667,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 +704,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 +762,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;
@@ -828,29 +842,41 @@
break;
}
+ case SCC_GROUP_NAME: { // {GROUP}
+ const Group *g = GetGroup(GetInt32(&argv));
+ int32 args[1];
+
+ assert(IsValidGroup(g));
+
+ args[0] = g->index;
+ buff = GetStringWithArgs(buff, (g->string_id == STR_SV_GROUP_NAME) ? (StringID)STR_GROUP_NAME_FORMAT : g->string_id, args, last);
+
+ break;
+ }
+
case SCC_CURRENCY_64: { // {CURRENCY64}
buff = FormatGenericCurrency(buff, _currency, GetInt64(&argv), false, last);
break;
}
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 +1044,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 +1066,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 +1076,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 +1132,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 +1162,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 5a8b295aa345 -r 4cc327ad39d5 src/strings.h
--- a/src/strings.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/strings.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file strings.h */
+
#ifndef STRINGS_H
#define STRINGS_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/subsidy_gui.cpp
--- a/src/subsidy_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/subsidy_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file subsidy_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "table/strings.h"
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/ai_rail.h
--- a/src/table/ai_rail.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/ai_rail.h Sat Jun 02 19:59:29 2007 +0000
@@ -21,7 +21,7 @@
};
-#define MKHDR(a,b,c,d,e) a,b,c,d,e,
+#define MKHDR(a, b, c, d, e) a, b, c, d, e,
#define MKDEPOT(a, b, c) {0, a, {b, c}}
#define MKSTATION(a, b, c) {1, a, {b, c}}
#define MKRAIL(a, b, c) {2, a, {b, c}}
@@ -424,17 +424,17 @@
#undef MKHDR
-#define MKHDR(a) a,{
+#define MKHDR(a) a, {
static const AiDefaultBlockData _roaddata_ai_0_data[] = {
- MKDEPOT(2, -1,1),
- MKSTATION(0x2, -1,0),
- MKRAIL(0xC, 0,0),
- MKRAIL(0x9, 0,1),
- MKCLRRAIL(0, 0,-1),
- MKCLRRAIL(0, 1,0),
- MKCLRRAIL(0, 1,1),
- MKCLRRAIL(0, 0,2),
+ MKDEPOT(2, -1, 1),
+ MKSTATION(0x2, -1, 0),
+ MKRAIL(0xC, 0, 0),
+ MKRAIL(0x9, 0, 1),
+ MKCLRRAIL(0, 0, -1),
+ MKCLRRAIL(0, 1, 0),
+ MKCLRRAIL(0, 1, 1),
+ MKCLRRAIL(0, 0, 2),
MKEND
};
@@ -443,14 +443,14 @@
};
static const AiDefaultBlockData _roaddata_ai_1_data[] = {
- MKDEPOT(1, 0,-1),
- MKSTATION(0x1, 1,-1),
- MKRAIL(0x3, 0,0),
- MKRAIL(0x9, 1,0),
- MKCLRRAIL(0, -1,0),
- MKCLRRAIL(0, 0,1),
- MKCLRRAIL(0, 1,1),
- MKCLRRAIL(0, 2,0),
+ MKDEPOT(1, 0, -1),
+ MKSTATION(0x1, 1, -1),
+ MKRAIL(0x3, 0, 0),
+ MKRAIL(0x9, 1, 0),
+ MKCLRRAIL(0, -1, 0),
+ MKCLRRAIL(0, 0, 1),
+ MKCLRRAIL(0, 1, 1),
+ MKCLRRAIL(0, 2, 0),
MKEND
};
@@ -459,14 +459,14 @@
};
static const AiDefaultBlockData _roaddata_ai_2_data[] = {
- MKDEPOT(3, 1,1),
- MKSTATION(0x3, 0,1),
- MKRAIL(0x6, 0,0),
- MKRAIL(0xC, 1,0),
- MKCLRRAIL(0, -1,0),
- MKCLRRAIL(0, 0,-1),
- MKCLRRAIL(0, 1,-1),
- MKCLRRAIL(0, 2,0),
+ MKDEPOT(3, 1, 1),
+ MKSTATION(0x3, 0, 1),
+ MKRAIL(0x6, 0, 0),
+ MKRAIL(0xC, 1, 0),
+ MKCLRRAIL(0, -1, 0),
+ MKCLRRAIL(0, 0, -1),
+ MKCLRRAIL(0, 1, -1),
+ MKCLRRAIL(0, 2, 0),
MKEND
};
@@ -475,14 +475,14 @@
};
static const AiDefaultBlockData _roaddata_ai_3_data[] = {
- MKDEPOT(0, 1,0),
- MKSTATION(0x0, 1,1),
- MKRAIL(0x6, 0,0),
- MKRAIL(0x3, 0,1),
- MKCLRRAIL(0, 0,-1),
- MKCLRRAIL(0, -1,0),
- MKCLRRAIL(0, -1,1),
- MKCLRRAIL(0, 0,2),
+ MKDEPOT(0, 1, 0),
+ MKSTATION(0x0, 1, 1),
+ MKRAIL(0x6, 0, 0),
+ MKRAIL(0x3, 0, 1),
+ MKCLRRAIL(0, 0, -1),
+ MKCLRRAIL(0, -1, 0),
+ MKCLRRAIL(0, -1, 1),
+ MKCLRRAIL(0, 0, 2),
MKEND
};
@@ -491,11 +491,11 @@
};
static const AiDefaultBlockData _roaddata_ai_4_data[] = {
- MKSTATION(0x2, -1,0),
- MKRAIL(0x8, 0,0),
- MKCLRRAIL(0, 0,-1),
- MKCLRRAIL(0, 1,0),
- MKCLRRAIL(0, 0,1),
+ MKSTATION(0x2, -1, 0),
+ MKRAIL(0x8, 0, 0),
+ MKCLRRAIL(0, 0, -1),
+ MKCLRRAIL(0, 1, 0),
+ MKCLRRAIL(0, 0, 1),
MKEND
};
@@ -504,11 +504,11 @@
};
static const AiDefaultBlockData _roaddata_ai_5_data[] = {
- MKSTATION(0x3, 0,1),
- MKRAIL(0x4, 0,0),
- MKCLRRAIL(0, -1,0),
- MKCLRRAIL(0, 0,-1),
- MKCLRRAIL(0, 1,0),
+ MKSTATION(0x3, 0, 1),
+ MKRAIL(0x4, 0, 0),
+ MKCLRRAIL(0, -1, 0),
+ MKCLRRAIL(0, 0, -1),
+ MKCLRRAIL(0, 1, 0),
MKEND
};
@@ -517,11 +517,11 @@
};
static const AiDefaultBlockData _roaddata_ai_6_data[] = {
- MKSTATION(0x0, 1,1),
- MKRAIL(0x2, 0,1),
- MKCLRRAIL(0, 0,0),
- MKCLRRAIL(0, -1,0),
- MKCLRRAIL(0, 0,2),
+ MKSTATION(0x0, 1, 1),
+ MKRAIL(0x2, 0, 1),
+ MKCLRRAIL(0, 0, 0),
+ MKCLRRAIL(0, -1, 0),
+ MKCLRRAIL(0, 0, 2),
MKEND
};
@@ -530,11 +530,11 @@
};
static const AiDefaultBlockData _roaddata_ai_7_data[] = {
- MKSTATION(0x1, 1,-1),
- MKRAIL(0x1, 1,0),
- MKCLRRAIL(0, 0,0),
- MKCLRRAIL(0, 1,1),
- MKCLRRAIL(0, 2,0),
+ MKSTATION(0x1, 1, -1),
+ MKRAIL(0x1, 1, 0),
+ MKCLRRAIL(0, 0, 0),
+ MKCLRRAIL(0, 1, 1),
+ MKCLRRAIL(0, 2, 0),
MKEND
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/build_industry.h
--- a/src/table/build_industry.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/build_industry.h Sat Jun 02 19:59:29 2007 +0000
@@ -5,54 +5,65 @@
#ifndef BUILD_INDUSTRY_H
#define BUILD_INDUSTRY_H
-#define MK(x,y, m) {{x, y}, m}
+/**
+ * Definition of an industry tiles layout.
+ * @param x offset x of this tile
+ * @param y offset y of this tile
+ * @param m index of the tile.
+ * @see _industry_specs
+ * @see IndustryTileTable
+ */
+#define MK(x, y, m) {{x, y}, m}
+/**
+ * Terminator of industry tiles layout definition
+ */
#define MKEND {{-0x80, 0}, 0}
static const IndustryTileTable _tile_table_coal_mine_0[] = {
- MK(1,1, 0),
- MK(1,2, 2),
- MK(0,0, 5),
- MK(1,0, 6),
- MK(2,0, 3),
- MK(2,2, 3),
+ MK(1, 1, 0),
+ MK(1, 2, 2),
+ MK(0, 0, 5),
+ MK(1, 0, 6),
+ MK(2, 0, 3),
+ MK(2, 2, 3),
MKEND
};
static const IndustryTileTable _tile_table_coal_mine_1[] = {
- MK(1,1, 0),
- MK(1,2, 2),
- MK(2,0, 0),
- MK(2,1, 2),
- MK(1,0, 3),
- MK(0,0, 3),
- MK(0,1, 4),
- MK(0,2, 4),
- MK(2,2, 4),
+ MK(1, 1, 0),
+ MK(1, 2, 2),
+ MK(2, 0, 0),
+ MK(2, 1, 2),
+ MK(1, 0, 3),
+ MK(0, 0, 3),
+ MK(0, 1, 4),
+ MK(0, 2, 4),
+ MK(2, 2, 4),
MKEND
};
static const IndustryTileTable _tile_table_coal_mine_2[] = {
- MK(0,0, 0),
- MK(0,1, 2),
- MK(0,2, 5),
- MK(1,0, 3),
- MK(1,1, 3),
- MK(1,2, 6),
+ MK(0, 0, 0),
+ MK(0, 1, 2),
+ MK(0, 2, 5),
+ MK(1, 0, 3),
+ MK(1, 1, 3),
+ MK(1, 2, 6),
MKEND
};
static const IndustryTileTable _tile_table_coal_mine_3[] = {
- MK(0,1, 0),
- MK(0,2, 2),
- MK(0,3, 4),
- MK(1,0, 5),
- MK(1,1, 0),
- MK(1,2, 2),
- MK(1,3, 3),
- MK(2,0, 6),
- MK(2,1, 4),
- MK(2,2, 3),
+ MK(0, 1, 0),
+ MK(0, 2, 2),
+ MK(0, 3, 4),
+ MK(1, 0, 5),
+ MK(1, 1, 0),
+ MK(1, 2, 2),
+ MK(1, 3, 3),
+ MK(2, 0, 6),
+ MK(2, 1, 4),
+ MK(2, 2, 3),
MKEND
};
@@ -64,36 +75,36 @@
};
static const IndustryTileTable _tile_table_power_station_0[] = {
- MK(0,0, 7),
- MK(0,1, 9),
- MK(1,0, 7),
- MK(1,1, 8),
- MK(2,0, 7),
- MK(2,1, 8),
- MK(3,0, 10),
- MK(3,1, 10),
+ MK(0, 0, 7),
+ MK(0, 1, 9),
+ MK(1, 0, 7),
+ MK(1, 1, 8),
+ MK(2, 0, 7),
+ MK(2, 1, 8),
+ MK(3, 0, 10),
+ MK(3, 1, 10),
MKEND
};
static const IndustryTileTable _tile_table_power_station_1[] = {
- MK(0,1, 7),
- MK(0,2, 7),
- MK(1,0, 8),
- MK(1,1, 8),
- MK(1,2, 7),
- MK(2,0, 9),
- MK(2,1, 10),
- MK(2,2, 9),
+ MK(0, 1, 7),
+ MK(0, 2, 7),
+ MK(1, 0, 8),
+ MK(1, 1, 8),
+ MK(1, 2, 7),
+ MK(2, 0, 9),
+ MK(2, 1, 10),
+ MK(2, 2, 9),
MKEND
};
static const IndustryTileTable _tile_table_power_station_2[] = {
- MK(0,0, 7),
- MK(0,1, 7),
- MK(1,0, 9),
- MK(1,1, 8),
- MK(2,0, 10),
- MK(2,1, 9),
+ MK(0, 0, 7),
+ MK(0, 1, 7),
+ MK(1, 0, 9),
+ MK(1, 1, 8),
+ MK(2, 0, 10),
+ MK(2, 1, 9),
MKEND
};
@@ -104,26 +115,26 @@
};
static const IndustryTileTable _tile_table_sawmill_0[] = {
- MK(1,0, 14),
- MK(1,1, 12),
- MK(1,2, 11),
- MK(2,0, 14),
- MK(2,1, 13),
- MK(0,0, 15),
- MK(0,1, 15),
- MK(0,2, 12),
+ MK(1, 0, 14),
+ MK(1, 1, 12),
+ MK(1, 2, 11),
+ MK(2, 0, 14),
+ MK(2, 1, 13),
+ MK(0, 0, 15),
+ MK(0, 1, 15),
+ MK(0, 2, 12),
MKEND
};
static const IndustryTileTable _tile_table_sawmill_1[] = {
- MK(0,0, 15),
- MK(0,1, 11),
- MK(0,2, 14),
- MK(1,0, 15),
- MK(1,1, 13),
- MK(1,2, 12),
- MK(2,0, 11),
- MK(2,1, 13),
+ MK(0, 0, 15),
+ MK(0, 1, 11),
+ MK(0, 2, 14),
+ MK(1, 0, 15),
+ MK(1, 1, 13),
+ MK(1, 2, 12),
+ MK(2, 0, 11),
+ MK(2, 1, 13),
MKEND
};
@@ -133,51 +144,51 @@
};
static const IndustryTileTable _tile_table_forest_0[] = {
- MK(0,0, 16),
- MK(0,1, 16),
- MK(0,2, 16),
- MK(0,3, 16),
- MK(1,0, 16),
- MK(1,1, 16),
- MK(1,2, 16),
- MK(1,3, 16),
- MK(2,0, 16),
- MK(2,1, 16),
- MK(2,2, 16),
- MK(2,3, 16),
- MK(3,0, 16),
- MK(3,1, 16),
- MK(3,2, 16),
- MK(3,3, 16),
- MK(1,4, 16),
- MK(2,4, 16),
+ MK(0, 0, 16),
+ MK(0, 1, 16),
+ MK(0, 2, 16),
+ MK(0, 3, 16),
+ MK(1, 0, 16),
+ MK(1, 1, 16),
+ MK(1, 2, 16),
+ MK(1, 3, 16),
+ MK(2, 0, 16),
+ MK(2, 1, 16),
+ MK(2, 2, 16),
+ MK(2, 3, 16),
+ MK(3, 0, 16),
+ MK(3, 1, 16),
+ MK(3, 2, 16),
+ MK(3, 3, 16),
+ MK(1, 4, 16),
+ MK(2, 4, 16),
MKEND
};
static const IndustryTileTable _tile_table_forest_1[] = {
- MK(0,0, 16),
- MK(1,0, 16),
- MK(2,0, 16),
- MK(3,0, 16),
- MK(4,0, 16),
- MK(0,1, 16),
- MK(1,1, 16),
- MK(2,1, 16),
- MK(3,1, 16),
- MK(4,1, 16),
- MK(0,2, 16),
- MK(1,2, 16),
- MK(2,2, 16),
- MK(3,2, 16),
- MK(4,2, 16),
- MK(0,3, 16),
- MK(1,3, 16),
- MK(2,3, 16),
- MK(3,3, 16),
- MK(4,3, 16),
- MK(1,4, 16),
- MK(2,4, 16),
- MK(3,4, 16),
+ MK(0, 0, 16),
+ MK(1, 0, 16),
+ MK(2, 0, 16),
+ MK(3, 0, 16),
+ MK(4, 0, 16),
+ MK(0, 1, 16),
+ MK(1, 1, 16),
+ MK(2, 1, 16),
+ MK(3, 1, 16),
+ MK(4, 1, 16),
+ MK(0, 2, 16),
+ MK(1, 2, 16),
+ MK(2, 2, 16),
+ MK(3, 2, 16),
+ MK(4, 2, 16),
+ MK(0, 3, 16),
+ MK(1, 3, 16),
+ MK(2, 3, 16),
+ MK(3, 3, 16),
+ MK(4, 3, 16),
+ MK(1, 4, 16),
+ MK(2, 4, 16),
+ MK(3, 4, 16),
MKEND
};
@@ -187,40 +198,40 @@
};
static const IndustryTileTable _tile_table_oil_refinery_0[] = {
- MK(0,0, 20),
- MK(0,1, 21),
- MK(0,2, 22),
- MK(0,3, 21),
- MK(1,0, 20),
- MK(1,1, 19),
- MK(1,2, 22),
- MK(1,3, 20),
- MK(2,1, 18),
- MK(2,2, 18),
- MK(2,3, 18),
- MK(3,2, 18),
- MK(3,3, 18),
- MK(2,0, 23),
- MK(3,1, 23),
+ MK(0, 0, 20),
+ MK(0, 1, 21),
+ MK(0, 2, 22),
+ MK(0, 3, 21),
+ MK(1, 0, 20),
+ MK(1, 1, 19),
+ MK(1, 2, 22),
+ MK(1, 3, 20),
+ MK(2, 1, 18),
+ MK(2, 2, 18),
+ MK(2, 3, 18),
+ MK(3, 2, 18),
+ MK(3, 3, 18),
+ MK(2, 0, 23),
+ MK(3, 1, 23),
MKEND
};
static const IndustryTileTable _tile_table_oil_refinery_1[] = {
- MK(0,0, 18),
- MK(0,1, 18),
- MK(0,2, 21),
- MK(0,3, 22),
- MK(0,4, 20),
- MK(1,0, 18),
- MK(1,1, 18),
- MK(1,2, 19),
- MK(1,3, 20),
- MK(2,0, 18),
- MK(2,1, 18),
- MK(2,2, 19),
- MK(2,3, 22),
- MK(1,4, 23),
- MK(2,4, 23),
+ MK(0, 0, 18),
+ MK(0, 1, 18),
+ MK(0, 2, 21),
+ MK(0, 3, 22),
+ MK(0, 4, 20),
+ MK(1, 0, 18),
+ MK(1, 1, 18),
+ MK(1, 2, 19),
+ MK(1, 3, 20),
+ MK(2, 0, 18),
+ MK(2, 1, 18),
+ MK(2, 2, 19),
+ MK(2, 3, 22),
+ MK(1, 4, 23),
+ MK(2, 4, 23),
MKEND
};
@@ -230,51 +241,51 @@
};
static const IndustryTileTable _tile_table_oil_rig_0[] = {
- MK(0,0, 24),
- MK(0,1, 24),
- MK(0,2, 25),
- MK(1,0, 26),
- MK(1,1, 27),
- MK(1,2, 28),
- MK(-4,-5, 255),
- MK(-4,-4, 255),
- MK(-4,-3, 255),
- MK(-4,-2, 255),
- MK(-4,-1, 255),
- MK(-4,0, 255),
- MK(-4,1, 255),
- MK(-4,2, 255),
- MK(-4,3, 255),
- MK(-4,4, 255),
- MK(-4,5, 255),
- MK(-3,5, 255),
- MK(-2,5, 255),
- MK(-1,5, 255),
- MK(0,6, 255),
- MK(1,6, 255),
- MK(2,6, 255),
- MK(3,6, 255),
- MK(4,6, 255),
- MK(5,6, 255),
- MK(5,5, 255),
- MK(5,4, 255),
- MK(5,3, 255),
- MK(5,2, 255),
- MK(5,1, 255),
- MK(5,0, 255),
- MK(5,-1, 255),
- MK(5,-2, 255),
- MK(5,-3, 255),
- MK(5,-4, 255),
- MK(4,-4, 255),
- MK(3,-4, 255),
- MK(2,-4, 255),
- MK(1,-4, 255),
- MK(0,-4, 255),
- MK(-1,-5, 255),
- MK(-2,-5, 255),
- MK(-3,-5, 255),
- MK(2,0, 255),
+ MK(0, 0, 24),
+ MK(0, 1, 24),
+ MK(0, 2, 25),
+ MK(1, 0, 26),
+ MK(1, 1, 27),
+ MK(1, 2, 28),
+ MK(-4, -5, 255),
+ MK(-4, -4, 255),
+ MK(-4, -3, 255),
+ MK(-4, -2, 255),
+ MK(-4, -1, 255),
+ MK(-4, 0, 255),
+ MK(-4, 1, 255),
+ MK(-4, 2, 255),
+ MK(-4, 3, 255),
+ MK(-4, 4, 255),
+ MK(-4, 5, 255),
+ MK(-3, 5, 255),
+ MK(-2, 5, 255),
+ MK(-1, 5, 255),
+ MK(0, 6, 255),
+ MK(1, 6, 255),
+ MK(2, 6, 255),
+ MK(3, 6, 255),
+ MK(4, 6, 255),
+ MK(5, 6, 255),
+ MK(5, 5, 255),
+ MK(5, 4, 255),
+ MK(5, 3, 255),
+ MK(5, 2, 255),
+ MK(5, 1, 255),
+ MK(5, 0, 255),
+ MK(5, -1, 255),
+ MK(5, -2, 255),
+ MK(5, -3, 255),
+ MK(5, -4, 255),
+ MK(4, -4, 255),
+ MK(3, -4, 255),
+ MK(2, -4, 255),
+ MK(1, -4, 255),
+ MK(0, -4, 255),
+ MK(-1, -5, 255),
+ MK(-2, -5, 255),
+ MK(-3, -5, 255),
+ MK(2, 0, 255),
MKEND
};
@@ -283,34 +294,34 @@
};
static const IndustryTileTable _tile_table_factory_0[] = {
- MK(0,0, 39),
- MK(0,1, 40),
- MK(1,0, 41),
- MK(1,1, 42),
- MK(0,2, 39),
- MK(0,3, 40),
- MK(1,2, 41),
- MK(1,3, 42),
- MK(2,1, 39),
- MK(2,2, 40),
- MK(3,1, 41),
- MK(3,2, 42),
+ MK(0, 0, 39),
+ MK(0, 1, 40),
+ MK(1, 0, 41),
+ MK(1, 1, 42),
+ MK(0, 2, 39),
+ MK(0, 3, 40),
+ MK(1, 2, 41),
+ MK(1, 3, 42),
+ MK(2, 1, 39),
+ MK(2, 2, 40),
+ MK(3, 1, 41),
+ MK(3, 2, 42),
MKEND
};
static const IndustryTileTable _tile_table_factory_1[] = {
- MK(0,0, 39),
- MK(0,1, 40),
- MK(1,0, 41),
- MK(1,1, 42),
- MK(2,0, 39),
- MK(2,1, 40),
- MK(3,0, 41),
- MK(3,1, 42),
- MK(1,2, 39),
- MK(1,3, 40),
- MK(2,2, 41),
- MK(2,3, 42),
+ MK(0, 0, 39),
+ MK(0, 1, 40),
+ MK(1, 0, 41),
+ MK(1, 1, 42),
+ MK(2, 0, 39),
+ MK(2, 1, 40),
+ MK(3, 0, 41),
+ MK(3, 1, 42),
+ MK(1, 2, 39),
+ MK(1, 3, 40),
+ MK(2, 2, 41),
+ MK(2, 3, 42),
MKEND
};
@@ -320,34 +331,34 @@
};
static const IndustryTileTable _tile_table_printing_works_0[] = {
- MK(0,0, 43),
- MK(0,1, 44),
- MK(1,0, 45),
- MK(1,1, 46),
- MK(0,2, 43),
- MK(0,3, 44),
- MK(1,2, 45),
- MK(1,3, 46),
- MK(2,1, 43),
- MK(2,2, 44),
- MK(3,1, 45),
- MK(3,2, 46),
+ MK(0, 0, 43),
+ MK(0, 1, 44),
+ MK(1, 0, 45),
+ MK(1, 1, 46),
+ MK(0, 2, 43),
+ MK(0, 3, 44),
+ MK(1, 2, 45),
+ MK(1, 3, 46),
+ MK(2, 1, 43),
+ MK(2, 2, 44),
+ MK(3, 1, 45),
+ MK(3, 2, 46),
MKEND
};
static const IndustryTileTable _tile_table_printing_works_1[] = {
- MK(0,0, 43),
- MK(0,1, 44),
- MK(1,0, 45),
- MK(1,1, 46),
- MK(2,0, 43),
- MK(2,1, 44),
- MK(3,0, 45),
- MK(3,1, 46),
- MK(1,2, 43),
- MK(1,3, 44),
- MK(2,2, 45),
- MK(2,3, 46),
+ MK(0, 0, 43),
+ MK(0, 1, 44),
+ MK(1, 0, 45),
+ MK(1, 1, 46),
+ MK(2, 0, 43),
+ MK(2, 1, 44),
+ MK(3, 0, 45),
+ MK(3, 1, 46),
+ MK(1, 2, 43),
+ MK(1, 3, 44),
+ MK(2, 2, 45),
+ MK(2, 3, 46),
MKEND
};
@@ -357,36 +368,36 @@
};
static const IndustryTileTable _tile_table_steel_mill_0[] = {
- MK(2,1, 52),
- MK(2,2, 53),
- MK(3,1, 54),
- MK(3,2, 55),
- MK(0,0, 56),
- MK(1,0, 57),
- MK(0,1, 56),
- MK(1,1, 57),
- MK(0,2, 56),
- MK(1,2, 57),
- MK(2,0, 56),
- MK(3,0, 57),
+ MK(2, 1, 52),
+ MK(2, 2, 53),
+ MK(3, 1, 54),
+ MK(3, 2, 55),
+ MK(0, 0, 56),
+ MK(1, 0, 57),
+ MK(0, 1, 56),
+ MK(1, 1, 57),
+ MK(0, 2, 56),
+ MK(1, 2, 57),
+ MK(2, 0, 56),
+ MK(3, 0, 57),
MKEND
};
static const IndustryTileTable _tile_table_steel_mill_1[] = {
- MK(0,0, 52),
- MK(0,1, 53),
- MK(1,0, 54),
- MK(1,1, 55),
- MK(2,0, 52),
- MK(2,1, 53),
- MK(3,0, 54),
- MK(3,1, 55),
- MK(0,2, 56),
- MK(1,2, 57),
- MK(2,2, 56),
- MK(3,2, 57),
- MK(1,3, 56),
- MK(2,3, 57),
+ MK(0, 0, 52),
+ MK(0, 1, 53),
+ MK(1, 0, 54),
+ MK(1, 1, 55),
+ MK(2, 0, 52),
+ MK(2, 1, 53),
+ MK(3, 0, 54),
+ MK(3, 1, 55),
+ MK(0, 2, 56),
+ MK(1, 2, 57),
+ MK(2, 2, 56),
+ MK(3, 2, 57),
+ MK(1, 3, 56),
+ MK(2, 3, 57),
MKEND
};
@@ -396,47 +407,47 @@
};
static const IndustryTileTable _tile_table_farm_0[] = {
- MK(1,0, 33),
- MK(1,1, 34),
- MK(1,2, 36),
- MK(0,0, 37),
- MK(0,1, 37),
- MK(0,2, 36),
- MK(2,0, 35),
- MK(2,1, 38),
- MK(2,2, 38),
+ MK(1, 0, 33),
+ MK(1, 1, 34),
+ MK(1, 2, 36),
+ MK(0, 0, 37),
+ MK(0, 1, 37),
+ MK(0, 2, 36),
+ MK(2, 0, 35),
+ MK(2, 1, 38),
+ MK(2, 2, 38),
MKEND
};
static const IndustryTileTable _tile_table_farm_1[] = {
- MK(1,1, 33),
- MK(1,2, 34),
- MK(0,0, 35),
- MK(0,1, 36),
- MK(0,2, 36),
- MK(0,3, 35),
- MK(1,0, 37),
- MK(1,3, 38),
- MK(2,0, 37),
- MK(2,1, 37),
- MK(2,2, 38),
- MK(2,3, 38),
+ MK(1, 1, 33),
+ MK(1, 2, 34),
+ MK(0, 0, 35),
+ MK(0, 1, 36),
+ MK(0, 2, 36),
+ MK(0, 3, 35),
+ MK(1, 0, 37),
+ MK(1, 3, 38),
+ MK(2, 0, 37),
+ MK(2, 1, 37),
+ MK(2, 2, 38),
+ MK(2, 3, 38),
MKEND
};
static const IndustryTileTable _tile_table_farm_2[] = {
- MK(2,0, 33),
- MK(2,1, 34),
- MK(0,0, 36),
- MK(0,1, 36),
- MK(0,2, 37),
- MK(0,3, 37),
- MK(1,0, 35),
- MK(1,1, 38),
- MK(1,2, 38),
- MK(1,3, 37),
- MK(2,2, 37),
- MK(2,3, 35),
+ MK(2, 0, 33),
+ MK(2, 1, 34),
+ MK(0, 0, 36),
+ MK(0, 1, 36),
+ MK(0, 2, 37),
+ MK(0, 3, 37),
+ MK(1, 0, 35),
+ MK(1, 1, 38),
+ MK(1, 2, 38),
+ MK(1, 3, 37),
+ MK(2, 2, 37),
+ MK(2, 3, 35),
MKEND
};
@@ -447,27 +458,27 @@
};
static const IndustryTileTable _tile_table_copper_mine_0[] = {
- MK(0,0, 47),
- MK(0,1, 49),
- MK(0,2, 51),
- MK(1,0, 47),
- MK(1,1, 49),
- MK(1,2, 50),
- MK(2,0, 51),
- MK(2,1, 51),
+ MK(0, 0, 47),
+ MK(0, 1, 49),
+ MK(0, 2, 51),
+ MK(1, 0, 47),
+ MK(1, 1, 49),
+ MK(1, 2, 50),
+ MK(2, 0, 51),
+ MK(2, 1, 51),
MKEND
};
static const IndustryTileTable _tile_table_copper_mine_1[] = {
- MK(0,0, 50),
- MK(0,1, 47),
- MK(0,2, 49),
- MK(1,0, 47),
- MK(1,1, 49),
- MK(1,2, 51),
- MK(2,0, 51),
- MK(2,1, 47),
- MK(2,2, 49),
+ MK(0, 0, 50),
+ MK(0, 1, 47),
+ MK(0, 2, 49),
+ MK(1, 0, 47),
+ MK(1, 1, 49),
+ MK(1, 2, 51),
+ MK(2, 0, 51),
+ MK(2, 1, 47),
+ MK(2, 2, 49),
MKEND
};
@@ -477,20 +488,20 @@
};
static const IndustryTileTable _tile_table_oil_well_0[] = {
- MK(0,0, 29),
- MK(1,0, 29),
- MK(2,0, 29),
- MK(0,1, 29),
- MK(0,2, 29),
+ MK(0, 0, 29),
+ MK(1, 0, 29),
+ MK(2, 0, 29),
+ MK(0, 1, 29),
+ MK(0, 2, 29),
MKEND
};
static const IndustryTileTable _tile_table_oil_well_1[] = {
- MK(0,0, 29),
- MK(1,0, 29),
- MK(1,1, 29),
- MK(2,2, 29),
- MK(2,3, 29),
+ MK(0, 0, 29),
+ MK(1, 0, 29),
+ MK(1, 1, 29),
+ MK(2, 2, 29),
+ MK(2, 3, 29),
MKEND
};
@@ -500,8 +511,8 @@
};
static const IndustryTileTable _tile_table_bank_0[] = {
- MK(0,0, 58),
- MK(1,0, 59),
+ MK(0, 0, 58),
+ MK(1, 0, 59),
MKEND
};
@@ -510,36 +521,36 @@
};
static const IndustryTileTable _tile_table_food_process_0[] = {
- MK(0,0, 60),
- MK(1,0, 60),
- MK(2,0, 60),
- MK(0,1, 60),
- MK(1,1, 60),
- MK(2,1, 60),
- MK(0,2, 61),
- MK(1,2, 61),
- MK(2,2, 63),
- MK(0,3, 62),
- MK(1,3, 62),
- MK(2,3, 63),
+ MK(0, 0, 60),
+ MK(1, 0, 60),
+ MK(2, 0, 60),
+ MK(0, 1, 60),
+ MK(1, 1, 60),
+ MK(2, 1, 60),
+ MK(0, 2, 61),
+ MK(1, 2, 61),
+ MK(2, 2, 63),
+ MK(0, 3, 62),
+ MK(1, 3, 62),
+ MK(2, 3, 63),
MKEND
};
static const IndustryTileTable _tile_table_food_process_1[] = {
- MK(0,0, 61),
- MK(1,0, 60),
- MK(2,0, 61),
- MK(3,0, 61),
- MK(0,1, 62),
- MK(1,1, 63),
- MK(2,1, 63),
- MK(3,1, 63),
- MK(0,2, 60),
- MK(1,2, 60),
- MK(2,2, 60),
- MK(3,2, 60),
- MK(0,3, 62),
- MK(1,3, 62),
+ MK(0, 0, 61),
+ MK(1, 0, 60),
+ MK(2, 0, 61),
+ MK(3, 0, 61),
+ MK(0, 1, 62),
+ MK(1, 1, 63),
+ MK(2, 1, 63),
+ MK(3, 1, 63),
+ MK(0, 2, 60),
+ MK(1, 2, 60),
+ MK(2, 2, 60),
+ MK(3, 2, 60),
+ MK(0, 3, 62),
+ MK(1, 3, 62),
MKEND
};
@@ -549,18 +560,18 @@
};
static const IndustryTileTable _tile_table_paper_mill_0[] = {
- MK(0,0, 64),
- MK(1,0, 65),
- MK(2,0, 66),
- MK(3,0, 67),
- MK(0,1, 68),
- MK(1,1, 69),
- MK(2,1, 67),
- MK(3,1, 67),
- MK(0,2, 66),
- MK(1,2, 71),
- MK(2,2, 71),
- MK(3,2, 70),
+ MK(0, 0, 64),
+ MK(1, 0, 65),
+ MK(2, 0, 66),
+ MK(3, 0, 67),
+ MK(0, 1, 68),
+ MK(1, 1, 69),
+ MK(2, 1, 67),
+ MK(3, 1, 67),
+ MK(0, 2, 66),
+ MK(1, 2, 71),
+ MK(2, 2, 71),
+ MK(3, 2, 70),
MKEND
};
@@ -569,22 +580,22 @@
};
static const IndustryTileTable _tile_table_gold_mine_0[] = {
- MK(0,0, 72),
- MK(0,1, 73),
- MK(0,2, 74),
- MK(0,3, 75),
- MK(1,0, 76),
- MK(1,1, 77),
- MK(1,2, 78),
- MK(1,3, 79),
- MK(2,0, 80),
- MK(2,1, 81),
- MK(2,2, 82),
- MK(2,3, 83),
- MK(3,0, 84),
- MK(3,1, 85),
- MK(3,2, 86),
- MK(3,3, 87),
+ MK(0, 0, 72),
+ MK(0, 1, 73),
+ MK(0, 2, 74),
+ MK(0, 3, 75),
+ MK(1, 0, 76),
+ MK(1, 1, 77),
+ MK(1, 2, 78),
+ MK(1, 3, 79),
+ MK(2, 0, 80),
+ MK(2, 1, 81),
+ MK(2, 2, 82),
+ MK(2, 3, 83),
+ MK(3, 0, 84),
+ MK(3, 1, 85),
+ MK(3, 2, 86),
+ MK(3, 3, 87),
MKEND
};
@@ -593,8 +604,8 @@
};
static const IndustryTileTable _tile_table_bank2_0[] = {
- MK(0,0, 89),
- MK(1,0, 90),
+ MK(0, 0, 89),
+ MK(1, 0, 90),
MKEND
};
@@ -603,15 +614,15 @@
};
static const IndustryTileTable _tile_table_diamond_mine_0[] = {
- MK(0,0, 91),
- MK(0,1, 92),
- MK(0,2, 93),
- MK(1,0, 94),
- MK(1,1, 95),
- MK(1,2, 96),
- MK(2,0, 97),
- MK(2,1, 98),
- MK(2,2, 99),
+ MK(0, 0, 91),
+ MK(0, 1, 92),
+ MK(0, 2, 93),
+ MK(1, 0, 94),
+ MK(1, 1, 95),
+ MK(1, 2, 96),
+ MK(2, 0, 97),
+ MK(2, 1, 98),
+ MK(2, 2, 99),
MKEND
};
@@ -620,22 +631,22 @@
};
static const IndustryTileTable _tile_table_iron_mine_0[] = {
- MK(0,0, 100),
- MK(0,1, 101),
- MK(0,2, 102),
- MK(0,3, 103),
- MK(1,0, 104),
- MK(1,1, 105),
- MK(1,2, 106),
- MK(1,3, 107),
- MK(2,0, 108),
- MK(2,1, 109),
- MK(2,2, 110),
- MK(2,3, 111),
- MK(3,0, 112),
- MK(3,1, 113),
- MK(3,2, 114),
- MK(3,3, 115),
+ MK(0, 0, 100),
+ MK(0, 1, 101),
+ MK(0, 2, 102),
+ MK(0, 3, 103),
+ MK(1, 0, 104),
+ MK(1, 1, 105),
+ MK(1, 2, 106),
+ MK(1, 3, 107),
+ MK(2, 0, 108),
+ MK(2, 1, 109),
+ MK(2, 2, 110),
+ MK(2, 3, 111),
+ MK(3, 0, 112),
+ MK(3, 1, 113),
+ MK(3, 2, 114),
+ MK(3, 3, 115),
MKEND
};
@@ -644,26 +655,26 @@
};
static const IndustryTileTable _tile_table_fruit_plantation_0[] = {
- MK(0,0, 116),
- MK(0,1, 116),
- MK(0,2, 116),
- MK(0,3, 116),
- MK(1,0, 116),
- MK(1,1, 116),
- MK(1,2, 116),
- MK(1,3, 116),
- MK(2,0, 116),
- MK(2,1, 116),
- MK(2,2, 116),
- MK(2,3, 116),
- MK(3,0, 116),
- MK(3,1, 116),
- MK(3,2, 116),
- MK(3,3, 116),
- MK(4,0, 116),
- MK(4,1, 116),
- MK(4,2, 116),
- MK(4,3, 116),
+ MK(0, 0, 116),
+ MK(0, 1, 116),
+ MK(0, 2, 116),
+ MK(0, 3, 116),
+ MK(1, 0, 116),
+ MK(1, 1, 116),
+ MK(1, 2, 116),
+ MK(1, 3, 116),
+ MK(2, 0, 116),
+ MK(2, 1, 116),
+ MK(2, 2, 116),
+ MK(2, 3, 116),
+ MK(3, 0, 116),
+ MK(3, 1, 116),
+ MK(3, 2, 116),
+ MK(3, 3, 116),
+ MK(4, 0, 116),
+ MK(4, 1, 116),
+ MK(4, 2, 116),
+ MK(4, 3, 116),
MKEND
};
@@ -672,26 +683,26 @@
};
static const IndustryTileTable _tile_table_rubber_plantation_0[] = {
- MK(0,0, 117),
- MK(0,1, 117),
- MK(0,2, 117),
- MK(0,3, 117),
- MK(1,0, 117),
- MK(1,1, 117),
- MK(1,2, 117),
- MK(1,3, 117),
- MK(2,0, 117),
- MK(2,1, 117),
- MK(2,2, 117),
- MK(2,3, 117),
- MK(3,0, 117),
- MK(3,1, 117),
- MK(3,2, 117),
- MK(3,3, 117),
- MK(4,0, 117),
- MK(4,1, 117),
- MK(4,2, 117),
- MK(4,3, 117),
+ MK(0, 0, 117),
+ MK(0, 1, 117),
+ MK(0, 2, 117),
+ MK(0, 3, 117),
+ MK(1, 0, 117),
+ MK(1, 1, 117),
+ MK(1, 2, 117),
+ MK(1, 3, 117),
+ MK(2, 0, 117),
+ MK(2, 1, 117),
+ MK(2, 2, 117),
+ MK(2, 3, 117),
+ MK(3, 0, 117),
+ MK(3, 1, 117),
+ MK(3, 2, 117),
+ MK(3, 3, 117),
+ MK(4, 0, 117),
+ MK(4, 1, 117),
+ MK(4, 2, 117),
+ MK(4, 3, 117),
MKEND
};
@@ -700,10 +711,10 @@
};
static const IndustryTileTable _tile_table_water_supply_0[] = {
- MK(0,0, 118),
- MK(0,1, 119),
- MK(1,0, 118),
- MK(1,1, 119),
+ MK(0, 0, 118),
+ MK(0, 1, 119),
+ MK(1, 0, 118),
+ MK(1, 1, 119),
MKEND
};
@@ -712,7 +723,7 @@
};
static const IndustryTileTable _tile_table_water_tower_0[] = {
- MK(0,0, 120),
+ MK(0, 0, 120),
MKEND
};
@@ -721,26 +732,26 @@
};
static const IndustryTileTable _tile_table_factory2_0[] = {
- MK(0,0, 121),
- MK(0,1, 122),
- MK(1,0, 123),
- MK(1,1, 124),
- MK(0,2, 121),
- MK(0,3, 122),
- MK(1,2, 123),
- MK(1,3, 124),
+ MK(0, 0, 121),
+ MK(0, 1, 122),
+ MK(1, 0, 123),
+ MK(1, 1, 124),
+ MK(0, 2, 121),
+ MK(0, 3, 122),
+ MK(1, 2, 123),
+ MK(1, 3, 124),
MKEND
};
static const IndustryTileTable _tile_table_factory2_1[] = {
- MK(0,0, 121),
- MK(0,1, 122),
- MK(1,0, 123),
- MK(1,1, 124),
- MK(2,0, 121),
- MK(2,1, 122),
- MK(3,0, 123),
- MK(3,1, 124),
+ MK(0, 0, 121),
+ MK(0, 1, 122),
+ MK(1, 0, 123),
+ MK(1, 1, 124),
+ MK(2, 0, 121),
+ MK(2, 1, 122),
+ MK(3, 0, 123),
+ MK(3, 1, 124),
MKEND
};
@@ -750,47 +761,47 @@
};
static const IndustryTileTable _tile_table_farm2_0[] = {
- MK(1,0, 33),
- MK(1,1, 34),
- MK(1,2, 36),
- MK(0,0, 37),
- MK(0,1, 37),
- MK(0,2, 36),
- MK(2,0, 35),
- MK(2,1, 38),
- MK(2,2, 38),
+ MK(1, 0, 33),
+ MK(1, 1, 34),
+ MK(1, 2, 36),
+ MK(0, 0, 37),
+ MK(0, 1, 37),
+ MK(0, 2, 36),
+ MK(2, 0, 35),
+ MK(2, 1, 38),
+ MK(2, 2, 38),
MKEND
};
static const IndustryTileTable _tile_table_farm2_1[] = {
- MK(1,1, 33),
- MK(1,2, 34),
- MK(0,0, 35),
- MK(0,1, 36),
- MK(0,2, 36),
- MK(0,3, 35),
- MK(1,0, 37),
- MK(1,3, 38),
- MK(2,0, 37),
- MK(2,1, 37),
- MK(2,2, 38),
- MK(2,3, 38),
+ MK(1, 1, 33),
+ MK(1, 2, 34),
+ MK(0, 0, 35),
+ MK(0, 1, 36),
+ MK(0, 2, 36),
+ MK(0, 3, 35),
+ MK(1, 0, 37),
+ MK(1, 3, 38),
+ MK(2, 0, 37),
+ MK(2, 1, 37),
+ MK(2, 2, 38),
+ MK(2, 3, 38),
MKEND
};
static const IndustryTileTable _tile_table_farm2_2[] = {
- MK(2,0, 33),
- MK(2,1, 34),
- MK(0,0, 36),
- MK(0,1, 36),
- MK(0,2, 37),
- MK(0,3, 37),
- MK(1,0, 35),
- MK(1,1, 38),
- MK(1,2, 38),
- MK(1,3, 37),
- MK(2,2, 37),
- MK(2,3, 35),
+ MK(2, 0, 33),
+ MK(2, 1, 34),
+ MK(0, 0, 36),
+ MK(0, 1, 36),
+ MK(0, 2, 37),
+ MK(0, 3, 37),
+ MK(1, 0, 35),
+ MK(1, 1, 38),
+ MK(1, 2, 38),
+ MK(1, 3, 37),
+ MK(2, 2, 37),
+ MK(2, 3, 35),
MKEND
};
@@ -801,10 +812,10 @@
};
static const IndustryTileTable _tile_table_lumber_mill_0[] = {
- MK(0,0, 125),
- MK(0,1, 126),
- MK(1,0, 127),
- MK(1,1, 128),
+ MK(0, 0, 125),
+ MK(0, 1, 126),
+ MK(1, 0, 127),
+ MK(1, 1, 128),
MKEND
};
@@ -813,51 +824,51 @@
};
static const IndustryTileTable _tile_table_cotton_candy_0[] = {
- MK(0,0, 129),
- MK(0,1, 129),
- MK(0,2, 129),
- MK(0,3, 129),
- MK(1,0, 129),
- MK(1,1, 129),
- MK(1,2, 129),
- MK(1,3, 129),
- MK(2,0, 129),
- MK(2,1, 129),
- MK(2,2, 129),
- MK(2,3, 129),
- MK(3,0, 129),
- MK(3,1, 129),
- MK(3,2, 129),
- MK(3,3, 129),
- MK(1,4, 129),
- MK(2,4, 129),
+ MK(0, 0, 129),
+ MK(0, 1, 129),
+ MK(0, 2, 129),
+ MK(0, 3, 129),
+ MK(1, 0, 129),
+ MK(1, 1, 129),
+ MK(1, 2, 129),
+ MK(1, 3, 129),
+ MK(2, 0, 129),
+ MK(2, 1, 129),
+ MK(2, 2, 129),
+ MK(2, 3, 129),
+ MK(3, 0, 129),
+ MK(3, 1, 129),
+ MK(3, 2, 129),
+ MK(3, 3, 129),
+ MK(1, 4, 129),
+ MK(2, 4, 129),
MKEND
};
static const IndustryTileTable _tile_table_cotton_candy_1[] = {
- MK(0,0, 129),
- MK(1,0, 129),
- MK(2,0, 129),
- MK(3,0, 129),
- MK(4,0, 129),
- MK(0,1, 129),
- MK(1,1, 129),
- MK(2,1, 129),
- MK(3,1, 129),
- MK(4,1, 129),
- MK(0,2, 129),
- MK(1,2, 129),
- MK(2,2, 129),
- MK(3,2, 129),
- MK(4,2, 129),
- MK(0,3, 129),
- MK(1,3, 129),
- MK(2,3, 129),
- MK(3,3, 129),
- MK(4,3, 129),
- MK(1,4, 129),
- MK(2,4, 129),
- MK(3,4, 129),
+ MK(0, 0, 129),
+ MK(1, 0, 129),
+ MK(2, 0, 129),
+ MK(3, 0, 129),
+ MK(4, 0, 129),
+ MK(0, 1, 129),
+ MK(1, 1, 129),
+ MK(2, 1, 129),
+ MK(3, 1, 129),
+ MK(4, 1, 129),
+ MK(0, 2, 129),
+ MK(1, 2, 129),
+ MK(2, 2, 129),
+ MK(3, 2, 129),
+ MK(4, 2, 129),
+ MK(0, 3, 129),
+ MK(1, 3, 129),
+ MK(2, 3, 129),
+ MK(3, 3, 129),
+ MK(4, 3, 129),
+ MK(1, 4, 129),
+ MK(2, 4, 129),
+ MK(3, 4, 129),
MKEND
};
@@ -867,34 +878,34 @@
};
static const IndustryTileTable _tile_table_candy_factory_0[] = {
- MK(0,0, 131),
- MK(0,1, 132),
- MK(1,0, 133),
- MK(1,1, 134),
- MK(0,2, 131),
- MK(0,3, 132),
- MK(1,2, 133),
- MK(1,3, 134),
- MK(2,1, 131),
- MK(2,2, 132),
- MK(3,1, 133),
- MK(3,2, 134),
+ MK(0, 0, 131),
+ MK(0, 1, 132),
+ MK(1, 0, 133),
+ MK(1, 1, 134),
+ MK(0, 2, 131),
+ MK(0, 3, 132),
+ MK(1, 2, 133),
+ MK(1, 3, 134),
+ MK(2, 1, 131),
+ MK(2, 2, 132),
+ MK(3, 1, 133),
+ MK(3, 2, 134),
MKEND
};
static const IndustryTileTable _tile_table_candy_factory_1[] = {
- MK(0,0, 131),
- MK(0,1, 132),
- MK(1,0, 133),
- MK(1,1, 134),
- MK(2,0, 131),
- MK(2,1, 132),
- MK(3,0, 133),
- MK(3,1, 134),
- MK(1,2, 131),
- MK(1,3, 132),
- MK(2,2, 133),
- MK(2,3, 134),
+ MK(0, 0, 131),
+ MK(0, 1, 132),
+ MK(1, 0, 133),
+ MK(1, 1, 134),
+ MK(2, 0, 131),
+ MK(2, 1, 132),
+ MK(3, 0, 133),
+ MK(3, 1, 134),
+ MK(1, 2, 131),
+ MK(1, 3, 132),
+ MK(2, 2, 133),
+ MK(2, 3, 134),
MKEND
};
@@ -904,26 +915,26 @@
};
static const IndustryTileTable _tile_table_battery_farm_0[] = {
- MK(0,0, 135),
- MK(0,1, 135),
- MK(0,2, 135),
- MK(0,3, 135),
- MK(1,0, 135),
- MK(1,1, 135),
- MK(1,2, 135),
- MK(1,3, 135),
- MK(2,0, 135),
- MK(2,1, 135),
- MK(2,2, 135),
- MK(2,3, 135),
- MK(3,0, 135),
- MK(3,1, 135),
- MK(3,2, 135),
- MK(3,3, 135),
- MK(4,0, 135),
- MK(4,1, 135),
- MK(4,2, 135),
- MK(4,3, 135),
+ MK(0, 0, 135),
+ MK(0, 1, 135),
+ MK(0, 2, 135),
+ MK(0, 3, 135),
+ MK(1, 0, 135),
+ MK(1, 1, 135),
+ MK(1, 2, 135),
+ MK(1, 3, 135),
+ MK(2, 0, 135),
+ MK(2, 1, 135),
+ MK(2, 2, 135),
+ MK(2, 3, 135),
+ MK(3, 0, 135),
+ MK(3, 1, 135),
+ MK(3, 2, 135),
+ MK(3, 3, 135),
+ MK(4, 0, 135),
+ MK(4, 1, 135),
+ MK(4, 2, 135),
+ MK(4, 3, 135),
MKEND
};
@@ -932,25 +943,25 @@
};
static const IndustryTileTable _tile_table_cola_wells_0[] = {
- MK(0,0, 137),
- MK(0,1, 137),
- MK(0,2, 137),
- MK(1,0, 137),
- MK(1,1, 137),
- MK(1,2, 137),
- MK(2,1, 137),
- MK(2,2, 137),
+ MK(0, 0, 137),
+ MK(0, 1, 137),
+ MK(0, 2, 137),
+ MK(1, 0, 137),
+ MK(1, 1, 137),
+ MK(1, 2, 137),
+ MK(2, 1, 137),
+ MK(2, 2, 137),
MKEND
};
static const IndustryTileTable _tile_table_cola_wells_1[] = {
- MK(0,1, 137),
- MK(0,2, 137),
- MK(0,3, 137),
- MK(1,0, 137),
- MK(1,1, 137),
- MK(1,2, 137),
- MK(2,1, 137),
+ MK(0, 1, 137),
+ MK(0, 2, 137),
+ MK(0, 3, 137),
+ MK(1, 0, 137),
+ MK(1, 1, 137),
+ MK(1, 2, 137),
+ MK(2, 1, 137),
MKEND
};
@@ -960,10 +971,10 @@
};
static const IndustryTileTable _tile_table_toy_shop_0[] = {
- MK(0,0, 138),
- MK(0,1, 139),
- MK(1,0, 140),
- MK(1,1, 141),
+ MK(0, 0, 138),
+ MK(0, 1, 139),
+ MK(1, 0, 140),
+ MK(1, 1, 141),
MKEND
};
@@ -972,14 +983,14 @@
};
static const IndustryTileTable _tile_table_toy_factory_0[] = {
- MK(0,0, 147),
- MK(0,1, 142),
- MK(1,0, 147),
- MK(1,1, 143),
- MK(2,0, 147),
- MK(2,1, 144),
- MK(3,0, 146),
- MK(3,1, 145),
+ MK(0, 0, 147),
+ MK(0, 1, 142),
+ MK(1, 0, 147),
+ MK(1, 1, 143),
+ MK(2, 0, 147),
+ MK(2, 1, 144),
+ MK(3, 0, 146),
+ MK(3, 1, 145),
MKEND
};
@@ -988,16 +999,16 @@
};
static const IndustryTileTable _tile_table_plastic_fountain_0[] = {
- MK(0,0, 148),
- MK(0,1, 151),
- MK(0,2, 154),
+ MK(0, 0, 148),
+ MK(0, 1, 151),
+ MK(0, 2, 154),
MKEND
};
static const IndustryTileTable _tile_table_plastic_fountain_1[] = {
- MK(0,0, 148),
- MK(1,0, 151),
- MK(2,0, 154),
+ MK(0, 0, 148),
+ MK(1, 0, 151),
+ MK(2, 0, 154),
MKEND
};
@@ -1007,10 +1018,10 @@
};
static const IndustryTileTable _tile_table_fizzy_drink_0[] = {
- MK(0,0, 156),
- MK(0,1, 157),
- MK(1,0, 158),
- MK(1,1, 159),
+ MK(0, 0, 156),
+ MK(0, 1, 157),
+ MK(1, 0, 158),
+ MK(1, 1, 159),
MKEND
};
@@ -1019,18 +1030,18 @@
};
static const IndustryTileTable _tile_table_bubble_generator_0[] = {
- MK(0,0, 163),
- MK(0,1, 160),
- MK(1,0, 163),
- MK(1,1, 161),
- MK(2,0, 163),
- MK(2,1, 162),
- MK(0,2, 163),
- MK(0,3, 160),
- MK(1,2, 163),
- MK(1,3, 161),
- MK(2,2, 163),
- MK(2,3, 162),
+ MK(0, 0, 163),
+ MK(0, 1, 160),
+ MK(1, 0, 163),
+ MK(1, 1, 161),
+ MK(2, 0, 163),
+ MK(2, 1, 162),
+ MK(0, 2, 163),
+ MK(0, 3, 160),
+ MK(1, 2, 163),
+ MK(1, 3, 161),
+ MK(2, 2, 163),
+ MK(2, 3, 162),
MKEND
};
@@ -1039,9 +1050,9 @@
};
static const IndustryTileTable _tile_table_toffee_quarry_0[] = {
- MK(0,0, 164),
- MK(1,0, 165),
- MK(2,0, 166),
+ MK(0, 0, 164),
+ MK(1, 0, 165),
+ MK(2, 0, 166),
MKEND
};
@@ -1050,14 +1061,14 @@
};
static const IndustryTileTable _tile_table_sugar_mine_0[] = {
- MK(0,0, 167),
- MK(0,1, 168),
- MK(1,0, 169),
- MK(1,1, 170),
- MK(2,0, 171),
- MK(2,1, 172),
- MK(3,0, 173),
- MK(3,1, 174),
+ MK(0, 0, 167),
+ MK(0, 1, 168),
+ MK(1, 0, 169),
+ MK(1, 1, 170),
+ MK(2, 0, 171),
+ MK(2, 1, 172),
+ MK(3, 0, 173),
+ MK(3, 1, 174),
MKEND
};
@@ -1068,659 +1079,706 @@
#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,
-};
+/** Array with saw sound, for sawmill */
+static const uint8 _sawmill_sounds[] = { SND_28_SAWMILL };
-#define MK(tbl, d, c1, c2, c3, proc, p1, r1, p2, r2, m, a1, a2, a3, pr, clim, in, intx, s1, s2, s3) \
- {tbl, lengthof(tbl), d, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m, \
- {a1, a2, a3}, pr, clim, in, intx, s1, s2, s3}
+/** Array with whistle sound, for factory */
+static const uint8 _factory_sounds[] = { SND_03_FACTORY_WHISTLE };
-static const IndustrySpec _industry_specs[] = {
+/** Array with 3 animal sounds, for farms */
+static const uint8 _farm_sounds[] = { SND_24_SHEEP, SND_25_COW, SND_26_HORSE };
+
+/** Array with... hem... a sound of toyland */
+static const uint8 _plastic_mine_sounds[] = { SND_33_PLASTIC_MINE };
+
+/**
+ * Writes the properties of an industry into the IndustrySpec struct.
+ * @param tbl tile table
+ * @param sndc number of sounds
+ * @param snd sounds table
+ * @param d cost multiplier
+ * @param ai1 appear chance ingame - temperate
+ * @param ai2 appear chance ingame - arctic
+ * @param ai3 appear chance ingame - tropic
+ * @param ai4 appear chance ingame - toyland
+ * @param ag1 appear chance random creation - temperate
+ * @param ag2 appear chance random creation - arctic
+ * @param ag3 appear chance random creation - tropic
+ * @param ag4 appear chance random creation - toyland
+ * @param col map colour
+ * @param c1 industry proximity refusal - 1st
+ * @param c2 industry proximity refusal - 2nd
+ * @param c3 industry proximity refusal - 3th
+ * @param proc check procedure index
+ * @param p1 produce cargo 1
+ * @param r1 rate of production 1
+ * @param p2 produce cargo 2
+ * @param r2 rate of production 1
+ * @param m minimum cargo moved to station
+ * @param a1 accepted cargo 1
+ * @param im1 input multiplier for cargo 1
+ * @param a2 accepted cargo 2
+ * @param im2 input multiplier for cargo 2
+ * @param a3 accepted cargo 3
+ * @param im3 input multiplier for cargo 3
+ * @param pr industry life (actually, the same as extractive, organic, processing in ttdpatch's specs)
+ * @param clim climate availaility
+ * @param bev industry behaviour
+ * @param in name
+ * @param intx text while building
+ * @param s1 text for closure
+ * @param s2 text for production up
+ * @param s3 text for production down
+ */
+
+#define MI(tbl, sndc, snd, d, ai1, ai2, ai3, ai4, ag1, ag2, ag3, ag4, col, \
+ c1, c2, c3, proc, p1, r1, p2, r2, m, a1, im1, a2, im2, a3, im3, pr, clim, bev, in, intx, s1, s2, s3) \
+ {tbl, lengthof(tbl), d, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m, \
+ {a1, a2, a3}, {{im1, 0}, {im2, 0}, {im3, 0}}, pr, clim, bev, col, in, intx, s1, s2, s3, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
+ sndc, snd, 0, 0, true, {0, 0, NULL, NULL, INVALID_INDUSTRYTYPE}}
/* Format:
- tile table cost multiplier
+ tile table count and sounds 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
+ 3 accepted cargo and their corresponding input multiplier
industry life climate availability
+ industry behaviours
industry name building text
messages : Closure production up production down */
- MK(_tile_table_coal_mine, 210,
+static const IndustrySpec _origin_industry_specs[NEW_INDUSTRYOFFSET] = {
+ MI(_tile_table_coal_mine, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TEMPERATE | 1 << LT_ARCTIC,
+ INDUSTRYBEH_CAN_SUBSIDENCE,
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,
+ MI(_tile_table_power_station, 0, NULL,
+ 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,
+ CT_COAL, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_NOT_CLOSABLE, 1 << LT_TEMPERATE | 1 << LT_ARCTIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_sawmill, 1, _sawmill_sounds,
+ 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,
+ CT_WOOD, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TEMPERATE,
+ 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,
+ MI(_tile_table_forest, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TEMPERATE | 1 << LT_ARCTIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_oil_refinery, 0, NULL,
+ 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,
+ CT_OIL, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TEMPERATE | 1 << LT_ARCTIC | 1 << LT_TROPIC,
+ INDUSTRYBEH_AIRPLANE_ATTACKS,
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,
+ MI(_tile_table_oil_rig, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TEMPERATE,
+ INDUSTRYBEH_BUILT_ONWATER | INDUSTRYBEH_AFTER_1960 | INDUSTRYBEH_AI_AIRSHIP_ROUTES,
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,
+ MI(_tile_table_factory, 1, _factory_sounds,
+ 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,
+ CT_LIVESTOCK, 256, CT_GRAIN , 256, CT_STEEL, 256,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TEMPERATE,
+ INDUSTRYBEH_CHOPPER_ATTACKS,
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,
+ MI(_tile_table_printing_works, 1, _factory_sounds,
+ 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,
+ CT_PAPER, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_ARCTIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_steel_mill, 0, NULL,
+ 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,
+ CT_IRON_ORE, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TEMPERATE,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_farm, 3, _farm_sounds,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TEMPERATE | 1 << LT_ARCTIC,
+ INDUSTRYBEH_PLANT_FIELDS | INDUSTRYBEH_PLANT_ON_BUILT,
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,
+ MI(_tile_table_copper_mine, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_oil_well, 0, NULL, 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TEMPERATE | 1 << LT_ARCTIC | 1 << LT_TROPIC,
+ INDUSTRYBEH_DONT_INCR_PROD | INDUSTRYBEH_BEFORE_1950,
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,
+ MI(_tile_table_bank, 0, NULL,
+ 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,
+ CT_VALUABLES, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_NOT_CLOSABLE, 1 << LT_TEMPERATE,
+ INDUSTRYBEH_TOWN1200_MORE | INDUSTRYBEH_ONLY_INTOWN,
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,
+ MI(_tile_table_food_process, 0, NULL,
+ 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,
+ CT_FRUIT, 256, CT_MAIZE, 256, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_ARCTIC | 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_paper_mill, 1, _sawmill_sounds,
+ 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,
+ CT_WOOD, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_ARCTIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_gold_mine, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
+ 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,
+ MI(_tile_table_bank2, 0, NULL,
+ 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,
+ CT_GOLD, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_NOT_CLOSABLE, 1 << LT_ARCTIC | 1 << LT_TROPIC,
+ INDUSTRYBEH_ONLY_INTOWN,
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,
+ MI(_tile_table_diamond_mine, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_iron_mine, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TEMPERATE,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_fruit_plantation, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_rubber_plantation, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_water_supply, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_water_tower, 0, NULL,
+ 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,
+ CT_WATER, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_NOT_CLOSABLE, 1 << LT_TROPIC,
+ INDUSTRYBEH_ONLY_INTOWN,
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,
+ MI(_tile_table_factory2, 1, _factory_sounds,
+ 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,
+ CT_RUBBER, 256, CT_COPPER_ORE, 256, CT_WOOD, 256,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TROPIC,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_farm2, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TROPIC,
+ INDUSTRYBEH_PLANT_FIELDS | INDUSTRYBEH_PLANT_ON_BUILT,
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,
+ MI(_tile_table_lumber_mill, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TROPIC,
+ INDUSTRYBEH_CUT_TREES,
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,
+ MI(_tile_table_cotton_candy, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_candy_factory, 0, NULL,
+ 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,
+ CT_SUGAR, 256, CT_TOFFEE, 256, CT_COTTON_CANDY, 256,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_battery_farm, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_cola_wells, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_toy_shop, 0, NULL,
+ 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,
+ CT_TOYS, 256, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_NOT_CLOSABLE, 1 << LT_TOYLAND,
+ INDUSTRYBEH_ONLY_NEARTOWN,
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,
+ MI(_tile_table_toy_factory, 0, NULL,
+ 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,
+ CT_PLASTIC, 256, CT_BATTERIES, 256, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_plastic_fountain, 1, _plastic_mine_sounds,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_fizzy_drink, 0, NULL,
+ 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,
+ CT_COLA, 256, CT_BUBBLES, 256, CT_INVALID, 0,
INDUSTRYLIFE_CLOSABLE, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_bubble_generator, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_toffee_quarry, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
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,
+ MI(_tile_table_sugar_mine, 0, NULL,
+ 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,
+ CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, 0,
INDUSTRYLIFE_PRODUCTION, 1 << LT_TOYLAND,
+ INDUSTRYBEH_NONE,
STR_4826_SUGAR_MINE, STR_482D_NEW_UNDER_CONSTRUCTION,
STR_4832_ANNOUNCES_IMMINENT_CLOSURE, STR_4835_INCREASES_PRODUCTION, STR_4839_PRODUCTION_DOWN_BY_50),
};
-#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
-};
+#undef MI
-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
- * @param c3 and third cargo. Those three are in an array
- * @param s1 slope refused upon choosing a place to build
- * @param a1 animation frame on production
- * @param a2 next frame of animation
- * @param a3 chosses between animation of construction state
+/** Writes the properties of an industry tile into the IndustryTileSpec struct.
+ * @param ca1 acceptance of first cargo
+ * @param c1 first type of cargo accepted for this tile
+ * @param ca2 acceptance of second cargo
+ * @param c2 second cargo
+ * @param ca3 acceptance of third cargo
+ * @param c3 and third cargo. Those three are in an array
+ * @param s1 slope refused upon choosing a place to build
+ * @param a1 animation frame on production
+ * @param a2 next frame of animation
+ * @param a3 chooses between animation or construction state
*/
-#define MK(c1, c2, c3, sl, a1, a2, a3) {{c1, c2, c3}, sl, a1, a2, a3}
-static const IndustryTileSpec _industry_tile_specs[] = {
+#define MT(ca1, c1, ca2, c2, ca3, c3, sl, a1, a2, a3) {{c1, c2, c3}, {ca1, ca2, ca3}, sl, a1, a2, a3, 0, true, {0, 0, NULL, NULL, 0}}
+static const IndustryTileSpec _origin_industry_tile_specs[NEW_INDUSTRYTILEOFFSET] = {
/* Coal Mine */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, true),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Power Station */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_COAL, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_COAL, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Sawmill */
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Forest Artic, temperate */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, 17, INDUTILE_NOANIM, false), // Chopping forest
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, 16, false), // Growing forest
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, 17, INDUSTRYTILE_NOANIM, false), ///< Chopping forest
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, 16, false), ///< Growing forest
/* Oil refinery */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_OIL, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_OIL, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* oil Rig */
- MK(CT_INVALID, CT_INVALID, CT_PASSENGERS, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_MAIL, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_PASSENGERS, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_MAIL, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Oil Wells artic, temperate */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, true ),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, true ),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, true ),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true ),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true ),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true ),
/* Farm tropic, arctic and temperate */
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Factory temperate */
- MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_GRAIN, CT_STEEL, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(8, CT_GRAIN, 8, CT_STEEL, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_GRAIN, 8, CT_STEEL, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_GRAIN, 8, CT_STEEL, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_GRAIN, 8, CT_STEEL, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Printing works */
- MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_PAPER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_PAPER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_PAPER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_PAPER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_PAPER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Copper ore mine */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, true ),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true ),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Steel mill */
- MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_IRON_ORE, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_IRON_ORE, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_IRON_ORE, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_IRON_ORE, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_IRON_ORE, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_IRON_ORE, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_IRON_ORE, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Bank temperate*/
- MK(CT_PASSENGERS, CT_INVALID, CT_VALUABLES, SLOPE_E, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_PASSENGERS, CT_INVALID, CT_VALUABLES, SLOPE_S, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_VALUABLES, SLOPE_E, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(1, CT_PASSENGERS, 0, CT_INVALID, 8, CT_VALUABLES, SLOPE_S, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Food processing plant, tropic and arctic. CT_MAIZE or CT_WHEAT, CT_LIVESTOCK or CT_FRUIT*/
- MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_MAIZE, CT_INVALID, CT_LIVESTOCK, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(8, CT_MAIZE, 0, CT_INVALID, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_MAIZE, 0, CT_INVALID, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_MAIZE, 0, CT_INVALID, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_MAIZE, 0, CT_INVALID, 8, CT_LIVESTOCK, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Paper mill */
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_WOOD, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WOOD, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Gold mine */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, true ),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, true ),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Bank Sub Arctic */
- MK(CT_INVALID, CT_INVALID, CT_GOLD, SLOPE_E, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_GOLD, SLOPE_S, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_GOLD, SLOPE_E, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_GOLD, SLOPE_S, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Diamond mine */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Iron ore Mine */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Fruit plantation */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Rubber plantation */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Water supply */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Water tower */
- MK(CT_INVALID, CT_INVALID, CT_WATER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_WATER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Factory (sub-tropical) */
- MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_COPPER_ORE, CT_WOOD, CT_RUBBER, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(8, CT_COPPER_ORE, 8, CT_WOOD, 8, CT_RUBBER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_COPPER_ORE, 8, CT_WOOD, 8, CT_RUBBER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_COPPER_ORE, 8, CT_WOOD, 8, CT_RUBBER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_COPPER_ORE, 8, CT_WOOD, 8, CT_RUBBER, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Lumber mill */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Candyfloss forest */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, 130, INDUTILE_NOANIM, false), // Chopping candyfloss
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, 129, false), // Growing candyfloss
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, 130, INDUSTRYTILE_NOANIM, false), ///< Chopping candyfloss
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, 129, false), ///< Growing candyfloss
/* Sweet factory */
- MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_COTTON_CANDY, CT_TOFFEE, CT_SUGAR, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(8, CT_COTTON_CANDY, 8, CT_TOFFEE, 8, CT_SUGAR, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_COTTON_CANDY, 8, CT_TOFFEE, 8, CT_SUGAR, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_COTTON_CANDY, 8, CT_TOFFEE, 8, CT_SUGAR, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_COTTON_CANDY, 8, CT_TOFFEE, 8, CT_SUGAR, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Batter farm */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, 136, INDUTILE_NOANIM, false), // Reaping batteries
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, 135, false), // Growing batteries
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, 136, INDUSTRYTILE_NOANIM, false), ///< Reaping batteries
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, 135, false), ///< Growing batteries
/* Cola wells */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Toy shop */
- MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_TOYS, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_TOYS, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_TOYS, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_TOYS, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 8, CT_TOYS, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Toy factory */
- MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BATTERIES, CT_INVALID, CT_PLASTIC, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(8, CT_BATTERIES, 0, CT_INVALID, 8, CT_PLASTIC, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BATTERIES, 0, CT_INVALID, 8, CT_PLASTIC, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BATTERIES, 0, CT_INVALID, 8, CT_PLASTIC, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BATTERIES, 0, CT_INVALID, 8, CT_PLASTIC, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BATTERIES, 0, CT_INVALID, 8, CT_PLASTIC, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BATTERIES, 0, CT_INVALID, 8, CT_PLASTIC, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Plastic Fountain */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Fizzy drink factory */
- MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_BUBBLES, CT_INVALID, CT_COLA, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(8, CT_BUBBLES, 0, CT_INVALID, 8, CT_COLA, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BUBBLES, 0, CT_INVALID, 8, CT_COLA, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BUBBLES, 0, CT_INVALID, 8, CT_COLA, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(8, CT_BUBBLES, 0, CT_INVALID, 8, CT_COLA, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Bubble generator */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Toffee quarry */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
/* Sugar mine */
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
- MK(CT_INVALID, CT_INVALID, CT_INVALID, SLOPE_STEEP, INDUTILE_NOANIM, INDUTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
+ MT(0, CT_INVALID, 0, CT_INVALID, 0, CT_INVALID, SLOPE_STEEP, INDUSTRYTILE_NOANIM, INDUSTRYTILE_NOANIM, false),
};
-#undef MK
+#undef MT
#endif /* BUILD_INDUSTRY_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/cargo_const.h
--- a/src/table/cargo_const.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/cargo_const.h Sat Jun 02 19:59:29 2007 +0000
@@ -17,10 +17,16 @@
STR_0011_MAIL, STR_0031_MAIL, STR_BAGS, STR_QUANTITY_MAIL, STR_ABBREV_MAIL,
SPR_CARGO_MAIL, CC_MAIL ),
+ /* Oil in temperate and arctic */
MK( 3, 'OIL_', 174, 16, 4437, 25, 255, true, TE_NONE,
STR_0012_OIL, STR_0032_OIL, STR_LITERS, STR_QUANTITY_OIL, STR_ABBREV_OIL,
SPR_CARGO_OIL, CC_LIQUID ),
+ /* Oil in subtropic */
+ MK( 3, 'OIL_', 174, 16, 4892, 25, 255, true, TE_NONE,
+ STR_0012_OIL, STR_0032_OIL, STR_LITERS, STR_QUANTITY_OIL, STR_ABBREV_OIL,
+ SPR_CARGO_OIL, CC_LIQUID ),
+
MK( 4, 'LVST', 208, 3, 4322, 4, 18, true, TE_NONE,
STR_0013_LIVESTOCK, STR_0033_LIVESTOCK, STR_ITEMS, STR_QUANTITY_LIVESTOCK, STR_ABBREV_LIVESTOCK,
SPR_CARGO_LIVESTOCK, CC_PIECE_GOODS ),
@@ -37,14 +43,20 @@
STR_0022_WHEAT, STR_0042_WHEAT, STR_TONS, STR_QUANTITY_WHEAT, STR_ABBREV_WHEAT,
SPR_CARGO_GRAIN, CC_BULK ),
- MK( 6, 'MAIZ', 191, 6, 4778, 4, 40, true, TE_NONE,
+ MK( 6, 'MAIZ', 191, 6, 4322, 4, 40, true, TE_NONE,
STR_001B_MAIZE, STR_003B_MAIZE, STR_TONS, STR_QUANTITY_MAIZE, STR_ABBREV_MAIZE,
SPR_CARGO_GRAIN, CC_BULK ),
+ /* Wood in temperate and arctic */
MK( 7, 'WOOD', 84, 16, 5005, 15, 255, true, TE_NONE,
STR_0016_WOOD, STR_0036_WOOD, STR_TONS, STR_QUANTITY_WOOD, STR_ABBREV_WOOD,
SPR_CARGO_WOOD, CC_PIECE_GOODS ),
+ /* Wood in subtropic */
+ MK( 7, 'WOOD', 84, 16, 7964, 15, 255, true, TE_NONE,
+ STR_0016_WOOD, STR_0036_WOOD, STR_TONS, STR_QUANTITY_WOOD, STR_ABBREV_WOOD,
+ SPR_CARGO_WOOD, CC_PIECE_GOODS ),
+
MK( 8, 'IORE', 184, 16, 5120, 9, 255, true, TE_NONE,
STR_0017_IRON_ORE, STR_0037_IRON_ORE, STR_TONS, STR_QUANTITY_IRON_ORE, STR_ABBREV_IRON_ORE,
SPR_CARGO_IRON_ORE, CC_BULK ),
@@ -57,15 +69,15 @@
STR_0019_VALUABLES, STR_0039_VALUABLES, STR_BAGS, STR_QUANTITY_VALUABLES, STR_ABBREV_VALUABLES,
SPR_CARGO_VALUES_GOLD, CC_ARMOURED ),
- MK( 10, 'GOLD', 202, 8, 7509, 10, 40, true, TE_NONE,
+ MK( 10, 'GOLD', 202, 8, 5802, 10, 40, true, TE_NONE,
STR_0020_GOLD, STR_0040_GOLD, STR_BAGS, STR_QUANTITY_GOLD, STR_ABBREV_GOLD,
SPR_CARGO_VALUES_GOLD, CC_ARMOURED ),
- MK( 10, 'DIAM', 202, 2, 7509, 10, 255, true, TE_NONE,
+ MK( 10, 'DIAM', 202, 2, 5802, 10, 255, true, TE_NONE,
STR_001D_DIAMONDS, STR_003D_DIAMOND, STR_BAGS, STR_QUANTITY_DIAMONDS, STR_ABBREV_DIAMONDS,
SPR_CARGO_DIAMONDS, CC_ARMOURED ),
- MK( 11, 'PAPR', 10, 16, 5688, 7, 60, true, TE_NONE,
+ MK( 11, 'PAPR', 10, 16, 5461, 7, 60, true, TE_NONE,
STR_001F_PAPER, STR_003F_PAPER, STR_TONS, STR_QUANTITY_PAPER, STR_ABBREV_PAPER,
SPR_CARGO_PAPER, CC_PIECE_GOODS ),
@@ -73,27 +85,27 @@
STR_001E_FOOD, STR_003E_FOOD, STR_TONS, STR_QUANTITY_FOOD, STR_ABBREV_FOOD,
SPR_CARGO_FOOD, CC_EXPRESS | CC_REFRIGERATED),
- MK( 13, 'FRUT', 208, 6, 4322, 0, 15, true, TE_NONE,
+ MK( 13, 'FRUT', 208, 6, 4209, 0, 15, true, TE_NONE,
STR_001C_FRUIT, STR_003C_FRUIT, STR_TONS, STR_QUANTITY_FRUIT, STR_ABBREV_FRUIT,
SPR_CARGO_FRUIT, CC_BULK | CC_REFRIGERATED),
- MK( 14, 'CORE', 184, 6, 5120, 12, 255, true, TE_NONE,
+ MK( 14, 'CORE', 184, 6, 4892, 12, 255, true, TE_NONE,
STR_001A_COPPER_ORE, STR_003A_COPPER_ORE, STR_TONS, STR_QUANTITY_COPPER_ORE, STR_ABBREV_COPPER_ORE,
SPR_CARGO_COPPER_ORE, CC_BULK ),
- MK( 15, 'WATR', 10, 6, 5688, 20, 80, true, TE_WATER,
+ MK( 15, 'WATR', 10, 6, 4664, 20, 80, true, TE_WATER,
STR_0021_WATER, STR_0041_WATER, STR_LITERS, STR_QUANTITY_WATER, STR_ABBREV_WATER,
SPR_CARGO_WATERCOLA, CC_LIQUID ),
- MK( 16, 'RUBR', 32, 6, 5916, 2, 20, true, TE_NONE,
+ MK( 16, 'RUBR', 32, 6, 4437, 2, 20, true, TE_NONE,
STR_0023_RUBBER, STR_0043_RUBBER, STR_LITERS, STR_QUANTITY_RUBBER, STR_ABBREV_RUBBER,
SPR_CARGO_RUBBER, CC_LIQUID ),
- MK( 17, 'SUGR', 32, 16, 5916, 20, 255, true, TE_NONE,
+ MK( 17, 'SUGR', 32, 16, 4437, 20, 255, true, TE_NONE,
STR_0024_SUGAR, STR_0044_SUGAR, STR_TONS, STR_QUANTITY_SUGAR, STR_ABBREV_SUGAR,
SPR_CARGO_SUGAR, CC_BULK ),
- MK( 18, 'TOYS', 174, 2, 4437, 25, 255, true, TE_NONE,
+ MK( 18, 'TOYS', 174, 2, 5574, 25, 255, true, TE_NONE,
STR_0025_TOYS, STR_0045_TOY, STR_NOTHING, STR_QUANTITY_TOYS, STR_ABBREV_TOYS,
SPR_CARGO_TOYS, CC_PIECE_GOODS ),
@@ -109,23 +121,23 @@
STR_002A_TOFFEE, STR_004A_TOFFEE, STR_TONS, STR_QUANTITY_TOFFEE, STR_ABBREV_TOFFEE,
SPR_CARGO_TOFFEE, CC_BULK ),
- MK( 22, 'COLA', 84, 16, 5005, 5, 75, true, TE_NONE,
+ MK( 22, 'COLA', 84, 16, 4892, 5, 75, true, TE_NONE,
STR_0027_COLA, STR_0047_COLA, STR_LITERS, STR_QUANTITY_COLA, STR_ABBREV_COLA,
SPR_CARGO_WATERCOLA, CC_LIQUID ),
- MK( 23, 'CTCD', 184, 16, 5120, 10, 25, true, TE_NONE,
+ MK( 23, 'CTCD', 184, 16, 5005, 10, 25, true, TE_NONE,
STR_0028_COTTON_CANDY, STR_0048_COTTON_CANDY, STR_TONS, STR_QUANTITY_CANDYFLOSS, STR_ABBREV_CANDYFLOSS,
SPR_CARGO_COTTONCANDY, CC_BULK ),
- MK( 24, 'BUBL', 10, 1, 5688, 20, 80, true, TE_NONE,
+ MK( 24, 'BUBL', 10, 1, 5077, 20, 80, true, TE_NONE,
STR_0029_BUBBLES, STR_0049_BUBBLE, STR_NOTHING, STR_QUANTITY_BUBBLES, STR_ABBREV_BUBBLES,
SPR_CARGO_BUBBLES, CC_PIECE_GOODS ),
- MK( 25, 'PLST', 202, 16, 7509, 30, 255, true, TE_NONE,
+ MK( 25, 'PLST', 202, 16, 4664, 30, 255, true, TE_NONE,
STR_002C_PLASTIC, STR_004C_PLASTIC, STR_LITERS, STR_QUANTITY_PLASTIC, STR_ABBREV_PLASTIC,
SPR_CARGO_PLASTIC, CC_LIQUID ),
- MK( 26, 'FZDR', 48, 2, 5688, 30, 50, true, TE_FOOD,
+ MK( 26, 'FZDR', 48, 2, 6250, 30, 50, true, TE_FOOD,
STR_002D_FIZZY_DRINKS, STR_004D_FIZZY_DRINK, STR_NOTHING, STR_QUANTITY_FIZZY_DRINKS, STR_ABBREV_FIZZY_DRINKS,
SPR_CARGO_FIZZYDRINK, CC_PIECE_GOODS ),
@@ -136,7 +148,7 @@
static const CargoLabel _default_climate_cargo[NUM_LANDSCAPE][12] = {
{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'GRAI', 'WOOD', 'IORE', 'STEL', 'VALU', 'VOID', },
{ 'PASS', 'COAL', 'MAIL', 'OIL_', 'LVST', 'GOOD', 'WHEA', 'WOOD', 'VOID', 'PAPR', 'GOLD', 'FOOD', },
- { 'PASS', 'RUBR', 'MAIL', 'OIL_', 'FRUT', 'GOOD', 'MAIZ', 'WOOD', 'CORE', 'WATR', 'DIAM', 'FOOD', },
+ { 'PASS', 'RUBR', 'MAIL', 4, 'FRUT', 'GOOD', 'MAIZ', 11, 'CORE', 'WATR', 'DIAM', 'FOOD', },
{ 'PASS', 'SUGR', 'MAIL', 'TOYS', 'BATT', 'SWET', 'TOFF', 'COLA', 'CTCD', 'BUBL', 'PLST', 'FZDR', },
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/control_codes.h
--- a/src/table/control_codes.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/control_codes.h Sat Jun 02 19:59:29 2007 +0000
@@ -26,6 +26,7 @@
SCC_WAYPOINT_NAME,
SCC_STATION_NAME,
SCC_TOWN_NAME,
+ SCC_GROUP_NAME,
SCC_CURRENCY_COMPACT,
SCC_CURRENCY_COMPACT_64,
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/engines.h
--- a/src/table/engines.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/engines.h Sat Jun 02 19:59:29 2007 +0000
@@ -12,29 +12,47 @@
/** Writes the properties of a train or road vehicle into the EngineInfo struct.
* @see EngineInfo
* @param a Introduction date
+ * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
+ * @param c life length
+ * @param d base life
* @param e Bitmask of the climates
- * @note the 5 between d and e is the load amount
- */
-#define MK(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, e, 0, 8, 0, 0 }
-
-/** Writes the properties of a train carriage into the EngineInfo struct.
- * @see MK
* @note the 0x80 in parameter b sets the "is carriage bit"
* @note the 5 between d and e is the load amount
*/
-#define MW(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b | 0x80, 5, e, 0, 8, 0, 0 }
+#define MK(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 5, e, 0, 8, 0, 0, 0 }
+
+/** Writes the properties of a train carriage into the EngineInfo struct.
+ * @param a Introduction date
+ * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
+ * @param c life length
+ * @param d base life
+ * @param e Bitmask of the climates
+ * @see MK
+ * @note the 5 between d and e is the load amount
+ */
+#define MW(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b | 0x80, 5, e, 0, 8, 0, 0, 0 }
/** Writes the properties of a ship into the EngineInfo struct.
+ * @param a Introduction date
+ * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
+ * @param c life length
+ * @param d base life
+ * @param e Bitmask of the climates
* @see MK
* @note the 10 between d and e is the load amount
*/
-#define MS(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 10, e, 0, 8, 0, 0 }
+#define MS(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 10, e, 0, 8, 0, 0, 0 }
/** Writes the properties of an aeroplane into the EngineInfo struct.
+ * @param a Introduction date
+ * @param b unk2, flag for carriage(bit 7) and decay speed(bits0..6)
+ * @param c life length
+ * @param d base life
+ * @param e Bitmask of the climates
* @see MK
* @note the 20 between d and e is the load amount
*/
-#define MA(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 20, e, 0, 8, 0, 0 }
+#define MA(a, b, c, d, e) { DAYS_TILL_ORIGINAL_BASE_YEAR + a, c, d, b, 20, e, 0, 8, 0, 0, 0 }
// Climates
// T = Temperate
@@ -321,20 +339,25 @@
* @param e power (hp)
* @param f weight
* @param g running_cost_base
- * @param h running_cost_class / engclass
+ * @param h running_cost_class
* @param i capacity
* @param j cargo_type
* @param k ai_rank
* @param l railtype
+ * @param m engclass
* Tractive effort coefficient by default is the same as TTDPatch, 0.30*256=76
*/
-#define RVI(a, b, c, d, e, f, g, h, i, j, k, l) { a, b, c, {l}, d, e, f, g, h, h, i, j, k, 0, 0, 0, 0, 76, 0 }
+#define RVI(a, b, c, d, e, f, g, h, i, j, k, l, m) { a, b, c, {l}, d, e, f, g, h, m, i, j, k, 0, 0, 0, 0, 76, 0 }
#define M RAILVEH_MULTIHEAD
#define W RAILVEH_WAGON
#define G RAILVEH_SINGLEHEAD
-#define S 0
-#define D 1
-#define E 2
+#define S EC_STEAM
+#define D EC_DIESEL
+#define E EC_ELECTRIC
+#define N EC_MONORAIL
+#define V EC_MAGLEV
+/* Wagons always have engine type 0, i.e. steam. */
+#define A EC_STEAM
#define R RAILTYPE_RAIL
#define C RAILTYPE_ELECTRIC
@@ -342,132 +365,134 @@
#define L RAILTYPE_MAGLEV
const RailVehicleInfo orig_rail_vehicle_info[NUM_TRAIN_ENGINES] = {
- // image_index max_speed (kph) running_cost_base
- // | flags | power (hp) | running_cost_class & engclass
- // | | base_cost | weight | | capacity
- // | | | | | | | | | cargo_type
- // | | | | | | | | | |
- RVI( 2, G, 7, 64, 300, 47, 50, S, 0, 0 , 1, R), // 0
- RVI(19, G, 8, 80, 600, 65, 65, D, 0, 0 , 4, R), // 1
- RVI( 2, G, 10, 72, 400, 85, 90, S, 0, 0 , 7, R), // 2
- RVI( 0, G, 15, 96, 900, 130, 130, S, 0, 0 , 19, R), // 3
- RVI( 1, G, 19, 112, 1000, 140, 145, S, 0, 0 , 20, R), // 4
- RVI(12, G, 16, 120, 1400, 95, 125, D, 0, 0 , 30, R), // 5
- RVI(14, G, 20, 152, 2000, 120, 135, D, 0, 0 , 31, R), // 6
- RVI( 3, G, 14, 88, 1100, 145, 130, S, 0, 0 , 19, R), // 7
- RVI( 0, G, 13, 112, 1000, 131, 120, S, 0, 0 , 20, R), // 8
- RVI( 1, G, 19, 128, 1200, 162, 140, S, 0, 0 , 21, R), // 9
- RVI( 0, G, 22, 144, 1600, 170, 130, S, 0, 0 , 22, R), // 10
- RVI( 8, M, 11, 112, 600/2,32/2, 85/2, D, 38, CT_PASSENGERS , 10, R), // 11
- RVI(10, M, 14, 120, 700/2,38/2, 70/2, D, 40, CT_PASSENGERS , 11, R), // 12
- RVI( 4, G, 15, 128, 1250, 72, 95, D, 0, 0 , 30, R), // 13
- RVI( 5, G, 17, 144, 1750, 101, 120, D, 0, 0 , 31, R), // 14
- RVI( 4, G, 18, 160, 2580, 112, 140, D, 0, 0 , 32, R), // 15
- RVI(14, G, 23, 96, 4000, 150, 135, D, 0, 0 , 33, R), // 16
- RVI(12, G, 16, 112, 2400, 120, 105, D, 0, 0 , 34, R), // 17
- RVI(13, G, 30, 112, 6600, 207, 155, D, 0, 0 , 35, R), // 18
- RVI(15, G, 18, 104, 1500, 110, 105, D, 0, 0 , 29, R), // 19
- RVI(16, M, 35, 160, 3500/2,95/2, 205/2, D, 0, 0 , 45, R), // 20
- RVI(18, G, 21, 104, 2200, 120, 145, D, 0, 0 , 32, R), // 21
- RVI( 6, M, 20, 200, 4500/2,70/2, 190/2, D, 4, CT_MAIL , 50, R), // 22
- RVI(20, G, 26, 160, 3600, 84, 180, E, 0, 0 , 40, C), // 23
- RVI(20, G, 30, 176, 5000, 82, 205, E, 0, 0 , 41, C), // 24
- RVI(21, M, 40, 240, 7000/2,90/2, 240/2, E, 0, 0 , 51, C), // 25
- RVI(23, M, 43, 264, 8000/2,95/2, 250/2, E, 0, 0 , 52, C), // 26
- RVI(33, W, 247, 0, 0, 25, 0, 0, 40, CT_PASSENGERS , 0, R), // 27
- RVI(35, W, 228, 0, 0, 21, 0, 0, 30, CT_MAIL , 0, R), // 28
- RVI(34, W, 176, 0, 0, 18, 0, 0, 30, CT_COAL , 0, R), // 29
- RVI(36, W, 200, 0, 0, 24, 0, 0, 30, CT_OIL , 0, R), // 30
- RVI(37, W, 192, 0, 0, 20, 0, 0, 25, CT_LIVESTOCK , 0, R), // 31
- RVI(38, W, 190, 0, 0, 21, 0, 0, 25, CT_GOODS , 0, R), // 32
- RVI(39, W, 182, 0, 0, 19, 0, 0, 30, CT_GRAIN , 0, R), // 33
- RVI(40, W, 181, 0, 0, 16, 0, 0, 30, CT_WOOD , 0, R), // 34
- RVI(41, W, 179, 0, 0, 19, 0, 0, 30, CT_IRON_ORE , 0, R), // 35
- RVI(42, W, 196, 0, 0, 18, 0, 0, 20, CT_STEEL , 0, R), // 36
- RVI(43, W, 255, 0, 0, 30, 0, 0, 20, CT_VALUABLES , 0, R), // 37
- RVI(44, W, 191, 0, 0, 22, 0, 0, 25, CT_FOOD , 0, R), // 38
- RVI(45, W, 196, 0, 0, 18, 0, 0, 20, CT_PAPER , 0, R), // 39
- RVI(46, W, 179, 0, 0, 19, 0, 0, 30, CT_COPPER_ORE , 0, R), // 40
- RVI(47, W, 199, 0, 0, 25, 0, 0, 25, CT_WATER , 0, R), // 41
- RVI(48, W, 182, 0, 0, 18, 0, 0, 25, CT_FRUIT , 0, R), // 42
- RVI(49, W, 185, 0, 0, 19, 0, 0, 21, CT_RUBBER , 0, R), // 43
- RVI(50, W, 176, 0, 0, 19, 0, 0, 30, CT_SUGAR , 0, R), // 44
- RVI(51, W, 178, 0, 0, 20, 0, 0, 30, CT_COTTON_CANDY, 0, R), // 45
- RVI(52, W, 192, 0, 0, 20, 0, 0, 30, CT_TOFFEE , 0, R), // 46
- RVI(53, W, 190, 0, 0, 21, 0, 0, 20, CT_BUBBLES , 0, R), // 47
- RVI(54, W, 182, 0, 0, 24, 0, 0, 25, CT_COLA , 0, R), // 48
- RVI(55, W, 181, 0, 0, 21, 0, 0, 25, CT_CANDY , 0, R), // 49
- RVI(56, W, 183, 0, 0, 21, 0, 0, 20, CT_TOYS , 0, R), // 50
- RVI(57, W, 196, 0, 0, 18, 0, 0, 22, CT_BATTERIES , 0, R), // 51
- RVI(58, W, 193, 0, 0, 18, 0, 0, 25, CT_FIZZY_DRINKS, 0, R), // 52
- RVI(59, W, 191, 0, 0, 18, 0, 0, 30, CT_PLASTIC , 0, R), // 53
- RVI(25, G, 52, 304, 9000, 95, 230, E, 0, 0 , 60, O), // 54
- RVI(26, M, 60, 336, 10000/2,85/2, 240/2, E, 25, CT_PASSENGERS , 62, O), // 55
- RVI(26, G, 53, 320, 5000, 95, 230, E, 0, 0 , 63, O), // 56
- RVI(60, W, 247, 0, 0, 25, 0, 0, 45, CT_PASSENGERS , 0, O), // 57
- RVI(62, W, 228, 0, 0, 21, 0, 0, 35, CT_MAIL , 0, O), // 58
- RVI(61, W, 176, 0, 0, 18, 0, 0, 35, CT_COAL , 0, O), // 59
- RVI(63, W, 200, 0, 0, 24, 0, 0, 35, CT_OIL , 0, O), // 60
- RVI(64, W, 192, 0, 0, 20, 0, 0, 30, CT_LIVESTOCK , 0, O), // 61
- RVI(65, W, 190, 0, 0, 21, 0, 0, 30, CT_GOODS , 0, O), // 62
- RVI(66, W, 182, 0, 0, 19, 0, 0, 35, CT_GRAIN , 0, O), // 63
- RVI(67, W, 181, 0, 0, 16, 0, 0, 35, CT_WOOD , 0, O), // 64
- RVI(68, W, 179, 0, 0, 19, 0, 0, 35, CT_IRON_ORE , 0, O), // 65
- RVI(69, W, 196, 0, 0, 18, 0, 0, 25, CT_STEEL , 0, O), // 66
- RVI(70, W, 255, 0, 0, 30, 0, 0, 25, CT_VALUABLES , 0, O), // 67
- RVI(71, W, 191, 0, 0, 22, 0, 0, 30, CT_FOOD , 0, O), // 68
- RVI(72, W, 196, 0, 0, 18, 0, 0, 25, CT_PAPER , 0, O), // 69
- RVI(73, W, 179, 0, 0, 19, 0, 0, 35, CT_COPPER_ORE , 0, O), // 70
- RVI(47, W, 199, 0, 0, 25, 0, 0, 30, CT_WATER , 0, O), // 71
- RVI(48, W, 182, 0, 0, 18, 0, 0, 30, CT_FRUIT , 0, O), // 72
- RVI(49, W, 185, 0, 0, 19, 0, 0, 26, CT_RUBBER , 0, O), // 73
- RVI(50, W, 176, 0, 0, 19, 0, 0, 35, CT_SUGAR , 0, O), // 74
- RVI(51, W, 178, 0, 0, 20, 0, 0, 35, CT_COTTON_CANDY, 0, O), // 75
- RVI(52, W, 192, 0, 0, 20, 0, 0, 35, CT_TOFFEE , 0, O), // 76
- RVI(53, W, 190, 0, 0, 21, 0, 0, 25, CT_BUBBLES , 0, O), // 77
- RVI(54, W, 182, 0, 0, 24, 0, 0, 30, CT_COLA , 0, O), // 78
- RVI(55, W, 181, 0, 0, 21, 0, 0, 30, CT_CANDY , 0, O), // 79
- RVI(56, W, 183, 0, 0, 21, 0, 0, 25, CT_TOYS , 0, O), // 80
- RVI(57, W, 196, 0, 0, 18, 0, 0, 27, CT_BATTERIES , 0, O), // 81
- RVI(58, W, 193, 0, 0, 18, 0, 0, 30, CT_FIZZY_DRINKS, 0, O), // 82
- RVI(59, W, 191, 0, 0, 18, 0, 0, 35, CT_PLASTIC , 0, O), // 83
- RVI(28, G, 70, 400, 10000, 105, 250, E, 0, 0 , 70, L), // 84
- RVI(29, G, 74, 448, 12000, 120, 253, E, 0, 0 , 71, L), // 85
- RVI(30, G, 82, 480, 15000, 130, 254, E, 0, 0 , 72, L), // 86
- RVI(31, M, 95, 640, 20000/2,150/2,255/2, E, 0, 0 , 73, L), // 87
- RVI(28, G, 70, 480, 10000, 120, 250, E, 0, 0 , 74, L), // 88
- RVI(60, W, 247, 0, 0, 25, 0, 0, 47, CT_PASSENGERS , 0, L), // 89
- RVI(62, W, 228, 0, 0, 21, 0, 0, 37, CT_MAIL , 0, L), // 90
- RVI(61, W, 176, 0, 0, 18, 0, 0, 37, CT_COAL , 0, L), // 91
- RVI(63, W, 200, 0, 0, 24, 0, 0, 37, CT_OIL , 0, L), // 92
- RVI(64, W, 192, 0, 0, 20, 0, 0, 32, CT_LIVESTOCK , 0, L), // 93
- RVI(65, W, 190, 0, 0, 21, 0, 0, 32, CT_GOODS , 0, L), // 94
- RVI(66, W, 182, 0, 0, 19, 0, 0, 37, CT_GRAIN , 0, L), // 95
- RVI(67, W, 181, 0, 0, 16, 0, 0, 37, CT_WOOD , 0, L), // 96
- RVI(68, W, 179, 0, 0, 19, 0, 0, 37, CT_IRON_ORE , 0, L), // 97
- RVI(69, W, 196, 0, 0, 18, 0, 0, 27, CT_STEEL , 0, L), // 98
- RVI(70, W, 255, 0, 0, 30, 0, 0, 27, CT_VALUABLES , 0, L), // 99
- RVI(71, W, 191, 0, 0, 22, 0, 0, 32, CT_FOOD , 0, L), // 100
- RVI(72, W, 196, 0, 0, 18, 0, 0, 27, CT_PAPER , 0, L), // 101
- RVI(73, W, 179, 0, 0, 19, 0, 0, 37, CT_COPPER_ORE , 0, L), // 102
- RVI(47, W, 199, 0, 0, 25, 0, 0, 32, CT_WATER , 0, L), // 103
- RVI(48, W, 182, 0, 0, 18, 0, 0, 32, CT_FRUIT , 0, L), // 104
- RVI(49, W, 185, 0, 0, 19, 0, 0, 28, CT_RUBBER , 0, L), // 105
- RVI(50, W, 176, 0, 0, 19, 0, 0, 37, CT_SUGAR , 0, L), // 106
- RVI(51, W, 178, 0, 0, 20, 0, 0, 37, CT_COTTON_CANDY, 0, L), // 107
- RVI(52, W, 192, 0, 0, 20, 0, 0, 37, CT_TOFFEE , 0, L), // 108
- RVI(53, W, 190, 0, 0, 21, 0, 0, 27, CT_BUBBLES , 0, L), // 109
- RVI(54, W, 182, 0, 0, 24, 0, 0, 32, CT_COLA , 0, L), // 110
- RVI(55, W, 181, 0, 0, 21, 0, 0, 32, CT_CANDY , 0, L), // 111
- RVI(56, W, 183, 0, 0, 21, 0, 0, 27, CT_TOYS , 0, L), // 112
- RVI(57, W, 196, 0, 0, 18, 0, 0, 29, CT_BATTERIES , 0, L), // 113
- RVI(58, W, 193, 0, 0, 18, 0, 0, 32, CT_FIZZY_DRINKS, 0, L), // 114
- RVI(59, W, 191, 0, 0, 18, 0, 0, 37, CT_PLASTIC , 0, L), // 115
+ // image_index max_speed (kph) running_cost_base ai_rank
+ // | flags | power (hp) | running_cost_class | railtype
+ // | | base_cost | weight | | capacity | |
+ // | | | | | | | | | cargo_type | | engclass
+ // | | | | | | | | | | | | |
+ RVI( 2, G, 7, 64, 300, 47, 50, S, 0, 0 , 1, R, S), // 0
+ RVI(19, G, 8, 80, 600, 65, 65, D, 0, 0 , 4, R, D), // 1
+ RVI( 2, G, 10, 72, 400, 85, 90, S, 0, 0 , 7, R, S), // 2
+ RVI( 0, G, 15, 96, 900, 130, 130, S, 0, 0 , 19, R, S), // 3
+ RVI( 1, G, 19, 112, 1000, 140, 145, S, 0, 0 , 20, R, S), // 4
+ RVI(12, G, 16, 120, 1400, 95, 125, D, 0, 0 , 30, R, D), // 5
+ RVI(14, G, 20, 152, 2000, 120, 135, D, 0, 0 , 31, R, D), // 6
+ RVI( 3, G, 14, 88, 1100, 145, 130, S, 0, 0 , 19, R, S), // 7
+ RVI( 0, G, 13, 112, 1000, 131, 120, S, 0, 0 , 20, R, S), // 8
+ RVI( 1, G, 19, 128, 1200, 162, 140, S, 0, 0 , 21, R, S), // 9
+ RVI( 0, G, 22, 144, 1600, 170, 130, S, 0, 0 , 22, R, S), // 10
+ RVI( 8, M, 11, 112, 600/2,32/2, 85/2, D, 38, CT_PASSENGERS , 10, R, D), // 11
+ RVI(10, M, 14, 120, 700/2,38/2, 70/2, D, 40, CT_PASSENGERS , 11, R, D), // 12
+ RVI( 4, G, 15, 128, 1250, 72, 95, D, 0, 0 , 30, R, D), // 13
+ RVI( 5, G, 17, 144, 1750, 101, 120, D, 0, 0 , 31, R, D), // 14
+ RVI( 4, G, 18, 160, 2580, 112, 140, D, 0, 0 , 32, R, D), // 15
+ RVI(14, G, 23, 96, 4000, 150, 135, D, 0, 0 , 33, R, D), // 16
+ RVI(12, G, 16, 112, 2400, 120, 105, D, 0, 0 , 34, R, D), // 17
+ RVI(13, G, 30, 112, 6600, 207, 155, D, 0, 0 , 35, R, D), // 18
+ RVI(15, G, 18, 104, 1500, 110, 105, D, 0, 0 , 29, R, D), // 19
+ RVI(16, M, 35, 160, 3500/2,95/2, 205/2, D, 0, 0 , 45, R, D), // 20
+ RVI(18, G, 21, 104, 2200, 120, 145, D, 0, 0 , 32, R, D), // 21
+ RVI( 6, M, 20, 200, 4500/2,70/2, 190/2, D, 4, CT_MAIL , 50, R, D), // 22
+ RVI(20, G, 26, 160, 3600, 84, 180, E, 0, 0 , 40, C, E), // 23
+ RVI(20, G, 30, 176, 5000, 82, 205, E, 0, 0 , 41, C, E), // 24
+ RVI(21, M, 40, 240, 7000/2,90/2, 240/2, E, 0, 0 , 51, C, E), // 25
+ RVI(23, M, 43, 264, 8000/2,95/2, 250/2, E, 0, 0 , 52, C, E), // 26
+ RVI(33, W, 247, 0, 0, 25, 0, 0, 40, CT_PASSENGERS , 0, R, A), // 27
+ RVI(35, W, 228, 0, 0, 21, 0, 0, 30, CT_MAIL , 0, R, A), // 28
+ RVI(34, W, 176, 0, 0, 18, 0, 0, 30, CT_COAL , 0, R, A), // 29
+ RVI(36, W, 200, 0, 0, 24, 0, 0, 30, CT_OIL , 0, R, A), // 30
+ RVI(37, W, 192, 0, 0, 20, 0, 0, 25, CT_LIVESTOCK , 0, R, A), // 31
+ RVI(38, W, 190, 0, 0, 21, 0, 0, 25, CT_GOODS , 0, R, A), // 32
+ RVI(39, W, 182, 0, 0, 19, 0, 0, 30, CT_GRAIN , 0, R, A), // 33
+ RVI(40, W, 181, 0, 0, 16, 0, 0, 30, CT_WOOD , 0, R, A), // 34
+ RVI(41, W, 179, 0, 0, 19, 0, 0, 30, CT_IRON_ORE , 0, R, A), // 35
+ RVI(42, W, 196, 0, 0, 18, 0, 0, 20, CT_STEEL , 0, R, A), // 36
+ RVI(43, W, 255, 0, 0, 30, 0, 0, 20, CT_VALUABLES , 0, R, A), // 37
+ RVI(44, W, 191, 0, 0, 22, 0, 0, 25, CT_FOOD , 0, R, A), // 38
+ RVI(45, W, 196, 0, 0, 18, 0, 0, 20, CT_PAPER , 0, R, A), // 39
+ RVI(46, W, 179, 0, 0, 19, 0, 0, 30, CT_COPPER_ORE , 0, R, A), // 40
+ RVI(47, W, 199, 0, 0, 25, 0, 0, 25, CT_WATER , 0, R, A), // 41
+ RVI(48, W, 182, 0, 0, 18, 0, 0, 25, CT_FRUIT , 0, R, A), // 42
+ RVI(49, W, 185, 0, 0, 19, 0, 0, 21, CT_RUBBER , 0, R, A), // 43
+ RVI(50, W, 176, 0, 0, 19, 0, 0, 30, CT_SUGAR , 0, R, A), // 44
+ RVI(51, W, 178, 0, 0, 20, 0, 0, 30, CT_COTTON_CANDY, 0, R, A), // 45
+ RVI(52, W, 192, 0, 0, 20, 0, 0, 30, CT_TOFFEE , 0, R, A), // 46
+ RVI(53, W, 190, 0, 0, 21, 0, 0, 20, CT_BUBBLES , 0, R, A), // 47
+ RVI(54, W, 182, 0, 0, 24, 0, 0, 25, CT_COLA , 0, R, A), // 48
+ RVI(55, W, 181, 0, 0, 21, 0, 0, 25, CT_CANDY , 0, R, A), // 49
+ RVI(56, W, 183, 0, 0, 21, 0, 0, 20, CT_TOYS , 0, R, A), // 50
+ RVI(57, W, 196, 0, 0, 18, 0, 0, 22, CT_BATTERIES , 0, R, A), // 51
+ RVI(58, W, 193, 0, 0, 18, 0, 0, 25, CT_FIZZY_DRINKS, 0, R, A), // 52
+ RVI(59, W, 191, 0, 0, 18, 0, 0, 30, CT_PLASTIC , 0, R, A), // 53
+ RVI(25, G, 52, 304, 9000, 95, 230, E, 0, 0 , 60, O, N), // 54
+ RVI(26, M, 60, 336, 10000/2,85/2, 240/2, E, 25, CT_PASSENGERS , 62, O, N), // 55
+ RVI(26, G, 53, 320, 5000, 95, 230, E, 0, 0 , 63, O, N), // 56
+ RVI(60, W, 247, 0, 0, 25, 0, 0, 45, CT_PASSENGERS , 0, O, A), // 57
+ RVI(62, W, 228, 0, 0, 21, 0, 0, 35, CT_MAIL , 0, O, A), // 58
+ RVI(61, W, 176, 0, 0, 18, 0, 0, 35, CT_COAL , 0, O, A), // 59
+ RVI(63, W, 200, 0, 0, 24, 0, 0, 35, CT_OIL , 0, O, A), // 60
+ RVI(64, W, 192, 0, 0, 20, 0, 0, 30, CT_LIVESTOCK , 0, O, A), // 61
+ RVI(65, W, 190, 0, 0, 21, 0, 0, 30, CT_GOODS , 0, O, A), // 62
+ RVI(66, W, 182, 0, 0, 19, 0, 0, 35, CT_GRAIN , 0, O, A), // 63
+ RVI(67, W, 181, 0, 0, 16, 0, 0, 35, CT_WOOD , 0, O, A), // 64
+ RVI(68, W, 179, 0, 0, 19, 0, 0, 35, CT_IRON_ORE , 0, O, A), // 65
+ RVI(69, W, 196, 0, 0, 18, 0, 0, 25, CT_STEEL , 0, O, A), // 66
+ RVI(70, W, 255, 0, 0, 30, 0, 0, 25, CT_VALUABLES , 0, O, A), // 67
+ RVI(71, W, 191, 0, 0, 22, 0, 0, 30, CT_FOOD , 0, O, A), // 68
+ RVI(72, W, 196, 0, 0, 18, 0, 0, 25, CT_PAPER , 0, O, A), // 69
+ RVI(73, W, 179, 0, 0, 19, 0, 0, 35, CT_COPPER_ORE , 0, O, A), // 70
+ RVI(47, W, 199, 0, 0, 25, 0, 0, 30, CT_WATER , 0, O, A), // 71
+ RVI(48, W, 182, 0, 0, 18, 0, 0, 30, CT_FRUIT , 0, O, A), // 72
+ RVI(49, W, 185, 0, 0, 19, 0, 0, 26, CT_RUBBER , 0, O, A), // 73
+ RVI(50, W, 176, 0, 0, 19, 0, 0, 35, CT_SUGAR , 0, O, A), // 74
+ RVI(51, W, 178, 0, 0, 20, 0, 0, 35, CT_COTTON_CANDY, 0, O, A), // 75
+ RVI(52, W, 192, 0, 0, 20, 0, 0, 35, CT_TOFFEE , 0, O, A), // 76
+ RVI(53, W, 190, 0, 0, 21, 0, 0, 25, CT_BUBBLES , 0, O, A), // 77
+ RVI(54, W, 182, 0, 0, 24, 0, 0, 30, CT_COLA , 0, O, A), // 78
+ RVI(55, W, 181, 0, 0, 21, 0, 0, 30, CT_CANDY , 0, O, A), // 79
+ RVI(56, W, 183, 0, 0, 21, 0, 0, 25, CT_TOYS , 0, O, A), // 80
+ RVI(57, W, 196, 0, 0, 18, 0, 0, 27, CT_BATTERIES , 0, O, A), // 81
+ RVI(58, W, 193, 0, 0, 18, 0, 0, 30, CT_FIZZY_DRINKS, 0, O, A), // 82
+ RVI(59, W, 191, 0, 0, 18, 0, 0, 35, CT_PLASTIC , 0, O, A), // 83
+ RVI(28, G, 70, 400, 10000, 105, 250, E, 0, 0 , 70, L, V), // 84
+ RVI(29, G, 74, 448, 12000, 120, 253, E, 0, 0 , 71, L, V), // 85
+ RVI(30, G, 82, 480, 15000, 130, 254, E, 0, 0 , 72, L, V), // 86
+ RVI(31, M, 95, 640, 20000/2,150/2,255/2, E, 0, 0 , 73, L, V), // 87
+ RVI(28, G, 70, 480, 10000, 120, 250, E, 0, 0 , 74, L, V), // 88
+ RVI(60, W, 247, 0, 0, 25, 0, 0, 47, CT_PASSENGERS , 0, L, A), // 89
+ RVI(62, W, 228, 0, 0, 21, 0, 0, 37, CT_MAIL , 0, L, A), // 90
+ RVI(61, W, 176, 0, 0, 18, 0, 0, 37, CT_COAL , 0, L, A), // 91
+ RVI(63, W, 200, 0, 0, 24, 0, 0, 37, CT_OIL , 0, L, A), // 92
+ RVI(64, W, 192, 0, 0, 20, 0, 0, 32, CT_LIVESTOCK , 0, L, A), // 93
+ RVI(65, W, 190, 0, 0, 21, 0, 0, 32, CT_GOODS , 0, L, A), // 94
+ RVI(66, W, 182, 0, 0, 19, 0, 0, 37, CT_GRAIN , 0, L, A), // 95
+ RVI(67, W, 181, 0, 0, 16, 0, 0, 37, CT_WOOD , 0, L, A), // 96
+ RVI(68, W, 179, 0, 0, 19, 0, 0, 37, CT_IRON_ORE , 0, L, A), // 97
+ RVI(69, W, 196, 0, 0, 18, 0, 0, 27, CT_STEEL , 0, L, A), // 98
+ RVI(70, W, 255, 0, 0, 30, 0, 0, 27, CT_VALUABLES , 0, L, A), // 99
+ RVI(71, W, 191, 0, 0, 22, 0, 0, 32, CT_FOOD , 0, L, A), // 100
+ RVI(72, W, 196, 0, 0, 18, 0, 0, 27, CT_PAPER , 0, L, A), // 101
+ RVI(73, W, 179, 0, 0, 19, 0, 0, 37, CT_COPPER_ORE , 0, L, A), // 102
+ RVI(47, W, 199, 0, 0, 25, 0, 0, 32, CT_WATER , 0, L, A), // 103
+ RVI(48, W, 182, 0, 0, 18, 0, 0, 32, CT_FRUIT , 0, L, A), // 104
+ RVI(49, W, 185, 0, 0, 19, 0, 0, 28, CT_RUBBER , 0, L, A), // 105
+ RVI(50, W, 176, 0, 0, 19, 0, 0, 37, CT_SUGAR , 0, L, A), // 106
+ RVI(51, W, 178, 0, 0, 20, 0, 0, 37, CT_COTTON_CANDY, 0, L, A), // 107
+ RVI(52, W, 192, 0, 0, 20, 0, 0, 37, CT_TOFFEE , 0, L, A), // 108
+ RVI(53, W, 190, 0, 0, 21, 0, 0, 27, CT_BUBBLES , 0, L, A), // 109
+ RVI(54, W, 182, 0, 0, 24, 0, 0, 32, CT_COLA , 0, L, A), // 110
+ RVI(55, W, 181, 0, 0, 21, 0, 0, 32, CT_CANDY , 0, L, A), // 111
+ RVI(56, W, 183, 0, 0, 21, 0, 0, 27, CT_TOYS , 0, L, A), // 112
+ RVI(57, W, 196, 0, 0, 18, 0, 0, 29, CT_BATTERIES , 0, L, A), // 113
+ RVI(58, W, 193, 0, 0, 18, 0, 0, 32, CT_FIZZY_DRINKS, 0, L, A), // 114
+ RVI(59, W, 191, 0, 0, 18, 0, 0, 37, CT_PLASTIC , 0, L, A), // 115
};
#undef L
#undef O
#undef C
#undef R
+#undef V
+#undef N
#undef E
#undef D
#undef S
@@ -586,101 +611,101 @@
* @param f capacity
* @param g cargo_type
*/
-#define RVI(a, b, c, d, e, f, g) { a, b, c, {d}, e, f, g }
+#define ROV(a, b, c, d, e, f, g) { a, b, c, {d}, e, f, g }
const RoadVehicleInfo orig_road_vehicle_info[NUM_ROAD_ENGINES] = {
// image_index sfx max_speed
// | base_cost | | capacity
// | | running_cost | | cargo_type
// | | | | | | |
- RVI( 0, 120, 91, SND_19_BUS_START_PULL_AWAY, 112, 31, CT_PASSENGERS ), /* 0 */
- RVI( 17, 140, 128, SND_1C_TRUCK_START_2, 176, 35, CT_PASSENGERS ), /* 1 */
- RVI( 17, 150, 178, SND_1B_TRUCK_START, 224, 37, CT_PASSENGERS ), /* 2 */
- RVI( 34, 160, 240, SND_1B_TRUCK_START, 255, 40, CT_PASSENGERS ), /* 3 */
- RVI( 51, 120, 91, SND_3C_COMEDY_CAR, 112, 30, CT_PASSENGERS ), /* 4 */
- RVI( 51, 140, 171, SND_3E_COMEDY_CAR_2, 192, 35, CT_PASSENGERS ), /* 5 */
- RVI( 51, 160, 240, SND_3C_COMEDY_CAR, 240, 38, CT_PASSENGERS ), /* 6 */
- RVI( 1, 108, 90, SND_19_BUS_START_PULL_AWAY, 96, 20, CT_COAL ), /* 7 */
- RVI( 18, 128, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_COAL ), /* 8 */
- RVI( 35, 138, 240, SND_19_BUS_START_PULL_AWAY, 224, 28, CT_COAL ), /* 9 */
- RVI( 2, 115, 90, SND_19_BUS_START_PULL_AWAY, 96, 22, CT_MAIL ), /* 10 */
- RVI( 19, 135, 168, SND_19_BUS_START_PULL_AWAY, 176, 28, CT_MAIL ), /* 11 */
- RVI( 36, 145, 240, SND_19_BUS_START_PULL_AWAY, 224, 30, CT_MAIL ), /* 12 */
- RVI( 57, 115, 90, SND_3E_COMEDY_CAR_2, 96, 22, CT_MAIL ), /* 13 */
- RVI( 57, 135, 168, SND_3C_COMEDY_CAR, 176, 28, CT_MAIL ), /* 14 */
- RVI( 57, 145, 240, SND_3E_COMEDY_CAR_2, 224, 30, CT_MAIL ), /* 15 */
- RVI( 3, 110, 90, SND_19_BUS_START_PULL_AWAY, 96, 21, CT_OIL ), /* 16 */
- RVI( 20, 140, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_OIL ), /* 17 */
- RVI( 37, 150, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_OIL ), /* 18 */
- RVI( 4, 105, 90, SND_19_BUS_START_PULL_AWAY, 96, 14, CT_LIVESTOCK ), /* 19 */
- RVI( 21, 130, 168, SND_19_BUS_START_PULL_AWAY, 176, 16, CT_LIVESTOCK ), /* 20 */
- RVI( 38, 140, 240, SND_19_BUS_START_PULL_AWAY, 224, 18, CT_LIVESTOCK ), /* 21 */
- RVI( 5, 107, 90, SND_19_BUS_START_PULL_AWAY, 96, 14, CT_GOODS ), /* 22 */
- RVI( 22, 130, 168, SND_19_BUS_START_PULL_AWAY, 176, 16, CT_GOODS ), /* 23 */
- RVI( 39, 140, 240, SND_19_BUS_START_PULL_AWAY, 224, 18, CT_GOODS ), /* 24 */
- RVI( 6, 114, 90, SND_19_BUS_START_PULL_AWAY, 96, 20, CT_GRAIN ), /* 25 */
- RVI( 23, 133, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_GRAIN ), /* 26 */
- RVI( 40, 143, 240, SND_19_BUS_START_PULL_AWAY, 224, 30, CT_GRAIN ), /* 27 */
- RVI( 7, 118, 90, SND_19_BUS_START_PULL_AWAY, 96, 20, CT_WOOD ), /* 28 */
- RVI( 24, 137, 168, SND_19_BUS_START_PULL_AWAY, 176, 22, CT_WOOD ), /* 29 */
- RVI( 41, 147, 240, SND_19_BUS_START_PULL_AWAY, 224, 24, CT_WOOD ), /* 30 */
- RVI( 8, 121, 90, SND_19_BUS_START_PULL_AWAY, 96, 22, CT_IRON_ORE ), /* 31 */
- RVI( 25, 140, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_IRON_ORE ), /* 32 */
- RVI( 42, 150, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_IRON_ORE ), /* 33 */
- RVI( 9, 112, 90, SND_19_BUS_START_PULL_AWAY, 96, 15, CT_STEEL ), /* 34 */
- RVI( 26, 135, 168, SND_19_BUS_START_PULL_AWAY, 176, 18, CT_STEEL ), /* 35 */
- RVI( 43, 145, 240, SND_19_BUS_START_PULL_AWAY, 224, 20, CT_STEEL ), /* 36 */
- RVI( 10, 145, 90, SND_19_BUS_START_PULL_AWAY, 96, 12, CT_VALUABLES ), /* 37 */
- RVI( 27, 170, 168, SND_19_BUS_START_PULL_AWAY, 176, 15, CT_VALUABLES ), /* 38 */
- RVI( 44, 180, 240, SND_19_BUS_START_PULL_AWAY, 224, 16, CT_VALUABLES ), /* 39 */
- RVI( 11, 112, 90, SND_19_BUS_START_PULL_AWAY, 96, 17, CT_FOOD ), /* 40 */
- RVI( 28, 134, 168, SND_19_BUS_START_PULL_AWAY, 176, 20, CT_FOOD ), /* 41 */
- RVI( 45, 144, 240, SND_19_BUS_START_PULL_AWAY, 224, 22, CT_FOOD ), /* 42 */
- RVI( 12, 112, 90, SND_19_BUS_START_PULL_AWAY, 96, 15, CT_PAPER ), /* 43 */
- RVI( 29, 135, 168, SND_19_BUS_START_PULL_AWAY, 176, 18, CT_PAPER ), /* 44 */
- RVI( 46, 145, 240, SND_19_BUS_START_PULL_AWAY, 224, 20, CT_PAPER ), /* 45 */
- RVI( 13, 121, 90, SND_19_BUS_START_PULL_AWAY, 96, 22, CT_COPPER_ORE ), /* 46 */
- RVI( 30, 140, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_COPPER_ORE ), /* 47 */
- RVI( 47, 150, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_COPPER_ORE ), /* 48 */
- RVI( 14, 111, 90, SND_19_BUS_START_PULL_AWAY, 96, 21, CT_WATER ), /* 49 */
- RVI( 31, 141, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_WATER ), /* 50 */
- RVI( 48, 151, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_WATER ), /* 51 */
- RVI( 15, 118, 90, SND_19_BUS_START_PULL_AWAY, 96, 18, CT_FRUIT ), /* 52 */
- RVI( 32, 148, 168, SND_19_BUS_START_PULL_AWAY, 176, 20, CT_FRUIT ), /* 53 */
- RVI( 49, 158, 240, SND_19_BUS_START_PULL_AWAY, 224, 23, CT_FRUIT ), /* 54 */
- RVI( 16, 117, 90, SND_19_BUS_START_PULL_AWAY, 96, 17, CT_RUBBER ), /* 55 */
- RVI( 33, 147, 168, SND_19_BUS_START_PULL_AWAY, 176, 19, CT_RUBBER ), /* 56 */
- RVI( 50, 157, 240, SND_19_BUS_START_PULL_AWAY, 224, 22, CT_RUBBER ), /* 57 */
- RVI( 52, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_SUGAR ), /* 58 */
- RVI( 52, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_SUGAR ), /* 59 */
- RVI( 52, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_SUGAR ), /* 60 */
- RVI( 53, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_COLA ), /* 61 */
- RVI( 53, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_COLA ), /* 62 */
- RVI( 53, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_COLA ), /* 63 */
- RVI( 54, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_COTTON_CANDY ), /* 64 */
- RVI( 54, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_COTTON_CANDY ), /* 65 */
- RVI( 54, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_COTTON_CANDY ), /* 66 */
- RVI( 55, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_TOFFEE ), /* 67 */
- RVI( 55, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_TOFFEE ), /* 68 */
- RVI( 55, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_TOFFEE ), /* 69 */
- RVI( 56, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_TOYS ), /* 70 */
- RVI( 56, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_TOYS ), /* 71 */
- RVI( 56, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_TOYS ), /* 72 */
- RVI( 58, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_CANDY ), /* 73 */
- RVI( 58, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_CANDY ), /* 74 */
- RVI( 58, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_CANDY ), /* 75 */
- RVI( 59, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_BATTERIES ), /* 76 */
- RVI( 59, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_BATTERIES ), /* 77 */
- RVI( 59, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_BATTERIES ), /* 78 */
- RVI( 60, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_FIZZY_DRINKS ), /* 79 */
- RVI( 60, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_FIZZY_DRINKS ), /* 80 */
- RVI( 60, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_FIZZY_DRINKS ), /* 81 */
- RVI( 61, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_PLASTIC ), /* 82 */
- RVI( 61, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_PLASTIC ), /* 83 */
- RVI( 61, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_PLASTIC ), /* 84 */
- RVI( 62, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_BUBBLES ), /* 85 */
- RVI( 62, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_BUBBLES ), /* 86 */
- RVI( 62, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_BUBBLES ), /* 87 */
+ ROV( 0, 120, 91, SND_19_BUS_START_PULL_AWAY, 112, 31, CT_PASSENGERS ), /* 0 */
+ ROV( 17, 140, 128, SND_1C_TRUCK_START_2, 176, 35, CT_PASSENGERS ), /* 1 */
+ ROV( 17, 150, 178, SND_1B_TRUCK_START, 224, 37, CT_PASSENGERS ), /* 2 */
+ ROV( 34, 160, 240, SND_1B_TRUCK_START, 255, 40, CT_PASSENGERS ), /* 3 */
+ ROV( 51, 120, 91, SND_3C_COMEDY_CAR, 112, 30, CT_PASSENGERS ), /* 4 */
+ ROV( 51, 140, 171, SND_3E_COMEDY_CAR_2, 192, 35, CT_PASSENGERS ), /* 5 */
+ ROV( 51, 160, 240, SND_3C_COMEDY_CAR, 240, 38, CT_PASSENGERS ), /* 6 */
+ ROV( 1, 108, 90, SND_19_BUS_START_PULL_AWAY, 96, 20, CT_COAL ), /* 7 */
+ ROV( 18, 128, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_COAL ), /* 8 */
+ ROV( 35, 138, 240, SND_19_BUS_START_PULL_AWAY, 224, 28, CT_COAL ), /* 9 */
+ ROV( 2, 115, 90, SND_19_BUS_START_PULL_AWAY, 96, 22, CT_MAIL ), /* 10 */
+ ROV( 19, 135, 168, SND_19_BUS_START_PULL_AWAY, 176, 28, CT_MAIL ), /* 11 */
+ ROV( 36, 145, 240, SND_19_BUS_START_PULL_AWAY, 224, 30, CT_MAIL ), /* 12 */
+ ROV( 57, 115, 90, SND_3E_COMEDY_CAR_2, 96, 22, CT_MAIL ), /* 13 */
+ ROV( 57, 135, 168, SND_3C_COMEDY_CAR, 176, 28, CT_MAIL ), /* 14 */
+ ROV( 57, 145, 240, SND_3E_COMEDY_CAR_2, 224, 30, CT_MAIL ), /* 15 */
+ ROV( 3, 110, 90, SND_19_BUS_START_PULL_AWAY, 96, 21, CT_OIL ), /* 16 */
+ ROV( 20, 140, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_OIL ), /* 17 */
+ ROV( 37, 150, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_OIL ), /* 18 */
+ ROV( 4, 105, 90, SND_19_BUS_START_PULL_AWAY, 96, 14, CT_LIVESTOCK ), /* 19 */
+ ROV( 21, 130, 168, SND_19_BUS_START_PULL_AWAY, 176, 16, CT_LIVESTOCK ), /* 20 */
+ ROV( 38, 140, 240, SND_19_BUS_START_PULL_AWAY, 224, 18, CT_LIVESTOCK ), /* 21 */
+ ROV( 5, 107, 90, SND_19_BUS_START_PULL_AWAY, 96, 14, CT_GOODS ), /* 22 */
+ ROV( 22, 130, 168, SND_19_BUS_START_PULL_AWAY, 176, 16, CT_GOODS ), /* 23 */
+ ROV( 39, 140, 240, SND_19_BUS_START_PULL_AWAY, 224, 18, CT_GOODS ), /* 24 */
+ ROV( 6, 114, 90, SND_19_BUS_START_PULL_AWAY, 96, 20, CT_GRAIN ), /* 25 */
+ ROV( 23, 133, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_GRAIN ), /* 26 */
+ ROV( 40, 143, 240, SND_19_BUS_START_PULL_AWAY, 224, 30, CT_GRAIN ), /* 27 */
+ ROV( 7, 118, 90, SND_19_BUS_START_PULL_AWAY, 96, 20, CT_WOOD ), /* 28 */
+ ROV( 24, 137, 168, SND_19_BUS_START_PULL_AWAY, 176, 22, CT_WOOD ), /* 29 */
+ ROV( 41, 147, 240, SND_19_BUS_START_PULL_AWAY, 224, 24, CT_WOOD ), /* 30 */
+ ROV( 8, 121, 90, SND_19_BUS_START_PULL_AWAY, 96, 22, CT_IRON_ORE ), /* 31 */
+ ROV( 25, 140, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_IRON_ORE ), /* 32 */
+ ROV( 42, 150, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_IRON_ORE ), /* 33 */
+ ROV( 9, 112, 90, SND_19_BUS_START_PULL_AWAY, 96, 15, CT_STEEL ), /* 34 */
+ ROV( 26, 135, 168, SND_19_BUS_START_PULL_AWAY, 176, 18, CT_STEEL ), /* 35 */
+ ROV( 43, 145, 240, SND_19_BUS_START_PULL_AWAY, 224, 20, CT_STEEL ), /* 36 */
+ ROV( 10, 145, 90, SND_19_BUS_START_PULL_AWAY, 96, 12, CT_VALUABLES ), /* 37 */
+ ROV( 27, 170, 168, SND_19_BUS_START_PULL_AWAY, 176, 15, CT_VALUABLES ), /* 38 */
+ ROV( 44, 180, 240, SND_19_BUS_START_PULL_AWAY, 224, 16, CT_VALUABLES ), /* 39 */
+ ROV( 11, 112, 90, SND_19_BUS_START_PULL_AWAY, 96, 17, CT_FOOD ), /* 40 */
+ ROV( 28, 134, 168, SND_19_BUS_START_PULL_AWAY, 176, 20, CT_FOOD ), /* 41 */
+ ROV( 45, 144, 240, SND_19_BUS_START_PULL_AWAY, 224, 22, CT_FOOD ), /* 42 */
+ ROV( 12, 112, 90, SND_19_BUS_START_PULL_AWAY, 96, 15, CT_PAPER ), /* 43 */
+ ROV( 29, 135, 168, SND_19_BUS_START_PULL_AWAY, 176, 18, CT_PAPER ), /* 44 */
+ ROV( 46, 145, 240, SND_19_BUS_START_PULL_AWAY, 224, 20, CT_PAPER ), /* 45 */
+ ROV( 13, 121, 90, SND_19_BUS_START_PULL_AWAY, 96, 22, CT_COPPER_ORE ), /* 46 */
+ ROV( 30, 140, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_COPPER_ORE ), /* 47 */
+ ROV( 47, 150, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_COPPER_ORE ), /* 48 */
+ ROV( 14, 111, 90, SND_19_BUS_START_PULL_AWAY, 96, 21, CT_WATER ), /* 49 */
+ ROV( 31, 141, 168, SND_19_BUS_START_PULL_AWAY, 176, 25, CT_WATER ), /* 50 */
+ ROV( 48, 151, 240, SND_19_BUS_START_PULL_AWAY, 224, 27, CT_WATER ), /* 51 */
+ ROV( 15, 118, 90, SND_19_BUS_START_PULL_AWAY, 96, 18, CT_FRUIT ), /* 52 */
+ ROV( 32, 148, 168, SND_19_BUS_START_PULL_AWAY, 176, 20, CT_FRUIT ), /* 53 */
+ ROV( 49, 158, 240, SND_19_BUS_START_PULL_AWAY, 224, 23, CT_FRUIT ), /* 54 */
+ ROV( 16, 117, 90, SND_19_BUS_START_PULL_AWAY, 96, 17, CT_RUBBER ), /* 55 */
+ ROV( 33, 147, 168, SND_19_BUS_START_PULL_AWAY, 176, 19, CT_RUBBER ), /* 56 */
+ ROV( 50, 157, 240, SND_19_BUS_START_PULL_AWAY, 224, 22, CT_RUBBER ), /* 57 */
+ ROV( 52, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_SUGAR ), /* 58 */
+ ROV( 52, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_SUGAR ), /* 59 */
+ ROV( 52, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_SUGAR ), /* 60 */
+ ROV( 53, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_COLA ), /* 61 */
+ ROV( 53, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_COLA ), /* 62 */
+ ROV( 53, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_COLA ), /* 63 */
+ ROV( 54, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_COTTON_CANDY ), /* 64 */
+ ROV( 54, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_COTTON_CANDY ), /* 65 */
+ ROV( 54, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_COTTON_CANDY ), /* 66 */
+ ROV( 55, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_TOFFEE ), /* 67 */
+ ROV( 55, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_TOFFEE ), /* 68 */
+ ROV( 55, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_TOFFEE ), /* 69 */
+ ROV( 56, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_TOYS ), /* 70 */
+ ROV( 56, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_TOYS ), /* 71 */
+ ROV( 56, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_TOYS ), /* 72 */
+ ROV( 58, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_CANDY ), /* 73 */
+ ROV( 58, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_CANDY ), /* 74 */
+ ROV( 58, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_CANDY ), /* 75 */
+ ROV( 59, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_BATTERIES ), /* 76 */
+ ROV( 59, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_BATTERIES ), /* 77 */
+ ROV( 59, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_BATTERIES ), /* 78 */
+ ROV( 60, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_FIZZY_DRINKS ), /* 79 */
+ ROV( 60, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_FIZZY_DRINKS ), /* 80 */
+ ROV( 60, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_FIZZY_DRINKS ), /* 81 */
+ ROV( 61, 117, 90, SND_3F_COMEDY_CAR_3, 96, 17, CT_PLASTIC ), /* 82 */
+ ROV( 61, 147, 168, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 176, 19, CT_PLASTIC ), /* 83 */
+ ROV( 61, 157, 240, SND_3F_COMEDY_CAR_3, 224, 22, CT_PLASTIC ), /* 84 */
+ ROV( 62, 117, 90, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 96, 17, CT_BUBBLES ), /* 85 */
+ ROV( 62, 147, 168, SND_3F_COMEDY_CAR_3, 176, 19, CT_BUBBLES ), /* 86 */
+ ROV( 62, 157, 240, SND_40_COMEDY_CAR_START_AND_PULL_AWAY, 224, 22, CT_BUBBLES ), /* 87 */
};
-#undef RVI
+#undef ROV
#endif /* ENGINES_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/files.h
--- a/src/table/files.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/files.h Sat Jun 02 19:59:29 2007 +0000
@@ -59,7 +59,11 @@
{ "autorail.grf", { 0xed, 0x44, 0x7f, 0xbb, 0x19, 0x44, 0x48, 0x4c, 0x07, 0x8a, 0xb1, 0xc1, 0x5c, 0x12, 0x3a, 0x60 } },
{ "canalsw.grf", { 0x13, 0x9c, 0x98, 0xcf, 0xb8, 0x7c, 0xd7, 0x1f, 0xca, 0x34, 0xa5, 0x6b, 0x65, 0x31, 0xec, 0x0f } },
{ "elrailsw.grf", { 0x4f, 0xf9, 0xac, 0x79, 0x50, 0x28, 0x9b, 0xe2, 0x15, 0x30, 0xa8, 0x1e, 0xd5, 0xfd, 0xe1, 0xda } },
- { "openttd.grf", { 0x10, 0xc1, 0x68, 0x56, 0x9e, 0x1e, 0x0e, 0x85, 0x9d, 0xf8, 0x53, 0x27, 0x48, 0x7e, 0x17, 0x58 } },
+ { "openttd.grf", { 0x20, 0x64, 0x4a, 0xf6, 0x75, 0x26, 0x5b, 0x92, 0xbb, 0x6f, 0x8d, 0x0e, 0x34, 0x7e, 0xa6, 0xe3 } },
{ "trkfoundw.grf", { 0x12, 0x33, 0x3f, 0xa3, 0xd1, 0x86, 0x8b, 0x04, 0x53, 0x18, 0x9c, 0xee, 0xf9, 0x2d, 0xf5, 0x95 } },
{ "roadstops.grf", { 0x8c, 0xd9, 0x45, 0x21, 0x28, 0x82, 0x96, 0x45, 0x33, 0x22, 0x7a, 0xb9, 0x0d, 0xf3, 0x67, 0x4a } },
+ { "group.grf", { 0xe8, 0x52, 0x5f, 0x1c, 0x3e, 0xf9, 0x91, 0x9d, 0x0f, 0x70, 0x8c, 0x8a, 0x21, 0xa4, 0xc7, 0x02 } },
+ { "tramtrkw.grf", { 0x83, 0x0a, 0xf4, 0x9f, 0x29, 0x10, 0x48, 0xfd, 0x76, 0xe9, 0xda, 0xac, 0x5d, 0xa2, 0x30, 0x45 } },
+ { "oneway.grf", { 0xbb, 0xc6, 0xa3, 0xb2, 0xb3, 0xa0, 0xc9, 0x3c, 0xc9, 0xee, 0x24, 0x7c, 0xb6, 0x51, 0x74, 0x63 } },
+ { "flags.grf", { 0xa1, 0xd7, 0x72, 0x75, 0x0e, 0x81, 0x86, 0x0e, 0xc9, 0xcd, 0xc2, 0x57, 0xb2, 0x19, 0xe1, 0x0c } },
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/industry_land.h
--- a/src/table/industry_land.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/industry_land.h Sat Jun 02 19:59:29 2007 +0000
@@ -2,22 +2,47 @@
/** @file industry_land.h */
-struct DrawIndustrySpec1Struct {
- byte x;
- byte image_1;
- byte image_2;
- byte image_3;
+/**
+ * This is used to gather some data about animation
+ * drawing in the industry code
+ * Image_1-2-3 are in fact only offset in the sprites
+ * used by the industry.
+ * To specify an invalid one, either 255 or 0 is used,
+ * depending of the industry.
+ */
+struct DrawIndustryAnimationStruct {
+ int x; ///< coordinate x of the first image offset
+ byte image_1; ///< image offset 1
+ byte image_2; ///< image offset 2
+ byte image_3; ///< image offset 3
};
-struct DrawIndustrySpec4Struct {
- byte image_1;
- byte image_2;
- byte image_3;
+/**
+ * Simple structure gathering x,y coordinates for
+ * industries animations
+ */
+struct DrawIndustryCoordinates {
+ byte x; ///< coordinate x of the pair
+ byte y; ///< coordinate y of the pair
};
+/**
+ * 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 }
-static const DrawBuildingsTileStruct _industry_draw_tile_data[NUM_INDUSTRY_GFXES * 4] = {
+/** Structure for industry tiles drawing */
+static const DrawBuildingsTileStruct _industry_draw_tile_data[NEW_INDUSTRYTILEOFFSET * 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),
M( 0xf54, PAL_NONE, 0x7dd, PAL_NONE, 7, 0, 9, 9, 30, 0),
@@ -719,9 +744,10 @@
M( 0xf8d, PAL_NONE, 0x12a5 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 0, 16, 16, 50, 1),
M( 0xf8d, PAL_NONE, 0x12a5 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 0, 16, 16, 50, 1),
};
+#undef M
/* this is ONLY used for Sugar Mine*/
-static const DrawIndustrySpec1Struct _draw_industry_spec1[96] = {
+static const DrawIndustryAnimationStruct _draw_industry_spec1[96] = {
{ 8, 4, 0, 0},
{ 6, 0, 1, 0},
{ 4, 0, 2, 0},
@@ -821,71 +847,77 @@
};
/* this is ONLY used for Sugar Mine*/
-static const byte _drawtile_proc1_x[5] = {
- 22, 17, 14, 10, 8
-};
-
-/* this is ONLY used for Sugar Mine*/
-static const byte _drawtile_proc1_y[5] = {
- 73, 70, 69, 66, 41
+static const DrawIndustryCoordinates _drawtile_proc1[5] = {
+ {22, 73},
+ {17, 70},
+ {14, 69},
+ {10, 66},
+ { 8, 41},
};
-/* this is ONLY used for Toy Factory*/
-static const DrawIndustrySpec4Struct _industry_anim_offs_3[] = {
- {255, 255, 0},
- { 0, 255, 0},
- { 1, 255, 0},
- { 2, 255, 0},
- { 3, 255, 0},
- { 4, 255, 0},
- { 5, 255, 0},
- { 6, 255, 0},
- { 7, 255, 0},
- { 8, 255, 0},
- { 9, 255, 0},
- { 10, 255, 0},
- { 11, 255, 0},
- { 12, 255, 0},
- { 13, 255, 0},
- { 14, 255, 0},
- { 15, 255, 0},
- { 16, 255, 0},
- { 17, 255, 0},
- { 18, 255, 0},
- { 18, 255, 1},
- { 18, 255, 2},
- { 18, 255, 4},
- { 18, 255, 6},
- { 18, 255, 8},
- { 18, 255, 11},
- { 18, 255, 14},
- { 18, 255, 17},
- { 18, 255, 20},
- { 18, 255, 24},
- {255, 0, 29},
- {255, 0, 24},
- {255, 0, 20},
- {255, 0, 17},
- {255, 0, 14},
- {255, 0, 11},
- {255, 0, 8},
- {255, 0, 6},
- {255, 0, 4},
- {255, 0, 2},
- {255, 0, 1},
- {255, 1, 0},
- {255, 2, 0},
- {255, 3, 0},
- {255, 4, 0},
- {255, 5, 0},
- {255, 6, 0},
- {255, 7, 0},
- {255, 8, 0},
- {255, 255, 0},
+/** this is ONLY used for Toy Factory.
+ * 255 means no drawing
+ * @param img1 offset from base sprite SPR_IT_SUGAR_MINE_SIEVE
+ * @param img2 offset from base sprite SPR_IT_SUGAR_MINE_CLOUDS
+ * @param img3 offset from base sprite SPR_IT_SUGAR_MINE_PILE
+ */
+#define MD( img1, img2, img3) { (50 - img1 * 2), img1, img2, img3 }
+static const DrawIndustryAnimationStruct _industry_anim_offs_toys[] = {
+ MD(255, 255, 0),
+ MD( 0, 255, 0),
+ MD( 1, 255, 0),
+ MD( 2, 255, 0),
+ MD( 3, 255, 0),
+ MD( 4, 255, 0),
+ MD( 5, 255, 0),
+ MD( 6, 255, 0),
+ MD( 7, 255, 0),
+ MD( 8, 255, 0),
+ MD( 9, 255, 0),
+ MD( 10, 255, 0),
+ MD( 11, 255, 0),
+ MD( 12, 255, 0),
+ MD( 13, 255, 0),
+ MD( 14, 255, 0),
+ MD( 15, 255, 0),
+ MD( 16, 255, 0),
+ MD( 17, 255, 0),
+ MD( 18, 255, 0),
+ MD( 18, 255, 1),
+ MD( 18, 255, 2),
+ MD( 18, 255, 4),
+ MD( 18, 255, 6),
+ MD( 18, 255, 8),
+ MD( 18, 255, 11),
+ MD( 18, 255, 14),
+ MD( 18, 255, 17),
+ MD( 18, 255, 20),
+ MD( 18, 255, 24),
+ MD(255, 0, 29),
+ MD(255, 0, 24),
+ MD(255, 0, 20),
+ MD(255, 0, 17),
+ MD(255, 0, 14),
+ MD(255, 0, 11),
+ MD(255, 0, 8),
+ MD(255, 0, 6),
+ MD(255, 0, 4),
+ MD(255, 0, 2),
+ MD(255, 0, 1),
+ MD(255, 1, 0),
+ MD(255, 2, 0),
+ MD(255, 3, 0),
+ MD(255, 4, 0),
+ MD(255, 5, 0),
+ MD(255, 6, 0),
+ MD(255, 7, 0),
+ MD(255, 8, 0),
+ MD(255, 255, 0),
};
+#undef MD
/* this is ONLY used for Toffee Quarry*/
-static const byte _industry_anim_offs[] = {
+static const byte _industry_anim_offs_toffee[] = {
255, 0, 0, 0, 2, 4, 6, 8, 10, 9,
7, 5, 3, 1, 255, 0, 0, 0, 2, 4,
6, 8, 10, 9, 7, 5, 3, 1, 255, 0,
@@ -896,13 +928,22 @@
};
/* this is ONLY used for the Bubble Generator*/
-static const byte _industry_anim_offs_2[] = {
+static const byte _industry_anim_offs_bubbles[] = {
68, 69, 71, 74, 77, 80, 83, 85, 86, 86,
86, 86, 86, 86, 86, 86, 86, 86, 86, 86,
86, 86, 85, 84, 83, 82, 81, 80, 79, 78,
77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
};
-/* those are ONLY used for Power Station*/
-static const byte _coal_plant_sparks_x[] = {11, 11, 14, 13, 18, 15};
-static const byte _coal_plant_sparks_y[] = {23, 11, 6, 3, 1, 0};
+/**
+ * Movement of the sparks , only used for Power Station
+ */
+static const DrawIndustryCoordinates _coal_plant_sparks[] = {
+ {11, 23},
+ {11, 11},
+ {14, 6},
+ {13, 3},
+ {18, 1},
+ {15, 0},
+};
+
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/namegen.h
--- a/src/table/namegen.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/namegen.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file table/namegen.h Namepart tables for the town name generator */
+
#include "../stdafx.h"
#include "../openttd.h"
@@ -1929,7 +1931,7 @@
-static const char *name_romanian_real[]= {
+static const char *name_romanian_real[] = {
"Adjud",
"Alba Iulia",
"Alexandria",
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/palettes.h
--- a/src/table/palettes.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/palettes.h Sat Jun 02 19:59:29 2007 +0000
@@ -178,22 +178,43 @@
byte shadow;
};
-static const StringColor _string_colormap[] = {
- { 150, 215 }, // BLUE
- { 12, 215 }, // SILVER
- { 189, 215 }, // GOLD
- { 184, 215 }, // RED
- { 174, 215 }, // PURPLE
- { 30, 215 }, // LTBROWN
- { 195, 215 }, // ORANGE
- { 209, 215 }, // GREEN
- { 68, 215 }, // YELLOW
- { 95, 215 }, // DKGREEN
- { 79, 215 }, // CREAM
- { 116, 215 }, // BROWN
- { 15, 215 }, // WHITE
- { 152, 215 }, // LTBLUE
- { 32, 215 }, // GRAY
- { 133, 215 }, // DKBLUE
- { 215, 0 }, // BLACK
+static const StringColor _string_colormap[][17] = {
+ { /* Windows palette. */
+ { 150, 215 }, // BLUE
+ { 12, 215 }, // SILVER
+ { 189, 215 }, // GOLD
+ { 184, 215 }, // RED
+ { 174, 215 }, // PURPLE
+ { 30, 215 }, // LTBROWN
+ { 195, 215 }, // ORANGE
+ { 209, 215 }, // GREEN
+ { 68, 215 }, // YELLOW
+ { 95, 215 }, // DKGREEN
+ { 79, 215 }, // CREAM
+ { 116, 215 }, // BROWN
+ { 15, 215 }, // WHITE
+ { 152, 215 }, // LTBLUE
+ { 32, 215 }, // GRAY
+ { 133, 215 }, // DKBLUE
+ { 215, 0 }, // BLACK
+ },
+ { /* DOS palette. */
+ { 150, 1 }, // BLUE
+ { 12, 1 }, // SILVER
+ { 189, 1 }, // GOLD
+ { 184, 1 }, // RED
+ { 174, 1 }, // PURPLE
+ { 30, 1 }, // LTBROWN
+ { 195, 1 }, // ORANGE
+ { 209, 1 }, // GREEN
+ { 68, 1 }, // YELLOW
+ { 95, 1 }, // DKGREEN
+ { 79, 1 }, // CREAM
+ { 116, 1 }, // BROWN
+ { 15, 1 }, // WHITE
+ { 152, 1 }, // LTBLUE
+ { 6, 1 }, // GRAY
+ { 133, 1 }, // DKBLUE
+ { 1, 0 }, // BLACK
+ }
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/road_land.h
--- a/src/table/road_land.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/road_land.h Sat Jun 02 19:59:29 2007 +0000
@@ -32,6 +32,35 @@
{ 0xA4A, PAL_NONE, _road_depot_NW }
};
+static const DrawTileSeqStruct _tram_depot_NE[] = {
+ TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x35 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
+ TILE_SEQ_END()
+};
+
+static const DrawTileSeqStruct _tram_depot_SE[] = {
+ TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x31, PAL_NONE, 0, 0, 1, 16)
+ TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x32 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 15, 0, 1, 16)
+ TILE_SEQ_END()
+};
+
+static const DrawTileSeqStruct _tram_depot_SW[] = {
+ TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x33, PAL_NONE, 0, 0, 16, 1)
+ TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x34 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 0, 15, 16, 1)
+ TILE_SEQ_END()
+};
+
+static const DrawTileSeqStruct _tram_depot_NW[] = {
+ TILE_SEQ_LINE(SPR_TRAMWAY_BASE + 0x36 | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE, 15, 0, 1, 16)
+ TILE_SEQ_END()
+};
+
+static const DrawTileSprites _tram_depot[] = {
+ { 0xA4A, PAL_NONE, _tram_depot_NE },
+ { 0xA4A, PAL_NONE, _tram_depot_SE },
+ { 0xA4A, PAL_NONE, _tram_depot_SW },
+ { 0xA4A, PAL_NONE, _tram_depot_NW }
+};
+
#undef TILE_SEQ_BEGIN
#undef TILE_SEQ_LINE
#undef TILE_SEQ_END
@@ -42,7 +71,13 @@
0x543, 0x53C, 0x535, 0x538, 0x53D, 0x537, 0x53A, 0x536
};
+static const SpriteID _road_frontwire_sprites_1[16] = {
+ 0, 0x37, 0x37, 0x3F, 0x37, 0x37, 0x43, 0x37, 0x37, 0x3F, 0x37, 0x37, 0x3F, 0x37, 0x37, 0x37
+};
+static const SpriteID _road_backpole_sprites_1[16] = {
+ 0, 0x38, 0x39, 0x40, 0x38, 0x38, 0x43, 0x3E, 0x39, 0x41, 0x39, 0x3C, 0x42, 0x3B, 0x3D, 0x3A
+};
#define MAKELINE(a, b, c) { a, b, c },
#define ENDLINE { 0, 0, 0 }
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/roadveh.h
--- a/src/table/roadveh.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/roadveh.h Sat Jun 02 19:59:29 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},
@@ -1009,7 +1011,7 @@
{RDE_NEXT_TILE | DIAGDIR_SE, 0}
};
-static const RoadDriveEntry * const _road_drive_data[] = {
+static const RoadDriveEntry * const _road_road_drive_data[] = {
_roadveh_drive_data_0,
_roadveh_drive_data_1,
_roadveh_drive_data_2,
@@ -1075,3 +1077,386 @@
NULL,
NULL,
};
+
+static const RoadDriveEntry _roadveh_tram_turn_ne_0[] = {
+ {15, 5},
+ {14, 5},
+ {13, 5},
+ {12, 5},
+ {11, 5},
+ {10, 5},
+ { 9, 5},
+ { 8, 5},
+ { 7, 5},
+ { 6, 5},
+ { 5, 5},
+ { 4, 5},
+ { 3, 5},
+ { 2, 5},
+ { 1, 5},
+ { 0, 5},
+ { 0, 6},
+ { 0, 7},
+ { 0, 8},
+ { 0, 9},
+ { 1, 9},
+ { 2, 9},
+ { 3, 9},
+ { 4, 9},
+ { 5, 9},
+ { 6, 9},
+ { 7, 9},
+ { 8, 9},
+ { 9, 9},
+ {10, 9},
+ {11, 9},
+ {12, 9},
+ {13, 9},
+ {14, 9},
+ {15, 9},
+ {RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_ne_1[] = {
+ {15, 9},
+ {14, 9},
+ {13, 9},
+ {12, 9},
+ {11, 9},
+ {10, 9},
+ { 9, 9},
+ { 8, 9},
+ { 7, 9},
+ { 6, 9},
+ { 5, 9},
+ { 4, 9},
+ { 3, 9},
+ { 2, 9},
+ { 1, 9},
+ { 0, 9},
+ { 0, 8},
+ { 0, 7},
+ { 0, 6},
+ { 0, 5},
+ { 1, 5},
+ { 2, 5},
+ { 3, 5},
+ { 4, 5},
+ { 5, 5},
+ { 6, 5},
+ { 7, 5},
+ { 8, 5},
+ { 9, 5},
+ {10, 5},
+ {11, 5},
+ {12, 5},
+ {13, 5},
+ {14, 5},
+ {15, 5},
+ {RDE_NEXT_TILE | DIAGDIR_SW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_se_0[] = {
+ {5, 0},
+ {5, 1},
+ {5, 2},
+ {5, 3},
+ {5, 4},
+ {5, 5},
+ {5, 6},
+ {5, 7},
+ {5, 8},
+ {5, 9},
+ {5, 10},
+ {5, 11},
+ {5, 12},
+ {5, 13},
+ {5, 14},
+ {5, 15},
+ {6, 15},
+ {7, 15},
+ {8, 15},
+ {9, 15},
+ {9, 14},
+ {9, 13},
+ {9, 12},
+ {9, 11},
+ {9, 10},
+ {9, 9},
+ {9, 8},
+ {9, 7},
+ {9, 6},
+ {9, 5},
+ {9, 4},
+ {9, 3},
+ {9, 2},
+ {9, 1},
+ {9, 0},
+ {RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_se_1[] = {
+ {9, 0},
+ {9, 1},
+ {9, 2},
+ {9, 3},
+ {9, 4},
+ {9, 5},
+ {9, 6},
+ {9, 7},
+ {9, 8},
+ {9, 9},
+ {9, 10},
+ {9, 11},
+ {9, 12},
+ {9, 13},
+ {9, 14},
+ {9, 15},
+ {8, 15},
+ {7, 15},
+ {6, 15},
+ {5, 15},
+ {5, 14},
+ {5, 13},
+ {5, 12},
+ {5, 11},
+ {5, 10},
+ {5, 9},
+ {5, 8},
+ {5, 7},
+ {5, 6},
+ {5, 5},
+ {5, 4},
+ {5, 3},
+ {5, 2},
+ {5, 1},
+ {5, 0},
+ {RDE_NEXT_TILE | DIAGDIR_NW, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_sw_0[] = {
+ { 0, 9},
+ { 1, 9},
+ { 2, 9},
+ { 3, 9},
+ { 4, 9},
+ { 5, 9},
+ { 6, 9},
+ { 7, 9},
+ { 8, 9},
+ { 9, 9},
+ {10, 9},
+ {11, 9},
+ {12, 9},
+ {13, 9},
+ {14, 9},
+ {15, 9},
+ {15, 8},
+ {15, 7},
+ {15, 6},
+ {15, 5},
+ {14, 5},
+ {13, 5},
+ {12, 5},
+ {11, 5},
+ {10, 5},
+ { 9, 5},
+ { 8, 5},
+ { 7, 5},
+ { 6, 5},
+ { 5, 5},
+ { 4, 5},
+ { 3, 5},
+ { 2, 5},
+ { 1, 5},
+ { 0, 5},
+ {RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+static const RoadDriveEntry _roadveh_tram_turn_sw_1[] = {
+ { 0, 5},
+ { 1, 5},
+ { 2, 5},
+ { 3, 5},
+ { 4, 5},
+ { 5, 5},
+ { 6, 5},
+ { 7, 5},
+ { 8, 5},
+ { 9, 5},
+ {10, 5},
+ {11, 5},
+ {12, 5},
+ {13, 5},
+ {14, 5},
+ {15, 5},
+ {15, 6},
+ {15, 7},
+ {15, 8},
+ {15, 9},
+ {14, 9},
+ {13, 9},
+ {12, 9},
+ {11, 9},
+ {10, 9},
+ { 9, 9},
+ { 8, 9},
+ { 7, 9},
+ { 6, 9},
+ { 5, 9},
+ { 4, 9},
+ { 3, 9},
+ { 2, 9},
+ { 1, 9},
+ { 0, 9},
+ {RDE_NEXT_TILE | DIAGDIR_NE, 0}
+};
+
+static const RoadDriveEntry _roadveh_tram_turn_nw_0[] = {
+ {9, 15},
+ {9, 14},
+ {9, 13},
+ {9, 12},
+ {9, 11},
+ {9, 10},
+ {9, 9},
+ {9, 8},
+ {9, 7},
+ {9, 6},
+ {9, 5},
+ {9, 4},
+ {9, 3},
+ {9, 2},
+ {9, 1},
+ {9, 0},
+ {8, 0},
+ {7, 0},
+ {6, 0},
+ {5, 0},
+ {5, 1},
+ {5, 2},
+ {5, 3},
+ {5, 4},
+ {5, 5},
+ {5, 6},
+ {5, 7},
+ {5, 8},
+ {5, 9},
+ {5, 10},
+ {5, 11},
+ {5, 12},
+ {5, 13},
+ {5, 14},
+ {5, 15},
+ {RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+static const RoadDriveEntry _roadveh_tram_turn_nw_1[] = {
+ {5, 15},
+ {5, 14},
+ {5, 13},
+ {5, 12},
+ {5, 11},
+ {5, 10},
+ {5, 9},
+ {5, 8},
+ {5, 7},
+ {5, 6},
+ {5, 5},
+ {5, 4},
+ {5, 3},
+ {5, 2},
+ {5, 1},
+ {5, 0},
+ {6, 0},
+ {7, 0},
+ {8, 0},
+ {9, 0},
+ {9, 1},
+ {9, 2},
+ {9, 3},
+ {9, 4},
+ {9, 5},
+ {9, 6},
+ {9, 7},
+ {9, 8},
+ {9, 9},
+ {9, 10},
+ {9, 11},
+ {9, 12},
+ {9, 13},
+ {9, 14},
+ {9, 15},
+ {RDE_NEXT_TILE | DIAGDIR_SE, 0}
+};
+
+static const RoadDriveEntry * const _road_tram_drive_data[] = {
+ _roadveh_drive_data_0,
+ _roadveh_drive_data_1,
+ _roadveh_drive_data_2,
+ _roadveh_drive_data_3,
+ _roadveh_drive_data_4,
+ _roadveh_drive_data_5,
+ _roadveh_tram_turn_ne_0,
+ _roadveh_tram_turn_se_0,
+ _roadveh_drive_data_8,
+ _roadveh_drive_data_9,
+ _roadveh_drive_data_10,
+ _roadveh_drive_data_11,
+ _roadveh_drive_data_12,
+ _roadveh_drive_data_13,
+ _roadveh_tram_turn_sw_0,
+ _roadveh_tram_turn_nw_0,
+ _roadveh_drive_data_16,
+ _roadveh_drive_data_17,
+ _roadveh_drive_data_18,
+ _roadveh_drive_data_19,
+ _roadveh_drive_data_20,
+ _roadveh_drive_data_21,
+ _roadveh_tram_turn_ne_1,
+ _roadveh_tram_turn_se_1,
+ _roadveh_drive_data_24,
+ _roadveh_drive_data_25,
+ _roadveh_drive_data_26,
+ _roadveh_drive_data_27,
+ _roadveh_drive_data_28,
+ _roadveh_drive_data_29,
+ _roadveh_tram_turn_sw_1,
+ _roadveh_tram_turn_nw_1,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+};
+
+static const RoadDriveEntry * const * const _road_drive_data[2] = {
+ _road_road_drive_data,
+ _road_tram_drive_data,
+};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/sprites.h
--- a/src/table/sprites.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/sprites.h Sat Jun 02 19:59:29 2007 +0000
@@ -25,7 +25,7 @@
* All sprites which are described here are referenced only one to a handful of times
* throughout the code. When introducing new sprite enums, use meaningful names.
* Don't be lazy and typing, and only use abbrevations when their meaning is clear or
- * the length of the enum would get out of hand. In that case EXPLAINÂ THE ABBREVATION
+ * the length of the enum would get out of hand. In that case EXPLAIN THE ABBREVATION
* IN THIS FILE, and perhaps add some comments in the code where it is used.
* Now, don't whine about this being too much typing work if the enums are like
* 30 characters in length. If your editor doen't help you simplifying your work,
@@ -47,7 +47,7 @@
SPR_ASCII_SPACE_BIG = 450,
/* Extra graphic spritenumbers */
- OPENTTD_SPRITES_COUNT = 117, // number of gfx-sprites in openttd.grf
+ OPENTTD_SPRITES_COUNT = 112, // number of gfx-sprites in openttd.grf
SPR_SIGNALS_BASE = 4896,
SPR_CANALS_BASE = SPR_SIGNALS_BASE + 486,
SPR_SLOPES_BASE = SPR_CANALS_BASE + 70,
@@ -62,44 +62,43 @@
SPR_PIN_DOWN = SPR_OPENTTD_BASE + 56,
SPR_BOX_EMPTY = SPR_OPENTTD_BASE + 59,
SPR_BOX_CHECKED = SPR_OPENTTD_BASE + 60,
- SPR_WINDOW_RESIZE = SPR_OPENTTD_BASE + 87, // resize icon
- SPR_HOUSE_ICON = SPR_OPENTTD_BASE + 94,
+ SPR_WINDOW_RESIZE = SPR_OPENTTD_BASE + 82, // resize icon
+ SPR_HOUSE_ICON = SPR_OPENTTD_BASE + 89,
// arrow icons pointing in all 4 directions
- SPR_ARROW_DOWN = SPR_OPENTTD_BASE + 88,
- SPR_ARROW_UP = SPR_OPENTTD_BASE + 89,
- SPR_ARROW_LEFT = SPR_OPENTTD_BASE + 90,
- SPR_ARROW_RIGHT = SPR_OPENTTD_BASE + 91,
+ SPR_ARROW_DOWN = SPR_OPENTTD_BASE + 83,
+ SPR_ARROW_UP = SPR_OPENTTD_BASE + 84,
+ SPR_ARROW_LEFT = SPR_OPENTTD_BASE + 85,
+ SPR_ARROW_RIGHT = SPR_OPENTTD_BASE + 86,
SPR_LARGE_SMALL_WINDOW = 682,
/* Clone vehicles stuff */
- SPR_CLONE_TRAIN = SPR_OPENTTD_BASE + 92,
- SPR_CLONE_ROADVEH = SPR_OPENTTD_BASE + 109,
- SPR_CLONE_SHIP = SPR_OPENTTD_BASE + 111,
- SPR_CLONE_AIRCRAFT = SPR_OPENTTD_BASE + 113,
+ SPR_CLONE_TRAIN = SPR_OPENTTD_BASE + 87,
+ SPR_CLONE_ROADVEH = SPR_OPENTTD_BASE + 104,
+ SPR_CLONE_SHIP = SPR_OPENTTD_BASE + 106,
+ SPR_CLONE_AIRCRAFT = SPR_OPENTTD_BASE + 108,
- SPR_SELL_TRAIN = SPR_OPENTTD_BASE + 96,
- SPR_SELL_ROADVEH = SPR_OPENTTD_BASE + 97,
- SPR_SELL_SHIP = SPR_OPENTTD_BASE + 98,
- SPR_SELL_AIRCRAFT = SPR_OPENTTD_BASE + 99,
- SPR_SELL_ALL_TRAIN = SPR_OPENTTD_BASE + 100,
- SPR_SELL_ALL_ROADVEH = SPR_OPENTTD_BASE + 101,
- SPR_SELL_ALL_SHIP = SPR_OPENTTD_BASE + 102,
- SPR_SELL_ALL_AIRCRAFT = SPR_OPENTTD_BASE + 103,
- SPR_REPLACE_TRAIN = SPR_OPENTTD_BASE + 104,
- SPR_REPLACE_ROADVEH = SPR_OPENTTD_BASE + 105,
- SPR_REPLACE_SHIP = SPR_OPENTTD_BASE + 106,
- SPR_REPLACE_AIRCRAFT = SPR_OPENTTD_BASE + 107,
- SPR_SELL_CHAIN_TRAIN = SPR_OPENTTD_BASE + 108,
+ SPR_SELL_TRAIN = SPR_OPENTTD_BASE + 91,
+ SPR_SELL_ROADVEH = SPR_OPENTTD_BASE + 92,
+ SPR_SELL_SHIP = SPR_OPENTTD_BASE + 93,
+ SPR_SELL_AIRCRAFT = SPR_OPENTTD_BASE + 94,
+ SPR_SELL_ALL_TRAIN = SPR_OPENTTD_BASE + 95,
+ SPR_SELL_ALL_ROADVEH = SPR_OPENTTD_BASE + 96,
+ SPR_SELL_ALL_SHIP = SPR_OPENTTD_BASE + 97,
+ SPR_SELL_ALL_AIRCRAFT = SPR_OPENTTD_BASE + 98,
+ SPR_REPLACE_TRAIN = SPR_OPENTTD_BASE + 99,
+ SPR_REPLACE_ROADVEH = SPR_OPENTTD_BASE + 100,
+ SPR_REPLACE_SHIP = SPR_OPENTTD_BASE + 101,
+ SPR_REPLACE_AIRCRAFT = SPR_OPENTTD_BASE + 102,
+ SPR_SELL_CHAIN_TRAIN = SPR_OPENTTD_BASE + 103,
- SPR_SHARED_ORDERS_ICON = SPR_OPENTTD_BASE + 115,
+ SPR_SHARED_ORDERS_ICON = SPR_OPENTTD_BASE + 110,
- SPR_WARNING_SIGN = SPR_OPENTTD_BASE + 116, // warning sign (shown if there are any newgrf errors)
+ SPR_WARNING_SIGN = SPR_OPENTTD_BASE + 111, // warning sign (shown if there are any newgrf errors)
/* Network GUI sprites */
SPR_SQUARE = SPR_OPENTTD_BASE + 20, // colored square (used for newgrf compatibility)
SPR_LOCK = SPR_OPENTTD_BASE + 19, // lock icon (for password protected servers)
- SPR_FLAGS_BASE = SPR_OPENTTD_BASE + 83, // start of the flags block (in same order as enum NetworkLanguage)
SPR_AIRPORTX_BASE = SPR_OPENTTD_BASE + OPENTTD_SPRITES_COUNT, // The sprites used for other airport angles
SPR_NEWAIRPORT_TARMAC = SPR_AIRPORTX_BASE,
@@ -128,6 +127,52 @@
SPR_TRUCK_STOP_DT_X_W = SPR_ROADSTOP_BASE + 6,
SPR_TRUCK_STOP_DT_X_E = SPR_ROADSTOP_BASE + 7,
+ SPR_GROUP_BASE = SPR_ROADSTOP_BASE + 8, // The sprites used for the group interface
+ SPR_GROUP_CREATE_TRAIN = SPR_GROUP_BASE,
+ SPR_GROUP_CREATE_ROADVEH = SPR_GROUP_BASE + 1,
+ SPR_GROUP_CREATE_SHIP = SPR_GROUP_BASE + 2,
+ SPR_GROUP_CREATE_AIRCRAFT = SPR_GROUP_BASE + 3,
+ SPR_GROUP_DELETE_TRAIN = SPR_GROUP_BASE + 4,
+ SPR_GROUP_DELETE_ROADVEH = SPR_GROUP_BASE + 5,
+ SPR_GROUP_DELETE_SHIP = SPR_GROUP_BASE + 6,
+ SPR_GROUP_DELETE_AIRCRAFT = SPR_GROUP_BASE + 7,
+ SPR_GROUP_RENAME_TRAIN = SPR_GROUP_BASE + 8,
+ SPR_GROUP_RENAME_ROADVEH = SPR_GROUP_BASE + 9,
+ SPR_GROUP_RENAME_SHIP = SPR_GROUP_BASE + 10,
+ SPR_GROUP_RENAME_AIRCRAFT = SPR_GROUP_BASE + 11,
+ SPR_GROUP_REPLACE_ON_TRAIN = SPR_GROUP_BASE + 12,
+ SPR_GROUP_REPLACE_ON_ROADVEH = SPR_GROUP_BASE + 13,
+ SPR_GROUP_REPLACE_ON_SHIP = SPR_GROUP_BASE + 14,
+ SPR_GROUP_REPLACE_ON_AIRCRAFT = SPR_GROUP_BASE + 15,
+ SPR_GROUP_REPLACE_OFF_TRAIN = SPR_GROUP_BASE + 16,
+ SPR_GROUP_REPLACE_OFF_ROADVEH = SPR_GROUP_BASE + 17,
+ SPR_GROUP_REPLACE_OFF_SHIP = SPR_GROUP_BASE + 18,
+ SPR_GROUP_REPLACE_OFF_AIRCRAFT = SPR_GROUP_BASE + 19,
+
+ /* Tramway sprites */
+ SPR_TRAMWAY_BASE = SPR_GROUP_BASE + 20,
+ SPR_TRAMWAY_OVERLAY = SPR_TRAMWAY_BASE + 4,
+ SPR_TRAMWAY_TRAM = SPR_TRAMWAY_BASE + 27,
+ SPR_TRAMWAY_SLOPED_OFFSET = 11,
+ SPR_TRAMWAY_BUS_STOP_DT_Y_W = SPR_TRAMWAY_BASE + 25,
+ SPR_TRAMWAY_BUS_STOP_DT_Y_E = SPR_TRAMWAY_BASE + 23,
+ SPR_TRAMWAY_BUS_STOP_DT_X_W = SPR_TRAMWAY_BASE + 24,
+ SPR_TRAMWAY_BUS_STOP_DT_X_E = SPR_TRAMWAY_BASE + 26,
+ SPR_TRAMWAY_PAVED_STRAIGHT_Y = SPR_TRAMWAY_BASE + 46,
+ SPR_TRAMWAY_PAVED_STRAIGHT_X = SPR_TRAMWAY_BASE + 47,
+ SPR_TRAMWAY_BACK_WIRES_STRAIGHT = SPR_TRAMWAY_BASE + 55,
+ SPR_TRAMWAY_FRONT_WIRES_STRAIGHT = SPR_TRAMWAY_BASE + 56,
+ SPR_TRAMWAY_BACK_WIRES_SLOPED = SPR_TRAMWAY_BASE + 72,
+ SPR_TRAMWAY_FRONT_WIRES_SLOPED = SPR_TRAMWAY_BASE + 68,
+ SPR_TRAMWAY_TUNNEL_WIRES = SPR_TRAMWAY_BASE + 80,
+ SPR_TRAMWAY_BRIDGE = SPR_TRAMWAY_BASE + 107,
+
+ /* One way road sprites */
+ SPR_ONEWAY_BASE = SPR_TRAMWAY_BASE + 113,
+
+ /* Flags sprites (in same order as enum NetworkLanguage) */
+ SPR_FLAGS_BASE = SPR_ONEWAY_BASE + 6,
+
/* Manager face sprites */
SPR_GRADIENT = 874, // background gradient behind manager face
@@ -940,7 +985,6 @@
SPR_IMG_LEVEL_LAND = SPR_OPENTTD_BASE + 61,
SPR_IMG_BUILD_CANAL = SPR_OPENTTD_BASE + 58,
SPR_IMG_BUILD_LOCK = SPR_CANALS_BASE + 69,
- SPR_IMG_PLACE_SIGN = SPR_OPENTTD_BASE + 63,
SPR_IMG_PAUSE = 726,
SPR_IMG_FASTFORWARD = SPR_OPENTTD_BASE + 54,
SPR_IMG_SETTINGS = 751,
@@ -1157,6 +1201,8 @@
SPR_IMG_BRIDGE = 2594,
SPR_IMG_ROAD_TUNNEL = 2429,
SPR_IMG_REMOVE = 714,
+ SPR_IMG_TRAMWAY_NW = SPR_TRAMWAY_BASE + 0,
+ SPR_IMG_TRAMWAY_NE = SPR_TRAMWAY_BASE + 1,
/* rail_gui.c */
SPR_IMG_RAIL_NS = 1251,
@@ -1273,16 +1319,18 @@
/* road cursors */
SPR_CURSOR_ROAD_NESW = 1311,
SPR_CURSOR_ROAD_NWSE = 1312,
+ SPR_CURSOR_TRAMWAY_NESW = SPR_TRAMWAY_BASE + 2,
+ SPR_CURSOR_TRAMWAY_NWSE = SPR_TRAMWAY_BASE + 3,
SPR_CURSOR_ROAD_DEPOT = 1297,
SPR_CURSOR_BUS_STATION = 2725,
SPR_CURSOR_TRUCK_STATION = 2726,
SPR_CURSOR_ROAD_TUNNEL = 2433,
- SPR_CURSOR_CLONE_TRAIN = SPR_OPENTTD_BASE + 93,
- SPR_CURSOR_CLONE_ROADVEH = SPR_OPENTTD_BASE + 110,
- SPR_CURSOR_CLONE_SHIP = SPR_OPENTTD_BASE + 112,
- SPR_CURSOR_CLONE_AIRPLANE = SPR_OPENTTD_BASE + 114,
+ SPR_CURSOR_CLONE_TRAIN = SPR_OPENTTD_BASE + 88,
+ SPR_CURSOR_CLONE_ROADVEH = SPR_OPENTTD_BASE + 105,
+ SPR_CURSOR_CLONE_SHIP = SPR_OPENTTD_BASE + 107,
+ SPR_CURSOR_CLONE_AIRPLANE = SPR_OPENTTD_BASE + 109
};
/// Animation macro in table/animcursors.h (_animcursors[])
@@ -1302,7 +1350,7 @@
* - TRANSPARENT_BIT is the bit number which toggles sprite transparency
* - RECOLOR_BIT toggles the recoloring system
* - PALETTE_SPRITE_WIDTH and PALETTE_SPRITE_START determine the position and number of
- * bits used for the recoloring process. For transparency, it must be 0x322.
+ * bits used for the recoloring process. For transparency, it must be 0x322.
*/
enum SpriteSetup {
TRANSPARENT_BIT = 31, ///< toggles transparency in the sprite
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/station_land.h
--- a/src/table/station_land.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/station_land.h Sat Jun 02 19:59:29 2007 +0000
@@ -34,7 +34,7 @@
{ 0, 0, 0, 16, 5, 7, SPR_RAIL_PLATFORM_PILLARS_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
@@ -42,7 +42,7 @@
{ 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_A | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_A | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
@@ -50,7 +50,7 @@
{ 0, 0, 0, 16, 5, 2, SPR_RAIL_PLATFORM_X_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 11, 0, 16, 5, 2, SPR_RAIL_PLATFORM_PILLARS_X_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_X_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_X_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
@@ -58,7 +58,7 @@
{ 0, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_Y_REAR | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 11, 0, 0, 5, 16, 2, SPR_RAIL_PLATFORM_PILLARS_Y_FRONT | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
{ 0, 0, 16, 16, 16, 10, SPR_RAIL_ROOF_STRUCTURE_Y_TILE_B | (1 << PALETTE_MODIFIER_COLOR), PAL_NONE },
- { 0, 0,(byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
+ { 0, 0, (byte)0x80, 0, 0, 0, SPR_RAIL_ROOF_GLASS_Y_TILE_B | (1 << PALETTE_MODIFIER_TRANSPARENT), PALETTE_TO_TRANSPARENT },
TILE_SEQ_END()
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/town_land.h
--- a/src/table/town_land.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/town_land.h Sat Jun 02 19:59:29 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),
@@ -1779,7 +1781,7 @@
M(0x1244, PAL_NONE, 0x125a, PAL_NONE, 0, 0, 16, 16, 50, 0),
};
#undef M
-/* 4 variants * 4 build stages */
+/** Make sure we have the right number of elements: 4 variants * 4 build stages for each house */
assert_compile(lengthof(_town_draw_tile_data) == (NEW_HOUSE_OFFSET) * 4 * 4);
/** Describes the data that defines each house in the game
@@ -1800,9 +1802,10 @@
* @param cg3 3rd CargoID available
* @see HouseSpec
*/
-#define M(mnd, mxd, p, rc, bn, rr, mg, ca1, ca2, ca3, bf, ba, cg1, cg2, cg3) \
+#define MS(mnd, mxd, p, rc, bn, rr, mg, ca1, ca2, ca3, bf, ba, cg1, cg2, cg3) \
{mnd, mxd, p, rc, bn, rr, mg, {ca1, ca2, ca3}, {cg1, cg2, cg3}, bf, ba, true, \
- 0, NULL, 0, 0, {0, 0, 0, 0}, 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, 0, 2, 0, 0, NULL}
+ 0, NULL, 0, 0, {0, 0, 0, 0}, 16, NO_EXTRA_FLAG, HOUSE_NO_CLASS, 0, 2, 0, 0, 0, NULL}
+/** House specifications from original data */
static const HouseSpec _original_house_specs[] = {
/**
* remove_rating_decrease
@@ -1818,446 +1821,448 @@
* +-building_availability | | | | | | |
* +-cargoID accepted | | | | | | | |
* | | | | | | | | | | | */
- M( 1963, MAX_YEAR, 187, 150, STR_200F_TALL_OFFICE_BLOCK, 140, 70, 8, 3, 4,
+ MS(1963, MAX_YEAR, 187, 150, STR_200F_TALL_OFFICE_BLOCK, 140, 70, 8, 3, 4,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //00
- M( 1957, MAX_YEAR, 85, 140, STR_2010_OFFICE_BLOCK, 130, 55, 8, 3, 4,
+ MS(1957, MAX_YEAR, 85, 140, STR_2010_OFFICE_BLOCK, 130, 55, 8, 3, 4,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //01
- M( 1968, MAX_YEAR, 40, 100, STR_2011_SMALL_BLOCK_OF_FLATS, 90, 20, 8, 3, 1,
+ MS(1968, MAX_YEAR, 40, 100, STR_2011_SMALL_BLOCK_OF_FLATS, 90, 20, 8, 3, 1,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //02
- M( 0, MAX_YEAR, 5, 90, STR_2012_CHURCH, 230, 2, 2, 0, 0,
+ MS( 0, MAX_YEAR, 5, 90, STR_2012_CHURCH, 230, 2, 2, 0, 0,
BUILDING_IS_CHURCH | TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //03
- M( 1975, MAX_YEAR, 220, 160, STR_2013_LARGE_OFFICE_BLOCK, 160, 85, 10, 4, 6,
+ MS(1975, MAX_YEAR, 220, 160, STR_2013_LARGE_OFFICE_BLOCK, 160, 85, 10, 4, 6,
BUILDING_IS_ANIMATED | TILE_SIZE_1x1,
HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //04
- M( 1975, MAX_YEAR, 220, 160, STR_2013_LARGE_OFFICE_BLOCK, 160, 85, 10, 4, 6,
+ MS(1975, MAX_YEAR, 220, 160, STR_2013_LARGE_OFFICE_BLOCK, 160, 85, 10, 4, 6,
BUILDING_IS_ANIMATED | TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //05
- M( 0, MAX_YEAR, 30, 80, STR_2014_TOWN_HOUSES, 80, 12, 4, 1, 0,
+ MS( 0, MAX_YEAR, 30, 80, STR_2014_TOWN_HOUSES, 80, 12, 4, 1, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //06
- M( 1959, MAX_YEAR, 140, 180, STR_2015_HOTEL, 150, 22, 6, 1, 2,
+ MS(1959, MAX_YEAR, 140, 180, STR_2015_HOTEL, 150, 22, 6, 1, 2,
TILE_SIZE_1x2,
HZ_TEMP | HZ_ZON5 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //07
- M( 1959, MAX_YEAR, 0, 180, STR_2015_HOTEL, 150, 22, 6, 1, 2,
+ MS(1959, MAX_YEAR, 0, 180, STR_2015_HOTEL, 150, 22, 6, 1, 2,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //08
- M( 1945, MAX_YEAR, 0, 65, STR_2016_STATUE, 40, 0, 2, 0, 0,
+ MS(1945, MAX_YEAR, 0, 65, STR_2016_STATUE, 40, 0, 2, 0, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //09
- M( 1945, MAX_YEAR, 0, 65, STR_2017_FOUNTAIN, 40, 0, 2, 0, 0,
+ MS(1945, MAX_YEAR, 0, 65, STR_2017_FOUNTAIN, 40, 0, 2, 0, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //0A
- M( 0, MAX_YEAR, 0, 60, STR_2018_PARK, 75, 0, 2, 0, 0,
+ MS( 0, MAX_YEAR, 0, 60, STR_2018_PARK, 75, 0, 2, 0, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //0B
- M( 1935, MAX_YEAR, 0, 60, STR_2018_PARK, 75, 0, 2, 0, 0,
+ MS(1935, MAX_YEAR, 0, 60, STR_2018_PARK, 75, 0, 2, 0, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //0C
- M( 1951, MAX_YEAR, 150, 130, STR_2019_OFFICE_BLOCK, 110, 65, 8, 2, 4,
+ MS(1951, MAX_YEAR, 150, 130, STR_2019_OFFICE_BLOCK, 110, 65, 8, 2, 4,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //0D
- M( 1930, 1960, 95, 110, STR_201A_SHOPS_AND_OFFICES, 100, 48, 6, 2, 3,
+ MS(1930, 1960, 95, 110, STR_201A_SHOPS_AND_OFFICES, 100, 48, 6, 2, 3,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //0E
- M( 1930, 1960, 95, 105, STR_201A_SHOPS_AND_OFFICES, 100, 48, 6, 2, 3,
+ MS(1930, 1960, 95, 105, STR_201A_SHOPS_AND_OFFICES, 100, 48, 6, 2, 3,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //0F
- M( 1930, 1960, 95, 107, STR_201A_SHOPS_AND_OFFICES, 100, 48, 6, 2, 3,
+ MS(1930, 1960, 95, 107, STR_201A_SHOPS_AND_OFFICES, 100, 48, 6, 2, 3,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //10
- M( 1977, MAX_YEAR, 130, 200, STR_201B_MODERN_OFFICE_BUILDING, 150, 50, 10, 3, 6,
+ MS(1977, MAX_YEAR, 130, 200, STR_201B_MODERN_OFFICE_BUILDING, 150, 50, 10, 3, 6,
TILE_SIZE_1x1,
HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //11
- M( 1983, MAX_YEAR, 6, 145, STR_201C_WAREHOUSE, 110, 10, 6, 3, 8,
+ MS(1983, MAX_YEAR, 6, 145, STR_201C_WAREHOUSE, 110, 10, 6, 3, 8,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //12
- M( 1985, MAX_YEAR, 110, 155, STR_201D_OFFICE_BLOCK, 110, 55, 6, 2, 6,
+ MS(1985, MAX_YEAR, 110, 155, STR_201D_OFFICE_BLOCK, 110, 55, 6, 2, 6,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //13
- M( 0, MAX_YEAR, 65, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
+ MS( 0, MAX_YEAR, 65, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
BUILDING_IS_STADIUM | TILE_SIZE_2x2,
HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //14
- M( 0, MAX_YEAR, 0, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
+ MS( 0, MAX_YEAR, 0, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //15
- M( 0, MAX_YEAR, 0, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
+ MS( 0, MAX_YEAR, 0, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //16
- M( 0, MAX_YEAR, 0, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
+ MS( 0, MAX_YEAR, 0, 250, STR_201E_STADIUM, 300, 5, 4, 0, 0,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //17
- M( 0, 1951, 15, 70, STR_201F_OLD_HOUSES, 75, 6, 3, 1, 0,
+ MS( 0, 1951, 15, 70, STR_201F_OLD_HOUSES, 75, 6, 3, 1, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //18
- M( 0, 1952, 12, 75, STR_2036_COTTAGES, 75, 7, 3, 1, 0,
+ MS( 0, 1952, 12, 75, STR_2036_COTTAGES, 75, 7, 3, 1, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //19
- M( 1931, MAX_YEAR, 13, 71, STR_2037_HOUSES, 75, 8, 3, 1, 0,
+ MS(1931, MAX_YEAR, 13, 71, STR_2037_HOUSES, 75, 8, 3, 1, 0,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //1A
- M( 1935, MAX_YEAR, 100, 135, STR_2038_FLATS, 100, 35, 7, 2, 2,
+ MS(1935, MAX_YEAR, 100, 135, STR_2038_FLATS, 100, 35, 7, 2, 2,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //1B
- M( 1963, MAX_YEAR, 170, 145, STR_2039_TALL_OFFICE_BLOCK, 170, 50, 8, 3, 3,
+ MS(1963, MAX_YEAR, 170, 145, STR_2039_TALL_OFFICE_BLOCK, 170, 50, 8, 3, 3,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //1C
- M( 0, 1955, 100, 132, STR_203A_SHOPS_AND_OFFICES, 135, 40, 6, 2, 3,
+ MS( 0, 1955, 100, 132, STR_203A_SHOPS_AND_OFFICES, 135, 40, 6, 2, 3,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //1D
- M( 1973, MAX_YEAR, 180, 155, STR_203B_SHOPS_AND_OFFICES, 180, 64, 8, 3, 3,
+ MS(1973, MAX_YEAR, 180, 155, STR_203B_SHOPS_AND_OFFICES, 180, 64, 8, 3, 3,
TILE_SIZE_1x1,
HZ_TEMP | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //1E
- M( 0, MAX_YEAR, 35, 220, STR_203C_THEATER, 230, 23, 8, 2, 2,
+ MS( 0, MAX_YEAR, 35, 220, STR_203C_THEATER, 230, 23, 8, 2, 2,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //1F
- M( 1958, MAX_YEAR, 65, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
+ MS(1958, MAX_YEAR, 65, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
BUILDING_IS_STADIUM | TILE_SIZE_2x2,
HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //20
- M( 1958, MAX_YEAR, 0, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
+ MS(1958, MAX_YEAR, 0, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //21
- M( 1958, MAX_YEAR, 0, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
+ MS(1958, MAX_YEAR, 0, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //22
- M( 1958, MAX_YEAR, 0, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
+ MS(1958, MAX_YEAR, 0, 250, STR_203D_STADIUM, 300, 5, 4, 0, 0,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //23
- M( 2000, MAX_YEAR, 140, 170, STR_203E_OFFICES, 250, 65, 8, 3, 2,
+ MS(2000, MAX_YEAR, 140, 170, STR_203E_OFFICES, 250, 65, 8, 3, 2,
TILE_SIZE_1x1,
HZ_TEMP | HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //24
- M( 0, 1960, 15, 70, STR_203F_HOUSES, 75, 6, 3, 1, 1,
+ MS( 0, 1960, 15, 70, STR_203F_HOUSES, 75, 6, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //25
- M( 0, 1960, 15, 70, STR_203F_HOUSES, 75, 6, 3, 1, 1,
+ MS( 0, 1960, 15, 70, STR_203F_HOUSES, 75, 6, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //26
- M( 1945, MAX_YEAR, 35, 210, STR_2040_CINEMA, 230, 23, 8, 2, 2,
+ MS(1945, MAX_YEAR, 35, 210, STR_2040_CINEMA, 230, 23, 8, 2, 2,
TILE_SIZE_1x1,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //27
- M( 1983, MAX_YEAR, 180, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
+ MS(1983, MAX_YEAR, 180, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
TILE_SIZE_2x2,
HZ_TEMP | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 |HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //28
- M( 1983, MAX_YEAR, 0, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
+ MS(1983, MAX_YEAR, 0, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //29
- M( 1983, MAX_YEAR, 0, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
+ MS(1983, MAX_YEAR, 0, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //2A
- M( 1983, MAX_YEAR, 0, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
+ MS(1983, MAX_YEAR, 0, 250, STR_2041_SHOPPING_MALL, 300, 5, 8, 2, 3,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //2B
- M( 0, MAX_YEAR, 80, 100, STR_2038_FLATS, 90, 20, 5, 2, 2,
+ MS( 0, MAX_YEAR, 80, 100, STR_2038_FLATS, 90, 20, 5, 2, 2,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //2C
- M( 0, MAX_YEAR, 80, 100, STR_2038_FLATS, 90, 20, 5, 2, 2,
+ MS( 0, MAX_YEAR, 80, 100, STR_2038_FLATS, 90, 20, 5, 2, 2,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //2D
- M( 0, MAX_YEAR, 16, 70, STR_203F_HOUSES, 70, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 16, 70, STR_203F_HOUSES, 70, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //2E
- M( 0, MAX_YEAR, 16, 70, STR_203F_HOUSES, 70, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 16, 70, STR_203F_HOUSES, 70, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //2F
- M( 0, 1963, 14, 80, STR_203F_HOUSES, 70, 6, 3, 1, 2,
+ MS( 0, 1963, 14, 80, STR_203F_HOUSES, 70, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //30
- M( 0, 1963, 14, 80, STR_203F_HOUSES, 70, 6, 3, 1, 2,
+ MS( 0, 1963, 14, 80, STR_203F_HOUSES, 70, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //31
- M( 1966, MAX_YEAR, 135, 150, STR_200F_TALL_OFFICE_BLOCK, 120, 60, 8, 3, 4,
+ MS(1966, MAX_YEAR, 135, 150, STR_200F_TALL_OFFICE_BLOCK, 120, 60, 8, 3, 4,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //32
- M( 1966, MAX_YEAR, 135, 150, STR_200F_TALL_OFFICE_BLOCK, 120, 60, 8, 3, 4,
+ MS(1966, MAX_YEAR, 135, 150, STR_200F_TALL_OFFICE_BLOCK, 120, 60, 8, 3, 4,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //33
- M( 1970, MAX_YEAR, 170, 170, STR_200F_TALL_OFFICE_BLOCK, 130, 70, 9, 3, 4,
+ MS(1970, MAX_YEAR, 170, 170, STR_200F_TALL_OFFICE_BLOCK, 130, 70, 9, 3, 4,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //34
- M( 1970, MAX_YEAR, 170, 170, STR_200F_TALL_OFFICE_BLOCK, 130, 70, 9, 3, 4,
+ MS(1970, MAX_YEAR, 170, 170, STR_200F_TALL_OFFICE_BLOCK, 130, 70, 9, 3, 4,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //35
- M( 1974, MAX_YEAR, 210, 200, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 10, 3, 5,
+ MS(1974, MAX_YEAR, 210, 200, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 10, 3, 5,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //36
- M( 1974, MAX_YEAR, 210, 200, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 10, 3, 5,
+ MS(1974, MAX_YEAR, 210, 200, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 10, 3, 5,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //37
- M( 0, MAX_YEAR, 10, 60, STR_203F_HOUSES, 60, 5, 2, 1, 1,
+ MS( 0, MAX_YEAR, 10, 60, STR_203F_HOUSES, 60, 5, 2, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //38
- M( 0, MAX_YEAR, 10, 60, STR_203F_HOUSES, 60, 5, 2, 1, 1,
+ MS( 0, MAX_YEAR, 10, 60, STR_203F_HOUSES, 60, 5, 2, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //39
- M( 0, MAX_YEAR, 25, 100, STR_201A_SHOPS_AND_OFFICES, 80, 20, 3, 1, 1,
+ MS( 0, MAX_YEAR, 25, 100, STR_201A_SHOPS_AND_OFFICES, 80, 20, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //3A
- M( 0, MAX_YEAR, 25, 100, STR_201A_SHOPS_AND_OFFICES, 80, 20, 3, 1, 1,
+ MS( 0, MAX_YEAR, 25, 100, STR_201A_SHOPS_AND_OFFICES, 80, 20, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //3B
- M( 0, MAX_YEAR, 6, 85, STR_2012_CHURCH, 230, 2, 2, 0, 0,
+ MS( 0, MAX_YEAR, 6, 85, STR_2012_CHURCH, 230, 2, 2, 0, 0,
BUILDING_IS_CHURCH | TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //3C
- M( 0, MAX_YEAR, 6, 85, STR_2012_CHURCH, 230, 2, 2, 0, 0,
+ MS( 0, MAX_YEAR, 6, 85, STR_2012_CHURCH, 230, 2, 2, 0, 0,
BUILDING_IS_CHURCH | TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //3D
- M( 0, MAX_YEAR, 17, 80, STR_203F_HOUSES, 80, 7, 3, 1, 1,
+ MS( 0, MAX_YEAR, 17, 80, STR_203F_HOUSES, 80, 7, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //3E
- M( 0, MAX_YEAR, 17, 80, STR_203F_HOUSES, 80, 7, 3, 1, 1,
+ MS( 0, MAX_YEAR, 17, 80, STR_203F_HOUSES, 80, 7, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //3F
- M( 0, 1960, 90, 140, STR_201A_SHOPS_AND_OFFICES, 110, 45, 6, 2, 3,
+ MS( 0, 1960, 90, 140, STR_201A_SHOPS_AND_OFFICES, 110, 45, 6, 2, 3,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //40
- M( 0, 1960, 90, 140, STR_201A_SHOPS_AND_OFFICES, 110, 45, 6, 2, 3,
+ MS( 0, 1960, 90, 140, STR_201A_SHOPS_AND_OFFICES, 110, 45, 6, 2, 3,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //41
- M( 1972, MAX_YEAR, 140, 160, STR_2015_HOTEL, 160, 25, 6, 1, 3,
+ MS(1972, MAX_YEAR, 140, 160, STR_2015_HOTEL, 160, 25, 6, 1, 3,
TILE_SIZE_1x2,
HZ_SUBARTC_BELOW| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //42
- M( 1972, MAX_YEAR, 0, 160, STR_2015_HOTEL, 160, 25, 6, 1, 2,
+ MS(1972, MAX_YEAR, 0, 160, STR_2015_HOTEL, 160, 25, 6, 1, 2,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //43
- M( 1972, MAX_YEAR, 140, 160, STR_2015_HOTEL, 160, 25, 6, 1, 3,
+ MS(1972, MAX_YEAR, 140, 160, STR_2015_HOTEL, 160, 25, 6, 1, 3,
TILE_SIZE_1x2,
HZ_SUBARTC_ABOVE| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //44
- M( 1972, MAX_YEAR, 0, 160, STR_2015_HOTEL, 160, 25, 6, 1, 2,
+ MS(1972, MAX_YEAR, 0, 160, STR_2015_HOTEL, 160, 25, 6, 1, 2,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //45
- M( 1963, MAX_YEAR, 105, 130, STR_201A_SHOPS_AND_OFFICES, 105, 50, 7, 2, 3,
+ MS(1963, MAX_YEAR, 105, 130, STR_201A_SHOPS_AND_OFFICES, 105, 50, 7, 2, 3,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //46
- M( 1963, MAX_YEAR, 105, 130, STR_201A_SHOPS_AND_OFFICES, 105, 50, 7, 2, 3,
+ MS(1963, MAX_YEAR, 105, 130, STR_201A_SHOPS_AND_OFFICES, 105, 50, 7, 2, 3,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //47
- M( 1978, MAX_YEAR, 190, 190, STR_200F_TALL_OFFICE_BLOCK, 135, 75, 9, 3, 4,
+ MS(1978, MAX_YEAR, 190, 190, STR_200F_TALL_OFFICE_BLOCK, 135, 75, 9, 3, 4,
TILE_SIZE_1x1,
HZ_SUBARTC_BELOW | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //48
- M( 1978, MAX_YEAR, 190, 190, STR_200F_TALL_OFFICE_BLOCK, 135, 75, 9, 3, 4,
+ MS(1978, MAX_YEAR, 190, 190, STR_200F_TALL_OFFICE_BLOCK, 135, 75, 9, 3, 4,
TILE_SIZE_1x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //49
- M( 1967, MAX_YEAR, 250, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
+ MS(1967, MAX_YEAR, 250, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
TILE_SIZE_2x1,
HZ_SUBARTC_BELOW| HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //4A
- M( 1967, MAX_YEAR, 0, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
+ MS(1967, MAX_YEAR, 0, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //4B
- M( 1967, MAX_YEAR, 250, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
+ MS(1967, MAX_YEAR, 250, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
TILE_SIZE_2x1,
HZ_SUBARTC_ABOVE | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //4C
- M( 1967, MAX_YEAR, 0, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
+ MS(1967, MAX_YEAR, 0, 140, STR_200F_TALL_OFFICE_BLOCK, 200, 60, 7, 2, 2,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //4D
- M( 0, MAX_YEAR, 16, 80, STR_203F_HOUSES, 80, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 16, 80, STR_203F_HOUSES, 80, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //4E
- M( 0, MAX_YEAR, 16, 80, STR_203F_HOUSES, 80, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 16, 80, STR_203F_HOUSES, 80, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //4F
- M( 0, MAX_YEAR, 16, 80, STR_203F_HOUSES, 80, 5, 3, 1, 2,
+ MS( 0, MAX_YEAR, 16, 80, STR_203F_HOUSES, 80, 5, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //50
- M( 0, MAX_YEAR, 7, 30, STR_203F_HOUSES, 30, 4, 3, 1, 1,
+ MS( 0, MAX_YEAR, 7, 30, STR_203F_HOUSES, 30, 4, 3, 1, 1,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //51
- M( 0, MAX_YEAR, 45, 130, STR_2038_FLATS, 95, 15, 6, 2, 1,
+ MS( 0, MAX_YEAR, 45, 130, STR_2038_FLATS, 95, 15, 6, 2, 1,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //52
- M( 0, MAX_YEAR, 8, 90, STR_2012_CHURCH, 200, 3, 2, 0, 0,
+ MS( 0, MAX_YEAR, 8, 90, STR_2012_CHURCH, 200, 3, 2, 0, 0,
BUILDING_IS_CHURCH | TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //53
- M( 0, MAX_YEAR, 18, 80, STR_203F_HOUSES, 80, 7, 3, 1, 2,
+ MS( 0, MAX_YEAR, 18, 80, STR_203F_HOUSES, 80, 7, 3, 1, 2,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2,
CT_PASSENGERS, CT_MAIL, CT_FOOD), //54
- M( 1973, MAX_YEAR, 90, 110, STR_2038_FLATS, 95, 24, 6, 2, 1,
+ MS(1973, MAX_YEAR, 90, 110, STR_2038_FLATS, 95, 24, 6, 2, 1,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //55
- M( 1962, MAX_YEAR, 120, 120, STR_2038_FLATS, 95, 25, 6, 2, 1,
+ MS(1962, MAX_YEAR, 120, 120, STR_2038_FLATS, 95, 25, 6, 2, 1,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //56
- M( 1984, MAX_YEAR, 250, 190, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 8, 3, 4,
+ MS(1984, MAX_YEAR, 250, 190, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 8, 3, 4,
TILE_SIZE_2x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //57
- M( 1984, MAX_YEAR, 0, 190, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 8, 3, 4,
+ MS(1984, MAX_YEAR, 0, 190, STR_200F_TALL_OFFICE_BLOCK, 140, 80, 8, 3, 4,
TILE_NO_FLAG,
HZ_SUBTROPIC,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //58
- M( 0, MAX_YEAR, 80, 110, STR_2038_FLATS, 95, 23, 6, 2, 1,
+ MS( 0, MAX_YEAR, 80, 110, STR_2038_FLATS, 95, 23, 6, 2, 1,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //59
- M( 1993, MAX_YEAR, 180, 180, STR_200F_TALL_OFFICE_BLOCK, 150, 90, 8, 3, 4,
+ MS(1993, MAX_YEAR, 180, 180, STR_200F_TALL_OFFICE_BLOCK, 150, 90, 8, 3, 4,
TILE_SIZE_1x1,
HZ_SUBTROPIC | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_GOODS), //5A
- M( 0, MAX_YEAR, 8, 90, STR_2012_CHURCH, 200, 3, 2, 0, 0,
+ MS( 0, MAX_YEAR, 8, 90, STR_2012_CHURCH, 200, 3, 2, 0, 0,
BUILDING_IS_CHURCH | TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //5B
- M( 0, MAX_YEAR, 18, 90, STR_203F_HOUSES, 90, 5, 6, 2, 2,
+ MS( 0, MAX_YEAR, 18, 90, STR_203F_HOUSES, 90, 5, 6, 2, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //5C
- M( 0, MAX_YEAR, 7, 70, STR_203F_HOUSES, 50, 3, 3, 1, 1,
+ MS( 0, MAX_YEAR, 7, 70, STR_203F_HOUSES, 50, 3, 3, 1, 1,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //5D
- M( 0, MAX_YEAR, 15, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 15, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //5E
- M( 0, MAX_YEAR, 17, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 17, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //5F
- M( 0, MAX_YEAR, 19, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 19, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //60
- M( 0, MAX_YEAR, 21, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
+ MS( 0, MAX_YEAR, 21, 80, STR_203F_HOUSES, 75, 6, 3, 1, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //61
- M( 0, MAX_YEAR, 75, 160, STR_200F_TALL_OFFICE_BLOCK, 130, 20, 8, 4, 2,
+ MS( 0, MAX_YEAR, 75, 160, STR_200F_TALL_OFFICE_BLOCK, 130, 20, 8, 4, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //62
- M( 0, MAX_YEAR, 35, 90, STR_203F_HOUSES, 80, 9, 4, 1, 2,
+ MS( 0, MAX_YEAR, 35, 90, STR_203F_HOUSES, 80, 9, 4, 1, 2,
TILE_SIZE_1x2,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //63
- M( 0, MAX_YEAR, 0, 90, STR_203F_HOUSES, 80, 0, 4, 1, 2,
+ MS( 0, MAX_YEAR, 0, 90, STR_203F_HOUSES, 80, 0, 4, 1, 2,
TILE_NO_FLAG,
HZ_NOZNS,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //64
- M( 0, MAX_YEAR, 85, 150, STR_200F_TALL_OFFICE_BLOCK, 130, 18, 8, 4, 2,
+ MS( 0, MAX_YEAR, 85, 150, STR_200F_TALL_OFFICE_BLOCK, 130, 18, 8, 4, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //65
- M( 0, MAX_YEAR, 11, 60, STR_2059_IGLOO, 45, 3, 3, 1, 1,
+ MS( 0, MAX_YEAR, 11, 60, STR_2059_IGLOO, 45, 3, 3, 1, 1,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //66
- M( 0, MAX_YEAR, 10, 60, STR_205A_TEPEES, 45, 3, 3, 1, 1,
+ MS( 0, MAX_YEAR, 10, 60, STR_205A_TEPEES, 45, 3, 3, 1, 1,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //67
- M( 0, MAX_YEAR, 67, 140, STR_201A_SHOPS_AND_OFFICES, 130, 22, 8, 4, 4,
+ MS( 0, MAX_YEAR, 67, 140, STR_201A_SHOPS_AND_OFFICES, 130, 22, 8, 4, 4,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_FIZZY_DRINKS), //68
- M( 0, MAX_YEAR, 86, 145, STR_201A_SHOPS_AND_OFFICES, 130, 23, 8, 4, 4,
+ MS( 0, MAX_YEAR, 86, 145, STR_201A_SHOPS_AND_OFFICES, 130, 23, 8, 4, 4,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_FIZZY_DRINKS), //69
- M( 0, MAX_YEAR, 95, 165, STR_200F_TALL_OFFICE_BLOCK, 130, 28, 8, 4, 2,
+ MS( 0, MAX_YEAR, 95, 165, STR_200F_TALL_OFFICE_BLOCK, 130, 28, 8, 4, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //6A
- M( 0, MAX_YEAR, 30, 90, STR_2016_STATUE, 70, 10, 4, 1, 2,
+ MS( 0, MAX_YEAR, 30, 90, STR_2016_STATUE, 70, 10, 4, 1, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //6B
- M( 0, MAX_YEAR, 25, 75, STR_205B_TEAPOT_HOUSE, 65, 8, 3, 1, 2,
+ MS( 0, MAX_YEAR, 25, 75, STR_205B_TEAPOT_HOUSE, 65, 8, 3, 1, 2,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_CANDY), //6C
- M( 0, MAX_YEAR, 18, 85, STR_205C_PIGGY_BANK, 95, 7, 3, 2, 4,
+ MS( 0, MAX_YEAR, 18, 85, STR_205C_PIGGY_BANK, 95, 7, 3, 2, 4,
TILE_SIZE_1x1,
HZ_TOYLND | HZ_ZON5 | HZ_ZON4 | HZ_ZON3 | HZ_ZON2 | HZ_ZON1,
CT_PASSENGERS, CT_MAIL, CT_FIZZY_DRINKS), //6D
};
-#undef M
+#undef MS
+
+/** Make sure we have the right number of elements: one entry for each house */
assert_compile(lengthof(_original_house_specs) == NEW_HOUSE_OFFSET);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/tree_land.h
--- a/src/table/tree_land.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/tree_land.h Sat Jun 02 19:59:29 2007 +0000
@@ -25,7 +25,7 @@
{ { 3, 9 }, { 8, 2 }, { 9, 9 }, { 1, 5 } }
};
-static const PalSpriteID _tree_layout_sprite[164+(79-48+1)][4] = {
+static const PalSpriteID _tree_layout_sprite[164 + (79 - 48 + 1)][4] = {
{ { 0x652, PAL_NONE }, { 0x659, PAL_NONE }, { 0x660, PAL_NONE }, { 0x667, PAL_NONE } }, /* 0 */
{ { 0x652, PAL_NONE }, { 0x667, PAL_NONE }, { 0x66e, PAL_NONE }, { 0x675, PAL_NONE } }, /* 1 */
{ { 0x652, PAL_NONE }, { 0x66e, PAL_NONE }, { 0x659, PAL_NONE }, { 0x675, PAL_NONE } }, /* 2 */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/table/water_land.h
--- a/src/table/water_land.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/table/water_land.h Sat Jun 02 19:59:29 2007 +0000
@@ -47,86 +47,86 @@
};
static const WaterDrawTileStruct _shiplift_display_seq_0[] = {
- BEGIN(SPR_CANALS_BASE + 6),
- { 0, 0, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 0 + 1 },
- { 0, 0xF, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 4 + 1 },
+ BEGIN(1),
+ { 0, 0, 0, 0x10, 1, 0x14, 0 + 1 },
+ { 0, 0xF, 0, 0x10, 1, 0x14, 4 + 1 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_1[] = {
- BEGIN(SPR_CANALS_BASE + 5),
- { 0, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 0 },
- { 0xF, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 4 },
+ BEGIN(0),
+ { 0, 0, 0, 1, 0x10, 0x14, 0 },
+ { 0xF, 0, 0, 1, 0x10, 0x14, 4 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_2[] = {
- BEGIN(SPR_CANALS_BASE + 7),
- { 0, 0, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 0 + 2 },
- { 0, 0xF, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 4 + 2 },
+ BEGIN(2),
+ { 0, 0, 0, 0x10, 1, 0x14, 0 + 2 },
+ { 0, 0xF, 0, 0x10, 1, 0x14, 4 + 2 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_3[] = {
- BEGIN(SPR_CANALS_BASE + 8),
- { 0, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 0 + 3 },
- { 0xF, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 4 + 3 },
+ BEGIN(3),
+ { 0, 0, 0, 1, 0x10, 0x14, 0 + 3 },
+ { 0xF, 0, 0, 1, 0x10, 0x14, 4 + 3 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_0b[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 8 + 1 },
- { 0, 0xF, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 12 + 1 },
+ { 0, 0, 0, 0x10, 1, 0x14, 8 + 1 },
+ { 0, 0xF, 0, 0x10, 1, 0x14, 12 + 1 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_1b[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 0x1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 8 },
- { 0xF, 0, 0, 0x1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 12 },
+ { 0, 0, 0, 0x1, 0x10, 0x14, 8 },
+ { 0xF, 0, 0, 0x1, 0x10, 0x14, 12 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_2b[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 8 + 2 },
- { 0, 0xF, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 12 + 2 },
+ { 0, 0, 0, 0x10, 1, 0x14, 8 + 2 },
+ { 0, 0xF, 0, 0x10, 1, 0x14, 12 + 2 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_3b[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 8 + 3 },
- { 0xF, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 12 + 3 },
+ { 0, 0, 0, 1, 0x10, 0x14, 8 + 3 },
+ { 0xF, 0, 0, 1, 0x10, 0x14, 12 + 3 },
END(0)
};
static const WaterDrawTileStruct _shiplift_display_seq_0t[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 16 + 1 },
- { 0, 0xF, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 20 + 1 },
+ { 0, 0, 0, 0x10, 1, 0x14, 16 + 1 },
+ { 0, 0xF, 0, 0x10, 1, 0x14, 20 + 1 },
END(8)
};
static const WaterDrawTileStruct _shiplift_display_seq_1t[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 0x1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 16 },
- { 0xF, 0, 0, 0x1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 20 },
+ { 0, 0, 0, 0x1, 0x10, 0x14, 16 },
+ { 0xF, 0, 0, 0x1, 0x10, 0x14, 20 },
END(8)
};
static const WaterDrawTileStruct _shiplift_display_seq_2t[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 16 + 2 },
- { 0, 0xF, 0, 0x10, 1, 0x14, SPR_CANALS_BASE + 9 + 20 + 2 },
+ { 0, 0, 0, 0x10, 1, 0x14, 16 + 2 },
+ { 0, 0xF, 0, 0x10, 1, 0x14, 20 + 2 },
END(8)
};
static const WaterDrawTileStruct _shiplift_display_seq_3t[] = {
BEGIN(0xFDD),
- { 0, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 16 + 3 },
- { 0xF, 0, 0, 1, 0x10, 0x14, SPR_CANALS_BASE + 9 + 20 + 3 },
+ { 0, 0, 0, 1, 0x10, 0x14, 16 + 3 },
+ { 0xF, 0, 0, 1, 0x10, 0x14, 20 + 3 },
END(8)
};
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/terraform_gui.cpp
--- a/src/terraform_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/terraform_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file terraform_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "bridge_map.h"
@@ -91,34 +93,35 @@
/**
* 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)
{
TileIndex start_tile = e->we.place.starttile;
TileIndex end_tile = e->we.place.tile;
- switch (e->we.place.userdata >> 4) {
- case GUI_PlaceProc_DemolishArea >> 4:
- DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
- break;
- case GUI_PlaceProc_LevelArea >> 4:
- DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
- break;
- case GUI_PlaceProc_RockyArea >> 4:
- GenerateRockyArea(end_tile, start_tile);
- break;
- case GUI_PlaceProc_DesertArea >> 4:
- GenerateDesertArea(end_tile, start_tile);
- break;
- case GUI_PlaceProc_WaterArea >> 4:
- DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
- break;
- default: return false;
+ switch (e->we.place.select_proc) {
+ case DDSP_DEMOLISH_AREA:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_CLEAR_AREA | CMD_MSG(STR_00B5_CAN_T_CLEAR_THIS_AREA));
+ break;
+ case DDSP_LEVEL_AREA:
+ DoCommandP(end_tile, start_tile, 0, CcPlaySound10, CMD_LEVEL_LAND | CMD_AUTO);
+ break;
+ case DDSP_CREATE_ROCKS:
+ GenerateRockyArea(end_tile, start_tile);
+ break;
+ case DDSP_CREATE_DESERT:
+ GenerateDesertArea(end_tile, start_tile);
+ break;
+ case DDSP_CREATE_WATER:
+ DoCommandP(end_tile, start_tile, _ctrl_pressed, CcBuildCanal, CMD_BUILD_CANAL | CMD_AUTO | CMD_MSG(STR_CANT_BUILD_CANALS));
+ break;
+ default:
+ return false;
}
return true;
@@ -138,7 +141,7 @@
void PlaceProc_DemolishArea(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_DemolishArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_DEMOLISH_AREA);
}
static void PlaceProc_RaiseLand(TileIndex tile)
@@ -159,7 +162,7 @@
void PlaceProc_LevelLand(TileIndex tile)
{
- VpStartPlaceSizing(tile, VPM_X_AND_Y | GUI_PlaceProc_LevelArea);
+ VpStartPlaceSizing(tile, VPM_X_AND_Y, DDSP_LEVEL_AREA);
}
static void TerraformClick_Lower(Window *w)
@@ -237,13 +240,17 @@
return;
case WE_PLACE_DRAG:
- VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.userdata & 0xF);
+ VpSelectTilesWithMethod(e->we.place.pt.x, e->we.place.pt.y, e->we.place.select_method);
break;
case WE_PLACE_MOUSEUP:
- if (e->we.place.pt.x != -1 &&
- (e->we.place.userdata & 0xF) == VPM_X_AND_Y) { // dragged actions
- GUIPlaceProcDragXY(e);
+ if (e->we.place.pt.x != -1) {
+ switch (e->we.place.select_proc) {
+ case DDSP_DEMOLISH_AREA:
+ case DDSP_LEVEL_AREA:
+ GUIPlaceProcDragXY(e);
+ break;
+ }
}
break;
@@ -265,13 +272,13 @@
{ WWT_IMGBTN, RESIZE_NONE, 7, 70, 91, 14, 35, SPR_IMG_DYNAMITE, STR_018D_DEMOLISH_BUILDINGS_ETC},
{ WWT_IMGBTN, RESIZE_NONE, 7, 92, 113, 14, 35, SPR_IMG_BUY_LAND, STR_0329_PURCHASE_LAND_FOR_FUTURE},
{ WWT_IMGBTN, RESIZE_NONE, 7, 114, 135, 14, 35, SPR_IMG_PLANTTREES, STR_0185_PLANT_TREES_PLACE_SIGNS},
-{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_PLACE_SIGN, STR_0289_PLACE_SIGN},
+{ WWT_IMGBTN, RESIZE_NONE, 7, 136, 157, 14, 35, SPR_IMG_SIGN, STR_0289_PLACE_SIGN},
{ WIDGETS_END},
};
static const WindowDesc _terraform_desc = {
- WDP_ALIGN_TBR, 22+36, 158, 36,
+ WDP_ALIGN_TBR, 22 + 36, 158, 36,
WC_SCEN_LAND_GEN, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON,
_terraform_widgets,
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/texteff.cpp
--- a/src/texteff.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/texteff.cpp Sat Jun 02 19:59:29 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;
@@ -243,7 +246,7 @@
/* Paint the messages starting with the lowest at the bottom */
for (uint y = 13; count-- != 0; y += 13) {
DoDrawString(_textmsg_list[count].message, _textmsg_box.x + 3, _screen.height - _textmsg_box.y - y + 1, _textmsg_list[count].color);
- }
+ }
/* Make sure the data is updated next flush */
_video_driver->make_dirty(x, y, width, height);
@@ -324,7 +327,7 @@
const TextEffect* te;
switch (dpi->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
if (te->string_id != INVALID_STRING_ID &&
dpi->left <= te->right &&
@@ -336,7 +339,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
for (te = _text_effect_list; te != endof(_text_effect_list); te++) {
if (te->string_id != INVALID_STRING_ID &&
dpi->left <= te->right * 2 - te->x &&
@@ -347,6 +350,13 @@
}
}
break;
+
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tgp.cpp
--- a/src/tgp.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tgp.cpp Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/tgp.h
--- a/src/tgp.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tgp.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tgp.h */
+
#ifndef TGP_H
#define TGP_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/thread.cpp
--- a/src/thread.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/thread.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,11 +1,13 @@
/* $Id$ */
+/** @file thread.cpp */
+
#include "stdafx.h"
#include "thread.h"
#include
#include "helpers.hpp"
-#if defined(__AMIGA__) || defined(__MORPHOS__) || defined(PSP) || defined(NO_THREADS)
+#if defined(__AMIGA__) || defined(PSP) || defined(NO_THREADS)
OTTDThread *OTTDCreateThread(OTTDThreadFunc function, void *arg) { return NULL; }
void *OTTDJoinThread(OTTDThread *t) { return NULL; }
void OTTDExitThread() { NOT_REACHED(); };
@@ -63,7 +65,7 @@
_endthread();
}
-#elif defined(UNIX)
+#elif defined(UNIX) && !defined(MORPHOS)
#include
@@ -155,4 +157,157 @@
{
ExitThread(0);
}
+
+
+#elif defined(MORPHOS)
+
+#include
+#include
+#include
+
+#include
+#include
+
+#include
+
+/* NOTE: this code heavily depends on latest libnix updates. So make
+ * sure you link with new stuff which supports semaphore locking of
+ * the IO resources, else it will just go foobar. */
+
+struct OTTDThreadStartupMessage {
+ struct Message msg; ///< standard exec.library message (MUST be the first thing in the message struct!)
+ OTTDThreadFunc func; ///< function the thread will execute
+ void *arg; ///< functions arguments for the thread function
+ void *ret; ///< return value of the thread function
+ jmp_buf jumpstore; ///< storage for the setjump state
+};
+
+struct OTTDThread {
+ struct MsgPort *replyport;
+ struct OTTDThreadStartupMessage msg;
+};
+
+
+/**
+ * Default OpenTTD STDIO/ERR debug output is not very useful for this, so we
+ * utilize serial/ramdebug instead.
+ */
+#ifndef NO_DEBUG_MESSAGES
+void KPutStr(CONST_STRPTR format)
+{
+ RawDoFmt(format, NULL, (void (*)())RAWFMTFUNC_SERIAL, NULL);
+}
+#else
+#define KPutStr(x)
#endif
+
+static void Proxy(void)
+{
+ struct Task *child = FindTask(NULL);
+ struct OTTDThreadStartupMessage *msg;
+
+ /* Make sure, we don't block the parent. */
+ SetTaskPri(child, -5);
+
+ KPutStr("[Child] Progressing...\n");
+
+ if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) {
+ /* Make use of setjmp() here, so this point can be reached again from inside
+ * OTTDExitThread() which can be called from anythere inside msg->func.
+ * It's a bit ugly and in worst case it leaks some memory. */
+ if (setjmp(msg->jumpstore) == 0) {
+ msg->ret = msg->func(msg->arg);
+ } else {
+ KPutStr("[Child] Returned to main()\n");
+ }
+ }
+
+ /* Quit the child, exec.library will reply the startup msg internally. */
+ KPutStr("[Child] Done.\n");
+}
+
+OTTDThread* OTTDCreateThread(OTTDThreadFunc function, void *arg)
+{
+ OTTDThread *t;
+ struct Task *parent;
+
+ KPutStr("[OpenTTD] Create thread...\n");
+
+ t = (struct OTTDThread *)AllocVecTaskPooled(sizeof(struct OTTDThread));
+ if (t == NULL) return NULL;
+
+ parent = FindTask(NULL);
+
+ /* Make sure main thread runs with sane priority */
+ SetTaskPri(parent, 0);
+
+ /* Things we'll pass down to the child by utilizing NP_StartupMsg */
+ t->msg.func = function;
+ t->msg.arg = arg;
+ t->msg.ret = NULL;
+
+ t->replyport = CreateMsgPort();
+
+ if (t->replyport != NULL) {
+ struct Process *child;
+
+ t->msg.msg.mn_Node.ln_Type = NT_MESSAGE;
+ t->msg.msg.mn_ReplyPort = t->replyport;
+ t->msg.msg.mn_Length = sizeof(struct OTTDThreadStartupMessage);
+
+ child = CreateNewProcTags(
+ NP_CodeType, CODETYPE_PPC,
+ NP_Entry, Proxy,
+ NP_StartupMsg, (ULONG)&t->msg,
+ NP_Priority, 5UL,
+ NP_Name, (ULONG)"OpenTTD Thread",
+ NP_PPCStackSize, 131072UL,
+ TAG_DONE);
+
+ if (child != NULL) {
+ KPutStr("[OpenTTD] Child process launched.\n");
+ return t;
+ }
+ DeleteMsgPort(t->replyport);
+ }
+ FreeVecTaskPooled(t);
+
+ return NULL;
+}
+
+void* OTTDJoinThread(OTTDThread *t)
+{
+ struct OTTDThreadStartupMessage *reply;
+ void *ret;
+
+ KPutStr("[OpenTTD] Join threads...\n");
+
+ if (t == NULL) return NULL;
+
+ KPutStr("[OpenTTD] Wait for child to quit...\n");
+ WaitPort(t->replyport);
+
+ reply = (struct OTTDThreadStartupMessage *)GetMsg(t->replyport);
+ ret = reply->ret;
+
+ DeleteMsgPort(t->replyport);
+ FreeVecTaskPooled(t);
+
+ return ret;
+}
+
+void OTTDExitThread()
+{
+ struct OTTDThreadStartupMessage *msg;
+
+ KPutStr("[Child] Aborting...\n");
+
+ if (NewGetTaskAttrs(NULL, &msg, sizeof(struct OTTDThreadStartupMessage *), TASKINFOTYPE_STARTUPMSG, TAG_DONE) && msg != NULL) {
+ KPutStr("[Child] Jumping back...\n");
+ longjmp(msg->jumpstore, 0xBEAFCAFE);
+ }
+
+ NOT_REACHED();
+}
+
+#endif
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/thread.h
--- a/src/thread.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/thread.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file thread.h */
+
#ifndef THREAD_H
#define THREAD_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tile.cpp
--- a/src/tile.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tile.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tile.cpp */
+
#include "stdafx.h"
#include "tile.h"
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tile.h
--- a/src/tile.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tile.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tile.h */
+
#ifndef TILE_H
#define TILE_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/town.h
--- a/src/town.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/town.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file town.h */
+
#ifndef TOWN_H
#define TOWN_H
@@ -76,34 +78,34 @@
struct Town {
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;
@@ -113,36 +115,39 @@
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.
+ /* If this is a larger town, and should grow more quickly. */
+ bool larger_town;
+
+ /* 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;
};
@@ -159,10 +164,10 @@
CargoID accepts_cargo[3]; ///< 3 input cargo slots
BuildingFlags building_flags; ///< some flags that describe the house (size, stadium etc...)
HouseZones building_availability; ///< where can it be built (climates, zones)
- bool enabled; ///< the house is still avaible (by default, true.newgrf can disable it, though)
+ bool enabled; ///< the house is available to build (true by default, but can be disabled by newgrf)
/* NewHouses properties */
- HouseID substitute_id; ///< which house this one is based on
+ HouseID substitute_id; ///< which original house this one is based on
struct SpriteGroup *spritegroup; ///< pointer to the different sprites of the house
HouseID override; ///< which house this one replaces
uint16 callback_mask; ///< House callback flags
@@ -173,12 +178,19 @@
byte animation_frames; ///< number of animation frames
byte animation_speed; ///< amount of time between each of those frames
byte processing_time; ///< Periodic refresh multiplier
+ byte minimum_life; ///< The minimum number of years this house will survive before the town rebuilds it
/* grf file related properties*/
uint8 local_id; ///< id defined by the grf file for this house
const struct GRFFile *grffile; ///< grf file that introduced this house
};
+enum TownSizeMode {
+ TSM_RANDOM,
+ TSM_FIXED,
+ TSM_CITY
+};
+
VARDEF HouseSpec _house_specs[HOUSE_MAX];
uint32 GetWorldPopulation();
@@ -187,7 +199,7 @@
void InitializeTown();
void ShowTownViewWindow(TownID town);
void ExpandTown(Town *t);
-Town *CreateRandomTown(uint attempts, uint size_mode);
+Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size);
enum {
ROAD_REMOVE = 0,
@@ -197,8 +209,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,
@@ -207,11 +219,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,
@@ -232,25 +244,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);
@@ -267,12 +279,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 index to inquiry in the pool of town
+ * @return true if it exists
+ */
static inline bool IsValidTownID(TownID index)
{
return index < GetTownPoolSize() && IsValidTown(GetTown(index));
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/town_cmd.cpp
--- a/src/town_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/town_cmd.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -38,6 +38,7 @@
#include "newgrf.h"
#include "newgrf_callbacks.h"
#include "newgrf_house.h"
+#include "newgrf_commons.h"
/**
* Called if a new block is added to the town-pool
@@ -54,6 +55,11 @@
/* Initialize the town-pool */
DEFINE_OLD_POOL(Town, Town, TownPoolNewBlock, NULL)
+/**
+ * Removes a specific town as well as all industries
+ * under its "juridiction"
+ * @param t Town to remove
+ */
void DestroyTown(Town *t)
{
Industry *i;
@@ -120,6 +126,11 @@
return variant;
}
+/**
+ * House Tile drawing handler.
+ * Part of the tile loop process
+ * @param ti TileInfo of the tile to draw
+ */
static void DrawTile_Town(TileInfo *ti)
{
const DrawBuildingsTileStruct *dcts;
@@ -151,7 +162,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 {
@@ -167,7 +178,7 @@
ti->z
);
- if (_display_opt & DO_TRANS_BUILDINGS) return;
+ if (HASBIT(_transparent_opt, TO_HOUSES)) return;
}
{
@@ -187,6 +198,12 @@
return SLOPE_FLAT;
}
+/**
+ * Animate a tile for a town
+ * Only certain houses can be animated
+ * The newhouses animation superseeds regular ones
+ * @param tile TileIndex of the house to animate
+ */
static void AnimateTile_Town(TileIndex tile)
{
int pos, dest;
@@ -198,10 +215,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;
@@ -210,7 +227,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) */
@@ -233,6 +250,12 @@
static void UpdateTownRadius(Town *t);
+/**
+ * Determines if a town is close to a tile
+ * @param tile TileIndex of the tile to query
+ * @param dist maximum distance to be accepted
+ * @returns true if the tile correspond to the distance criteria
+ */
static bool IsCloseToTown(TileIndex tile, uint dist)
{
const Town* t;
@@ -243,16 +266,25 @@
return false;
}
+/**
+ * Marks the town sign as needing a repaint
+ * @param t Town requesting repaint
+ */
static void MarkTownSignDirty(Town *t)
{
MarkAllViewportsDirty(
- t->sign.left-6,
- t->sign.top-3,
- t->sign.left+t->sign.width_1*4+12,
+ t->sign.left - 6,
+ t->sign.top - 3,
+ t->sign.left + t->sign.width_1 * 4 + 12,
t->sign.top + 45
);
}
+/**
+ * Resize the sign(label) of the town after changes in
+ * population (creation or growth or else)
+ * @param t Town to update
+ */
void UpdateTownVirtCoord(Town *t)
{
Point pt;
@@ -266,6 +298,11 @@
MarkTownSignDirty(t);
}
+/**
+ * Change the towns population
+ * @param t Town which polulation has changed
+ * @param mod polulation change (can be positive or negative)
+ */
static void ChangePopulation(Town *t, int mod)
{
t->population += mod;
@@ -275,6 +312,11 @@
if (_town_sort_order & 2) _town_sort_dirty = true;
}
+/**
+ * Determines the world population
+ * Basically, count population of all towns, one by one
+ * @return uint32 the calculated population of the world
+ */
uint32 GetWorldPopulation()
{
uint32 pop;
@@ -285,17 +327,24 @@
return pop;
}
+/**
+ * Helper function for house completion stages progression
+ * @param tile TileIndex of the house (or parts of it) to "grow"
+ */
static void MakeSingleHouseBigger(TileIndex tile)
{
assert(IsTileType(tile, MP_HOUSE));
+ /* means it is completed, get out. */
if (LiftHasDestination(tile)) return;
+ /* progress in construction stages */
IncHouseConstructionTick(tile);
if (GetHouseConstructionTick(tile) != 0) return;
+ /* Check and/or */
if (HASBIT(GetHouseSpecs(GetHouseType(tile))->callback_mask, CBM_CONSTRUCTION_STATE_CHANGE)) {
- uint16 callback_res = GetHouseCallback(CBID_CONSTRUCTION_STATE_CHANGE, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ uint16 callback_res = GetHouseCallback(CBID_CONSTRUCTION_STATE_CHANGE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
if (callback_res != CALLBACK_FAILED) ChangeHouseAnimationFrame(tile, callback_res);
}
@@ -307,6 +356,9 @@
MarkTileDirtyByTile(tile);
}
+/** Make the house advances in its construction stages until completion
+ * @param tile TileIndex of house
+ */
static void MakeTownHouseBigger(TileIndex tile)
{
uint flags = GetHouseSpecs(GetHouseType(tile))->building_flags;
@@ -316,6 +368,10 @@
if (flags & BUILDING_HAS_4_TILES) MakeSingleHouseBigger(TILE_ADDXY(tile, 1, 1));
}
+/**
+ * Periodic tic handler for houses and town
+ * @param tile been asked to do its stuff
+ */
static void TileLoop_Town(TileIndex tile)
{
Town *t;
@@ -328,52 +384,95 @@
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;
}
/* If the lift has a destination, it is already an animated tile. */
- if ((hs->building_flags & BUILDING_IS_ANIMATED) && house_id < NEW_HOUSE_OFFSET && !LiftHasDestination(tile) && CHANCE16(1, 2)) AddAnimatedTile(tile);
+ if ((hs->building_flags & BUILDING_IS_ANIMATED) &&
+ house_id < NEW_HOUSE_OFFSET &&
+ !LiftHasDestination(tile) &&
+ CHANCE16(1, 2))
+ AddAnimatedTile(tile);
t = GetTownByTile(tile);
r = Random();
- if (GB(r, 0, 8) < hs->population) {
- uint amt = GB(r, 0, 8) / 8 + 1;
- uint moved;
-
- if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
- t->new_max_pass += amt;
- moved = MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt);
- t->new_act_pass += moved;
- }
-
- if (GB(r, 8, 8) < hs->mail_generation) {
- uint amt = GB(r, 8, 8) / 8 + 1;
- uint moved;
-
- if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
- t->new_max_mail += amt;
- moved = MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt);
- t->new_act_mail += moved;
+ if (HASBIT(hs->callback_mask, CBM_HOUSE_PRODUCE_CARGO)) {
+ for (uint i = 0; i < 256; i++) {
+ uint16 callback = GetHouseCallback(CBID_HOUSE_PRODUCE_CARGO, i, r, house_id, t, tile);
+
+ if (callback == CALLBACK_FAILED) break;
+ if (callback == 0x20FF) break;
+
+ CargoID cargo = GetCargoTranslation(GB(callback, 8, 7), hs->grffile);
+ if (cargo == CT_INVALID) continue;
+
+ uint amt = GB(callback, 0, 8);
+ uint moved = MoveGoodsToStation(tile, 1, 1, cargo, amt);
+
+ const CargoSpec *cs = GetCargo(cargo);
+ switch (cs->town_effect) {
+ case TE_PASSENGERS:
+ t->new_max_pass += amt;
+ t->new_act_pass += moved;
+ break;
+
+ case TE_MAIL:
+ t->new_max_mail += amt;
+ t->new_act_mail += moved;
+ break;
+
+ default:
+ break;
+ }
+ }
+ } else {
+ if (GB(r, 0, 8) < hs->population) {
+ uint amt = GB(r, 0, 8) / 8 + 1;
+ uint moved;
+
+ if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
+ t->new_max_pass += amt;
+ moved = MoveGoodsToStation(tile, 1, 1, CT_PASSENGERS, amt);
+ t->new_act_pass += moved;
+ }
+
+ if (GB(r, 8, 8) < hs->mail_generation) {
+ uint amt = GB(r, 8, 8) / 8 + 1;
+ uint moved;
+
+ if (_economy.fluct <= 0) amt = (amt + 1) >> 1;
+ t->new_max_mail += amt;
+ moved = MoveGoodsToStation(tile, 1, 1, CT_MAIL, amt);
+ t->new_act_mail += moved;
+ }
}
_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;
+ if (hs->building_flags & BUILDING_HAS_1_TILE &&
+ HASBIT(t->flags12, TOWN_IS_FUNDED) &&
+ CanDeleteHouse(tile) &&
+ max(_cur_year - GetHouseConstructionYear(tile), 0) >= hs->minimum_life &&
+ --t->time_until_rebuild == 0) {
+ 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);
}
_current_player = OWNER_NONE;
}
+/**
+ * Unused handler
+ * @param tile unused
+ */
static void ClickTile_Town(TileIndex tile)
{
/* not used */
@@ -413,8 +512,44 @@
static void GetAcceptedCargo_Town(TileIndex tile, AcceptedCargo ac)
{
HouseSpec *hs = GetHouseSpecs(GetHouseType(tile));
-
- for (uint8 i = 0; i < 3; i++) ac[hs->accepts_cargo[i]] = hs->cargo_acceptance[i];
+ CargoID accepts[3];
+
+ /* Set the initial accepted cargo types */
+ for (uint8 i = 0; i < lengthof(accepts); i++) {
+ accepts[i] = hs->accepts_cargo[i];
+ }
+
+ /* Check for custom accepted cargo types */
+ if (HASBIT(hs->callback_mask, CBM_HOUSE_ACCEPT_CARGO)) {
+ uint16 callback = GetHouseCallback(CBID_HOUSE_ACCEPT_CARGO, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ if (callback != CALLBACK_FAILED) {
+ /* Replace accepted cargo types with translated values from callback */
+ accepts[0] = GetCargoTranslation(GB(callback, 0, 5), hs->grffile);
+ accepts[1] = GetCargoTranslation(GB(callback, 5, 5), hs->grffile);
+ accepts[2] = GetCargoTranslation(GB(callback, 10, 5), hs->grffile);
+ }
+ }
+
+ /* Check for custom cargo acceptance */
+ if (HASBIT(hs->callback_mask, CBM_CARGO_ACCEPTANCE)) {
+ uint16 callback = GetHouseCallback(CBID_HOUSE_CARGO_ACCEPTANCE, 0, 0, GetHouseType(tile), GetTownByTile(tile), tile);
+ if (callback != CALLBACK_FAILED) {
+ if (accepts[0] != CT_INVALID) ac[accepts[0]] = GB(callback, 0, 4);
+ if (accepts[1] != CT_INVALID) ac[accepts[1]] = GB(callback, 4, 4);
+ if (_opt.landscape != LT_TEMPERATE && HASBIT(callback, 12)) {
+ /* The 'S' bit indicates food instead of goods */
+ ac[CT_FOOD] = GB(callback, 8, 4);
+ } else {
+ if (accepts[2] != CT_INVALID) ac[accepts[2]] = GB(callback, 8, 4);
+ }
+ return;
+ }
+ }
+
+ /* No custom acceptance, so fill in with the default values */
+ for (uint8 i = 0; i < lengthof(accepts); i++) {
+ if (accepts[i] != CT_INVALID) ac[accepts[i]] = hs->cargo_acceptance[i];
+ }
}
static void GetTileDesc_Town(TileIndex tile, TileDesc *td)
@@ -428,7 +563,7 @@
td->owner = OWNER_TOWN;
}
-static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Town(TileIndex tile, TransportType mode, uint sub_mode)
{
/* not used */
return 0;
@@ -446,13 +581,21 @@
{ 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}
};
+/**
+ * Distance multiplyer
+ * Defines the possible distances between 2 road tiles
+ */
+enum RoadBlockTitleDistance {
+ RB_TILE_DIST1 = 1, ///< 1 tile between
+ RB_TILE_DIST2, ///< 2 tiles between
+};
static bool GrowTown(Town *t);
@@ -493,7 +636,7 @@
static RoadBits GetTownRoadMask(TileIndex tile)
{
- TrackBits b = GetAnyRoadTrackBits(tile);
+ TrackBits b = GetAnyRoadTrackBits(tile, ROADTYPE_ROAD);
RoadBits r = ROAD_NONE;
if (b & TRACK_BIT_X) r |= ROAD_X;
@@ -505,21 +648,38 @@
return r;
}
+/**
+ * Check if a neighboring tile has a road
+ *
+ * @param tile curent tile
+ * @param dir target direction
+ * @param dist_multi distance multiplyer
+ * @return true if one of the neighboring tiles at the
+ * given distance is a road tile else
+ */
+static bool NeighborIsRoadTile(TileIndex tile, int dir, RoadBlockTitleDistance dist_multi)
+{
+ return (HASBIT(GetTownRoadMask(TILE_ADD(tile, dist_multi * ToTileIndexDiff(_roadblock_tileadd[dir + 1]))), dir ^ 2) ||
+ HASBIT(GetTownRoadMask(TILE_ADD(tile, dist_multi * ToTileIndexDiff(_roadblock_tileadd[dir + 3]))), dir ^ 2) ||
+ HASBIT(GetTownRoadMask(TILE_ADD(tile, dist_multi * (ToTileIndexDiff(_roadblock_tileadd[dir + 1]) + ToTileIndexDiff(_roadblock_tileadd[dir + 2])))), dir) ||
+ HASBIT(GetTownRoadMask(TILE_ADD(tile, dist_multi * (ToTileIndexDiff(_roadblock_tileadd[dir + 3]) + ToTileIndexDiff(_roadblock_tileadd[dir + 2])))), dir));
+}
+
static bool IsRoadAllowedHere(TileIndex tile, int dir)
{
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?
- 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.
+ /* Check if there already is a road at this point? */
+ if (GetAnyRoadTrackBits(tile, ROADTYPE_ROAD) == 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. */
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;
@@ -528,20 +688,21 @@
slope = GetTileSlope(tile, NULL);
if (slope == SLOPE_FLAT) {
no_slope:
- // 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
- return true;
+ /* Tile has no slope */
+ switch (_patches.town_layout) {
+ default: NOT_REACHED();
+
+ case TL_ORIGINAL: /* Disallow the road if any neighboring tile has a road (distance: 1) */
+ return !NeighborIsRoadTile(tile, dir, RB_TILE_DIST1);
+
+ case TL_BETTER_ROADS: /* Disallow the road if any neighboring tile has a road (distance: 1 and 2). */
+ return !(NeighborIsRoadTile(tile, dir, RB_TILE_DIST1) ||
+ NeighborIsRoadTile(tile, dir, RB_TILE_DIST2));
+ }
}
- // 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();
@@ -557,7 +718,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;
}
}
@@ -585,17 +746,138 @@
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);
}
}
+/**
+ * Generate the RoadBits of a grid tile
+ *
+ * @param t current town
+ * @param tile tile in reference to the town
+ * @return the RoadBit of the current tile regarding
+ * the selected town layout
+ */
+static RoadBits GetTownRoadGridElement(Town* t, TileIndex tile)
+{
+ /* align the grid to the downtown */
+ TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile); ///< Vector from downtown to the tile
+
+ /* lx, ly description:
+ * @li lx and ly are true if the tile is a crossing tile.
+ * @li lx xor ly are true if the tile is a straight road tile.
+ * @li lx and ly are false if the tile is a house tile.
+ */
+ bool lx, ly;
+
+ switch (_patches.town_layout) {
+ default: NOT_REACHED();
+
+ case TL_2X2_GRID:
+ lx = ((grid_pos.x % 3) == 0);
+ ly = ((grid_pos.y % 3) == 0);
+ break;
+
+ case TL_3X3_GRID:
+ lx = ((grid_pos.x % 4) == 0);
+ ly = ((grid_pos.y % 4) == 0);
+ break;
+ }
+
+ /* generate the basic grid structure */
+ if (!lx && !ly) { ///< It is a house tile
+ return ROAD_NONE;
+ } else if (lx && !ly) { ///< It is a Y-dir road tile
+ return ROAD_Y;
+ } else if (!lx && ly) { ///< It is a X-dir road tile
+ return ROAD_X;
+ } else { ///< It is a crossing tile
+ /* Presets for junctions on slopes
+ * not nice :( */
+ switch (GetTileSlope(tile, NULL)) {
+ case SLOPE_W:
+ return ROAD_NW | ROAD_SW;
+ case SLOPE_S:
+ return ROAD_SE | ROAD_SW;
+ case SLOPE_SW:
+ return ROAD_Y | ROAD_SW;
+ case SLOPE_E:
+ return ROAD_NE | ROAD_SE;
+ case SLOPE_SE:
+ return ROAD_X | ROAD_SE;
+ case SLOPE_N:
+ return ROAD_NW | ROAD_NE;
+ case SLOPE_NW:
+ return ROAD_X | ROAD_NW;
+ case SLOPE_NE:
+ return ROAD_Y | ROAD_NE;
+ case SLOPE_STEEP_W:
+ case SLOPE_STEEP_N:
+ return ROAD_X;
+ case SLOPE_STEEP_S:
+ case SLOPE_STEEP_E:
+ return ROAD_Y;
+ default:
+ return ROAD_ALL;
+ }
+ }
+}
+
+/**
+ * Check there are enougth neighbor house tiles next to the current tile
+ *
+ * @param tile current tile
+ * @return true if there are more than 2 house tiles next
+ * to the current one
+ */
+static bool NeighborsAreHouseTiles(TileIndex tile)
+{
+ uint counter = 0; ///< counts the house neighbor tiles
+
+ /* We can't look further than that. */
+ if (TileX(tile) < 1 || TileY(tile) < 1) {
+ return false;
+ }
+
+ /* Check the tiles E,N,W and S of the current tile. */
+ for (uint i = 0; i < 4; i++) {
+ if (IsTileType(TILE_ADD(tile, ToTileIndexDiff(_roadblock_tileadd[i])), MP_HOUSE)) {
+ counter++;
+ }
+
+ /* If there are enougth neighbor's stop it here */
+ if (counter >= 3) {
+ return true;
+ }
+ }
+ return false;
+}
+
+/**
+ * Grows the given town.
+ * There are at the moment 3 possible way's for
+ * the town expansion:
+ * @li Generate a random tile and check if there is a road allowed
+ * @li TL_ORIGINAL
+ * @li TL_BETTER_ROADS
+ * @li Check if the town geometry allows a road and which one
+ * @li TL_2X2_GRID
+ * @li TL_3X3_GRID
+ * @li Forbid roads, only build houses
+ * @li TL_NO_ROADS
+ *
+ * @param tile_ptr current tile
+ * @param mask current tiles RoadBits
+ * @param block road block
+ * @param t1 current town
+ */
static void GrowTownInTile(TileIndex* tile_ptr, RoadBits mask, int block, Town* t1)
{
RoadBits rcmd;
@@ -610,49 +892,91 @@
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?
- if (!IsRoadAllowedHere(tile, block)) return;
-
- // Randomize new road block numbers
- a = block;
- b = block ^ 2;
- if (CHANCE16(1, 4)) {
- do {
- a = GB(Random(), 0, 2);
- } while (a == b);
+ /* Is a road allowed here? */
+ switch (_patches.town_layout) {
+ default: NOT_REACHED();
+
+ case TL_NO_ROADS: /* Disallow Roads */
+ return;
+
+ case TL_3X3_GRID:
+ case TL_2X2_GRID:
+ rcmd = GetTownRoadGridElement(t1, tile);
+ if (rcmd == ROAD_NONE) {
+ return;
+ }
+ break;
+
+ case TL_BETTER_ROADS:
+ case TL_ORIGINAL:
+ if (!IsRoadAllowedHere(tile, block)) {
+ return;
+ }
+
+ /* Randomize new road block numbers */
+ a = block;
+ b = block ^ 2;
+ if (CHANCE16(1, 4)) {
+ do {
+ a = GB(Random(), 0, 2);
+ } while (a == b);
+ }
+
+ 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. */
+ if (a != (b ^ 2)) {
+ return;
+ }
+
+ /* 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. */
+ }
+
+ rcmd = (RoadBits)((1 << a) + (1 << b));
+ break;
}
- 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.
- if (a != (b ^ 2)) return;
-
- // 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))
+ } else if (block < 5 && !HASBIT(mask, block ^ 2)) {
+ /* Continue building on a partial road.
+ * Always OK. */
+ _grow_town_result = 0;
+
+ switch (_patches.town_layout) {
+ default: NOT_REACHED();
+
+ case TL_NO_ROADS: /* Disallow Roads */
return;
- // That means that the road is only allowed if there is a house
- // at any side of the new road.
+ case TL_3X3_GRID:
+ case TL_2X2_GRID:
+ rcmd = GetTownRoadGridElement(t1, tile);
+ break;
+
+ case TL_BETTER_ROADS:
+ case TL_ORIGINAL:
+ rcmd = (RoadBits)(1 << (block ^ 2));
+ break;
}
- rcmd = (RoadBits)((1 << a) + (1 << b));
-
- } else if (block < 5 && !HASBIT(mask,block^2)) {
- // 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.
+ bool allow_house = false;
+ TileIndex tmptile2;
+
+ /* 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);
@@ -662,28 +986,62 @@
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.
- if (!IsRoadAllowedHere(tmptile, i) || CHANCE16(6, 10)) {
- // But not if there already is a house there.
+ switch (_patches.town_layout) {
+ default: NOT_REACHED();
+
+ case TL_NO_ROADS:
+ allow_house = true;
+ break;
+
+ case TL_3X3_GRID: /* Use 2x2 grid afterwards! */
+ /* Fill gap if house has enougth neighbors */
+ tmptile2 = TILE_ADD(tmptile, ToTileIndexDiff(_roadblock_tileadd[i]));
+ if (NeighborsAreHouseTiles(tmptile2) && BuildTownHouse(t1, tmptile2)) {
+ _grow_town_result = -1;
+ }
+
+ case TL_2X2_GRID:
+ rcmd = GetTownRoadGridElement(t1, tmptile);
+ allow_house = (rcmd == ROAD_NONE);
+ break;
+
+ case TL_BETTER_ROADS: /* Use original afterwards! */
+ /* Fill gap if house has enougth neighbors */
+ tmptile2 = TILE_ADD(tmptile, ToTileIndexDiff(_roadblock_tileadd[i]));
+ if (NeighborsAreHouseTiles(tmptile2) && BuildTownHouse(t1, tmptile2)) {
+ _grow_town_result = -1;
+ }
+
+ case TL_ORIGINAL:
+ /* Allow a house at the edge. 60% chance or
+ * always ok if no road allowed. */
+ allow_house = (!IsRoadAllowedHere(tmptile, i) || CHANCE16(6, 10));
+ break;
+ }
+
+
+ if (allow_house) {
+ /* Build a house, 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.
- if (BuildTownHouse(t1, tmptile)) _grow_town_result = -1;
+ /* And build a house.
+ * Set result to -1 if we managed to build it. */
+ if (BuildTownHouse(t1, tmptile)) {
+ _grow_town_result = -1;
+ }
}
return;
}
@@ -692,11 +1050,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;
@@ -711,9 +1069,15 @@
return;
}
+ /* Check if the bridge is in the right direction */
+ if ((rcmd == ROAD_X && (i == DIAGDIR_NW || i == DIAGDIR_SE)) ||
+ (rcmd == ROAD_Y && (i == DIAGDIR_NE || i == DIAGDIR_SW))) {
+ goto build_road_and_exit;
+ }
+
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)
@@ -721,11 +1085,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);
@@ -735,39 +1099,58 @@
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.
- _grow_town_result = 10 + t->num_houses * 4 / 9;
+ /* Number of times to search.
+ * Better roads, 2X2 and 3X3 grid grow quite fast so we give
+ * them a little handicap. */
+ switch (_patches.town_layout) {
+ case TL_BETTER_ROADS:
+ _grow_town_result = 10 + t->num_houses * 2 / 9;
+ break;
+
+ case TL_3X3_GRID:
+ case TL_2X2_GRID:
+ _grow_town_result = 10 + t->num_houses * 1 / 9;
+ break;
+
+ default:
+ _grow_town_result = 10 + t->num_houses * 4 / 9;
+ break;
+ }
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);
-
- // Exclude the source position from the bitmask
- // and return if no more road blocks available
+ /* 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 */
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.
- do block = Random() & 3; while (!HASBIT(mask,block));
+ /* 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]);
if (IsTileType(tile, MP_STREET)) {
@@ -782,15 +1165,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();
@@ -800,8 +1183,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;
@@ -824,14 +1207,21 @@
{ 0, 0}
};
- // Current player is a town
+ /* Let the town be a ghost town
+ * The player wanted it in such a way. Thus there he has it. ;)
+ * Never reached in editor mode. */
+ if (_patches.town_layout == TL_NO_ROADS && _generating_world) {
+ return false;
+ }
+
+ /* 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) {
+ if (GetAnyRoadTrackBits(tile, ROADTYPE_ROAD) != 0) {
int r = GrowTownAtRoad(t, tile);
_current_player = old_player;
return r != 0;
@@ -839,13 +1229,13 @@
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 */
if (!IsTileType(tile, MP_HOUSE) && GetTileSlope(tile, NULL) == SLOPE_FLAT) {
- if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO, CMD_LANDSCAPE_CLEAR))) {
+ if (!CmdFailed(DoCommand(tile, 0, 0, DC_AUTO | DC_NO_WATER, CMD_LANDSCAPE_CLEAR))) {
DoCommand(tile, GenRandomRoadBits(), t->index, DC_EXEC | DC_AUTO, CMD_BUILD_ROAD);
_current_player = old_player;
return true;
@@ -890,11 +1280,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;
@@ -926,12 +1316,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) {
@@ -950,11 +1340,20 @@
t->max_mail = t->population >> 4;
}
-static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, uint size_mode)
+/**
+ * Does the actual town creation.
+ *
+ * @param t The town
+ * @param tile Where to put it
+ * @param townnameparts The town name
+ * @param size_mode How the size should be determined
+ * @param size Parameter for size determination
+ */
+static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSizeMode size_mode, uint size)
{
int x, i;
- // clear the town struct
+ /* clear the town struct */
i = t->index;
memset(t, 0, sizeof(Town));
t->index = i;
@@ -999,10 +1398,25 @@
UpdateTownVirtCoord(t);
_town_sort_dirty = true;
- if (size_mode == 0) {
- x = (Random() & 0xF) + 8;
- } else {
- x = (size_mode - 1) * 16 + 3;
+ /* Random town size. */
+ x = (Random() & 0xF) + 8;
+
+ switch (size_mode) {
+ default: NOT_REACHED();
+
+ case TSM_RANDOM:
+ t->larger_town = false;
+ break;
+
+ case TSM_FIXED:
+ x = size * 16 + 3;
+ t->larger_town = false;
+ break;
+
+ case TSM_CITY:
+ x *= _patches.initial_city_size;
+ t->larger_town = true;
+ break;
}
t->num_houses += x;
@@ -1046,8 +1460,9 @@
* 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 p1 size of the town (0 = random, 1 = small, 2 = medium, 3 = large)
- * @param p2 unused
+ * @param flags type of operation
+ * @param p1 size of the town (0 = small, 1 = medium, 2 = large)
+ * @param p2 size mode (@see TownSizeMode)
*/
int32 CmdBuildTown(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
@@ -1056,86 +1471,90 @@
/* Only in the scenario editor */
if (_game_mode != GM_EDITOR) return CMD_ERROR;
+ if (p2 > TSM_CITY) return CMD_ERROR;
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);
+ DoCreateTown(t, tile, townnameparts, (TownSizeMode)p2, p1);
_generating_world = false;
}
return 0;
}
-Town *CreateRandomTown(uint attempts, uint size_mode)
+Town *CreateRandomTown(uint attempts, TownSizeMode mode, uint size)
{
TileIndex tile;
Town *t;
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;
- DoCreateTown(t, tile, townnameparts, size_mode);
+ DoCreateTown(t, tile, townnameparts, mode, size);
return t;
} while (--attempts);
return NULL;
}
-static const byte _num_initial_towns[3] = {11, 23, 46};
+static const byte _num_initial_towns[4] = {5, 11, 23, 46};
bool GenerateTowns()
{
uint num = 0;
uint n = ScaleByMapSize(_num_initial_towns[_opt.diff.number_towns] + (Random() & 7));
+ uint num_cities = _patches.larger_towns == 0 ? 0 : n / _patches.larger_towns;
SetGeneratingWorldProgress(GWP_TOWN, n);
do {
IncreaseGeneratingWorldProgress(GWP_TOWN);
- // try 20 times to create a random-sized town for the first loop.
- if (CreateRandomTown(20, 0) != NULL) num++;
+ /* try 20 times to create a random-sized town for the first loop. */
+ TownSizeMode mode = num_cities > 0 ? TSM_CITY : TSM_RANDOM;
+ if (CreateRandomTown(20, mode, _patches.initial_city_size) != NULL) num++;
+ if (num_cities > 0) num_cities--;
} while (--n);
- // give it a last try, but now more aggressive
- if (num == 0 && CreateRandomTown(10000, 0) == NULL) {
+ /* give it a last try, but now more aggressive */
+ if (num == 0 && CreateRandomTown(10000, TSM_RANDOM, 0) == NULL) {
if (GetNumTowns() == 0) {
/* XXX - can we handle that more gracefully? */
if (_game_mode != GM_EDITOR) error("Could not generate any town");
@@ -1223,10 +1642,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 = GetTownRadiusGroup(t, tile);
@@ -1236,20 +1655,20 @@
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) {
- if (_have_newhouses) {
+ if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) {
probability_max += hs->probability;
cumulative_probs[num] = probability_max;
}
@@ -1258,7 +1677,7 @@
}
for (;;) {
- if (_have_newhouses) {
+ if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) {
uint r = RandomRange(probability_max);
for (i = 0; i < num; i++) if (cumulative_probs[i] >= r) break;
@@ -1269,20 +1688,20 @@
hs = GetHouseSpecs(house);
- if (_have_newhouses) {
+ if (HASBIT(_loaded_newgrf_features, GRFLOADED_NEWHOUSES)) {
if (hs->override != 0) hs = GetHouseSpecs(hs->override);
if ((hs->extra_flags & BUILDING_IS_HISTORICAL) && !_generating_world) continue;
if (HASBIT(hs->callback_mask, CBM_HOUSE_ALLOW_CONSTRUCTION)) {
- uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, house, t, tile);
+ uint16 callback_res = GetHouseCallback(CBID_HOUSE_ALLOW_CONSTRUCTION, 0, 0, house, t, tile);
if (callback_res != CALLBACK_FAILED && callback_res == 0) continue;
}
}
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) {
@@ -1293,7 +1712,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) {
@@ -1327,7 +1746,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;
{
@@ -1379,7 +1798,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--;
@@ -1398,7 +1817,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);
}
@@ -1406,14 +1825,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));
@@ -1423,6 +1842,7 @@
/** Rename a town (server-only).
* @param tile unused
+ * @param flags type of operation
* @param p1 town ID to rename
* @param p2 unused
*/
@@ -1452,7 +1872,7 @@
return 0;
}
-// Called from GUI
+/** Called from GUI */
void ExpandTown(Town *t)
{
int amount, n;
@@ -1537,6 +1957,7 @@
/**
* Search callback function for TownActionBuildStatue
+ * @param tile on which to perform the search
* @param town_id The town_id for which we want a statue
* @return the result of the test
*/
@@ -1555,16 +1976,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;
}
@@ -1581,18 +2002,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!
@@ -1625,6 +2046,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
*/
@@ -1655,10 +2077,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;
@@ -1680,22 +2102,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) {
@@ -1706,6 +2127,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 (t->larger_town) m /= 2;
+
t->growth_rate = m / (t->num_houses / 50 + 1);
if (m <= t->grow_counter)
t->grow_counter = m;
@@ -1715,7 +2143,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;
@@ -1723,7 +2151,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;
@@ -1780,7 +2208,7 @@
{
if (IsTileType(tile, MP_HOUSE) || (
IsTileType(tile, MP_STREET) &&
- (IsLevelCrossing(tile) ? GetCrossingRoadOwner(tile) : GetTileOwner(tile)) == OWNER_TOWN
+ GetRoadOwner(tile, ROADTYPE_ROAD) == OWNER_TOWN
)) {
return GetTownByTile(tile);
} else {
@@ -1793,7 +2221,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)) {
@@ -1820,17 +2248,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;
@@ -1900,7 +2328,7 @@
};
-// Save and load of towns.
+/** Save and load of towns. */
static const SaveLoad _town_desc[] = {
SLE_CONDVAR(Town, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Town, xy, SLE_UINT32, 6, SL_MAX_VERSION),
@@ -1916,12 +2344,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),
@@ -1950,15 +2378,23 @@
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)
+
+ SLE_CONDVAR(Town, larger_town, SLE_BOOL, 56, SL_MAX_VERSION),
+
+ /* reserve extra space in savegame here. (currently 30 bytes) */
SLE_CONDNULL(30, 2, SL_MAX_VERSION),
SLE_END()
@@ -1967,19 +2403,19 @@
/* Save and load the mapping between the house id on the map, and the grf file
* it came from. */
static const SaveLoad _house_id_mapping_desc[] = {
- SLE_VAR(HouseIDMapping, grfid, SLE_UINT32),
- SLE_VAR(HouseIDMapping, house_id, SLE_UINT8),
- SLE_VAR(HouseIDMapping, substitute_id, SLE_UINT8),
+ SLE_VAR(EntityIDMapping, grfid, SLE_UINT32),
+ SLE_VAR(EntityIDMapping, entity_id, SLE_UINT8),
+ SLE_VAR(EntityIDMapping, substitute_id, SLE_UINT8),
SLE_END()
};
static void Save_HOUSEIDS()
{
- uint i;
-
- for (i = 0; i != lengthof(_house_id_mapping); i++) {
+ uint j = _house_mngr.GetMaxMapping();
+
+ for (uint i = 0; i < j; i++) {
SlSetArrayIndex(i);
- SlObject(&_house_id_mapping[i], _house_id_mapping_desc);
+ SlObject(&_house_mngr.mapping_ID[i], _house_id_mapping_desc);
}
}
@@ -1987,11 +2423,12 @@
{
int index;
- ResetHouseIDMapping();
+ _house_mngr.ResetMapping();
+ uint max_id = _house_mngr.GetMaxMapping();
while ((index = SlIterateArray()) != -1) {
- if ((uint)index >= lengthof(_house_id_mapping)) break;
- SlObject(&_house_id_mapping[index], _house_id_mapping_desc);
+ if ((uint)index >= max_id) break;
+ SlObject(&_house_mngr.mapping_ID[index], _house_id_mapping_desc);
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/town_gui.cpp
--- a/src/town_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/town_gui.cpp Sat Jun 02 19:59:29 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 + _price.station_value * 200;
ref = _price.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);
@@ -347,7 +349,7 @@
if (w != NULL) {
w->flags4 |= WF_DISABLE_VP_SCROLL;
- AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, 1);
+ AssignWindowViewport(w, 3, 17, 0xFE, 0x56, GetTown(town)->xy, ZOOM_LVL_TOWN);
}
}
@@ -365,7 +367,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 5a8b295aa345 -r 4cc327ad39d5 src/town_map.h
--- a/src/town_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/town_map.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/train.h
--- a/src/train.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/train.h Sat Jun 02 19:59:29 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
};
@@ -29,6 +31,7 @@
*/
static inline bool IsFrontEngine(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return HASBIT(v->subtype, Train_Front);
}
@@ -37,6 +40,7 @@
*/
static inline void SetFrontEngine(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
SETBIT(v->subtype, Train_Front);
}
@@ -45,6 +49,7 @@
*/
static inline void ClearFrontEngine(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
CLRBIT(v->subtype, Train_Front);
}
@@ -54,6 +59,7 @@
*/
static inline bool IsArticulatedPart(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return HASBIT(v->subtype, Train_Articulated_Part);
}
@@ -62,6 +68,7 @@
*/
static inline void SetArticulatedPart(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
SETBIT(v->subtype, Train_Articulated_Part);
}
@@ -70,6 +77,7 @@
*/
static inline void ClearArticulatedPart(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
CLRBIT(v->subtype, Train_Articulated_Part);
}
@@ -79,6 +87,7 @@
*/
static inline bool IsTrainWagon(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return HASBIT(v->subtype, Train_Wagon);
}
@@ -87,6 +96,7 @@
*/
static inline void SetTrainWagon(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
SETBIT(v->subtype, Train_Wagon);
}
@@ -95,6 +105,7 @@
*/
static inline void ClearTrainWagon(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
CLRBIT(v->subtype, Train_Wagon);
}
@@ -104,6 +115,7 @@
*/
static inline bool IsTrainEngine(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return HASBIT(v->subtype, Train_Engine);
}
@@ -112,6 +124,7 @@
*/
static inline void SetTrainEngine(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
SETBIT(v->subtype, Train_Engine);
}
@@ -120,6 +133,7 @@
*/
static inline void ClearTrainEngine(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
CLRBIT(v->subtype, Train_Engine);
}
@@ -129,6 +143,7 @@
*/
static inline bool IsFreeWagon(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return HASBIT(v->subtype, Train_Free_Wagon);
}
@@ -137,6 +152,7 @@
*/
static inline void SetFreeWagon(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
SETBIT(v->subtype, Train_Free_Wagon);
}
@@ -145,6 +161,7 @@
*/
static inline void ClearFreeWagon(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
CLRBIT(v->subtype, Train_Free_Wagon);
}
@@ -154,6 +171,7 @@
*/
static inline bool IsMultiheaded(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return HASBIT(v->subtype, Train_Multiheaded);
}
@@ -162,6 +180,7 @@
*/
static inline void SetMultiheaded(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
SETBIT(v->subtype, Train_Multiheaded);
}
@@ -170,6 +189,7 @@
*/
static inline void ClearMultiheaded(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
CLRBIT(v->subtype, Train_Multiheaded);
}
@@ -179,6 +199,7 @@
*/
static inline bool EngineHasArticPart(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
return (v->next != NULL && IsArticulatedPart(v->next));
}
@@ -199,6 +220,7 @@
*/
static inline Vehicle *GetLastEnginePart(Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
while (EngineHasArticPart(v)) v = GetNextArticPart(v);
return v;
}
@@ -209,6 +231,7 @@
*/
static inline Vehicle *GetNextVehicle(const Vehicle *v)
{
+ assert(v->type == VEH_TRAIN);
while (EngineHasArticPart(v)) v = GetNextArticPart(v);
/* v now contains the last artic part in the engine */
@@ -226,4 +249,29 @@
byte FreightWagonMult(CargoID cargo);
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ * v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct Train : public Vehicle {
+ /** Initializes the Vehicle to a train */
+ Train() { this->type = VEH_TRAIN; }
+
+ /** We want to 'destruct' the right class. */
+ virtual ~Train() {}
+
+ const char *GetTypeString() const { return "train"; }
+ void MarkDirty();
+ void UpdateDeltaXY(Direction direction);
+ ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
+ WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
+ void PlayLeaveStationSound() const;
+ bool IsPrimaryVehicle() const { return IsFrontEngine(this); }
+ bool HasFront() const { return true; }
+};
+
#endif /* TRAIN_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/train_cmd.cpp
--- a/src/train_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/train_cmd.cpp Sat Jun 02 19:59:29 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"
@@ -12,6 +15,7 @@
#include "tile.h"
#include "tunnel_map.h"
#include "vehicle.h"
+#include "articulated_vehicles.h"
#include "command.h"
#include "pathfind.h"
#include "npf.h"
@@ -34,6 +38,7 @@
#include "yapf/yapf.h"
#include "date.h"
#include "cargotype.h"
+#include "group.h"
static bool TrainCheckIfLineEnds(Vehicle *v);
static void TrainController(Vehicle *v, bool update_image);
@@ -60,7 +65,7 @@
*/
void TrainPowerChanged(Vehicle* v)
{
- uint32 power = 0;
+ uint32 total_power = 0;
uint32 max_te = 0;
for (const Vehicle *u = v; u != NULL; u = u->next) {
@@ -73,19 +78,22 @@
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
- if (engine_has_power && rvi_u->power != 0) {
- power += rvi_u->power;
- /* Tractive effort in (tonnes * 1000 * 10 =) N */
- max_te += (u->u.rail.cached_veh_weight * 10000 * rvi_u->tractive_effort) / 256;
+ if (engine_has_power) {
+ uint16 power = GetVehicleProperty(u, 0x0B, rvi_u->power);
+ if (power != 0) {
+ total_power += power;
+ /* Tractive effort in (tonnes * 1000 * 10 =) N */
+ max_te += (u->u.rail.cached_veh_weight * 10000 * GetVehicleProperty(u, 0x1F, rvi_u->tractive_effort)) / 256;
+ }
}
if (HASBIT(u->u.rail.flags, VRF_POWEREDWAGON) && (wagon_has_power)) {
- power += RailVehInfo(u->u.rail.first_engine)->pow_wag_power;
+ total_power += RailVehInfo(u->u.rail.first_engine)->pow_wag_power;
}
}
- if (v->u.rail.cached_power != power || v->u.rail.cached_max_te != max_te) {
- v->u.rail.cached_power = power;
+ if (v->u.rail.cached_power != total_power || v->u.rail.cached_max_te != max_te) {
+ v->u.rail.cached_power = total_power;
v->u.rail.cached_max_te = max_te;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
@@ -105,24 +113,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
- vweight += RailVehInfo(u->engine_type)->weight;
-
- // powered wagons have extra weight added
+ /* vehicle weight is the sum of the weight of the vehicle and the weight of its cargo */
+ vweight += GetVehicleProperty(u, 0x16, RailVehInfo(u->engine_type)->weight);
+
+ /* 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,26 +159,29 @@
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;
if (IsTrainEngine(u)) first_engine = u->engine_type;
+ /* Cache wagon override sprite group. NULL is returned if there is none */
+ u->u.rail.cached_override = GetWagonOverrideSpriteSet(u->engine_type, u->cargo_type, u->u.rail.first_engine);
+
if (rvi_u->visual_effect != 0) {
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;
}
}
@@ -184,7 +195,7 @@
}
if (rvi_v->pow_wag_power != 0 && rvi_u->railveh_type == RAILVEH_WAGON &&
- UsesWagonOverride(u) && (u->u.rail.cached_vis_effect < 0x40)) {
+ UsesWagonOverride(u) && !HASBIT(u->u.rail.cached_vis_effect, 7)) {
/* wagon is powered */
SETBIT(u->u.rail.flags, VRF_POWEREDWAGON); // cache 'powered' status
} else {
@@ -204,13 +215,19 @@
u->u.rail.compatible_railtypes |= (1 << RAILTYPE_RAIL);
}
- // 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);
+ /* 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) && !UsesWagonOverride(u)) {
+ uint16 speed = GetVehicleProperty(u, 0x09, rvi_u->max_speed);
+ if (speed != 0) max_speed = min(speed, max_speed);
+ }
}
- // check the vehicle length (callback)
+ if (u->cargo_type == rvi_u->cargo_type && u->cargo_subtype == 0) {
+ /* Set cargo capacity if we've not been refitted */
+ u->cargo_cap = GetVehicleProperty(u, 0x14, rvi_u->capacity);
+ }
+
+ /* 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 +238,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 +280,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 +295,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 +326,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 +419,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);
}
@@ -485,82 +502,12 @@
DrawSprite(image, pal, x, y);
}
-uint CountArticulatedParts(EngineID engine_type)
-{
- if (!HASBIT(EngInfo(engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return 0;
-
- uint i;
- for (i = 1; i < 10; i++) {
- uint16 callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, engine_type, NULL);
- if (callback == CALLBACK_FAILED || callback == 0xFF) break;
- }
-
- return i - 1;
-}
-
-static void AddArticulatedParts(Vehicle **vl)
-{
- const Vehicle *v = vl[0];
- Vehicle *u = vl[0];
-
- if (!HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_ARTIC_ENGINE)) return;
-
- for (uint i = 1; i < 10; i++) {
- uint16 callback = GetVehicleCallback(CBID_TRAIN_ARTIC_ENGINE, i, 0, v->engine_type, v);
- if (callback == CALLBACK_FAILED || callback == 0xFF) return;
-
- /* Attempt to use pre-allocated vehicles until they run out. This can happen
- * if the callback returns different values depending on the cargo type. */
- u->next = vl[i];
- if (u->next == NULL) u->next = AllocateVehicle();
- if (u->next == NULL) return;
-
- u = u->next;
-
- EngineID engine_type = GB(callback, 0, 7);
- bool flip_image = HASBIT(callback, 7);
- const RailVehicleInfo *rvi_artic = RailVehInfo(engine_type);
-
- // get common values from first engine
- u->direction = v->direction;
- u->owner = v->owner;
- u->tile = v->tile;
- u->x_pos = v->x_pos;
- u->y_pos = v->y_pos;
- u->z_pos = v->z_pos;
- u->z_height = v->z_height;
- u->u.rail.track = v->u.rail.track;
- u->u.rail.railtype = v->u.rail.railtype;
- u->build_year = v->build_year;
- u->vehstatus = v->vehstatus & ~VS_STOPPED;
- u->u.rail.first_engine = v->engine_type;
-
- // 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;
- u->cargo_subtype = 0;
- u->cargo_cap = rvi_artic->capacity;
- u->max_speed = 0;
- u->max_age = 0;
- u->engine_type = engine_type;
- u->value = 0;
- u->type = VEH_TRAIN;
- u->subtype = 0;
- SetArticulatedPart(u);
- u->cur_image = 0xAC2;
- u->random_bits = VehicleRandomBits();
-
- VehiclePositionChanged(u);
- }
-}
-
static int32 CmdBuildRailWagon(EngineID engine, TileIndex tile, uint32 flags)
{
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
const RailVehicleInfo *rvi = RailVehInfo(engine);
- int32 value = (rvi->base_cost * _price.build_railwagon) >> 8;
+ int32 value = (GetEngineProperty(engine, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8;
uint num_vehicles = 1 + CountArticulatedParts(engine);
@@ -601,12 +548,13 @@
v->y_pos = y;
v->z_pos = GetSlopeZ(x, y);
v->owner = _current_player;
- v->z_height = 6;
v->u.rail.track = TRACK_BIT_DEPOT;
v->vehstatus = VS_HIDDEN | VS_DEFPAL;
+ v = new (v) Train();
v->subtype = 0;
SetTrainWagon(v);
+
if (u != NULL) {
u->next = v;
} else {
@@ -623,16 +571,18 @@
v->u.rail.railtype = rvi->railtype;
v->build_year = _cur_year;
- v->type = VEH_TRAIN;
v->cur_image = 0xAC2;
v->random_bits = VehicleRandomBits();
+ v->group_id = DEFAULT_GROUP;
+
AddArticulatedParts(vl);
_new_vehicle_id = v->index;
VehiclePositionChanged(v);
TrainConsistChanged(GetFirstVehicleInChain(v));
+ UpdateTrainGroupID(GetFirstVehicleInChain(v));
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
if (IsLocalPlayer()) {
@@ -645,7 +595,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;
@@ -661,9 +611,9 @@
}
}
-static int32 EstimateTrainCost(const RailVehicleInfo* rvi)
+static int32 EstimateTrainCost(EngineID engine, const RailVehicleInfo* rvi)
{
- return rvi->base_cost * (_price.build_railvehicle >> 3) >> 5;
+ return GetEngineProperty(engine, 0x17, rvi->base_cost) * (_price.build_railvehicle >> 3) >> 5;
}
static void AddRearEngineToMultiheadedTrain(Vehicle* v, Vehicle* u, bool building)
@@ -674,9 +624,9 @@
u->x_pos = v->x_pos;
u->y_pos = v->y_pos;
u->z_pos = v->z_pos;
- u->z_height = 6;
u->u.rail.track = TRACK_BIT_DEPOT;
u->vehstatus = v->vehstatus & ~VS_STOPPED;
+ u = new (u) Train();
u->subtype = 0;
SetMultiheaded(u);
u->spritenum = v->spritenum + 1;
@@ -689,7 +639,6 @@
u->build_year = v->build_year;
if (building) v->value >>= 1;
u->value = v->value;
- u->type = VEH_TRAIN;
u->cur_image = 0xAC2;
u->random_bits = VehicleRandomBits();
VehiclePositionChanged(u);
@@ -697,6 +646,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 +654,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 */
@@ -723,7 +673,7 @@
if (rvi->railveh_type == RAILVEH_WAGON) return CmdBuildRailWagon(p1, tile, flags);
- int32 value = EstimateTrainCost(rvi);
+ int32 value = EstimateTrainCost(p1, rvi);
uint num_vehicles =
(rvi->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1) +
@@ -755,7 +705,6 @@
v->x_pos = x;
v->y_pos = y;
v->z_pos = GetSlopeZ(x, y);
- v->z_height = 6;
v->u.rail.track = TRACK_BIT_DEPOT;
v->vehstatus = VS_HIDDEN | VS_STOPPED | VS_DEFPAL;
v->spritenum = rvi->image_index;
@@ -781,13 +730,15 @@
v->service_interval = _patches.servint_trains;
v->date_of_last_service = _date;
v->build_year = _cur_year;
- v->type = VEH_TRAIN;
+ v = new (v) Train();
v->cur_image = 0xAC2;
v->random_bits = VehicleRandomBits();
v->vehicle_flags = 0;
if (e->flags & ENGINE_EXCLUSIVE_PREVIEW) SETBIT(v->vehicle_flags, VF_BUILT_AS_PROTOTYPE);
+ v->group_id = DEFAULT_GROUP;
+
v->subtype = 0;
SetFrontEngine(v);
SetTrainEngine(v);
@@ -809,6 +760,7 @@
TrainConsistChanged(v);
UpdateTrainAcceleration(v);
+ UpdateTrainGroupID(v);
if (!HASBIT(p2, 1)) { // check if the cars should be added to the new vehicle
NormalizeTrainVehInDepot(v);
@@ -874,7 +826,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;
@@ -887,6 +839,7 @@
Vehicle *u;
for (u = first; GetNextVehicle(u) != v; u = GetNextVehicle(u)) {}
GetLastEnginePart(u)->next = GetNextVehicle(v);
+ v->first = NULL; // we shouldn't point to the old first, since the vehicle isn't in that chain anymore
return first;
}
@@ -898,7 +851,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 +903,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 +920,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 +930,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,92 +945,59 @@
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;
}
- if (dst != NULL && IsMultiheaded(dst) && !IsTrainEngine(dst) && IsTrainWagon(src)) {
- /* We are moving a wagon to the rear part of a multiheaded engine */
- if (dst->next == NULL) {
- /* It's the last one, so we will add the wagon just before the rear engine */
- 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 == NULL) return CMD_ERROR;
- } else {
- /* there are more units on this train, so we will add the wagon after the next one*/
- dst = dst->next;
- }
- }
-
- if (IsTrainEngine(src) && dst_head != NULL) {
- /* we need to make sure that we didn't place it between a pair of multiheaded engines */
- Vehicle *engine = NULL;
-
- for (Vehicle *u = dst_head; u != NULL; u = u->next) {
- if (IsTrainEngine(u) && IsMultiheaded(u) && u->u.rail.other_multiheaded_part != NULL) {
- engine = u;
- }
- if (engine != NULL && engine->u.rail.other_multiheaded_part == u) {
- engine = NULL;
- }
- if (u == dst) {
- if (engine != NULL) dst = engine->u.rail.other_multiheaded_part;
- break;
- }
- }
- }
-
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)
@@ -1103,8 +1024,18 @@
for (Vehicle *u = src_head; u != NULL; u = u->next) u->first = NULL;
for (Vehicle *u = dst_head; u != NULL; u = u->next) u->first = NULL;
+ /* If we move the front Engine and if the second vehicle is not an engine
+ add the whole vehicle to the DEFAULT_GROUP */
+ if (IsFrontEngine(src) && !IsDefaultGroupID(src->group_id)) {
+ const Vehicle *v = GetNextVehicle(src);
+
+ if (v != NULL && !IsTrainEngine(v)) {
+ DoCommand(tile, DEFAULT_GROUP, v->index, flags, CMD_ADD_VEHICLE_GROUP);
+ }
+ }
+
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 +1045,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,13 +1056,21 @@
/* 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;
+
+ // Decrease the engines number of the src engine_type
+ if (!IsDefaultGroupID(src->group_id) && IsValidGroupID(src->group_id)) {
+ GetGroup(src->group_id)->num_engines[src->engine_type]--;
+ }
+
+ // If we move an engine to a new line affect it to the DEFAULT_GROUP
+ src->group_id = DEFAULT_GROUP;
}
} else {
SetFreeWagon(src);
@@ -1139,7 +1078,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 +1090,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,41 +1104,26 @@
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;
}
- if (HASBIT(p2, 0) && src_head != NULL && src_head != src) {
- /* if we stole a rear multiheaded engine, we better give it back to the front end */
- Vehicle *engine = NULL, *u;
- for (u = src_head; u != NULL; u = u->next) {
- if (IsMultiheaded(u)) {
- if (IsTrainEngine(u)) {
- engine = u;
- continue;
- }
- /* we got the rear engine to match with the front one */
- engine = NULL;
- }
- }
- 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
- engine->u.rail.other_multiheaded_part->first = NULL;
- }
- }
-
/* If there is an engine behind first_engine we moved away, it should become new first_engine
* To do this, CmdMoveRailVehicle must be called once more
* we can't loop forever here because next time we reach this line we will have a front engine */
if (src_head != NULL && !IsFrontEngine(src_head) && IsTrainEngine(src_head)) {
+ /* As in CmdMoveRailVehicle src_head->group_id will be equal to DEFAULT_GROUP
+ * we need to save the group and reaffect it to src_head */
+ const GroupID tmp_g = src_head->group_id;
CmdMoveRailVehicle(0, flags, src_head->index | (INVALID_VEHICLE << 16), 1);
+ SetTrainGroupID(src_head, tmp_g);
src_head = NULL; // don't do anything more to this train since the new call will do it
}
if (src_head != NULL) {
NormaliseTrainConsist(src_head);
TrainConsistChanged(src_head);
+ UpdateTrainGroupID(src_head);
if (IsFrontEngine(src_head)) {
UpdateTrainAcceleration(src_head);
InvalidateWindow(WC_VEHICLE_DETAILS, src_head->index);
@@ -1214,6 +1138,7 @@
if (dst_head != NULL) {
NormaliseTrainConsist(dst_head);
TrainConsistChanged(dst_head);
+ UpdateTrainGroupID(dst_head);
if (IsFrontEngine(dst_head)) {
UpdateTrainAcceleration(dst_head);
InvalidateWindow(WC_VEHICLE_DETAILS, dst_head->index);
@@ -1233,6 +1158,7 @@
/** Start/Stop a train.
* @param tile unused
+ * @param flags type of operation
* @param p1 train to start/stop
* @param p2 unused
*/
@@ -1259,7 +1185,6 @@
DeleteVehicleNews(p1, STR_8814_TRAIN_IS_WAITING_IN_DEPOT);
}
- v->u.rail.days_since_order_progr = 0;
v->vehstatus ^= VS_STOPPED;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
@@ -1269,6 +1194,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 +1216,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);
}
@@ -1353,6 +1279,8 @@
if (first->next_shared != NULL) {
first->next_shared->prev_shared = new_f;
new_f->next_shared = first->next_shared;
+ } else {
+ RemoveVehicleFromGroup(v);
}
/*
@@ -1383,6 +1311,7 @@
if (first != NULL) {
NormaliseTrainConsist(first);
TrainConsistChanged(first);
+ UpdateTrainGroupID(first);
if (IsFrontEngine(first)) {
InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
InvalidateWindow(WC_VEHICLE_REFIT, first->index);
@@ -1419,6 +1348,15 @@
if (rear != NULL) {
cost -= rear->value;
+
+ /* If this is a multiheaded vehicle with nothing
+ * between the parts, tmp will be pointing to the
+ * rear part, which is unlinked from the train and
+ * deleted here. However, because tmp has already
+ * been set it needs to be updated now so that the
+ * loop never sees the rear part. */
+ if (tmp == rear) tmp = GetNextVehicle(tmp);
+
if (flags & DC_EXEC) {
first = UnlinkWagon(rear, first);
DeleteDepotHighlightOfVehicle(rear);
@@ -1436,6 +1374,7 @@
first = UnlinkWagon(v, first);
DeleteDepotHighlightOfVehicle(v);
DeleteVehicle(v);
+ RemoveVehicleFromGroup(v);
}
}
@@ -1443,6 +1382,7 @@
if (flags & DC_EXEC && first != NULL) {
NormaliseTrainConsist(first);
TrainConsistChanged(first);
+ UpdateTrainGroupID(first);
if (IsFrontEngine(first)) UpdateTrainAcceleration(first);
InvalidateWindow(WC_VEHICLE_DETAILS, first->index);
InvalidateWindow(WC_VEHICLE_REFIT, first->index);
@@ -1452,9 +1392,9 @@
return cost;
}
-static void UpdateTrainDeltaXY(Vehicle *v, Direction direction)
+void Train::UpdateDeltaXY(Direction direction)
{
-#define MKIT(a,b,c,d) ((a&0xFF)<<24) | ((b&0xFF)<<16) | ((c&0xFF)<<8) | ((d&0xFF)<<0)
+#define MKIT(a, b, c, d) ((a & 0xFF) << 24) | ((b & 0xFF) << 16) | ((c & 0xFF) << 8) | ((d & 0xFF) << 0)
static const uint32 _delta_xy_table[8] = {
MKIT(3, 3, -1, -1),
MKIT(3, 7, -1, -3),
@@ -1468,16 +1408,16 @@
#undef MKIT
uint32 x = _delta_xy_table[direction];
-
- v->x_offs = GB(x, 0, 8);
- v->y_offs = GB(x, 8, 8);
- v->sprite_width = GB(x, 16, 8);
- v->sprite_height = GB(x, 24, 8);
+ this->x_offs = GB(x, 0, 8);
+ this->y_offs = GB(x, 8, 8);
+ this->sprite_width = GB(x, 16, 8);
+ this->sprite_height = GB(x, 24, 8);
+ this->z_height = 6;
}
static void UpdateVarsAfterSwap(Vehicle *v)
{
- UpdateTrainDeltaXY(v, v->direction);
+ v->UpdateDeltaXY(v->direction);
v->cur_image = GetTrainImage(v, v->direction);
BeginVehicleMove(v);
VehiclePositionChanged(v);
@@ -1596,8 +1536,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 +1545,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 +1583,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 +1607,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 +1620,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 +1638,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 +1656,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,15 +1675,19 @@
/** 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
* - p2 = (bit 8-15) - the new cargo subtype to refit to
+ * - p2 = (bit 16) - refit only this vehicle
+ * @return cost of refit or error
*/
int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
CargoID new_cid = GB(p2, 0, 8);
byte new_subtype = GB(p2, 8, 8);
+ bool only_this = HASBIT(p2, 16);
if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -1819,7 +1765,7 @@
}
}
}
- } while ((v = v->next) != NULL);
+ } while ((v = v->next) != NULL && !only_this);
_returned_refit_capacity = num;
@@ -1854,8 +1800,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));
@@ -1881,7 +1827,7 @@
Trackdir trackdir_rev = ReverseTrackdir(GetVehicleTrackdir(last));
assert(trackdir != INVALID_TRACKDIR);
- NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY);
+ NPFFoundTargetData ftd = NPFRouteToDepotBreadthFirstTwoWay(v->tile, trackdir, last->tile, trackdir_rev, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes, NPF_INFINITE_PENALTY);
if (ftd.best_bird_dist == 0) {
/* Found target */
tfdd.tile = ftd.node.tile;
@@ -1893,7 +1839,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 +1847,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 +1861,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)
@@ -1951,7 +1898,6 @@
if (p2 & DEPOT_DONT_CANCEL) return CMD_ERROR; // Requested no cancelation of depot orders
if (flags & DC_EXEC) {
if (HASBIT(v->current_order.flags, OFB_PART_OF_ORDERS)) {
- v->u.rail.days_since_order_progr = 0;
v->cur_order_index++;
}
@@ -1970,6 +1916,8 @@
if (tfdd.best_length == (uint)-1) return_cmd_error(STR_883A_UNABLE_TO_FIND_ROUTE_TO);
if (flags & DC_EXEC) {
+ if (v->current_order.type == OT_LOADING) v->LeaveStation();
+
v->dest_tile = tfdd.tile;
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
@@ -1978,8 +1926,7 @@
v->current_order.refit_cargo = CT_INVALID;
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
/* If there is no depot in front, reverse automatically */
- if (tfdd.reverse)
- DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
+ if (tfdd.reverse) DoCommand(v->tile, v->index, 0, DC_EXEC, CMD_REVERSE_TRAIN_DIRECTION);
}
return 0;
@@ -2010,22 +1957,21 @@
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 ||
v->vehstatus & VS_HIDDEN) {
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 +1987,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 +1995,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 +2003,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;
@@ -2074,32 +2020,30 @@
static const SoundFx sfx[] = {
SND_04_TRAIN,
SND_0A_TRAIN_HORN,
- SND_0A_TRAIN_HORN
+ SND_0A_TRAIN_HORN,
+ SND_47_MAGLEV_2,
+ SND_41_MAGLEV
};
if (PlayVehicleSound(v, VSE_START)) return;
EngineID engtype = v->engine_type;
- switch (RailVehInfo(engtype)->railtype) {
- case RAILTYPE_RAIL:
- case RAILTYPE_ELECTRIC:
- SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
- break;
-
- case RAILTYPE_MONO: SndPlayVehicleFx(SND_47_MAGLEV_2, v); break;
- case RAILTYPE_MAGLEV: SndPlayVehicleFx(SND_41_MAGLEV, v); break;
- default: NOT_REACHED();
- }
+ SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
+}
+
+void Train::PlayLeaveStationSound() const
+{
+ TrainPlayLeaveStationSound(this);
}
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);
@@ -2130,7 +2074,7 @@
v->vehstatus &= ~VS_HIDDEN;
v->cur_speed = 0;
- UpdateTrainDeltaXY(v, v->direction);
+ v->UpdateDeltaXY(v->direction);
v->cur_image = GetTrainImage(v, v->direction);
VehiclePositionChanged(v);
UpdateSignalsOnSegment(v->tile, DirToDiagDir(v->direction));
@@ -2151,10 +2095,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 +2107,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 +2150,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 +2164,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
@@ -2247,12 +2192,12 @@
Trackdir trackdir = GetVehicleTrackdir(v);
assert(trackdir != 0xff);
- NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes);
+ NPFFoundTargetData ftd = NPFRouteToStationOrTile(tile - TileOffsByDiagDir(enterdir), trackdir, &fstd, TRANSPORT_RAIL, 0, 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 +2225,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 +2238,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 +2255,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? */
}
}
@@ -2357,7 +2302,7 @@
assert(trackdir != 0xff);
assert(trackdir_rev != 0xff);
- ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, v->owner, v->u.rail.compatible_railtypes);
+ ftd = NPFRouteToStationOrTileTwoWay(v->tile, trackdir, last->tile, trackdir_rev, &fstd, TRANSPORT_RAIL, 0, v->owner, v->u.rail.compatible_railtypes);
if (ftd.best_bird_dist != 0) {
/* We didn't find anything, just keep on going straight ahead */
reverse_best = false;
@@ -2440,14 +2385,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 +2400,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;
@@ -2502,62 +2447,17 @@
return !at_waypoint && CheckReverseTrain(v);
}
-static void MarkTrainDirty(Vehicle *v)
+void Train::MarkDirty()
{
+ Vehicle *v = this;
do {
v->cur_image = GetTrainImage(v, v->direction);
MarkAllViewportsDirty(v->left_coord, v->top_coord, v->right_coord + 1, v->bottom_coord + 1);
} while ((v = v->next) != NULL);
-}
-
-static void HandleTrainLoading(Vehicle *v, bool mode)
-{
- switch (v->current_order.type) {
- case OT_LOADING: {
- if (mode) return;
-
- // 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;
- }
-
- if (--v->load_unload_time_rem) return;
-
- if (CanFillVehicle(v) && (
- 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 */
- 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.
- TrainCargoChanged(v);
- UpdateTrainAcceleration(v);
- }
- return;
- }
-
- TrainPlayLeaveStationSound(v);
-
- Order b = v->current_order;
- v->LeaveStation();
-
- // If this was not the final order, don't remove it from the list.
- if (!(b.flags & OF_NON_STOP)) return;
- break;
- }
-
- case OT_DUMMY: break;
-
- default: return;
- }
-
- v->u.rail.days_since_order_progr = 0;
- v->cur_order_index++;
- InvalidateVehicleOrder(v);
+
+ /* need to update acceleration and cached values since the goods on the train changed. */
+ TrainCargoChanged(this);
+ UpdateTrainAcceleration(this);
}
static int UpdateTrainSpeed(Vehicle *v)
@@ -2614,34 +2514,13 @@
);
}
- // 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.
- 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
- v->BeginLoading();
- v->current_order.flags = 0;
- }
+ v->BeginLoading();
v->current_order.dest = 0;
-
- SET_EXPENSES_TYPE(EXPENSES_TRAIN_INC);
- if (LoadUnloadVehicle(v, true) != 0) {
- InvalidateWindow(WC_TRAINS_LIST, v->owner);
- TrainCargoChanged(v);
- UpdateTrainAcceleration(v);
- }
- MarkTrainDirty(v);
- InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, STATUS_BAR);
}
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 +2533,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 +2606,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 +2624,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;
@@ -2788,7 +2667,7 @@
v != tcc->v_skip &&
v->type == VEH_TRAIN &&
v->u.rail.track != TRACK_BIT_DEPOT &&
- myabs(v->z_pos - tcc->v->z_pos) <= 6 &&
+ myabs(v->z_pos - tcc->v->z_pos) < 6 &&
myabs(v->x_pos - tcc->v->x_pos) < 6 &&
myabs(v->y_pos - tcc->v->y_pos) < 6) {
return v;
@@ -2820,7 +2699,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 +2727,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);
@@ -2931,7 +2810,7 @@
/* Get the status of the tracks in the new tile and mask
* away the bits that aren't reachable. */
- uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL) & _reachable_tracks[enterdir];
+ uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0) & _reachable_tracks[enterdir];
/* Combine the from & to directions.
* Now, the lower byte contains the track status, and the byte at bit 16 contains
@@ -2959,8 +2838,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);
@@ -2972,7 +2851,7 @@
} else if (HasSignalOnTrackdir(gp.new_tile, i)) {
v->cur_speed = 0;
v->subspeed = 0;
- v->progress = 255-10;
+ v->progress = 255 - 10;
if (++v->load_unload_time_rem < _patches.wait_twoway_signal * 73) {
TileIndex o_tile = gp.new_tile + TileOffsByDiagDir(enterdir);
VehicleAtSignalData vasd;
@@ -3061,7 +2940,7 @@
/* update image of train, as well as delta XY */
Direction newdir = GetNewVehicleDirection(v, gp.x, gp.y);
- UpdateTrainDeltaXY(v, newdir);
+ v->UpdateDeltaXY(newdir);
if (update_image) v->cur_image = GetTrainImage(v, newdir);
v->x_pos = gp.x;
@@ -3095,7 +2974,7 @@
* train, then goes to the last wagon and deletes that. Each call to this function
* will remove the last wagon of a crashed train. If this wagon was on a crossing,
* or inside a tunnel, recalculate the signals as they might need updating
- * @param v the @Vehicle of which last wagon is to be removed
+ * @param v the Vehicle of which last wagon is to be removed
*/
static void DeleteLastWagon(Vehicle *v)
{
@@ -3113,6 +2992,9 @@
BeginVehicleMove(v);
EndVehicleMove(v);
+
+ if (IsFrontEngine(v)) RemoveVehicleFromGroup(v);
+
DeleteVehicle(v);
if (v->u.rail.track != TRACK_BIT_DEPOT && v->u.rail.track != TRACK_BIT_WORMHOLE)
@@ -3157,7 +3039,7 @@
if (!(v->vehstatus & VS_HIDDEN)) {
v->direction = ChangeDir(v->direction, delta[GB(Random(), 0, 2)]);
BeginVehicleMove(v);
- UpdateTrainDeltaXY(v, v->direction);
+ v->UpdateDeltaXY(v->direction);
v->cur_image = GetTrainImage(v, v->direction);
/* Refrain from updating the z position of the vehicle when on
a bridge, because AfterSetTrainPos will put the vehicle under
@@ -3198,6 +3080,7 @@
if (state >= 4440 && !(v->tick_counter&0x1F)) {
DeleteLastWagon(v);
+ InvalidateWindow(WC_REPLACE_VEHICLE, (v->group_id << 16) | VEH_TRAIN);
}
}
@@ -3272,7 +3155,7 @@
/* Calculate next tile */
tile += TileOffsByDiagDir(dir);
// determine the track status on the next tile.
- uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL) & _reachable_tracks[dir];
+ uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _reachable_tracks[dir];
/* Calc position within the current tile ?? */
uint x = v->x_pos & 0xF;
@@ -3300,7 +3183,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 +3199,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;
@@ -3359,7 +3242,7 @@
return;
}
- HandleTrainLoading(v, mode);
+ v->HandleLoading(mode);
if (v->current_order.type == OT_LOADING) return;
@@ -3369,7 +3252,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 +3279,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 +3298,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;
@@ -3448,6 +3331,8 @@
return;
}
+ if (v->current_order.type == OT_LOADING) v->LeaveStation();
+
v->current_order.type = OT_GOTO_DEPOT;
v->current_order.flags = OF_NON_STOP;
v->current_order.dest = depot->index;
@@ -3461,8 +3346,11 @@
do {
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
- if (rvi->running_cost_base > 0)
- cost += rvi->running_cost_base * _price.running_rail[rvi->running_cost_class];
+
+ byte cost_factor = GetVehicleProperty(v, 0x0D, rvi->running_cost_base);
+ if (cost_factor == 0) continue;
+
+ cost += cost_factor * _price.running_rail[rvi->running_cost_class];
} while ((v = GetNextVehicle(v)) != NULL);
return cost;
@@ -3507,7 +3395,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);
@@ -3579,7 +3467,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 5a8b295aa345 -r 4cc327ad39d5 src/train_gui.cpp
--- a/src/train_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/train_gui.cpp Sat Jun 02 19:59:29 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();
}
@@ -232,7 +234,7 @@
DrawSprite(v->vehstatus & VS_STOPPED ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, 2, w->widget[5].top + 1);
DrawStringCenteredTruncated(w->widget[5].left + 8, w->widget[5].right, w->widget[5].top + 1, str, 0);
DrawWindowViewport(w);
- } break;
+ } break;
case WE_CLICK: {
int wid = e->we.click.widget;
@@ -318,7 +320,7 @@
if (w != NULL) {
w->caption_color = v->owner;
- AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), 0);
+ AssignWindowViewport(w, 3, 17, 0xE2, 0x66, w->window_number | (1 << 31), ZOOM_LVL_TRAIN);
}
}
@@ -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 5a8b295aa345 -r 4cc327ad39d5 src/transparency_gui.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/transparency_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -0,0 +1,89 @@
+/* $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"
+
+enum TransparencyToolbarWidgets{
+ /* Widgets not toggled when pressing the X key */
+ TTW_WIDGET_SIGNS = 3, ///< Make signs background transparent
+
+ /* Widgets toggled when pressing the X key */
+ TTW_WIDGET_TREES, ///< Make trees transparent
+ TTW_WIDGET_HOUSES, ///< Make houses transparent
+ TTW_WIDGET_INDUSTRIES, ///< Make Industries transparent
+ TTW_WIDGET_BUILDINGS, ///< Make player buildings and structures transparent
+ TTW_WIDGET_BRIDGES, ///< Make bridges transparent
+ TTW_WIDGET_STRUCTURES, ///< Make unmovable structures transparent
+ TTW_WIDGET_END, ///< End of toggle buttons
+};
+
+/** Toggle the bits of the transparencies variable
+ * when clicking on a widget, and play a sound
+ * @param widget been clicked.
+ */
+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:
+ /* must be sure that the widgets show the transparency variable changes
+ * also when we use shortcuts */
+ for (uint i = TTW_WIDGET_SIGNS; i < TTW_WIDGET_END; i++) {
+ SetWindowWidgetLoweredState(w, i, HASBIT(_transparent_opt, i - TTW_WIDGET_SIGNS));
+ }
+ DrawWindowWidgets(w);
+ break;
+
+ case WE_CLICK:
+ if (e->we.click.widget >= TTW_WIDGET_SIGNS) {
+ Transparent_Click(e->we.click.widget - TTW_WIDGET_SIGNS);
+ 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, bridges and unmovable structures */
+{ WWT_IMGBTN, RESIZE_NONE, 7, 0, 21, 14, 35, SPR_IMG_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 5a8b295aa345 -r 4cc327ad39d5 src/transparency_gui.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/transparency_gui.h Sat Jun 02 19:59:29 2007 +0000
@@ -0,0 +1,8 @@
+/* $Id$ */
+
+#ifndef TRANSPARENCY_GUI_H
+#define TRANSPARENCY_GUI_H
+
+void ShowTransparencyToolbar();
+
+#endif /* TRANSPARENCY_GUI_H */
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tree_cmd.cpp
--- a/src/tree_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tree_cmd.cpp Sat Jun 02 19:59:29 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 += _price.build_trees * 2;
break;
@@ -314,7 +317,7 @@
struct TreeListEnt {
SpriteID image;
SpriteID pal;
- byte x,y;
+ byte x, y;
};
static void DrawTile_Trees(TileInfo *ti)
@@ -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 */
@@ -645,7 +648,7 @@
/* not used */
}
-static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode)
{
return 0;
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tree_map.h
--- a/src/tree_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tree_map.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/tunnel_map.cpp
--- a/src/tunnel_map.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tunnel_map.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,10 +1,18 @@
/* $Id$ */
+/** @file tunnel_map.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "tile.h"
#include "tunnel_map.h"
+/**
+ * Gets the other end of the tunnel. Where a vehicle would reappear when it
+ * enters at the given tile.
+ * @param tile the tile to search from.
+ * @return the tile of the other end of the tunnel.
+ */
TileIndex GetOtherTunnelEnd(TileIndex tile)
{
DiagDirection dir = GetTunnelDirection(tile);
@@ -24,6 +32,13 @@
}
+/**
+ * Is there a tunnel in the way in the given direction?
+ * @param tile the tile to search from.
+ * @param z the 'z' to search on.
+ * @param dir the direction to start searching to.
+ * @return true if and only if there is a tunnel.
+ */
static bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir)
{
TileIndexDiff delta = TileOffsByDiagDir(dir);
@@ -40,6 +55,12 @@
GetTunnelDirection(tile) == dir;
}
+/**
+ * Is there a tunnel in the way in any direction?
+ * @param tile the tile to search from.
+ * @param z the 'z' to search on.
+ * @return true if and only if there is a tunnel.
+ */
bool IsTunnelInWay(TileIndex tile, uint z)
{
return
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tunnel_map.h
--- a/src/tunnel_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tunnel_map.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file tunnel_map.h */
+
#ifndef TUNNEL_MAP_H
#define TUNNEL_MAP_H
@@ -7,8 +9,14 @@
#include "macros.h"
#include "map.h"
#include "rail.h"
+#include "road.h"
-
+/**
+ * Is this a tunnel (entrance)?
+ * @param t the tile that might be a tunnel
+ * @pre IsTileType(t, MP_TUNNELBRIDGE)
+ * @return true if and only if this tile is a tunnel (entrance)
+ */
static inline bool IsTunnel(TileIndex t)
{
assert(IsTileType(t, MP_TUNNELBRIDGE));
@@ -16,31 +24,60 @@
}
+/**
+ * Is this a tunnel (entrance)?
+ * @param t the tile that might be a tunnel
+ * @return true if and only if this tile is a tunnel (entrance)
+ */
static inline bool IsTunnelTile(TileIndex t)
{
return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
}
-
+/**
+ * Gets the direction facing out of the tunnel
+ * @param t the tile to get the tunnel facing direction of
+ * @pre IsTunnelTile(t)
+ * @return the direction the tunnel is facing
+ */
static inline DiagDirection GetTunnelDirection(TileIndex t)
{
assert(IsTunnelTile(t));
return (DiagDirection)GB(_m[t].m5, 0, 2);
}
-
+/**
+ * Gets the transport type of the tunnel (road or rail)
+ * @param t the tunnel entrance tile to get the type of
+ * @pre IsTunnelTile(t)
+ * @return the transport type in the tunnel
+ */
static inline TransportType GetTunnelTransportType(TileIndex t)
{
assert(IsTunnelTile(t));
return (TransportType)GB(_m[t].m5, 2, 2);
}
+/**
+ * Is this tunnel entrance in a snowy or desert area?
+ * @param t the tunnel entrance tile
+ * @pre IsTunnelTile(t)
+ * @return true if and only if the tunnel entrance is in a snowy/desert area
+ */
static inline bool HasTunnelSnowOrDesert(TileIndex t)
{
assert(IsTunnelTile(t));
return HASBIT(_m[t].m4, 7);
}
+/**
+ * Places this tunnel entrance in a snowy or desert area,
+ * or takes it out of there.
+ * @param t the tunnel entrance tile
+ * @param snow_or_desert is the entrance in snow or desert (true), when
+ * not in snow and not in desert false
+ * @pre IsTunnelTile(t)
+ */
static inline void SetTunnelSnowOrDesert(TileIndex t, bool snow_or_desert)
{
assert(IsTunnelTile(t));
@@ -52,16 +89,30 @@
bool IsTunnelInWay(TileIndex, uint z);
-static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d)
+/**
+ * Makes a road tunnel entrance
+ * @param t the entrance of the tunnel
+ * @param o the owner of the entrance
+ * @param d the direction facing out of the tunnel
+ * @param r the road type used in the tunnel
+ */
+static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
{
SetTileType(t, MP_TUNNELBRIDGE);
SetTileOwner(t, o);
_m[t].m2 = 0;
- _m[t].m3 = 0;
+ _m[t].m3 = r;
_m[t].m4 = 0;
_m[t].m5 = TRANSPORT_ROAD << 2 | d;
}
+/**
+ * Makes a rail tunnel entrance
+ * @param t the entrance of the tunnel
+ * @param o the owner of the entrance
+ * @param d the direction facing out of the tunnel
+ * @param r the rail type used in the tunnel
+ */
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
{
SetTileType(t, MP_TUNNELBRIDGE);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/tunnelbridge_cmd.cpp
--- a/src/tunnelbridge_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/tunnelbridge_cmd.cpp Sat Jun 02 19:59:29 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,15 +168,18 @@
/** 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)
- * - p2 = (bit 8-..) - rail type. bit15 ((x>>8)&0x80) means road bridge.
+ * - p2 = (bit 8-..) - rail type or road types.
+ * - p2 = (bit 15 ) - set means road bridge.
*/
int32 CmdBuildBridge(TileIndex end_tile, uint32 flags, uint32 p1, uint32 p2)
{
uint bridge_type;
RailType railtype;
+ RoadTypes roadtypes;
uint x;
uint y;
uint sx;
@@ -202,12 +206,15 @@
if (p1 >= MapSize()) return CMD_ERROR;
- // type of bridge
+ /* type of bridge */
if (HASBIT(p2, 15)) {
railtype = INVALID_RAILTYPE; // road bridge
+ roadtypes = (RoadTypes)GB(p2, 8, 3);
+ if (!AreValidRoadTypes(roadtypes)) return CMD_ERROR;
} else {
if (!ValParamRailtype(GB(p2, 8, 8))) return CMD_ERROR;
railtype = (RailType)GB(p2, 8, 8);
+ roadtypes = ROADTYPES_NONE;
}
x = TileX(end_tile);
@@ -255,7 +262,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);
@@ -297,6 +304,9 @@
cost = (bridge_len + 1) * _price.clear_bridge; // The cost of clearing the current bridge.
replace_bridge = true;
replaced_bridge_type = GetBridgeType(tile_start);
+
+ /* Do not remove road types when upgrading a bridge */
+ roadtypes |= GetRoadTypes(tile_start);
} else {
/* Build a new bridge. */
@@ -315,7 +325,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);
@@ -350,8 +360,8 @@
MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype);
MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype);
} else {
- MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir);
- MakeRoadBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir));
+ MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir, roadtypes);
+ MakeRoadBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), roadtypes);
}
MarkTileDirtyByTile(tile_start);
MarkTileDirtyByTile(tile_end);
@@ -438,8 +448,9 @@
/** Build Tunnel.
- * @param tile start tile of tunnel
- * @param p1 railtype, 0x200 for road tunnel
+ * @param start_tile start tile of tunnel
+ * @param flags type of operation
+ * @param p1 railtype or roadtypes. bit 9 set means road tunnel
* @param p2 unused
*/
int32 CmdBuildTunnel(TileIndex start_tile, uint32 flags, uint32 p1, uint32 p2)
@@ -455,8 +466,11 @@
int32 ret;
_build_tunnel_endtile = 0;
-
- if (p1 != 0x200 && !ValParamRailtype(p1)) return CMD_ERROR;
+ if (!HASBIT(p1, 9)) {
+ if (!ValParamRailtype(p1)) return CMD_ERROR;
+ } else if (!AreValidRoadTypes((RoadTypes)GB(p1, 0, 3))) {
+ return CMD_ERROR;
+ }
start_tileh = GetTileSlope(start_tile, &start_z);
@@ -496,10 +510,10 @@
/* Add the cost of the entrance */
cost += _price.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);
@@ -516,8 +530,8 @@
UpdateSignalsOnSegment(start_tile, direction);
YapfNotifyTrackLayoutChange(start_tile, AxisToTrack(DiagDirToAxis(direction)));
} else {
- MakeRoadTunnel(start_tile, _current_player, direction);
- MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction));
+ MakeRoadTunnel(start_tile, _current_player, direction, (RoadTypes)GB(p1, 0, 3));
+ MakeRoadTunnel(end_tile, _current_player, ReverseDiagDir(direction), (RoadTypes)GB(p1, 0, 3));
}
}
@@ -591,12 +605,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);
@@ -636,10 +650,11 @@
if (!CheckAllowRemoveTunnelBridge(tile)) return CMD_ERROR;
endtile = GetOtherBridgeEnd(tile);
+ byte bridge_height = GetBridgeHeight(tile);
- if (!EnsureNoVehicle(tile) ||
- !EnsureNoVehicle(endtile) ||
- IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
+ if (FindVehicleOnTileZ(tile, bridge_height) != NULL ||
+ FindVehicleOnTileZ(endtile, bridge_height) != NULL ||
+ IsVehicleOnBridge(tile, endtile, bridge_height)) {
return CMD_ERROR;
}
@@ -661,8 +676,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 +732,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);
@@ -740,10 +755,11 @@
if (!CheckTileOwnership(tile)) return CMD_ERROR;
endtile = GetOtherBridgeEnd(tile);
+ byte bridge_height = GetBridgeHeight(tile);
- if (!EnsureNoVehicle(tile) ||
- !EnsureNoVehicle(endtile) ||
- IsVehicleOnBridge(tile, endtile, GetBridgeHeight(tile))) {
+ if (FindVehicleOnTileZ(tile, bridge_height) != NULL ||
+ FindVehicleOnTileZ(endtile, bridge_height) != NULL ||
+ IsVehicleOnBridge(tile, endtile, bridge_height)) {
return CMD_ERROR;
}
@@ -792,7 +808,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 +845,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;
@@ -846,10 +862,44 @@
}
/**
+ * Draws the trambits over an already drawn (lower end) of a bridge.
+ * @param x the x of the bridge
+ * @param y the y of the bridge
+ * @param z the z of the bridge
+ * @param offset number representing whether to level or sloped and the direction
+ * @param overlay do we want to still see the road?
+ */
+static void DrawBridgeTramBits(int x, int y, byte z, int offset, bool overlay)
+{
+ static const SpriteID tram_offsets[2][6] = { { 107, 108, 109, 110, 111, 112 }, { 4, 5, 15, 16, 17, 18 } };
+ static const SpriteID back_offsets[6] = { 95, 95, 99, 102, 100, 101 };
+ static const SpriteID front_offsets[6] = { 97, 98, 103, 106, 104, 105 };
+
+ static const uint size_x[6] = { 11, 16, 16, 16, 16, 16 };
+ static const uint size_y[6] = { 16, 11, 16, 16, 16, 16 };
+
+ AddSortableSpriteToDraw(SPR_TRAMWAY_BASE + tram_offsets[overlay][offset], PAL_NONE, x, y, size_x[offset], size_y[offset], offset >= 2 ? 1 : 0, z);
+
+ SpriteID front = SPR_TRAMWAY_BASE + front_offsets[offset];
+ SpriteID back = SPR_TRAMWAY_BASE + back_offsets[offset];
+ SpriteID pal = PAL_NONE;
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
+ SETBIT(front, PALETTE_MODIFIER_TRANSPARENT);
+ SETBIT(back, PALETTE_MODIFIER_TRANSPARENT);
+ pal = PALETTE_TO_TRANSPARENT;
+ }
+
+ AddSortableSpriteToDraw(back, pal, x, y, size_x[offset], size_y[offset], 0, z);
+ /* For sloped sprites the bounding box needs to be higher, as the pylons stop on a higher point */
+ AddSortableSpriteToDraw(front, pal, x, y, size_x[offset], size_y[offset], offset >= 2 ? 0x30 : 0x10, z);
+}
+
+/**
* Draws a tunnel of bridge tile.
* 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
@@ -873,9 +923,21 @@
image += GetTunnelDirection(ti->tile) * 2;
DrawGroundSprite(image, PAL_NONE);
- if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
+ if (GetTunnelTransportType(ti->tile) == TRANSPORT_ROAD) {
+ DiagDirection dir = GetTunnelDirection(ti->tile);
+ RoadTypes rts = GetRoadTypes(ti->tile);
- AddSortableSpriteToDraw(image+1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, 1, 1, 8, (byte)ti->z);
+ if (HASBIT(rts, ROADTYPE_TRAM)) {
+ static const SpriteID tunnel_sprites[2][4] = { { 28, 78, 79, 27 }, { 5, 76, 77, 4 } };
+
+ DrawGroundSprite(SPR_TRAMWAY_BASE + tunnel_sprites[rts - ROADTYPES_TRAM][dir], PAL_NONE);
+ AddSortableSpriteToDraw(SPR_TRAMWAY_TUNNEL_WIRES + dir, PAL_NONE, ti->x, ti->y, 16, 16, 16, (byte)ti->z);
+ }
+ } else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
+ DrawCatenary(ti);
+ }
+
+ AddSortableSpriteToDraw(image + 1, PAL_NONE, ti->x + TILE_SIZE - 1, ti->y + TILE_SIZE - 1, 1, 1, 8, (byte)ti->z);
DrawBridgeMiddle(ti);
} else if (IsBridge(ti->tile)) { // XXX is this necessary?
const PalSpriteID *psid;
@@ -884,7 +946,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 +959,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
@@ -911,12 +973,10 @@
DrawGroundSprite(SPR_FLAT_SNOWY_TILE + _tileh_to_sprite[ti->tileh], PAL_NONE);
}
- if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
-
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 {
@@ -927,9 +987,27 @@
* it doesn't disappear behind it
*/
AddSortableSpriteToDraw(
- image, pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 1 : 8, ti->z
+ image, pal, ti->x, ti->y, 16, 16, ti->tileh == SLOPE_FLAT ? 0 : 8, ti->z
);
+ if (GetBridgeTransportType(ti->tile) == TRANSPORT_ROAD) {
+ RoadTypes rts = GetRoadTypes(ti->tile);
+
+ if (HASBIT(rts, ROADTYPE_TRAM)) {
+ uint offset = GetBridgeRampDirection(ti->tile);
+ uint z = ti->z;
+ if (ti->tileh != SLOPE_FLAT) {
+ offset = (offset + 1) & 1;
+ z += TILE_HEIGHT;
+ } else {
+ offset += 2;
+ }
+ DrawBridgeTramBits(ti->x, ti->y, z, offset, HASBIT(rts, ROADTYPE_ROAD));
+ }
+ } else if (GetRailType(ti->tile) == RAILTYPE_ELECTRIC) {
+ DrawCatenary(ti);
+ }
+
DrawBridgeMiddle(ti);
}
}
@@ -1005,10 +1083,11 @@
x = ti->x;
y = ti->y;
- z = GetBridgeHeight(rampsouth) - 3;
+ uint bridge_z = GetBridgeHeight(rampsouth);
+ z = bridge_z - 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 +1102,24 @@
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
+ if (GetBridgeTransportType(rampsouth) == TRANSPORT_ROAD) {
+ RoadTypes rts = GetRoadTypes(rampsouth);
+
+ if (HASBIT(rts, ROADTYPE_TRAM)) {
+ DrawBridgeTramBits(x, y, bridge_z, axis ^ 1, HASBIT(rts, ROADTYPE_ROAD));
+ }
+ } else if (GetRailType(rampsouth) == RAILTYPE_ELECTRIC) {
+ DrawCatenary(ti);
+ }
+
+ /* 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);
@@ -1039,14 +1128,12 @@
if (image & SPRITE_MASK) AddSortableSpriteToDraw(image, pal, x, y, 1, 16, 0x28, z);
}
- if (GetRailType(rampsouth) == RAILTYPE_ELECTRIC) DrawCatenary(ti);
-
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 +1143,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 +1160,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;
@@ -1218,13 +1305,15 @@
}
-static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_TunnelBridge(TileIndex tile, TransportType mode, uint sub_mode)
{
if (IsTunnel(tile)) {
if (GetTunnelTransportType(tile) != mode) return 0;
+ if (GetTunnelTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
return AxisToTrackBits(DiagDirToAxis(GetTunnelDirection(tile))) * 0x101;
} else {
if (GetBridgeTransportType(tile) != mode) return 0;
+ if (GetBridgeTransportType(tile) == TRANSPORT_ROAD && (GetRoadTypes(tile) & sub_mode) == 0) return 0;
return AxisToTrackBits(DiagDirToAxis(GetBridgeRampDirection(tile))) * 0x101;
}
}
@@ -1236,7 +1325,14 @@
if (new_player != PLAYER_SPECTATOR) {
SetTileOwner(tile, new_player);
} else {
- DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
+ if (CmdFailed(DoCommand(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR))) {
+ /* When clearing the bridge/tunnel failed there are still vehicles on/in
+ * the bridge/tunnel. As all *our* vehicles are already removed, they
+ * must be of another owner. Therefor this must be a road bridge/tunnel.
+ * In that case we can safely reassign the ownership to OWNER_NONE. */
+ assert((IsTunnel(tile) ? GetTunnelTransportType(tile) : GetBridgeTransportType(tile)) == TRANSPORT_ROAD);
+ SetTileOwner(tile, OWNER_NONE);
+ }
}
}
@@ -1302,7 +1398,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 5a8b295aa345 -r 4cc327ad39d5 src/unix.cpp
--- a/src/unix.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/unix.cpp Sat Jun 02 19:59:29 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
@@ -51,7 +53,7 @@
#else
/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
const char *s = strchr(path, ':');
- return s[1] == '\0';
+ return s != NULL && s[1] == '\0';
#endif
}
@@ -85,8 +87,11 @@
if (FiosIsRoot(path)) {
snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
} else // XXX - only next line!
+#else
+ assert(path[strlen(path) - 1] == PATHSEPCHAR);
+ if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
#endif
- snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);
+ snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name);
return stat(filename, sb) == 0;
}
@@ -104,11 +109,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 +156,10 @@
}
-// multi os compatible sleep function
+/* multi os compatible sleep function */
#ifdef __AMIGA__
-// usleep() implementation
+/* usleep() implementation */
# include
# include
@@ -174,7 +179,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 +248,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 5a8b295aa345 -r 4cc327ad39d5 src/unmovable.h
--- a/src/unmovable.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/unmovable.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file unmovable.h */
+
#ifndef UNMOVABLE_H
#define UNMOVABLE_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/unmovable_cmd.cpp
--- a/src/unmovable_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/unmovable_cmd.cpp Sat Jun 02 19:59:29 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"
@@ -24,8 +27,9 @@
/** Destroy a HQ.
* During normal gameplay you can only implicitely destroy a HQ when you are
* rebuilding it. Otherwise, only water can destroy it.
- * @param tile tile coordinates where HQ is located to destroy
+ * @param pid Player requesting the destruction of his HQ
* @param flags docommand flags of calling function
+ * @return cost of the operation
*/
static int32 DestroyCompanyHQ(PlayerID pid, uint32 flags)
{
@@ -44,7 +48,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 +73,14 @@
MarkTileDirtyByTile(tile + TileDiffXY(1, 1));
}
+extern int32 CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true);
+
/** 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 +93,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 +127,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 +145,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 +181,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 {
@@ -224,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);
@@ -252,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);
}
@@ -295,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;
@@ -313,7 +319,7 @@
}
-static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mode, uint sub_mode)
{
return 0;
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/unmovable_map.h
--- a/src/unmovable_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/unmovable_map.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,91 +1,157 @@
/* $Id$ */
+/** @file unmovable_map.h */
+
#ifndef UNMOVABLE_MAP_H
#define UNMOVABLE_MAP_H
enum {
- HQ_NUM_TILE = 4,
- HQ_NUM_SIZE = 5
+ HQ_NUM_TILE = 4, ///< Number of HQ tiles
+ HQ_NUM_SIZE = 5 ///< Number of stages of an HQ
};
+/** Types of unmovable structure */
enum UnmovableType {
- UNMOVABLE_TRANSMITTER = 0,
- UNMOVABLE_LIGHTHOUSE = 1,
- UNMOVABLE_STATUE = 2,
- UNMOVABLE_OWNED_LAND = 3,
- UNMOVABLE_HQ_NORTH = 0x80,
- UNMOVABLE_HQ_WEST = 0x81,
- UNMOVABLE_HQ_EAST = 0x82,
- UNMOVABLE_HQ_SOUTH = 0x83,
+ UNMOVABLE_TRANSMITTER = 0, ///< The large antenna
+ UNMOVABLE_LIGHTHOUSE = 1, ///< The nice lighthouse
+ UNMOVABLE_STATUE = 2, ///< Statue in towns
+ UNMOVABLE_OWNED_LAND = 3, ///< Owned land 'flag'
+ UNMOVABLE_HQ_NORTH = 0x80, ///< Offset for the northern HQ tile
+ UNMOVABLE_HQ_WEST = 0x81, ///< Offset for the western HQ tile
+ UNMOVABLE_HQ_EAST = 0x82, ///< Offset for the eastern HQ tile
+ UNMOVABLE_HQ_SOUTH = 0x83, ///< Offset for the southern HQ tile
+ /** End of the HQ (rather end + 1 for IS_INT_INSIDE) */
UNMOVABLE_HQ_END = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
};
+/**
+ * Gets the UnmovableType of the given unmovable tile
+ * @param t the tile to get the type from.
+ * @pre IsTileType(t, MP_UNMOVABLE)
+ * @return the type.
+ */
static inline UnmovableType GetUnmovableType(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
return (UnmovableType)_m[t].m5;
}
-
+/**
+ * Does the given tile have a transmitter?
+ * @param t the tile to inspect.
+ * @return true if and only if the tile has a transmitter.
+ */
static inline bool IsTransmitterTile(TileIndex t)
{
- return
- IsTileType(t, MP_UNMOVABLE) &&
- GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
+ return IsTileType(t, MP_UNMOVABLE) && GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
}
-
+/**
+ * Is this unmovable tile an 'owned land' tile?
+ * @param t the tile to inspect.
+ * @pre IsTileType(t, MP_UNMOVABLE)
+ * @return true if and only if the tile is an 'owned land' tile.
+ */
static inline bool IsOwnedLand(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
}
+/**
+ * Is the given tile (pre-)owned by someone (the little flags)?
+ * @param t the tile to inspect.
+ * @return true if and only if the tile is an 'owned land' tile.
+ */
static inline bool IsOwnedLandTile(TileIndex t)
{
return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
}
+/**
+ * Is this unmovable tile a HQ tile?
+ * @param t the tile to inspect.
+ * @pre IsTileType(t, MP_UNMOVABLE)
+ * @return true if and only if the tile is a HQ tile.
+ */
static inline bool IsCompanyHQ(TileIndex t)
{
+ assert(IsTileType(t, MP_UNMOVABLE));
return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
}
+/**
+ * Is this unmovable tile a statue?
+ * @param t the tile to inspect.
+ * @pre IsTileType(t, MP_UNMOVABLE)
+ * @return true if and only if the tile is a statue.
+ */
static inline bool IsStatue(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
return GetUnmovableType(t) == UNMOVABLE_STATUE;
}
+/**
+ * Is the given tile a statue?
+ * @param t the tile to inspect.
+ * @return true if and only if the tile is a statue.
+ */
static inline bool IsStatueTile(TileIndex t)
{
return IsTileType(t, MP_UNMOVABLE) && IsStatue(t);
}
+/**
+ * Get the town of the given statue tile.
+ * @param t the tile of the statue.
+ * @pre IsStatueTile(t)
+ * @return the town the given statue is in.
+ */
static inline TownID GetStatueTownID(TileIndex t)
{
- assert(IsStatue(t));
+ assert(IsStatueTile(t));
return _m[t].m2;
}
+/**
+ * Get the 'stage' of the HQ.
+ * @param t a tile of the HQ.
+ * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
+ * @return the 'stage' of the HQ.
+ */
static inline byte GetCompanyHQSize(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
return GB(_m[t].m5, 2, 3);
}
+/**
+ * Get the 'section' (including stage) of the HQ.
+ * @param t a tile of the HQ.
+ * @pre IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t)
+ * @return the 'section' of the HQ.
+ */
static inline byte GetCompanyHQSection(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
return GB(_m[t].m5, 0, 5);
}
-
+/**
+ * Enlarge the given HQ to the given size. If the new size
+ * is larger than the current size, nothing happens.
+ * @param t the tile of the HQ.
+ * @param size the new size of the HQ.
+ * @pre t is the northern tile of the HQ
+ */
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
{
+ assert(GB(GetCompanyHQSection(t), 0, 2) == 0);
+
size *= 4;
if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return;
@@ -96,6 +162,13 @@
}
+/**
+ * Make an Unmovable tile.
+ * @note do not use this function directly. Use one of the other Make* functions.
+ * @param t the tile to make unmovable.
+ * @param u the unmovable type of the tile.
+ * @param o the new owner of the tile.
+ */
static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
{
SetTileType(t, MP_UNMOVABLE);
@@ -107,27 +180,51 @@
}
+/**
+ * Make a transmitter tile.
+ * @param t the tile to make a transmitter.
+ */
static inline void MakeTransmitter(TileIndex t)
{
MakeUnmovable(t, UNMOVABLE_TRANSMITTER, OWNER_NONE);
}
+/**
+ * Make a lighthouse tile.
+ * @param t the tile to make a transmitter.
+ */
static inline void MakeLighthouse(TileIndex t)
{
MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
}
+/**
+ * Make a statue tile.
+ * @param t the tile to make a statue.
+ * @param o the owner of the statue.
+ * @param town_id the town the statue was built in.
+ */
static inline void MakeStatue(TileIndex t, Owner o, TownID town_id)
{
MakeUnmovable(t, UNMOVABLE_STATUE, o);
_m[t].m2 = town_id;
}
+/**
+ * Make an 'owned land' tile.
+ * @param t the tile to make an 'owned land' tile.
+ * @param o the owner of the land.
+ */
static inline void MakeOwnedLand(TileIndex t, Owner o)
{
MakeUnmovable(t, UNMOVABLE_OWNED_LAND, o);
}
+/**
+ * Make an HQ with the give tile as it's northern tile.
+ * @param t the tile to make the northern tile of a HQ.
+ * @param o the owner of the HQ.
+ */
static inline void MakeCompanyHQ(TileIndex t, Owner o)
{
MakeUnmovable(t + TileDiffXY(0, 0), UNMOVABLE_HQ_NORTH, o);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/variables.h
--- a/src/variables.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/variables.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,18 +1,20 @@
/* $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
#include "gfx.h"
-// Prices and also the fractional part.
+/* Prices and also the fractional part. */
VARDEF Prices _price;
VARDEF uint16 _price_frac[NUM_PRICES];
@@ -38,47 +40,46 @@
/* 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
@@ -117,6 +118,7 @@
byte se_flat_world_height; // land height a flat world gets in SE
bool bribe; // enable bribing the local authority
bool nonuniform_stations; // allow nonuniform train stations
+ bool adjacent_stations; // allow stations to be built directly adjacent to other stations
bool always_small_airport; // always allow small airports
bool realistic_acceleration; // realistic acceleration for trains
bool wagon_speed_limits; // enable wagon speed limits
@@ -125,10 +127,12 @@
bool no_servicing_if_no_breakdowns; // dont send vehicles to depot when breakdowns are disabled
bool link_terraform_toolbar; // display terraform toolbar when displaying rail, road, water and airport toolbars
bool reverse_scroll; // Right-Click-Scrolling scrolls in the opposite direction
+ bool smooth_scroll; ///< Smooth scroll viewports
bool disable_elrails; // when true, the elrails are disabled
bool measure_tooltip; // Show a permanent tooltip when dragging tools
byte liveries; // Options for displaying company liveries, 0=none, 1=self, 2=all
bool prefer_teamchat; // Choose the chat message target with , true=all players, false=your team
+ bool advanced_vehicle_list; // Use the "advanced" vehicle list
uint8 toolbar_pos; // position of toolbars, 0=left, 1=center, 2=right
uint8 window_snap_radius; // Windows snap at each other if closer than this
@@ -201,28 +205,36 @@
*/
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; ///< The number of cities to build. These start off larger and grow twice as fast
+ uint8 initial_city_size; ///< Multiplier for the initial size of the cities compared to towns
+
+ bool pause_on_newgame; ///< Whether to start new games paused or not.
+
+ TownLayoutByte town_layout; ///< Select town layout
};
VARDEF Patches _patches;
@@ -234,9 +246,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
@@ -268,7 +280,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;
@@ -280,6 +292,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;
@@ -291,20 +304,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;
@@ -372,24 +385,24 @@
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);
-#define COPY_IN_DPARAM(offs,src,num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num))
-#define COPY_OUT_DPARAM(dst,offs,num) memcpy(dst,_decode_parameters + offs, sizeof(uint32) * (num))
+#define COPY_IN_DPARAM(offs, src, num) memcpy(_decode_parameters + offs, src, sizeof(uint32) * (num))
+#define COPY_OUT_DPARAM(dst, offs, num) memcpy(dst, _decode_parameters + offs, sizeof(uint32) * (num))
#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 5a8b295aa345 -r 4cc327ad39d5 src/vehicle.cpp
--- a/src/vehicle.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/vehicle.cpp Sat Jun 02 19:59:29 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"
@@ -37,6 +40,8 @@
#include "newgrf_engine.h"
#include "newgrf_sound.h"
#include "helpers.hpp"
+#include "group.h"
+#include "economy.h"
#define INVALID_COORD (-0x8000)
#define GEN_HASH(x, y) ((GB((y), 6, 6) << 6) + GB((x), 7, 6))
@@ -86,7 +91,7 @@
* TODO - This is just a temporary stage, this will be removed. */
for (v = GetVehicle(start_item); v != NULL; v = (v->index + 1U < GetVehiclePoolSize()) ? GetVehicle(v->index + 1) : NULL) {
v->index = start_item++;
- v->type = VEH_INVALID;
+ v = new (v) InvalidVehicle();
}
}
@@ -104,10 +109,10 @@
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 */
+ return EngineHasReplacementForPlayer(GetPlayer(v->owner), v->engine_type, v->group_id); /* Vehicles set for autoreplacing needs to go to a depot even if breakdowns are turned off */
}
return _patches.servint_ispercent ?
@@ -185,9 +190,9 @@
}
FOR_ALL_VEHICLES(veh) {
if (without_crashed && (veh->vehstatus & VS_CRASHED) != 0) continue;
- if ((veh->type == VEH_TRAIN || veh->type == VEH_ROAD) && (z==0xFF || veh->z_pos == z)) {
- if ((veh->x_pos>>4) >= x1 && (veh->x_pos>>4) <= x2 &&
- (veh->y_pos>>4) >= y1 && (veh->y_pos>>4) <= y2) {
+ if ((veh->type == VEH_TRAIN || veh->type == VEH_ROAD) && (z == 0xFF || veh->z_pos == z)) {
+ if ((veh->x_pos >> 4) >= x1 && (veh->x_pos >> 4) <= x2 &&
+ (veh->y_pos >> 4) >= y1 && (veh->y_pos >> 4) <= y2) {
return veh;
}
}
@@ -215,12 +220,14 @@
v->bottom_coord = pt.y + spr->height + 2;
}
-// Called after load to update coordinates
+/** Called after load to update coordinates */
void AfterLoadVehicles()
{
Vehicle *v;
FOR_ALL_VEHICLES(v) {
+ v->UpdateDeltaXY(v->direction);
+
v->first = NULL;
if (v->type == VEH_TRAIN) v->u.rail.first_engine = INVALID_ENGINE;
}
@@ -232,8 +239,13 @@
FOR_ALL_VEHICLES(v) {
switch (v->type) {
+ case VEH_ROAD:
+ v->cur_image = GetRoadVehImage(v, v->direction);
+ v->u.road.roadtype = HASBIT(EngInfo(v->engine_type)->misc_flags, EF_ROAD_TRAM) ? ROADTYPE_TRAM : ROADTYPE_ROAD;
+ v->u.road.compatible_roadtypes = RoadTypeToRoadTypes(v->u.road.roadtype);
+ break;
+
case VEH_TRAIN: v->cur_image = GetTrainImage(v, v->direction); break;
- case VEH_ROAD: v->cur_image = GetRoadVehImage(v, v->direction); break;
case VEH_SHIP: v->cur_image = GetShipImage(v, v->direction); break;
case VEH_AIRCRAFT:
if (IsNormalAircraft(v)) {
@@ -248,6 +260,8 @@
Vehicle *rotor = shadow->next;
rotor->cur_image = GetRotorImage(v);
}
+
+ UpdateAircraftCache(v);
}
break;
default: break;
@@ -266,7 +280,7 @@
assert(v->orders == NULL);
- v->type = VEH_INVALID;
+ v = new (v) InvalidVehicle();
v->left_coord = INVALID_COORD;
v->first = NULL;
v->next = NULL;
@@ -276,6 +290,8 @@
v->prev_shared = NULL;
v->depot_list = NULL;
v->random_bits = 0;
+ v->group_id = DEFAULT_GROUP;
+
return v;
}
@@ -311,7 +327,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 +343,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 +397,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;
@@ -416,7 +432,7 @@
int old_x = v->left_coord;
int old_y = v->top_coord;
- new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x,y)];
+ new_hash = (x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(x, y)];
old_hash = (old_x == INVALID_COORD) ? NULL : &_vehicle_position_hash[GEN_HASH(old_x, old_y)];
if (old_hash == new_hash) return;
@@ -498,7 +514,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);
@@ -565,9 +581,16 @@
void DestroyVehicle(Vehicle *v)
{
+ if (IsValidStationID(v->last_station_visited)) {
+ GetStation(v->last_station_visited)->loading_vehicles.remove(v);
+ }
+
if (IsEngineCountable(v)) {
GetPlayer(v->owner)->num_engines[v->engine_type]--;
if (v->owner == _local_player) InvalidateAutoreplaceWindow(v->engine_type);
+
+ if (IsValidGroupID(v->group_id)) GetGroup(v->group_id)->num_engines[v->engine_type]--;
+ if (v->IsPrimaryVehicle()) DecreaseGroupNumVehicle(v->group_id);
}
DeleteVehicleNews(v->index, INVALID_STRING_ID);
@@ -586,14 +609,23 @@
/* Now remove any artic part. This will trigger an other
* destroy vehicle, which on his turn can remove any
* other artic parts. */
- if (EngineHasArticPart(v)) DeleteVehicle(v->next);
+ if (v->type == VEH_TRAIN && EngineHasArticPart(v)) DeleteVehicle(v->next);
}
+/**
+ * Deletes all vehicles in a chain.
+ * @param v The first vehicle in the chain.
+ *
+ * @warning This function is not valid for any vehicle containing articulated
+ * parts.
+ */
void DeleteVehicleChain(Vehicle *v)
{
+ assert(v->type != VEH_TRAIN);
+
do {
Vehicle *u = v;
- v = GetNextVehicle(v);
+ v = v->next;
DeleteVehicle(u);
} while (v != NULL);
}
@@ -606,7 +638,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 +646,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;
}
@@ -647,11 +679,9 @@
void CallVehicleTicks()
{
- 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);
}
@@ -659,10 +689,16 @@
_first_veh_in_depot_list = NULL; // now we are sure it's initialized at the start of each tick
+ Station *st;
+ FOR_ALL_STATIONS(st) LoadUnloadStation(st);
+
+ Vehicle *v;
FOR_ALL_VEHICLES(v) {
_vehicle_tick_procs[v->type](v);
switch (v->type) {
+ default: break;
+
case VEH_TRAIN:
case VEH_ROAD:
case VEH_AIRCRAFT:
@@ -679,7 +715,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;
@@ -689,70 +725,6 @@
}
}
-static bool CanFillVehicle_FullLoadAny(Vehicle *v)
-{
- uint32 full = 0, not_full = 0;
- 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
- 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.
- do {
- //Should never happen, but just in case future additions change this
- assert(v->cargo_type<32);
-
- if (v->cargo_cap != 0) {
- uint32 mask = 1 << v->cargo_type;
-
- if (v->cargo_cap == v->cargo_count) {
- full |= mask;
- } else if (GB(ge[v->cargo_type].waiting_acceptance, 0, 12) > 0 ||
- (HASBIT(v->vehicle_flags, VF_CARGO_UNLOADING) && (ge[v->cargo_type].waiting_acceptance & 0x8000))) {
- /* If there is any cargo waiting, or this vehicle is still unloading
- * and the station accepts the cargo, don't leave the station. */
- keep_loading = true;
- } else {
- not_full |= mask;
- }
- }
- } while ((v = v->next) != NULL);
-
- // 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);
-}
-
-bool CanFillVehicle(Vehicle *v)
-{
- TileIndex tile = v->tile;
-
- if (IsTileType(tile, MP_STATION) ||
- (v->type == VEH_SHIP && (
- IsTileType(TILE_ADDXY(tile, 1, 0), MP_STATION) ||
- IsTileType(TILE_ADDXY(tile, -1, 0), MP_STATION) ||
- IsTileType(TILE_ADDXY(tile, 0, 1), MP_STATION) ||
- IsTileType(TILE_ADDXY(tile, 0, -1), MP_STATION) ||
- IsTileType(TILE_ADDXY(tile, -2, 0), MP_STATION)
- ))) {
-
- // 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 {
- if (v->cargo_count != v->cargo_cap) return true;
- } while ((v = v->next) != NULL);
- }
- return false;
-}
-
/** Check if a given engine type can be refitted to a given cargo
* @param engine_type Engine type to check
* @param cid_to check refit to this cargo-type
@@ -764,7 +736,7 @@
}
/** Find the first cargo type that an engine can be refitted to.
- * @param engine Which engine to find cargo for.
+ * @param engine_type Which engine to find cargo for.
* @return A climate dependent cargo type. CT_INVALID is returned if not refittable.
*/
CargoID FindFirstRefittableCargo(EngineID engine_type)
@@ -781,7 +753,7 @@
}
/** Learn the price of refitting a certain engine
-* @param engine Which engine to refit
+* @param engine_type Which engine to refit
* @return Price for refitting
*/
int32 GetRefitCost(EngineID engine_type)
@@ -821,13 +793,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;
@@ -1429,14 +1401,13 @@
v = ForceAllocateSpecialVehicle();
if (v != NULL) {
- v->type = VEH_SPECIAL;
+ v = new (v) SpecialVehicle();
v->subtype = type;
v->x_pos = x;
v->y_pos = y;
v->z_pos = z;
- v->z_height = v->sprite_width = v->sprite_height = 1;
- v->x_offs = v->y_offs = 0;
v->tile = 0;
+ v->UpdateDeltaXY(INVALID_DIR);
v->vehstatus = VS_UNCLICKABLE;
_effect_init_procs[type](v);
@@ -1474,8 +1445,8 @@
(uint)(y -= vp->top) >= (uint)vp->height)
return NULL;
- x = (x << vp->zoom) + vp->virtual_left;
- y = (y << vp->zoom) + vp->virtual_top;
+ x = ScaleByZoom(x, vp->zoom) + vp->virtual_left;
+ y = ScaleByZoom(y, vp->zoom) + vp->virtual_top;
FOR_ALL_VEHICLES(v) {
if ((v->vehstatus & (VS_HIDDEN|VS_UNCLICKABLE)) == 0 &&
@@ -1567,7 +1538,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 +1570,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
@@ -1614,7 +1586,7 @@
int32 return_value = CMD_ERROR;
uint i;
uint stop_command;
- byte vehicle_type = GB(p2, 0, 5);
+ VehicleType vehicle_type = (VehicleType)GB(p2, 0, 5);
bool start_stop = HASBIT(p2, 5);
bool vehicle_list_window = HASBIT(p2, 6);
@@ -1665,10 +1637,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;
@@ -1680,7 +1653,7 @@
int32 cost = 0;
uint i, sell_command, total_number_vehicles;
- byte vehicle_type = GB(p1, 0, 8);
+ VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
switch (vehicle_type) {
case VEH_TRAIN: sell_command = CMD_SELL_RAIL_WAGON; break;
@@ -1717,10 +1690,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;
@@ -1728,8 +1702,7 @@
uint16 engine_count = 0;
uint i, x = 0, y = 0, z = 0;
int32 cost = 0;
- byte vehicle_type = GB(p1, 0, 8);
-
+ VehicleType vehicle_type = (VehicleType)GB(p1, 0, 8);
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
@@ -1784,6 +1757,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
*/
@@ -1791,7 +1765,7 @@
{
Vehicle *v_front, *v;
Vehicle *w_front, *w, *w_rear;
- int cost, total_cost = 0;
+ int32 cost, total_cost = 0;
uint32 build_argument = 2;
if (!IsValidVehicleID(p1)) return CMD_ERROR;
@@ -1814,7 +1788,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 {
@@ -1829,8 +1803,7 @@
v = v_front;
do {
-
- if (IsMultiheaded(v) && !IsTrainEngine(v)) {
+ if (v->type == VEH_TRAIN && IsMultiheaded(v) && !IsTrainEngine(v)) {
/* we build the rear ends of multiheaded trains with the front ones */
continue;
}
@@ -1845,28 +1818,16 @@
if (flags & DC_EXEC) {
w = GetVehicle(_new_vehicle_id);
- Vehicle *w2 = w;
- Vehicle *v2 = v;
- do {
- if (v2->cargo_type != w2->cargo_type || v2->cargo_subtype != w2->cargo_subtype) {
- /* We can't pay for refitting because we can't estimate refitting costs for a vehicle before it's build.
- * If we pay for it anyway, the cost and the estimated cost will not be the same and we will have an assert.
- * We need to check the whole chain if it is a train because some newgrf articulated engines can refit some units only (and not the front) */
- DoCommand(0, w->index, v2->cargo_type | (v2->cargo_subtype << 8), flags, GetCmdRefitVeh(v));
- break; // We learned that the engine in question needed a refit. No need to check anymore
- }
- } while (v->type == VEH_TRAIN && (w2 = w2->next) != NULL && (v2 = v2->next) != NULL);
-
if (v->type == VEH_TRAIN && HASBIT(v->u.rail.flags, VRF_REVERSE_DIRECTION)) {
SETBIT(w->u.rail.flags, VRF_REVERSE_DIRECTION);
}
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,10 +1837,63 @@
} 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;
}
+ if (flags & DC_EXEC) {
+ /* Cloned vehicles belong to the same group */
+ DoCommand(0, v_front->group_id, w_front->index, flags, CMD_ADD_VEHICLE_GROUP);
+ }
+
+
+ /* Take care of refitting. */
+ w = w_front;
+ v = v_front;
+
+ /* Both building and refitting are influenced by newgrf callbacks, which
+ * makes it impossible to accurately estimate the cloning costs. In
+ * particular, it is possible for engines of the same type to be built with
+ * different numbers of articulated parts, so when refitting we have to
+ * loop over real vehicles first, and then the articulated parts of those
+ * vehicles in a different loop. */
+ do {
+ do {
+ if (flags & DC_EXEC) {
+ assert(w != NULL);
+
+ if (w->cargo_type != v->cargo_type || w->cargo_subtype != v->cargo_type) {
+ cost = DoCommand(0, w->index, v->cargo_type | (v->cargo_subtype << 8) | 1U << 16 , flags, GetCmdRefitVeh(v));
+ if (!CmdFailed(cost)) total_cost += cost;
+ }
+
+ if (w->type == VEH_TRAIN && EngineHasArticPart(w)) {
+ w = GetNextArticPart(w);
+ } else {
+ break;
+ }
+ } else {
+ CargoID initial_cargo = GetEngineCargoType(v->engine_type);
+
+ if (v->cargo_type != initial_cargo && initial_cargo != CT_INVALID) {
+ total_cost += GetRefitCost(v->engine_type);
+ }
+ }
+ } while (v->type == VEH_TRAIN && EngineHasArticPart(v) && (v = GetNextArticPart(v)) != NULL);
+
+ if ((flags & DC_EXEC) && v->type == VEH_TRAIN) w = GetNextVehicle(w);
+ } while (v->type == VEH_TRAIN && (v = GetNextVehicle(v)) != NULL);
+
+ /* Since we can't estimate the cost of cloning a vehicle accurately we must
+ * check whether the player has enough money manually. */
+ if (!CheckPlayerHasMoney(total_cost)) {
+ if (flags & DC_EXEC) {
+ /* The vehicle has already been bought, so now it must be sold again. */
+ DoCommand(w_front->tile, w_front->index, 1, flags, GetCmdSellVeh(w_front));
+ }
+ return CMD_ERROR;
+ }
+
/* Set the expense type last as refitting will make the cost go towards
* running costs... */
SET_EXPENSES_TYPE(EXPENSES_NEW_VEHICLES);
@@ -1897,7 +1911,7 @@
/** Generates a list of vehicles inside a depot
* Will enlarge allocated space for the list if they are too small, so it's ok to call with (pointer to NULL array, pointer to uninitised uint16, pointer to 0)
* If one of the lists is not needed (say wagons when finding ships), all the pointers regarding that list should be set to NULL
- * @param Type type of vehicle
+ * @param type Type of vehicle
* @param tile The tile the depot is located in
* @param ***engine_list Pointer to a pointer to an array of vehicles in the depot (old list is freed and a new one is malloced)
* @param *engine_list_length Allocated size of engine_list. Needs to be set to 0 when engine_list points to a NULL array
@@ -1906,7 +1920,7 @@
* @param *wagon_list_length Allocated size of wagon_list. Needs to be set to 0 when wagon_list points to a NULL array
* @param *wagon_count The number of engines stored in the list
*/
-void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count)
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count)
{
Vehicle *v;
@@ -1979,26 +1993,26 @@
* @param length_of_array informs the length allocated for sort_list. This is not the same as the number of vehicles in the list. Needs to be 0 when sort_list is NULL
* @param type type of vehicle
* @param owner PlayerID of owner to generate a list for
-* @param index This parameter got different meanings depending on window_type
- VLW_STATION_LIST: index of station to generate a list for
- VLW_SHARED_ORDERS: index of order to generate a list for
- VLW_STANDARD: not used
- VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for
+* @param index This parameter has different meanings depending on window_type
+
+ - VLW_STATION_LIST: index of station to generate a list for
+ - VLW_SHARED_ORDERS: index of order to generate a list for
-
+
- VLW_STANDARD: not used
-
+
- VLW_DEPOT_LIST: TileIndex of the depot/hangar to make the list for
+ - VLW_GROUP_LIST: index of group to generate a list for
+
* @param window_type tells what kind of window the list is for. Use the VLW flags in vehicle_gui.h
* @return the number of vehicles added to the list
*/
-uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, byte type, PlayerID owner, uint32 index, uint16 window_type)
+uint GenerateVehicleSortList(const Vehicle ***sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type)
{
- const byte subtype = (type != VEH_AIRCRAFT) ? (byte)Train_Front : (byte)AIR_AIRCRAFT;
uint n = 0;
const Vehicle *v;
switch (window_type) {
case VLW_STATION_LIST: {
FOR_ALL_VEHICLES(v) {
- if (v->type == type && (
- (type == VEH_TRAIN && IsFrontEngine(v)) ||
- (type != VEH_TRAIN && v->subtype <= subtype))) {
+ if (v->type == type && v->IsPrimaryVehicle()) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
@@ -2031,9 +2045,7 @@
case VLW_STANDARD: {
FOR_ALL_VEHICLES(v) {
- if (v->type == type && v->owner == owner && (
- (type == VEH_TRAIN && IsFrontEngine(v)) ||
- (type != VEH_TRAIN && v->subtype <= subtype))) {
+ if (v->type == type && v->owner == owner && v->IsPrimaryVehicle()) {
/* TODO find a better estimate on the total number of vehicles for current player */
if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetNumVehicles()/4);
(*sort_list)[n++] = v;
@@ -2044,9 +2056,7 @@
case VLW_DEPOT_LIST: {
FOR_ALL_VEHICLES(v) {
- if (v->type == type && (
- (type == VEH_TRAIN && IsFrontEngine(v)) ||
- (type != VEH_TRAIN && v->subtype <= subtype))) {
+ if (v->type == type && v->IsPrimaryVehicle()) {
const Order *order;
FOR_VEHICLE_ORDERS(v, order) {
@@ -2061,6 +2071,17 @@
break;
}
+ case VLW_GROUP_LIST:
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == type && v->IsPrimaryVehicle() &&
+ v->owner == owner && v->group_id == index) {
+ if (n == *length_of_array) ExtendVehicleListSize(sort_list, length_of_array, GetNumVehicles() / 4);
+
+ (*sort_list)[n++] = v;
+ }
+ }
+ break;
+
default: NOT_REACHED(); break;
}
@@ -2081,10 +2102,10 @@
* @param flags the flags used for DoCommand()
* @param service should the vehicles only get service in the depots
* @param owner PlayerID of owner of the vehicles to send
- * @param VLW_flag tells what kind of list requested the goto depot
+ * @param vlw_flag tells what kind of list requested the goto depot
* @return 0 for success and CMD_ERROR if no vehicle is able to go to depot
*/
-int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
+int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id)
{
const Vehicle **sort_list = NULL;
uint n, i;
@@ -2195,7 +2216,6 @@
if (HASBIT(t.flags, OFB_PART_OF_ORDERS)) {
/* Part of orders */
- if (v->type == VEH_TRAIN) v->u.rail.days_since_order_progr = 0;
v->cur_order_index++;
} else if (HASBIT(t.flags, OFB_HALT_IN_DEPOT)) {
/* Force depot visit */
@@ -2212,7 +2232,7 @@
}
SetDParam(0, v->unitnumber);
- AddNewsItem(string, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ AddNewsItem(string, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
}
}
}
@@ -2220,6 +2240,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 +2274,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 +2371,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));
@@ -2393,7 +2415,7 @@
return _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
}
-UnitID GetFreeUnitNumber(byte type)
+UnitID GetFreeUnitNumber(VehicleType type)
{
UnitID unit, max = 0;
const Vehicle *u;
@@ -2422,16 +2444,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;
}
@@ -2439,31 +2461,19 @@
return unit;
}
-static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v)
+
+const Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v)
{
- SpriteID map = PAL_NONE;
const Player *p = GetPlayer(player);
LiveryScheme scheme = LS_DEFAULT;
CargoID cargo_type = v == NULL ? (CargoID)CT_INVALID : v->cargo_type;
- /* Check if we should use the colour map callback */
- if (HASBIT(EngInfo(engine_type)->callbackmask, CBM_COLOUR_REMAP)) {
- uint16 callback = GetVehicleCallback(CBID_VEHICLE_COLOUR_MAPPING, 0, 0, engine_type, v);
- /* A return value of 0xC000 is stated to "use the default two-color
- * maps" which happens to be the failure action too... */
- if (callback != CALLBACK_FAILED && callback != 0xC000) {
- map = GB(callback, 0, 14);
- /* If bit 14 is set, then the company colours are applied to the
- * map else it's returned as-is. */
- if (!HASBIT(callback, 14)) return map;
- }
- }
-
/* The default livery is always available for use, but its in_use flag determines
* whether any _other_ liveries are in use. */
if (p->livery[LS_DEFAULT].in_use && (_patches.liveries == 2 || (_patches.liveries == 1 && player == _local_player))) {
/* Determine the livery scheme to use */
switch (GetEngine(engine_type)->type) {
+ default: NOT_REACHED();
case VEH_TRAIN: {
const RailVehicleInfo *rvi = RailVehInfo(engine_type);
@@ -2474,14 +2484,15 @@
{
if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type;
if (rvi->railveh_type == RAILVEH_WAGON) {
- if (cargo_type == CT_PASSENGERS || cargo_type == CT_MAIL || cargo_type == CT_VALUABLES) {
+ if (!GetCargo(cargo_type)->is_freight) {
if (parent_engine_type == INVALID_ENGINE) {
scheme = LS_PASSENGER_WAGON_STEAM;
} else {
switch (RailVehInfo(parent_engine_type)->engclass) {
- case 0: scheme = LS_PASSENGER_WAGON_STEAM; break;
- case 1: scheme = LS_PASSENGER_WAGON_DIESEL; break;
- case 2: scheme = LS_PASSENGER_WAGON_ELECTRIC; break;
+ default: NOT_REACHED();
+ case EC_STEAM: scheme = LS_PASSENGER_WAGON_STEAM; break;
+ case EC_DIESEL: scheme = LS_PASSENGER_WAGON_DIESEL; break;
+ case EC_ELECTRIC: scheme = LS_PASSENGER_WAGON_ELECTRIC; break;
}
}
} else {
@@ -2491,9 +2502,10 @@
bool is_mu = HASBIT(_engine_info[engine_type].misc_flags, EF_RAIL_IS_MU);
switch (rvi->engclass) {
- case 0: scheme = LS_STEAM; break;
- case 1: scheme = is_mu ? LS_DMU : LS_DIESEL; break;
- case 2: scheme = is_mu ? LS_EMU : LS_ELECTRIC; break;
+ default: NOT_REACHED();
+ case EC_STEAM: scheme = LS_STEAM; break;
+ case EC_DIESEL: scheme = is_mu ? LS_DMU : LS_DIESEL; break;
+ case EC_ELECTRIC: scheme = is_mu ? LS_EMU : LS_ELECTRIC; break;
}
}
break;
@@ -2508,7 +2520,13 @@
case VEH_ROAD: {
const RoadVehicleInfo *rvi = RoadVehInfo(engine_type);
if (cargo_type == CT_INVALID) cargo_type = rvi->cargo_type;
- scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_BUS : LS_TRUCK;
+ if (HASBIT(EngInfo(engine_type)->misc_flags, EF_ROAD_TRAM)) {
+ /* Tram */
+ scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_PASSENGER_TRAM : LS_FREIGHT_TRAM;
+ } else {
+ /* Bus or truck */
+ scheme = IsCargoInClass(cargo_type, CC_PASSENGERS) ? LS_BUS : LS_TRUCK;
+ }
break;
}
@@ -2535,12 +2553,35 @@
if (!p->livery[scheme].in_use) scheme = LS_DEFAULT;
}
+ return &p->livery[scheme];
+}
+
+
+static SpriteID GetEngineColourMap(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v)
+{
+ SpriteID map = PAL_NONE;
+
+ /* Check if we should use the colour map callback */
+ if (HASBIT(EngInfo(engine_type)->callbackmask, CBM_COLOUR_REMAP)) {
+ uint16 callback = GetVehicleCallback(CBID_VEHICLE_COLOUR_MAPPING, 0, 0, engine_type, v);
+ /* A return value of 0xC000 is stated to "use the default two-color
+ * maps" which happens to be the failure action too... */
+ if (callback != CALLBACK_FAILED && callback != 0xC000) {
+ map = GB(callback, 0, 14);
+ /* If bit 14 is set, then the company colours are applied to the
+ * map else it's returned as-is. */
+ if (!HASBIT(callback, 14)) return map;
+ }
+ }
+
bool twocc = HASBIT(EngInfo(engine_type)->misc_flags, EF_USES_2CC);
if (map == PAL_NONE) map = twocc ? (SpriteID)SPR_2CCMAP_BASE : (SpriteID)PALETTE_RECOLOR_START;
- map += p->livery[scheme].colour1;
- if (twocc) map += p->livery[scheme].colour2 * 16;
+ const Livery *livery = GetEngineLivery(engine_type, player, parent_engine_type, v);
+
+ map += livery->colour1;
+ if (twocc) map += livery->colour2 * 16;
return map;
}
@@ -2562,7 +2603,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),
@@ -2583,13 +2624,9 @@
SLE_VAR(Vehicle, z_pos, SLE_UINT8),
SLE_VAR(Vehicle, direction, SLE_UINT8),
- SLE_VAR(Vehicle, cur_image, SLE_UINT16),
+ SLE_CONDNULL(2, 0, 57),
SLE_VAR(Vehicle, spritenum, SLE_UINT8),
- SLE_VAR(Vehicle, sprite_width, SLE_UINT8),
- SLE_VAR(Vehicle, sprite_height, SLE_UINT8),
- SLE_VAR(Vehicle, z_height, SLE_UINT8),
- SLE_VAR(Vehicle, x_offs, SLE_INT8),
- SLE_VAR(Vehicle, y_offs, SLE_INT8),
+ SLE_CONDNULL(5, 0, 57),
SLE_VAR(Vehicle, engine_type, SLE_UINT16),
SLE_VAR(Vehicle, max_speed, SLE_UINT16),
@@ -2620,17 +2657,17 @@
/* This next line is for version 4 and prior compatibility.. it temporarily reads
type and flags (which were both 4 bits) into type. Later on this is
converted correctly */
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 0, 4),
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, type), SLE_UINT8, 0, 4),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
/* Orders for version 5 and on */
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, type), SLE_UINT8, 5, SL_MAX_VERSION),
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, flags), SLE_UINT8, 5, SL_MAX_VERSION),
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, type), SLE_UINT8, 5, SL_MAX_VERSION),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, flags), SLE_UINT8, 5, SL_MAX_VERSION),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
/* Refit in current order */
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, refit_cargo), SLE_UINT8, 36, SL_MAX_VERSION),
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, refit_subtype), SLE_UINT8, 36, SL_MAX_VERSION),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, refit_cargo), SLE_UINT8, 36, SL_MAX_VERSION),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, refit_subtype), SLE_UINT8, 36, SL_MAX_VERSION),
SLE_REF(Vehicle, orders, REF_ORDER),
@@ -2667,7 +2704,9 @@
SLE_REF(Vehicle, next_shared, REF_VEHICLE),
SLE_REF(Vehicle, prev_shared, REF_VEHICLE),
- // reserve extra space in savegame here. (currently 10 bytes)
+ SLE_CONDVAR(Vehicle, group_id, SLE_UINT16, 60, SL_MAX_VERSION),
+
+ /* reserve extra space in savegame here. (currently 10 bytes) */
SLE_CONDNULL(10, 2, SL_MAX_VERSION),
SLE_END()
@@ -2677,16 +2716,16 @@
static const SaveLoad _train_desc[] = {
SLE_WRITEBYTE(Vehicle, type, VEH_TRAIN, 0), // Train type. VEH_TRAIN in mem, 0 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, crash_anim_pos), SLE_UINT16),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, force_proceed), SLE_UINT8),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, railtype), SLE_UINT8),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRail, track), SLE_UINT8),
-
- SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRail, flags), SLE_UINT8, 2, SL_MAX_VERSION),
- SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleRail, days_since_order_progr), SLE_UINT16, 2, SL_MAX_VERSION),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, crash_anim_pos), SLE_UINT16),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, force_proceed), SLE_UINT8),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, railtype), SLE_UINT8),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, track), SLE_UINT8),
+
+ SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRail, flags), SLE_UINT8, 2, SL_MAX_VERSION),
+ SLE_CONDNULL(2, 2, 59),
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()
@@ -2695,18 +2734,18 @@
static const SaveLoad _roadveh_desc[] = {
SLE_WRITEBYTE(Vehicle, type, VEH_ROAD, 1), // Road type. VEH_ROAD in mem, 1 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, state), SLE_UINT8),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, frame), SLE_UINT8),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, blocked_ctr), SLE_UINT16),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, overtaking), SLE_UINT8),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, overtaking_ctr), SLE_UINT8),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, crashed_ctr), SLE_UINT16),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleRoad, reverse_ctr), SLE_UINT8),
-
- SLE_CONDREFX(offsetof(Vehicle, u) + offsetof(VehicleRoad, slot), REF_ROADSTOPS, 6, SL_MAX_VERSION),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, state), SLE_UINT8),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, frame), SLE_UINT8),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, blocked_ctr), SLE_UINT16),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, overtaking), SLE_UINT8),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, overtaking_ctr), SLE_UINT8),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, crashed_ctr), SLE_UINT16),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, reverse_ctr), SLE_UINT8),
+
+ SLE_CONDREFX(cpp_offsetof(Vehicle, u) + cpp_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)
+ SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleRoad, slot_age), SLE_UINT8, 6, SL_MAX_VERSION),
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2715,9 +2754,9 @@
static const SaveLoad _ship_desc[] = {
SLE_WRITEBYTE(Vehicle, type, VEH_SHIP, 2), // Ship type. VEH_SHIP in mem, 2 in file.
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)
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleShip, state), SLE_UINT8),
+
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2726,17 +2765,17 @@
static const SaveLoad _aircraft_desc[] = {
SLE_WRITEBYTE(Vehicle, type, VEH_AIRCRAFT, 3), // Aircraft type. VEH_AIRCRAFT in mem, 3 in file.
SLE_INCLUDEX(0, INC_VEHICLE_COMMON),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleAir, crashed_counter), SLE_UINT16),
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleAir, pos), SLE_UINT8),
-
- SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, targetairport), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
- SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, targetairport), SLE_UINT16, 5, SL_MAX_VERSION),
-
- SLE_VARX(offsetof(Vehicle, u) + offsetof(VehicleAir, state), SLE_UINT8),
-
- SLE_CONDVARX(offsetof(Vehicle, u) + offsetof(VehicleAir, previous_pos), SLE_UINT8, 2, SL_MAX_VERSION),
-
- // reserve extra space in savegame here. (currently 15 bytes)
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, crashed_counter), SLE_UINT16),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, pos), SLE_UINT8),
+
+ SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, targetairport), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, targetairport), SLE_UINT16, 5, SL_MAX_VERSION),
+
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, state), SLE_UINT8),
+
+ SLE_CONDVARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleAir, previous_pos), SLE_UINT8, 2, SL_MAX_VERSION),
+
+ /* reserve extra space in savegame here. (currently 15 bytes) */
SLE_CONDNULL(15, 2, SL_MAX_VERSION),
SLE_END()
@@ -2757,18 +2796,14 @@
SLE_VAR(Vehicle, z_pos, SLE_UINT8),
SLE_VAR(Vehicle, cur_image, SLE_UINT16),
- SLE_VAR(Vehicle, sprite_width, SLE_UINT8),
- SLE_VAR(Vehicle, sprite_height, SLE_UINT8),
- SLE_VAR(Vehicle, z_height, SLE_UINT8),
- SLE_VAR(Vehicle, x_offs, SLE_INT8),
- SLE_VAR(Vehicle, y_offs, SLE_INT8),
+ SLE_CONDNULL(5, 0, 57),
SLE_VAR(Vehicle, progress, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
- 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)
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleSpecial, unk0), SLE_UINT16),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleSpecial, unk2), SLE_UINT8),
+
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2792,25 +2827,21 @@
SLE_VAR(Vehicle, z_pos, SLE_UINT8),
SLE_VAR(Vehicle, direction, SLE_UINT8),
- SLE_VAR(Vehicle, x_offs, SLE_INT8),
- SLE_VAR(Vehicle, y_offs, SLE_INT8),
- SLE_VAR(Vehicle, sprite_width, SLE_UINT8),
- SLE_VAR(Vehicle, sprite_height, SLE_UINT8),
- SLE_VAR(Vehicle, z_height, SLE_UINT8),
+ SLE_CONDNULL(5, 0, 57),
SLE_VAR(Vehicle, owner, SLE_UINT8),
SLE_VAR(Vehicle, vehstatus, SLE_UINT8),
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
- SLE_CONDVARX(offsetof(Vehicle, current_order) + offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_FILE_U8 | SLE_VAR_U16, 0, 4),
+ SLE_CONDVARX(cpp_offsetof(Vehicle, current_order) + cpp_offsetof(Order, dest), SLE_UINT16, 5, SL_MAX_VERSION),
SLE_VAR(Vehicle, cur_image, SLE_UINT16),
SLE_CONDVAR(Vehicle, age, SLE_FILE_U16 | SLE_VAR_I32, 0, 30),
SLE_CONDVAR(Vehicle, age, SLE_INT32, 31, SL_MAX_VERSION),
SLE_VAR(Vehicle, tick_counter, SLE_UINT8),
- 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)
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleDisaster, image_override), SLE_UINT16),
+ SLE_VARX(cpp_offsetof(Vehicle, u) + cpp_offsetof(VehicleDisaster, unk2), SLE_UINT16),
+
+ /* reserve extra space in savegame here. (currently 16 bytes) */
SLE_CONDNULL(16, 2, SL_MAX_VERSION),
SLE_END()
@@ -2826,18 +2857,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;
@@ -2852,6 +2883,17 @@
v = GetVehicle(index);
SlObject(v, (SaveLoad*)_veh_descs[SlReadByte()]);
+ switch (v->type) {
+ case VEH_TRAIN: v = new (v) Train(); break;
+ case VEH_ROAD: v = new (v) RoadVehicle(); break;
+ case VEH_SHIP: v = new (v) Ship(); break;
+ case VEH_AIRCRAFT: v = new (v) Aircraft(); break;
+ case VEH_SPECIAL: v = new (v) SpecialVehicle(); break;
+ case VEH_DISASTER: v = new (v) DisasterVehicle(); break;
+ case VEH_INVALID: v = new (v) InvalidVehicle(); break;
+ default: NOT_REACHED();
+ }
+
/* Old savegames used 'last_station_visited = 0xFF' */
if (CheckSavegameVersion(5) && v->last_station_visited == 0xFF)
v->last_station_visited = INVALID_STATION;
@@ -2862,6 +2904,9 @@
v->current_order.flags = (v->current_order.type & 0xF0) >> 4;
v->current_order.type.m_val &= 0x0F;
}
+
+ /* Advanced vehicle lists got added */
+ if (CheckSavegameVersion(60)) v->group_id = DEFAULT_GROUP;
}
/* Check for shared order-lists (we now use pointers for that) */
@@ -2889,13 +2934,80 @@
void Vehicle::BeginLoading()
{
assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
+
+ if (this->current_order.type == OT_GOTO_STATION &&
+ this->current_order.dest == this->last_station_visited) {
+ /* Arriving at the ordered station.
+ * Keep the load/unload flags, as we (obviously) still need them. */
+ this->current_order.flags &= OF_FULL_LOAD | OF_UNLOAD | OF_TRANSFER;
+
+ /* Furthermore add the Non Stop flag to mark that this station
+ * is the actual destination of the vehicle, which is (for example)
+ * necessary to be known for HandleTrainLoading to determine
+ * whether the train is lost or not; not marking a train lost
+ * that arrives at random stations is bad. */
+ this->current_order.flags |= OF_NON_STOP;
+ } else {
+ /* This is just an unordered intermediate stop */
+ this->current_order.flags = 0;
+ }
+
current_order.type = OT_LOADING;
+ GetStation(this->last_station_visited)->loading_vehicles.push_back(this);
+
+ SET_EXPENSES_TYPE(this->GetExpenseType(true));
+ VehiclePayment(this);
+
+ InvalidateWindow(this->GetVehicleListWindowClass(), this->owner);
+ InvalidateWindowWidget(WC_VEHICLE_VIEW, this->index, STATUS_BAR);
+ InvalidateWindow(WC_VEHICLE_DETAILS, this->index);
+ InvalidateWindow(WC_STATION_VIEW, this->last_station_visited);
+
+ GetStation(this->last_station_visited)->MarkTilesDirty();
+ this->MarkDirty();
}
void Vehicle::LeaveStation()
{
- assert(IsTileType(tile, MP_STATION) || type == VEH_SHIP);
assert(current_order.type == OT_LOADING);
current_order.type = OT_LEAVESTATION;
current_order.flags = 0;
+ GetStation(this->last_station_visited)->loading_vehicles.remove(this);
}
+
+
+void Vehicle::HandleLoading(bool mode)
+{
+ switch (this->current_order.type) {
+ case OT_LOADING: {
+ /* Not the first call for this tick, or still loading */
+ if (mode || !HASBIT(this->vehicle_flags, VF_LOADING_FINISHED)) return;
+
+ this->PlayLeaveStationSound();
+
+ Order b = this->current_order;
+ this->LeaveStation();
+
+ /* If this was not the final order, don't remove it from the list. */
+ if (!(b.flags & OF_NON_STOP)) return;
+ break;
+ }
+
+ case OT_DUMMY: break;
+
+ default: return;
+ }
+
+ this->cur_order_index++;
+ InvalidateVehicleOrder(this);
+}
+
+
+void SpecialVehicle::UpdateDeltaXY(Direction direction)
+{
+ this->x_offs = 0;
+ this->y_offs = 0;
+ this->sprite_width = 1;
+ this->sprite_height = 1;
+ this->z_height = 1;
+}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/vehicle.h
--- a/src/vehicle.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/vehicle.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,11 +1,14 @@
/* $Id$ */
+/** @vehicle.h */
+
#ifndef VEHICLE_H
#define VEHICLE_H
#include "oldpool.h"
#include "order.h"
#include "rail.h"
+#include "road.h"
/** The returned bits of VehicleEnterTile. */
enum VehicleEnterTileStatus {
@@ -62,15 +65,18 @@
RVSB_ROAD_STOP_TRACKDIR_MASK = 0x09 ///< Only bits 0 and 3 are used to encode the trackdir for road stops
};
-enum {
+enum VehicleType {
VEH_TRAIN,
VEH_ROAD,
VEH_SHIP,
VEH_AIRCRAFT,
VEH_SPECIAL,
VEH_DISASTER,
+ VEH_END,
VEH_INVALID = 0xFF,
-} ;
+};
+template <> struct EnumPropsT : MakeEnumPropsT {};
+typedef TinyEnumT VehicleTypeByte;
enum VehStatus {
VS_HIDDEN = 0x01,
@@ -106,15 +112,14 @@
struct VehicleRail {
uint16 last_speed; // NOSAVE: only used in UI
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 +132,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,32 +143,36 @@
byte flags;
- // Link between the two ends of a multiheaded engine
+ /* Link between the two ends of a multiheaded engine */
Vehicle *other_multiheaded_part;
+
+ /* Cached wagon override spritegroup */
+ const struct SpriteGroup *cached_override;
};
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,
};
struct VehicleAir {
uint16 crashed_counter;
+ uint16 cached_max_speed;
byte pos;
byte previous_pos;
StationID targetairport;
@@ -171,7 +180,7 @@
};
struct VehicleRoad {
- byte state; /// @see RoadVehicleStates
+ byte state; ///< @see RoadVehicleStates
byte frame;
uint16 blocked_ctr;
byte overtaking;
@@ -180,6 +189,9 @@
byte reverse_ctr;
struct RoadStop *slot;
byte slot_age;
+
+ RoadType roadtype;
+ RoadTypes compatible_roadtypes;
};
struct VehicleSpecial {
@@ -198,7 +210,7 @@
struct Vehicle {
- byte type; // type, ie roadven,train,ship,aircraft,special
+ VehicleTypeByte type; ///< Type of vehicle
byte subtype; // subtype (Filled with values from EffectVehicles/TrainSubTypes/AircraftSubTypes)
VehicleID index; // NOSAVE: Index in vehicle array
@@ -210,7 +222,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 +243,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 +281,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;
@@ -302,6 +314,8 @@
TileIndex cargo_loaded_at_xy; ///< tile index where feeder cargo was loaded
uint32 value;
+ GroupID group_id; ///< Index of group Pool array
+
union {
VehicleRail rail;
VehicleAir air;
@@ -313,6 +327,152 @@
void BeginLoading();
void LeaveStation();
+
+ /**
+ * Handle the loading of the vehicle; when not it skips through dummy
+ * orders and does nothing in all other cases.
+ * @param mode is the non-first call for this vehicle in this tick?
+ */
+ void HandleLoading(bool mode = false);
+
+ /**
+ * An overriden version of new, so you can use the vehicle instance
+ * instead of a newly allocated piece of memory.
+ * @param size the size of the variable (unused)
+ * @param v the vehicle to use as 'storage' backend
+ * @return the memory that is 'allocated'
+ */
+ void* operator new(size_t size, Vehicle *v) { return v; }
+
+ /**
+ * 'Free' the memory allocated by the overriden new.
+ * @param p the memory to 'free'
+ * @param v the vehicle that was given to 'new' on creation.
+ * @note This function isn't used (at the moment) and only added
+ * to please some compiler.
+ */
+ void operator delete(void *p, Vehicle *v) {}
+
+ /**
+ * 'Free' the memory allocated by the overriden new.
+ * @param p the memory to 'free'
+ * @note This function isn't used (at the moment) and only added
+ * as the above function was needed to please some compiler
+ * which made it necessary to add this to please yet
+ * another compiler...
+ */
+ void operator delete(void *p) {}
+
+ /** We want to 'destruct' the right class. */
+ virtual ~Vehicle() {}
+
+ /**
+ * Get a string 'representation' of the vehicle type.
+ * @return the string representation.
+ */
+ virtual const char* GetTypeString() const = 0;
+
+ /**
+ * Marks the vehicles to be redrawn and updates cached variables
+ */
+ virtual void MarkDirty() {}
+
+ /**
+ * Updates the x and y offsets and the size of the sprite used
+ * for this vehicle.
+ * @param direction the direction the vehicle is facing
+ */
+ virtual void UpdateDeltaXY(Direction direction) {}
+
+ /**
+ * Sets the expense type associated to this vehicle type
+ * @param income whether this is income or (running) expenses of the vehicle
+ */
+ virtual ExpensesType GetExpenseType(bool income) const { return EXPENSES_OTHER; }
+
+ /**
+ * Invalidates the vehicle list window of this type of vehicle
+ */
+ virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
+
+ /**
+ * Play the sound associated with leaving the station
+ */
+ virtual void PlayLeaveStationSound() const {}
+
+ /**
+ * Whether this is the primary vehicle in the chain.
+ */
+ virtual bool IsPrimaryVehicle() const { return false; }
+
+ /**
+ * Whether this vehicle understands the concept of a front engine, so
+ * basically, if GetFirstVehicleInChain() can be called for it.
+ */
+ virtual bool HasFront() const { return false; }
+};
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ * v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ *
+ * A special vehicle is one of the following:
+ * - smoke
+ * - electric sparks for trains
+ * - explosions
+ * - bulldozer (road works)
+ * - bubbles (industry)
+ */
+struct SpecialVehicle : public Vehicle {
+ /** Initializes the Vehicle to a special vehicle */
+ SpecialVehicle() { this->type = VEH_SPECIAL; }
+
+ /** We want to 'destruct' the right class. */
+ virtual ~SpecialVehicle() {}
+
+ const char *GetTypeString() const { return "special vehicle"; }
+ void UpdateDeltaXY(Direction direction);
+};
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ * v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct DisasterVehicle : public Vehicle {
+ /** Initializes the Vehicle to a disaster vehicle */
+ DisasterVehicle() { this->type = VEH_DISASTER; }
+
+ /** We want to 'destruct' the right class. */
+ virtual ~DisasterVehicle() {}
+
+ const char *GetTypeString() const { return "disaster vehicle"; }
+ void UpdateDeltaXY(Direction direction);
+};
+
+/**
+ * This class 'wraps' Vehicle; you do not actually instantiate this class.
+ * You create a Vehicle using AllocateVehicle, so it is added to the pool
+ * and you reinitialize that to a Train using:
+ * v = new (v) Train();
+ *
+ * As side-effect the vehicle type is set correctly.
+ */
+struct InvalidVehicle : public Vehicle {
+ /** Initializes the Vehicle to a invalid vehicle */
+ InvalidVehicle() { this->type = VEH_INVALID; }
+
+ /** We want to 'destruct' the right class. */
+ virtual ~InvalidVehicle() {}
+
+ const char *GetTypeString() const { return "invalid vehicle"; }
};
#define is_custom_sprite(x) (x >= 0xFD)
@@ -342,7 +502,6 @@
byte VehicleRandomBits();
void ResetVehiclePosHash();
-bool CanFillVehicle(Vehicle *v);
bool CanRefitTo(EngineID engine_type, CargoID cid_to);
CargoID FindFirstRefittableCargo(EngineID engine_type);
int32 GetRefitCost(EngineID engine_type);
@@ -380,9 +539,7 @@
void ShowAircraftViewWindow(const Vehicle* v);
-UnitID GetFreeUnitNumber(byte type);
-
-int LoadUnloadVehicle(Vehicle *v, bool just_arrived);
+UnitID GetFreeUnitNumber(VehicleType type);
void TrainConsistChanged(Vehicle *v);
void TrainPowerChanged(Vehicle *v);
@@ -392,9 +549,9 @@
bool VehicleNeedsService(const Vehicle *v);
-uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, byte type, PlayerID owner, uint32 index, uint16 window_type);
-void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
-int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
+uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, VehicleType type, PlayerID owner, uint32 index, uint16 window_type);
+void BuildDepotVehicleList(VehicleType type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
+int32 SendAllVehiclesToDepot(VehicleType type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
bool IsVehicleInDepot(const Vehicle *v);
void VehicleEnterDepot(Vehicle *v);
@@ -405,7 +562,7 @@
/* Flags to add to p2 for goto depot commands */
/* Note: bits 8-10 are used for VLW flags */
enum {
- DEPOT_SERVICE = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
+ DEPOT_SERVICE = (1 << 0), // The vehicle will leave the depot right after arrival (serivce only)
DEPOT_MASS_SEND = (1 << 1), // Tells that it's a mass send to depot command (type in VLW flag)
DEPOT_DONT_CANCEL = (1 << 2), // Don't cancel current goto depot command if any
DEPOT_LOCATE_HANGAR = (1 << 3), // Find another airport if the target one lacks a hangar
@@ -467,10 +624,10 @@
static inline void DeleteVehicle(Vehicle *v)
{
DestroyVehicle(v);
- v->type = VEH_INVALID;
+ v = new (v) InvalidVehicle();
}
-static inline bool IsPlayerBuildableVehicleType(byte type)
+static inline bool IsPlayerBuildableVehicleType(VehicleType type)
{
switch (type) {
case VEH_TRAIN:
@@ -478,8 +635,9 @@
case VEH_SHIP:
case VEH_AIRCRAFT:
return true;
+
+ default: return false;
}
- return false;
}
static inline bool IsPlayerBuildableVehicleType(const Vehicle *v)
@@ -492,7 +650,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 +671,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 +688,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,12 +700,14 @@
return u;
}
-// NOSAVE: Return values from various commands.
+/* NOSAVE: Return values from various commands. */
VARDEF VehicleID _new_vehicle_id;
VARDEF uint16 _returned_refit_capacity;
static const VehicleID INVALID_VEHICLE = 0xFFFF;
+const struct Livery *GetEngineLivery(EngineID engine_type, PlayerID player, EngineID parent_engine_type, const Vehicle *v);
+
/**
* Get the colour map for an engine. This used for unbuilt engines in the user interface.
* @param engine_type ID of engine
@@ -566,7 +733,7 @@
extern const uint32 _send_to_depot_proc_table[];
/* Functions to find the right command for certain vehicle type */
-static inline uint32 GetCmdBuildVeh(byte type)
+static inline uint32 GetCmdBuildVeh(VehicleType type)
{
return _veh_build_proc_table[type];
}
@@ -576,7 +743,7 @@
return GetCmdBuildVeh(v->type);
}
-static inline uint32 GetCmdSellVeh(byte type)
+static inline uint32 GetCmdSellVeh(VehicleType type)
{
return _veh_sell_proc_table[type];
}
@@ -586,7 +753,7 @@
return GetCmdSellVeh(v->type);
}
-static inline uint32 GetCmdRefitVeh(byte type)
+static inline uint32 GetCmdRefitVeh(VehicleType type)
{
return _veh_refit_proc_table[type];
}
@@ -596,7 +763,7 @@
return GetCmdRefitVeh(v->type);
}
-static inline uint32 GetCmdSendToDepot(byte type)
+static inline uint32 GetCmdSendToDepot(VehicleType type)
{
return _send_to_depot_proc_table[type];
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/vehicle_gui.cpp
--- a/src/vehicle_gui.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/vehicle_gui.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file vehicle_gui.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "debug.h"
@@ -29,6 +31,7 @@
#include "depot.h"
#include "helpers.hpp"
#include "cargotype.h"
+#include "group.h"
struct Sorting {
Listing aircraft;
@@ -39,15 +42,6 @@
static Sorting _sorting;
-struct vehiclelist_d {
- const Vehicle** sort_list; // List of vehicles (sorted)
- Listing *_sorting; // pointer to the appropiate subcategory of _sorting
- uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
- byte vehicle_type; // The vehicle type that is sorted
- list_d l; // General list struct
-};
-assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
-
static bool _internal_sort_order; // descending/ascending
typedef int CDECL VehicleSortListingTypeFunction(const void*, const void*);
@@ -76,7 +70,7 @@
&VehicleValueSorter,
};
-static const StringID _vehicle_sort_listing[] = {
+const StringID _vehicle_sort_listing[] = {
STR_SORT_BY_NUMBER,
STR_SORT_BY_DROPDOWN_NAME,
STR_SORT_BY_AGE,
@@ -132,7 +126,7 @@
}
}
-static void BuildVehicleList(vehiclelist_d* vl, PlayerID owner, uint16 index, uint16 window_type)
+void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type)
{
if (!(vl->l.flags & VL_REBUILD)) return;
@@ -144,7 +138,7 @@
vl->l.flags |= VL_RESORT;
}
-static void SortVehicleList(vehiclelist_d *vl)
+void SortVehicleList(vehiclelist_d *vl)
{
if (!(vl->l.flags & VL_RESORT)) return;
@@ -162,12 +156,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) {
@@ -277,8 +271,11 @@
/** Draw the list of available refit options for a consist.
* Draw the list and highlight the selected refit option (if any)
- * @param *v first vehicle in consist to get the refit-options of
+ * @param *list first vehicle in consist to get the refit-options of
* @param sel selected refit cargo-type in the window
+ * @param pos position of the selected item in caller widow
+ * @param rows number of rows(capacity) in caller window
+ * @param delta step height in caller window
* @return the refit option that is hightlighted, NULL if none
*/
static RefitOption *DrawVehicleRefitWindow(const RefitList *list, int sel, uint pos, uint rows, uint delta)
@@ -338,48 +335,49 @@
SetDParam(1, v->unitnumber);
DrawWindowWidgets(w);
- WP(w,refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height);
+ WP(w, refit_d).cargo = DrawVehicleRefitWindow(WP(w, refit_d).list, WP(w, refit_d).sel, w->vscroll.pos, w->vscroll.cap, w->resize.step_height);
- if (WP(w,refit_d).cargo != NULL) {
+ if (WP(w, refit_d).cargo != NULL) {
int32 cost;
- cost = DoCommand(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8,
+ cost = DoCommand(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8,
DC_QUERY_COST, GetCmdRefitVeh(GetVehicle(w->window_number)->type));
if (!CmdFailed(cost)) {
- SetDParam(0, WP(w,refit_d).cargo->cargo);
+ SetDParam(0, WP(w, refit_d).cargo->cargo);
SetDParam(1, _returned_refit_capacity);
SetDParam(2, cost);
DrawString(2, w->widget[5].top + 1, STR_9840_NEW_CAPACITY_COST_OF_REFIT, 0);
}
}
- } break;
+ } break;
case WE_CLICK:
switch (e->we.click.widget) {
case 3: { // listbox
int y = e->we.click.pt.y - w->widget[3].top;
if (y >= 0) {
- WP(w,refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
+ WP(w, refit_d).sel = (y / (int)w->resize.step_height) + w->vscroll.pos;
SetWindowDirty(w);
}
} break;
case 6: // refit button
- if (WP(w,refit_d).cargo != NULL) {
+ if (WP(w, refit_d).cargo != NULL) {
const Vehicle *v = GetVehicle(w->window_number);
if (WP(w, refit_d).order == INVALID_VEH_ORDER_ID) {
int command = 0;
switch (v->type) {
+ default: NOT_REACHED();
case VEH_TRAIN: command = CMD_REFIT_RAIL_VEHICLE | CMD_MSG(STR_RAIL_CAN_T_REFIT_VEHICLE); break;
case VEH_ROAD: command = CMD_REFIT_ROAD_VEH | CMD_MSG(STR_REFIT_ROAD_VEHICLE_CAN_T); break;
case VEH_SHIP: command = CMD_REFIT_SHIP | CMD_MSG(STR_9841_CAN_T_REFIT_SHIP); break;
case VEH_AIRCRAFT: command = CMD_REFIT_AIRCRAFT | CMD_MSG(STR_A042_CAN_T_REFIT_AIRCRAFT); break;
}
- if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
+ if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8, NULL, command)) DeleteWindow(w);
} else {
- if (DoCommandP(v->tile, v->index, WP(w,refit_d).cargo->cargo | WP(w,refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) DeleteWindow(w);
+ if (DoCommandP(v->tile, v->index, WP(w, refit_d).cargo->cargo | WP(w, refit_d).cargo->subtype << 8 | WP(w, refit_d).order << 16, NULL, CMD_ORDER_REFIT)) DeleteWindow(w);
}
}
break;
@@ -413,7 +411,7 @@
static const WindowDesc _vehicle_refit_desc = {
WDP_AUTO, WDP_AUTO, 240, 174,
- WC_VEHICLE_REFIT,WC_VEHICLE_VIEW,
+ WC_VEHICLE_REFIT, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
_vehicle_refit_widgets,
VehicleRefitWndProc,
@@ -421,6 +419,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 +465,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 +484,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 +528,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)
@@ -742,16 +741,6 @@
}
}
-/*
- * Start of functions regarding vehicle list windows
- */
-
-enum {
- PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
- PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
- PLY_WND_PRC__SIZE_OF_ROW_BIG = 36,
-};
-
enum VehicleListWindowWidgets {
VLW_WIDGET_CLOSEBOX = 0,
VLW_WIDGET_CAPTION,
@@ -802,7 +791,7 @@
uint16 window_type = w->window_number & VLW_MASK;
PlayerID player = (PlayerID)GB(w->window_number, 0, 8);
- vl->vehicle_type = GB(w->window_number, 11, 5);
+ vl->vehicle_type = (VehicleType)GB(w->window_number, 11, 5);
vl->length_of_sort_list = 0;
vl->sort_list = NULL;
w->caption_color = player;
@@ -916,10 +905,10 @@
vl->l.flags = VL_REBUILD | (vl->_sorting->order ? VL_DESC : VL_NONE);
vl->l.sort_type = vl->_sorting->criteria;
vl->sort_list = NULL;
- vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
+ vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
}
-static void DrawSmallOrderList(const Vehicle *v, int x, int y)
+void DrawSmallOrderList(const Vehicle *v, int x, int y)
{
const Order *order;
int sel, i = 0;
@@ -1134,13 +1123,13 @@
DoCommandP(0, GB(w->window_number, 16, 16), (w->window_number & VLW_MASK) | (1 << 6) | (e->we.click.widget == VLW_WIDGET_START_ALL ? (1 << 5) : 0) | vl->vehicle_type, NULL, CMD_MASS_START_STOP);
break;
}
- } break;
+ } break;
case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
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;
@@ -1229,7 +1218,7 @@
PlayerVehWndProc
};
-static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, byte vehicle_type, uint16 unique_number)
+static void ShowVehicleListWindowLocal(PlayerID player, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number)
{
Window *w;
WindowNumber num;
@@ -1266,9 +1255,13 @@
}
}
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type)
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type)
{
- ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
+ if (player == _local_player && _patches.advanced_vehicle_list) {
+ ShowPlayerGroup(player, vehicle_type);
+ } else {
+ ShowVehicleListWindowLocal(player, VLW_STANDARD, vehicle_type, 0);
+ }
}
void ShowVehicleListWindow(const Vehicle *v)
@@ -1277,12 +1270,12 @@
ShowVehicleListWindowLocal(v->owner, VLW_SHARED_ORDERS, v->type, v->orders->index);
}
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station)
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station)
{
ShowVehicleListWindowLocal(player, VLW_STATION_LIST, vehicle_type, station);
}
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile)
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile)
{
uint16 depot_airport_index;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/vehicle_gui.h
--- a/src/vehicle_gui.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/vehicle_gui.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file vehicle_gui.h */
+
#ifndef VEHICLE_GUI_H
#define VEHICLE_GUI_H
@@ -13,21 +15,35 @@
/* sorter stuff */
void RebuildVehicleLists();
void ResortVehicleLists();
+void SortVehicleList(vehiclelist_d *vl);
+void BuildVehicleList(vehiclelist_d *vl, PlayerID owner, uint16 index, uint16 window_type);
#define PERIODIC_RESORT_DAYS 10
+extern const StringID _vehicle_sort_listing[];
+
+/* Start of functions regarding vehicle list windows */
+enum {
+ PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
+ PLY_WND_PRC__SIZE_OF_ROW_TINY = 13,
+ PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
+ PLY_WND_PRC__SIZE_OF_ROW_BIG = 36,
+ PLY_WND_PRC__SIZE_OF_ROW_BIG2 = 39,
+};
+
/* Vehicle List Window type flags */
enum {
VLW_STANDARD = 0 << 8,
VLW_SHARED_ORDERS = 1 << 8,
VLW_STATION_LIST = 2 << 8,
VLW_DEPOT_LIST = 3 << 8,
+ VLW_GROUP_LIST = 4 << 8,
VLW_MASK = 0x700,
};
static inline bool ValidVLWFlags(uint16 flags)
{
- return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST);
+ return (flags == VLW_STANDARD || flags == VLW_SHARED_ORDERS || flags == VLW_STATION_LIST || flags == VLW_DEPOT_LIST || flags == VLW_GROUP_LIST);
}
void PlayerVehWndProc(Window *w, WindowEvent *e);
@@ -39,7 +55,7 @@
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection);
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
-void ShowBuildVehicleWindow(TileIndex tile, byte type);
+void ShowBuildVehicleWindow(TileIndex tile, VehicleType type);
void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
@@ -47,11 +63,13 @@
uint ShowRefitOptionsList(int x, int y, uint w, EngineID engine);
void ShowVehicleListWindow(const Vehicle *v);
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type);
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type, StationID station);
-void ShowVehicleListWindow(PlayerID player, byte vehicle_type, TileIndex depot_tile);
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type);
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, StationID station);
+void ShowVehicleListWindow(PlayerID player, VehicleType vehicle_type, TileIndex depot_tile);
-void ShowReplaceVehicleWindow(byte vehicletype);
+void ShowReplaceVehicleWindow(VehicleType vehicletype);
+void DrawSmallOrderList(const Vehicle *v, int x, int y);
+void ShowReplaceGroupVehicleWindow(GroupID group, VehicleType veh);
static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
{
@@ -64,7 +82,7 @@
}
}
-static inline uint GetVehicleListHeight(byte type)
+static inline uint GetVehicleListHeight(VehicleType type)
{
return (type == VEH_TRAIN || type == VEH_ROAD) ? 14 : 24;
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/video/dedicated_v.cpp
--- a/src/video/dedicated_v.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/video/dedicated_v.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -112,7 +112,7 @@
#endif
-static void *_dedicated_video_mem;
+static Pixel *_dedicated_video_mem;
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm);
extern void SwitchMode(int new_mode);
@@ -122,7 +122,7 @@
{
_screen.width = _screen.pitch = _cur_resolution[0];
_screen.height = _cur_resolution[1];
- _dedicated_video_mem = malloc(_cur_resolution[0]*_cur_resolution[1]);
+ _dedicated_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel));
SetDebugString("net=6");
@@ -283,7 +283,7 @@
next_tick = cur_ticks + 30;
GameLoop();
- _screen.dst_ptr = (Pixel*)_dedicated_video_mem;
+ _screen.dst_ptr = _dedicated_video_mem;
UpdateWindows();
}
CSleep(1);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/video/null_v.cpp
--- a/src/video/null_v.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/video/null_v.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -7,13 +7,13 @@
#include "../window.h"
#include "null_v.h"
-static void* _null_video_mem = NULL;
+static Pixel *_null_video_mem = NULL;
static const char* NullVideoStart(const char* const* parm)
{
_screen.width = _screen.pitch = _cur_resolution[0];
_screen.height = _cur_resolution[1];
- _null_video_mem = malloc(_cur_resolution[0] * _cur_resolution[1]);
+ _null_video_mem = (Pixel *)malloc(_cur_resolution[0] * _cur_resolution[1] * sizeof(Pixel));
return NULL;
}
@@ -27,7 +27,7 @@
for (i = 0; i < 1000; i++) {
GameLoop();
- _screen.dst_ptr = (Pixel*)_null_video_mem;
+ _screen.dst_ptr = _null_video_mem;
UpdateWindows();
}
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/video/sdl_v.cpp
--- a/src/video/sdl_v.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/video/sdl_v.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -195,7 +195,7 @@
_screen.width = newscreen->w;
_screen.height = newscreen->h;
- _screen.pitch = newscreen->pitch;
+ _screen.pitch = newscreen->pitch / sizeof(Pixel);
_sdl_screen = newscreen;
InitPalette();
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/video/win32_v.cpp
--- a/src/video/win32_v.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/video/win32_v.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -45,7 +45,7 @@
LOGPALETTE *pal;
uint i;
- pal = (LOGPALETTE*)alloca(sizeof(LOGPALETTE) + (256-1) * sizeof(PALETTEENTRY));
+ pal = (LOGPALETTE*)alloca(sizeof(LOGPALETTE) + (256 - 1) * sizeof(PALETTEENTRY));
pal->palVersion = 0x300;
pal->palNumEntries = 256;
@@ -212,6 +212,7 @@
static LRESULT CALLBACK WndProcGdi(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static uint32 keycode = 0;
+ static bool console = false;
switch (msg) {
case WM_CREATE:
@@ -363,12 +364,23 @@
}
#endif /* UNICODE */
+ case WM_DEADCHAR:
+ console = GB(lParam, 16, 8) == 41;
+ return 0;
+
case WM_CHAR: {
/* Silently drop all non-text messages as those were handled by WM_KEYDOWN */
if (wParam < VK_SPACE) return 0;
uint scancode = GB(lParam, 16, 8);
uint charcode = wParam;
+ /* If the console key is a dead-key, we need to press it twice to get a WM_CHAR message.
+ * But we then get two WM_CHAR messages, so ignore the first one */
+ if (console && scancode == 41) {
+ console = false;
+ return 0;
+ }
+
#if !defined(UNICODE)
wchar_t w;
int len = MultiByteToWideChar(_codepage, 0, (char*)&charcode, 1, &w, 1);
@@ -653,13 +665,13 @@
_wnd.alloced_bits = NULL;
}
- bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
- memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD)*256);
+ bi = (BITMAPINFO*)alloca(sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
+ memset(bi, 0, sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 256);
bi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
if (_wnd.double_size) {
w = ALIGN(w, 4);
- _wnd.alloced_bits = _wnd.buffer_bits = (Pixel*)malloc(w * h);
+ _wnd.alloced_bits = _wnd.buffer_bits = (Pixel *)malloc(w * h * sizeof(Pixel));
w *= 2;
h *= 2;
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/viewport.cpp
--- a/src/viewport.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/viewport.cpp Sat Jun 02 19:59:29 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"
@@ -26,7 +27,9 @@
#define VIEWPORT_DRAW_MEM (65536 * 2)
-// XXX - maximum viewports is maximum windows - 2 (main toolbar + status bar)
+ZoomLevel _saved_scrollpos_zoom;
+
+/* 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);
@@ -92,8 +95,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 {
@@ -143,7 +146,7 @@
}
void AssignWindowViewport(Window *w, int x, int y,
- int width, int height, uint32 follow_flags, byte zoom)
+ int width, int height, uint32 follow_flags, ZoomLevel zoom)
{
ViewPort *vp;
Point pt;
@@ -162,8 +165,8 @@
vp->zoom = zoom;
- vp->virtual_width = width << zoom;
- vp->virtual_height = height << zoom;
+ vp->virtual_width = ScaleByZoom(width, zoom);
+ vp->virtual_height = ScaleByZoom(height, zoom);
if (follow_flags & 0x80000000) {
const Vehicle *veh;
@@ -181,6 +184,9 @@
WP(w, vp_d).scrollpos_x = pt.x;
WP(w, vp_d).scrollpos_y = pt.y;
+ WP(w, vp_d).dest_scrollpos_x = pt.x;
+ WP(w, vp_d).dest_scrollpos_y = pt.y;
+
w->viewport = vp;
vp->virtual_left = 0;//pt.x;
vp->virtual_top = 0;//pt.y;
@@ -267,10 +273,10 @@
vp->virtual_left = x;
vp->virtual_top = y;
- old_left >>= vp->zoom;
- old_top >>= vp->zoom;
- x >>= vp->zoom;
- y >>= vp->zoom;
+ old_left = UnScaleByZoom(old_left, vp->zoom);
+ old_top = UnScaleByZoom(old_top, vp->zoom);
+ x = UnScaleByZoom(x, vp->zoom);
+ y = UnScaleByZoom(y, vp->zoom);
old_left -= x;
old_top -= y;
@@ -331,8 +337,8 @@
return pt;
}
- x = ((x << vp->zoom) + vp->virtual_left) >> 2;
- y = ((y << vp->zoom) + vp->virtual_top) >> 1;
+ x = (ScaleByZoom(x, vp->zoom) + vp->virtual_left) >> 2;
+ y = (ScaleByZoom(y, vp->zoom) + vp->virtual_top) >> 1;
a = y-x;
b = y+x;
@@ -398,16 +404,16 @@
/** 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 */
void HandleZoomMessage(Window *w, const ViewPort *vp, byte widget_zoom_in, byte widget_zoom_out)
{
- SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == 0);
+ SetWindowWidgetDisabledState(w, widget_zoom_in, vp->zoom == ZOOM_LVL_MIN);
InvalidateWidget(w, widget_zoom_in);
- SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == 2);
+ SetWindowWidgetDisabledState(w, widget_zoom_out, vp->zoom == ZOOM_LVL_MAX);
InvalidateWidget(w, widget_zoom_out);
}
@@ -439,7 +445,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;
@@ -494,12 +500,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;
}
@@ -647,16 +653,16 @@
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) {
@@ -669,15 +675,15 @@
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;
if (ti->tileh == SLOPE_STEEP_N) z += TILE_HEIGHT;
}
- DrawGroundSpriteAt(_cur_dpi->zoom != 2 ? SPR_DOT : SPR_DOT_SMALL, PAL_NONE, ti->x, ti->y, z);
+ DrawGroundSpriteAt(_cur_dpi->zoom <= ZOOM_LVL_DETAIL ? 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;
@@ -695,7 +701,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;
@@ -721,12 +727,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;
}
@@ -741,11 +747,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;
@@ -805,7 +811,7 @@
Town *t;
int left, top, right, bottom;
- if (!(_display_opt & DO_SHOW_TOWN_NAMES) || _game_mode == GM_MENU)
+ if (!HASBIT(_display_opt, DO_SHOW_TOWN_NAMES) || _game_mode == GM_MENU)
return;
left = dpi->left;
@@ -814,7 +820,7 @@
bottom = top + dpi->height;
switch (dpi->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
FOR_ALL_TOWNS(t) {
if (bottom > t->sign.top &&
top < t->sign.top + 12 &&
@@ -827,7 +833,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
@@ -843,21 +849,26 @@
}
break;
- default: NOT_REACHED();
- case 2:
- right += 4;
- bottom += 5;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ right += ScaleByZoom(1, dpi->zoom);
+ bottom += ScaleByZoom(1, dpi->zoom) + 1;
FOR_ALL_TOWNS(t) {
if (bottom > t->sign.top &&
- top < t->sign.top + 24 &&
+ top < t->sign.top + ScaleByZoom(12, dpi->zoom) &&
right > t->sign.left &&
- left < t->sign.left + t->sign.width_2*4) {
+ left < t->sign.left + ScaleByZoom(t->sign.width_2, dpi->zoom)) {
AddStringToDraw(t->sign.left + 5, t->sign.top + 1, STR_TOWN_LABEL_TINY_BLACK, t->index, 0);
AddStringToDraw(t->sign.left + 1, t->sign.top - 3, STR_TOWN_LABEL_TINY_WHITE, t->index, 0);
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
}
@@ -879,7 +890,7 @@
int left, top, right, bottom;
const Station *st;
- if (!(_display_opt & DO_SHOW_STATION_NAMES) || _game_mode == GM_MENU)
+ if (!HASBIT(_display_opt, DO_SHOW_STATION_NAMES) || _game_mode == GM_MENU)
return;
left = dpi->left;
@@ -888,7 +899,7 @@
bottom = top + dpi->height;
switch (dpi->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
FOR_ALL_STATIONS(st) {
if (bottom > st->sign.top &&
top < st->sign.top + 12 &&
@@ -899,7 +910,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
FOR_ALL_STATIONS(st) {
@@ -912,19 +923,25 @@
}
break;
- default: NOT_REACHED();
- case 2:
- right += 4;
- bottom += 5;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ right += ScaleByZoom(1, dpi->zoom);
+ bottom += ScaleByZoom(1, dpi->zoom) + 1;
+
FOR_ALL_STATIONS(st) {
if (bottom > st->sign.top &&
- top < st->sign.top + 24 &&
+ top < st->sign.top + ScaleByZoom(12, dpi->zoom) &&
right > st->sign.left &&
- left < st->sign.left + st->sign.width_2*4) {
+ left < st->sign.left + ScaleByZoom(st->sign.width_2, dpi->zoom)) {
AddStation(st, STR_STATION_SIGN_TINY, st->sign.width_2 | 0x8000);
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
}
@@ -946,7 +963,7 @@
const Sign *si;
int left, top, right, bottom;
- if (!(_display_opt & DO_SHOW_SIGNS))
+ if (!HASBIT(_display_opt, DO_SHOW_SIGNS))
return;
left = dpi->left;
@@ -955,7 +972,7 @@
bottom = top + dpi->height;
switch (dpi->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
FOR_ALL_SIGNS(si) {
if (bottom > si->sign.top &&
top < si->sign.top + 12 &&
@@ -966,7 +983,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
FOR_ALL_SIGNS(si) {
@@ -979,19 +996,25 @@
}
break;
- default: NOT_REACHED();
- case 2:
- right += 4;
- bottom += 5;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ right += ScaleByZoom(1, dpi->zoom);
+ bottom += ScaleByZoom(1, dpi->zoom) + 1;
+
FOR_ALL_SIGNS(si) {
if (bottom > si->sign.top &&
- top < si->sign.top + 24 &&
+ top < si->sign.top + ScaleByZoom(12, dpi->zoom) &&
right > si->sign.left &&
- left < si->sign.left + si->sign.width_2 * 4) {
+ left < si->sign.left + ScaleByZoom(si->sign.width_2, dpi->zoom)) {
AddSign(si, STR_2002, si->sign.width_2 | 0x8000);
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
}
@@ -1013,7 +1036,7 @@
const Waypoint *wp;
int left, top, right, bottom;
- if (!(_display_opt & DO_WAYPOINTS))
+ if (!HASBIT(_display_opt, DO_WAYPOINTS))
return;
left = dpi->left;
@@ -1022,7 +1045,7 @@
bottom = top + dpi->height;
switch (dpi->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
FOR_ALL_WAYPOINTS(wp) {
if (bottom > wp->sign.top &&
top < wp->sign.top + 12 &&
@@ -1033,7 +1056,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
right += 2;
bottom += 2;
FOR_ALL_WAYPOINTS(wp) {
@@ -1046,19 +1069,25 @@
}
break;
- default: NOT_REACHED();
- case 2:
- right += 4;
- bottom += 5;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ right += ScaleByZoom(1, dpi->zoom);
+ bottom += ScaleByZoom(1, dpi->zoom) + 1;
+
FOR_ALL_WAYPOINTS(wp) {
if (bottom > wp->sign.top &&
- top < wp->sign.top + 24 &&
+ top < wp->sign.top + ScaleByZoom(12, dpi->zoom) &&
right > wp->sign.left &&
- left < wp->sign.left + wp->sign.width_2*4) {
+ left < wp->sign.left + ScaleByZoom(wp->sign.width_2, dpi->zoom)) {
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT_TINY, wp->sign.width_2 | 0x8000);
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
}
@@ -1135,7 +1164,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;
@@ -1169,25 +1198,25 @@
static void ViewportDrawStrings(DrawPixelInfo *dpi, const StringSpriteToDraw *ss)
{
DrawPixelInfo dp;
- byte zoom;
+ ZoomLevel zoom;
_cur_dpi = &dp;
dp = *dpi;
zoom = dp.zoom;
- dp.zoom = 0;
-
- dp.left >>= zoom;
- dp.top >>= zoom;
- dp.width >>= zoom;
- dp.height >>= zoom;
+ dp.zoom = ZOOM_LVL_NORMAL;
+
+ dp.left = UnScaleByZoom(dp.left, zoom);
+ dp.top = UnScaleByZoom(dp.top, zoom);
+ dp.width = UnScaleByZoom(dp.width, zoom);
+ dp.height = UnScaleByZoom(dp.height, zoom);
do {
uint16 colour;
if (ss->width != 0) {
- int x = (ss->x >> zoom) - 1;
- int y = (ss->y >> zoom) - 1;
+ int x = UnScaleByZoom(ss->x, zoom) - 1;
+ int y = UnScaleByZoom(ss->y, zoom) - 1;
int bottom = y + 11;
int w = ss->width;
@@ -1200,21 +1229,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;
@@ -1222,7 +1249,7 @@
colour = 16;
}
DrawString(
- ss->x >> zoom, (ss->y >> zoom) - (ss->width & 0x8000 ? 2 : 0),
+ UnScaleByZoom(ss->x, zoom), UnScaleByZoom(ss->y, zoom) - (ss->width & 0x8000 ? 2 : 0),
ss->string, colour
);
@@ -1247,7 +1274,7 @@
_cur_dpi = &vd.dpi;
vd.dpi.zoom = vp->zoom;
- mask = (-1) << vp->zoom;
+ mask = ScaleByZoom(-1, vp->zoom);
vd.combine_sprites = 0;
@@ -1257,8 +1284,8 @@
vd.dpi.top = top & mask;
vd.dpi.pitch = old_dpi->pitch;
- x = ((vd.dpi.left - (vp->virtual_left&mask)) >> vp->zoom) + vp->left;
- y = ((vd.dpi.top - (vp->virtual_top&mask)) >> vp->zoom) + vp->top;
+ x = UnScaleByZoom(vd.dpi.left - (vp->virtual_left & mask), vp->zoom) + vp->left;
+ y = UnScaleByZoom(vd.dpi.top - (vp->virtual_top & mask), vp->zoom) + vp->top;
vd.dpi.dst_ptr = old_dpi->dst_ptr + x - old_dpi->left + (y - old_dpi->top) * old_dpi->pitch;
@@ -1280,8 +1307,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);
@@ -1297,11 +1324,11 @@
_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) {
+ if (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > 180000) {
if ((bottom - top) > (right - left)) {
int t = (top + bottom) >> 1;
ViewportDrawChk(vp, left, top, right, t);
@@ -1313,10 +1340,10 @@
}
} else {
ViewportDoDraw(vp,
- ((left - vp->left) << vp->zoom) + vp->virtual_left,
- ((top - vp->top) << vp->zoom) + vp->virtual_top,
- ((right - vp->left) << vp->zoom) + vp->virtual_left,
- ((bottom - vp->top) << vp->zoom) + vp->virtual_top
+ ScaleByZoom(left - vp->left, vp->zoom) + vp->virtual_left,
+ ScaleByZoom(top - vp->top, vp->zoom) + vp->virtual_top,
+ ScaleByZoom(right - vp->left, vp->zoom) + vp->virtual_left,
+ ScaleByZoom(bottom - vp->top, vp->zoom) + vp->virtual_top
);
}
}
@@ -1366,20 +1393,39 @@
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
+
+ int dest_x = WP(w,vp_d).dest_scrollpos_x + vp->virtual_width / 2;
+ int dest_y = WP(w,vp_d).dest_scrollpos_y + vp->virtual_height / 2;
+
+ int delta_x = dest_x - x;
+ int delta_y = dest_y - y;
+
+ if (delta_x != 0 || delta_y != 0) {
+ if (_patches.smooth_scroll) {
+ int max_scroll = ScaleByMapSize1D(512);
+ /* Not at our desired positon yet... */
+ x += clamp(delta_x / 8, -max_scroll, max_scroll);
+ y += clamp(delta_y / 8, -max_scroll, max_scroll);
+ } else {
+ x = dest_x;
+ y = dest_y;
+ }
+ }
+
+ /* 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;
@@ -1404,10 +1450,10 @@
if (top >= vp->virtual_height) return;
SetDirtyBlocks(
- (left >> vp->zoom) + vp->left,
- (top >> vp->zoom) + vp->top,
- (right >> vp->zoom) + vp->left,
- (bottom >> vp->zoom) + vp->top
+ UnScaleByZoom(left, vp->zoom) + vp->left,
+ UnScaleByZoom(top, vp->zoom) + vp->top,
+ UnScaleByZoom(right, vp->zoom) + vp->left,
+ UnScaleByZoom(bottom, vp->zoom) + vp->top
);
}
@@ -1495,10 +1541,10 @@
{
const Town *t;
- if (!(_display_opt & DO_SHOW_TOWN_NAMES)) return false;
+ if (!HASBIT(_display_opt, DO_SHOW_TOWN_NAMES)) return false;
switch (vp->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_TOWNS(t) {
@@ -1512,7 +1558,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_TOWNS(t) {
@@ -1526,19 +1572,26 @@
}
break;
- default:
- x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left;
+ y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
+
FOR_ALL_TOWNS(t) {
if (y >= t->sign.top &&
- y < t->sign.top + 24 &&
+ y < t->sign.top + ScaleByZoom(12, vp->zoom) &&
x >= t->sign.left &&
- x < t->sign.left + t->sign.width_2 * 4) {
+ x < t->sign.left + ScaleByZoom(t->sign.width_2, vp->zoom)) {
ShowTownViewWindow(t->index);
return true;
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
return false;
@@ -1549,10 +1602,10 @@
{
const Station *st;
- if (!(_display_opt & DO_SHOW_STATION_NAMES)) return false;
+ if (!HASBIT(_display_opt, DO_SHOW_STATION_NAMES)) return false;
switch (vp->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_STATIONS(st) {
@@ -1566,7 +1619,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_STATIONS(st) {
@@ -1580,19 +1633,26 @@
}
break;
- default:
- x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left;
+ y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
+
FOR_ALL_STATIONS(st) {
if (y >= st->sign.top &&
- y < st->sign.top + 24 &&
+ y < st->sign.top + ScaleByZoom(12, vp->zoom) &&
x >= st->sign.left &&
- x < st->sign.left + st->sign.width_2 * 4) {
+ x < st->sign.left + ScaleByZoom(st->sign.width_2, vp->zoom)) {
ShowStationViewWindow(st->index);
return true;
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
return false;
@@ -1603,10 +1663,10 @@
{
const Sign *si;
- if (!(_display_opt & DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
+ if (!HASBIT(_display_opt, DO_SHOW_SIGNS) || _current_player == PLAYER_SPECTATOR) return false;
switch (vp->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_SIGNS(si) {
@@ -1620,7 +1680,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_SIGNS(si) {
@@ -1634,19 +1694,26 @@
}
break;
- default:
- x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left;
+ y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
+
FOR_ALL_SIGNS(si) {
if (y >= si->sign.top &&
- y < si->sign.top + 24 &&
+ y < si->sign.top + ScaleByZoom(12, vp->zoom) &&
x >= si->sign.left &&
- x < si->sign.left + si->sign.width_2 * 4) {
+ x < si->sign.left + ScaleByZoom(si->sign.width_2, vp->zoom)) {
ShowRenameSignWindow(si);
return true;
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
return false;
@@ -1657,10 +1724,10 @@
{
const Waypoint *wp;
- if (!(_display_opt & DO_WAYPOINTS)) return false;
+ if (!HASBIT(_display_opt, DO_WAYPOINTS)) return false;
switch (vp->zoom) {
- case 0:
+ case ZOOM_LVL_NORMAL:
x = x - vp->left + vp->virtual_left;
y = y - vp->top + vp->virtual_top;
FOR_ALL_WAYPOINTS(wp) {
@@ -1674,7 +1741,7 @@
}
break;
- case 1:
+ case ZOOM_LVL_OUT_2X:
x = (x - vp->left + 1) * 2 + vp->virtual_left;
y = (y - vp->top + 1) * 2 + vp->virtual_top;
FOR_ALL_WAYPOINTS(wp) {
@@ -1688,19 +1755,26 @@
}
break;
- default:
- x = (x - vp->left + 3) * 4 + vp->virtual_left;
- y = (y - vp->top + 3) * 4 + vp->virtual_top;
+ case ZOOM_LVL_OUT_4X:
+ case ZOOM_LVL_OUT_8X:
+ x = ScaleByZoom(x - vp->left + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_left;
+ y = ScaleByZoom(y - vp->top + ScaleByZoom(1, vp->zoom) - 1, vp->zoom) + vp->virtual_top;
+
FOR_ALL_WAYPOINTS(wp) {
if (y >= wp->sign.top &&
- y < wp->sign.top + 24 &&
+ y < wp->sign.top + ScaleByZoom(12, vp->zoom) &&
x >= wp->sign.left &&
- x < wp->sign.left + wp->sign.width_2 * 4) {
+ x < wp->sign.left + ScaleByZoom(wp->sign.width_2, vp->zoom)) {
ShowRenameWaypointWindow(wp);
return true;
}
}
break;
+
+ case ZOOM_LVL_OUT_16X:
+ break;
+
+ default: NOT_REACHED();
}
return false;
@@ -1796,26 +1870,31 @@
/* scrolls the viewport in a window to a given location */
-bool ScrollWindowTo(int x , int y, Window *w)
+bool ScrollWindowTo(int x , int y, Window *w, bool instant)
{
Point pt;
pt = MapXYZToViewport(w->viewport, x, y, GetSlopeZ(x, y));
WP(w, vp_d).follow_vehicle = INVALID_VEHICLE;
- if (WP(w, vp_d).scrollpos_x == pt.x && WP(w, vp_d).scrollpos_y == pt.y)
+ if (WP(w, vp_d).dest_scrollpos_x == pt.x && WP(w, vp_d).dest_scrollpos_y == pt.y)
return false;
- WP(w, vp_d).scrollpos_x = pt.x;
- WP(w, vp_d).scrollpos_y = pt.y;
+ if (instant) {
+ WP(w, vp_d).scrollpos_x = pt.x;
+ WP(w, vp_d).scrollpos_y = pt.y;
+ }
+
+ WP(w, vp_d).dest_scrollpos_x = pt.x;
+ WP(w, vp_d).dest_scrollpos_y = pt.y;
return true;
}
-bool ScrollMainWindowTo(int x, int y)
+bool ScrollMainWindowTo(int x, int y, bool instant)
{
Window *w;
- bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0));
+ bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0), instant);
/* If a user scrolls to a tile (via what way what so ever) and already is on
* that tile (e.g.: pressed twice), move the smallmap to that location,
@@ -1832,9 +1911,9 @@
}
-bool ScrollMainWindowToTile(TileIndex tile)
+bool ScrollMainWindowToTile(TileIndex tile, bool instant)
{
- return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2);
+ return ScrollMainWindowTo(TileX(tile) * TILE_SIZE + TILE_SIZE / 2, TileY(tile) * TILE_SIZE + TILE_SIZE / 2, instant);
}
void SetRedErrorSquare(TileIndex tile)
@@ -1866,13 +1945,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;
@@ -1919,13 +1998,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;
@@ -1934,15 +2013,16 @@
_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
-void VpStartPlaceSizing(TileIndex tile, int user)
+/** highlighting tiles while only going over them with the mouse */
+void VpStartPlaceSizing(TileIndex tile, byte method, byte process)
{
- _thd.userdata = user;
+ _thd.select_method = method;
+ _thd.select_proc = process;
_thd.selend.x = TileX(tile) * TILE_SIZE;
_thd.selstart.x = TileX(tile) * TILE_SIZE;
_thd.selend.y = TileY(tile) * TILE_SIZE;
@@ -1989,7 +2069,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)
{
@@ -2031,8 +2111,9 @@
* north-south (DIR_S) to obtain the same results with less code. This is what
* the return value signifies.
* @param style HighLightStyle dragging style
- * @param start_tile, end_tile start and end tile of drag
- * @param boolean value which when true means start/end should be swapped */
+ * @param start_tile start tile of drag
+ * @param end_tile end tile of drag
+ * @return boolean value which when true means start/end should be swapped */
static bool SwapDirection(HighLightStyle style, TileIndex start_tile, TileIndex end_tile)
{
uint start_x = TileX(start_tile);
@@ -2057,7 +2138,7 @@
* To correctly get the height difference we need the direction we are dragging
* in, as well as with what kind of tool we are dragging. For example a horizontal
* autorail tool that starts in bottom and ends at the top of a tile will need the
-* maximum of SW,S and SE,N corners respectively. This is handled by the lookup table below
+* maximum of SW, S and SE, N corners respectively. This is handled by the lookup table below
* See _tileoffs_by_dir in map.c for the direction enums if you can't figure out
* the values yourself.
* @param style HightlightStyle of drag. This includes direction and style (autorail, rect, etc.)
@@ -2140,7 +2221,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;
@@ -2391,7 +2472,7 @@
_thd.selend.y = y;
}
-// while dragging
+/** while dragging */
bool VpHandlePlaceSizingDrag()
{
Window *w;
@@ -2399,16 +2480,17 @@
if (_special_mouse_mode != WSM_SIZING) return true;
- e.we.place.userdata = _thd.userdata;
-
- // stop drag mode if the window has been closed
- w = FindWindowById(_thd.window_class,_thd.window_number);
+ e.we.place.select_method = _thd.select_method;
+ e.we.place.select_proc = _thd.select_proc;
+
+ /* 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();
@@ -2416,12 +2498,12 @@
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;
- } else if ((e.we.place.userdata & 0xF) == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik
+ } else if (e.we.place.select_method == VPM_SIGNALDIRS) { // some might call this a hack... -- Dominik
_thd.place_mode = VHM_RECT;
} else if (_thd.next_drawstyle & HT_LINE) {
_thd.place_mode = VHM_RAIL;
@@ -2432,7 +2514,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);
@@ -2453,7 +2535,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 5a8b295aa345 -r 4cc327ad39d5 src/viewport.h
--- a/src/viewport.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/viewport.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,8 +1,12 @@
/* $Id$ */
+/** @file viewport.h */
+
#ifndef VIEWPORT_H
#define VIEWPORT_H
+#include "zoom.hpp"
+
struct ViewPort {
int left,top; // screen coordinates for the viewport
int width, height; // screen width/height for the viewport
@@ -10,16 +14,16 @@
int virtual_left, virtual_top; // virtual coordinates
int virtual_width, virtual_height; // these are just width << zoom, height << zoom
- byte zoom;
+ ZoomLevel zoom;
};
void SetSelectionRed(bool);
-/* viewport.c */
+/* viewport.cpp */
void InitViewports();
void DeleteWindowViewport(Window *w);
void AssignWindowViewport(Window *w, int x, int y,
- int width, int height, uint32 follow_flags, byte zoom);
+ int width, int height, uint32 follow_flags, ZoomLevel zoom);
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
Point GetTileBelowCursor();
void UpdateViewportPosition(Window *w);
@@ -58,7 +62,7 @@
void SetTileSelectSize(int w, int h);
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
-void VpStartPlaceSizing(TileIndex tile, int user);
+void VpStartPlaceSizing(TileIndex tile, byte method, byte process);
void VpSetPresizeRange(uint from, uint to);
void VpSetPlaceSizingLimit(int limit);
@@ -74,28 +78,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):
@@ -136,12 +140,14 @@
WindowClass window_class;
WindowNumber window_number;
- int userdata;
+ byte select_method;
+ byte select_proc;
+
TileIndex redsq;
};
-// 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 5a8b295aa345 -r 4cc327ad39d5 src/void_map.h
--- a/src/void_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/void_map.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,8 +1,14 @@
/* $Id$ */
+/** @file void_map.h */
+
#ifndef VOID_MAP_H
#define VOID_MAP_H
+/**
+ * Make a nice void tile ;)
+ * @param t the tile to make void
+ */
static inline void MakeVoid(TileIndex t)
{
SetTileType(t, MP_VOID);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/water_cmd.cpp
--- a/src/water_cmd.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/water_cmd.cpp Sat Jun 02 19:59:29 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"
@@ -22,6 +25,7 @@
#include "train.h"
#include "water_map.h"
#include "newgrf.h"
+#include "newgrf_canal.h"
static const SpriteID _water_shore_sprites[] = {
0,
@@ -47,6 +51,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 +81,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 +125,25 @@
return _price.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 +172,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 +195,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 +217,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 +256,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 +289,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 +306,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 +332,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 +346,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,44 +369,48 @@
}
}
-// 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.
+ /* Test for custom graphics, else use the default */
+ SpriteID dikes_base = GetCanalSprite(CF_DIKES, tile);
+ if (dikes_base == 0) dikes_base = SPR_CANALS_BASE + 57;
+
+ /* 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;
wa += IsWateredTile(TILE_ADDXY(tile, 0, -1)) << 3;
- if (!(wa & 1)) DrawGroundSprite(SPR_CANALS_BASE + 57, PAL_NONE);
- if (!(wa & 2)) DrawGroundSprite(SPR_CANALS_BASE + 58, PAL_NONE);
- if (!(wa & 4)) DrawGroundSprite(SPR_CANALS_BASE + 59, PAL_NONE);
- if (!(wa & 8)) DrawGroundSprite(SPR_CANALS_BASE + 60, PAL_NONE);
+ if (!(wa & 1)) DrawGroundSprite(dikes_base, PAL_NONE);
+ if (!(wa & 2)) DrawGroundSprite(dikes_base + 1, PAL_NONE);
+ if (!(wa & 4)) DrawGroundSprite(dikes_base + 2, PAL_NONE);
+ if (!(wa & 8)) DrawGroundSprite(dikes_base + 3, 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;
+ case 0: DrawGroundSprite(dikes_base + 4, PAL_NONE); break;
+ case 3: if (!IsWateredTile(TILE_ADDXY(tile, -1, 1))) DrawGroundSprite(dikes_base + 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;
+ case 0: DrawGroundSprite(dikes_base + 5, PAL_NONE); break;
+ case 6: if (!IsWateredTile(TILE_ADDXY(tile, 1, 1))) DrawGroundSprite(dikes_base + 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;
+ case 0: DrawGroundSprite(dikes_base + 6, PAL_NONE); break;
+ case 12: if (!IsWateredTile(TILE_ADDXY(tile, 1, -1))) DrawGroundSprite(dikes_base + 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;
+ case 0: DrawGroundSprite(dikes_base + 7, PAL_NONE); break;
+ case 9: if (!IsWateredTile(TILE_ADDXY(tile, -1, -1))) DrawGroundSprite(dikes_base + 11, PAL_NONE); break;
}
}
@@ -415,13 +426,31 @@
SpriteID palette, uint base
)
{
- DrawGroundSprite(wdts++->image, PAL_NONE);
+ SpriteID image;
+ SpriteID water_base = GetCanalSprite(CF_WATERSLOPE, ti->tile);
+ SpriteID locks_base = GetCanalSprite(CF_LOCKS, ti->tile);
+
+ /* If no custom graphics, use defaults */
+ if (water_base == 0) water_base = SPR_CANALS_BASE + 5;
+ if (locks_base == 0) {
+ locks_base = SPR_CANALS_BASE + 9;
+ } else {
+ /* If using custom graphics, ignore the variation on height */
+ base = 0;
+ }
+
+ image = wdts++->image;
+ if (image < 4) image += water_base;
+ DrawGroundSprite(image, PAL_NONE);
for (; wdts->delta_x != 0x80; wdts++) {
- SpriteID image = wdts->image + base;
+ SpriteID image = wdts->image;
SpriteID pal;
- if (_display_opt & DO_TRANS_BUILDINGS) {
+ if (image < 24) image += locks_base;
+ image += base;
+
+ if (HASBIT(_transparent_opt, TO_BUILDINGS)) {
SETBIT(image, PALETTE_MODIFIER_TRANSPARENT);
pal = PALETTE_TO_TRANSPARENT;
} else {
@@ -524,7 +553,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 +563,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 +655,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;
@@ -645,7 +674,7 @@
SetDParam(0, pass);
AddNewsItem(STR_B006_FLOOD_VEHICLE_DESTROYED,
- NEWS_FLAGS(NM_THIN, NF_VIEWPORT|NF_VEHICLE, NT_ACCIDENT, 0),
+ NEWS_FLAGS(NM_THIN, NF_VIEWPORT | NF_VEHICLE, NT_ACCIDENT, 0),
v->index,
0);
CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
@@ -653,7 +682,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 +704,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]);
}
@@ -697,7 +725,7 @@
}
}
-static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode)
+static uint32 GetTileTrackStatus_Water(TileIndex tile, TransportType mode, uint sub_mode)
{
static const byte coast_tracks[] = {0, 32, 4, 0, 16, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0};
@@ -713,11 +741,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 5a8b295aa345 -r 4cc327ad39d5 src/water_map.h
--- a/src/water_map.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/water_map.h Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file water_map.h */
+
#ifndef WATER_MAP_H
#define WATER_MAP_H
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/waypoint.cpp
--- a/src/waypoint.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/waypoint.cpp Sat Jun 02 19:59:29 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 _price.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 _price.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 5a8b295aa345 -r 4cc327ad39d5 src/waypoint.h
--- a/src/waypoint.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/waypoint.h Sat Jun 02 19:59:29 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 5a8b295aa345 -r 4cc327ad39d5 src/widget.cpp
--- a/src/widget.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/widget.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
/* $Id$ */
+/** @file widget.cpp */
+
#include "stdafx.h"
#include "openttd.h"
#include "functions.h"
@@ -34,17 +36,13 @@
return pt;
}
-/*****************************************************
- * Special handling for the scrollbar widget type.
+/** Special handling for the scrollbar widget type.
* Handles the special scrolling buttons and other
* scrolling.
- * Parameters:
- * w - Window.
- * wi - Pointer to the scrollbar widget.
- * x - The X coordinate of the mouse click.
- * y - The Y coordinate of the mouse click.
- */
-
+ * @param w Window on which a scroll was performed.
+ * @param wi Pointer to the scrollbar widget.
+ * @param x The X coordinate of the mouse click.
+ * @param y The Y coordinate of the mouse click. */
void ScrollbarClickHandler(Window *w, const Widget *wi, int x, int y)
{
int mi, ma, pos;
@@ -52,7 +50,7 @@
switch (wi->type) {
case WWT_SCROLLBAR: {
- // vertical scroller
+ /* vertical scroller */
w->flags4 &= ~WF_HSCROLL;
w->flags4 &= ~WF_SCROLL2;
mi = wi->top;
@@ -62,7 +60,7 @@
break;
}
case WWT_SCROLL2BAR: {
- // 2nd vertical scroller
+ /* 2nd vertical scroller */
w->flags4 &= ~WF_HSCROLL;
w->flags4 |= WF_SCROLL2;
mi = wi->top;
@@ -72,7 +70,7 @@
break;
}
case WWT_HSCROLLBAR: {
- // horizontal scroller
+ /* horizontal scroller */
w->flags4 &= ~WF_SCROLL2;
w->flags4 |= WF_HSCROLL;
mi = wi->left;
@@ -84,7 +82,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 +90,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 +100,6 @@
}
_left_button_clicked = false;
} else {
- //
Point pt = HandleScrollbarHittest(sb, mi, ma);
if (pos < pt.x) {
@@ -127,7 +124,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 The Window client X coordinate
+ * @param y The Window client y coordinate
* @return A widget index, or -1 if no widget was found.
*/
int GetWidgetFromPos(const Window *w, int x, int y)
@@ -135,8 +133,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 +292,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 +311,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 +331,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 +343,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 +358,7 @@
break;
}
- // horizontal scrollbar
+ /* horizontal scrollbar */
case WWT_HSCROLLBAR: {
Point pt;
int c1,c2;
@@ -378,17 +376,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 +402,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 +499,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++;
@@ -735,7 +733,7 @@
/** Evenly distribute some widgets when resizing horizontally (often a button row)
* When only two arguments are given, the widgets are presumed to be on a line and only the ends are given
- * @param w widow to modify
+ * @param w Window to modify
* @param left The leftmost widget to resize
* @param right The rightmost widget to resize. Since right side of it is used, remember to set it to RESIZE_RIGHT
*/
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/win32.cpp
--- a/src/win32.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/win32.cpp Sat Jun 02 19:59:29 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;
@@ -335,7 +335,7 @@
static void SetWndSize(HWND wnd, int mode)
{
- RECT r,r2;
+ RECT r, r2;
int offs;
GetWindowRect(wnd, &r);
@@ -368,7 +368,7 @@
return b;
}
-static INT_PTR CALLBACK CrashDialogFunc(HWND wnd,UINT msg,WPARAM wParam,LPARAM lParam)
+static INT_PTR CALLBACK CrashDialogFunc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG: {
@@ -418,7 +418,7 @@
EnableWindow(GetDlgItem(wnd, 14), FALSE);
SetCursor(LoadCursor(NULL, IDC_ARROW));
MessageBox(wnd, _T("Crash report submitted. Thank you."), _T("Crash Report"), MB_ICONINFORMATION);
- } break;
+ } break;
#endif /* Disabled crash-submit procedures */
case 15: /* Expand window to show crash-message */
_expanded ^= 1;
@@ -549,7 +549,7 @@
}
{
- int i,j;
+ int i, j;
#ifdef _M_AMD64
uint32 *b = (uint32*)ep->ContextRecord->Rsp;
#else
@@ -557,7 +557,7 @@
#endif
for (j = 0; j != 24; j++) {
for (i = 0; i != 8; i++) {
- if (IsBadReadPtr(b,sizeof(uint32))) {
+ if (IsBadReadPtr(b, sizeof(uint32))) {
output += sprintf(output, " ????????"); //OCR: WAS - , 0);
} else {
output += sprintf(output, " %.8X", *b);
@@ -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" );
@@ -890,6 +890,9 @@
#endif /* UNICODE */
#if defined(UNICODE)
+ /* Check if a win9x user started the win32 version */
+ if (HASBIT(GetVersion(), 31)) error("This version of OpenTTD doesn't run on windows 95/98/ME.\nPlease download the win9x binary and try again.");
+
/* For UNICODE we need to convert the commandline to char* _AND_
* save it because argv[] points into this buffer and thus needs to
* be available between subsequent calls to FS2OTTD() */
@@ -946,6 +949,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 +966,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 +1040,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 5a8b295aa345 -r 4cc327ad39d5 src/window.cpp
--- a/src/window.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/window.cpp Sat Jun 02 19:59:29 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);
@@ -235,25 +235,25 @@
bottom > v->top &&
left < v->left + v->width &&
top < v->top + v->height) {
- if (left < (x=v->left)) {
+ if (left < (x = v->left)) {
DrawOverlappedWindow(wz, left, top, x, bottom);
DrawOverlappedWindow(wz, x, top, right, bottom);
return;
}
- if (right > (x=v->left + v->width)) {
+ if (right > (x = v->left + v->width)) {
DrawOverlappedWindow(wz, left, top, x, bottom);
DrawOverlappedWindow(wz, x, top, right, bottom);
return;
}
- if (top < (x=v->top)) {
+ if (top < (x = v->top)) {
DrawOverlappedWindow(wz, left, top, right, x);
DrawOverlappedWindow(wz, left, x, right, bottom);
return;
}
- if (bottom > (x=v->top + v->height)) {
+ if (bottom > (x = v->top + v->height)) {
DrawOverlappedWindow(wz, left, top, right, x);
DrawOverlappedWindow(wz, left, x, right, bottom);
return;
@@ -271,7 +271,7 @@
dp->top = top - (*wz)->top;
dp->pitch = _screen.pitch;
dp->dst_ptr = _screen.dst_ptr + top * _screen.pitch + left;
- dp->zoom = 0;
+ dp->zoom = ZOOM_LVL_NORMAL;
CallWindowEventNP(*wz, WE_PAINT);
}
}
@@ -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)
@@ -670,22 +682,17 @@
};
-static SizeRect _awap_r;
-
-static bool IsGoodAutoPlace1(int left, int top)
+static bool IsGoodAutoPlace1(int left, int top, int width, int height, Point &pos)
{
- int right,bottom;
Window* const *wz;
- _awap_r.left= left;
- _awap_r.top = top;
- right = _awap_r.width + left;
- bottom = _awap_r.height + top;
+ int right = width + left;
+ int bottom = height + top;
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;
@@ -698,23 +705,19 @@
}
}
+ pos.x = left;
+ pos.y = top;
return true;
}
-static bool IsGoodAutoPlace2(int left, int top)
+static bool IsGoodAutoPlace2(int left, int top, int width, int height, Point &pos)
{
- int width,height;
Window* const *wz;
- _awap_r.left= left;
- _awap_r.top = top;
- width = _awap_r.width;
- height = _awap_r.height;
-
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;
@@ -727,6 +730,8 @@
}
}
+ pos.x = left;
+ pos.y = top;
return true;
}
@@ -735,39 +740,36 @@
Window* const *wz;
Point pt;
- _awap_r.width = width;
- _awap_r.height = height;
-
- if (IsGoodAutoPlace1(0, 24)) goto ok_pos;
+ if (IsGoodAutoPlace1(0, 24, width, height, pt)) return pt;
FOR_ALL_WINDOWS(wz) {
const Window *w = *wz;
if (w->window_class == WC_MAIN_WINDOW) continue;
- if (IsGoodAutoPlace1(w->left+w->width+2,w->top)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left- width-2,w->top)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left,w->top+w->height+2)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left,w->top- height-2)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left+w->width+2,w->top+w->height-height)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left- width-2,w->top+w->height-height)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left+w->width-width,w->top+w->height+2)) goto ok_pos;
- if (IsGoodAutoPlace1(w->left+w->width-width,w->top- height-2)) goto ok_pos;
+ if (IsGoodAutoPlace1(w->left + w->width + 2, w->top, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left - width - 2, w->top, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left, w->top + w->height + 2, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left, w->top - height - 2, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left + w->width + 2, w->top + w->height - height, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left - width - 2, w->top + w->height - height, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left + w->width - width, w->top + w->height + 2, width, height, pt)) return pt;
+ if (IsGoodAutoPlace1(w->left + w->width - width, w->top - height - 2, width, height, pt)) return pt;
}
FOR_ALL_WINDOWS(wz) {
const Window *w = *wz;
if (w->window_class == WC_MAIN_WINDOW) continue;
- if (IsGoodAutoPlace2(w->left+w->width+2,w->top)) goto ok_pos;
- if (IsGoodAutoPlace2(w->left- width-2,w->top)) goto ok_pos;
- if (IsGoodAutoPlace2(w->left,w->top+w->height+2)) goto ok_pos;
- if (IsGoodAutoPlace2(w->left,w->top- height-2)) goto ok_pos;
+ if (IsGoodAutoPlace2(w->left + w->width + 2, w->top, width, height, pt)) return pt;
+ if (IsGoodAutoPlace2(w->left - width - 2, w->top, width, height, pt)) return pt;
+ if (IsGoodAutoPlace2(w->left, w->top + w->height + 2, width, height, pt)) return pt;
+ if (IsGoodAutoPlace2(w->left, w->top - height - 2, width, height, pt)) return pt;
}
{
- int left=0,top=24;
+ int left = 0, top = 24;
-restart:;
+restart:
FOR_ALL_WINDOWS(wz) {
const Window *w = *wz;
@@ -782,11 +784,6 @@
pt.y = top;
return pt;
}
-
-ok_pos:;
- pt.x = _awap_r.left;
- pt.y = _awap_r.top;
- return pt;
}
static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number)
@@ -811,7 +808,7 @@
case WDP_ALIGN_TBR: { /* Align the right side with the top toolbar */
w = FindWindowById(WC_MAIN_TOOLBAR, 0);
pt.x = (w->left + w->width) - desc->width;
- } break;
+ } break;
case WDP_ALIGN_TBL: /* Align the left side with the top toolbar */
pt.x = FindWindowById(WC_MAIN_TOOLBAR, 0)->left;
break;
@@ -852,7 +849,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 +860,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 +873,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 +935,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 +992,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 +1037,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 +1047,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 +1057,7 @@
w->wndproc(w, &e);
}
- // Mouseover never stops execution
+ /* Mouseover never stops execution */
return true;
}
@@ -1066,7 +1065,7 @@
* Both the areas of the old window and the new sized window are set dirty
* ensuring proper redrawal.
* @param w Window to resize
- * @param x delta x-size of changed window (positive if larger, etc.(
+ * @param x delta x-size of changed window (positive if larger, etc.)
* @param y delta y-size of changed window */
void ResizeWindow(Window *w, int x, int y)
{
@@ -1117,10 +1116,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 +1131,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 +1157,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 +1173,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 +1189,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 +1205,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 +1222,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 +1344,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 +1370,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 +1481,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 +1499,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 +1513,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 +1550,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 +1565,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 +1584,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,17 +1615,17 @@
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;
+ WP(w, vp_d).scrollpos_x += ScaleByZoom((x - 15) * scrollspeed, vp->zoom);
} else if (15 - (vp->width - x) > 0) {
- WP(w, vp_d).scrollpos_x += (15 - (vp->width - x)) * scrollspeed << vp->zoom;
+ WP(w, vp_d).scrollpos_x += ScaleByZoom((15 - (vp->width - x)) * scrollspeed, vp->zoom);
}
if (y - 15 < 0) {
- WP(w, vp_d).scrollpos_y += (y - 15) * scrollspeed << vp->zoom;
+ WP(w, vp_d).scrollpos_y += ScaleByZoom((y - 15) * scrollspeed, vp->zoom);
} else if (15 - (vp->height - y) > 0) {
- WP(w,vp_d).scrollpos_y += (15 - (vp->height - y)) * scrollspeed << vp->zoom;
+ WP(w,vp_d).scrollpos_y += ScaleByZoom((15 - (vp->height - y)) * scrollspeed, vp->zoom);
}
#undef scrollspeed
}
@@ -1685,7 +1684,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 +1735,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 +1792,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 +1909,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 +1933,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);
@@ -1971,8 +1970,8 @@
ViewPort *vp = w->viewport;
vp->width = w->width = neww;
vp->height = w->height = newh;
- vp->virtual_width = neww << vp->zoom;
- vp->virtual_height = newh << vp->zoom;
+ vp->virtual_width = ScaleByZoom(neww, vp->zoom);
+ vp->virtual_height = ScaleByZoom(newh, vp->zoom);
continue; // don't modify top,left
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/window.h
--- a/src/window.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/window.h Sat Jun 02 19:59:29 2007 +0000
@@ -9,7 +9,9 @@
#include "string.h"
#include "order.h"
#include "rail.h"
+#include "road.h"
#include "airport.h"
+#include "vehicle.h"
struct WindowEvent;
@@ -133,7 +135,8 @@
Point pt;
TileIndex tile;
TileIndex starttile;
- int userdata;
+ byte select_method;
+ byte select_proc;
} place;
struct {
@@ -280,6 +283,11 @@
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(querystr_d));
+struct chatquerystr_d : public querystr_d {
+ int dest;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(chatquerystr_d));
+
struct menu_d {
byte item_count; ///< follow_vehicle
byte sel_index; ///< scrollpos_x
@@ -318,10 +326,11 @@
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(tooltips_d));
struct buildvehicle_d {
- byte vehicle_type;
+ VehicleType vehicle_type;
union {
RailTypeByte railtype;
AirportFTAClass::Flags flags;
+ RoadTypes roadtypes;
} filter;
byte sel_index; ///< deprecated value, used for 'unified' ship and road
bool descending_sort_order;
@@ -342,12 +351,13 @@
bool update_left;
bool update_right;
bool init_lists;
+ GroupID sel_group;
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(replaceveh_d));
struct depot_d {
VehicleID sel;
- byte type;
+ VehicleType type;
bool generate_list;
uint16 engine_list_length;
uint16 wagon_list_length;
@@ -394,6 +404,8 @@
VehicleID follow_vehicle;
int32 scrollpos_x;
int32 scrollpos_y;
+ int32 dest_scrollpos_x;
+ int32 dest_scrollpos_y;
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
@@ -402,6 +414,8 @@
VehicleID follow_vehicle;
int32 scrollpos_x;
int32 scrollpos_y;
+ int32 dest_scrollpos_x;
+ int32 dest_scrollpos_y;
byte data_1;
byte data_2;
byte data_3;
@@ -412,6 +426,8 @@
uint16 follow_vehicle;
int32 scrollpos_x;
int32 scrollpos_y;
+ int32 dest_scrollpos_x;
+ int32 dest_scrollpos_y;
NewsItem *ni;
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(news_d));
@@ -472,6 +488,28 @@
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(dropdown_d));
+struct vehiclelist_d {
+ const Vehicle** sort_list; // List of vehicles (sorted)
+ Listing *_sorting; // pointer to the appropiate subcategory of _sorting
+ uint16 length_of_sort_list; // Keeps track of how many vehicle pointers sort list got space for
+ VehicleType vehicle_type; // The vehicle type that is sorted
+ list_d l; // General list struct
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
+
+struct grouplist_d {
+ const Group **sort_list;
+ list_d l; // General list struct
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(grouplist_d));
+
+struct groupveh_d : vehiclelist_d {
+ GroupID group_sel;
+ VehicleID vehicle_sel;
+
+ grouplist_d gl;
+};
+assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(groupveh_d));
/****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
enum WindowWidgetBehaviours {
@@ -659,7 +697,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 5a8b295aa345 -r 4cc327ad39d5 src/yapf/follow_track.hpp
--- a/src/yapf/follow_track.hpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/follow_track.hpp Sat Jun 02 19:59:29 2007 +0000
@@ -45,7 +45,7 @@
{
m_old_tile = old_tile;
m_old_td = old_td;
- assert((GetTileTrackStatus(m_old_tile, TT()) & TrackdirToTrackdirBits(m_old_td)) != 0);
+ assert((GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(m_old_td)) != 0);
m_exitdir = TrackdirToExitdir(m_old_td);
if (EnteredDepot()) return true;
if (!CanExitOldTile()) return false;
@@ -114,7 +114,7 @@
if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) {
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101);
} else {
- uint32 ts = GetTileTrackStatus(m_new_tile, TT());
+ uint32 ts = GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes);
m_new_td_bits = (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
}
return (m_new_td_bits != TRACKDIR_BIT_NONE);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf.h
--- a/src/yapf/yapf.h Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf.h Sat Jun 02 19:59:29 2007 +0000
@@ -20,7 +20,6 @@
* @param v the RV that needs to find a path
* @param tile the tile to find the path from (should be next tile the RV is about to enter)
* @param enterdir diagonal direction which the RV will enter this new tile from
- * @param tracks available tracks on the new tile (to choose from)
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
Trackdir YapfChooseRoadTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir);
@@ -29,8 +28,8 @@
* @param v the train that needs to find a path
* @param tile the tile to find the path from (should be next tile the train is about to enter)
* @param enterdir diagonal direction which the RV will enter this new tile from
- * @param trackdirs available trackdirs on the new tile (to choose from)
- * @param no_path_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
+ * @param tracks available trackdirs on the new tile (to choose from)
+ * @param path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
* @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found
*/
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found);
@@ -48,13 +47,13 @@
Depot* YapfFindNearestRoadDepot(const Vehicle *v);
/** Used when user sends train to the nearest depot or if train needs servicing.
- * @v train that needs to go to some depot
- * @max_distance max distance (number of track tiles) from the current train position
+ * @param v train that needs to go to some depot
+ * @param max_distance max distance (number of track tiles) from the current train position
* (used also as optimization - the pathfinder can stop path finding if max_distance
* was reached and no depot was seen)
- * @reverse_penalty penalty that should be added for the path that requires reversing the train first
- * @depot_tile receives the depot tile if depot was found
- * @reversed receives true if train needs to reversed first
+ * @param reverse_penalty penalty that should be added for the path that requires reversing the train first
+ * @param depot_tile receives the depot tile if depot was found
+ * @param reversed receives true if train needs to reversed first
* @return the true if depot was found.
*/
bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed);
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf.hpp
--- a/src/yapf/yapf.hpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf.hpp Sat Jun 02 19:59:29 2007 +0000
@@ -7,6 +7,7 @@
#include "track_dir.hpp"
+#include "../vehicle.h"
#include "../depot.h"
#include "../road_map.h"
#include "../tunnel_map.h"
@@ -14,9 +15,9 @@
#include "../bridge.h"
#include "../station.h"
#include "../station_map.h"
-#include "../vehicle.h"
#include "../date.h"
#include "../functions.h"
+#include "../landscape.h"
#include "yapf.h"
#include "../pathfind.h"
#include "../waypoint.h"
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf_base.hpp
--- a/src/yapf/yapf_base.hpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf_base.hpp Sat Jun 02 19:59:29 2007 +0000
@@ -117,7 +117,8 @@
while (true) {
m_num_steps++;
Node *n = m_nodes.GetBestOpenNode();
- if (n == NULL) break;
+ if (n == NULL)
+ break;
// if the best open node was worse than the best path found, we can finish
if (m_pBestDestNode != NULL && m_pBestDestNode->GetCost() < n->GetCostEstimate())
@@ -160,9 +161,9 @@
/** If path was found return the best node that has reached the destination. Otherwise
* return the best visited node (which was nearest to the destination).
*/
- FORCEINLINE Node& GetBestNode()
+ FORCEINLINE Node* GetBestNode()
{
- return (m_pBestDestNode != NULL) ? *m_pBestDestNode : *m_pBestIntermediateNode;
+ return (m_pBestDestNode != NULL) ? m_pBestDestNode : m_pBestIntermediateNode;
}
/** Calls NodeList::CreateNewNode() - allocates new node that can be filled and used
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf_costrail.hpp
--- a/src/yapf/yapf_costrail.hpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf_costrail.hpp Sat Jun 02 19:59:29 2007 +0000
@@ -121,7 +121,7 @@
Yapf().m_stopped_on_first_two_way_signal = true;
return -1;
}
- SignalType sig_type = GetSignalType(tile);
+ SignalType sig_type = GetSignalType(tile, TrackdirToTrack(trackdir));
n.m_last_red_signal_type = sig_type;
n.flags_u.flags_s.m_last_signal_was_red = true;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf_destrail.hpp
--- a/src/yapf/yapf_destrail.hpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf_destrail.hpp Sat Jun 02 19:59:29 2007 +0000
@@ -86,14 +86,35 @@
public:
void SetDestination(Vehicle* v)
{
- if (v->current_order.type == OT_GOTO_STATION) {
- m_destTile = CalcStationCenterTile(v->current_order.dest);
- m_dest_station_id = v->current_order.dest;
- m_destTrackdirs = INVALID_TRACKDIR_BIT;
- } else {
- m_destTile = v->dest_tile;
- m_dest_station_id = INVALID_STATION;
- m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL) & TRACKDIR_BIT_MASK);
+ switch (v->current_order.type) {
+ case OT_GOTO_STATION:
+ m_destTile = CalcStationCenterTile(v->current_order.dest);
+ m_dest_station_id = v->current_order.dest;
+ m_destTrackdirs = INVALID_TRACKDIR_BIT;
+ break;
+
+ case OT_GOTO_WAYPOINT: {
+ Waypoint *wp = GetWaypoint(v->current_order.dest);
+ if (wp == NULL) {
+ /* Invalid waypoint in orders! */
+ DEBUG(yapf, 0, "Invalid waypoint in orders == 0x%04X (train %d, player %d)", v->current_order.dest, v->unitnumber, (PlayerID)v->owner);
+ break;
+ }
+ m_destTile = wp->xy;
+ if (m_destTile != v->dest_tile) {
+ /* Something is wrong with orders! */
+ DEBUG(yapf, 0, "Invalid v->dest_tile == 0x%04X (train %d, player %d)", v->dest_tile, v->unitnumber, (PlayerID)v->owner);
+ }
+ m_dest_station_id = INVALID_STATION;
+ m_destTrackdirs = TrackToTrackdirBits(AxisToTrack(GetWaypointAxis(wp->xy)));
+ break;
+ }
+
+ default:
+ m_destTile = v->dest_tile;
+ m_dest_station_id = INVALID_STATION;
+ m_destTrackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_RAIL, 0) & TRACKDIR_BIT_MASK);
+ break;
}
CYapfDestinationRailBase::SetDestination(v);
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf_rail.cpp
--- a/src/yapf/yapf_rail.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf_rail.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -61,11 +61,11 @@
// some path found
// get found depot tile
- Node& n = Yapf().GetBestNode();
- *depot_tile = n.GetLastTile();
+ Node *n = Yapf().GetBestNode();
+ *depot_tile = n->GetLastTile();
// walk through the path back to the origin
- Node* pNode = &n;
+ Node *pNode = n;
while (pNode->m_parent != NULL) {
pNode = pNode->m_parent;
}
@@ -128,7 +128,7 @@
// if path not found - return INVALID_TRACKDIR
Trackdir next_trackdir = INVALID_TRACKDIR;
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
if (pNode != NULL) {
// path was found or at least suggested
// walk through the path back to the origin
@@ -165,7 +165,7 @@
// path was found
// walk through the path back to the origin
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
while (pNode->m_parent != NULL) {
pNode = pNode->m_parent;
}
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf_road.cpp
--- a/src/yapf/yapf_road.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf_road.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -268,14 +268,14 @@
// our source tile will be the next vehicle tile (should be the given one)
TileIndex src_tile = tile;
// get available trackdirs on the start tile
- uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD);
+ uint ts = GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
TrackdirBits src_trackdirs = (TrackdirBits)(ts & TRACKDIR_BIT_MASK);
// select reachable trackdirs only
src_trackdirs &= DiagdirReachesTrackdirs(enterdir);
// get available trackdirs on the destination tile
TileIndex dest_tile = v->dest_tile;
- uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD);
+ uint dest_ts = GetTileTrackStatus(dest_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
TrackdirBits dest_trackdirs = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK);
// set origin and destination nodes
@@ -287,7 +287,7 @@
// if path not found - return INVALID_TRACKDIR
Trackdir next_trackdir = INVALID_TRACKDIR;
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
if (pNode != NULL) {
// path was found or at least suggested
// walk through the path back to its origin
@@ -320,7 +320,7 @@
// set destination tile, trackdir
// get available trackdirs on the destination tile
- uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD);
+ uint dest_ts = GetTileTrackStatus(dst_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes);
TrackdirBits dst_td_bits = (TrackdirBits)(dest_ts & TRACKDIR_BIT_MASK);
Yapf().SetDestination(dst_tile, dst_td_bits);
@@ -329,7 +329,7 @@
// if path not found - return distance = UINT_MAX
uint dist = UINT_MAX;
- Node* pNode = &Yapf().GetBestNode();
+ Node *pNode = Yapf().GetBestNode();
if (pNode != NULL) {
// path was found or at least suggested
// get the path cost estimate
@@ -345,7 +345,7 @@
// set origin (tile, trackdir)
TileIndex src_tile = v->tile;
Trackdir src_td = GetVehicleTrackdir(v);
- if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD) & TrackdirToTrackdirBits(src_td)) == 0) {
+ if ((GetTileTrackStatus(src_tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(src_td)) == 0) {
// sometimes the roadveh is not on the road (it resides on non-existing track)
// how should we handle that situation?
return false;
@@ -371,8 +371,8 @@
// some path found
// get found depot tile
- Node& n = Yapf().GetBestNode();
- TileIndex depot_tile = n.m_segment_last_tile;
+ Node *n = Yapf().GetBestNode();
+ TileIndex depot_tile = n->m_segment_last_tile;
assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
Depot* ret = GetDepotByTile(depot_tile);
return ret;
@@ -438,7 +438,7 @@
{
TileIndex tile = v->tile;
Trackdir trackdir = GetVehicleTrackdir(v);
- if ((GetTileTrackStatus(tile, TRANSPORT_ROAD) & TrackdirToTrackdirBits(trackdir)) == 0)
+ if ((GetTileTrackStatus(tile, TRANSPORT_ROAD, v->u.road.compatible_roadtypes) & TrackdirToTrackdirBits(trackdir)) == 0)
return NULL;
// handle the case when our vehicle is already in the depot tile
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/yapf/yapf_ship.cpp
--- a/src/yapf/yapf_ship.cpp Tue Mar 27 23:27:27 2007 +0000
+++ b/src/yapf/yapf_ship.cpp Sat Jun 02 19:59:29 2007 +0000
@@ -26,7 +26,7 @@
* and adds it to the open list by calling Yapf().AddNewNode(n) */
inline void PfFollowNode(Node& old_node)
{
- TrackFollower F;
+ TrackFollower F(Yapf().GetVehicle());
if (F.Follow(old_node.m_key.m_tile, old_node.m_key.m_td))
Yapf().AddMultipleNodes(&old_node, F);
}
@@ -53,7 +53,7 @@
// convert origin trackdir to TrackdirBits
TrackdirBits trackdirs = TrackdirToTrackdirBits(trackdir);
// get available trackdirs on the destination tile
- TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER) & TRACKDIR_BIT_MASK);
+ TrackdirBits dest_trackdirs = (TrackdirBits)(GetTileTrackStatus(v->dest_tile, TRANSPORT_WATER, 0) & TRACKDIR_BIT_MASK);
// create pathfinder instance
Tpf pf;
@@ -61,13 +61,13 @@
pf.SetOrigin(src_tile, trackdirs);
pf.SetDestination(v->dest_tile, dest_trackdirs);
// find best path
- bool bFound = pf.FindPath(v);
+ pf.FindPath(v);
Trackdir next_trackdir = INVALID_TRACKDIR; // this would mean "path not found"
- if (bFound) {
- // path was found
+
+ Node* pNode = pf.GetBestNode();
+ if (pNode != NULL) {
// walk through the path back to the origin
- Node* pNode = &pf.GetBestNode();
Node* pPrevNode = NULL;
while (pNode->m_parent != NULL) {
pPrevNode = pNode;
diff -r 5a8b295aa345 -r 4cc327ad39d5 src/zoom.hpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/zoom.hpp Sat Jun 02 19:59:29 2007 +0000
@@ -0,0 +1,50 @@
+/* $Id$ */
+
+/** @file zoom.hpp */
+
+#ifndef ZOOM_HPP
+#define ZOOM_HPP
+
+enum ZoomLevel {
+ /* Our possible zoom-levels */
+ ZOOM_LVL_NORMAL = 0,
+ ZOOM_LVL_OUT_2X,
+ ZOOM_LVL_OUT_4X,
+ ZOOM_LVL_OUT_8X,
+ ZOOM_LVL_OUT_16X,
+ ZOOM_LVL_END,
+
+ /* Here we define in which zoom viewports are */
+ ZOOM_LVL_VIEWPORT = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_NEWS = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_INDUSTRY = ZOOM_LVL_OUT_2X,
+ ZOOM_LVL_TOWN = ZOOM_LVL_OUT_2X,
+ ZOOM_LVL_AIRCRAFT = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_SHIP = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_TRAIN = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_ROADVEH = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_WORLD_SCREENSHOT = ZOOM_LVL_NORMAL,
+
+ ZOOM_LVL_DETAIL = ZOOM_LVL_OUT_2X, //! All zoomlevels below or equal to this, will result in details on the screen, like road-work, ...
+
+ ZOOM_LVL_MIN = ZOOM_LVL_NORMAL,
+ ZOOM_LVL_MAX = ZOOM_LVL_OUT_16X,
+};
+
+extern ZoomLevel _saved_scrollpos_zoom;
+
+static inline int ScaleByZoom(int value, ZoomLevel zoom)
+{
+ if (zoom == ZOOM_LVL_NORMAL) return value;
+ int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
+ return (zoom > ZOOM_LVL_NORMAL) ? value << izoom : value >> -izoom;
+}
+
+static inline int UnScaleByZoom(int value, ZoomLevel zoom)
+{
+ if (zoom == ZOOM_LVL_NORMAL) return value;
+ int izoom = (int)zoom - (int)ZOOM_LVL_NORMAL;
+ return (zoom > ZOOM_LVL_NORMAL) ? value >> izoom : value << -izoom;
+}
+
+#endif /* ZOOM_HPP */