diff -r 9a27928bcd5e -r ebf0ece7d8f6 src/openttd.cpp --- a/src/openttd.cpp Thu Nov 22 23:01:41 2007 +0000 +++ b/src/openttd.cpp Fri Nov 23 16:59:30 2007 +0000 @@ -287,8 +287,8 @@ return; } - res[0] = clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); - res[1] = clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT); + res[0] = Clamp(strtoul(s, NULL, 0), 64, MAX_SCREEN_WIDTH); + res[1] = Clamp(strtoul(t + 1, NULL, 0), 64, MAX_SCREEN_HEIGHT); } static void InitializeDynamicVariables() @@ -328,9 +328,6 @@ { _game_mode = GM_MENU; - /* Clear transparency options */ - _transparent_opt = 0; - _opt_ptr = &_opt_newgame; ResetGRFConfig(false); @@ -1145,7 +1142,7 @@ StateGameLoop(); #endif /* ENABLE_NETWORK */ - if (!_pause_game && HASBIT(_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(); @@ -1172,7 +1169,7 @@ for (tile = 0; tile != MapSize(); tile++) { switch (GetTileType(tile)) { case MP_ROAD: - if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HASBIT(_m[tile].m4, 7)) { + if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m4, 7)) { _m[tile].m4 = OWNER_TOWN; } /* FALLTHROUGH */ @@ -1258,8 +1255,6 @@ bool AfterLoadGame() { TileIndex map_size = MapSize(); - Window *w; - ViewPort *vp; Player *p; /* in version 2.1 of the savegame, town owner was unified. */ @@ -1343,22 +1338,6 @@ return false; } - /* Initialize windows */ - ResetWindowSystem(); - SetupColorsAndInitialWindow(); - - w = FindWindowById(WC_MAIN_WINDOW, 0); - - WP(w,vp_d).scrollpos_x = _saved_scrollpos_x; - WP(w,vp_d).scrollpos_y = _saved_scrollpos_y; - WP(w,vp_d).dest_scrollpos_x = _saved_scrollpos_x; - WP(w,vp_d).dest_scrollpos_y = _saved_scrollpos_y; - - vp = w->viewport; - vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX); - 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 */ if (CheckSavegameVersionOldStyle(4, 1)) CheckIsPlayerActive(); @@ -1373,9 +1352,6 @@ if (!_players[0].is_active && (!_networking || (_networking && _network_server && !_network_dedicated))) DoStartupNewPlayer(false); - DoZoomInOutWindow(ZOOM_NONE, w); // update button status - MarkWholeScreenDirty(); - if (CheckSavegameVersion(72)) { /* Locks/shiplifts in very old savegames had OWNER_WATER as owner */ for (TileIndex t = 0; t < MapSize(); t++) { @@ -1387,7 +1363,7 @@ break; case MP_STATION: { - if (HASBIT(_m[t].m6, 3)) SETBIT(_m[t].m6, 2); + if (HasBit(_m[t].m6, 3)) SetBit(_m[t].m6, 2); StationGfx gfx = GetStationGfx(t); StationType st; if ( IS_INT_INSIDE(gfx, 0, 8)) { // Railway station @@ -1546,10 +1522,10 @@ 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)) { + } 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); + ClrBit(_m[t].m5, 2); + ClrBit(_m[t].m5, 6); } break; @@ -1592,7 +1568,7 @@ case MP_TUNNELBRIDGE: /* Middle part of "old" bridges */ - if (old_bridge && IsBridgeTile(t) && HASBIT(_m[t].m5, 6)) break; + if (old_bridge && IsBridgeTile(t) && HasBit(_m[t].m5, 6)) break; if ((IsTunnel(t) ? GetTunnelTransportType(t) : (old_bridge ? (TransportType)GB(_m[t].m5, 1, 2) : GetBridgeTransportType(t))) == TRANSPORT_ROAD) { SetRoadTypes(t, ROADTYPES_ROAD); } @@ -1609,10 +1585,10 @@ for (TileIndex t = 0; t < map_size; t++) { if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t); if (IsBridgeTile(t)) { - if (HASBIT(_m[t].m5, 6)) { // middle part + if (HasBit(_m[t].m5, 6)) { // middle part Axis axis = (Axis)GB(_m[t].m5, 0, 1); - if (HASBIT(_m[t].m5, 5)) { // transport route under bridge? + if (HasBit(_m[t].m5, 5)) { // transport route under bridge? if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) { MakeRailNormal( t, @@ -1750,7 +1726,7 @@ if (wp->deleted == 0) { const StationSpec *statspec = NULL; - if (HASBIT(_m[wp->xy].m3, 4)) + if (HasBit(_m[wp->xy].m3, 4)) statspec = GetCustomStationSpec(STAT_CLASS_WAYP, _m[wp->xy].m4 + 1); if (statspec != NULL) { @@ -1784,27 +1760,27 @@ case MP_RAILWAY: if (HasSignals(t)) { /* convert PBS signals to combo-signals */ - if (HASBIT(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO); + if (HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO); /* move the signal variant back */ - SetSignalVariant(t, TRACK_X, HASBIT(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); - CLRBIT(_m[t].m2, 3); + SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC); + ClrBit(_m[t].m2, 3); } /* Clear PBS reservation on track */ if (!IsTileDepotType(t, TRANSPORT_RAIL)) { SB(_m[t].m4, 4, 4, 0); } else { - CLRBIT(_m[t].m3, 6); + ClrBit(_m[t].m3, 6); } break; case MP_ROAD: /* Clear PBS reservation on crossing */ - if (IsLevelCrossing(t)) CLRBIT(_m[t].m5, 0); + if (IsLevelCrossing(t)) ClrBit(_m[t].m5, 0); break; case MP_STATION: /* Clear PBS reservation on station */ - CLRBIT(_m[t].m3, 6); + ClrBit(_m[t].m3, 6); break; default: break; @@ -1950,12 +1926,12 @@ } else { /* The "lift has destination" bit has been moved from * m5[7] to m7[0]. */ - SB(_me[t].m7, 0, 1, HASBIT(_m[t].m5, 7)); - CLRBIT(_m[t].m5, 7); + SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7)); + ClrBit(_m[t].m5, 7); /* The "lift is moving" bit has been removed, as it does * the same job as the "lift has destination" bit. */ - CLRBIT(_m[t].m1, 7); + ClrBit(_m[t].m1, 7); /* The position of the lift goes from m1[7..0] to m6[7..2], * making m1 totally free, now. The lift position does not @@ -2049,9 +2025,9 @@ const CargoList::List *packets = v->cargo.Packets(); for (CargoList::List::const_iterator it = packets->begin(); it != packets->end(); it++) { CargoPacket *cp = *it; - cp->paid_for = HASBIT(v->vehicle_flags, 2); + cp->paid_for = HasBit(v->vehicle_flags, 2); } - CLRBIT(v->vehicle_flags, 2); + ClrBit(v->vehicle_flags, 2); v->cargo.InvalidateCache(); } } @@ -2061,7 +2037,7 @@ if (CheckSavegameVersion(46)) { Station *st; FOR_ALL_STATIONS(st) { - if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE)) SetTileOwner(st->xy, OWNER_WATER); + if (st->IsBuoy() && IsTileOwner(st->xy, OWNER_NONE) && TileHeight(st->xy) == 0) SetTileOwner(st->xy, OWNER_WATER); } } @@ -2113,7 +2089,7 @@ /* 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); + ClrBit(v->vehicle_flags, VF_LOADING_FINISHED); } } } else if (CheckSavegameVersion(59)) { @@ -2148,7 +2124,7 @@ SetSignalStates(t, GB(_m[t].m2, 4, 4)); SetSignalVariant(t, INVALID_TRACK, GetSignalVariant(t, TRACK_X)); SetSignalType(t, INVALID_TRACK, GetSignalType(t, TRACK_X)); - CLRBIT(_m[t].m2, 7); + ClrBit(_m[t].m2, 7); } } } @@ -2158,7 +2134,7 @@ Vehicle *v; FOR_ALL_VEHICLES(v) { if (v->type == VEH_ROAD && (v->u.road.state == 250 || v->u.road.state == 251)) { - SETBIT(v->u.road.state, RVS_IS_STOPPING); + SetBit(v->u.road.state, RVS_IS_STOPPING); } } } @@ -2182,25 +2158,12 @@ } } - /* 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(74)) { Station *st; FOR_ALL_STATIONS(st) { for (CargoID c = 0; c < NUM_CARGO; c++) { st->goods[c].last_speed = 0; - if (st->goods[c].cargo.Count() != 0) SETBIT(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); + if (st->goods[c].cargo.Count() != 0) SetBit(st->goods[c].acceptance_pickup, GoodsEntry::PICKUP); } } } @@ -2232,6 +2195,38 @@ } } + /* Initialize windows */ + ResetWindowSystem(); + SetupColorsAndInitialWindow(); + + Window *w = FindWindowById(WC_MAIN_WINDOW, 0); + + WP(w, vp_d).scrollpos_x = _saved_scrollpos_x; + WP(w, vp_d).scrollpos_y = _saved_scrollpos_y; + WP(w, vp_d).dest_scrollpos_x = _saved_scrollpos_x; + WP(w, vp_d).dest_scrollpos_y = _saved_scrollpos_y; + + ViewPort *vp = w->viewport; + vp->zoom = (ZoomLevel)min(_saved_scrollpos_zoom, ZOOM_LVL_MAX); + vp->virtual_width = ScaleByZoom(vp->width, vp->zoom); + vp->virtual_height = ScaleByZoom(vp->height, vp->zoom); + + DoZoomInOutWindow(ZOOM_NONE, w); // update button status + MarkWholeScreenDirty(); + + /* 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; }