--- a/src/openttd.cpp Fri May 11 15:13:08 2007 +0000
+++ b/src/openttd.cpp Fri May 25 00:25:08 2007 +0000
@@ -62,7 +62,9 @@
#include "newgrf.h"
#include "newgrf_config.h"
#include "newgrf_house.h"
+#include "newgrf_commons.h"
#include "player_face.h"
+#include "group.h"
#include "bridge_map.h"
#include "clear_map.h"
@@ -300,6 +302,7 @@
CleanPool(&_Vehicle_pool);
CleanPool(&_Sign_pool);
CleanPool(&_Order_pool);
+ CleanPool(&_Group_pool);
free((void*)_town_sort);
free((void*)_industry_sort);
@@ -511,6 +514,8 @@
LoadDriver(MUSIC_DRIVER, _ini_musicdriver);
LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads
_savegame_sort_order = SORT_BY_DATE | SORT_DESCENDING;
+ /* Initialize the zoom level of the screen to normal */
+ _screen.zoom = ZOOM_LVL_NORMAL;
/* restore saved music volume */
_music_driver->set_volume(msf.music_vol);
@@ -694,7 +699,7 @@
_game_mode = GM_NORMAL;
ResetGRFConfig(true);
- ResetHouseIDMapping();
+ _house_mngr.ResetMapping();
GenerateWorldSetCallback(&MakeNewGameDone);
GenerateWorld(from_heightmap ? GW_HEIGHTMAP : GW_NEWGAME, 1 << _patches.map_x, 1 << _patches.map_y);
@@ -995,8 +1000,8 @@
Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
assert(w);
- WP(w,vp_d).scrollpos_x += x << w->viewport->zoom;
- WP(w,vp_d).scrollpos_y += y << w->viewport->zoom;
+ WP(w,vp_d).scrollpos_x += ScaleByZoom(x, w->viewport->zoom);
+ WP(w,vp_d).scrollpos_y += ScaleByZoom(y, w->viewport->zoom);
}
}
@@ -1112,8 +1117,8 @@
for (tile = 0; tile != MapSize(); tile++) {
switch (GetTileType(tile)) {
case MP_STREET:
- if (IsLevelCrossing(tile) && GetCrossingRoadOwner(tile) & 0x80) {
- SetCrossingRoadOwner(tile, OWNER_TOWN);
+ if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HASBIT(_m[tile].m4, 7)) {
+ _m[tile].m4 = OWNER_TOWN;
}
/* FALLTHROUGH */
@@ -1291,8 +1296,8 @@
vp = w->viewport;
vp->zoom = _saved_scrollpos_zoom;
- vp->virtual_width = vp->width << vp->zoom;
- vp->virtual_height = vp->height << vp->zoom;
+ vp->virtual_width = ScaleByZoom(vp->width, vp->zoom);
+ vp->virtual_height = ScaleByZoom(vp->height, vp->zoom);
/* in version 4.1 of the savegame, is_active was introduced to determine
* if a player does exist, rather then checking name_1 */
@@ -1418,6 +1423,70 @@
}
}
+ if (CheckSavegameVersion(48)) {
+ for (TileIndex t = 0; t < map_size; t++) {
+ switch (GetTileType(t)) {
+ case MP_RAILWAY:
+ if (IsPlainRailTile(t)) {
+ /* Swap ground type and signal type for plain rail tiles, so the
+ * ground type uses the same bits as for depots and waypoints. */
+ uint tmp = GB(_m[t].m4, 0, 4);
+ SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
+ SB(_m[t].m2, 0, 4, tmp);
+ } else if (HASBIT(_m[t].m5, 2)) {
+ /* Split waypoint and depot rail type and remove the subtype. */
+ CLRBIT(_m[t].m5, 2);
+ CLRBIT(_m[t].m5, 6);
+ }
+ break;
+
+ case MP_STREET:
+ /* Swap m3 and m4, so the track type for rail crossings is the
+ * same as for normal rail. */
+ Swap(_m[t].m3, _m[t].m4);
+ break;
+
+ default: break;
+ }
+ }
+ }
+
+ if (CheckSavegameVersion(61)) {
+ /* Added the RoadType */
+ for (TileIndex t = 0; t < map_size; t++) {
+ switch(GetTileType(t)) {
+ case MP_STREET:
+ SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2));
+ switch (GetRoadTileType(t)) {
+ default: NOT_REACHED();
+ case ROAD_TILE_NORMAL:
+ SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4));
+ SB(_m[t].m4, 4, 4, 0);
+ SB(_m[t].m6, 2, 4, 0);
+ break;
+ case ROAD_TILE_CROSSING:
+ SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2));
+ break;
+ case ROAD_TILE_DEPOT: break;
+ }
+ SetRoadTypes(t, ROADTYPES_ROAD);
+ break;
+
+ case MP_STATION:
+ if (IsRoadStop(t)) SetRoadTypes(t, ROADTYPES_ROAD);
+ break;
+
+ case MP_TUNNELBRIDGE:
+ if ((IsTunnel(t) ? GetTunnelTransportType(t) : GetBridgeTransportType(t)) == TRANSPORT_ROAD) {
+ SetRoadTypes(t, ROADTYPES_ROAD);
+ }
+ break;
+
+ default: break;
+ }
+ }
+ }
+
if (CheckSavegameVersion(42)) {
Vehicle* v;
@@ -1440,9 +1509,10 @@
MakeRoadNormal(
t,
- GetTileOwner(t),
axis == AXIS_X ? ROAD_Y : ROAD_X,
- town
+ ROADTYPES_ROAD,
+ town,
+ GetTileOwner(t), OWNER_NONE, OWNER_NONE
);
}
} else {
@@ -1490,34 +1560,6 @@
}
}
- if (CheckSavegameVersion(48)) {
- for (TileIndex t = 0; t < map_size; t++) {
- switch (GetTileType(t)) {
- case MP_RAILWAY:
- if (IsPlainRailTile(t)) {
- /* Swap ground type and signal type for plain rail tiles, so the
- * ground type uses the same bits as for depots and waypoints. */
- uint tmp = GB(_m[t].m4, 0, 4);
- SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
- SB(_m[t].m2, 0, 4, tmp);
- } else if (HASBIT(_m[t].m5, 2)) {
- /* Split waypoint and depot rail type and remove the subtype. */
- CLRBIT(_m[t].m5, 2);
- CLRBIT(_m[t].m5, 6);
- }
- break;
-
- case MP_STREET:
- /* Swap m3 and m4, so the track type for rail crossings is the
- * same as for normal rail. */
- Swap(_m[t].m3, _m[t].m4);
- break;
-
- default: break;
- }
- }
- }
-
/* Elrails got added in rev 24 */
if (CheckSavegameVersion(24)) {
Vehicle *v;
@@ -1776,8 +1818,6 @@
* space for newhouses grf features. A new byte, m7, was also added. */
if (CheckSavegameVersion(53)) {
for (TileIndex t = 0; t < map_size; t++) {
- _me[t].m7 = 0;
-
if (IsTileType(t, MP_HOUSE)) {
if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
/* Move the construction stage from m3[7..6] to m5[5..4].
@@ -1943,6 +1983,10 @@
!(v->vehstatus & (VS_STOPPED | VS_CRASHED)) && // not stopped or crashed
v->current_order.type == OT_LOADING) { // loading
GetStation(v->last_station_visited)->loading_vehicles.push_back(v);
+
+ /* The loading finished flag is *only* set when actually completely
+ * finished. Because the vehicle is loading, it is not finished. */
+ CLRBIT(v->vehicle_flags, VF_LOADING_FINISHED);
}
}
}
@@ -1958,6 +2002,20 @@
_opt.diff.number_towns++;
}
+ /* Recalculate */
+ Group *g;
+ FOR_ALL_GROUPS(g) {
+ const Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (!IsEngineCountable(v)) continue;
+
+ if (v->group_id != g->index || v->type != g->vehicle_type || v->owner != g->owner) continue;
+
+ g->num_engines[v->engine_type]++;
+ }
+ }
+
+
return true;
}