Loading

Paste #p1hzxewop

  1. Index: src/saveload/afterload.cpp
  2. ===================================================================
  3. --- src/saveload/afterload.cpp  (revision 27203)
  4. +++ src/saveload/afterload.cpp  (working copy)
  5. @@ -2985,6 +2985,17 @@
  6.     ResetSignalHandlers();
  7.  
  8.     AfterLoadLinkGraphs();
  9. +
  10. +   if (IsSavegameVersionBefore(195)) {
  11. +       for (TileIndex t = 0; t < map_size; t++) {
  12. +           if (IsDockTile(t) && HasTileWaterGround(t)) {
  13. +               if (HasTileWaterClass(t) && !GetWaterClass(t) == WATER_CLASS_CANAL) {
  14. +                   SetTileOwner(t, OWNER_WATER);
  15. +               }
  16. +           }
  17. +       }
  18. +   }
  19. +
  20.     return true;
  21.  }
  22.  
  23. Index: src/saveload/company_sl.cpp
  24. ===================================================================
  25. --- src/saveload/company_sl.cpp (revision 27203)
  26. +++ src/saveload/company_sl.cpp (working copy)
  27. @@ -141,7 +141,7 @@
  28.  
  29.             case MP_STATION:
  30.                 c = Company::GetIfValid(GetTileOwner(tile));
  31. -               if (c != NULL && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile)) c->infrastructure.station++;
  32. +               if (c != NULL && GetStationType(tile) != STATION_AIRPORT && !IsBuoy(tile) && !IsDock(tile)) c->infrastructure.station++;
  33.  
  34.                 switch (GetStationType(tile)) {
  35.                     case STATION_RAIL:
  36. @@ -161,6 +161,11 @@
  37.                     }
  38.  
  39.                     case STATION_DOCK:
  40. +                       if (IsDockTile(tile) && !HasTileWaterGround(tile)) {
  41. +                           if (c != NULL) c->infrastructure.station += 2;
  42. +                       }
  43. +                       /* FALL THROUGH */
  44. +
  45.                     case STATION_BUOY:
  46.                         if (GetWaterClass(tile) == WATER_CLASS_CANAL) {
  47.                             if (c != NULL) c->infrastructure.water++;
  48. Index: src/saveload/saveload.cpp
  49. ===================================================================
  50. --- src/saveload/saveload.cpp   (revision 27203)
  51. +++ src/saveload/saveload.cpp   (working copy)
  52. @@ -262,8 +262,9 @@
  53.   *  192   26700
  54.   *  193   26802
  55.   *  194   26881   1.5.x
  56. + *  195   27202M
  57.   */
  58. -extern const uint16 SAVEGAME_VERSION = 194; ///< Current savegame version of OpenTTD.
  59. +extern const uint16 SAVEGAME_VERSION = 195; ///< Current savegame version of OpenTTD.
  60.  
  61.  SavegameType _savegame_type; ///< type of savegame we are loading
  62.  
  63. Index: src/station_cmd.cpp
  64. ===================================================================
  65. --- src/station_cmd.cpp (revision 27203)
  66. +++ src/station_cmd.cpp (working copy)
  67. @@ -2511,10 +2511,13 @@
  68.  
  69.     /* Get the water class of the water tile before it is cleared.*/
  70.     WaterClass wc = GetWaterClass(tile_cur);
  71. +   Owner o_wc = GetTileOwner(tile_cur);
  72. +  
  73. +   if (o_wc != OWNER_NONE) {
  74. +       ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  75. +       if (ret.Failed() && !IsCanal(tile_cur)) return ret;
  76. +   }
  77.  
  78. -   ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  79. -   if (ret.Failed()) return ret;
  80. -
  81.     tile_cur += TileOffsByDiagDir(direction);
  82.     if (!IsTileType(tile_cur, MP_WATER) || !IsTileFlat(tile_cur)) {
  83.         return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
  84. @@ -2544,7 +2547,7 @@
  85.  
  86.         /* If the water part of the dock is on a canal, update infrastructure counts.
  87.          * This is needed as we've unconditionally cleared that tile before. */
  88. -       if (wc == WATER_CLASS_CANAL) {
  89. +       if (wc == WATER_CLASS_CANAL && o_wc != OWNER_NONE && ) {
  90.             Company::Get(st->owner)->infrastructure.water++;
  91.         }
  92.         Company::Get(st->owner)->infrastructure.station += 2;
  93. @@ -2587,7 +2590,7 @@
  94.     if (flags & DC_EXEC) {
  95.         DoClearSquare(tile1);
  96.         MarkTileDirtyByTile(tile1);
  97. -       MakeWaterKeepingClass(tile2, st->owner);
  98. +       MakeWaterKeepingClass(tile2, GetTileOwner(tile2));
  99.  
  100.         st->rect.AfterRemoveTile(st, tile1);
  101.         st->rect.AfterRemoveTile(st, tile2);
  102. @@ -3993,11 +3996,16 @@
  103.         }
  104.  
  105.         /* Update station tile count. */
  106. -       if (!IsBuoy(tile) && !IsAirport(tile)) {
  107. +       if (!IsBuoy(tile) && !IsAirport(tile) && !IsDock(tile)) {
  108.             old_company->infrastructure.station--;
  109.             new_company->infrastructure.station++;
  110.         }
  111.  
  112. +       if (IsDockTile(tile) && !HasTileWaterGround(tile)) {
  113. +           old_company->infrastructure.station -= 2;
  114. +           new_company->infrastructure.station += 2;
  115. +       }
  116. +
  117.         /* for buoys, owner of tile is owner of water, st->owner == OWNER_NONE */
  118.         SetTileOwner(tile, new_owner);
  119.         InvalidateWindowClassesData(WC_STATION_LIST, 0);
  120. Index: src/station_map.h
  121. ===================================================================
  122. --- src/station_map.h   (revision 27203)
  123. +++ src/station_map.h   (working copy)
  124. @@ -650,7 +650,7 @@
  125.  static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
  126.  {
  127.     MakeStation(t, o, sid, STATION_DOCK, d);
  128. -   MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
  129. +   MakeStation(t + TileOffsByDiagDir(d), IsWaterTile(t + TileOffsByDiagDir(d)) ? GetTileOwner (t + TileOffsByDiagDir(d)) : o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
  130.  }
  131.  
  132.  /**

Comments