Loading

Paste #pebfvml1q

  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,9 +2511,17 @@
  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. +   bool self_canal = true;
  73.  
  74. -   ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR);
  75. -   if (ret.Failed()) return ret;
  76. +   if (o_wc != OWNER_NONE || (o_wc == OWNER_NONE && !IsWater(tile_cur))) { // do not demolish canal of OWNER_NONE, but check for clearance
  77. +       ret = DoCommand(tile_cur, 0, 0, flags, CMD_LANDSCAPE_CLEAR); // this demolishes own canal if it succeeds
  78. +       if (ret.Failed() && !IsCanal(tile_cur)) {
  79. +           return ret;
  80. +       } else {
  81. +           if (ret.Succeeded()) self_canal = false;
  82. +       }
  83. +   }
  84.  
  85.     tile_cur += TileOffsByDiagDir(direction);
  86.     if (!IsTileType(tile_cur, MP_WATER) || !IsTileFlat(tile_cur)) {
  87. @@ -2544,7 +2552,7 @@
  88.  
  89.         /* If the water part of the dock is on a canal, update infrastructure counts.
  90.          * This is needed as we've unconditionally cleared that tile before. */
  91. -       if (wc == WATER_CLASS_CANAL) {
  92. +       if (wc == WATER_CLASS_CANAL && o_wc != OWNER_NONE && !self_canal) {
  93.             Company::Get(st->owner)->infrastructure.water++;
  94.         }
  95.         Company::Get(st->owner)->infrastructure.station += 2;
  96. @@ -2587,7 +2595,7 @@
  97.     if (flags & DC_EXEC) {
  98.         DoClearSquare(tile1);
  99.         MarkTileDirtyByTile(tile1);
  100. -       MakeWaterKeepingClass(tile2, st->owner);
  101. +       MakeWaterKeepingClass(tile2, GetTileOwner(tile2));
  102.  
  103.         st->rect.AfterRemoveTile(st, tile1);
  104.         st->rect.AfterRemoveTile(st, tile2);
  105. @@ -3993,11 +4001,16 @@
  106.         }
  107.  
  108.         /* Update station tile count. */
  109. -       if (!IsBuoy(tile) && !IsAirport(tile)) {
  110. +       if (!IsBuoy(tile) && !IsAirport(tile) && !IsDock(tile)) {
  111.             old_company->infrastructure.station--;
  112.             new_company->infrastructure.station++;
  113.         }
  114.  
  115. +       if (IsDockTile(tile) && !HasTileWaterGround(tile)) {
  116. +           old_company->infrastructure.station -= 2;
  117. +           new_company->infrastructure.station += 2;
  118. +       }
  119. +
  120.         /* for buoys, owner of tile is owner of water, st->owner == OWNER_NONE */
  121.         SetTileOwner(tile, new_owner);
  122.         InvalidateWindowClassesData(WC_STATION_LIST, 0);
  123. Index: src/station_map.h
  124. ===================================================================
  125. --- src/station_map.h   (revision 27203)
  126. +++ src/station_map.h   (working copy)
  127. @@ -650,7 +650,7 @@
  128.  static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
  129.  {
  130.     MakeStation(t, o, sid, STATION_DOCK, d);
  131. -   MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
  132. +   MakeStation(t + TileOffsByDiagDir(d), IsWaterTile(t + TileOffsByDiagDir(d)) ? GetTileOwner (t + TileOffsByDiagDir(d)) : o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
  133.  }
  134.  
  135.  /**

Comments