diff --git a/projects/determineversion.vbs b/projects/determineversion.vbs index 1c6f48552d..692fba65d9 100755 --- a/projects/determineversion.vbs +++ b/projects/determineversion.vbs @@ -96,7 +96,7 @@ Function DetermineSVNVersion() Dim sTortoise ' First, try with 32-bit architecture sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 32) - If sTortoise = "" Then + If sTortoise = "" Or IsNull(sTortoise) Then ' No 32-bit version of TortoiseSVN installed, try 64-bit version (doesn't hurt on 32-bit machines, it returns nothing or is ignored) sTortoise = ReadRegistryKey("HKLM", "SOFTWARE\TortoiseSVN", "Directory", 64) End If diff --git a/src/network/network_command.cpp b/src/network/network_command.cpp index 96b400aa3e..b9983eeedd 100644 --- a/src/network/network_command.cpp +++ b/src/network/network_command.cpp @@ -141,6 +141,7 @@ void NetworkSyncCommandQueue(NetworkClientSocket *cs) for (CommandPacket *p = _local_command_queue; p != NULL; p = p->next) { CommandPacket c = *p; c.callback = 0; + c.next = NULL; NetworkAddCommandQueue(c, cs); } } diff --git a/src/openttd.cpp b/src/openttd.cpp index 731bf763cd..0a5d047a15 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -859,6 +859,50 @@ void StartupCompanies(); void StartupDisasters(); extern void StartupEconomy(); +/** + * Load the specified savegame but on error do different things. + * If loading fails due to corrupt savegame, bad version, etc. go back to + * a previous correct state. In the menu for example load the intro game again. + * @param filename file to be loaded + * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD + * @param newgm switch to this mode of loading fails due to some unknown error + * @param subdir default directory to look for filename, set to 0 if not needed + */ +bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir) +{ + GameMode ogm = _game_mode; + + _game_mode = newgm; + assert(mode == SL_LOAD || mode == SL_OLD_LOAD); + switch (SaveOrLoad(filename, mode, subdir)) { + case SL_OK: return true; + + case SL_REINIT: + if (_network_dedicated) { + /* + * We need to reinit a network map... + * We can't simply load the intro game here as that game has many + * special cases which make clients desync immediately. So we fall + * back to just generating a new game with the current settings. + */ + DEBUG(net, 0, "Loading game failed, so a new (random) game will be started!"); + MakeNewGame(false, true); + return false; + } + + switch (ogm) { + default: + case GM_MENU: LoadIntroGame(); break; + case GM_EDITOR: MakeNewEditorWorld(); break; + } + return false; + + default: + _game_mode = ogm; + return false; + } +} + /** * Start Scenario starts a new game based on a scenario. * Eg 'New Game' --> select a preset scenario @@ -885,10 +929,10 @@ static void StartScenario() ResetGRFConfig(true); /* Load game */ - if (SaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, SCENARIO_DIR) != SL_OK) { - LoadIntroGame(); + if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, SCENARIO_DIR)) { SetDParamStr(0, GetSaveLoadErrorString()); ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, 0, 0); + return; } _settings_game.difficulty = _settings_newgame.difficulty; @@ -907,37 +951,6 @@ static void StartScenario() MarkWholeScreenDirty(); } -/** Load the specified savegame but on error do different things. - * If loading fails due to corrupt savegame, bad version, etc. go back to - * a previous correct state. In the menu for example load the intro game again. - * @param filename file to be loaded - * @param mode mode of loading, either SL_LOAD or SL_OLD_LOAD - * @param newgm switch to this mode of loading fails due to some unknown error - * @param subdir default directory to look for filename, set to 0 if not needed - */ -bool SafeSaveOrLoad(const char *filename, int mode, GameMode newgm, Subdirectory subdir) -{ - GameMode ogm = _game_mode; - - _game_mode = newgm; - assert(mode == SL_LOAD || mode == SL_OLD_LOAD); - switch (SaveOrLoad(filename, mode, subdir)) { - case SL_OK: return true; - - case SL_REINIT: - switch (ogm) { - default: - case GM_MENU: LoadIntroGame(); break; - case GM_EDITOR: MakeNewEditorWorld(); break; - } - return false; - - default: - _game_mode = ogm; - return false; - } -} - void SwitchToMode(SwitchMode new_mode) { #ifdef ENABLE_NETWORK @@ -1002,7 +1015,6 @@ void SwitchToMode(SwitchMode new_mode) ResetWindowSystem(); if (!SafeSaveOrLoad(_file_to_saveload.name, _file_to_saveload.mode, GM_NORMAL, NO_DIRECTORY)) { - LoadIntroGame(); SetDParamStr(0, GetSaveLoadErrorString()); ShowErrorMessage(STR_JUST_RAW_STRING, INVALID_STRING_ID, 0, 0); } else { diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 48054792ce..cf414153b2 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1170,12 +1170,12 @@ static void DrawTile_Road(TileInfo *ti) case ROAD_TILE_CROSSING: { if (ti->tileh != SLOPE_FLAT) DrawFoundation(ti, FOUNDATION_LEVELED); + PaletteID pal = PAL_NONE; const RailtypeInfo *rti = GetRailTypeInfo(GetRailType(ti->tile)); if (rti->UsesOverlay()) { Axis axis = GetCrossingRailAxis(ti->tile); SpriteID road = SPR_ROAD_Y + axis; - PaletteID pal = PAL_NONE; Roadside roadside = GetRoadside(ti->tile); @@ -1194,34 +1194,30 @@ static void DrawTile_Road(TileInfo *ti) SpriteID rail = GetCustomRailSprite(rti, ti->tile, RTSG_CROSSING) + axis; DrawGroundSprite(rail, PAL_NONE); DrawRailTileSeq(ti, &_crossing_layout, TO_CATENARY, rail, 0, PAL_NONE); - - if (HasCatenaryDrawn(GetRailType(ti->tile))) DrawCatenary(ti); - break; - } - - SpriteID image = rti->base_sprites.crossing; - PaletteID pal = PAL_NONE; - - if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; - if (IsCrossingBarred(ti->tile)) image += 2; - - Roadside roadside = GetRoadside(ti->tile); - - if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) { - image += 8; } else { - switch (roadside) { - case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break; - case ROADSIDE_GRASS: break; - default: image += 4; break; // Paved + SpriteID image = rti->base_sprites.crossing; + + if (GetCrossingRoadAxis(ti->tile) == AXIS_X) image++; + if (IsCrossingBarred(ti->tile)) image += 2; + + Roadside roadside = GetRoadside(ti->tile); + + if (AlwaysDrawUnpavedRoads(ti->tile, roadside)) { + image += 8; + } else { + switch (roadside) { + case ROADSIDE_BARREN: pal = PALETTE_TO_BARE_LAND; break; + case ROADSIDE_GRASS: break; + default: image += 4; break; // Paved + } } - } - DrawGroundSprite(image, pal); + DrawGroundSprite(image, pal); - /* PBS debugging, draw reserved tracks darker */ - if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) { - DrawGroundSprite(GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y, PALETTE_CRASH); + /* PBS debugging, draw reserved tracks darker */ + if (_game_mode != GM_MENU && _settings_client.gui.show_track_reservation && HasCrossingReservation(ti->tile)) { + DrawGroundSprite(GetCrossingRoadAxis(ti->tile) == AXIS_Y ? GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_x : GetRailTypeInfo(GetRailType(ti->tile))->base_sprites.single_y, PALETTE_CRASH); + } } if (HasTileRoadType(ti->tile, ROADTYPE_TRAM)) { diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 61e8d4af67..84a65ec1ba 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -1248,8 +1248,12 @@ static WindowDesc _vehicle_list_desc( static void ShowVehicleListWindowLocal(CompanyID company, uint16 VLW_flag, VehicleType vehicle_type, uint16 unique_number) { if (!Company::IsValidID(company)) { - _vehicle_list_desc.flags |= WDF_CONSTRUCTION; company = _local_company; + /* This can happen when opening the vehicle list as a spectator. + * While it would be cleaner to check this somewhere else, having + * it here reduces code duplication */ + if (!Company::IsValidID(company)) return; + _vehicle_list_desc.flags |= WDF_CONSTRUCTION; } else { _vehicle_list_desc.flags &= ~WDF_CONSTRUCTION; }