Loading

Paste #pzafzgnpd

  1. Index: src/fios.h
  2. ===================================================================
  3. --- src/fios.h  (revision 27726)
  4. +++ src/fios.h  (working copy)
  5. @@ -81,10 +81,9 @@
  6.  
  7.  enum FileSlots {
  8.     /**
  9. -    * Slot used for the GRF scanning and such. This slot cannot be reused
  10. -    * as it will otherwise cause issues when pressing "rescan directories".
  11. -    * It can furthermore not be larger than LAST_GRF_SLOT as that complicates
  12. -    * the testing for "too much NewGRFs".
  13. +    * Slot used for the GRF scanning and such.
  14. +    * This slot is used for all temporary accesses to files when scanning/testing files,
  15. +    * and thus cannot be used for any long-term usage.
  16.      */
  17.     CONFIG_SLOT    =  0,
  18.     /** Slot for the sound. */
  19. @@ -91,10 +90,8 @@
  20.     SOUND_SLOT     =  1,
  21.     /** First slot usable for (New)GRFs used during the game. */
  22.     FIRST_GRF_SLOT =  2,
  23. -   /** Last slot usable for (New)GRFs used during the game. */
  24. -   LAST_GRF_SLOT  = 63,
  25.     /** Maximum number of slots. */
  26. -   MAX_FILE_SLOTS = 64
  27. +   MAX_FILE_SLOTS = 128,
  28.  };
  29.  
  30.  /** Deals with finding savegames */
  31. Index: src/network/core/config.h
  32. ===================================================================
  33. --- src/network/core/config.h   (revision 27726)
  34. +++ src/network/core/config.h   (working copy)
  35. @@ -55,8 +55,7 @@
  36.  
  37.  /**
  38.   * Maximum number of GRFs that can be sent.
  39. - * This value is related to number of handles (files) OpenTTD can open.
  40. - * This is currently 64. Two are used for configuration and sound.
  41. + * This limit is reached when PACKET_UDP_SERVER_RESPONSE reaches the maximum size of SEND_MTU bytes.
  42.   */
  43.  static const uint NETWORK_MAX_GRF_COUNT           =   62;
  44.  
  45. Index: src/newgrf.cpp
  46. ===================================================================
  47. --- src/newgrf.cpp  (revision 27726)
  48. +++ src/newgrf.cpp  (working copy)
  49. @@ -8860,7 +8860,7 @@
  50.         if (stage == GLS_ACTIVATION && !HasBit(config->flags, GCF_RESERVED)) return;
  51.     }
  52.  
  53. -   if (file_index > LAST_GRF_SLOT) {
  54. +   if (file_index >= MAX_FILE_SLOTS) {
  55.         DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", filename);
  56.         config->status = GCS_DISABLED;
  57.         config->error  = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
  58. @@ -9263,6 +9263,7 @@
  59.         }
  60.  
  61.         uint slot = file_index;
  62. +       uint num_non_static = 0;
  63.  
  64.         _cur.stage = stage;
  65.         for (GRFConfig *c = _grfconfig; c != NULL; c = c->next) {
  66. @@ -9277,6 +9278,16 @@
  67.             }
  68.  
  69.             if (stage == GLS_LABELSCAN) InitNewGRFFile(c);
  70. +
  71. +           if (!HasBit(c->flags, GCF_STATIC) && !HasBit(c->flags, GCF_SYSTEM)) {
  72. +               if (num_non_static == NETWORK_MAX_GRF_COUNT) {
  73. +                   DEBUG(grf, 0, "'%s' is not loaded as the maximum number of GRFs has been reached", c->filename);
  74. +                   c->status = GCS_DISABLED;
  75. +                   c->error  = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
  76. +                   continue;
  77. +               }
  78. +               num_non_static++;
  79. +           }
  80.             LoadNewGRFFile(c, slot++, stage, subdir);
  81.             if (stage == GLS_RESERVE) {
  82.                 SetBit(c->flags, GCF_RESERVED);
  83. Index: src/newgrf_gui.cpp
  84. ===================================================================
  85. --- src/newgrf_gui.cpp  (revision 27726)
  86. +++ src/newgrf_gui.cpp  (working copy)
  87. @@ -39,10 +39,6 @@
  88.  #include <map>
  89.  #include "safeguards.h"
  90.  
  91. -/* Maximum number of NewGRFs that may be loaded. Six reserved slots are:
  92. - * 0 - config, 1 - sound, 2 - base, 3 - logos, 4 - climate, 5 - extra */
  93. -static const int MAX_NEWGRFS = MAX_FILE_SLOTS - 6;
  94. -
  95.  /**
  96.   * Show the first NewGRF error we can find.
  97.   */
  98. @@ -1509,7 +1505,7 @@
  99.     {
  100.         if (this->avail_sel == NULL || !this->editable || HasBit(this->avail_sel->flags, GCF_INVALID)) return false;
  101.  
  102. -       int count = 0;
  103. +       uint count = 0;
  104.         GRFConfig **entry = NULL;
  105.         GRFConfig **list;
  106.         /* Find last entry in the list, checking for duplicate grfid on the way */
  107. @@ -1522,7 +1518,7 @@
  108.             count++;
  109.         }
  110.         if (entry == NULL) entry = list;
  111. -       if (count >= MAX_NEWGRFS) {
  112. +       if (count >= NETWORK_MAX_GRF_COUNT) {
  113.             ShowErrorMessage(STR_NEWGRF_TOO_MANY_NEWGRFS, INVALID_STRING_ID, WL_INFO);
  114.             return false;
  115.         }
  116.  

Comments