(svn r12774) [NewGRF_ports] -Sync: with trunk r12742:12772.
--- a/docs/landscape.html Wed Apr 16 22:34:14 2008 +0000
+++ b/docs/landscape.html Fri Apr 18 19:55:13 2008 +0000
@@ -900,6 +900,7 @@
<li>m6 bits 5..3: the station type (rail, airport, truck, bus, oilrig, dock, buoy)</li>
<li>m6 bit 2: 1 when a drive through road stop is built over a town owned road, otherwise 0</li>
<li>m6 bits 1..0 : <a href="#tropic_zone">Tropic zone definition</a></li>
+ <li>m7: animation frame</li>
</ul>
</td>
</tr>
--- a/docs/landscape_grid.html Wed Apr 16 22:34:14 2008 +0000
+++ b/docs/landscape_grid.html Fri Apr 18 19:55:13 2008 +0000
@@ -198,7 +198,7 @@
<td class="bits">XXXX XXXX</td>
<td class="bits">XXXX XXXX</td>
<td class="bits"><span class="free">OO</span>XX X<span class="free">O</span>XX</td>
- <td class="bits"><span class="free">OOOO OOOO</span></td>
+ <td class="bits">XXXX XXXX</td>
</tr>
<tr>
<td class="caption">road stop</td>
--- a/projects/generate Wed Apr 16 22:34:14 2008 +0000
+++ b/projects/generate Fri Apr 18 19:55:13 2008 +0000
@@ -55,6 +55,15 @@
done
}
+grep '\.h' "$ROOT_DIR/source.list" | grep -v '../objs/langs/table/strings.h' | sort > tmp.headers.source.list
+find "$ROOT_DIR/src" -iname "*.h*" -and -not -iname "*svn*" -and -not -iname "*.hpp.sq" | sed "s@$ROOT_DIR/src/@@" | sort > tmp.headers.src
+if [ -n "`diff tmp.headers.source.list tmp.headers.src`" ]; then
+ echo "The following headers are missing in source.list and not in /src/ or vice versa."
+ diff tmp.headers.source.list tmp.headers.src | grep '[<>]' | sort
+ echo ""
+fi
+rm tmp.headers.*
+
load_main_data() {
# Read the source.list and process it
RES="`cat $1 | tr '\r' '\n' | awk '
--- a/projects/generate.vbs Wed Apr 16 22:34:14 2008 +0000
+++ b/projects/generate.vbs Fri Apr 18 19:55:13 2008 +0000
@@ -46,6 +46,85 @@
file.Close
End Sub
+Sub get_files(srcdir, dir, list)
+ Dim file, filename
+ Dim rekeep, reskip
+
+ ' pattern for files to keep
+ Set rekeep = New RegExp
+ rekeep.Pattern = "\.h"
+ rekeep.Global = True
+
+ ' pattern for files to exclude
+ Set reskip = New RegExp
+ reskip.Pattern = "\.svn|\.hpp\.sq"
+ reskip.Global = True
+
+ For Each file in dir.Files
+ filename = Replace(file.path, srcdir, "") ' Remove */src/
+ filename = Replace(filename, "\", "/") ' Replace separators
+ If rekeep.Test(filename) And Not reskip.Test(filename) Then
+ list.Add filename, filename
+ End If
+ Next
+End Sub
+
+Sub get_dir_files(srcdir, dir, list)
+ Dim folder
+ ' Get files
+ get_files srcdir, dir, list
+
+ ' Recurse in subfolders
+ For Each folder in dir.SubFolders
+ get_dir_files srcdir, folder, list
+ Next
+End Sub
+
+Sub headers_check(filename, dir)
+ Dim source_list_headers, src_dir_headers, regexp, line, file, str
+
+ ' Define regexp for source.list parsing
+ Set regexp = New RegExp
+ regexp.Pattern = "\.h"
+ regexp.Global = True
+
+ ' Parse source.list and store headers in a dictionary
+ Set source_list_headers = CreateObject("Scripting.Dictionary")
+ Set file = FSO.OpenTextFile(filename, 1, 0, 0)
+ While Not file.AtEndOfStream
+ line = Replace(file.ReadLine, Chr(9), "") ' Remove tabs
+ If Len(line) > 0 And regexp.Test(line) And line <> "../objs/langs/table/strings.h" Then
+ source_list_headers.Add line, line
+ End If
+ Wend
+ file.Close()
+
+ ' Get header files in /src/
+ Set src_dir_headers = CreateObject("Scripting.Dictionary")
+ get_dir_files dir, FSO.GetFolder(dir), src_dir_headers
+
+ ' Finding files in source.list but not in /src/
+ For Each line In source_list_headers
+ If Not src_dir_headers.Exists(line) Then
+ str = str & "< " & line & vbCrLf
+ End If
+ Next
+
+ ' Finding files in /src/ but not in source.list
+ For Each line In src_dir_headers
+ If Not source_list_headers.Exists(line) Then
+ str = str & "> " & line & vbCrLf
+ End If
+ Next
+
+ ' Display the missing files if any
+ If str <> "" Then
+ str = "The following headers are missing in source.list and not in /src/ or vice versa." _
+ & vbCrLf & str
+ WScript.Echo str
+ End If
+End Sub
+
Function load_main_data(filename)
Dim res, file, line, deep, skip, first_time
res = ""
@@ -171,6 +250,7 @@
End If
safety_check ROOT_DIR & "/source.list"
+headers_check ROOT_DIR & "/source.list", ROOT_DIR & "\src\" ' Backslashes needed for DoFiles
Dim openttd
openttd = load_main_data(ROOT_DIR &"/source.list")
--- a/projects/openttd_vs80.vcproj Wed Apr 16 22:34:14 2008 +0000
+++ b/projects/openttd_vs80.vcproj Fri Apr 18 19:55:13 2008 +0000
@@ -492,6 +492,14 @@
>
</File>
<File
+ RelativePath=".\..\src\cheat.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\cheat_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\command.cpp"
>
</File>
@@ -728,6 +736,10 @@
>
</File>
<File
+ RelativePath=".\..\src\statusbar_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\string.cpp"
>
</File>
@@ -876,6 +888,14 @@
>
</File>
<File
+ RelativePath=".\..\src\cheat_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\cheat_type.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\currency.h"
>
</File>
@@ -900,7 +920,15 @@
>
</File>
<File
- RelativePath=".\..\src\depot.h"
+ RelativePath=".\..\src\depot_base.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\depot_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\depot_map.h"
>
</File>
<File
@@ -1172,10 +1200,6 @@
>
</File>
<File
- RelativePath=".\..\src\newgrf_string_type.h"
- >
- </File>
- <File
RelativePath=".\..\src\newgrf_text.h"
>
</File>
@@ -1192,6 +1216,10 @@
>
</File>
<File
+ RelativePath=".\..\src\news_gui.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\news_type.h"
>
</File>
@@ -2292,7 +2320,7 @@
>
</File>
<File
- RelativePath=".\..\src\misc\smallveh.h"
+ RelativePath=".\..\src\misc\smallvec.h"
>
</File>
<File
--- a/projects/openttd_vs90.vcproj Wed Apr 16 22:34:14 2008 +0000
+++ b/projects/openttd_vs90.vcproj Fri Apr 18 19:55:13 2008 +0000
@@ -489,6 +489,14 @@
>
</File>
<File
+ RelativePath=".\..\src\cheat.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\cheat_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\command.cpp"
>
</File>
@@ -717,6 +725,10 @@
>
</File>
<File
+ RelativePath=".\..\src\statusbar_gui.cpp"
+ >
+ </File>
+ <File
RelativePath=".\..\src\string.cpp"
>
</File>
@@ -869,6 +881,14 @@
>
</File>
<File
+ RelativePath=".\..\src\cheat_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\cheat_type.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\currency.h"
>
</File>
@@ -893,7 +913,15 @@
>
</File>
<File
- RelativePath=".\..\src\depot.h"
+ RelativePath=".\..\src\depot_base.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\depot_func.h"
+ >
+ </File>
+ <File
+ RelativePath=".\..\src\depot_map.h"
>
</File>
<File
@@ -1153,10 +1181,6 @@
>
</File>
<File
- RelativePath=".\..\src\newgrf_string_type.h"
- >
- </File>
- <File
RelativePath=".\..\src\newgrf_text.h"
>
</File>
@@ -1173,6 +1197,10 @@
>
</File>
<File
+ RelativePath=".\..\src\news_gui.h"
+ >
+ </File>
+ <File
RelativePath=".\..\src\news_type.h"
>
</File>
@@ -2269,7 +2297,7 @@
>
</File>
<File
- RelativePath=".\..\src\misc\smallveh.h"
+ RelativePath=".\..\src\misc\smallvec.h"
>
</File>
<File
--- a/source.list Wed Apr 16 22:34:14 2008 +0000
+++ b/source.list Fri Apr 18 19:55:13 2008 +0000
@@ -9,6 +9,8 @@
callback_table.cpp
cargopacket.cpp
cargotype.cpp
+cheat.cpp
+cheat_gui.cpp
command.cpp
console.cpp
console_cmds.cpp
@@ -75,6 +77,7 @@
sound.cpp
spritecache.cpp
station.cpp
+statusbar_gui.cpp
string.cpp
strings.cpp
texteff.cpp
@@ -140,13 +143,17 @@
command_func.h
command_type.h
console.h
+cheat_func.h
+cheat_type.h
currency.h
date_func.h
date_type.h
debug.h
video/dedicated_v.h
ai/default/default.h
-depot.h
+depot_base.h
+depot_func.h
+depot_map.h
depot_type.h
direction_func.h
direction_type.h
@@ -214,11 +221,11 @@
newgrf_spritegroup.h
newgrf_station.h
newgrf_storage.h
-newgrf_string_type.h
newgrf_text.h
newgrf_town.h
newgrf_townname.h
news_func.h
+news_gui.h
news_type.h
npf.h
music/null_m.h
@@ -520,7 +527,7 @@
misc/dbg_helpers.h
misc/fixedsizearray.hpp
misc/hashtable.hpp
-misc/smallveh.h
+misc/smallvec.h
misc/str.hpp
misc/strapi.hpp
--- a/src/ai/default/default.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/ai/default/default.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -16,7 +16,6 @@
#include "../../industry.h"
#include "../../pathfind.h"
#include "../../airport.h"
-#include "../../depot.h"
#include "../../variables.h"
#include "../../bridge.h"
#include "../../date_func.h"
@@ -330,7 +329,7 @@
EngineID veh;
// wait until the vehicle reaches the depot.
- if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
+ if (!IsRailDepotTile(v->tile) || v->u.rail.track != TRACK_BIT_DEPOT || !(v->vehstatus & VS_STOPPED)) {
AiHandleGotoDepot(p, CMD_SEND_TRAIN_TO_DEPOT);
return;
}
@@ -2886,7 +2885,7 @@
are.dest = _players_ai[p->index].cur_tile_b;
tile = TILE_MASK(_players_ai[p->index].cur_tile_a + TileOffsByDiagDir(dir));
- if (IsRoadStopTile(tile) || IsTileDepotType(tile, TRANSPORT_ROAD)) return false;
+ if (IsRoadStopTile(tile) || IsRoadDepotTile(tile)) return false;
TrackdirBits bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, ROADTYPES_ROAD)) & DiagdirReachesTrackdirs(dir);
if (bits == TRACKDIR_BIT_NONE) return false;
@@ -3098,7 +3097,7 @@
Axis axis = (TileX(t1) == TileX(t2) ? AXIS_Y : AXIS_X);
/* try to build a long road instead of bridge - CMD_BUILD_LONG_ROAD has to fail if it couldn't build at least one piece! */
- CommandCost cost = DoCommand(t2, t1, (t2 < t1 ? 1 : 2) | (axis << 2) | (ROADTYPE_ROAD << 3), DC_AUTO | DC_NO_WATER, CMD_BUILD_LONG_ROAD);
+ CommandCost cost = DoCommand(t2, t1, (t2 < t1 ? 1 : 2) | (axis << 2) | (ROADTYPE_ROAD << 3), DC_AUTO | DC_NO_WATER, CMD_BUILD_LONG_ROAD);
if (CmdSucceeded(cost) && cost.GetCost() <= p->player_money) {
DoCommand(t2, t1, (t2 < t1 ? 1 : 2) | (axis << 2) | (ROADTYPE_ROAD << 3), DC_AUTO | DC_EXEC | DC_NO_WATER, CMD_BUILD_LONG_ROAD);
@@ -3582,7 +3581,7 @@
if (v->owner == _current_player) {
if (v->type == VEH_TRAIN) {
- if (!IsTileDepotType(v->tile, TRANSPORT_RAIL) || v->u.rail.track != 0x80 || !(v->vehstatus&VS_STOPPED)) {
+ if (!IsRailDepotTile(v->tile) || v->u.rail.track != TRACK_BIT_DEPOT || !(v->vehstatus & VS_STOPPED)) {
if (!v->current_order.IsType(OT_GOTO_DEPOT))
DoCommand(0, v->index, 0, DC_EXEC, CMD_SEND_TRAIN_TO_DEPOT);
goto going_to_depot;
@@ -3972,11 +3971,11 @@
if (_players_ai[p->index].state != old_state) {
if (hasdots)
printf("\n");
- hasdots=false;
+ hasdots = false;
printf("AiState: %s\n", _ai_state_names[old_state=_players_ai[p->index].state]);
} else {
printf(".");
- hasdots=true;
+ hasdots = true;
}
}
#endif
--- a/src/ai/trolly/pathfinder.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/ai/trolly/pathfinder.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -6,7 +6,6 @@
#include "../../debug.h"
#include "../../command_func.h"
#include "trolly.h"
-#include "../../depot.h"
#include "../../tunnel_map.h"
#include "../../bridge.h"
#include "../../tunnelbridge_map.h"
@@ -45,7 +44,7 @@
{
return
// MP_ROAD, but not a road depot?
- (IsTileType(tile, MP_ROAD) && !IsTileDepotType(tile, TRANSPORT_ROAD)) ||
+ (IsTileType(tile, MP_ROAD) && !IsRoadDepot(tile)) ||
(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD);
}
@@ -343,7 +342,7 @@
// For now, we check both sides for this tile.. terraforming gives fuzzy result
if (tileh == InclinedSlope(dir)) {
// Now simply check if a tunnel can be build
- ret = AI_DoCommand(tile, (PathFinderInfo->rail_or_road?0:0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
+ ret = AI_DoCommand(tile, (PathFinderInfo->rail_or_road ? 0 : 0x200), 0, DC_AUTO, CMD_BUILD_TUNNEL);
tileh = GetTileSlope(_build_tunnel_endtile, NULL);
if (CmdSucceeded(ret) && IsInclinedSlope(tileh)) {
aystar->neighbours[aystar->num_neighbours].tile = _build_tunnel_endtile;
--- a/src/ai/trolly/trolly.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/ai/trolly/trolly.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -24,12 +24,13 @@
#include "../../station_map.h"
#include "../../command_func.h"
#include "trolly.h"
+#include "../../depot_base.h"
#include "../../town.h"
#include "../../industry.h"
#include "../../station_base.h"
#include "../../engine_func.h"
#include "../../gui.h"
-#include "../../depot.h"
+#include "../../depot_base.h"
#include "../../vehicle_base.h"
#include "../../vehicle_func.h"
#include "../../date_func.h"
@@ -795,7 +796,7 @@
_players_ainew[p->index].depot_tile = 0;
- for (i=2;i<_players_ainew[p->index].path_info.route_length-2;i++) {
+ for (i = 2; i < _players_ainew[p->index].path_info.route_length - 2; i++) {
tile = _players_ainew[p->index].path_info.route[i];
for (j = DIAGDIR_BEGIN; j < DIAGDIR_END; j++) {
TileIndex t = tile + TileOffsByDiagDir(j);
@@ -818,9 +819,9 @@
while (i > 1 && i < _players_ainew[p->index].path_info.route_length - 2) {
i += g;
g *= -1;
- (g < 0?g--:g++);
+ (g < 0 ? g-- : g++);
- if (_players_ainew[p->index].path_info.route_extra[i] != 0 || _players_ainew[p->index].path_info.route_extra[i+1] != 0) {
+ if (_players_ainew[p->index].path_info.route_extra[i] != 0 || _players_ainew[p->index].path_info.route_extra[i + 1] != 0) {
// Bridge or tunnel.. we can't place a depot there
continue;
}
@@ -948,7 +949,7 @@
_players_ainew[p->index].cur_veh = 0;
// Check how much it it going to cost us..
- for (i=0;i<res;i++) {
+ for (i = 0; i < res; i++) {
_players_ainew[p->index].new_cost += AiNew_Build_Vehicle(p, 0, DC_QUERY_COST).GetCost();
}
@@ -1254,8 +1255,8 @@
// We are already sending him back
if (AiNew_GetSpecialVehicleFlag(p, v) & AI_VEHICLEFLAG_SELL) {
- if (v->type == VEH_ROAD && IsTileDepotType(v->tile, TRANSPORT_ROAD) &&
- (v->vehstatus&VS_STOPPED)) {
+ if (v->type == VEH_ROAD && IsRoadDepotTile(v->tile) &&
+ (v->vehstatus & VS_STOPPED)) {
// We are at the depot, sell the vehicle
AI_DoCommand(0, v->index, 0, DC_EXEC, CMD_SELL_ROAD_VEH);
}
--- a/src/aircraft_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/aircraft_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -10,7 +10,7 @@
#include "landscape.h"
#include "station_map.h"
#include "timetable.h"
-#include "depot.h"
+#include "depot_func.h"
#include "news_func.h"
#include "aircraft.h"
#include "airport.h"
@@ -29,6 +29,7 @@
#include "sound_func.h"
#include "functions.h"
#include "variables.h"
+#include "cheat_func.h"
#include "autoreplace_func.h"
#include "autoreplace_gui.h"
#include "gfx_func.h"
--- a/src/aircraft_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/aircraft_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -7,7 +7,6 @@
#include "aircraft.h"
#include "debug.h"
#include "gui.h"
-#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"
--- a/src/airport_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/airport_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -12,7 +12,6 @@
#include "station_gui.h"
#include "station_func.h"
#include "airport.h"
-#include "depot.h"
#include "newgrf_callbacks.h"
#include "sound_func.h"
#include "settings_type.h"
@@ -24,6 +23,7 @@
#include "gfx_func.h"
#include "widgets/dropdown_func.h"
#include "order_func.h"
+#include "station_type.h"
#include "table/sprites.h"
#include "table/strings.h"
--- a/src/autoreplace_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/autoreplace_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -8,7 +8,6 @@
#include "player_func.h"
#include "debug.h"
#include "vehicle_gui.h"
-#include "depot.h"
#include "train.h"
#include "aircraft.h"
#include "cargotype.h"
--- a/src/autoslope.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/autoslope.h Fri Apr 18 19:55:13 2008 +0000
@@ -5,9 +5,9 @@
#ifndef AUTOSLOPE_H
#define AUTOSLOPE_H
-#include "depot.h"
#include "settings_type.h"
#include "player_func.h"
+#include "depot_func.h"
/**
* Autoslope check for tiles with an entrance on an edge.
--- a/src/blitter/32bpp_base.hpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/blitter/32bpp_base.hpp Fri Apr 18 19:55:13 2008 +0000
@@ -104,7 +104,7 @@
}
/**
- * Make a colour grey-based.
+ * Make a colour grey - based.
* @param colour the colour to make grey.
* @return the new colour, now grey.
*/
--- a/src/build_vehicle_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/build_vehicle_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -14,7 +14,6 @@
#include "textbuf_gui.h"
#include "command_func.h"
#include "player_func.h"
-#include "depot.h"
#include "airport.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
--- a/src/cargotype.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/cargotype.h Fri Apr 18 19:55:13 2008 +0000
@@ -7,7 +7,7 @@
#include "cargo_type.h"
#include "gfx_type.h"
-#include "newgrf_string_type.h"
+#include "strings_type.h"
typedef uint32 CargoLabel;
@@ -36,11 +36,11 @@
uint16 multipliertowngrowth;
uint8 callback_mask;
- GRFMappedStringID name;
- GRFMappedStringID name_single;
- GRFMappedStringID units_volume;
- GRFMappedStringID quantifier;
- GRFMappedStringID abbrev;
+ StringID name;
+ StringID name_single;
+ StringID units_volume;
+ StringID quantifier;
+ StringID abbrev;
SpriteID sprite;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cheat.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,57 @@
+/* $Id$ */
+
+/** @file misc.cpp */
+
+#include "stdafx.h"
+#include "saveload.h"
+#include "cheat_type.h"
+
+Cheats _cheats;
+
+void InitializeCheats()
+{
+ memset(&_cheats, 0, sizeof(Cheats));
+}
+
+static void Save_CHTS()
+{
+ /* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
+ byte count = sizeof(_cheats) / sizeof(Cheat);
+ Cheat *cht = (Cheat*) &_cheats;
+ Cheat *cht_last = &cht[count];
+
+ SlSetLength(count * 2);
+ for (; cht != cht_last; cht++) {
+ SlWriteByte(cht->been_used);
+ SlWriteByte(cht->value);
+ }
+}
+
+static void Load_CHTS()
+{
+ Cheat *cht = (Cheat*)&_cheats;
+ uint count = SlGetFieldLength() / 2;
+
+ for (uint i = 0; i < count; i++) {
+ cht[i].been_used = (SlReadByte() != 0);
+ cht[i].value = (SlReadByte() != 0);
+ }
+}
+
+bool CheatHasBeenUsed()
+{
+ /* Cannot use lengthof because _cheats is of type Cheats, not Cheat */
+ const Cheat* cht = (Cheat*)&_cheats;
+ const Cheat* cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
+
+ for (; cht != cht_last; cht++) {
+ if (cht->been_used) return true;
+ }
+
+ return false;
+}
+
+
+extern const ChunkHandler _cheat_chunk_handlers[] = {
+ { 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST}
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cheat_func.h Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,20 @@
+/* $Id$ */
+
+/** @file cheat_func.h Functions related to cheating. */
+
+#ifndef CHEAT_FUNC_H
+#define CHEAT_FUNC_H
+
+#include "cheat_type.h"
+
+extern Cheats _cheats;
+
+void ShowCheatWindow();
+
+/**
+ * Return true if any cheat has been used, false otherwise
+ * @return has a cheat been used?
+ */
+bool CheatHasBeenUsed();
+
+#endif /* CHEAT_FUNC_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cheat_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,233 @@
+/* $Id$ */
+
+/** @file misc_gui.cpp */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "command_func.h"
+#include "cheat_func.h"
+#include "player_base.h"
+#include "player_func.h"
+#include "gfx_func.h"
+#include "date_func.h"
+#include "saveload.h"
+#include "window_gui.h"
+#include "newgrf.h"
+#include "settings_type.h"
+#include "strings_func.h"
+#include "window_func.h"
+#include "rail_gui.h"
+#include "gui.h"
+#include "player_gui.h"
+
+#include "table/strings.h"
+#include "table/sprites.h"
+
+
+/**
+ * The 'amount' to cheat with.
+ * This variable is semantically a constant value, but because the cheat
+ * code requires to be able to write to the variable it is not constified.
+ */
+static int32 _money_cheat_amount = 10000000;
+
+static int32 ClickMoneyCheat(int32 p1, int32 p2)
+{
+ DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, NULL, CMD_MONEY_CHEAT);
+ return _money_cheat_amount;
+}
+
+/**
+ * @param p1 player to set to
+ * @param p2 is -1 or +1 (down/up)
+ */
+static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
+{
+ while (IsValidPlayer((PlayerID)p1)) {
+ if (_players[p1].is_active) {
+ SetLocalPlayer((PlayerID)p1);
+
+ MarkWholeScreenDirty();
+ return _local_player;
+ }
+ p1 += p2;
+ }
+
+ return _local_player;
+}
+
+/**
+ * @param p1 -1 or +1 (down/up)
+ * @param p2 unused
+ */
+static int32 ClickChangeClimateCheat(int32 p1, int32 p2)
+{
+ if (p1 == -1) p1 = 3;
+ if (p1 == 4) p1 = 0;
+ _opt.landscape = p1;
+ ReloadNewGRFData();
+ return _opt.landscape;
+}
+
+extern void EnginesMonthlyLoop();
+
+/**
+ * @param p1 unused
+ * @param p2 1 (increase) or -1 (decrease)
+ */
+static int32 ClickChangeDateCheat(int32 p1, int32 p2)
+{
+ YearMonthDay ymd;
+ ConvertDateToYMD(_date, &ymd);
+
+ if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
+
+ SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
+ EnginesMonthlyLoop();
+ SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
+ ResetSignalVariant();
+ return _cur_year;
+}
+
+typedef int32 CheckButtonClick(int32, int32);
+
+struct CheatEntry {
+ VarType type; ///< type of selector
+ StringID str; ///< string with descriptive text
+ void *variable; ///< pointer to the variable
+ bool *been_used; ///< has this cheat been used before?
+ CheckButtonClick *proc;///< procedure
+};
+
+static const CheatEntry _cheats_ui[] = {
+ {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
+ {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
+ {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
+ {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
+ {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
+ {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
+};
+
+
+static const Widget _cheat_widgets[] = {
+{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS},
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_CHEATS_TIP},
+{ WIDGETS_END},
+};
+
+static void CheatsWndProc(Window *w, WindowEvent *e)
+{
+ switch (e->event) {
+ case WE_PAINT: {
+ int clk = WP(w, def_d).data_1;
+
+ DrawWindowWidgets(w);
+ DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, w->width - 50);
+
+ for (int i = 0, x = 0, y = 45; i != lengthof(_cheats_ui); i++) {
+ const CheatEntry *ce = &_cheats_ui[i];
+
+ DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, x + 5, y + 2);
+
+ switch (ce->type) {
+ case SLE_BOOL: {
+ bool on = (*(bool*)ce->variable);
+
+ DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, on ? 6 : 4, on ? FR_LOWERED : FR_NONE);
+ SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
+ } break;
+
+ default: {
+ int32 val = (int32)ReadValue(ce->variable, ce->type);
+ char buf[512];
+
+ /* Draw [<][>] boxes for settings of an integer-type */
+ DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true, true);
+
+ switch (ce->str) {
+ /* Display date for change date cheat */
+ case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break;
+
+ /* Draw colored flag for change player cheat */
+ case STR_CHEAT_CHANGE_PLAYER:
+ SetDParam(0, val);
+ GetString(buf, STR_CHEAT_CHANGE_PLAYER, lastof(buf));
+ DrawPlayerIcon(_current_player, 60 + GetStringBoundingBox(buf).width, y + 2);
+ break;
+
+ /* Set correct string for switch climate cheat */
+ case STR_CHEAT_SWITCH_CLIMATE: val += STR_TEMPERATE_LANDSCAPE;
+
+ /* Fallthrough */
+ default: SetDParam(0, val);
+ }
+ } break;
+ }
+
+ DrawString(50, y + 1, ce->str, TC_FROMSTRING);
+
+ y += 12;
+ }
+ break;
+ }
+
+ case WE_CLICK: {
+ uint btn = (e->we.click.pt.y - 46) / 12;
+ uint x = e->we.click.pt.x;
+
+ /* Not clicking a button? */
+ if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) break;
+
+ const CheatEntry *ce = &_cheats_ui[btn];
+ int value = (int32)ReadValue(ce->variable, ce->type);
+ int oldvalue = value;
+
+ *ce->been_used = true;
+
+ switch (ce->type) {
+ case SLE_BOOL:
+ value ^= 1;
+ if (ce->proc != NULL) ce->proc(value, 0);
+ break;
+
+ default:
+ /* Take whatever the function returns */
+ value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1);
+
+ if (value != oldvalue) WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
+ break;
+ }
+
+ if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
+
+ w->flags4 |= 5 << WF_TIMEOUT_SHL;
+
+ SetWindowDirty(w);
+ } break;
+
+ case WE_TIMEOUT:
+ WP(w, def_d).data_1 = 0;
+ SetWindowDirty(w);
+ break;
+ }
+}
+
+static const WindowDesc _cheats_desc = {
+ 240, 22, 400, 170, 400, 170,
+ WC_CHEATS, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+ _cheat_widgets,
+ CheatsWndProc
+};
+
+
+void ShowCheatWindow()
+{
+ DeleteWindowById(WC_CHEATS, 0);
+ AllocateWindowDesc(&_cheats_desc);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cheat_type.h Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,36 @@
+/* $Id$ */
+
+/** @file cheat_type.h Types related to cheating. */
+
+#ifndef CHEAT_TYPE_H
+#define CHEAT_TYPE_H
+
+/**
+ * Info about each of the cheats.
+ */
+struct Cheat {
+ bool been_used; ///< has this cheat been used before?
+ bool value; ///< tells if the bool cheat is active or not
+};
+
+/**
+ * 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
+ Cheat switch_player; ///< change to another player
+ Cheat money; ///< get rich or poor
+ Cheat crossing_tunnels; ///< allow tunnels that cross each other
+ Cheat build_in_pause; ///< build while in pause mode
+ Cheat no_jetcrash; ///< no jet will crash on small airports anymore
+ Cheat switch_climate; ///< change the climate of the map
+ Cheat change_date; ///< changes date ingame
+ Cheat setup_prod; ///< setup raw-material production in game
+ Cheat dummy; ///< empty cheat (enable running el-engines on normal rail)
+};
+
+extern Cheats _cheats;
+
+#endif /* CHEAT_TYPE_H */
--- a/src/core/alloc_type.hpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/core/alloc_type.hpp Fri Apr 18 19:55:13 2008 +0000
@@ -88,6 +88,9 @@
* Memory release for a single class instance.
* @param ptr the memory to free.
* @param size the amount of allocated memory (unused).
+ *
+ * @warning The value of the \a size parameter can only be trusted for
+ * classes that have their own (virtual) destructor method.
*/
void operator delete(void *ptr, size_t size) { free(ptr); }
@@ -95,6 +98,9 @@
* Memory release for an array of class instances.
* @param ptr the memory to free.
* @param size the amount of allocated memory (unused).
+ *
+ * @warning The value of the \a size parameter can only be trusted for
+ * classes that have their own (virtual) destructor method.
*/
void operator delete[](void *ptr, size_t size) { free(ptr); }
};
--- a/src/core/enum_type.hpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/core/enum_type.hpp Fri Apr 18 19:55:13 2008 +0000
@@ -66,7 +66,7 @@
/** In some cases we use byte or uint16 to store values that are defined as enum. It is
* necessary in order to control the sizeof() such values. Some compilers make enum
* the same size as int (4 or 8 bytes instead of 1 or 2). As a consequence the strict
- * compiler type-checking causes errors like:
+ * compiler type - checking causes errors like:
* 'HasPowerOnRail' : cannot convert parameter 1 from 'byte' to 'RailType' when
* u->u.rail.railtype is passed as argument or type RailType. In such cases it is better
* to teach the compiler that u->u.rail.railtype is to be treated as RailType. */
--- a/src/depot.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/depot.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -4,7 +4,7 @@
#include "stdafx.h"
#include "openttd.h"
-#include "depot.h"
+#include "depot_base.h"
#include "landscape.h"
#include "saveload.h"
#include "order_func.h"
--- a/src/depot.h Wed Apr 16 22:34:14 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-/* $Id$ */
-
-/** @file depot.h Header files for depots (not hangars) */
-
-#ifndef DEPOT_H
-#define DEPOT_H
-
-#include "direction_type.h"
-#include "depot_type.h"
-#include "oldpool.h"
-#include "road_map.h"
-#include "rail_map.h"
-#include "water_map.h"
-#include "station_map.h"
-
-DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
-
-struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
- TileIndex xy;
- TownID town_index;
-
- Depot(TileIndex xy = 0) : xy(xy) {}
- ~Depot();
-
- inline bool IsValid() const { return this->xy != 0; }
-};
-
-static inline bool IsValidDepotID(DepotID index)
-{
- return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
-}
-
-void ShowDepotWindow(TileIndex tile, VehicleType type);
-
-#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
-#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
-
-/**
- * Check if a tile is a depot of the given type.
- */
-static inline bool IsTileDepotType(TileIndex tile, TransportType type)
-{
- switch (type) {
- case TRANSPORT_RAIL:
- return IsTileType(tile, MP_RAILWAY) && GetRailTileType(tile) == RAIL_TILE_DEPOT;
-
- case TRANSPORT_ROAD:
- return IsRoadDepotTile(tile);
-
- case TRANSPORT_WATER:
- return IsTileType(tile, MP_WATER) && GetWaterTileType(tile) == WATER_TILE_DEPOT;
-
- default:
- NOT_REACHED();
- return false;
- }
-}
-
-/**
- * Is the given tile a tile with a depot on it?
- * @param tile the tile to check
- * @return true if and only if there is a depot on the tile.
- */
-static inline bool IsDepotTile(TileIndex tile)
-{
- switch (GetTileType(tile)) {
- case MP_ROAD: return IsRoadDepot(tile);
- case MP_WATER: return GetWaterTileType(tile) == WATER_TILE_DEPOT;
- case MP_RAILWAY: return GetRailTileType(tile) == RAIL_TILE_DEPOT;
- case MP_STATION: return IsHangar(tile);
- default: return false;
- }
-}
-
-/**
- * Find out if the slope of the tile is suitable to build a depot of given direction
- * @param direction The direction in which the depot's exit points
- * @param tileh The slope of the tile in question
- * @return true if the construction is possible
-
- * This is checked by the ugly 0x4C >> direction magic, which does the following:
- * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
- * So: for direction (only the significant bits are shown)<p>
- * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
- * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
- * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
- * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
- * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
- */
-static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
-{
- return ((0x4C >> direction) & tileh) != 0;
-}
-
-Depot *GetDepotByTile(TileIndex tile);
-void InitializeDepots();
-
-void DeleteDepotHighlightOfVehicle(const Vehicle *v);
-
-#endif /* DEPOT_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/depot_base.h Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,35 @@
+/* $Id$ */
+
+/** @file depot.h Base for all depots (except hangars) */
+
+#ifndef DEPOT_BASE_H
+#define DEPOT_BASE_H
+
+#include "tile_type.h"
+#include "depot_type.h"
+#include "oldpool.h"
+#include "town_type.h"
+
+DECLARE_OLD_POOL(Depot, Depot, 3, 8000)
+
+struct Depot : PoolItem<Depot, DepotID, &_Depot_pool> {
+ TileIndex xy;
+ TownID town_index;
+
+ Depot(TileIndex xy = 0) : xy(xy) {}
+ ~Depot();
+
+ inline bool IsValid() const { return this->xy != 0; }
+};
+
+static inline bool IsValidDepotID(DepotID index)
+{
+ return index < GetDepotPoolSize() && GetDepot(index)->IsValid();
+}
+
+Depot *GetDepotByTile(TileIndex tile);
+
+#define FOR_ALL_DEPOTS_FROM(d, start) for (d = GetDepot(start); d != NULL; d = (d->index + 1U < GetDepotPoolSize()) ? GetDepot(d->index + 1U) : NULL) if (d->IsValid())
+#define FOR_ALL_DEPOTS(d) FOR_ALL_DEPOTS_FROM(d, 0)
+
+#endif /* DEPOT_BASE_H */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/depot_func.h Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,39 @@
+/* $Id$ */
+
+/** @file depot_func.h Functions related to depots. */
+
+#ifndef DEPOT_FUNC_H
+#define DEPOT_FUNC_H
+
+#include "depot_type.h"
+#include "tile_type.h"
+#include "vehicle_type.h"
+#include "direction_type.h"
+#include "slope_type.h"
+
+void ShowDepotWindow(TileIndex tile, VehicleType type);
+void InitializeDepots();
+
+void DeleteDepotHighlightOfVehicle(const Vehicle *v);
+
+/**
+ * Find out if the slope of the tile is suitable to build a depot of given direction
+ * @param direction The direction in which the depot's exit points
+ * @param tileh The slope of the tile in question
+ * @return true if the construction is possible
+
+ * This is checked by the ugly 0x4C >> direction magic, which does the following:
+ * 0x4C is 0100 1100 and tileh has only bits 0..3 set (steep tiles are ruled out)
+ * So: for direction (only the significant bits are shown)<p>
+ * 00 (exit towards NE) we need either bit 2 or 3 set in tileh: 0x4C >> 0 = 1100<p>
+ * 01 (exit towards SE) we need either bit 1 or 2 set in tileh: 0x4C >> 1 = 0110<p>
+ * 02 (exit towards SW) we need either bit 0 or 1 set in tileh: 0x4C >> 2 = 0011<p>
+ * 03 (exit towards NW) we need either bit 0 or 4 set in tileh: 0x4C >> 3 = 1001<p>
+ * So ((0x4C >> direction) & tileh) determines whether the depot can be built on the current tileh
+ */
+static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
+{
+ return ((0x4C >> direction) & tileh) != 0;
+}
+
+#endif /* DEPOT_FUNC_H */
--- a/src/depot_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/depot_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -13,7 +13,7 @@
#include "viewport_func.h"
#include "gfx_func.h"
#include "command_func.h"
-#include "depot.h"
+#include "depot_base.h"
#include "vehicle_gui.h"
#include "station_map.h"
#include "newgrf_engine.h"
@@ -23,6 +23,7 @@
#include "vehicle_func.h"
#include "player_func.h"
#include "order_func.h"
+#include "depot_base.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -204,7 +205,7 @@
DrawSprite((v->vehstatus & VS_STOPPED) ? SPR_FLAG_VEH_STOPPED : SPR_FLAG_VEH_RUNNING, PAL_NONE, x + diff_x, y + diff_y);
SetDParam(0, v->unitnumber);
- DrawString(x, y + 2, (uint16)(v->max_age-366) >= v->age ? STR_00E2 : STR_00E3, TC_FROMSTRING);
+ DrawString(x, y + 2, (uint16)(v->max_age - 366) >= v->age ? STR_00E2 : STR_00E3, TC_FROMSTRING);
}
static void DrawDepotWindow(Window *w)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/depot_map.h Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,41 @@
+/* $Id$ */
+
+/** @file depot_map.h Map related accessors for depots. */
+
+#ifndef DEPOT_MAP_H
+#define DEPOT_MAP_H
+
+#include "road_map.h"
+#include "rail_map.h"
+#include "water_map.h"
+#include "station_map.h"
+
+/**
+ * Check if a tile is a depot and it is a depot of the given type.
+ */
+static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
+{
+ switch (type) {
+ default: NOT_REACHED();
+ case TRANSPORT_RAIL:
+ return IsRailDepotTile(tile);
+
+ case TRANSPORT_ROAD:
+ return IsRoadDepotTile(tile);
+
+ case TRANSPORT_WATER:
+ return IsShipDepotTile(tile);
+ }
+}
+
+/**
+ * Is the given tile a tile with a depot on it?
+ * @param tile the tile to check
+ * @return true if and only if there is a depot on the tile.
+ */
+static inline bool IsDepotTile(TileIndex tile)
+{
+ return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
+}
+
+#endif /* DEPOT_MAP_H */
--- a/src/genworld.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/genworld.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -86,85 +86,89 @@
*/
static void * CDECL _GenerateWorld(void *arg)
{
- _generating_world = true;
- if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait...");
- /* Set the Random() seed to generation_seed so we produce the same map with the same seed */
- if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom();
- _random.SetSeed(_patches.generation_seed);
- SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
- SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
-
- IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
- /* Must start economy early because of the costs. */
- StartupEconomy();
-
- /* Don't generate landscape items when in the scenario editor. */
- if (_gw.mode == GW_EMPTY) {
- SetGeneratingWorldProgress(GWP_UNMOVABLE, 1);
-
- /* Make the map the height of the patch setting */
- if (_game_mode != GM_MENU) FlatEmptyWorld(_patches.se_flat_world_height);
-
- ConvertGroundTilesIntoWaterTiles();
- IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
- } else {
- GenerateLandscape(_gw.mode);
- GenerateClearTile();
-
- /* only generate towns, tree and industries in newgame mode. */
- if (_game_mode != GM_EDITOR) {
- GenerateTowns();
- GenerateIndustries();
- GenerateUnmovables();
- GenerateTrees();
- }
- }
-
- ClearStorageChanges(true);
+ try {
+ _generating_world = true;
+ if (_network_dedicated) DEBUG(net, 0, "Generating map, please wait...");
+ /* Set the Random() seed to generation_seed so we produce the same map with the same seed */
+ if (_patches.generation_seed == GENERATE_NEW_SEED) _patches.generation_seed = _patches_newgame.generation_seed = InteractiveRandom();
+ _random.SetSeed(_patches.generation_seed);
+ SetGeneratingWorldProgress(GWP_MAP_INIT, 2);
+ SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, VHM_NONE, WC_MAIN_WINDOW, 0);
- /* These are probably pointless when inside the scenario editor. */
- SetGeneratingWorldProgress(GWP_GAME_INIT, 3);
- StartupPlayers();
- IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
- StartupEngines();
- IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
- StartupDisasters();
- _generating_world = false;
-
- /* No need to run the tile loop in the scenario editor. */
- if (_gw.mode != GW_EMPTY) {
- uint i;
-
- SetGeneratingWorldProgress(GWP_RUNTILELOOP, 0x500);
- for (i = 0; i < 0x500; i++) {
- RunTileLoop();
- IncreaseGeneratingWorldProgress(GWP_RUNTILELOOP);
- }
- }
+ IncreaseGeneratingWorldProgress(GWP_MAP_INIT);
+ /* Must start economy early because of the costs. */
+ StartupEconomy();
- ResetObjectToPlace();
- SetLocalPlayer(_gw.lp);
-
- SetGeneratingWorldProgress(GWP_GAME_START, 1);
- /* Call any callback */
- if (_gw.proc != NULL) _gw.proc();
- IncreaseGeneratingWorldProgress(GWP_GAME_START);
+ /* Don't generate landscape items when in the scenario editor. */
+ if (_gw.mode == GW_EMPTY) {
+ SetGeneratingWorldProgress(GWP_UNMOVABLE, 1);
- if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
- /* Show all vital windows again, because we have hidden them */
- if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
- _gw.active = false;
- _gw.thread = NULL;
- _gw.proc = NULL;
- _gw.threaded = false;
+ /* Make the map the height of the patch setting */
+ if (_game_mode != GM_MENU) FlatEmptyWorld(_patches.se_flat_world_height);
- DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
- MarkWholeScreenDirty();
+ ConvertGroundTilesIntoWaterTiles();
+ IncreaseGeneratingWorldProgress(GWP_UNMOVABLE);
+ } else {
+ GenerateLandscape(_gw.mode);
+ GenerateClearTile();
- if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
+ /* only generate towns, tree and industries in newgame mode. */
+ if (_game_mode != GM_EDITOR) {
+ GenerateTowns();
+ GenerateIndustries();
+ GenerateUnmovables();
+ GenerateTrees();
+ }
+ }
- if (_patches.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
+ ClearStorageChanges(true);
+ /* These are probably pointless when inside the scenario editor. */
+ SetGeneratingWorldProgress(GWP_GAME_INIT, 3);
+ StartupPlayers();
+ IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
+ StartupEngines();
+ IncreaseGeneratingWorldProgress(GWP_GAME_INIT);
+ StartupDisasters();
+ _generating_world = false;
+
+ /* No need to run the tile loop in the scenario editor. */
+ if (_gw.mode != GW_EMPTY) {
+ uint i;
+
+ SetGeneratingWorldProgress(GWP_RUNTILELOOP, 0x500);
+ for (i = 0; i < 0x500; i++) {
+ RunTileLoop();
+ IncreaseGeneratingWorldProgress(GWP_RUNTILELOOP);
+ }
+ }
+
+ ResetObjectToPlace();
+ SetLocalPlayer(_gw.lp);
+
+ SetGeneratingWorldProgress(GWP_GAME_START, 1);
+ /* Call any callback */
+ if (_gw.proc != NULL) _gw.proc();
+ IncreaseGeneratingWorldProgress(GWP_GAME_START);
+
+ if (_cursor.sprite == SPR_CURSOR_ZZZ) SetMouseCursor(SPR_CURSOR_MOUSE, PAL_NONE);
+ /* Show all vital windows again, because we have hidden them */
+ if (_gw.threaded && _game_mode != GM_MENU) ShowVitalWindows();
+ _gw.active = false;
+ _gw.thread = NULL;
+ _gw.proc = NULL;
+ _gw.threaded = false;
+
+ DeleteWindowById(WC_GENERATE_PROGRESS_WINDOW, 0);
+ MarkWholeScreenDirty();
+
+ if (_network_dedicated) DEBUG(net, 0, "Map generated, starting game");
+
+ if (_patches.pause_on_newgame && _game_mode == GM_NORMAL) DoCommandP(0, 1, 0, NULL, CMD_PAUSE);
+ } catch (...) {
+ _generating_world = false;
+ throw;
+ }
return NULL;
}
--- a/src/group_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/group_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -9,7 +9,6 @@
#include "textbuf_gui.h"
#include "command_func.h"
#include "vehicle_gui.h"
-#include "depot.h"
#include "train.h"
#include "group.h"
#include "debug.h"
@@ -207,7 +206,7 @@
w->widget[GRP_WIDGET_LIST_VEHICLE].data = (w->vscroll2.cap << 8) + 1;
switch (gv->vehicle_type) {
- default: NOT_REACHED(); break;
+ default: NOT_REACHED();
case VEH_TRAIN: gv->_sorting = &_sorting.train; break;
case VEH_ROAD: gv->_sorting = &_sorting.roadveh; break;
case VEH_SHIP: gv->_sorting = &_sorting.ship; break;
@@ -218,11 +217,11 @@
gv->vehicle_type = (VehicleType)GB(w->window_number, 11, 5);
gv->l.sort_type = gv->_sorting->criteria;
gv->l.flags = VL_REBUILD | (gv->_sorting->order ? VL_DESC : VL_NONE);
- gv->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
+ gv->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
gl->sort_list = NULL;
gl->l.flags = VL_REBUILD | VL_NONE;
- gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
+ gl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS; // Set up resort timer
gv->group_sel = ALL_GROUP;
gv->vehicle_sel = INVALID_VEHICLE;
@@ -399,7 +398,7 @@
w->widget[GRP_WIDGET_CAPTION].data = STR_A009_AIRCRAFT;
w->widget[GRP_WIDGET_REPLACE_PROTECTION].data = SPR_GROUP_REPLACE_OFF_AIRCRAFT;
break;
- default: NOT_REACHED(); break;
+ default: NOT_REACHED();
}
} else {
const Group *g = GetGroup(gv->group_sel);
@@ -424,7 +423,7 @@
w->widget[GRP_WIDGET_CAPTION].data = STR_GROUP_AIRCRAFTS_CAPTION;
w->widget[GRP_WIDGET_REPLACE_PROTECTION].data = (g->replace_protection) ? SPR_GROUP_REPLACE_ON_AIRCRAFT : SPR_GROUP_REPLACE_OFF_AIRCRAFT;
break;
- default: NOT_REACHED(); break;
+ default: NOT_REACHED();
}
}
@@ -454,7 +453,7 @@
str_all_veh = STR_GROUP_ALL_AIRCRAFTS;
str_no_group_veh = STR_GROUP_DEFAULT_AIRCRAFTS;
break;
- default: NOT_REACHED(); break;
+ default: NOT_REACHED();
}
DrawString(10, y1, str_all_veh, IsAllGroupID(gv->group_sel) ? TC_WHITE : TC_BLACK);
@@ -524,7 +523,7 @@
break;
case GRP_WIDGET_SORT_BY_DROPDOWN: // Select sorting criteria dropdown menu
- ShowDropDownMenu(w, _vehicle_sort_listing, gv->l.sort_type, GRP_WIDGET_SORT_BY_DROPDOWN, 0, 0);
+ ShowDropDownMenu(w, _vehicle_sort_listing, gv->l.sort_type, GRP_WIDGET_SORT_BY_DROPDOWN, 0, (gv->vehicle_type == VEH_TRAIN || gv->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
return;
case GRP_WIDGET_ALL_VEHICLES: // All vehicles button
@@ -601,7 +600,7 @@
SetDParam(0, g->index);
ShowQueryString(STR_GROUP_NAME, STR_GROUP_RENAME_CAPTION, 31, 150, w, CS_ALPHANUMERAL);
- } break;
+ } break;
case GRP_WIDGET_AVAILABLE_VEHICLES:
--- a/src/gui.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/gui.h Fri Apr 18 19:55:13 2008 +0000
@@ -17,8 +17,6 @@
void CcBuildCanal(bool success, TileIndex tile, uint32 p1, uint32 p2);
void HandleOnEditText(const char *str);
void InitializeGUI();
-Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray);
-Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask);
/* settings_gui.cpp */
void ShowGameOptions();
@@ -36,11 +34,6 @@
void ShowCompanyLeagueTable();
void ShowPerformanceRatingDetail();
-/* news_gui.cpp */
-void ShowLastNewsMessage();
-void ShowMessageOptions();
-void ShowMessageHistory();
-
/* train_gui.cpp */
void ShowOrdersWindow(const Vehicle *v);
@@ -104,8 +97,6 @@
void SetVScroll2Count(Window *w, int num);
void SetHScrollCount(Window *w, int num);
-void ShowCheatWindow();
-
void BuildFileList();
void SetFiosType(const byte fiostype);
--- a/src/industry.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/industry.h Fri Apr 18 19:55:13 2008 +0000
@@ -15,7 +15,6 @@
#include "date_type.h"
#include "town_type.h"
#include "industry_type.h"
-#include "newgrf_string_type.h"
enum {
INVALID_INDUSTRY = 0xFFFF,
@@ -174,12 +173,12 @@
byte climate_availability; ///< Bitmask, giving landscape enums as bit position
IndustryBehaviour behaviour; ///< How this industry will behave, and how others entities can use it
byte map_colour; ///< colour used for the small map
- GRFMappedStringID name; ///< Displayed name of the industry
- GRFMappedStringID new_industry_text; ///< Message appearing when the industry is built
- GRFMappedStringID closure_text; ///< Message appearing when the industry closes
- GRFMappedStringID production_up_text; ///< Message appearing when the industry's production is increasing
- GRFMappedStringID production_down_text; ///< Message appearing when the industry's production is decreasing
- GRFMappedStringID station_name; ///< Default name for nearby station
+ StringID name; ///< Displayed name of the industry
+ StringID new_industry_text; ///< Message appearing when the industry is built
+ StringID closure_text; ///< Message appearing when the industry closes
+ StringID production_up_text; ///< Message appearing when the industry's production is increasing
+ StringID production_down_text; ///< Message appearing when the industry's production is decreasing
+ StringID station_name; ///< Default name for nearby station
byte appear_ingame[NUM_LANDSCAPE]; ///< Probability of appearance in game
byte appear_creation[NUM_LANDSCAPE]; ///< Probability of appearance during map creation
uint8 number_of_sounds; ///< Number of sounds available in the sounds array
--- a/src/industry_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/industry_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -16,6 +16,7 @@
#include "news_func.h"
#include "saveload.h"
#include "variables.h"
+#include "cheat_func.h"
#include "genworld.h"
#include "water_map.h"
#include "tree_map.h"
--- a/src/industry_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/industry_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -14,6 +14,7 @@
#include "industry.h"
#include "town.h"
#include "variables.h"
+#include "cheat_func.h"
#include "cargotype.h"
#include "newgrf.h"
#include "newgrf_callbacks.h"
--- a/src/intro_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/intro_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -106,7 +106,7 @@
}
break;
- case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
+ case SGI_TEMPERATE_LANDSCAPE: case SGI_ARCTIC_LANDSCAPE:
case SGI_TROPIC_LANDSCAPE: case SGI_TOYLAND_LANDSCAPE:
w->RaiseWidget(_opt_newgame.landscape + SGI_TEMPERATE_LANDSCAPE);
SetNewLandscapeType(e->we.click.widget - SGI_TEMPERATE_LANDSCAPE);
--- a/src/landscape.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/landscape.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -610,6 +610,7 @@
}
+TileIndex _cur_tileloop_tile;
#define TILELOOP_BITS 4
#define TILELOOP_SIZE (1 << TILELOOP_BITS)
#define TILELOOP_ASSERTMASK ((TILELOOP_SIZE - 1) + ((TILELOOP_SIZE - 1) << MapLogX()))
--- a/src/lang/english.txt Wed Apr 16 22:34:14 2008 +0000
+++ b/src/lang/english.txt Fri Apr 18 19:55:13 2008 +0000
@@ -378,6 +378,7 @@
STR_SORT_BY_MAX_SPEED :Maximum speed
STR_SORT_BY_MODEL :Model
STR_SORT_BY_VALUE :Value
+STR_SORT_BY_LENGTH :Length
STR_SORT_BY_FACILITY :Station type
STR_SORT_BY_WAITING :Waiting cargo value
STR_SORT_BY_RATING_MAX :Cargo rating
--- a/src/main_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/main_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -4,7 +4,6 @@
#include "stdafx.h"
#include "openttd.h"
-#include "heightmap.h"
#include "currency.h"
#include "spritecache.h"
#include "gui.h"
@@ -13,29 +12,14 @@
#include "textbuf_gui.h"
#include "viewport_func.h"
#include "command_func.h"
-#include "news_func.h"
-#include "town.h"
+#include "news_gui.h"
#include "console.h"
-#include "signs_func.h"
#include "waypoint.h"
-#include "variables.h"
-#include "train.h"
-#include "roadveh.h"
-#include "bridge_map.h"
-#include "screenshot.h"
#include "genworld.h"
-#include "vehicle_gui.h"
#include "transparency_gui.h"
-#include "newgrf_config.h"
-#include "rail_gui.h"
-#include "road_gui.h"
#include "date_func.h"
#include "functions.h"
-#include "vehicle_func.h"
#include "sound_func.h"
-#include "fios.h"
-#include "terraform_gui.h"
-#include "industry.h"
#include "transparency.h"
#include "strings_func.h"
#include "zoom_func.h"
@@ -45,6 +29,7 @@
#include "player_gui.h"
#include "settings_type.h"
#include "toolbar_gui.h"
+#include "variables.h"
#include "network/network.h"
#include "network/network_data.h"
@@ -58,11 +43,6 @@
static int _rename_id = 1;
static int _rename_what = -1;
-RailType _last_built_railtype;
-RoadType _last_built_roadtype;
-bool _draw_bounding_boxes = false;
-
-
void CcGiveMoney(bool success, TileIndex tile, uint32 p1, uint32 p2)
{
#ifdef ENABLE_NETWORK
@@ -142,167 +122,6 @@
if (success) SndPlayTileFx(SND_12_EXPLOSION, tile);
}
-
-static void MenuClickSettings(int index)
-{
- switch (index) {
- case 0: ShowGameOptions(); return;
- case 1: ShowGameDifficulty(); return;
- case 2: ShowPatchesSelection(); return;
- case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig); return;
- case 4: ShowTransparencyToolbar(); break;
-
- case 6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
- case 7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
- case 8: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
- case 9: ToggleBit(_display_opt, DO_WAYPOINTS); break;
- case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION); break;
- case 11: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
- case 12: ToggleTransparency(TO_HOUSES); break;
- case 13: ToggleTransparency(TO_SIGNS); break;
- }
- MarkWholeScreenDirty();
-}
-
-void MenuClickSaveLoad(int index)
-{
- if (_game_mode == GM_EDITOR) {
- switch (index) {
- case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO); break;
- case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
- case 2: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
- case 3: AskExitToGameMenu(); break;
- case 5: HandleExitGameRequest(); break;
- }
- } else {
- switch (index) {
- case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
- case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
- case 2: AskExitToGameMenu(); break;
- case 3: HandleExitGameRequest(); break;
- }
- }
-}
-
-static void MenuClickMap(int index)
-{
- switch (index) {
- case 0: ShowSmallMap(); break;
- case 1: ShowExtraViewPortWindow(); break;
- case 2: ShowSignList(); break;
- }
-}
-
-static void MenuClickTown(int index)
-{
- ShowTownDirectory();
-}
-
-static void MenuClickScenMap(int index)
-{
- switch (index) {
- case 0: ShowSmallMap(); break;
- case 1: ShowExtraViewPortWindow(); break;
- case 2: ShowSignList(); break;
- case 3: ShowTownDirectory(); break;
- }
-}
-
-static void MenuClickSubsidies(int index)
-{
- ShowSubsidiesList();
-}
-
-static void MenuClickStations(int index)
-{
- ShowPlayerStations((PlayerID)index);
-}
-
-static void MenuClickFinances(int index)
-{
- ShowPlayerFinances((PlayerID)index);
-}
-
-static void MenuClickCompany(int index)
-{
- if (_networking && index == 0) {
- ShowClientList();
- } else {
- if (_networking) index--;
- ShowPlayerCompany((PlayerID)index);
- }
-}
-
-static void MenuClickGraphs(int index)
-{
- switch (index) {
- case 0: ShowOperatingProfitGraph(); break;
- case 1: ShowIncomeGraph(); break;
- case 2: ShowDeliveredCargoGraph(); break;
- case 3: ShowPerformanceHistoryGraph(); break;
- case 4: ShowCompanyValueGraph(); break;
- case 5: ShowCargoPaymentRates(); break;
- }
-}
-
-static void MenuClickLeague(int index)
-{
- switch (index) {
- case 0: ShowCompanyLeagueTable(); break;
- case 1: ShowPerformanceRatingDetail(); break;
- }
-}
-
-static void MenuClickIndustry(int index)
-{
- switch (index) {
- case 0: ShowIndustryDirectory(); break;
- case 1: ShowBuildIndustryWindow(); break;
- }
-}
-
-static void MenuClickShowTrains(int index)
-{
- ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
-}
-
-static void MenuClickShowRoad(int index)
-{
- ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
-}
-
-static void MenuClickShowShips(int index)
-{
- ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
-}
-
-static void MenuClickShowAir(int index)
-{
- ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
-}
-
-static void MenuClickBuildRail(int index)
-{
- _last_built_railtype = (RailType)index;
- ShowBuildRailToolbar(_last_built_railtype, -1);
-}
-
-static void MenuClickBuildRoad(int index)
-{
- _last_built_roadtype = (RoadType)index;
- ShowBuildRoadToolbar(_last_built_roadtype);
-}
-
-static void MenuClickBuildWater(int index)
-{
- ShowBuildDocksToolbar();
-}
-
-static void MenuClickBuildAir(int index)
-{
- ShowBuildAirToolbar();
-}
-
#ifdef ENABLE_NETWORK
void ShowNetworkGiveMoneyWindow(PlayerID player)
{
@@ -329,418 +148,6 @@
ShowQueryString(STR_WAYPOINT_RAW, STR_EDIT_WAYPOINT_NAME, 30, 180, NULL, CS_ALPHANUMERAL);
}
-void SelectSignTool()
-{
- if (_cursor.sprite == SPR_CURSOR_SIGN) {
- ResetObjectToPlace();
- } else {
- SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
- _place_proc = PlaceProc_Sign;
- }
-}
-
-static void MenuClickForest(int index)
-{
- switch (index) {
- case 0: ShowTerraformToolbar(); break;
- case 1: ShowBuildTreesToolbar(); break;
- case 2: SelectSignTool(); break;
- }
-}
-
-static void MenuClickMusicWindow(int index)
-{
- ShowMusicWindow();
-}
-
-static void MenuClickNewspaper(int index)
-{
- switch (index) {
- case 0: ShowLastNewsMessage(); break;
- case 1: ShowMessageOptions(); break;
- case 2: ShowMessageHistory(); break;
- }
-}
-
-void MenuClickSmallScreenshot()
-{
- SetScreenshotType(SC_VIEWPORT);
-}
-
-void MenuClickWorldScreenshot()
-{
- SetScreenshotType(SC_WORLD);
-}
-
-static void MenuClickHelp(int index)
-{
- switch (index) {
- case 0: PlaceLandBlockInfo(); break;
- case 2: IConsoleSwitch(); break;
- case 3: MenuClickSmallScreenshot(); break;
- case 4: MenuClickWorldScreenshot(); break;
- case 5: ShowAboutWindow(); break;
- }
-}
-
-
-typedef void MenuClickedProc(int index);
-
-static MenuClickedProc * const _menu_clicked_procs[] = {
- NULL, /* 0 */
- NULL, /* 1 */
- MenuClickSettings, /* 2 */
- MenuClickSaveLoad, /* 3 */
- MenuClickMap, /* 4 */
- MenuClickTown, /* 5 */
- MenuClickSubsidies, /* 6 */
- MenuClickStations, /* 7 */
- MenuClickFinances, /* 8 */
- MenuClickCompany, /* 9 */
- MenuClickGraphs, /* 10 */
- MenuClickLeague, /* 11 */
- MenuClickIndustry, /* 12 */
- MenuClickShowTrains, /* 13 */
- MenuClickShowRoad, /* 14 */
- MenuClickShowShips, /* 15 */
- MenuClickShowAir, /* 16 */
- MenuClickScenMap, /* 17 */
- NULL, /* 18 */
- MenuClickBuildRail, /* 19 */
- MenuClickBuildRoad, /* 20 */
- MenuClickBuildWater, /* 21 */
- MenuClickBuildAir, /* 22 */
- MenuClickForest, /* 23 */
- MenuClickMusicWindow, /* 24 */
- MenuClickNewspaper, /* 25 */
- MenuClickHelp, /* 26 */
-};
-
-static void MenuWndProc(Window *w, WindowEvent *e)
-{
- switch (e->event) {
- case WE_CREATE: w->widget[0].right = w->width - 1; break;
-
- case WE_PAINT: {
- int x, y;
-
- byte count = WP(w, menu_d).item_count;
- byte sel = WP(w, menu_d).sel_index;
- uint16 chk = WP(w, menu_d).checked_items;
- StringID string = WP(w, menu_d).string_id;
- byte dis = WP(w, menu_d).disabled_items;
-
- DrawWindowWidgets(w);
-
- x = 1;
- y = 1;
-
- for (; count != 0; count--, string++, sel--) {
- TextColour color = HasBit(dis, 0) ? TC_GREY : (sel == 0) ? TC_WHITE : TC_BLACK;
- if (sel == 0) GfxFillRect(x, y, x + w->width - 3, y + 9, 0);
-
- if (HasBit(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color);
- DrawString(x + 2, y, string, color);
-
- y += 10;
- chk >>= 1;
- dis >>= 1;
- }
- } break;
-
- case WE_DESTROY: {
- Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
- v->RaiseWidget(WP(w, menu_d).main_button);
- SetWindowDirty(v);
- return;
- }
-
- case WE_POPUPMENU_SELECT: {
- int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
- int action_id;
-
-
- if (index < 0) {
- Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
- if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
- index = WP(w, menu_d).sel_index;
- }
-
- action_id = WP(w, menu_d).action_id;
- DeleteWindow(w);
-
- if (index >= 0) {
- assert((uint)index <= lengthof(_menu_clicked_procs));
- _menu_clicked_procs[action_id](index);
- }
-
- break;
- }
-
- case WE_POPUPMENU_OVER: {
- int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
-
- if (index == -1 || index == WP(w, menu_d).sel_index) return;
-
- WP(w, menu_d).sel_index = index;
- SetWindowDirty(w);
- return;
- }
- }
-}
-
-/* Dynamic widget length determined by toolbar-string length.
- * See PopupMainToolbMenu en MenuWndProc */
-static const Widget _menu_widgets[] = {
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 0, 0, 0, 0x0, STR_NULL},
-{ WIDGETS_END},
-};
-
-
-static const Widget _player_menu_widgets[] = {
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL},
-{ WIDGETS_END},
-};
-
-
-static int GetPlayerIndexFromMenu(int index)
-{
- if (index >= 0) {
- const Player *p;
-
- FOR_ALL_PLAYERS(p) {
- if (p->is_active && --index < 0) return p->index;
- }
- }
- return -1;
-}
-
-static void UpdatePlayerMenuHeight(Window *w)
-{
- byte num = ActivePlayerCount();
-
- /* Increase one to fit in PlayerList in the menu when in network */
- if (_networking && WP(w, menu_d).main_button == 9) num++;
-
- if (WP(w, menu_d).item_count != num) {
- WP(w, menu_d).item_count = num;
- SetWindowDirty(w);
- num = num * 10 + 2;
- w->height = num;
- w->widget[0].bottom = w->widget[0].top + num - 1;
- w->top = GetToolbarDropdownPos(0, w->width, w->height).y;
- SetWindowDirty(w);
- }
-}
-
-static void PlayerMenuWndProc(Window *w, WindowEvent *e)
-{
- switch (e->event) {
- case WE_PAINT: {
- int x,y;
- byte sel;
- TextColour color;
- Player *p;
- uint16 chk;
-
- UpdatePlayerMenuHeight(w);
- DrawWindowWidgets(w);
-
- x = 1;
- y = 1;
- sel = WP(w, menu_d).sel_index;
- chk = WP(w, menu_d).checked_items; // let this mean gray items.
-
- /* 9 = playerlist */
- if (_networking && WP(w, menu_d).main_button == 9) {
- if (sel == 0) {
- GfxFillRect(x, y, x + 238, y + 9, 0);
- }
- DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
- y += 10;
- sel--;
- }
-
- FOR_ALL_PLAYERS(p) {
- if (p->is_active) {
- if (p->index == sel) {
- GfxFillRect(x, y, x + 238, y + 9, 0);
- }
-
- DrawPlayerIcon(p->index, x + 2, y + 1);
-
- SetDParam(0, p->index);
- SetDParam(1, p->index);
-
- color = (p->index == sel) ? TC_WHITE : TC_BLACK;
- if (chk&1) color = TC_GREY;
- DrawString(x + 19, y, STR_7021, color);
-
- y += 10;
- }
- chk >>= 1;
- }
-
- break;
- }
-
- case WE_DESTROY: {
- Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
- v->RaiseWidget(WP(w, menu_d).main_button);
- SetWindowDirty(v);
- return;
- }
-
- case WE_POPUPMENU_SELECT: {
- int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
- int action_id = WP(w, menu_d).action_id;
-
- /* We have a new entry at the top of the list of menu 9 when networking
- * so keep that in count */
- if (_networking && WP(w, menu_d).main_button == 9) {
- if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
- } else {
- index = GetPlayerIndexFromMenu(index);
- }
-
- if (index < 0) {
- Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
- if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
- index = WP(w, menu_d).sel_index;
- }
-
- DeleteWindow(w);
-
- if (index >= 0) {
- assert(index >= 0 && index < 30);
- _menu_clicked_procs[action_id](index);
- }
- break;
- }
- case WE_POPUPMENU_OVER: {
- int index;
- UpdatePlayerMenuHeight(w);
- index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
-
- /* We have a new entry at the top of the list of menu 9 when networking
- * so keep that in count */
- if (_networking && WP(w, menu_d).main_button == 9) {
- if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
- } else {
- index = GetPlayerIndexFromMenu(index);
- }
-
- if (index == -1 || index == WP(w, menu_d).sel_index) return;
-
- WP(w, menu_d).sel_index = index;
- SetWindowDirty(w);
- return;
- }
- }
-}
-
-/** Get the maximum length of a given string in a string-list. This is an
- * implicit string-list where the ID's are consecutive
- * @param base_string StringID of the first string in the list
- * @param count amount of StringID's in the list
- * @return the length of the longest string */
-static int GetStringListMaxWidth(StringID base_string, byte count)
-{
- char buffer[512];
- int width, max_width;
- byte i;
-
- max_width = 0;
- for (i = 0; i != count; i++) {
- GetString(buffer, base_string + i, lastof(buffer));
- width = GetStringBoundingBox(buffer).width;
- if (width > max_width) max_width = width;
- }
-
- return max_width;
-}
-
-/** Show a general dropdown menu. The positioning of the dropdown menu
- * defaults to the left side of the parent_button, eg the button that caused
- * this window to appear. The only exceptions are when the right side of this
- * dropdown would fall outside the main toolbar window, in that case it is
- * aligned with the toolbar's right side.
- * Since the disable-mask is only 8 bits right now, these dropdowns are
- * restricted to 8 items max if any bits of disabled_mask are active.
- * @param w Pointer to a window this dropdown menu belongs to. Has no effect
- * whatsoever, only graphically for positioning.
- * @param parent_button The widget identifier of the button that was clicked for
- * this dropdown. The created dropdown then knows what button to raise (button) on
- * action and whose function to execute (action).
- * It is possible to appoint another button for an action event by setting the
- * upper 8 bits of this parameter. If non is set, action is presumed to be the same
- * as button. So<br>
- * button bits 0 - 7 - widget clicked to get dropdown
- * action bits 8 - 15 - function of widget to execute on select (defaults to bits 0 - 7)
- * @param base_string The first StringID shown in the dropdown list. All others are
- * consecutive indeces from the language file. XXX - fix? Use ingame-string tables?
- * @param item_count Number of strings in the list, see previous parameter
- * @param disabled_mask Bitmask of disabled strings in the list
- * @return Return a pointer to the newly created dropdown window */
- Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask)
-{
- assert(disabled_mask == 0 || item_count <= 8);
- w->LowerWidget(parent_button);
- w->InvalidateWidget(parent_button);
-
- DeleteWindowById(WC_TOOLBAR_MENU, 0);
-
- // Extend the dropdown toolbar to the longest string in the list
- int width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
- int height = item_count * 10 + 2;
-
- Point pos = GetToolbarDropdownPos(parent_button, width, height);
-
- w = AllocateWindow(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
- w->widget[0].bottom = item_count * 10 + 1;
- w->flags4 &= ~WF_WHITE_BORDER_MASK;
-
- WP(w, menu_d).item_count = item_count;
- WP(w, menu_d).sel_index = 0;
- WP(w, menu_d).main_button = GB(parent_button, 0, 8);
- WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
- WP(w, menu_d).string_id = base_string;
- WP(w, menu_d).checked_items = 0;
- WP(w, menu_d).disabled_items = disabled_mask;
-
- _popup_menu_active = true;
-
- SndPlayFx(SND_15_BEEP);
- return w;
-}
-
-Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray)
-{
- w->LowerWidget(main_button);
- w->InvalidateWidget(main_button);
-
- DeleteWindowById(WC_TOOLBAR_MENU, 0);
- Point pos = GetToolbarDropdownPos(main_button, 241, 82);
- w = AllocateWindow(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
- w->flags4 &= ~WF_WHITE_BORDER_MASK;
- WP(w, menu_d).item_count = 0;
- WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
- if (_networking && main_button == 9) {
- if (_local_player != PLAYER_SPECTATOR) {
- WP(w, menu_d).sel_index++;
- } else {
- /* Select client list by default for spectators */
- WP(w, menu_d).sel_index = 0;
- }
- }
- WP(w, menu_d).action_id = main_button;
- WP(w, menu_d).main_button = main_button;
- WP(w, menu_d).checked_items = gray;
- WP(w, menu_d).disabled_items = 0;
- _popup_menu_active = true;
- SndPlayFx(SND_15_BEEP);
- return w;
-}
/* Zooms a viewport in a window in or out */
/* No button handling or what so ever */
@@ -804,331 +211,165 @@
}
}
-
-extern GetNewsStringCallbackProc * const _get_news_string_callback[];
-
-
-static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width)
-{
- char buf[512];
- StringID str;
- const char *s, *last;
- char *d;
- DrawPixelInfo tmp_dpi, *old_dpi;
- int x;
- char buffer[256];
-
- if (ni->display_mode == NM_CALLBACK) {
- str = _get_news_string_callback[ni->callback](ni);
- } else {
- CopyInDParam(0, ni->params, lengthof(ni->params));
- str = ni->string_id;
- }
-
- GetString(buf, str, lastof(buf));
-
- s = buf;
- d = buffer;
- last = lastof(buffer);
-
- for (;;) {
- WChar c = Utf8Consume(&s);
- if (c == 0) {
- break;
- } else if (c == 0x0D) {
- if (d + 4 >= last) break;
- d[0] = d[1] = d[2] = d[3] = ' ';
- d += 4;
- } else if (IsPrintable(c)) {
- if (d + Utf8CharLen(c) >= last) break;
- d += Utf8Encode(d, c);
- }
- }
- *d = '\0';
-
- if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
-
- old_dpi = _cur_dpi;
- _cur_dpi = &tmp_dpi;
-
- x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE);
- _cur_dpi = old_dpi;
-
- return x > 0;
-}
-
-static void StatusBarWndProc(Window *w, WindowEvent *e)
-{
- switch (e->event) {
- case WE_PAINT: {
- const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player);
-
- DrawWindowWidgets(w);
- SetDParam(0, _date);
- DrawStringCentered(
- 70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING
- );
-
- if (p != NULL) {
- /* Draw player money */
- SetDParam(0, p->player_money);
- DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING);
- }
-
- /* Draw status bar */
- if (w->message.msg) { // true when saving is active
- DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING);
- } else if (_do_autosave) {
- DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
- } else if (_pause_game) {
- DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING);
- } else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
- /* Draw the scrolling news text */
- if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
- WP(w, def_d).data_1 = -1280;
- if (p != NULL) {
- /* This is the default text */
- SetDParam(0, p->index);
- DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
- }
- }
- } else {
- if (p != NULL) {
- /* This is the default text */
- SetDParam(0, p->index);
- DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
- }
- }
-
- if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, w->widget[1].right - 11, 2);
- } break;
-
- case WE_MESSAGE:
- w->message.msg = e->we.message.msg;
- SetWindowDirty(w);
- break;
-
- case WE_CLICK:
- switch (e->we.click.widget) {
- case 1: ShowLastNewsMessage(); break;
- case 2: if (_local_player != PLAYER_SPECTATOR) ShowPlayerFinances(_local_player); break;
- default: ResetObjectToPlace();
- }
- break;
-
- case WE_TICK: {
- if (_pause_game) return;
-
- if (WP(w, def_d).data_1 > -1280) { // Scrolling text
- WP(w, def_d).data_1 -= 2;
- w->InvalidateWidget(1);
- }
-
- if (WP(w, def_d).data_2 > 0) { // Red blot to show there are new unread newsmessages
- WP(w, def_d).data_2 -= 2;
- } else if (WP(w, def_d).data_2 < 0) {
- WP(w, def_d).data_2 = 0;
- w->InvalidateWidget(1);
- }
-
- break;
- }
- }
-}
-
-static const Widget _main_status_widgets[] = {
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 139, 0, 11, 0x0, STR_NULL},
-{ WWT_PUSHBTN, RESIZE_RIGHT, 14, 140, 179, 0, 11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS},
-{ WWT_PUSHBTN, RESIZE_LR, 14, 180, 319, 0, 11, 0x0, STR_NULL},
-{ WIDGETS_END},
-};
-
-static WindowDesc _main_status_desc = {
- WDP_CENTER, 0, 320, 12, 640, 12,
- WC_STATUS_BAR, WC_NONE,
- WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
- _main_status_widgets,
- StatusBarWndProc
-};
-
extern void UpdateAllStationVirtCoord();
static void MainWindowWndProc(Window *w, WindowEvent *e)
{
- int off_x;
-
switch (e->event) {
- case WE_PAINT:
- DrawWindowViewport(w);
- if (_game_mode == GM_MENU) {
- off_x = _screen.width / 2;
-
- DrawSprite(SPR_OTTD_O, PAL_NONE, off_x - 120, 50);
- DrawSprite(SPR_OTTD_P, PAL_NONE, off_x - 86, 50);
- DrawSprite(SPR_OTTD_E, PAL_NONE, off_x - 53, 50);
- DrawSprite(SPR_OTTD_N, PAL_NONE, off_x - 22, 50);
-
- DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 34, 50);
- DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50);
- DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50);
-
- /*
- DrawSprite(SPR_OTTD_R, off_x + 119, 50);
- DrawSprite(SPR_OTTD_A, off_x + 148, 50);
- DrawSprite(SPR_OTTD_N, off_x + 181, 50);
- DrawSprite(SPR_OTTD_S, off_x + 215, 50);
- DrawSprite(SPR_OTTD_P, off_x + 246, 50);
- DrawSprite(SPR_OTTD_O, off_x + 275, 50);
- DrawSprite(SPR_OTTD_R, off_x + 307, 50);
- DrawSprite(SPR_OTTD_T, off_x + 337, 50);
-
- DrawSprite(SPR_OTTD_T, off_x + 390, 50);
- DrawSprite(SPR_OTTD_Y, off_x + 417, 50);
- DrawSprite(SPR_OTTD_C, off_x + 447, 50);
- DrawSprite(SPR_OTTD_O, off_x + 478, 50);
- DrawSprite(SPR_OTTD_O, off_x + 509, 50);
- DrawSprite(SPR_OTTD_N, off_x + 541, 50);
- */
- }
- break;
+ case WE_PAINT:
+ DrawWindowViewport(w);
+ if (_game_mode == GM_MENU) {
+ int off_x = _screen.width / 2;
- case WE_KEYPRESS:
- switch (e->we.keypress.keycode) {
- case 'Q' | WKC_CTRL:
- case 'Q' | WKC_META:
- HandleExitGameRequest();
- break;
- }
+ DrawSprite(SPR_OTTD_O, PAL_NONE, off_x - 120, 50);
+ DrawSprite(SPR_OTTD_P, PAL_NONE, off_x - 86, 50);
+ DrawSprite(SPR_OTTD_E, PAL_NONE, off_x - 53, 50);
+ DrawSprite(SPR_OTTD_N, PAL_NONE, off_x - 22, 50);
- /* Disable all key shortcuts, except quit shortcuts when
- * generating the world, otherwise they create threading
- * problem during the generating, resulting in random
- * assertions that are hard to trigger and debug */
- if (IsGeneratingWorld()) break;
-
- if (e->we.keypress.keycode == WKC_BACKQUOTE) {
- IConsoleSwitch();
- e->we.keypress.cont = false;
+ DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 34, 50);
+ DrawSprite(SPR_OTTD_T, PAL_NONE, off_x + 65, 50);
+ DrawSprite(SPR_OTTD_D, PAL_NONE, off_x + 96, 50);
+ }
break;
- }
-
- if (e->we.keypress.keycode == ('B' | WKC_CTRL)) {
- e->we.keypress.cont = false;
- _draw_bounding_boxes = !_draw_bounding_boxes;
- MarkWholeScreenDirty();
- break;
- }
- if (_game_mode == GM_MENU) break;
+ case WE_KEYPRESS:
+ switch (e->we.keypress.keycode) {
+ case 'Q' | WKC_CTRL:
+ case 'Q' | WKC_META:
+ HandleExitGameRequest();
+ break;
+ }
- switch (e->we.keypress.keycode) {
- case 'C':
- case 'Z': {
- Point pt = GetTileBelowCursor();
- if (pt.x != -1) {
- if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
- ScrollMainWindowTo(pt.x, pt.y);
- }
+ /* Disable all key shortcuts, except quit shortcuts when
+ * generating the world, otherwise they create threading
+ * problem during the generating, resulting in random
+ * assertions that are hard to trigger and debug */
+ if (IsGeneratingWorld()) break;
+
+ if (e->we.keypress.keycode == WKC_BACKQUOTE) {
+ IConsoleSwitch();
+ e->we.keypress.cont = false;
break;
}
- case WKC_ESC: ResetObjectToPlace(); break;
- case WKC_DELETE: DeleteNonVitalWindows(); break;
- case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break;
- case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
-
-#if defined(_DEBUG)
- case '0' | WKC_ALT: // Crash the game
- *(byte*)0 = 0;
- break;
-
- case '1' | WKC_ALT: // Gimme money
- /* Server can not cheat in advertise mode either! */
- if (!_networking || !_network_server || !_network_advertise)
- DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
- break;
-
- case '2' | WKC_ALT: // Update the coordinates of all station signs
- UpdateAllStationVirtCoord();
- break;
-#endif
-
- case '1' | WKC_CTRL:
- case '2' | WKC_CTRL:
- case '3' | WKC_CTRL:
- case '4' | WKC_CTRL:
- case '5' | WKC_CTRL:
- case '6' | WKC_CTRL:
- case '7' | WKC_CTRL:
- case '8' | WKC_CTRL:
- case '9' | WKC_CTRL:
- /* Transparency toggle hot keys */
- ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
- MarkWholeScreenDirty();
- break;
-
- case '1' | WKC_CTRL | WKC_SHIFT:
- case '2' | WKC_CTRL | WKC_SHIFT:
- case '3' | WKC_CTRL | WKC_SHIFT:
- case '4' | WKC_CTRL | WKC_SHIFT:
- case '5' | WKC_CTRL | WKC_SHIFT:
- case '6' | WKC_CTRL | WKC_SHIFT:
- case '7' | WKC_CTRL | WKC_SHIFT:
- case '8' | WKC_CTRL | WKC_SHIFT:
- /* Invisibility toggle hot keys */
- ToggleInvisibilityWithTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
+ if (e->we.keypress.keycode == ('B' | WKC_CTRL)) {
+ e->we.keypress.cont = false;
+ extern bool _draw_bounding_boxes;
+ _draw_bounding_boxes = !_draw_bounding_boxes;
MarkWholeScreenDirty();
break;
+ }
- case 'X' | WKC_CTRL:
- ShowTransparencyToolbar();
- break;
+ if (_game_mode == GM_MENU) break;
- case 'X':
- ResetRestoreAllTransparency();
- break;
+ switch (e->we.keypress.keycode) {
+ case 'C':
+ case 'Z': {
+ Point pt = GetTileBelowCursor();
+ if (pt.x != -1) {
+ if (e->we.keypress.keycode == 'Z') MaxZoomInOut(ZOOM_IN, w);
+ ScrollMainWindowTo(pt.x, pt.y);
+ }
+ break;
+ }
+
+ case WKC_ESC: ResetObjectToPlace(); break;
+ case WKC_DELETE: DeleteNonVitalWindows(); break;
+ case WKC_DELETE | WKC_SHIFT: DeleteAllNonVitalWindows(); break;
+ case 'R' | WKC_CTRL: MarkWholeScreenDirty(); break;
+
+#if defined(_DEBUG)
+ case '0' | WKC_ALT: // Crash the game
+ *(byte*)0 = 0;
+ break;
+
+ case '1' | WKC_ALT: // Gimme money
+ /* Server can not cheat in advertise mode either! */
+ if (!_networking || !_network_server || !_network_advertise)
+ DoCommandP(0, 10000000, 0, NULL, CMD_MONEY_CHEAT);
+ break;
+
+ case '2' | WKC_ALT: // Update the coordinates of all station signs
+ UpdateAllStationVirtCoord();
+ break;
+#endif
+
+ case '1' | WKC_CTRL:
+ case '2' | WKC_CTRL:
+ case '3' | WKC_CTRL:
+ case '4' | WKC_CTRL:
+ case '5' | WKC_CTRL:
+ case '6' | WKC_CTRL:
+ case '7' | WKC_CTRL:
+ case '8' | WKC_CTRL:
+ case '9' | WKC_CTRL:
+ /* Transparency toggle hot keys */
+ ToggleTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL)));
+ MarkWholeScreenDirty();
+ break;
+
+ case '1' | WKC_CTRL | WKC_SHIFT:
+ case '2' | WKC_CTRL | WKC_SHIFT:
+ case '3' | WKC_CTRL | WKC_SHIFT:
+ case '4' | WKC_CTRL | WKC_SHIFT:
+ case '5' | WKC_CTRL | WKC_SHIFT:
+ case '6' | WKC_CTRL | WKC_SHIFT:
+ case '7' | WKC_CTRL | WKC_SHIFT:
+ case '8' | WKC_CTRL | WKC_SHIFT:
+ /* Invisibility toggle hot keys */
+ ToggleInvisibilityWithTransparency((TransparencyOption)(e->we.keypress.keycode - ('1' | WKC_CTRL | WKC_SHIFT)));
+ MarkWholeScreenDirty();
+ break;
+
+ case 'X' | WKC_CTRL:
+ ShowTransparencyToolbar();
+ break;
+
+ case 'X':
+ ResetRestoreAllTransparency();
+ break;
#ifdef ENABLE_NETWORK
- case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
- if (_networking) {
- const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
- bool teamchat = false;
-
- if (cio == NULL) break;
+ case WKC_RETURN: case 'T': // smart chat; send to team if any, otherwise to all
+ if (_networking) {
+ const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
+ bool teamchat = false;
- /* Only players actually playing can speak to team. Eg spectators cannot */
- if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
- const NetworkClientInfo *ci;
- FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
- if (ci->client_playas == cio->client_playas && ci != cio) {
- teamchat = true;
- break;
+ if (cio == NULL) break;
+
+ /* Only players actually playing can speak to team. Eg spectators cannot */
+ if (_patches.prefer_teamchat && IsValidPlayer(cio->client_playas)) {
+ const NetworkClientInfo *ci;
+ FOR_ALL_ACTIVE_CLIENT_INFOS(ci) {
+ if (ci->client_playas == cio->client_playas && ci != cio) {
+ teamchat = true;
+ break;
+ }
}
}
- }
-
- ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
- }
- break;
- case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
- if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
- break;
+ ShowNetworkChatQueryWindow(teamchat ? DESTTYPE_TEAM : DESTTYPE_BROADCAST, cio->client_playas);
+ }
+ break;
- case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates
- if (_networking) {
- const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
- if (cio == NULL) break;
+ case WKC_SHIFT | WKC_RETURN: case WKC_SHIFT | 'T': // send text message to all players
+ if (_networking) ShowNetworkChatQueryWindow(DESTTYPE_BROADCAST, 0);
+ break;
- ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
- }
- break;
+ case WKC_CTRL | WKC_RETURN: case WKC_CTRL | 'T': // send text to all team mates
+ if (_networking) {
+ const NetworkClientInfo *cio = NetworkFindClientInfoFromIndex(_network_own_client_index);
+ if (cio == NULL) break;
+
+ ShowNetworkChatQueryWindow(DESTTYPE_TEAM, cio->client_playas);
+ }
+ break;
#endif
- default: return;
- }
- e->we.keypress.cont = false;
- break;
+ default: return;
+ }
+ e->we.keypress.cont = false;
+ break;
case WE_SCROLL: {
ViewPort *vp = IsPtInWindowViewport(w, _cursor.pos.x, _cursor.pos.y);
@@ -1160,21 +401,17 @@
void SetupColorsAndInitialWindow()
{
- uint i;
- Window *w;
- int width, height;
-
- for (i = 0; i != 16; i++) {
+ for (uint i = 0; i != 16; i++) {
const byte *b = GetNonSprite(PALETTE_RECOLOR_START + i);
assert(b);
memcpy(_colour_gradient[i], b + 0xC6, sizeof(_colour_gradient[i]));
}
- width = _screen.width;
- height = _screen.height;
+ int width = _screen.width;
+ int height = _screen.height;
- w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
+ Window *w = AllocateWindow(0, 0, width, height, MainWindowWndProc, WC_MAIN_WINDOW, NULL);
AssignWindowViewport(w, 0, 0, width, height, TileXY(32, 32), ZOOM_LVL_VIEWPORT);
/* XXX: these are not done */
@@ -1191,27 +428,17 @@
}
}
+extern void ShowStatusBar();
+
void ShowVitalWindows()
{
Window *w = AllocateToolbar();
DoZoomInOutWindow(ZOOM_NONE, w);
- CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
-
- w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
- w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
-
- /* 'w' is for sure a WC_MAIN_TOOLBAR */
- PositionMainToolbar(w);
-
/* Status bad only for normal games */
if (_game_mode == GM_EDITOR) return;
- _main_status_desc.top = _screen.height - 12;
- w = AllocateWindowDesc(&_main_status_desc);
- CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
-
- WP(w, def_d).data_1 = -1280;
+ ShowStatusBar();
}
/**
@@ -1226,15 +453,3 @@
ScreenSizeChanged();
MarkWholeScreenDirty();
}
-
-void InitializeMainGui()
-{
- /* Clean old GUI values */
- _last_built_railtype = RAILTYPE_RAIL;
- _last_built_roadtype = ROADTYPE_ROAD;
-}
-
-
-
-
-
--- a/src/misc.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/misc.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -10,6 +10,7 @@
#include "saveload.h"
#include "vehicle_gui.h"
#include "variables.h"
+#include "cheat_func.h"
#include "ai/ai.h"
#include "newgrf_house.h"
#include "cargotype.h"
@@ -30,6 +31,7 @@
#include "table/sprites.h"
char _name_array[512][32];
+extern TileIndex _cur_tileloop_tile;
void InitializeVehicles();
void InitializeWaypoints();
@@ -42,7 +44,6 @@
void InitializeAirportGui();
void InitializeDockGui();
void InitializeIndustries();
-void InitializeMainGui();
void InitializeTowns();
void InitializeTrees();
void InitializeSigns();
@@ -50,7 +51,7 @@
void InitializeCargoPackets();
static void InitializeNameMgr();
void InitializePlayers();
-static void InitializeCheats();
+void InitializeCheats();
void InitializeNPF();
void InitializeGame(int mode, uint size_x, uint size_y)
@@ -91,7 +92,6 @@
InitializeCargoPackets();
InitializeIndustries();
InitializeBuildingCounts();
- InitializeMainGui();
InitializeNameMgr();
InitializeVehiclesGuiList();
@@ -117,12 +117,6 @@
}
-static void InitializeCheats()
-{
- memset(&_cheats, 0, sizeof(Cheats));
-}
-
-
static void InitializeNameMgr()
{
memset(_name_array, 0, sizeof(_name_array));
@@ -464,31 +458,6 @@
}
}
-static void Save_CHTS()
-{
- byte count = sizeof(_cheats)/sizeof(Cheat);
- Cheat* cht = (Cheat*) &_cheats;
- Cheat* cht_last = &cht[count];
-
- SlSetLength(count * 2);
- for (; cht != cht_last; cht++) {
- SlWriteByte(cht->been_used);
- SlWriteByte(cht->value);
- }
-}
-
-static void Load_CHTS()
-{
- Cheat* cht = (Cheat*)&_cheats;
- uint count = SlGetFieldLength() / 2;
-
- for (uint i = 0; i < count; i++) {
- cht[i].been_used = (SlReadByte() != 0);
- cht[i].value = (SlReadByte() != 0);
- }
-}
-
-
extern const ChunkHandler _misc_chunk_handlers[] = {
{ 'MAPS', Save_MAPS, Load_MAPS, CH_RIFF },
{ 'MAPT', Save_MAPT, Load_MAPT, CH_RIFF },
@@ -502,6 +471,5 @@
{ 'NAME', NULL, Load_NAME, CH_ARRAY},
{ 'DATE', SaveLoad_DATE, SaveLoad_DATE, CH_RIFF},
- { 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF},
- { 'CHTS', Save_CHTS, Load_CHTS, CH_RIFF | CH_LAST}
+ { 'VIEW', SaveLoad_VIEW, SaveLoad_VIEW, CH_RIFF | CH_LAST},
};
--- a/src/misc_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/misc_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -24,6 +24,7 @@
#include "town.h"
#include "network/network.h"
#include "variables.h"
+#include "cheat_func.h"
#include "train.h"
#include "tgp.h"
#include "cargotype.h"
@@ -566,6 +567,7 @@
case WE_DESTROY:
SetRedErrorSquare(0);
+ extern StringID _switch_mode_errorstr;
_switch_mode_errorstr = INVALID_STRING_ID;
break;
@@ -1393,7 +1395,7 @@
{ WWT_INSET, RESIZE_RB, 14, 2, 243, 50, 150, 0x0, STR_400A_LIST_OF_DRIVES_DIRECTORIES},
{ WWT_SCROLLBAR, RESIZE_LRB, 14, 245, 256, 60, 151, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
{ WWT_PANEL, RESIZE_RTB, 14, 0, 256, 152, 167, 0x0, STR_NULL},
-{ WWT_EDITBOX, RESIZE_RTB, 14, 2, 254, 154, 165, STR_SAVE_OSKTITLE,STR_400B_CURRENTLY_SELECTED_NAME},
+{ WWT_EDITBOX, RESIZE_RTB, 14, 2, 254, 154, 165, STR_SAVE_OSKTITLE, STR_400B_CURRENTLY_SELECTED_NAME},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 0, 127, 168, 179, STR_4003_DELETE, STR_400C_DELETE_THE_CURRENTLY_SELECTED},
{ WWT_PUSHTXTBTN, RESIZE_TB, 14, 128, 244, 168, 179, STR_4002_SAVE, STR_400D_SAVE_THE_CURRENT_GAME_USING},
{ WWT_RESIZEBOX, RESIZE_LRTB, 14, 245, 256, 168, 179, 0x0, STR_RESIZE_BUTTON},
@@ -1788,211 +1790,3 @@
break;
}
}
-
-/**
- * The 'amount' to cheat with.
- * This variable is semantically a constant value, but because the cheat
- * code requires to be able to write to the variable it is not constified.
- */
-static int32 _money_cheat_amount = 10000000;
-
-static int32 ClickMoneyCheat(int32 p1, int32 p2)
-{
- DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, NULL, CMD_MONEY_CHEAT);
- return _money_cheat_amount;
-}
-
-/**
- * @param p1 player to set to
- * @param p2 is -1 or +1 (down/up)
- */
-static int32 ClickChangePlayerCheat(int32 p1, int32 p2)
-{
- while (IsValidPlayer((PlayerID)p1)) {
- if (_players[p1].is_active) {
- SetLocalPlayer((PlayerID)p1);
-
- MarkWholeScreenDirty();
- return _local_player;
- }
- p1 += p2;
- }
-
- return _local_player;
-}
-
-/**
- * @param p1 -1 or +1 (down/up)
- * @param p2 unused
- */
-static int32 ClickChangeClimateCheat(int32 p1, int32 p2)
-{
- if (p1 == -1) p1 = 3;
- if (p1 == 4) p1 = 0;
- _opt.landscape = p1;
- ReloadNewGRFData();
- return _opt.landscape;
-}
-
-extern void EnginesMonthlyLoop();
-
-/**
- * @param p1 unused
- * @param p2 1 (increase) or -1 (decrease)
- */
-static int32 ClickChangeDateCheat(int32 p1, int32 p2)
-{
- YearMonthDay ymd;
- ConvertDateToYMD(_date, &ymd);
-
- if ((ymd.year == MIN_YEAR && p2 == -1) || (ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
-
- SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
- EnginesMonthlyLoop();
- SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
- ResetSignalVariant();
- return _cur_year;
-}
-
-typedef int32 CheckButtonClick(int32, int32);
-
-struct CheatEntry {
- VarType type; ///< type of selector
- StringID str; ///< string with descriptive text
- void *variable; ///< pointer to the variable
- bool *been_used; ///< has this cheat been used before?
- CheckButtonClick *proc;///< procedure
-};
-
-static const CheatEntry _cheats_ui[] = {
- {SLE_INT32, STR_CHEAT_MONEY, &_money_cheat_amount, &_cheats.money.been_used, &ClickMoneyCheat },
- {SLE_UINT8, STR_CHEAT_CHANGE_PLAYER, &_local_player, &_cheats.switch_player.been_used, &ClickChangePlayerCheat },
- {SLE_BOOL, STR_CHEAT_EXTRA_DYNAMITE, &_cheats.magic_bulldozer.value, &_cheats.magic_bulldozer.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_CROSSINGTUNNELS, &_cheats.crossing_tunnels.value, &_cheats.crossing_tunnels.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_BUILD_IN_PAUSE, &_cheats.build_in_pause.value, &_cheats.build_in_pause.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_NO_JETCRASH, &_cheats.no_jetcrash.value, &_cheats.no_jetcrash.been_used, NULL },
- {SLE_BOOL, STR_CHEAT_SETUP_PROD, &_cheats.setup_prod.value, &_cheats.setup_prod.been_used, NULL },
- {SLE_UINT8, STR_CHEAT_SWITCH_CLIMATE, &_opt.landscape, &_cheats.switch_climate.been_used, &ClickChangeClimateCheat},
- {SLE_INT32, STR_CHEAT_CHANGE_DATE, &_cur_year, &_cheats.change_date.been_used, &ClickChangeDateCheat },
-};
-
-
-static const Widget _cheat_widgets[] = {
-{ WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, RESIZE_NONE, 14, 11, 399, 0, 13, STR_CHEATS, STR_018C_WINDOW_TITLE_DRAG_THIS},
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 399, 14, 169, 0x0, STR_CHEATS_TIP},
-{ WIDGETS_END},
-};
-
-static void CheatsWndProc(Window *w, WindowEvent *e)
-{
- switch (e->event) {
- case WE_PAINT: {
- int clk = WP(w, def_d).data_1;
-
- DrawWindowWidgets(w);
- DrawStringMultiCenter(200, 25, STR_CHEATS_WARNING, w->width - 50);
-
- for (int i = 0, x = 0, y = 45; i != lengthof(_cheats_ui); i++) {
- const CheatEntry *ce = &_cheats_ui[i];
-
- DrawSprite((*ce->been_used) ? SPR_BOX_CHECKED : SPR_BOX_EMPTY, PAL_NONE, x + 5, y + 2);
-
- switch (ce->type) {
- case SLE_BOOL: {
- bool on = (*(bool*)ce->variable);
-
- DrawFrameRect(x + 20, y + 1, x + 30 + 9, y + 9, on ? 6 : 4, on ? FR_LOWERED : FR_NONE);
- SetDParam(0, on ? STR_CONFIG_PATCHES_ON : STR_CONFIG_PATCHES_OFF);
- } break;
-
- default: {
- int32 val = (int32)ReadValue(ce->variable, ce->type);
- char buf[512];
-
- /* Draw [<][>] boxes for settings of an integer-type */
- DrawArrowButtons(x + 20, y, 3, clk - (i * 2), true, true);
-
- switch (ce->str) {
- /* Display date for change date cheat */
- case STR_CHEAT_CHANGE_DATE: SetDParam(0, _date); break;
-
- /* Draw colored flag for change player cheat */
- case STR_CHEAT_CHANGE_PLAYER:
- SetDParam(0, val);
- GetString(buf, STR_CHEAT_CHANGE_PLAYER, lastof(buf));
- DrawPlayerIcon(_current_player, 60 + GetStringBoundingBox(buf).width, y + 2);
- break;
-
- /* Set correct string for switch climate cheat */
- case STR_CHEAT_SWITCH_CLIMATE: val += STR_TEMPERATE_LANDSCAPE;
-
- /* Fallthrough */
- default: SetDParam(0, val);
- }
- } break;
- }
-
- DrawString(50, y + 1, ce->str, TC_FROMSTRING);
-
- y += 12;
- }
- break;
- }
-
- case WE_CLICK: {
- uint btn = (e->we.click.pt.y - 46) / 12;
- uint x = e->we.click.pt.x;
-
- /* Not clicking a button? */
- if (!IsInsideMM(x, 20, 40) || btn >= lengthof(_cheats_ui)) break;
-
- const CheatEntry *ce = &_cheats_ui[btn];
- int value = (int32)ReadValue(ce->variable, ce->type);
- int oldvalue = value;
-
- *ce->been_used = true;
-
- switch (ce->type) {
- case SLE_BOOL:
- value ^= 1;
- if (ce->proc != NULL) ce->proc(value, 0);
- break;
-
- default:
- /* Take whatever the function returns */
- value = ce->proc(value + ((x >= 30) ? 1 : -1), (x >= 30) ? 1 : -1);
-
- if (value != oldvalue) WP(w, def_d).data_1 = btn * 2 + 1 + ((x >= 30) ? 1 : 0);
- break;
- }
-
- if (value != oldvalue) WriteValue(ce->variable, ce->type, (int64)value);
-
- w->flags4 |= 5 << WF_TIMEOUT_SHL;
-
- SetWindowDirty(w);
- } break;
-
- case WE_TIMEOUT:
- WP(w, def_d).data_1 = 0;
- SetWindowDirty(w);
- break;
- }
-}
-
-static const WindowDesc _cheats_desc = {
- 240, 22, 400, 170, 400, 170,
- WC_CHEATS, WC_NONE,
- WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
- _cheat_widgets,
- CheatsWndProc
-};
-
-
-void ShowCheatWindow()
-{
- DeleteWindowById(WC_CHEATS, 0);
- AllocateWindowDesc(&_cheats_desc);
-}
--- a/src/namegen.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/namegen.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -305,7 +305,7 @@
uint sel = SeedChance(2,
lengthof(name_finnish_1) + lengthof(name_finnish_2), seed);
if (sel >= lengthof(name_finnish_1)) {
- strecat(buf, name_finnish_2[sel-lengthof(name_finnish_1)], last);
+ strecat(buf, name_finnish_2[sel - lengthof(name_finnish_1)], last);
} else {
strecat(buf, name_finnish_1[sel], last);
}
--- a/src/network/core/tcp.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/network/core/tcp.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -75,6 +75,7 @@
if (!_network_server && _networking) {
_switch_mode = SM_MENU;
_networking = false;
+ extern StringID _switch_mode_errorstr;
_switch_mode_errorstr = STR_NETWORK_ERR_LOSTCONNECTION;
return NETWORK_RECV_STATUS_CONN_LOST;
--- a/src/network/network.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/network/network.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -224,6 +224,7 @@
static void NetworkError(StringID error_string)
{
_switch_mode = SM_MENU;
+ extern StringID _switch_mode_errorstr;
_switch_mode_errorstr = error_string;
}
@@ -391,7 +392,7 @@
uint32 netmask;
fields = sscanf(*output, "%u: %hhu.%hhu.%hhu.%hhu, netmask %hhu.%hhu.%hhu.%hhu%n",
- &n, &i1,&i2,&i3,&i4, &j1,&j2,&j3,&j4, &read);
+ &n, &i1, &i2, &i3, &i4, &j1, &j2, &j3, &j4, &read);
read += 1;
if (fields != 9) {
break;
--- a/src/network/network_client.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/network/network_client.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -328,6 +328,7 @@
// **********
extern bool SafeSaveOrLoad(const char *filename, int mode, int newgm, Subdirectory subdir);
+extern StringID _switch_mode_errorstr;
DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_FULL)
{
--- a/src/network/network_udp.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/network/network_udp.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -293,7 +293,7 @@
for (c = item->info.grfconfig; c != NULL; c = c->next) {
if (c->status == GCS_NOT_FOUND) item->info.compatible = false;
- if (c->status != GCS_NOT_FOUND || strcmp(c->name, UNKNOWN_GRF_NAME_PLACEHOLDER) != 0) continue;
+ if (c->status != GCS_NOT_FOUND || strcmp(c->name, UNKNOWN_GRF_NAME_PLACEHOLDER) != 0) continue;
in_request[in_request_count] = c;
in_request_count++;
}
--- a/src/newgrf.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/newgrf.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -47,6 +47,8 @@
#include "settings_type.h"
#include "map_func.h"
+#include <map>
+
#include "table/strings.h"
#include "table/sprites.h"
#include "table/town_land.h"
@@ -227,6 +229,9 @@
}
+typedef std::map<StringID *, uint32> StringIDToGRFIDMapping;
+StringIDToGRFIDMapping _string_to_grf_mapping;
+
/** Used when setting an object's property to map to the GRF's strings
* while taking in consideration the "drift" between TTDPatch string system and OpenTTD's one
* @param grfid Id of the grf file
@@ -1394,7 +1399,8 @@
break;
case 0x12: // Building name ID
- housespec->building_name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ housespec->building_name = grf_load_word(&buf);
+ _string_to_grf_mapping[&housespec->building_name] = _cur_grffile->grfid;
break;
case 0x13: // Building availability mask
@@ -1637,25 +1643,30 @@
break;
case 0x09: /* String ID for cargo type name */
- cs->name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ cs->name = grf_load_word(&buf);
+ _string_to_grf_mapping[&cs->name] = _cur_grffile->grfid;
break;
case 0x0A: /* String for 1 unit of cargo */
- cs->name_single = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ cs->name_single = grf_load_word(&buf);
+ _string_to_grf_mapping[&cs->name_single] = _cur_grffile->grfid;
break;
case 0x0B:
/* String for units of cargo. This is different in OpenTTD to TTDPatch
* (e.g. 10 tonnes of coal) */
- cs->units_volume = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ cs->units_volume = grf_load_word(&buf);
+ _string_to_grf_mapping[&cs->units_volume] = _cur_grffile->grfid;
break;
case 0x0C: /* String for quantity of cargo (e.g. 10 tonnes of coal) */
- cs->quantifier = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ cs->quantifier = grf_load_word(&buf);
+ _string_to_grf_mapping[&cs->quantifier] = _cur_grffile->grfid;
break;
case 0x0D: /* String for two letter cargo abbreviation */
- cs->abbrev = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ cs->abbrev = grf_load_word(&buf);
+ _string_to_grf_mapping[&cs->abbrev] = _cur_grffile->grfid;
break;
case 0x0E: /* Sprite ID for cargo icon */
@@ -2039,15 +2050,18 @@
break;
case 0x0C: // Industry closure message
- indsp->closure_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ indsp->closure_text = grf_load_word(&buf);
+ _string_to_grf_mapping[&indsp->closure_text] = _cur_grffile->grfid;
break;
case 0x0D: // Production increase message
- indsp->production_up_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ indsp->production_up_text = grf_load_word(&buf);
+ _string_to_grf_mapping[&indsp->production_up_text] = _cur_grffile->grfid;
break;
case 0x0E: // Production decrease message
- indsp->production_down_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ indsp->production_down_text = grf_load_word(&buf);
+ _string_to_grf_mapping[&indsp->production_down_text] = _cur_grffile->grfid;
break;
case 0x0F: // Fund cost multiplier
@@ -2106,19 +2120,21 @@
break;
case 0x1B: // New industry text ID
- indsp->new_industry_text = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ indsp->new_industry_text = grf_load_word(&buf);
+ _string_to_grf_mapping[&indsp->new_industry_text] = _cur_grffile->grfid;
break;
case 0x1C: // Input cargo multipliers for the three input cargo types
case 0x1D:
case 0x1E: {
uint32 multiples = grf_load_dword(&buf);
- indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0,15);
- indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 15,15);
+ indsp->input_cargo_multiplier[prop - 0x1C][0] = GB(multiples, 0, 15);
+ indsp->input_cargo_multiplier[prop - 0x1C][1] = GB(multiples, 15, 15);
} break;
case 0x1F: // Industry name
- indsp->name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ indsp->name = grf_load_word(&buf);
+ _string_to_grf_mapping[&indsp->name] = _cur_grffile->grfid;
break;
case 0x20: // Prospecting success chance
@@ -2136,7 +2152,8 @@
break;
case 0x24: // name for nearby station
- indsp->station_name = GRFMappedStringID(grf_load_word(&buf), _cur_grffile->grfid);
+ indsp->station_name = grf_load_word(&buf);
+ _string_to_grf_mapping[&indsp->station_name] = _cur_grffile->grfid;
break;
default:
@@ -3680,7 +3697,7 @@
if (_cur_grffile->housespec == NULL || _cur_grffile->housespec[GB(id, 0, 8)] == NULL) {
grfmsg(1, "FeatureNewName: Attempt to name undefined house 0x%X, ignoring.", GB(id, 0, 8));
} else {
- _cur_grffile->housespec[GB(id, 0, 8)]->building_name = GRFMappedStringID(AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED), 0);
+ _cur_grffile->housespec[GB(id, 0, 8)]->building_name = AddGRFString(_cur_grffile->grfid, id, lang, new_scheme, name, STR_UNDEFINED);
}
break;
@@ -5916,7 +5933,6 @@
for (int i = 0; i < HOUSE_MAX; i++) {
HouseSpec *hs = file->housespec[i];
if (hs != NULL) {
- hs->building_name.MapString();
_house_mngr.SetEntitySpec(hs);
if (hs->min_date < min_date) min_date = hs->min_date;
}
@@ -5947,27 +5963,21 @@
/* process the conversion of text at the end, so to be sure everything will be fine
* and available. Check if it does not return undefind marker, which is a very good sign of a
* substitute industry who has not changed the string been examined, thus using it as such */
- indsp->name.MapString();
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->name);
if (strid != STR_UNDEFINED) indsp->name = strid;
- indsp->closure_text.MapString();
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->closure_text);
if (strid != STR_UNDEFINED) indsp->closure_text = strid;
- indsp->production_up_text.MapString();
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_up_text);
if (strid != STR_UNDEFINED) indsp->production_up_text = strid;
- indsp->production_down_text.MapString();
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->production_down_text);
if (strid != STR_UNDEFINED) indsp->production_down_text = strid;
- indsp->new_industry_text.MapString();
strid = GetGRFStringID(indsp->grf_prop.grffile->grfid, indsp->new_industry_text);
if (strid != STR_UNDEFINED) indsp->new_industry_text = strid;
- indsp->station_name.MapString();
if (indsp->station_name != STR_NULL) {
/* STR_NULL (0) can be set by grf. It has a meaning regarding assignation of the
* station's name. Don't wont to loose the value, therefor, do not process. */
@@ -6010,12 +6020,6 @@
CargoSpec *cs = &_cargo[c];
/* Don't map if the cargo is unavailable or not from NewGRF */
if (cs->grfid == 0) continue;
-
- cs->name.MapString();
- cs->name_single.MapString();
- cs->units_volume.MapString();
- cs->quantifier.MapString();
- cs->abbrev.MapString();
}
}
@@ -6240,6 +6244,11 @@
static void AfterLoadGRFs()
{
+ for (StringIDToGRFIDMapping::iterator it = _string_to_grf_mapping.begin(); it != _string_to_grf_mapping.end(); it++) {
+ *((*it).first) = MapGRFStringID((*it).second, *((*it).first));
+ }
+ _string_to_grf_mapping.clear();
+
/* Update the bitmasks for the vehicle lists */
Player *p;
FOR_ALL_PLAYERS(p) {
@@ -6336,11 +6345,3 @@
{
return HasBit(_misc_grf_features, bit);
}
-
-void GRFMappedStringID::MapString()
-{
- if (this->grfid == 0) return;
-
- this->string = MapGRFStringID(this->grfid, this->string);
- this->grfid = 0;
-}
--- a/src/newgrf_industries.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/newgrf_industries.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -287,7 +287,7 @@
/* Distance of nearest industry of given type */
case 0x64: return GetClosestIndustry(tile, MapNewGRFIndustryType(parameter, indspec->grf_prop.grffile->grfid), industry);
/* Get town zone and Manhattan distance of closest town */
- case 0x65: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceManhattan(tile, industry->town->xy), 0xFFFF);
+ case 0x65: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceManhattan(tile, industry->town->xy), 0xFFFF);
/* Get square of Euclidian distance of closes town */
case 0x66: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceSquare(tile, industry->town->xy), 0xFFFF);
--- a/src/newgrf_industrytiles.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/newgrf_industrytiles.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -279,7 +279,7 @@
return !IsSlopeRefused(GetTileSlope(ind_tile, NULL), its->slopes_refused);
}
if (its->grf_prop.grffile->grf_version < 7) {
- return (callback_res & 0xFF) != 0; // mask to 8 bit callback result
+ return callback_res != 0;
}
/* Copy some parameters from the registers to the error message text ref. stack */
--- a/src/newgrf_spritegroup.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/newgrf_spritegroup.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -97,7 +97,7 @@
case CBID_INDTILE_ACCEPT_CARGO:
case CBID_VEHICLE_COLOUR_MAPPING:
case CBID_HOUSE_PRODUCE_CARGO:
- case CBID_INDTILE_SHAPE_CHECK: // depends on grf version, masked to 8 bit in PerformIndustryTileSlopeCheck() if needed
+ case CBID_INDTILE_SHAPE_CHECK:
case CBID_VEHICLE_SOUND_EFFECT:
case CBID_VEHICLE_MODIFY_PROPERTY: // depends on queried property
case CBID_CARGO_PROFIT_CALC:
--- a/src/newgrf_station.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/newgrf_station.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -420,9 +420,16 @@
if (!HasBit(_svc.valid, 5)) { _svc.v49 = GetPlatformInfoHelper(tile, false, true, false); SetBit(_svc.valid, 5); }
return _svc.v49;
+ case 0x4A: // Animation frame of tile
+ return GetStationAnimationFrame(tile);
+
/* Variables which use the parameter */
/* Variables 0x60 to 0x65 are handled separately below */
- case 0x67: { // Land info of nearby tiles
+ case 0x66: // Animation frame of nearby tile
+ if (parameter != 0) tile = GetNearbyTile(parameter, tile);
+ return st->TileBelongsToRailStation(tile) ? GetStationAnimationFrame(tile) : UINT_MAX;
+
+ case 0x67: { // Land info of nearby tile
Axis axis = GetRailStationAxis(tile);
if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
--- a/src/newgrf_string_type.h Wed Apr 16 22:34:14 2008 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/* $Id$ */
-
-/** @file newgrf_string_type.h */
-
-#ifndef NEWGRF_STRING_TYPE_H
-#define NEWGRF_STRING_TYPE_H
-
-#include "strings_type.h"
-
-/**
- * A string with the required information to perform a GRF string remapping.
- */
-struct GRFMappedStringID
-{
-private:
- /** The GRF ID associated to the to-be-remapped string */
- uint32 grfid;
- /** The string; when grfid != 0 it should be remapped */
- StringID string;
-
-public:
- /**
- * Create the struct.
- * @param str the string to store (or remap)
- * @param grf_id the GRF to remap it with
- */
- GRFMappedStringID(StringID str, uint32 grf_id) : grfid(grf_id), string(str) {}
-
- /**
- * An empty string.
- */
- GRFMappedStringID() {}
-
- /** Cast operator, returns the string */
- inline operator StringID() const
- {
- return string;
- }
-
- /** Assigns the string and resets the GRF ID. */
- GRFMappedStringID& operator = (StringID str)
- {
- string = str;
- grfid = 0;
- return *this;
- }
-
- /**
- * Map the string.
- */
- void MapString();
-};
-
-#endif /* NEWGRF_STRING_TYPE_H */
--- a/src/news_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/news_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -60,7 +60,7 @@
static NewsID _oldest_news = 0; ///< points to first item in fifo queue
static NewsID _latest_news = INVALID_NEWS; ///< points to last item in fifo queue
-struct news_d {
+struct news_d : vp_d {
uint16 follow_vehicle;
int32 scrollpos_x;
int32 scrollpos_y;
@@ -402,20 +402,20 @@
};
static const SoundFx _news_sounds[NT_END] = {
- SND_1D_APPLAUSE, ///< NT_ARRIVAL_PLAYER
- SND_1D_APPLAUSE, ///< NT_ARRIVAL_OTHER
- SND_BEGIN, ///< NT_ACCIDENT
- SND_BEGIN, ///< NT_COMPANY_INFO
- SND_BEGIN, ///< NT_OPENCLOSE
- SND_BEGIN, ///< NT_ECONOMY
- SND_BEGIN, ///< NT_INDUSTRY_PLAYER
- SND_BEGIN, ///< NT_INDUSTRY_OTHER
- SND_BEGIN, ///< NT_INDUSTRY_NOBODY
- SND_BEGIN, ///< NT_ADVICE
- SND_1E_OOOOH, ///< NT_NEW_VEHICLES
- SND_BEGIN, ///< NT_ACCEPTANCE
- SND_BEGIN, ///< NT_SUBSIDIES
- SND_BEGIN, ///< NT_GENERAL
+ SND_1D_APPLAUSE, ///< NT_ARRIVAL_PLAYER
+ SND_1D_APPLAUSE, ///< NT_ARRIVAL_OTHER
+ SND_BEGIN, ///< NT_ACCIDENT
+ SND_BEGIN, ///< NT_COMPANY_INFO
+ SND_BEGIN, ///< NT_OPENCLOSE
+ SND_BEGIN, ///< NT_ECONOMY
+ SND_BEGIN, ///< NT_INDUSTRY_PLAYER
+ SND_BEGIN, ///< NT_INDUSTRY_OTHER
+ SND_BEGIN, ///< NT_INDUSTRY_NOBODY
+ SND_BEGIN, ///< NT_ADVICE
+ SND_1E_OOOOH, ///< NT_NEW_VEHICLES
+ SND_BEGIN, ///< NT_ACCEPTANCE
+ SND_BEGIN, ///< NT_SUBSIDIES
+ SND_BEGIN, ///< NT_GENERAL
};
const char *_news_display_name[NT_END] = {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/news_gui.h Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,12 @@
+/* $Id$ */
+
+/** @file news_gui.h GUI functions related to the news. */
+
+#ifndef NEWS_GUI_H
+#define NEWS_GUI_H
+
+void ShowLastNewsMessage();
+void ShowMessageOptions();
+void ShowMessageHistory();
+
+#endif /* NEWS_GUI_H */
--- a/src/npf.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/npf.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -14,7 +14,8 @@
#include "pathfind.h"
#include "station_base.h"
#include "station_map.h"
-#include "depot.h"
+#include "depot_base.h"
+#include "depot_map.h"
#include "tunnel_map.h"
#include "network/network.h"
#include "water_map.h"
@@ -231,14 +232,14 @@
switch (GetTileType(tile)) {
case MP_RAILWAY:
/* DEBUG: mark visited tiles by mowing the grass under them ;-) */
- if (!IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (!IsRailDepot(tile)) {
SetRailGroundType(tile, RAIL_GROUND_BARREN);
MarkTileDirtyByTile(tile);
}
break;
case MP_ROAD:
- if (!IsTileDepotType(tile, TRANSPORT_ROAD)) {
+ if (!IsRoadDepot(tile)) {
SetRoadside(tile, ROADSIDE_BARREN);
MarkTileDirtyByTile(tile);
}
@@ -397,7 +398,7 @@
* curves should be taken into account, as this affects the speed limit. */
/* Check for reverse in depot */
- if (IsTileDepotType(tile, TRANSPORT_RAIL) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
+ if (IsRailDepotTile(tile) && as->EndNodeCheck(as, &new_node) != AYSTAR_FOUND_END_NODE) {
/* Penalise any depot tile that is not the last tile in the path. This
* _should_ penalise every occurence of reversing in a depot (and only
* that) */
@@ -417,7 +418,7 @@
{
/* It's not worth caching the result with NPF_FLAG_IS_TARGET here as below,
* since checking the cache not that much faster than the actual check */
- return IsTileDepotType(current->path.node.tile, (TransportType)as->user_data[NPF_TYPE]) ?
+ return IsDepotTypeTile(current->path.node.tile, (TransportType)as->user_data[NPF_TYPE]) ?
AYSTAR_FOUND_END_NODE : AYSTAR_DONE;
}
@@ -464,9 +465,9 @@
*/
static bool CanEnterTileOwnerCheck(Owner owner, TileIndex tile, DiagDirection enterdir)
{
- if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */
- IsRailwayStationTile(tile) || /* Rail station tile */
- IsTileDepotType(tile, TRANSPORT_ROAD) || /* Road depot tile */
+ if (IsTileType(tile, MP_RAILWAY) || /* Rail tile (also rail depot) */
+ IsRailwayStationTile(tile) || /* Rail station tile */
+ IsRoadDepotTile(tile) || /* Road depot tile */
IsStandardRoadStopTile(tile)) { /* Road station tile (but not drive-through stops) */
return IsTileOwner(tile, owner); /* You need to own these tiles entirely to use them */
}
@@ -499,7 +500,7 @@
*/
static DiagDirection GetDepotDirection(TileIndex tile, TransportType type)
{
- assert(IsTileDepotType(tile, type));
+ assert(IsDepotTypeTile(tile, type));
switch (type) {
case TRANSPORT_RAIL: return GetRailDepotDirection(tile);
@@ -537,7 +538,7 @@
*/
static DiagDirection GetTileSingleEntry(TileIndex tile, TransportType type, uint subtype)
{
- if (type != TRANSPORT_WATER && IsTileDepotType(tile, type)) return GetDepotDirection(tile, type);
+ if (type != TRANSPORT_WATER && IsDepotTypeTile(tile, type)) return GetDepotDirection(tile, type);
if (type == TRANSPORT_ROAD) {
if (IsStandardRoadStopTile(tile)) return GetRoadStopDir(tile);
@@ -879,7 +880,7 @@
FOR_ALL_DEPOTS(depot) {
/* Check if this is really a valid depot, it is of the needed type and
* owner */
- if (IsTileDepotType(depot->xy, type) && IsTileOwner(depot->xy, owner))
+ if (IsDepotTypeTile(depot->xy, type) && IsTileOwner(depot->xy, owner))
/* If so, let's add it to the queue, sorted by distance */
depots.push(&depots, depot, DistanceManhattan(tile, depot->xy));
}
--- a/src/oldloader.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/oldloader.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -15,7 +15,7 @@
#include "train.h"
#include "signs_base.h"
#include "debug.h"
-#include "depot.h"
+#include "depot_base.h"
#include "newgrf_config.h"
#include "ai/ai.h"
#include "ai/default/default.h"
@@ -1473,6 +1473,7 @@
return !ls->failed;
}
+extern TileIndex _cur_tileloop_tile;
static uint32 _old_cur_town_ctr;
static const OldChunks main_chunk[] = {
OCL_ASSERT( 0 ),
--- a/src/openttd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/openttd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -46,7 +46,6 @@
#include "network/network.h"
#include "signs_base.h"
#include "signs_func.h"
-#include "depot.h"
#include "waypoint.h"
#include "ai/ai.h"
#include "train.h"
@@ -59,6 +58,7 @@
#include "strings_func.h"
#include "date_func.h"
#include "vehicle_func.h"
+#include "cheat_func.h"
#include "newgrf.h"
#include "newgrf_config.h"
@@ -85,6 +85,8 @@
#include "table/strings.h"
+StringID _switch_mode_errorstr;
+
void CallLandscapeTick();
void IncreaseDate();
void DoPaletteAnimations();
@@ -1923,7 +1925,7 @@
}
/* Clear PBS reservation on track */
- if (!IsTileDepotType(t, TRANSPORT_RAIL)) {
+ if (!IsRailDepotTile(t)) {
SB(_m[t].m4, 4, 4, 0);
} else {
ClrBit(_m[t].m3, 6);
--- a/src/order_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/order_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -7,7 +7,7 @@
#include "order_base.h"
#include "order_func.h"
#include "airport.h"
-#include "depot.h"
+#include "order_base.h"
#include "waypoint.h"
#include "command_func.h"
#include "player_func.h"
@@ -26,6 +26,7 @@
#include "timetable.h"
#include "vehicle_func.h"
#include "oldpool_func.h"
+#include "depot_base.h"
#include "table/strings.h"
@@ -392,15 +393,15 @@
switch (v->type) {
case VEH_TRAIN:
- if (!IsTileDepotType(dp->xy, TRANSPORT_RAIL)) return CMD_ERROR;
+ if (!IsRailDepotTile(dp->xy)) return CMD_ERROR;
break;
case VEH_ROAD:
- if (!IsTileDepotType(dp->xy, TRANSPORT_ROAD)) return CMD_ERROR;
+ if (!IsRoadDepotTile(dp->xy)) return CMD_ERROR;
break;
case VEH_SHIP:
- if (!IsTileDepotType(dp->xy, TRANSPORT_WATER)) return CMD_ERROR;
+ if (!IsShipDepotTile(dp->xy)) return CMD_ERROR;
break;
default: return CMD_ERROR;
--- a/src/order_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/order_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -13,7 +13,7 @@
#include "command_func.h"
#include "viewport_func.h"
#include "gfx_func.h"
-#include "depot.h"
+#include "depot_base.h"
#include "waypoint.h"
#include "train.h"
#include "water_map.h"
@@ -29,6 +29,7 @@
#include "widgets/dropdown_func.h"
#include "textbuf_gui.h"
#include "string_func.h"
+#include "depot_base.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -462,8 +463,7 @@
case MP_WATER:
if (v->type != VEH_SHIP) break;
- if (IsTileDepotType(tile, TRANSPORT_WATER) &&
- IsTileOwner(tile, _local_player)) {
+ if (IsShipDepot(tile) && IsTileOwner(tile, _local_player)) {
TileIndex tile2 = GetOtherShipDepotTile(tile);
order.MakeGoToDepot(GetDepotByTile(tile < tile2 ? tile : tile2)->index, ODTFB_PART_OF_ORDERS);
@@ -541,7 +541,7 @@
if (!cmd.IsValid()) return;
if (DoCommandP(v->tile, v->index + (OrderGetSel(w) << 16), cmd.Pack(), NULL, CMD_INSERT_ORDER | CMD_MSG(STR_8833_CAN_T_INSERT_NEW_ORDER))) {
- if (WP(w, order_d).sel != -1) WP(w,order_d).sel++;
+ if (WP(w, order_d).sel != -1) WP(w, order_d).sel++;
ResetObjectToPlace();
}
}
@@ -1087,7 +1087,7 @@
static const WindowDesc _orders_train_desc = {
WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
- WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
+ WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
_orders_train_widgets,
OrdersWndProc
@@ -1128,7 +1128,7 @@
static const WindowDesc _orders_desc = {
WDP_AUTO, WDP_AUTO, 386, 100, 386, 100,
- WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
+ WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_RESIZABLE,
_orders_widgets,
OrdersWndProc
@@ -1169,7 +1169,7 @@
static const WindowDesc _other_orders_desc = {
WDP_AUTO, WDP_AUTO, 386, 88, 386, 88,
- WC_VEHICLE_ORDERS,WC_VEHICLE_VIEW,
+ WC_VEHICLE_ORDERS, WC_VEHICLE_VIEW,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
_other_orders_widgets,
OrdersWndProc
--- a/src/pathfind.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/pathfind.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -6,7 +6,6 @@
#include "openttd.h"
#include "bridge_map.h"
#include "station_map.h"
-#include "depot.h"
#include "tile_cmd.h"
#include "landscape.h"
#include "pathfind.h"
@@ -14,7 +13,6 @@
#include "debug.h"
#include "tunnel_map.h"
#include "settings_type.h"
-#include "depot.h"
#include "tunnelbridge_map.h"
#include "core/random_func.hpp"
#include "core/alloc_type.hpp"
@@ -170,10 +168,10 @@
{
if (tracktype == TRANSPORT_RAIL) {
/* depot from wrong side */
- if (IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) != side) return false;
+ if (IsRailDepotTile(tile) && GetRailDepotDirection(tile) != side) return false;
} else if (tracktype == TRANSPORT_ROAD) {
/* depot from wrong side */
- if (IsTileDepotType(tile, TRANSPORT_ROAD) && GetRoadDepotDirection(tile) != side) return false;
+ if (IsRoadDepotTile(tile) && GetRoadDepotDirection(tile) != side) return false;
/* non-driverthrough road station from wrong side */
if (IsStandardRoadStopTile(tile) && GetRoadStopDir(tile) != side) return false;
}
--- a/src/player_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/player_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -58,9 +58,9 @@
if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status
/* draw categories */
DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, TC_FROMSTRING);
- for (i = 0; i != 13; i++)
+ for (i = 0; i != EXPENSES_END; i++)
DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, TC_FROMSTRING);
- DrawStringRightAligned(111, 27 + 10 * 13 + 2, STR_7020_TOTAL, TC_FROMSTRING);
+ DrawStringRightAligned(111, 27 + 10 * EXPENSES_END + 2, STR_7020_TOTAL, TC_FROMSTRING);
/* draw the price columns */
year = _cur_year - 2;
@@ -72,7 +72,7 @@
SetDParam(0, year);
DrawStringRightAlignedUnderline(x, 15, STR_7010, TC_FROMSTRING);
sum = 0;
- for (i = 0; i != 13; i++) {
+ for (i = 0; i != EXPENSES_END; i++) {
/* draw one row in the price column */
cost = (*tbl)[i];
if (cost != 0) {
@@ -88,16 +88,16 @@
str = STR_701E;
if (sum < 0) { sum = -sum; str++; }
SetDParam(0, sum);
- DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, TC_FROMSTRING);
+ DrawStringRightAligned(x, 27 + EXPENSES_END * 10 + 2, str, TC_FROMSTRING);
- GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215);
+ GfxFillRect(x - 75, 27 + 10 * EXPENSES_END, x, 27 + 10 * EXPENSES_END, 215);
x += 95;
}
year++;
tbl--;
} while (--j != 0);
- y = 171;
+ y = 27 + 10 * EXPENSES_END + 14;
/* draw max loan aligned to loan below (y += 10) */
SetDParam(0, _economy.max_loan);
@@ -135,10 +135,10 @@
{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS},
{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW},
{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON},
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL},
-{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL},
-{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 204, 215, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN},
-{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 203, 406, 204, 215, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN},
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 14, 39 + 10 * EXPENSES_END, 0x0, STR_NULL},
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 40 + 10 * EXPENSES_END, 73 + 10 * EXPENSES_END, 0x0, STR_NULL},
+{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN},
+{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 203, 406, 74 + 10 * EXPENSES_END, 85 + 10 * EXPENSES_END, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN},
{ WIDGETS_END},
};
@@ -163,7 +163,7 @@
const Player *p = GetPlayer(player);
/* Recheck the size of the window as it might need to be resized due to the local player changing */
- int new_height = ((player != _local_player) ? 0 : 12) + ((WP(w, def_d).data_1 != 0) ? 48 : 204);
+ int new_height = ((player != _local_player) ? 0 : 12) + ((WP(w, def_d).data_1 != 0) ? 48 : 74 + 10 * EXPENSES_END);
if (w->height != new_height) {
/* Make window dirty before and after resizing */
SetWindowDirty(w);
@@ -216,7 +216,7 @@
}
static const WindowDesc _player_finances_desc = {
- WDP_AUTO, WDP_AUTO, 407, 216, 407, 216,
+ WDP_AUTO, WDP_AUTO, 407, 86 + 10 * EXPENSES_END, 407, 86 + 10 * EXPENSES_END,
WC_FINANCES, WC_NONE,
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON,
_player_finances_widgets,
--- a/src/players.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/players.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -14,6 +14,7 @@
#include "network/network.h"
#include "network/network_internal.h"
#include "variables.h"
+#include "cheat_func.h"
#include "ai/ai.h"
#include "player_face.h"
#include "group.h"
@@ -313,7 +314,7 @@
t = ClosestTownFromTile(tile, (uint)-1);
- if (IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST+1)) {
+ if (IsInsideMM(t->townnametype, SPECSTR_TOWNNAME_START, SPECSTR_TOWNNAME_LAST + 1)) {
str = t->townnametype - SPECSTR_TOWNNAME_START + SPECSTR_PLAYERNAME_START;
strp = t->townnameparts;
@@ -352,7 +353,7 @@
}
}
-#define COLOR_SWAP(i,j) do { byte t=colors[i];colors[i]=colors[j];colors[j]=t; } while(0)
+#define COLOR_SWAP(i, j) do { byte t = colors[i];colors[i] = colors[j];colors[j] = t; } while(0)
static const byte _color_sort[16] = {2, 2, 3, 2, 3, 2, 3, 2, 3, 2, 2, 2, 3, 1, 1, 1};
static const byte _color_similar_1[16] = {8, 6, 255, 12, 255, 0, 1, 1, 0, 13, 11, 10, 3, 9, 15, 14};
@@ -361,7 +362,7 @@
static byte GeneratePlayerColor()
{
byte colors[16], pcolor, t2;
- int i,j,n;
+ int i, j, n;
uint32 r;
Player *p;
@@ -388,14 +389,14 @@
/* Move the colors that look similar to each player's color to the side */
FOR_ALL_PLAYERS(p) if (p->is_active) {
pcolor = p->player_color;
- for (i=0; i!=16; i++) if (colors[i] == pcolor) {
+ for (i = 0; i != 16; i++) if (colors[i] == pcolor) {
colors[i] = 0xFF;
t2 = _color_similar_1[pcolor];
if (t2 == 0xFF) break;
- for (i=0; i!=15; i++) {
+ for (i = 0; i != 15; i++) {
if (colors[i] == t2) {
- do COLOR_SWAP(i,i+1); while (++i != 15);
+ do COLOR_SWAP(i, i + 1); while (++i != 15);
break;
}
}
@@ -720,7 +721,7 @@
cost = AddEngineReplacementForPlayer(p, old_engine_type, new_engine_type, id_g, flags);
} else {
- cost = RemoveEngineReplacementForPlayer(p, old_engine_type,id_g, flags);
+ cost = RemoveEngineReplacementForPlayer(p, old_engine_type, id_g, flags);
}
if (IsLocalPlayer()) InvalidateAutoreplaceWindow(old_engine_type, id_g);
@@ -956,19 +957,6 @@
return _endgame_perf_titles[value];
}
-/** Return true if any cheat has been used, false otherwise */
-static bool CheatHasBeenUsed()
-{
- const Cheat* cht = (Cheat*)&_cheats;
- const Cheat* cht_last = &cht[sizeof(_cheats) / sizeof(Cheat)];
-
- for (; cht != cht_last; cht++) {
- if (cht->been_used) return true;
- }
-
- return false;
-}
-
/** Save the highscore for the player */
int8 SaveHighScoreValue(const Player *p)
{
@@ -1101,8 +1089,8 @@
SLE_VAR(Player, name_1, SLE_STRINGID),
SLE_CONDSTR(Player, name, SLE_STR, 0, 84, SL_MAX_VERSION),
- SLE_VAR(Player, president_name_1,SLE_UINT16),
- SLE_VAR(Player, president_name_2,SLE_UINT32),
+ SLE_VAR(Player, president_name_1, SLE_UINT16),
+ SLE_VAR(Player, president_name_2, SLE_UINT32),
SLE_CONDSTR(Player, president_name, SLE_STR, 0, 84, SL_MAX_VERSION),
SLE_VAR(Player, face, SLE_UINT32),
--- a/src/rail_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/rail_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -20,7 +20,8 @@
#include "engine_func.h"
#include "town.h"
#include "sprite.h"
-#include "depot.h"
+#include "depot_base.h"
+#include "depot_func.h"
#include "waypoint.h"
#include "rail.h"
#include "newgrf.h"
@@ -40,6 +41,8 @@
#include "sound_func.h"
#include "signal_func.h"
#include "tunnelbridge.h"
+#include "station_map.h"
+#include "water_map.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -2268,7 +2271,7 @@
int length;
/* this routine applies only to trains in depot tiles */
- if (v->type != VEH_TRAIN || !IsTileDepotType(tile, TRANSPORT_RAIL)) return VETSB_CONTINUE;
+ if (v->type != VEH_TRAIN || !IsRailDepotTile(tile)) return VETSB_CONTINUE;
/* depot direction */
dir = GetRailDepotDirection(tile);
--- a/src/rail_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/rail_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -29,6 +29,7 @@
#include "settings_type.h"
#include "widgets/dropdown_type.h"
#include "widgets/dropdown_func.h"
+#include "tunnelbridge.h"
#include "bridge_map.h"
#include "rail_map.h"
--- a/src/rail_map.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/rail_map.h Fri Apr 18 19:55:13 2008 +0000
@@ -72,7 +72,18 @@
}
/**
- * Is this tile a rail depot?
+ * Is this rail 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;
+}
+
+/**
+ * Is this rail 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
@@ -83,17 +94,16 @@
}
/**
- * Is this tile a rail waypoint?
+ * Is this tile rail tile and 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 waypoint
+ * @return true if and only if the tile is a rail depot
*/
-static inline bool IsRailWaypoint(TileIndex t)
+static inline bool IsRailDepotTile(TileIndex t)
{
- return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
+ return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
}
-
/**
* Gets the rail type of the given tile
* @param t the tile to get the rail type from
--- a/src/road_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/road_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -18,7 +18,8 @@
#include "command_func.h"
#include "town.h"
#include "yapf/yapf.h"
-#include "depot.h"
+#include "depot_base.h"
+#include "depot_func.h"
#include "newgrf.h"
#include "station_map.h"
#include "tunnel_map.h"
@@ -34,6 +35,7 @@
#include "sound_func.h"
#include "road_func.h"
#include "tunnelbridge.h"
+#include "cheat_func.h"
#include "table/sprites.h"
#include "table/strings.h"
--- a/src/road_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/road_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -22,6 +22,7 @@
#include "sound_func.h"
#include "player_func.h"
#include "settings_type.h"
+#include "tunnelbridge.h"
#include "table/sprites.h"
#include "table/strings.h"
--- a/src/road_map.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/road_map.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -9,7 +9,6 @@
#include "road_map.h"
#include "tunnel_map.h"
#include "station_map.h"
-#include "depot.h"
#include "tunnelbridge_map.h"
--- a/src/roadveh_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/roadveh_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -17,7 +17,6 @@
#include "npf.h"
#include "player_func.h"
#include "player_base.h"
-#include "depot.h"
#include "bridge.h"
#include "tunnel_map.h"
#include "bridge_map.h"
@@ -41,6 +40,8 @@
#include "gfx_func.h"
#include "settings_type.h"
#include "order_func.h"
+#include "depot_base.h"
+#include "depot_func.h"
#include "table/strings.h"
@@ -178,7 +179,7 @@
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
- if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return CMD_ERROR;
+ if (!IsRoadDepotTile(tile)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
if (HasTileRoadType(tile, ROADTYPE_TRAM) != HasBit(EngInfo(p1)->misc_flags, EF_ROAD_TRAM)) return_cmd_error(STR_DEPOT_WRONG_DEPOT_TYPE);
@@ -340,7 +341,7 @@
{
TileIndex tile = v->tile;
- if (!IsTileDepotType(tile, TRANSPORT_ROAD)) return false;
+ if (!IsRoadDepotTile(tile)) return false;
if (IsRoadVehFront(v) && !(v->vehstatus & VS_STOPPED)) return false;
for (; v != NULL; v = v->Next()) {
@@ -1292,7 +1293,7 @@
v->cur_image = v->GetImage(v->direction);
v->UpdateDeltaXY(v->direction);
- SetRoadVehPosition(v,x,y);
+ SetRoadVehPosition(v, x, y);
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
@@ -1389,7 +1390,7 @@
Direction new_dir;
Direction old_dir;
RoadDriveEntry rd;
- int x,y;
+ int x, y;
uint32 r;
if (v->u.road.overtaking != 0) {
@@ -1430,7 +1431,7 @@
/* Vehicle has just entered a bridge or tunnel */
v->cur_image = v->GetImage(v->direction);
v->UpdateDeltaXY(v->direction);
- SetRoadVehPosition(v,gp.x,gp.y);
+ SetRoadVehPosition(v, gp.x, gp.y);
return true;
}
--- a/src/roadveh_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/roadveh_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -11,7 +11,6 @@
#include "viewport_func.h"
#include "gfx_func.h"
#include "command_func.h"
-#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"
--- a/src/saveload.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/saveload.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -343,7 +343,7 @@
/* Ugly encoding of >16M RIFF chunks
* The lower 24 bits are normal
* The uppermost 4 bits are bits 24:27 */
- assert(length < (1<<28));
+ assert(length < (1 << 28));
SlWriteUint32((length & 0xFFFFFF) | ((length >> 24) << 28));
break;
case CH_ARRAY:
@@ -1218,7 +1218,7 @@
z->avail_out = sizeof(buf);
r = deflate(z, mode);
/* bytes were emitted? */
- if ((n=sizeof(buf) - z->avail_out) != 0) {
+ if ((n = sizeof(buf) - z->avail_out) != 0) {
if (fwrite(buf, n, 1, _sl.fh) != 1) SlError(STR_GAME_SAVELOAD_ERROR_FILE_NOT_WRITEABLE);
}
if (r == Z_STREAM_END)
@@ -1248,6 +1248,7 @@
/* these define the chunks */
extern const ChunkHandler _misc_chunk_handlers[];
+extern const ChunkHandler _cheat_chunk_handlers[] ;
extern const ChunkHandler _setting_chunk_handlers[];
extern const ChunkHandler _player_chunk_handlers[];
extern const ChunkHandler _engine_chunk_handlers[];
@@ -1267,6 +1268,7 @@
static const ChunkHandler * const _chunk_handlers[] = {
_misc_chunk_handlers,
+ _cheat_chunk_handlers,
_setting_chunk_handlers,
_veh_chunk_handlers,
_waypoint_chunk_handlers,
--- a/src/settings.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/settings.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -83,7 +83,7 @@
static bool IsSignedVarMemType(VarType vt);
struct SettingsMemoryPool {
- uint pos,size;
+ uint pos, size;
SettingsMemoryPool *next;
byte mem[1];
};
@@ -242,7 +242,7 @@
/* trim whitespace from right side. */
e = s + strlen(s);
- while (e > s && ((c=e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--;
+ while (e > s && ((c = e[-1]) == '\n' || c == '\r' || c == ' ' || c == '\t')) e--;
*e = '\0';
/* skip comments and empty lines */
@@ -253,7 +253,7 @@
/* add to comment */
if (ns > a) {
a = max(a, 128U);
- do a*=2; while (a < ns);
+ do a *= 2; while (a < ns);
comment = ReallocT(comment, comment_alloc = a);
}
pos = comment_size;
--- a/src/settings_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/settings_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -64,7 +64,7 @@
{
static StringID buf[32 + 1];
StringID *p = buf;
- while (--num>=0) *p++ = base++;
+ while (--num >= 0) *p++ = base++;
*p = INVALID_STRING_ID;
return buf;
}
@@ -308,7 +308,7 @@
break;
case GAMEOPT_RESOLUTION_BTN: /* Change resolution */
- if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0],_resolutions[e->we.dropdown.index][1]))
+ if (e->we.dropdown.index < _num_resolutions && ChangeResInGame(_resolutions[e->we.dropdown.index][0], _resolutions[e->we.dropdown.index][1]))
SetWindowDirty(w);
break;
@@ -340,7 +340,7 @@
if (flags & DC_EXEC) {
_opt_ptr->road_side = p1;
- InvalidateWindow(WC_GAME_OPTIONS,0);
+ InvalidateWindow(WC_GAME_OPTIONS, 0);
}
return CommandCost();
}
@@ -1059,7 +1059,7 @@
case WE_ON_EDIT_TEXT:
if (e->we.edittext.str != NULL) {
- const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w,def_d).data_3];
+ const PatchEntry *pe = &_patches_page[WP(w, def_d).data_1].entries[WP(w, def_d).data_3];
const SettingDesc *sd = pe->setting;
int32 value = atoi(e->we.edittext.str);
--- a/src/ship_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/ship_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -17,7 +17,8 @@
#include "player_func.h"
#include "player_base.h"
#include "npf.h"
-#include "depot.h"
+#include "depot_base.h"
+#include "depot_func.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "water_map.h"
@@ -130,7 +131,7 @@
FOR_ALL_DEPOTS(depot) {
TileIndex tile = depot->xy;
- if (IsTileDepotType(tile, TRANSPORT_WATER) && IsTileOwner(tile, v->owner)) {
+ if (IsShipDepotTile(tile) && IsTileOwner(tile, v->owner)) {
uint dist = DistanceManhattan(tile, v->tile);
if (dist < best_dist) {
best_dist = dist;
@@ -762,7 +763,7 @@
/* The ai_new queries the vehicle cost before building the route,
* so we must check against cheaters no sooner than now. --pasky */
- if (!IsTileDepotType(tile, TRANSPORT_WATER)) return CMD_ERROR;
+ if (!IsShipDepotTile(tile)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
unit_num = HasBit(p2, 0) ? 0 : GetFreeUnitNumber(VEH_SHIP);
--- a/src/ship_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/ship_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -10,7 +10,6 @@
#include "window_gui.h"
#include "viewport_func.h"
#include "gfx_func.h"
-#include "depot.h"
#include "vehicle_gui.h"
#include "newgrf_engine.h"
#include "strings_func.h"
--- a/src/signal.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/signal.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -422,11 +422,11 @@
/* train in the segment */
newstate = SIGNAL_STATE_RED;
} else {
- /* is it a bidir combo? - then do not count its other signal direction as exit */
+ /* is it a bidir combo? - then do not count its other signal direction as exit */
if (sig == SIGTYPE_COMBO && HasSignalOnTrackdir(tile, ReverseTrackdir(trackdir))) {
/* at least one more exit */
if (flags & SF_EXIT2 &&
- /* no green exit */
+ /* no green exit */
(!(flags & SF_GREEN) ||
/* only one green exit, and it is this one - so all other exits are red */
(!(flags & SF_GREEN2) && GetSignalStateByTrackdir(tile, ReverseTrackdir(trackdir)) == SIGNAL_STATE_GREEN))) {
@@ -507,7 +507,7 @@
case MP_STATION:
case MP_ROAD:
if ((TrackStatusToTrackBits(GetTileTrackStatus(tile, TRANSPORT_RAIL, 0)) & _enterdir_to_trackbits[dir]) != TRACK_BIT_NONE) {
- /* only add to set when there is some 'interesting' track */
+ /* only add to set when there is some 'interesting' track */
_tbdset.Add(tile, dir);
_tbdset.Add(tile + TileOffsByDiagDir(dir), ReverseDiagDir(dir));
break;
--- a/src/signs_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/signs_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -219,7 +219,7 @@
case QUERY_EDIT_SIGN_WIDGET_NEXT:
if (_sign_sort_dirty) GlobalSortSignList();
sign_index = _sign_sort[0]->index;
- for (uint i = 0; i < _num_sign_sort-1; i++) {
+ for (uint i = 0; i < _num_sign_sort - 1; i++) {
if (qs->cur_sign == _sign_sort[i]->index) {
sign_index = _sign_sort[i + 1]->index;
break;
--- a/src/smallmap_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/smallmap_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -1,4 +1,3 @@
-
/* $Id$ */
/** @file smallmap_gui.cpp */
--- a/src/station.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/station.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -13,7 +13,6 @@
#include "player_func.h"
#include "airport.h"
#include "sprite.h"
-#include "depot.h"
#include "train.h"
#include "water_map.h"
#include "industry_map.h"
--- a/src/station_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/station_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -18,7 +18,6 @@
#include "saveload.h"
#include "airport.h"
#include "sprite.h"
-#include "depot.h"
#include "train.h"
#include "roadveh.h"
#include "water_map.h"
@@ -133,9 +132,9 @@
return st->airport_tile + ToTileIndexDiff(keydepot);
}
-RoadStop* GetRoadStopByTile(TileIndex tile, RoadStopType type)
+RoadStop *GetRoadStopByTile(TileIndex tile, RoadStopType type)
{
- const Station* st = GetStationByTile(tile);
+ const Station *st = GetStationByTile(tile);
for (RoadStop *rs = st->GetPrimaryRoadStop(type);; rs = rs->next) {
if (rs->xy == tile) return rs;
@@ -144,7 +143,7 @@
}
-static uint GetNumRoadStopsInStation(const Station* st, RoadStopType type)
+static uint GetNumRoadStopsInStation(const Station *st, RoadStopType type)
{
uint num = 0;
@@ -162,7 +161,7 @@
* @param st Station to query
* @return the so calculated radius
*/
-static uint FindCatchmentRadius(const Station* st)
+static uint FindCatchmentRadius(const Station *st)
{
uint ret = CA_NONE;
@@ -177,7 +176,7 @@
#define CHECK_STATIONS_ERR ((Station*)-1)
-static Station* GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
+static Station *GetStationAround(TileIndex tile, int w, int h, StationID closest_station)
{
/* check around to see if there's any stations there */
BEGIN_TILE_LOOP(tile_cur, w + 2, h + 2, tile - TileDiffXY(1, 1))
@@ -312,20 +311,19 @@
1 << M(STR_SV_STNAME_HELIPORT), /* 5 */
};
- Town *t = st->town;
- uint32 free_names = (uint32)-1;
- int found;
- unsigned long tmp;
+ const Town *t = st->town;
+ uint32 free_names = UINT32_MAX;
{
- Station *s;
+ const Station *s;
FOR_ALL_STATIONS(s) {
if (s != st && s->town == t) {
uint str = M(s->string_id);
if (str <= 0x20) {
- if (str == M(STR_SV_STNAME_FOREST))
+ if (str == M(STR_SV_STNAME_FOREST)) {
str = M(STR_SV_STNAME_WOODS);
+ }
ClrBit(free_names, str);
}
}
@@ -333,7 +331,8 @@
}
/* check default names */
- tmp = free_names & _gen_station_name_bits[flag];
+ uint32 tmp = free_names & _gen_station_name_bits[flag];
+ int found;
if (tmp != 0) {
found = FindFirstBit(tmp);
goto done;
@@ -410,11 +409,11 @@
}
#undef M
-static Station* GetClosestStationFromTile(TileIndex tile)
+static Station *GetClosestStationFromTile(TileIndex tile)
{
uint threshold = 8;
- Station* best_station = NULL;
- Station* st;
+ Station *best_station = NULL;
+ Station *st;
FOR_ALL_STATIONS(st) {
if (st->facilities == 0 && st->owner == _current_player) {
@@ -448,7 +447,7 @@
/** Update the virtual coords needed to draw the station sign for all stations. */
void UpdateAllStationVirtCoord()
{
- Station* st;
+ Station *st;
FOR_ALL_STATIONS(st) {
UpdateStationVirtCoord(st);
@@ -498,13 +497,13 @@
}
/**
-* Get a list of the cargo types being produced around the tile (in a rectangle).
-* @param produced: Destination array of produced cargo
-* @param tile: Center of the search area
-* @param w: Width of the center
-* @param h: Height of the center
-* @param rad: Radius of the search area
-*/
+ * Get a list of the cargo types being produced around the tile (in a rectangle).
+ * @param produced: Destination array of produced cargo
+ * @param tile: Center of the search area
+ * @param w: Width of the center
+ * @param h: Height of the center
+ * @param rad: Radius of the search area
+ */
void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile,
int w, int h, int rad)
{
@@ -547,13 +546,13 @@
}
/**
-* Get a list of the cargo types that are accepted around the tile.
-* @param accepts: Destination array of accepted cargo
-* @param tile: Center of the search area
-* @param w: Width of the center
-* @param h: Height of the center
-* @param rad: Radius of the rectangular search area
-*/
+ * Get a list of the cargo types that are accepted around the tile.
+ * @param accepts: Destination array of accepted cargo
+ * @param tile: Center of the search area
+ * @param w: Width of the center
+ * @param h: Height of the center
+ * @param rad: Radius of the rectangular search area
+ */
void GetAcceptanceAroundTiles(AcceptedCargo accepts, TileIndex tile,
int w, int h, int rad)
{
@@ -595,7 +594,7 @@
uint max_y;
};
-static inline void MergePoint(ottd_Rectangle* rect, TileIndex tile)
+static inline void MergePoint(ottd_Rectangle *rect, TileIndex tile)
{
uint x = TileX(tile);
uint y = TileY(tile);
@@ -627,18 +626,14 @@
/* Put all the tiles that span an area in the table. */
if (st->train_tile != 0) {
MergePoint(&rect, st->train_tile);
- MergePoint(&rect,
- st->train_tile + TileDiffXY(st->trainst_w - 1, st->trainst_h - 1)
- );
+ MergePoint(&rect, st->train_tile + TileDiffXY(st->trainst_w - 1, st->trainst_h - 1));
}
if (st->airport_tile != 0) {
- const AirportFTAClass* afc = st->Airport();
+ const AirportFTAClass *afc = st->Airport();
MergePoint(&rect, st->airport_tile);
- MergePoint(&rect,
- st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1)
- );
+ MergePoint(&rect, st->airport_tile + TileDiffXY(afc->size_x - 1, afc->size_y - 1));
}
if (st->dock_tile != 0) MergePoint(&rect, st->dock_tile);
@@ -672,16 +667,16 @@
/* Make sure the station can accept the goods type. */
bool is_passengers = IsCargoInClass(i, CC_PASSENGERS);
if ((!is_passengers && !(st->facilities & (byte)~FACIL_BUS_STOP)) ||
- (is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP)))
+ (is_passengers && !(st->facilities & (byte)~FACIL_TRUCK_STOP))) {
amt = 0;
+ }
SB(st->goods[i].acceptance_pickup, GoodsEntry::ACCEPTANCE, 1, amt >= 8);
}
/* Only show a message in case the acceptance was actually changed. */
uint new_acc = GetAcceptanceMask(st);
- if (old_acc == new_acc)
- return;
+ if (old_acc == new_acc) return;
/* show a message to report that the acceptance was changed? */
if (show_msg && st->owner == _local_player && st->facilities) {
@@ -866,7 +861,7 @@
return CheckFlatLandBelow(tile, w, h, flags, (uint32)invalid_dirs, station, NULL, check_clear);
}
-static bool CanExpandRailroadStation(const Station* st, uint* fin, Axis axis)
+static bool CanExpandRailroadStation(const Station *st, uint *fin, Axis axis)
{
uint curw = st->trainst_w;
uint curh = st->trainst_h;
@@ -989,9 +984,6 @@
*/
CommandCost CmdBuildRailroadStation(TileIndex tile_org, uint32 flags, uint32 p1, uint32 p2)
{
- int w_org, h_org;
- CommandCost ret;
-
/* Does the authority allow this? */
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile_org)) return CMD_ERROR;
if (!ValParamRailtype((RailType)(p2 & 0xF))) return CMD_ERROR;
@@ -1000,6 +992,8 @@
Axis axis = Extract<Axis, 0>(p1);
uint numtracks = GB(p1, 8, 8);
uint plat_len = GB(p1, 16, 8);
+
+ int w_org, h_org;
if (axis == AXIS_X) {
w_org = plat_len;
h_org = numtracks;
@@ -1021,7 +1015,7 @@
/* If DC_EXEC is in flag, do not want to pass it to CheckFlatLandBelow, because of a nice bug
* for detail info, see:
* https://sourceforge.net/tracker/index.php?func=detail&aid=1029064&group_id=103924&atid=636365 */
- ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
+ CommandCost ret = CheckFlatLandBelow(tile_org, w_org, h_org, flags & ~DC_EXEC, 5 << axis, _patches.nonuniform_stations ? &est : NULL);
if (CmdFailed(ret)) return ret;
CommandCost cost(EXPENSES_CONSTRUCTION, ret.GetCost() + (numtracks * _price.train_station_track + _price.train_station_length) * plat_len);
@@ -1283,7 +1277,7 @@
/* Do not allow removing from stations if non-uniform stations are not enabled
* The check must be here to give correct error message
- */
+ */
if (!_patches.nonuniform_stations) return_cmd_error(STR_NONUNIFORM_STATIONS_DISALLOWED);
/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
@@ -1329,12 +1323,12 @@
static CommandCost RemoveRailroadStation(Station *st, TileIndex tile, uint32 flags)
{
/* if there is flooding and non-uniform stations are enabled, remove platforms tile by tile */
- if (_current_player == OWNER_WATER && _patches.nonuniform_stations)
+ if (_current_player == OWNER_WATER && _patches.nonuniform_stations) {
return DoCommand(tile, 0, 0, DC_EXEC, CMD_REMOVE_FROM_RAILROAD_STATION);
+ }
/* Current player owns the station? */
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner))
- return CMD_ERROR;
+ if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR;
/* determine width and height of platforms */
tile = st->train_tile;
@@ -1392,7 +1386,7 @@
* @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)
+static RoadStop **FindRoadStopSpot(bool truck_station, Station *st)
{
RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops;
@@ -1438,8 +1432,6 @@
if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) return CMD_ERROR;
- CommandCost cost;
-
/* 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);
@@ -1464,7 +1456,7 @@
/* Do not remove roadtypes! */
rts |= cur_rts;
}
- cost = CheckFlatLandBelow(tile, 1, 1, flags, is_drive_through ? 5 << p1 : 1 << p1, NULL, false, !build_over_road);
+ CommandCost 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;
@@ -1675,18 +1667,18 @@
/* Check if a valid, buildable airport was chosen for construction */
//if (p1 > lengthof(_airport_sections) || !HasBit(GetValidAirports(), p1)) return CMD_ERROR;
- if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile))
+ if (!(flags & DC_NO_TOWN_RATING) && !CheckIfAuthorityAllows(tile)) {
return CMD_ERROR;
-
- Town *t = ClosestTownFromTile(tile, (uint)-1);
+ }
+
+ Town *t = ClosestTownFromTile(tile, UINT_MAX);
/* Check if local auth refuses a new airport */
{
uint num = 0;
const Station *st;
FOR_ALL_STATIONS(st) {
- if (st->town == t && st->facilities & FACIL_AIRPORT && st->Airport() == AirportFTAClass::oil_rig)
- num++;
+ if (st->town == t && st->facilities & FACIL_AIRPORT && st->Airport() != AirportFTAClass::oil_rig) num++;
}
if (num >= 2) {
SetDParam(0, t->index);
@@ -1730,13 +1722,15 @@
AutoPtrT<Station> st_auto_delete;
if (st != NULL) {
- if (st->owner != _current_player)
+ if (st->owner != _current_player) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
+ }
if (!st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TEST)) return CMD_ERROR;
- if (st->airport_tile != 0)
+ if (st->airport_tile != 0) {
return_cmd_error(STR_300D_TOO_CLOSE_TO_ANOTHER_AIRPORT);
+ }
} else {
airport_upgrade = false;
@@ -1851,7 +1845,9 @@
static CommandCost RemoveAirport(Station *st, uint32 flags)
{
- if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR;
+ if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) {
+ return CMD_ERROR;
+ }
TileIndex tile = st->airport_tile;
byte layout_set = st->FSMport_layout_set;
@@ -1862,7 +1858,7 @@
CommandCost cost(EXPENSES_CONSTRUCTION, w * h * _price.remove_airport);
- Vehicle *v;
+ const Vehicle *v;
FOR_ALL_VEHICLES(v) {
if (!(v->type == VEH_AIRCRAFT && IsNormalAircraft(v))) continue;
@@ -1989,7 +1985,7 @@
static CommandCost RemoveBuoy(Station *st, uint32 flags)
{
/* XXX: strange stuff */
- if (!IsValidPlayer(_current_player)) return_cmd_error(INVALID_STRING_ID);
+ if (!IsValidPlayer(_current_player)) return_cmd_error(INVALID_STRING_ID);
TileIndex tile = st->dock_tile;
@@ -2036,8 +2032,6 @@
*/
CommandCost CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
- CommandCost cost;
-
DiagDirection direction = GetInclinedSlopeDirection(GetTileSlope(tile, NULL));
if (direction == INVALID_DIAGDIR) return_cmd_error(STR_304B_SITE_UNSUITABLE);
direction = ReverseDiagDir(direction);
@@ -2049,8 +2043,7 @@
if (MayHaveBridgeAbove(tile) && IsBridgeAbove(tile)) return_cmd_error(STR_5007_MUST_DEMOLISH_BRIDGE_FIRST);
- cost = DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- if (CmdFailed(cost)) return CMD_ERROR;
+ if (CmdFailed(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR))) return CMD_ERROR;
TileIndex tile_cur = tile + TileOffsByDiagDir(direction);
@@ -2063,8 +2056,7 @@
/* Get the water class of the water tile before it is cleared.*/
WaterClass wc = GetWaterClass(tile_cur);
- cost = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
- if (CmdFailed(cost)) return CMD_ERROR;
+ if (CmdFailed(DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR))) return CMD_ERROR;
tile_cur += TileOffsByDiagDir(direction);
if (!IsTileType(tile_cur, MP_WATER) || GetTileSlope(tile_cur, NULL) != SLOPE_FLAT) {
@@ -2089,8 +2081,9 @@
AutoPtrT<Station> st_auto_delete;
if (st != NULL) {
- if (st->owner != _current_player)
+ if (st->owner != _current_player) {
return_cmd_error(STR_3009_TOO_CLOSE_TO_ANOTHER_STATION);
+ }
if (!st->rect.BeforeAddRect(tile, _dock_w_chk[direction], _dock_h_chk[direction], StationRect::ADD_TEST)) return CMD_ERROR;
@@ -2130,6 +2123,7 @@
/* success, so don't delete the new station */
st_auto_delete.Detach();
}
+
return CommandCost(EXPENSES_CONSTRUCTION, _price.build_dock);
}
@@ -2217,8 +2211,6 @@
statspec = st->speclist[specindex].spec;
}
- //debug("Cust-o-mized %p", statspec);
-
if (statspec != NULL) {
uint tile = GetStationGfx(ti->tile);
@@ -2600,7 +2592,11 @@
}
-static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; }
+static inline void byte_inc_sat(byte *p)
+{
+ byte b = *p + 1;
+ if (b != 0) *p = b;
+}
static void UpdateStationRating(Station *st)
{
@@ -2626,7 +2622,7 @@
{
int b = ge->last_speed;
- if ((b-=85) >= 0)
+ if ((b -= 85) >= 0)
rating += b >> 2;
}
@@ -2738,6 +2734,7 @@
void StationMonthlyLoop()
{
+ /* not used */
}
@@ -2749,7 +2746,7 @@
if (st->owner == owner &&
DistanceManhattan(tile, st->xy) <= radius) {
for (CargoID i = 0; i < NUM_CARGO; i++) {
- GoodsEntry* ge = &st->goods[i];
+ GoodsEntry *ge = &st->goods[i];
if (ge->acceptance_pickup != 0) {
ge->rating = Clamp(ge->rating + amount, 0, 255);
@@ -2810,14 +2807,14 @@
}
/**
-* Find all (non-buoy) stations around an industry tile
-*
-* @param tile: Center tile to search from
-* @param w: Width of the center
-* @param h: Height of the center
-*
-* @return: Set of found stations
-*/
+ * Find all (non-buoy) stations around an industry tile
+ *
+ * @param tile: Center tile to search from
+ * @param w: Width of the center
+ * @param h: Height of the center
+ *
+ * @return: Set of found stations
+ */
StationSet FindStationsAroundIndustryTile(TileIndex tile, int w, int h)
{
StationSet station_set;
@@ -2888,10 +2885,10 @@
uint MoveGoodsToStation(TileIndex tile, int w, int h, CargoID type, uint amount)
{
- Station *st1 = NULL; // Station with best rating
- Station *st2 = NULL; // Second best station
- uint best_rating1 = 0; // rating of st1
- uint best_rating2 = 0; // rating of st2
+ Station *st1 = NULL; // Station with best rating
+ Station *st2 = NULL; // Second best station
+ uint best_rating1 = 0; // rating of st1
+ uint best_rating2 = 0; // rating of st2
StationSet all_stations = FindStationsAroundIndustryTile(tile, w, h);
for (StationSet::iterator st_iter = all_stations.begin(); st_iter != all_stations.end(); ++st_iter) {
@@ -3010,7 +3007,7 @@
void DeleteOilRig(TileIndex tile)
{
- Station* st = GetStationByTile(tile);
+ Station *st = GetStationByTile(tile);
MakeWater(tile);
@@ -3027,7 +3024,7 @@
if (!IsTileOwner(tile, old_player)) return;
if (new_player != PLAYER_SPECTATOR) {
- Station* st = GetStationByTile(tile);
+ Station *st = GetStationByTile(tile);
SetTileOwner(tile, new_player);
if (!IsBuoy(tile)) st->owner = new_player; // do not set st->owner for buoys
@@ -3115,7 +3112,6 @@
_RoadStop_pool.AddBlockToPool();
_station_tick_ctr = 0;
-
/* Check whether our &fsmblocks == &fsmblocks.blocks "hack" works */
FSMblockmap::AssertOnWrongBlockOffset();
}
@@ -3196,15 +3192,15 @@
};
static const SaveLoad _roadstop_desc[] = {
- SLE_VAR(RoadStop,xy, SLE_UINT32),
+ SLE_VAR(RoadStop, xy, SLE_UINT32),
SLE_CONDNULL(1, 0, 44),
- SLE_VAR(RoadStop,status, SLE_UINT8),
+ SLE_VAR(RoadStop, status, SLE_UINT8),
/* Index was saved in some versions, but this is not needed */
SLE_CONDNULL(4, 0, 8),
SLE_CONDNULL(2, 0, 44),
SLE_CONDNULL(1, 0, 25),
- SLE_REF(RoadStop,next, REF_ROADSTOPS),
+ SLE_REF(RoadStop, next, REF_ROADSTOPS),
SLE_CONDNULL(2, 0, 44),
SLE_CONDNULL(4, 0, 24),
@@ -3216,7 +3212,7 @@
static const SaveLoad _station_desc[] = {
SLE_CONDVAR(Station, xy, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Station, xy, SLE_UINT32, 6, SL_MAX_VERSION),
- SLE_CONDNULL(4, 0, 5), // bus/lorry tile
+ SLE_CONDNULL(4, 0, 5), ///< bus/lorry tile
SLE_CONDVAR(Station, train_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
SLE_CONDVAR(Station, train_tile, SLE_UINT32, 6, SL_MAX_VERSION),
SLE_CONDVAR(Station, airport_tile, SLE_FILE_U16 | SLE_VAR_U32, 0, 5),
@@ -3227,8 +3223,7 @@
SLE_VAR(Station, trainst_w, SLE_UINT8),
SLE_CONDVAR(Station, trainst_h, SLE_UINT8, 2, SL_MAX_VERSION),
- /* alpha_order was stored here in savegame format 0 - 3 */
- SLE_CONDNULL(1, 0, 3),
+ SLE_CONDNULL(1, 0, 3), ///< alpha_order
SLE_VAR(Station, string_id, SLE_STRINGID),
SLE_CONDSTR(Station, name, SLE_STR, 0, 84, SL_MAX_VERSION),
@@ -3241,19 +3236,18 @@
SLE_VAR(Station, facilities, SLE_UINT8),
SLE_VAR(Station, airport_type, SLE_UINT8),
- SLE_CONDNULL(2, 0, 5), // Truck/bus stop status
- SLE_CONDNULL(1, 0, 4), // Blocked months
+ SLE_CONDNULL(2, 0, 5), ///< Truck/bus stop status
+ SLE_CONDNULL(1, 0, 4), ///< Blocked months
SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U16, 0, 2),
SLE_CONDVAR(Station, airport_flags, SLE_VAR_U64 | SLE_FILE_U32, 3, 45),
SLE_CONDVAR(Station, airport_flags, SLE_UINT64, 46, NEWGRF_AIRPORTS_SAVEGAME - 1),
SLE_CONDARR(Station, airport_flags, SLE_UINT64, 2, NEWGRF_AIRPORTS_SAVEGAME, SL_MAX_VERSION),
- SLE_CONDNULL(2, 0, 25), /* Ex last-vehicle */
+ SLE_CONDNULL(2, 0, 25), ///< last-vehicle
SLE_CONDVAR(Station, last_vehicle_type, SLE_UINT8, 26, SL_MAX_VERSION),
- /* Was custom station class and id */
- SLE_CONDNULL(2, 3, 25),
+ SLE_CONDNULL(2, 3, 25), ///< custom station class and id
SLE_CONDVAR(Station, build_date, SLE_FILE_U16 | SLE_VAR_I32, 3, 30),
SLE_CONDVAR(Station, build_date, SLE_INT32, 31, SL_MAX_VERSION),
--- a/src/station_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/station_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -94,15 +94,14 @@
};
static char _bufcache[64];
-static const Station* _last_station;
+static const Station *_last_station;
static int _internal_sort_order;
static int CDECL StationNameSorter(const void *a, const void *b)
{
- const Station* st1 = *(const Station**)a;
- const Station* st2 = *(const Station**)b;
+ const Station *st1 = *(const Station**)a;
+ const Station *st2 = *(const Station**)b;
char buf1[64];
- int r;
SetDParam(0, st1->index);
GetString(buf1, STR_STATION, lastof(buf1));
@@ -113,24 +112,24 @@
GetString(_bufcache, STR_STATION, lastof(_bufcache));
}
- r = strcmp(buf1, _bufcache); // sort by name
+ int r = strcmp(buf1, _bufcache); // sort by name
return (_internal_sort_order & 1) ? -r : r;
}
static int CDECL StationTypeSorter(const void *a, const void *b)
{
- const Station* st1 = *(const Station**)a;
- const Station* st2 = *(const Station**)b;
+ const Station *st1 = *(const Station**)a;
+ const Station *st2 = *(const Station**)b;
return (_internal_sort_order & 1) ? st2->facilities - st1->facilities : st1->facilities - st2->facilities;
}
-static const uint32 _cargo_filter_max = ~0;
+static const uint32 _cargo_filter_max = UINT32_MAX;
static uint32 _cargo_filter = _cargo_filter_max;
static int CDECL StationWaitingSorter(const void *a, const void *b)
{
- const Station* st1 = *(const Station**)a;
- const Station* st2 = *(const Station**)b;
+ const Station *st1 = *(const Station**)a;
+ const Station *st2 = *(const Station**)b;
Money sum1 = 0, sum2 = 0;
for (CargoID j = 0; j < NUM_CARGO; j++) {
@@ -152,8 +151,8 @@
*/
static int CDECL StationRatingMaxSorter(const void *a, const void *b)
{
- const Station* st1 = *(const Station**)a;
- const Station* st2 = *(const Station**)b;
+ const Station *st1 = *(const Station**)a;
+ const Station *st2 = *(const Station**)b;
byte maxr1 = 0;
byte maxr2 = 0;
@@ -176,7 +175,7 @@
/** Information about station list */
struct plstations_d {
- const Station** sort_list; ///< Pointer to list of stations
+ const Station **sort_list; ///< Pointer to list of stations
uint16 list_length; ///< Number of stations in list
uint16 resort_timer; ///< Tick counter to resort the list
byte sort_type; ///< Sort type - name, waiting, ...
@@ -189,7 +188,7 @@
*/
void RebuildStationLists()
{
- Window* const *wz;
+ Window *const *wz;
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
@@ -205,7 +204,7 @@
*/
void ResortStationLists()
{
- Window* const *wz;
+ Window *const *wz;
FOR_ALL_WINDOWS(wz) {
Window *w = *wz;
@@ -225,7 +224,7 @@
* @param cargo_filter bitmap of cargo types to include
* @param include_empty whether we should include stations without waiting cargo
*/
-static void BuildStationsList(plstations_d* sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty)
+static void BuildStationsList(plstations_d *sl, PlayerID owner, byte facilities, uint32 cargo_filter, bool include_empty)
{
uint n = 0;
const Station *st;
@@ -233,7 +232,7 @@
if (!(sl->flags & SL_REBUILD)) return;
/* Create array for sorting */
- const Station** station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
+ const Station **station_sort = MallocT<const Station*>(GetMaxStationIndex() + 1);
DEBUG(misc, 3, "Building station list for player %d", owner);
@@ -277,7 +276,7 @@
*/
static void SortStationsList(plstations_d *sl)
{
- static StationSortListingTypeFunction* const _station_sorter[] = {
+ static StationSortListingTypeFunction *const _station_sorter[] = {
&StationNameSorter,
&StationTypeSorter,
&StationWaitingSorter,
@@ -749,10 +748,7 @@
static void DrawStationViewWindow(Window *w)
{
StationID station_id = w->window_number;
- const Station* st = GetStation(station_id);
- int x, y; ///< coordinates used for printing waiting/accepted/rating of cargo
- int pos; ///< = w->vscroll.pos
- StringID str;
+ const Station *st = GetStation(station_id);
CargoDataList cargolist;
uint32 transfers = 0;
@@ -808,13 +804,15 @@
SetDParam(1, st->facilities);
DrawWindowWidgets(w);
- x = 2;
- y = 15;
- pos = w->vscroll.pos;
+ int x = 2; ///< coordinates used for printing waiting/accepted/rating of cargo
+ int y = 15;
+ int pos = w->vscroll.pos; ///< = w->vscroll.pos
uint width = w->widget[SVW_WAITING].right - w->widget[SVW_WAITING].left - 4;
int maxrows = w->vscroll.cap;
+ StringID str;
+
if (--pos < 0) {
str = STR_00D0_NOTHING;
for (CargoID i = 0; i < NUM_CARGO; i++) {
--- a/src/station_map.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/station_map.h Fri Apr 18 19:55:13 2008 +0000
@@ -68,6 +68,18 @@
_m[t].m5 = gfx;
}
+static inline uint8 GetStationAnimationFrame(TileIndex t)
+{
+ assert(IsTileType(t, MP_STATION));
+ return _me[t].m7;
+}
+
+static inline void SetStationAnimationFrame(TileIndex t, uint8 frame)
+{
+ assert(IsTileType(t, MP_STATION));
+ _me[t].m7 = frame;
+}
+
static inline bool IsRailwayStation(TileIndex t)
{
return GetStationType(t) == STATION_RAIL;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/statusbar_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -0,0 +1,170 @@
+/* $Id$ */
+
+/** @file main_gui.cpp */
+
+#include "stdafx.h"
+#include "openttd.h"
+#include "settings_type.h"
+#include "date_func.h"
+#include "gfx_func.h"
+#include "news_func.h"
+#include "player_func.h"
+#include "string_func.h"
+#include "strings_func.h"
+#include "player_base.h"
+#include "viewport_func.h"
+#include "news_gui.h"
+#include "player_gui.h"
+#include "window_gui.h"
+#include "variables.h"
+
+#include "table/strings.h"
+#include "table/sprites.h"
+
+extern GetNewsStringCallbackProc * const _get_news_string_callback[];
+
+static bool DrawScrollingStatusText(const NewsItem *ni, int pos, int width)
+{
+ StringID str;
+ if (ni->display_mode == NM_CALLBACK) {
+ str = _get_news_string_callback[ni->callback](ni);
+ } else {
+ CopyInDParam(0, ni->params, lengthof(ni->params));
+ str = ni->string_id;
+ }
+
+ char buf[512];
+ GetString(buf, str, lastof(buf));
+ const char *s = buf;
+
+ char buffer[256];
+ char *d = buffer;
+ const char *last = lastof(buffer);
+
+ for (;;) {
+ WChar c = Utf8Consume(&s);
+ if (c == 0) {
+ break;
+ } else if (c == 0x0D) {
+ if (d + 4 >= last) break;
+ d[0] = d[1] = d[2] = d[3] = ' ';
+ d += 4;
+ } else if (IsPrintable(c)) {
+ if (d + Utf8CharLen(c) >= last) break;
+ d += Utf8Encode(d, c);
+ }
+ }
+ *d = '\0';
+
+ DrawPixelInfo tmp_dpi;
+ if (!FillDrawPixelInfo(&tmp_dpi, 141, 1, width, 11)) return true;
+
+ DrawPixelInfo *old_dpi = _cur_dpi;
+ _cur_dpi = &tmp_dpi;
+
+ int x = DoDrawString(buffer, pos, 0, TC_LIGHT_BLUE);
+ _cur_dpi = old_dpi;
+
+ return x > 0;
+}
+
+static void StatusBarWndProc(Window *w, WindowEvent *e)
+{
+ switch (e->event) {
+ case WE_PAINT: {
+ const Player *p = (_local_player == PLAYER_SPECTATOR) ? NULL : GetPlayer(_local_player);
+
+ DrawWindowWidgets(w);
+ SetDParam(0, _date);
+ DrawStringCentered(70, 1, (_pause_game || _patches.status_long_date) ? STR_00AF : STR_00AE, TC_FROMSTRING);
+
+ if (p != NULL) {
+ /* Draw player money */
+ SetDParam(0, p->player_money);
+ DrawStringCentered(w->widget[2].left + 70, 1, STR_0004, TC_FROMSTRING);
+ }
+
+ /* Draw status bar */
+ if (w->message.msg) { // true when saving is active
+ DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_SAVING_GAME, TC_FROMSTRING);
+ } else if (_do_autosave) {
+ DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_032F_AUTOSAVE, TC_FROMSTRING);
+ } else if (_pause_game) {
+ DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_0319_PAUSED, TC_FROMSTRING);
+ } else if (WP(w, def_d).data_1 > -1280 && FindWindowById(WC_NEWS_WINDOW,0) == NULL && _statusbar_news_item.string_id != 0) {
+ /* Draw the scrolling news text */
+ if (!DrawScrollingStatusText(&_statusbar_news_item, WP(w, def_d).data_1, w->widget[1].right - w->widget[1].left - 2)) {
+ WP(w, def_d).data_1 = -1280;
+ if (p != NULL) {
+ /* This is the default text */
+ SetDParam(0, p->index);
+ DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
+ }
+ }
+ } else {
+ if (p != NULL) {
+ /* This is the default text */
+ SetDParam(0, p->index);
+ DrawStringCenteredTruncated(w->widget[1].left + 1, w->widget[1].right - 1, 1, STR_02BA, TC_FROMSTRING);
+ }
+ }
+
+ if (WP(w, def_d).data_2 > 0) DrawSprite(SPR_BLOT, PALETTE_TO_RED, w->widget[1].right - 11, 2);
+ } break;
+
+ case WE_MESSAGE:
+ w->message.msg = e->we.message.msg;
+ SetWindowDirty(w);
+ break;
+
+ case WE_CLICK:
+ switch (e->we.click.widget) {
+ case 1: ShowLastNewsMessage(); break;
+ case 2: if (_local_player != PLAYER_SPECTATOR) ShowPlayerFinances(_local_player); break;
+ default: ResetObjectToPlace();
+ }
+ break;
+
+ case WE_TICK: {
+ if (_pause_game) return;
+
+ if (WP(w, def_d).data_1 > -1280) { // Scrolling text
+ WP(w, def_d).data_1 -= 2;
+ w->InvalidateWidget(1);
+ }
+
+ if (WP(w, def_d).data_2 > 0) { // Red blot to show there are new unread newsmessages
+ WP(w, def_d).data_2 -= 2;
+ } else if (WP(w, def_d).data_2 < 0) {
+ WP(w, def_d).data_2 = 0;
+ w->InvalidateWidget(1);
+ }
+
+ } break;
+ }
+}
+
+static const Widget _main_status_widgets[] = {
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 139, 0, 11, 0x0, STR_NULL},
+{ WWT_PUSHBTN, RESIZE_RIGHT, 14, 140, 179, 0, 11, 0x0, STR_02B7_SHOW_LAST_MESSAGE_OR_NEWS},
+{ WWT_PUSHBTN, RESIZE_LR, 14, 180, 319, 0, 11, 0x0, STR_NULL},
+{ WIDGETS_END},
+};
+
+static WindowDesc _main_status_desc = {
+ WDP_CENTER, 0, 320, 12, 640, 12,
+ WC_STATUS_BAR, WC_NONE,
+ WDF_STD_TOOLTIPS | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
+ _main_status_widgets,
+ StatusBarWndProc
+};
+
+void ShowStatusBar()
+{
+ _main_status_desc.top = _screen.height - 12;
+ Window *w = AllocateWindowDesc(&_main_status_desc);
+ if (w != NULL) {
+ CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
+ WP(w, def_d).data_1 = -1280;
+ }
+}
--- a/src/stdafx.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/stdafx.h Fri Apr 18 19:55:13 2008 +0000
@@ -296,9 +296,9 @@
#define endof(x) (&x[lengthof(x)])
#define lastof(x) (&x[lengthof(x) - 1])
-#define cpp_offsetof(s,m) (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
+#define cpp_offsetof(s, m) (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
#if !defined(offsetof)
- #define offsetof(s,m) cpp_offsetof(s, m)
+ #define offsetof(s, m) cpp_offsetof(s, m)
#endif /* offsetof */
--- a/src/strgen/strgen.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/strgen/strgen.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -777,7 +777,7 @@
static void HandleString(char *str, bool master)
{
- char *s,*t;
+ char *s, *t;
LangString *ent;
char *casep;
--- a/src/strings.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/strings.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -1195,7 +1195,7 @@
}
/* town name? */
- if (IsInsideMM(ind - 6, 0, SPECSTR_TOWNNAME_LAST-SPECSTR_TOWNNAME_START + 1)) {
+ if (IsInsideMM(ind - 6, 0, SPECSTR_TOWNNAME_LAST - SPECSTR_TOWNNAME_START + 1)) {
buff = GetSpecialTownNameString(buff, ind - 6, GetInt32(&argv), last);
return strecpy(buff, " Transport", last);
}
--- a/src/table/build_industry.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/table/build_industry.h Fri Apr 18 19:55:13 2008 +0000
@@ -1176,7 +1176,7 @@
#define MI(tbl, sndc, snd, d, pc, 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), min(255, d), 0, d, pc, {c1, c2, c3}, proc, {p1, p2}, {r1, r2}, m, \
- {a1, a2, a3}, {{im1, 0}, {im2, 0}, {im3, 0}}, pr, clim, bev, col, GRFMappedStringID(in, 0), GRFMappedStringID(intx, 0), GRFMappedStringID(s1, 0), GRFMappedStringID(s2, 0), GRFMappedStringID(s3, 0), GRFMappedStringID(STR_UNDEFINED, 0), {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
+ {a1, a2, a3}, {{im1, 0}, {im2, 0}, {im3, 0}}, pr, clim, bev, col, in, intx, s1, s2, s3, STR_UNDEFINED, {ai1, ai2, ai3, ai4}, {ag1, ag2, ag3, ag4}, \
sndc, snd, 0, 0, true, {INVALID_INDUSTRYTYPE, 0, NULL, NULL, INVALID_INDUSTRYTYPE}}
/* Format:
tile table count and sounds table
--- a/src/table/cargo_const.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/table/cargo_const.h Fri Apr 18 19:55:13 2008 +0000
@@ -3,7 +3,7 @@
/* Table of all default cargo types */
#define MK(bt, label, c, e, f, g, h, fr, te, ks1, ks2, ks3, ks4, ks5, l, m) \
- {bt, label, 0, c, c, e, f, {g, h}, fr, te, 0, 0, GRFMappedStringID(ks1, 0), GRFMappedStringID(ks2, 0), GRFMappedStringID(ks3, 0), GRFMappedStringID(ks4, 0), GRFMappedStringID(ks5, 0), l, m, NULL}
+ {bt, label, 0, c, c, e, f, {g, h}, fr, te, 0, 0, ks1, ks2, ks3, ks4, ks5, l, m, NULL}
static const CargoSpec _default_cargo[] = {
MK( 0, 'PASS', 152, 1, 3185, 0, 24, false, TE_PASSENGERS,
STR_000F_PASSENGERS, STR_002F_PASSENGER, STR_PASSENGERS, STR_QUANTITY_PASSENGERS, STR_ABBREV_PASSENGERS,
--- a/src/table/town_land.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/table/town_land.h Fri Apr 18 19:55:13 2008 +0000
@@ -1803,7 +1803,7 @@
* @see HouseSpec
*/
#define MS(mnd, mxd, p, rc, bn, rr, mg, ca1, ca2, ca3, bf, ba, cg1, cg2, cg3) \
- {mnd, mxd, p, rc, GRFMappedStringID(bn, 0), rr, mg, {ca1, ca2, ca3}, {cg1, cg2, cg3}, bf, ba, true, \
+ {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, 0, NULL}
/** House specifications from original data */
static const HouseSpec _original_house_specs[] = {
--- a/src/timetable_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/timetable_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -160,15 +160,15 @@
if (!_patches.timetabling) return;
/* Make sure the timetable only starts when the vehicle reaches the first
- * order, not when travelling from the depot to the first station. */
- if (v->cur_order_index == 0 && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) {
- SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
- return;
- }
+ * order, not when travelling from the depot to the first station. */
+ if (v->cur_order_index == 0 && !HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) {
+ SetBit(v->vehicle_flags, VF_TIMETABLE_STARTED);
+ return;
+ }
if (!HasBit(v->vehicle_flags, VF_TIMETABLE_STARTED)) return;
- if (HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) {
+ if (HasBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE)) {
if (timetabled == 0) {
/* Round the time taken up to the nearest day, as this will avoid
* confusion for people who are timetabling in days, and can be
@@ -182,7 +182,7 @@
* assume that autofill is finished and turn it off again. */
ClrBit(v->vehicle_flags, VF_AUTOFILL_TIMETABLE);
}
- }
+ }
/* Vehicles will wait at stations if they arrive early even if they are not
* timetabled to wait there, so make sure the lateness counter is updated
--- a/src/timetable_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/timetable_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -10,7 +10,6 @@
#include "window_gui.h"
#include "textbuf_gui.h"
#include "cargotype.h"
-#include "depot.h"
#include "strings_func.h"
#include "vehicle_base.h"
#include "string_func.h"
--- a/src/toolbar_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/toolbar_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -28,24 +28,46 @@
#include "toolbar_gui.h"
#include "vehicle_base.h"
#include "gfx_func.h"
+#include "cheat_func.h"
+#include "transparency_gui.h"
+#include "screenshot.h"
+#include "newgrf_config.h"
+#include "signs_func.h"
+#include "fios.h"
+#include "functions.h"
+#include "console.h"
+#include "news_gui.h"
#include "network/network.h"
+#include "network/network_gui.h"
#include "table/strings.h"
#include "table/sprites.h"
-extern void SelectSignTool();
-extern RailType _last_built_railtype;
-extern RoadType _last_built_roadtype;
+static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask);
+static Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray);
-/* Returns the position where the toolbar wants the menu to appear.
+RailType _last_built_railtype;
+RoadType _last_built_roadtype;
+
+static void SelectSignTool()
+{
+ if (_cursor.sprite == SPR_CURSOR_SIGN) {
+ ResetObjectToPlace();
+ } else {
+ SetObjectToPlace(SPR_CURSOR_SIGN, PAL_NONE, VHM_RECT, WC_MAIN_TOOLBAR, 0);
+ _place_proc = PlaceProc_Sign;
+ }
+}
+
+/** Returns the position where the toolbar wants the menu to appear.
* Make sure the dropdown is fully visible within the window.
* x + w->left because x is supposed to be the offset of the toolbar-button
* we clicked on and w->left the toolbar window itself. So meaning that
* the default position is aligned with the left side of the clicked button */
-Point GetToolbarDropdownPos(uint16 parent_button, int width, int height)
+static Point GetToolbarDropdownPos(uint16 parent_button, int width, int height)
{
- const Window *w = FindWindowById(WC_MAIN_TOOLBAR,0);
+ const Window *w = FindWindowById(WC_MAIN_TOOLBAR, 0);
Point pos;
pos.x = w->widget[GB(parent_button, 0, 8)].left;
pos.x = w->left + Clamp(pos.x, 0, w->width - width);
@@ -54,6 +76,7 @@
return pos;
}
+/* --- Pausing --- */
static void ToolbarPauseClick(Window *w)
{
@@ -62,168 +85,15 @@
if (DoCommandP(0, _pause_game ? 0 : 1, 0, NULL, CMD_PAUSE)) SndPlayFx(SND_15_BEEP);
}
+/* --- Fast forwarding --- */
+
static void ToolbarFastForwardClick(Window *w)
{
_fast_forward ^= true;
SndPlayFx(SND_15_BEEP);
}
-static void ToolbarSaveClick(Window *w)
-{
- PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0);
-}
-
-static void ToolbarMapClick(Window *w)
-{
- PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
-}
-
-static void ToolbarTownClick(Window *w)
-{
- PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0);
-}
-
-static void ToolbarSubsidiesClick(Window *w)
-{
- PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
-}
-
-static void ToolbarStationsClick(Window *w)
-{
- PopupMainPlayerToolbMenu(w, 7, 0);
-}
-
-static void ToolbarMoneyClick(Window *w)
-{
- PopupMainPlayerToolbMenu(w, 8, 0);
-}
-
-static void ToolbarPlayersClick(Window *w)
-{
- PopupMainPlayerToolbMenu(w, 9, 0);
-}
-
-static void ToolbarGraphsClick(Window *w)
-{
- PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0);
-}
-
-static void ToolbarLeagueClick(Window *w)
-{
- PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0);
-}
-
-static void ToolbarIndustryClick(Window *w)
-{
- /* Disable build-industry menu if we are a spectator */
- PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
-}
-
-static void ToolbarTrainClick(Window *w)
-{
- const Vehicle *v;
- int dis = -1;
-
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_TRAIN && IsFrontEngine(v)) ClrBit(dis, v->owner);
- }
- PopupMainPlayerToolbMenu(w, 13, dis);
-}
-
-static void ToolbarRoadClick(Window *w)
-{
- const Vehicle *v;
- int dis = -1;
-
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_ROAD && IsRoadVehFront(v)) ClrBit(dis, v->owner);
- }
- PopupMainPlayerToolbMenu(w, 14, dis);
-}
-
-static void ToolbarShipClick(Window *w)
-{
- const Vehicle *v;
- int dis = -1;
-
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_SHIP) ClrBit(dis, v->owner);
- }
- PopupMainPlayerToolbMenu(w, 15, dis);
-}
-
-static void ToolbarAirClick(Window *w)
-{
- const Vehicle *v;
- int dis = -1;
-
- FOR_ALL_VEHICLES(v) {
- if (v->type == VEH_AIRCRAFT) ClrBit(dis, v->owner);
- }
- PopupMainPlayerToolbMenu(w, 16, dis);
-}
-
-
-static void ToolbarZoomInClick(Window *w)
-{
- if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
- w->HandleButtonClick(17);
- SndPlayFx(SND_15_BEEP);
- }
-}
-
-static void ToolbarZoomOutClick(Window *w)
-{
- if (DoZoomInOutWindow(ZOOM_OUT,FindWindowById(WC_MAIN_WINDOW, 0))) {
- w->HandleButtonClick(18);
- SndPlayFx(SND_15_BEEP);
- }
-}
-
-static void ToolbarBuildRailClick(Window *w)
-{
- const Player *p = GetPlayer(_local_player);
- Window *w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
- WP(w2, menu_d).sel_index = _last_built_railtype;
-}
-
-static void ToolbarBuildRoadClick(Window *w)
-{
- const Player *p = GetPlayer(_local_player);
- /* The standard road button is *always* available */
- Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD));
- WP(w2, menu_d).sel_index = _last_built_roadtype;
-}
-
-static void ToolbarBuildWaterClick(Window *w)
-{
- PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0);
-}
-
-static void ToolbarBuildAirClick(Window *w)
-{
- PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0);
-}
-
-static void ToolbarForestClick(Window *w)
-{
- PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
-}
-
-static void ToolbarMusicClick(Window *w)
-{
- PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0);
-}
-
-static void ToolbarNewspaperClick(Window *w)
-{
- PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0);
-}
-
-static void ToolbarHelpClick(Window *w)
-{
- PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0);
-}
+/* --- Options button menu --- */
static void ToolbarOptionsClick(Window *w)
{
@@ -242,12 +112,412 @@
WP(w, menu_d).checked_items = x;
}
+static void MenuClickSettings(int index)
+{
+ switch (index) {
+ case 0: ShowGameOptions(); return;
+ case 1: ShowGameDifficulty(); return;
+ case 2: ShowPatchesSelection(); return;
+ case 3: ShowNewGRFSettings(!_networking, true, true, &_grfconfig); return;
+ case 4: ShowTransparencyToolbar(); break;
+
+ case 6: ToggleBit(_display_opt, DO_SHOW_TOWN_NAMES); break;
+ case 7: ToggleBit(_display_opt, DO_SHOW_STATION_NAMES); break;
+ case 8: ToggleBit(_display_opt, DO_SHOW_SIGNS); break;
+ case 9: ToggleBit(_display_opt, DO_WAYPOINTS); break;
+ case 10: ToggleBit(_display_opt, DO_FULL_ANIMATION); break;
+ case 11: ToggleBit(_display_opt, DO_FULL_DETAIL); break;
+ case 12: ToggleTransparency(TO_HOUSES); break;
+ case 13: ToggleTransparency(TO_SIGNS); break;
+ }
+ MarkWholeScreenDirty();
+}
+
+/* --- Saving/loading button menu --- */
+
+static void ToolbarSaveClick(Window *w)
+{
+ PopupMainToolbMenu(w, 3, STR_015C_SAVE_GAME, 4, 0);
+}
static void ToolbarScenSaveOrLoad(Window *w)
{
PopupMainToolbMenu(w, 3, STR_0292_SAVE_SCENARIO, 6, 0);
}
+static void MenuClickSaveLoad(int index)
+{
+ if (_game_mode == GM_EDITOR) {
+ switch (index) {
+ case 0: ShowSaveLoadDialog(SLD_SAVE_SCENARIO); break;
+ case 1: ShowSaveLoadDialog(SLD_LOAD_SCENARIO); break;
+ case 2: ShowSaveLoadDialog(SLD_LOAD_HEIGHTMAP); break;
+ case 3: AskExitToGameMenu(); break;
+ case 5: HandleExitGameRequest(); break;
+ }
+ } else {
+ switch (index) {
+ case 0: ShowSaveLoadDialog(SLD_SAVE_GAME); break;
+ case 1: ShowSaveLoadDialog(SLD_LOAD_GAME); break;
+ case 2: AskExitToGameMenu(); break;
+ case 3: HandleExitGameRequest(); break;
+ }
+ }
+}
+
+/* --- Map button menu --- */
+
+static void ToolbarMapClick(Window *w)
+{
+ PopupMainToolbMenu(w, 4, STR_02DE_MAP_OF_WORLD, 3, 0);
+}
+
+static void MenuClickMap(int index)
+{
+ switch (index) {
+ case 0: ShowSmallMap(); break;
+ case 1: ShowExtraViewPortWindow(); break;
+ case 2: ShowSignList(); break;
+ }
+}
+
+static void MenuClickScenMap(int index)
+{
+ switch (index) {
+ case 0: ShowSmallMap(); break;
+ case 1: ShowExtraViewPortWindow(); break;
+ case 2: ShowSignList(); break;
+ case 3: ShowTownDirectory(); break;
+ }
+}
+
+/* --- Town button menu --- */
+
+static void ToolbarTownClick(Window *w)
+{
+ PopupMainToolbMenu(w, 5, STR_02BB_TOWN_DIRECTORY, 1, 0);
+}
+
+static void MenuClickTown(int index)
+{
+ ShowTownDirectory();
+}
+
+/* --- Subidies button menu --- */
+
+static void ToolbarSubsidiesClick(Window *w)
+{
+ PopupMainToolbMenu(w, 6, STR_02DD_SUBSIDIES, 1, 0);
+}
+
+static void MenuClickSubsidies(int index)
+{
+ ShowSubsidiesList();
+}
+
+/* --- Stations button menu --- */
+
+static void ToolbarStationsClick(Window *w)
+{
+ PopupMainPlayerToolbMenu(w, 7, 0);
+}
+
+static void MenuClickStations(int index)
+{
+ ShowPlayerStations((PlayerID)index);
+}
+
+/* --- Finances button menu --- */
+
+static void ToolbarFinancesClick(Window *w)
+{
+ PopupMainPlayerToolbMenu(w, 8, 0);
+}
+
+static void MenuClickFinances(int index)
+{
+ ShowPlayerFinances((PlayerID)index);
+}
+
+/* --- Company's button menu --- */
+
+static void ToolbarPlayersClick(Window *w)
+{
+ PopupMainPlayerToolbMenu(w, 9, 0);
+}
+
+static void MenuClickCompany(int index)
+{
+ if (_networking && index == 0) {
+ ShowClientList();
+ } else {
+ if (_networking) index--;
+ ShowPlayerCompany((PlayerID)index);
+ }
+}
+
+/* --- Graphs button menu --- */
+
+static void ToolbarGraphsClick(Window *w)
+{
+ PopupMainToolbMenu(w, 10, STR_0154_OPERATING_PROFIT_GRAPH, 6, 0);
+}
+
+static void MenuClickGraphs(int index)
+{
+ switch (index) {
+ case 0: ShowOperatingProfitGraph(); break;
+ case 1: ShowIncomeGraph(); break;
+ case 2: ShowDeliveredCargoGraph(); break;
+ case 3: ShowPerformanceHistoryGraph(); break;
+ case 4: ShowCompanyValueGraph(); break;
+ case 5: ShowCargoPaymentRates(); break;
+ }
+}
+
+/* --- League button menu --- */
+
+static void ToolbarLeagueClick(Window *w)
+{
+ PopupMainToolbMenu(w, 11, STR_015A_COMPANY_LEAGUE_TABLE, 2, 0);
+}
+
+static void MenuClickLeague(int index)
+{
+ switch (index) {
+ case 0: ShowCompanyLeagueTable(); break;
+ case 1: ShowPerformanceRatingDetail(); break;
+ }
+}
+
+/* --- Industries button menu --- */
+
+static void ToolbarIndustryClick(Window *w)
+{
+ /* Disable build-industry menu if we are a spectator */
+ PopupMainToolbMenu(w, 12, STR_INDUSTRY_DIR, 2, (_current_player == PLAYER_SPECTATOR) ? (1 << 1) : 0);
+}
+
+static void MenuClickIndustry(int index)
+{
+ switch (index) {
+ case 0: ShowIndustryDirectory(); break;
+ case 1: ShowBuildIndustryWindow(); break;
+ }
+}
+
+/* --- Trains button menu + 1 helper function for all vehicles. --- */
+
+static void ToolbarVehicleClick(Window *w, VehicleType veh)
+{
+ const Vehicle *v;
+ int dis = ~0;
+
+ FOR_ALL_VEHICLES(v) {
+ if (v->type == veh && v->IsPrimaryVehicle()) {
+ ClrBit(dis, v->owner);
+ break;
+ }
+ }
+ PopupMainPlayerToolbMenu(w, 13 + veh, dis);
+}
+
+
+static void ToolbarTrainClick(Window *w)
+{
+ ToolbarVehicleClick(w, VEH_TRAIN);
+}
+
+static void MenuClickShowTrains(int index)
+{
+ ShowVehicleListWindow((PlayerID)index, VEH_TRAIN);
+}
+
+/* --- Road vehicle button menu --- */
+
+static void ToolbarRoadClick(Window *w)
+{
+ ToolbarVehicleClick(w, VEH_ROAD);
+}
+
+static void MenuClickShowRoad(int index)
+{
+ ShowVehicleListWindow((PlayerID)index, VEH_ROAD);
+}
+
+/* --- Ship button menu --- */
+
+static void ToolbarShipClick(Window *w)
+{
+ ToolbarVehicleClick(w, VEH_SHIP);
+}
+
+static void MenuClickShowShips(int index)
+{
+ ShowVehicleListWindow((PlayerID)index, VEH_SHIP);
+}
+
+/* --- Aircraft button menu --- */
+
+static void ToolbarAirClick(Window *w)
+{
+ ToolbarVehicleClick(w, VEH_AIRCRAFT);
+}
+
+static void MenuClickShowAir(int index)
+{
+ ShowVehicleListWindow((PlayerID)index, VEH_AIRCRAFT);
+}
+
+/* --- Zoom in button --- */
+
+static void ToolbarZoomInClick(Window *w)
+{
+ if (DoZoomInOutWindow(ZOOM_IN, FindWindowById(WC_MAIN_WINDOW, 0))) {
+ w->HandleButtonClick(17);
+ SndPlayFx(SND_15_BEEP);
+ }
+}
+
+/* --- Zoom out button --- */
+
+static void ToolbarZoomOutClick(Window *w)
+{
+ if (DoZoomInOutWindow(ZOOM_OUT, FindWindowById(WC_MAIN_WINDOW, 0))) {
+ w->HandleButtonClick(18);
+ SndPlayFx(SND_15_BEEP);
+ }
+}
+
+/* --- Rail button menu --- */
+
+static void ToolbarBuildRailClick(Window *w)
+{
+ const Player *p = GetPlayer(_local_player);
+ Window *w2 = PopupMainToolbMenu(w, 19, STR_1015_RAILROAD_CONSTRUCTION, RAILTYPE_END, ~p->avail_railtypes);
+ WP(w2, menu_d).sel_index = _last_built_railtype;
+}
+
+static void MenuClickBuildRail(int index)
+{
+ _last_built_railtype = (RailType)index;
+ ShowBuildRailToolbar(_last_built_railtype, -1);
+}
+
+/* --- Road button menu --- */
+
+static void ToolbarBuildRoadClick(Window *w)
+{
+ const Player *p = GetPlayer(_local_player);
+ /* The standard road button is *always* available */
+ Window *w2 = PopupMainToolbMenu(w, 20, STR_180A_ROAD_CONSTRUCTION, 2, ~(p->avail_roadtypes | ROADTYPES_ROAD));
+ WP(w2, menu_d).sel_index = _last_built_roadtype;
+}
+
+static void MenuClickBuildRoad(int index)
+{
+ _last_built_roadtype = (RoadType)index;
+ ShowBuildRoadToolbar(_last_built_roadtype);
+}
+
+/* --- Water button menu --- */
+
+static void ToolbarBuildWaterClick(Window *w)
+{
+ PopupMainToolbMenu(w, 21, STR_9800_DOCK_CONSTRUCTION, 1, 0);
+}
+
+static void MenuClickBuildWater(int index)
+{
+ ShowBuildDocksToolbar();
+}
+
+/* --- Airport button menu --- */
+
+static void ToolbarBuildAirClick(Window *w)
+{
+ PopupMainToolbMenu(w, 22, STR_A01D_AIRPORT_CONSTRUCTION, 1, 0);
+}
+
+static void MenuClickBuildAir(int index)
+{
+ ShowBuildAirToolbar();
+}
+
+/* --- Forest button menu --- */
+
+static void ToolbarForestClick(Window *w)
+{
+ PopupMainToolbMenu(w, 23, STR_LANDSCAPING, 3, 0);
+}
+
+static void MenuClickForest(int index)
+{
+ switch (index) {
+ case 0: ShowTerraformToolbar(); break;
+ case 1: ShowBuildTreesToolbar(); break;
+ case 2: SelectSignTool(); break;
+ }
+}
+
+/* --- Music button menu --- */
+
+static void ToolbarMusicClick(Window *w)
+{
+ PopupMainToolbMenu(w, 24, STR_01D3_SOUND_MUSIC, 1, 0);
+}
+
+static void MenuClickMusicWindow(int index)
+{
+ ShowMusicWindow();
+}
+
+/* --- Newspaper button menu --- */
+
+static void ToolbarNewspaperClick(Window *w)
+{
+ PopupMainToolbMenu(w, 25, STR_0200_LAST_MESSAGE_NEWS_REPORT, 3, 0);
+}
+
+static void MenuClickNewspaper(int index)
+{
+ switch (index) {
+ case 0: ShowLastNewsMessage(); break;
+ case 1: ShowMessageOptions(); break;
+ case 2: ShowMessageHistory(); break;
+ }
+}
+
+/* --- Help button menu --- */
+
+static void ToolbarHelpClick(Window *w)
+{
+ PopupMainToolbMenu(w, 26, STR_02D5_LAND_BLOCK_INFO, 6, 0);
+}
+
+static void MenuClickSmallScreenshot()
+{
+ SetScreenshotType(SC_VIEWPORT);
+}
+
+static void MenuClickWorldScreenshot()
+{
+ SetScreenshotType(SC_WORLD);
+}
+
+static void MenuClickHelp(int index)
+{
+ switch (index) {
+ case 0: PlaceLandBlockInfo(); break;
+ case 2: IConsoleSwitch(); break;
+ case 3: MenuClickSmallScreenshot(); break;
+ case 4: MenuClickWorldScreenshot(); break;
+ case 5: ShowAboutWindow(); break;
+ }
+}
+
+/* --- Scenario editor specific handlers. */
+
static void ToolbarScenDateBackward(Window *w)
{
/* don't allow too fast scrolling */
@@ -345,6 +615,8 @@
}
+/* --- Toolbar handling for the 'normal' case */
+
typedef void ToolbarButtonProc(Window *w);
static ToolbarButtonProc * const _toolbar_button_procs[] = {
@@ -356,7 +628,7 @@
ToolbarTownClick,
ToolbarSubsidiesClick,
ToolbarStationsClick,
- ToolbarMoneyClick,
+ ToolbarFinancesClick,
ToolbarPlayersClick,
ToolbarGraphsClick,
ToolbarLeagueClick,
@@ -377,17 +649,13 @@
ToolbarHelpClick,
};
-extern void MenuClickSmallScreenshot();
-extern void MenuClickWorldScreenshot();
-extern void MenuClickSaveLoad(int index);
-
-void MainToolbarWndProc(Window *w, WindowEvent *e)
+static void MainToolbarWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT:
/* Draw brown-red toolbar bg. */
- GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
- GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
+ GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB2);
+ GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
/* If spectator, disable all construction buttons
* ie : Build road, rail, ships, airports and landscaping
@@ -403,8 +671,7 @@
break;
case WE_CLICK:
- if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget))
- _toolbar_button_procs[e->we.click.widget](w);
+ if (_game_mode != GM_MENU && !w->IsWidgetDisabled(e->we.click.widget)) _toolbar_button_procs[e->we.click.widget](w);
break;
case WE_KEYPRESS:
@@ -560,6 +827,8 @@
};
+/* --- Toolbar handling for the scenario editor */
+
static ToolbarButtonProc * const _scen_toolbar_button_procs[] = {
ToolbarPauseClick,
ToolbarFastForwardClick,
@@ -590,7 +859,7 @@
ToolbarHelpClick,
};
-void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
+static void ScenEditToolbarWndProc(Window *w, WindowEvent *e)
{
switch (e->event) {
case WE_PAINT:
@@ -598,8 +867,8 @@
w->SetWidgetDisabledState(7, _patches_newgame.starting_year >= MAX_YEAR);
/* Draw brown-red toolbar bg. */
- GfxFillRect(0, 0, w->width-1, w->height-1, 0xB2);
- GfxFillRect(0, 0, w->width-1, w->height-1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
+ GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB2);
+ GfxFillRect(0, 0, w->width - 1, w->height - 1, 0xB4 | (1 << PALETTE_MODIFIER_GREYOUT));
DrawWindowWidgets(w);
@@ -666,7 +935,7 @@
case WE_RESIZE: {
/* There are 15 buttons plus some spacings if the space allows it.
- * Furthermore there are two panels of which one is non-essential
+ * Furthermore there are two panels of which one is non - essential
* and that one can be removed is the space is too small. */
uint buttons_width;
uint spacing;
@@ -793,7 +1062,375 @@
ScenEditToolbarWndProc
};
+/* --- Rendering/handling the drop down menus --- */
+
+typedef void MenuClickedProc(int index);
+
+static MenuClickedProc * const _menu_clicked_procs[] = {
+ NULL, /* 0 */
+ NULL, /* 1 */
+ MenuClickSettings, /* 2 */
+ MenuClickSaveLoad, /* 3 */
+ MenuClickMap, /* 4 */
+ MenuClickTown, /* 5 */
+ MenuClickSubsidies, /* 6 */
+ MenuClickStations, /* 7 */
+ MenuClickFinances, /* 8 */
+ MenuClickCompany, /* 9 */
+ MenuClickGraphs, /* 10 */
+ MenuClickLeague, /* 11 */
+ MenuClickIndustry, /* 12 */
+ MenuClickShowTrains, /* 13 */
+ MenuClickShowRoad, /* 14 */
+ MenuClickShowShips, /* 15 */
+ MenuClickShowAir, /* 16 */
+ MenuClickScenMap, /* 17 */
+ NULL, /* 18 */
+ MenuClickBuildRail, /* 19 */
+ MenuClickBuildRoad, /* 20 */
+ MenuClickBuildWater, /* 21 */
+ MenuClickBuildAir, /* 22 */
+ MenuClickForest, /* 23 */
+ MenuClickMusicWindow, /* 24 */
+ MenuClickNewspaper, /* 25 */
+ MenuClickHelp, /* 26 */
+};
+
+static void MenuWndProc(Window *w, WindowEvent *e)
+{
+ switch (e->event) {
+ case WE_CREATE:
+ w->widget[0].right = w->width - 1;
+ break;
+
+ case WE_PAINT: {
+ byte count = WP(w, menu_d).item_count;
+ byte sel = WP(w, menu_d).sel_index;
+ uint16 chk = WP(w, menu_d).checked_items;
+ StringID string = WP(w, menu_d).string_id;
+ byte dis = WP(w, menu_d).disabled_items;
+
+ DrawWindowWidgets(w);
+
+ int x = 1;
+ int y = 1;
+
+ for (; count != 0; count--, string++, sel--) {
+ TextColour color = HasBit(dis, 0) ? TC_GREY : (sel == 0) ? TC_WHITE : TC_BLACK;
+ if (sel == 0) GfxFillRect(x, y, x + w->width - 3, y + 9, 0);
+
+ if (HasBit(chk, 0)) DrawString(x + 2, y, STR_CHECKMARK, color);
+ DrawString(x + 2, y, string, color);
+
+ y += 10;
+ chk >>= 1;
+ dis >>= 1;
+ }
+ } break;
+
+ case WE_DESTROY: {
+ Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
+ v->RaiseWidget(WP(w, menu_d).main_button);
+ SetWindowDirty(v);
+ return;
+ }
+
+ case WE_POPUPMENU_SELECT: {
+ int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
+
+ if (index < 0) {
+ Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
+ if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
+ index = WP(w, menu_d).sel_index;
+ }
+
+ int action_id = WP(w, menu_d).action_id;
+ DeleteWindow(w);
+
+ if (index >= 0) {
+ assert((uint)index <= lengthof(_menu_clicked_procs));
+ _menu_clicked_procs[action_id](index);
+ }
+
+ } break;
+
+ case WE_POPUPMENU_OVER: {
+ int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
+
+ if (index == -1 || index == WP(w, menu_d).sel_index) return;
+
+ WP(w, menu_d).sel_index = index;
+ SetWindowDirty(w);
+ return;
+ }
+ }
+}
+
+/* Dynamic widget length determined by toolbar-string length.
+ * See PopupMainToolbMenu en MenuWndProc */
+static const Widget _menu_widgets[] = {
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 0, 0, 0, 0x0, STR_NULL},
+{ WIDGETS_END},
+};
+
+
+/**
+ * Get the maximum length of a given string in a string-list. This is an
+ * implicit string-list where the ID's are consecutive
+ * @param base_string StringID of the first string in the list
+ * @param count amount of StringID's in the list
+ * @return the length of the longest string
+ */
+static int GetStringListMaxWidth(StringID base_string, byte count)
+{
+ char buffer[512];
+ int width, max_width = 0;
+
+ for (byte i = 0; i != count; i++) {
+ GetString(buffer, base_string + i, lastof(buffer));
+ width = GetStringBoundingBox(buffer).width;
+ if (width > max_width) max_width = width;
+ }
+
+ return max_width;
+}
+
+/**
+ * Show a general dropdown menu. The positioning of the dropdown menu
+ * defaults to the left side of the parent_button, eg the button that caused
+ * this window to appear. The only exceptions are when the right side of this
+ * dropdown would fall outside the main toolbar window, in that case it is
+ * aligned with the toolbar's right side.
+ * Since the disable-mask is only 8 bits right now, these dropdowns are
+ * restricted to 8 items max if any bits of disabled_mask are active.
+ * @param w Pointer to a window this dropdown menu belongs to. Has no effect
+ * whatsoever, only graphically for positioning.
+ * @param parent_button The widget identifier of the button that was clicked for
+ * this dropdown. The created dropdown then knows what button to raise (button) on
+ * action and whose function to execute (action).
+ * It is possible to appoint another button for an action event by setting the
+ * upper 8 bits of this parameter. If non is set, action is presumed to be the same
+ * as button. So<br>
+ * button bits 0 - 7 - widget clicked to get dropdown
+ * action bits 8 - 15 - function of widget to execute on select (defaults to bits 0 - 7)
+ * @param base_string The first StringID shown in the dropdown list. All others are
+ * consecutive indeces from the language file. XXX - fix? Use ingame-string tables?
+ * @param item_count Number of strings in the list, see previous parameter
+ * @param disabled_mask Bitmask of disabled strings in the list
+ * @return Return a pointer to the newly created dropdown window */
+static Window *PopupMainToolbMenu(Window *w, uint16 parent_button, StringID base_string, byte item_count, byte disabled_mask)
+{
+ assert(disabled_mask == 0 || item_count <= 8);
+ w->LowerWidget(parent_button);
+ w->InvalidateWidget(parent_button);
+
+ DeleteWindowById(WC_TOOLBAR_MENU, 0);
+
+ /* Extend the dropdown toolbar to the longest string in the list */
+ int width = max(GetStringListMaxWidth(base_string, item_count) + 6, 140);
+ int height = item_count * 10 + 2;
+
+ Point pos = GetToolbarDropdownPos(parent_button, width, height);
+
+ w = AllocateWindow(pos.x, pos.y, width, height, MenuWndProc, WC_TOOLBAR_MENU, _menu_widgets);
+ w->widget[0].bottom = item_count * 10 + 1;
+ w->flags4 &= ~WF_WHITE_BORDER_MASK;
+
+ WP(w, menu_d).item_count = item_count;
+ WP(w, menu_d).sel_index = 0;
+ WP(w, menu_d).main_button = GB(parent_button, 0, 8);
+ WP(w, menu_d).action_id = (GB(parent_button, 8, 8) != 0) ? GB(parent_button, 8, 8) : parent_button;
+ WP(w, menu_d).string_id = base_string;
+ WP(w, menu_d).checked_items = 0;
+ WP(w, menu_d).disabled_items = disabled_mask;
+
+ _popup_menu_active = true;
+
+ SndPlayFx(SND_15_BEEP);
+ return w;
+}
+
+/* --- Rendering/drawing the player menu --- */
+static int GetPlayerIndexFromMenu(int index)
+{
+ if (index >= 0) {
+ const Player *p;
+
+ FOR_ALL_PLAYERS(p) {
+ if (p->is_active && --index < 0) return p->index;
+ }
+ }
+ return -1;
+}
+
+static void UpdatePlayerMenuHeight(Window *w)
+{
+ byte num = ActivePlayerCount();
+
+ /* Increase one to fit in PlayerList in the menu when in network */
+ if (_networking && WP(w, menu_d).main_button == 9) num++;
+
+ if (WP(w, menu_d).item_count != num) {
+ WP(w, menu_d).item_count = num;
+ SetWindowDirty(w);
+ num = num * 10 + 2;
+ w->height = num;
+ w->widget[0].bottom = w->widget[0].top + num - 1;
+ w->top = GetToolbarDropdownPos(0, w->width, w->height).y;
+ SetWindowDirty(w);
+ }
+}
+
+static void PlayerMenuWndProc(Window *w, WindowEvent *e)
+{
+ switch (e->event) {
+ case WE_PAINT: {
+ UpdatePlayerMenuHeight(w);
+ DrawWindowWidgets(w);
+
+ int x = 1;
+ int y = 1;
+ int sel = WP(w, menu_d).sel_index;
+ int chk = WP(w, menu_d).checked_items; // let this mean gray items.
+
+ /* 9 = playerlist */
+ if (_networking && WP(w, menu_d).main_button == 9) {
+ if (sel == 0) {
+ GfxFillRect(x, y, x + 238, y + 9, 0);
+ }
+ DrawString(x + 19, y, STR_NETWORK_CLIENT_LIST, TC_FROMSTRING);
+ y += 10;
+ sel--;
+ }
+
+ const Player *p;
+ FOR_ALL_PLAYERS(p) {
+ if (p->is_active) {
+ if (p->index == sel) {
+ GfxFillRect(x, y, x + 238, y + 9, 0);
+ }
+
+ DrawPlayerIcon(p->index, x + 2, y + 1);
+
+ SetDParam(0, p->index);
+ SetDParam(1, p->index);
+
+ TextColour color = (p->index == sel) ? TC_WHITE : TC_BLACK;
+ if (chk & 1) color = TC_GREY;
+ DrawString(x + 19, y, STR_7021, color);
+
+ y += 10;
+ }
+ chk >>= 1;
+ }
+ } break;
+
+ case WE_DESTROY: {
+ Window *v = FindWindowById(WC_MAIN_TOOLBAR, 0);
+ v->RaiseWidget(WP(w, menu_d).main_button);
+ SetWindowDirty(v);
+ return;
+ }
+
+ case WE_POPUPMENU_SELECT: {
+ int index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
+ int action_id = WP(w, menu_d).action_id;
+
+ /* We have a new entry at the top of the list of menu 9 when networking
+ * so keep that in count */
+ if (_networking && WP(w, menu_d).main_button == 9) {
+ if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
+ } else {
+ index = GetPlayerIndexFromMenu(index);
+ }
+
+ if (index < 0) {
+ Window *w2 = FindWindowById(WC_MAIN_TOOLBAR,0);
+ if (GetWidgetFromPos(w2, e->we.popupmenu.pt.x - w2->left, e->we.popupmenu.pt.y - w2->top) == WP(w, menu_d).main_button)
+ index = WP(w, menu_d).sel_index;
+ }
+
+ DeleteWindow(w);
+
+ if (index >= 0) {
+ assert(index >= 0 && index < 30);
+ _menu_clicked_procs[action_id](index);
+ }
+ } break;
+
+ case WE_POPUPMENU_OVER: {
+ int index;
+ UpdatePlayerMenuHeight(w);
+ index = GetMenuItemIndex(w, e->we.popupmenu.pt.x, e->we.popupmenu.pt.y);
+
+ /* We have a new entry at the top of the list of menu 9 when networking
+ * so keep that in count */
+ if (_networking && WP(w, menu_d).main_button == 9) {
+ if (index > 0) index = GetPlayerIndexFromMenu(index - 1) + 1;
+ } else {
+ index = GetPlayerIndexFromMenu(index);
+ }
+
+ if (index == -1 || index == WP(w, menu_d).sel_index) return;
+
+ WP(w, menu_d).sel_index = index;
+ SetWindowDirty(w);
+ return;
+ }
+ }
+}
+
+static const Widget _player_menu_widgets[] = {
+{ WWT_PANEL, RESIZE_NONE, 14, 0, 240, 0, 81, 0x0, STR_NULL},
+{ WIDGETS_END},
+};
+
+static Window *PopupMainPlayerToolbMenu(Window *w, int main_button, int gray)
+{
+ w->LowerWidget(main_button);
+ w->InvalidateWidget(main_button);
+
+ DeleteWindowById(WC_TOOLBAR_MENU, 0);
+ Point pos = GetToolbarDropdownPos(main_button, 241, 82);
+ w = AllocateWindow(pos.x, pos.y, 241, 82, PlayerMenuWndProc, WC_TOOLBAR_MENU, _player_menu_widgets);
+ w->flags4 &= ~WF_WHITE_BORDER_MASK;
+ WP(w, menu_d).item_count = 0;
+ WP(w, menu_d).sel_index = (_local_player != PLAYER_SPECTATOR) ? _local_player : GetPlayerIndexFromMenu(0);
+ if (_networking && main_button == 9) {
+ if (_local_player != PLAYER_SPECTATOR) {
+ WP(w, menu_d).sel_index++;
+ } else {
+ /* Select client list by default for spectators */
+ WP(w, menu_d).sel_index = 0;
+ }
+ }
+ WP(w, menu_d).action_id = main_button;
+ WP(w, menu_d).main_button = main_button;
+ WP(w, menu_d).checked_items = gray;
+ WP(w, menu_d).disabled_items = 0;
+ _popup_menu_active = true;
+ SndPlayFx(SND_15_BEEP);
+ return w;
+}
+
+/* --- Allocating the toolbar --- */
+
Window *AllocateToolbar()
{
- return AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
+ /* Clean old GUI values */
+ _last_built_railtype = RAILTYPE_RAIL;
+ _last_built_roadtype = ROADTYPE_ROAD;
+
+ Window *w = AllocateWindowDesc((_game_mode != GM_EDITOR) ? &_toolb_normal_desc : &_toolb_scen_desc);
+ if (w == NULL) return NULL;
+
+ CLRBITS(w->flags4, WF_WHITE_BORDER_MASK);
+
+ w->SetWidgetDisabledState(0, _networking && !_network_server); // if not server, disable pause button
+ w->SetWidgetDisabledState(1, _networking); // if networking, disable fast-forward button
+
+ /* 'w' is for sure a WC_MAIN_TOOLBAR */
+ PositionMainToolbar(w);
+
+ return w;
}
--- a/src/toolbar_gui.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/toolbar_gui.h Fri Apr 18 19:55:13 2008 +0000
@@ -7,7 +7,6 @@
#include "window_type.h"
-Point GetToolbarDropdownPos(uint16 parent_button, int width, int height);
Window *AllocateToolbar();
#endif /*TOOLBAR_GUI_H*/
--- a/src/town.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/town.h Fri Apr 18 19:55:13 2008 +0000
@@ -13,8 +13,8 @@
#include "date_type.h"
#include "town_type.h"
#include "player_type.h"
-#include "newgrf_string_type.h"
#include "settings_type.h"
+#include "strings_type.h"
enum {
HOUSE_NO_CLASS = 0,
@@ -201,7 +201,7 @@
Year max_date; ///< last year it can be built
byte population; ///< population (Zero on other tiles in multi tile house.)
byte removal_cost; ///< cost multiplier for removing it
- GRFMappedStringID building_name; ///< building name
+ StringID building_name; ///< building name
uint16 remove_rating_decrease; ///< rating decrease if removed
byte mail_generation; ///< mail generation multiplier (tile based, as the acceptances below)
byte cargo_acceptance[3]; ///< acceptance level for the cargo slots
--- a/src/town_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/town_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -41,6 +41,10 @@
#include "string_func.h"
#include "newgrf_cargo.h"
#include "oldpool_func.h"
+#include "sprite.h"
+#include "economy_func.h"
+#include "station_func.h"
+#include "cheat_func.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -1060,7 +1064,7 @@
case TL_3X3_GRID:
case TL_2X2_GRID:
- rcmd = GetTownRoadGridElement(t1, tile, target_dir);
+ rcmd = GetTownRoadGridElement(t1, tile, target_dir);
break;
case TL_BETTER_ROADS:
@@ -2341,7 +2345,7 @@
if (TilePixelHeight(t->xy) >= GetSnowLine() && t->act_food == 0 && t->population > 90)
return;
} else if (_opt.landscape == LT_TROPIC) {
- if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food==0 || t->act_water==0) && t->population > 60)
+ if (GetTropicZone(t->xy) == TROPICZONE_DESERT && (t->act_food == 0 || t->act_water == 0) && t->population > 60)
return;
}
--- a/src/town_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/town_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -149,7 +149,7 @@
SetVScrollCount(w, numact + 1);
- if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w,def_d).data_1))
+ if (WP(w, def_d).data_1 != -1 && !HasBit(buttons, WP(w, def_d).data_1))
WP(w, def_d).data_1 = -1;
w->SetWidgetDisabledState(6, WP(w, def_d).data_1 == -1);
--- a/src/train_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/train_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -20,7 +20,8 @@
#include "engine_func.h"
#include "player_func.h"
#include "player_base.h"
-#include "depot.h"
+#include "depot_base.h"
+#include "depot_func.h"
#include "waypoint.h"
#include "vehicle_gui.h"
#include "train.h"
@@ -678,7 +679,7 @@
/* Check if the train is actually being built in a depot belonging
* to the player. Doesn't matter if only the cost is queried */
if (!(flags & DC_QUERY_COST)) {
- if (!IsTileDepotType(tile, TRANSPORT_RAIL)) return CMD_ERROR;
+ if (!IsRailDepotTile(tile)) return CMD_ERROR;
if (!IsTileOwner(tile, _current_player)) return CMD_ERROR;
}
@@ -806,7 +807,7 @@
TileIndex tile = v->tile;
/* check if stopped in a depot */
- if (!IsTileDepotType(tile, TRANSPORT_RAIL) || v->cur_speed != 0) return -1;
+ if (!IsRailDepotTile(tile) || v->cur_speed != 0) return -1;
int count = 0;
for (; v != NULL; v = v->Next()) {
@@ -1303,7 +1304,7 @@
* @param p2 the selling mode
* - p2 = 0: only sell the single dragged wagon/engine (and any belonging rear-engines)
* - p2 = 1: sell the vehicle and all vehicles following it in the chain
- if the wagon is dragged, don't delete the possibly belonging rear-engine to some front
+ * if the wagon is dragged, don't delete the possibly belonging rear-engine to some front
* - p2 = 2: when selling attached locos, rearrange all vehicles after it to separate lines;
* all wagons of the same type will go on the same line. Used by the AI currently
*/
@@ -1787,7 +1788,7 @@
static void ReverseTrainDirection(Vehicle *v)
{
- if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) {
+ if (IsRailDepotTile(v->tile)) {
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
}
@@ -1807,7 +1808,7 @@
AdvanceWagonsAfterSwap(v);
- if (IsTileDepotType(v->tile, TRANSPORT_RAIL)) {
+ if (IsRailDepotTile(v->tile)) {
InvalidateWindowData(WC_VEHICLE_DEPOT, v->tile);
}
@@ -2035,7 +2036,7 @@
tfdd.reverse = false;
TileIndex tile = v->tile;
- if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsRailDepotTile(tile)) {
tfdd.tile = tile;
tfdd.best_length = 0;
return tfdd;
@@ -2154,7 +2155,7 @@
}
/* No smoke in depots or tunnels */
- if (IsTileDepotType(v->tile, TRANSPORT_RAIL) || IsTunnelTile(v->tile)) continue;
+ if (IsRailDepotTile(v->tile) || IsTunnelTile(v->tile)) continue;
/* No sparks for electric vehicles on nonelectrified tracks */
if (!HasPowerOnRail(v->u.rail.railtype, GetTileRailType(v->tile))) continue;
@@ -3149,7 +3150,7 @@
if (IsLevelCrossingTile(tile)) UpdateLevelCrossing(tile);
/* Update signals */
- if (IsTileType(tile, MP_TUNNELBRIDGE) || IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsTileType(tile, MP_TUNNELBRIDGE) || IsRailDepotTile(tile)) {
UpdateSignalsOnSegment(tile, INVALID_DIAGDIR, owner);
} else {
SetSignalsOnBothDir(tile, (Track)(FIND_FIRST_BIT(track)), owner);
@@ -3206,7 +3207,7 @@
if (state <= 240 && !(v->tick_counter & 3)) ChangeTrainDirRandomly(v);
- if (state >= 4440 && !(v->tick_counter&0x1F)) {
+ if (state >= 4440 && !(v->tick_counter & 0x1F)) {
DeleteLastWagon(v);
InvalidateWindow(WC_REPLACE_VEHICLE, (v->group_id << 16) | VEH_TRAIN);
}
@@ -3311,7 +3312,7 @@
}
/* entering a depot? */
- if (IsTileDepotType(tile, TRANSPORT_RAIL)) {
+ if (IsRailDepotTile(tile)) {
DiagDirection dir = ReverseDiagDir(GetRailDepotDirection(tile));
if (DiagDirToDir(dir) == v->direction) return false;
}
--- a/src/train_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/train_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -10,7 +10,6 @@
#include "gfx_func.h"
#include "command_func.h"
#include "vehicle_gui.h"
-#include "depot.h"
#include "train.h"
#include "newgrf_engine.h"
#include "strings_func.h"
--- a/src/tunnelbridge.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/tunnelbridge.h Fri Apr 18 19:55:13 2008 +0000
@@ -6,8 +6,6 @@
#define TUNNELBRIDGE_H
#include "tile_type.h"
-#include "map_func.h"
-#include "tunnelbridge_map.h"
/**
* Calculates the length of a tunnel or a bridge (without end tiles)
@@ -23,4 +21,6 @@
return abs(x2 + y2 - x1 - y1) - 1;
}
+extern TileIndex _build_tunnel_endtile;
+
#endif /* TUNNELBRIDGE_H */
--- a/src/tunnelbridge_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/tunnelbridge_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -35,12 +35,16 @@
#include "tunnelbridge.h"
#include "player_base.h"
#include "engine_func.h"
+#include "economy_func.h"
+#include "rail.h"
+#include "cheat_func.h"
#include "table/sprites.h"
#include "table/strings.h"
#include "table/bridge_land.h"
BridgeSpec _bridge[MAX_BRIDGES];
+TileIndex _build_tunnel_endtile;
/** Reset the data been eventually changed by the grf loaded. */
void ResetBridges()
--- a/src/unmovable_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/unmovable_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -24,6 +24,9 @@
#include "window_func.h"
#include "vehicle_func.h"
#include "player_gui.h"
+#include "station_type.h"
+#include "economy_func.h"
+#include "cheat_func.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -155,7 +158,7 @@
if (flags & DC_EXEC) DoClearSquare(tile);
- return CommandCost(EXPENSES_CONSTRUCTION,- _price.clear_roughland * 2);
+ return CommandCost(EXPENSES_CONSTRUCTION, - _price.clear_roughland * 2);
}
static Foundation GetFoundation_Unmovable(TileIndex tile, Slope tileh);
--- a/src/variables.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/variables.h Fri Apr 18 19:55:13 2008 +0000
@@ -5,18 +5,12 @@
#ifndef VARIABLES_H
#define VARIABLES_H
-#include "tile_type.h"
-#include "strings_type.h"
-
/* Amount of game ticks */
VARDEF uint16 _tick_counter;
/* Skip aging of cargo? */
VARDEF byte _age_cargo_skip_counter;
-/* Position in tile loop */
-VARDEF TileIndex _cur_tileloop_tile;
-
/* Also save scrollpos_x, scrollpos_y and zoom */
VARDEF uint16 _disaster_delay;
@@ -39,31 +33,6 @@
VARDEF int _saved_scrollpos_x;
VARDEF int _saved_scrollpos_y;
-struct Cheat {
- bool been_used; // has this cheat been used before?
- bool value; // tells if the bool cheat is active or not
-};
-
-
-/* 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
- Cheat switch_player; // change to another player
- Cheat money; // get rich
- Cheat crossing_tunnels; // allow tunnels that cross each other
- Cheat build_in_pause; // build while in pause mode
- Cheat no_jetcrash; // no jet will crash on small airports anymore
- Cheat switch_climate;
- Cheat change_date; // changes date ingame
- Cheat setup_prod; // setup raw-material production in game
- Cheat dummy; // empty cheat (enable running el-engines on normal rail)
-};
-
-VARDEF Cheats _cheats;
-
/* NOSAVE: Used in palette animations only, not really important. */
VARDEF int _palette_animation_counter;
@@ -82,12 +51,10 @@
VARDEF bool _rightclick_emulate;
/* IN/OUT parameters to commands */
-VARDEF TileIndex _build_tunnel_endtile;
VARDEF bool _generating_world;
/* Used when switching from the intro menu. */
VARDEF byte _switch_mode;
-VARDEF StringID _switch_mode_errorstr;
VARDEF char _savegame_format[8];
@@ -98,8 +65,6 @@
/* landscape.cpp */
extern const byte _tileh_to_sprite[32];
-extern bool _draw_bounding_boxes;
-
/* misc */
VARDEF char _screenshot_name[128];
VARDEF byte _vehicle_design_names;
--- a/src/vehicle.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/vehicle.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -19,7 +19,6 @@
#include "player_func.h"
#include "debug.h"
#include "vehicle_gui.h"
-#include "depot.h"
#include "rail_type.h"
#include "train.h"
#include "aircraft.h"
@@ -47,6 +46,7 @@
#include "string_func.h"
#include "settings_type.h"
#include "oldpool_func.h"
+#include "depot_map.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -835,11 +835,9 @@
if (v->progress > 0) {
v->progress--;
} else {
- TileIndex tile;
-
BeginVehicleMove(v);
- tile = TileVirtXY(v->x_pos, v->y_pos);
+ TileIndex tile = TileVirtXY(v->x_pos, v->y_pos);
if (!IsTileType(tile, MP_INDUSTRY)) {
EndVehicleMove(v);
delete v;
@@ -1487,10 +1485,10 @@
/* decrease reliability */
v->reliability = rel = max((rel_old = v->reliability) - v->reliability_spd_dec, 0);
- if ((rel_old >> 8) != (rel >> 8))
- InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+ if ((rel_old >> 8) != (rel >> 8)) InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
if (v->breakdown_ctr != 0 || v->vehstatus & VS_STOPPED ||
+ _opt.diff.vehicle_breakdowns < 1 ||
v->cur_speed < 5 || _game_mode == GM_MENU) {
return;
}
@@ -1499,16 +1497,13 @@
/* increase chance of failure */
int chance = v->breakdown_chance + 1;
- if (Chance16I(1,25,r)) chance += 25;
+ if (Chance16I(1, 25, r)) chance += 25;
v->breakdown_chance = min(255, chance);
/* calculate reliability value to use in comparison */
rel = v->reliability;
if (v->type == VEH_SHIP) rel += 0x6666;
- /* disabled breakdowns? */
- if (_opt.diff.vehicle_breakdowns < 1) return;
-
/* reduced breakdowns? */
if (_opt.diff.vehicle_breakdowns == 1) rel += 0x6666;
@@ -2074,7 +2069,7 @@
break;
}
- case VLW_GROUP_LIST:
+ case VLW_GROUP_LIST:
FOR_ALL_VEHICLES(v) {
if (v->type == type && v->IsPrimaryVehicle() &&
v->owner == owner && v->group_id == index) {
@@ -3219,7 +3214,7 @@
/* check if at a standstill (not stopped only) in a depot
* the check is down here to make it possible to alter stop/service for trains entering the depot */
- if (this->type == VEH_TRAIN && IsTileDepotType(this->tile, TRANSPORT_RAIL) && this->cur_speed == 0) return CMD_ERROR;
+ if (this->type == VEH_TRAIN && IsRailDepotTile(this->tile) && this->cur_speed == 0) return CMD_ERROR;
TileIndex location;
DestinationID destination;
--- a/src/vehicle_gui.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/vehicle_gui.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -21,7 +21,7 @@
#include "ship.h"
#include "aircraft.h"
#include "roadveh.h"
-#include "depot.h"
+#include "depot_base.h"
#include "cargotype.h"
#include "group.h"
#include "group_gui.h"
@@ -35,6 +35,7 @@
#include "settings_type.h"
#include "widgets/dropdown_func.h"
#include "order_func.h"
+#include "depot_base.h"
#include "table/sprites.h"
#include "table/strings.h"
@@ -71,6 +72,7 @@
static VehicleSortListingTypeFunction VehicleMaxSpeedSorter;
static VehicleSortListingTypeFunction VehicleModelSorter;
static VehicleSortListingTypeFunction VehicleValueSorter;
+static VehicleSortListingTypeFunction VehicleLengthSorter;
static VehicleSortListingTypeFunction* const _vehicle_sorter[] = {
&VehicleNumberSorter,
@@ -83,6 +85,7 @@
&VehicleMaxSpeedSorter,
&VehicleModelSorter,
&VehicleValueSorter,
+ &VehicleLengthSorter,
};
const StringID _vehicle_sort_listing[] = {
@@ -96,6 +99,7 @@
STR_SORT_BY_MAX_SPEED,
STR_SORT_BY_MODEL,
STR_SORT_BY_VALUE,
+ STR_SORT_BY_LENGTH,
INVALID_STRING_ID
};
@@ -697,6 +701,30 @@
return (_internal_sort_order & 1) ? -r : r;
}
+static int CDECL VehicleLengthSorter(const void *a, const void *b)
+{
+ const Vehicle *va = *(const Vehicle**)a;
+ const Vehicle *vb = *(const Vehicle**)b;
+ int r = 0;
+
+ switch (va->type) {
+ case VEH_TRAIN:
+ r = va->u.rail.cached_total_length - vb->u.rail.cached_total_length;
+ break;
+
+ case VEH_ROAD:
+ for (const Vehicle *u = va; u != NULL; u = u->Next()) r += u->u.road.cached_veh_length;
+ for (const Vehicle *u = vb; u != NULL; u = u->Next()) r -= u->u.road.cached_veh_length;
+ break;
+
+ default: NOT_REACHED();
+ }
+
+ VEHICLEUNITNUMBERSORTER(r, va, vb);
+
+ return (_internal_sort_order & 1) ? -r : r;
+}
+
void InitializeGUI()
{
memset(&_sorting, 0, sizeof(_sorting));
@@ -1060,7 +1088,7 @@
SetWindowDirty(w);
break;
case VLW_WIDGET_SORT_BY_PULLDOWN:/* Select sorting criteria dropdown menu */
- ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, VLW_WIDGET_SORT_BY_PULLDOWN, 0, 0);
+ ShowDropDownMenu(w, _vehicle_sort_listing, vl->l.sort_type, VLW_WIDGET_SORT_BY_PULLDOWN, 0, (vl->vehicle_type == VEH_TRAIN || vl->vehicle_type == VEH_ROAD) ? 0 : (1 << 10));
return;
case VLW_WIDGET_LIST: { /* Matrix to show vehicles */
uint32 id_v = (e->we.click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / w->resize.step_height;
@@ -1436,7 +1464,7 @@
extern void DrawAircraftDetails(const Vehicle *v, int x, int y);
/**
-* Draw the details for the given vehicle at the position (x,y) of the Details windows
+* Draw the details for the given vehicle at the position (x, y) of the Details windows
*
* @param v current vehicle
* @param x The x coordinate
--- a/src/video/win32_v.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/video/win32_v.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -308,7 +308,7 @@
case WM_PAINT: {
PAINTSTRUCT ps;
- HDC dc,dc2;
+ HDC dc, dc2;
HBITMAP old_bmp;
HPALETTE old_palette;
--- a/src/viewport.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/viewport.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -1,6 +1,22 @@
/* $Id$ */
-/** @file viewport.cpp */
+/** @file viewport.cpp
+ *
+ * \verbatim
+ * The in-game coordinate system looks like this *
+ * *
+ * ^ Z *
+ * | *
+ * | *
+ * | *
+ * | *
+ * / \ *
+ * / \ *
+ * / \ *
+ * / \ *
+ * X < > Y *
+ * \endverbatim
+ */
#include "stdafx.h"
#include "openttd.h"
@@ -38,39 +54,6 @@
Point _tile_fract_coords;
ZoomLevel _saved_scrollpos_zoom;
-/**
- * The maximum number of viewports depends on the maximum number
- * of windows. Technically is could be the maximum number of
- * windows, but there is always at least one window that does
- * not need a viewport. Not having 'support' for that viewport
- * saves some time and memory.
- * For the introduction GUI and create game GUIs there is no
- * need for more than one viewport, however in the normal game
- * and scenario editor one can make a lot of viewports. For the
- * normal game one always has a main toolbar and a status bar,
- * however the statusbar does not exist on the scenario editor.
- *
- * This means that we can only safely assume that there is one
- * window without viewport.
- */
-static ViewPort _viewports[MAX_NUMBER_OF_WINDOWS - 1];
-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);
-
-/* The in-game coordiante system looks like this *
- * *
- * ^ Z *
- * | *
- * | *
- * | *
- * | *
- * / \ *
- * / \ *
- * / \ *
- * / \ *
- * X < > Y *
- */
-
struct StringSpriteToDraw {
uint16 string;
uint16 color;
@@ -158,6 +141,7 @@
TileHighlightData _thd;
static TileInfo *_cur_ti;
+bool _draw_bounding_boxes = false;
extern void SmallMapCenterOnCurrentPos(Window *w);
@@ -169,15 +153,8 @@
return p;
}
-void InitViewports()
-{
- memset(_viewports, 0, sizeof(_viewports));
- _active_viewports = 0;
-}
-
void DeleteWindowViewport(Window *w)
{
- ClrBit(_active_viewports, w->viewport - _viewports);
w->viewport->width = 0;
w->viewport = NULL;
}
@@ -185,15 +162,9 @@
void AssignWindowViewport(Window *w, int x, int y,
int width, int height, uint32 follow_flags, ZoomLevel zoom)
{
- ViewPort *vp;
- Point pt;
- uint32 bit;
-
- for (vp = _viewports, bit = 0; ; vp++, bit++) {
- assert(vp != endof(_viewports));
- if (vp->width == 0) break;
- }
- SetBit(_active_viewports, bit);
+ assert(w->viewport == NULL);
+
+ ViewPort *vp = &(WP(w, vp_d).vp_data);
vp->left = x + w->left;
vp->top = y + w->top;
@@ -205,6 +176,8 @@
vp->virtual_width = ScaleByZoom(width, zoom);
vp->virtual_height = ScaleByZoom(height, zoom);
+ Point pt;
+
if (follow_flags & 0x80000000) {
const Vehicle *veh;
@@ -1069,7 +1042,7 @@
if (bottom > t->sign.top &&
top < t->sign.top + 24 &&
right > t->sign.left &&
- left < t->sign.left + t->sign.width_1*2) {
+ left < t->sign.left + t->sign.width_1 * 2) {
AddStringToDraw(t->sign.left + 1, t->sign.top + 1,
_patches.population_in_label ? STR_TOWN_LABEL_POP : STR_TOWN_LABEL,
t->index, t->population);
@@ -1136,7 +1109,7 @@
if (bottom > st->sign.top &&
top < st->sign.top + 24 &&
right > st->sign.left &&
- left < st->sign.left + st->sign.width_1*2) {
+ left < st->sign.left + st->sign.width_1 * 2) {
AddStation(st, STR_305C_0, st->sign.width_1);
}
}
@@ -1264,7 +1237,7 @@
if (bottom > wp->sign.top &&
top < wp->sign.top + 24 &&
right > wp->sign.left &&
- left < wp->sign.left + wp->sign.width_1*2) {
+ left < wp->sign.left + wp->sign.width_1 * 2) {
AddWaypoint(wp, STR_WAYPOINT_VIEWPORT, wp->sign.width_1);
}
}
@@ -1677,14 +1650,15 @@
void MarkAllViewportsDirty(int left, int top, int right, int bottom)
{
- const ViewPort *vp = _viewports;
- uint32 act = _active_viewports;
- do {
- if (act & 1) {
+ Window **wz;
+
+ FOR_ALL_WINDOWS(wz) {
+ ViewPort *vp = (*wz)->viewport;
+ if (vp != NULL) {
assert(vp->width != 0);
MarkViewportDirty(vp, left, top, right, bottom);
}
- } while (vp++,act>>=1);
+ }
}
void MarkTileDirtyByTile(TileIndex tile)
--- a/src/viewport_func.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/viewport_func.h Fri Apr 18 19:55:13 2008 +0000
@@ -12,7 +12,6 @@
void SetSelectionRed(bool);
-void InitViewports();
void DeleteWindowViewport(Window *w);
void AssignWindowViewport(Window *w, int x, int y, int width, int height, uint32 follow_flags, ZoomLevel zoom);
ViewPort *IsPtInWindowViewport(const Window *w, int x, int y);
--- a/src/water_cmd.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/water_cmd.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -14,7 +14,8 @@
#include "command_func.h"
#include "town.h"
#include "news_func.h"
-#include "depot.h"
+#include "depot_base.h"
+#include "depot_func.h"
#include "vehicle_gui.h"
#include "train.h"
#include "roadveh.h"
--- a/src/water_map.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/water_map.h Fri Apr 18 19:55:13 2008 +0000
@@ -91,11 +91,16 @@
return t + (HasBit(_m[t].m5, 0) ? -1 : 1) * (HasBit(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
}
-static inline TileIndex IsShipDepot(TileIndex t)
+static inline bool IsShipDepot(TileIndex t)
{
return IsInsideMM(_m[t].m5, DEPOT_NORTH, DEPOT_END);
}
+static inline bool IsShipDepotTile(TileIndex t)
+{
+ return IsTileType(t, MP_WATER) && IsShipDepot(t);
+}
+
static inline Axis GetShipDepotAxis(TileIndex t)
{
return (Axis)GB(_m[t].m5, 1, 1);
--- a/src/waypoint.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/waypoint.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -100,7 +100,7 @@
Waypoint *lwp = GetWaypoint(cid);
/* check only valid waypoints... */
- if (lwp->IsValid() && wp != lwp) {
+ if (lwp->IsValid() && wp != lwp) {
/* only waypoints with 'generic' name within the same city */
if (lwp->name == NULL && lwp->town_index == wp->town_index) {
/* if lwp->town_cn < next, uint will overflow to '+inf' */
--- a/src/waypoint.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/waypoint.h Fri Apr 18 19:55:13 2008 +0000
@@ -10,6 +10,7 @@
#include "rail_map.h"
#include "command_type.h"
#include "station_type.h"
+#include "town_type.h"
DECLARE_OLD_POOL(Waypoint, Waypoint, 3, 8000)
--- a/src/widget.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/widget.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -86,7 +86,7 @@
default: NOT_REACHED();
}
- if (pos <= mi+9) {
+ if (pos <= mi + 9) {
/* Pressing the upper button? */
w->flags4 |= WF_SCROLL_UP;
if (_scroller_click_timeout == 0) {
--- a/src/win32.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/win32.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -249,7 +249,7 @@
#if 0
struct WinInetProcs {
- HINTERNET (WINAPI *InternetOpen)(LPCTSTR,DWORD, LPCTSTR, LPCTSTR, DWORD);
+ HINTERNET (WINAPI *InternetOpen)(LPCTSTR, DWORD, LPCTSTR, LPCTSTR, DWORD);
HINTERNET (WINAPI *InternetConnect)(HINTERNET, LPCTSTR, INTERNET_PORT, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD);
HINTERNET (WINAPI *HttpOpenRequest)(HINTERNET, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR *, DWORD, DWORD);
BOOL (WINAPI *HttpSendRequest)(HINTERNET, LPCTSTR, DWORD, LPVOID, DWORD);
@@ -1021,7 +1021,7 @@
char *getcwd(char *buf, size_t size)
{
#if defined(WINCE)
- TCHAR path[MAX_PATH];
+ TCHAR path[MAX_PATH];
GetModuleFileName(NULL, path, MAX_PATH);
convert_from_fs(path, buf, size);
/* GetModuleFileName returns dir with file, so remove everything behind latest '\\' */
--- a/src/window.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/window.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -19,6 +19,7 @@
#include "map_func.h"
#include "vehicle_base.h"
#include "settings_type.h"
+#include "cheat_func.h"
#include "table/sprites.h"
@@ -1037,7 +1038,6 @@
IConsoleClose();
_last_z_window = _z_windows;
- InitViewports();
_no_scroll = 0;
}
--- a/src/window_gui.h Wed Apr 16 22:34:14 2008 +0000
+++ b/src/window_gui.h Fri Apr 18 19:55:13 2008 +0000
@@ -42,7 +42,7 @@
Now the window will only change in height in steps of 10.
You can also give a minimum width and height. The default value is
the default height/width of the window itself. You can change this
- AFTER window-creation, with:
+ AFTER window - creation, with:
w->resize.width or w->resize.height.
That was all.. good luck, and enjoy :) -- TrueLight */
@@ -409,6 +409,7 @@
int32 scrollpos_y;
int32 dest_scrollpos_x;
int32 dest_scrollpos_y;
+ ViewPort vp_data; ///< Screen position and zoom of the viewport
};
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vp_d));
--- a/src/yapf/follow_track.hpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/yapf/follow_track.hpp Fri Apr 18 19:55:13 2008 +0000
@@ -6,7 +6,7 @@
#define FOLLOW_TRACK_HPP
#include "yapf.hpp"
-
+#include "../depot_map.h"
/** Track follower helper template class (can serve pathfinders and vehicle
* controllers). See 6 different typedefs below for 3 different transport
@@ -196,7 +196,7 @@
}
// road depots can be also left in one direction only
- if (IsRoadTT() && IsTileDepotType(m_old_tile, TT())) {
+ if (IsRoadTT() && IsDepotTypeTile(m_old_tile, TT())) {
DiagDirection exitdir = GetRoadDepotDirection(m_old_tile);
if (exitdir != m_exitdir) {
m_err = EC_NO_WAY;
@@ -226,7 +226,7 @@
}
// road and rail depots can also be entered from one direction only
- if (IsRoadTT() && IsTileDepotType(m_new_tile, TT())) {
+ if (IsRoadTT() && IsDepotTypeTile(m_new_tile, TT())) {
DiagDirection exitdir = GetRoadDepotDirection(m_new_tile);
if (ReverseDiagDir(exitdir) != m_exitdir) {
m_err = EC_NO_WAY;
@@ -238,7 +238,7 @@
return false;
}
}
- if (IsRailTT() && IsTileDepotType(m_new_tile, TT())) {
+ if (IsRailTT() && IsDepotTypeTile(m_new_tile, TT())) {
DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
if (ReverseDiagDir(exitdir) != m_exitdir) {
m_err = EC_NO_WAY;
@@ -305,7 +305,7 @@
FORCEINLINE bool ForcedReverse()
{
// rail and road depots cause reversing
- if (!IsWaterTT() && IsTileDepotType(m_old_tile, TT())) {
+ if (!IsWaterTT() && IsDepotTypeTile(m_old_tile, TT())) {
DiagDirection exitdir = IsRailTT() ? GetRailDepotDirection(m_old_tile) : GetRoadDepotDirection(m_old_tile);
if (exitdir != m_exitdir) {
// reverse
--- a/src/yapf/yapf.hpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/yapf/yapf.hpp Fri Apr 18 19:55:13 2008 +0000
@@ -8,7 +8,6 @@
#include "track_dir.hpp"
#include "../vehicle_base.h"
-#include "../depot.h"
#include "../road_map.h"
#include "../tunnel_map.h"
#include "../bridge_map.h"
--- a/src/yapf/yapf_destrail.hpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/yapf/yapf_destrail.hpp Fri Apr 18 19:55:13 2008 +0000
@@ -43,7 +43,7 @@
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(TileIndex tile, Trackdir td)
{
- bool bDest = IsTileDepotType(tile, TRANSPORT_RAIL);
+ bool bDest = IsRailDepotTile(tile);
return bDest;
}
--- a/src/yapf/yapf_road.cpp Wed Apr 16 22:34:14 2008 +0000
+++ b/src/yapf/yapf_road.cpp Fri Apr 18 19:55:13 2008 +0000
@@ -3,6 +3,7 @@
/** @file yapf_road.cpp */
#include "../stdafx.h"
+#include "../depot_base.h"
#include "yapf.hpp"
#include "yapf_node_road.hpp"
@@ -87,7 +88,7 @@
if (v->current_order.IsType(OT_GOTO_STATION) && tile == v->dest_tile) break;
// stop if we have just entered the depot
- if (IsTileDepotType(tile, TRANSPORT_ROAD) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
+ if (IsRoadDepotTile(tile) && trackdir == DiagdirToDiagTrackdir(ReverseDiagDir(GetRoadDepotDirection(tile)))) {
// next time we will reverse and leave the depot
break;
}
@@ -148,7 +149,7 @@
/// Called by YAPF to detect if node ends in the desired destination
FORCEINLINE bool PfDetectDestination(Node& n)
{
- bool bDest = IsTileDepotType(n.m_segment_last_tile, TRANSPORT_ROAD);
+ bool bDest = IsRoadDepotTile(n.m_segment_last_tile);
return bDest;
}
@@ -370,7 +371,7 @@
// get found depot tile
Node *n = Yapf().GetBestNode();
TileIndex depot_tile = n->m_segment_last_tile;
- assert(IsTileDepotType(depot_tile, TRANSPORT_ROAD));
+ assert(IsRoadDepotTile(depot_tile));
Depot* ret = GetDepotByTile(depot_tile);
return ret;
}
@@ -439,7 +440,7 @@
return NULL;
// handle the case when our vehicle is already in the depot tile
- if (IsTileType(tile, MP_ROAD) && IsTileDepotType(tile, TRANSPORT_ROAD)) {
+ if (IsRoadDepotTile(tile)) {
// only what we need to return is the Depot*
return GetDepotByTile(tile);
}