diff -r 0b2aebc8283e -r 0b8b245a2391 src/openttd.cpp --- a/src/openttd.cpp Wed Jun 13 11:17:30 2007 +0000 +++ b/src/openttd.cpp Wed Jun 13 11:45:14 2007 +0000 @@ -61,7 +61,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" @@ -293,6 +295,7 @@ CleanPool(&_Vehicle_pool); CleanPool(&_Sign_pool); CleanPool(&_Order_pool); + CleanPool(&_Group_pool); free((void*)_town_sort); free((void*)_industry_sort); @@ -502,6 +505,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); @@ -685,7 +690,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); @@ -986,8 +991,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); } } @@ -1076,7 +1081,7 @@ StateGameLoop(); #endif /* ENABLE_NETWORK */ - if (!_pause_game && _display_opt & DO_FULL_ANIMATION) DoPaletteAnimations(); + if (!_pause_game && HASBIT(_display_opt, DO_FULL_ANIMATION)) DoPaletteAnimations(); if (!_pause_game || _cheats.build_in_pause.value) MoveAllTextEffects(); @@ -1103,8 +1108,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 */ @@ -1282,8 +1287,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 */ @@ -1295,8 +1300,8 @@ /* If Load Scenario / New (Scenario) Game is used, * a player does not exist yet. So create one here. * 1 exeption: network-games. Those can have 0 players - * But this exeption is not true for network_servers! */ - if (!_players[0].is_active && (!_networking || (_networking && _network_server))) + * But this exeption is not true for non dedicated network_servers! */ + if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) DoStartupNewPlayer(false); DoZoomInOutWindow(ZOOM_NONE, w); // update button status @@ -1409,6 +1414,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; @@ -1431,9 +1500,10 @@ MakeRoadNormal( t, - GetTileOwner(t), axis == AXIS_X ? ROAD_Y : ROAD_X, - town + ROADTYPES_ROAD, + town, + GetTileOwner(t), OWNER_NONE, OWNER_NONE ); } } else { @@ -1481,34 +1551,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; @@ -1767,8 +1809,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]. @@ -1934,11 +1974,39 @@ !(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); } } } if (CheckSavegameVersion(58)) { + /* patch difficulty number_industries other then zero get bumped to +1 + * since a new option (very low at position1) has been added */ + if (_opt.diff.number_industries > 0) { + _opt.diff.number_industries++; + } + + /* Same goes for number of towns, although no test is needed, just an increment */ + _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]++; + } + } + + if (CheckSavegameVersion(62)) { Town *t; FOR_ALL_TOWNS(t) t->SetActivity(1); }