Loading

Paste #pq0jfvbnu

  1. Index: src/gfxinit.cpp
  2. ===================================================================
  3. --- src/gfxinit.cpp (revision 27730)
  4. +++ src/gfxinit.cpp (working copy)
  5. @@ -230,6 +230,14 @@
  6.  
  7.     LoadNewGRF(SPR_NEWGRFS_BASE, i, 2);
  8.  
  9. +   uint total_extra_graphics = SPR_NEWGRFS_BASE - SPR_OPENTTD_BASE;
  10. +   _missing_extra_graphics = GetSpriteCountForSlot(i, SPR_OPENTTD_BASE, SPR_NEWGRFS_BASE);
  11. +   DEBUG(sprite, 1, "%u extra sprites, %u from baseset, %u from fallback", total_extra_graphics, total_extra_graphics - _missing_extra_graphics, _missing_extra_graphics);
  12. +
  13. +   /* The original baseset extra graphics intentionally make use of the fallback graphics.
  14. +    * Let's say everything which provides less than 500 sprites misses the rest intentionally. */
  15. +   if (500 + _missing_extra_graphics > total_extra_graphics) _missing_extra_graphics = 0;
  16. +
  17.     /* Free and remove the top element. */
  18.     delete extra;
  19.     delete master;
  20. Index: src/intro_gui.cpp
  21. ===================================================================
  22. --- src/intro_gui.cpp   (revision 27730)
  23. +++ src/intro_gui.cpp   (working copy)
  24. @@ -60,13 +60,21 @@
  25.  
  26.     virtual void OnInit()
  27.     {
  28. -       bool missing = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
  29. -       this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing ? 0 : SZSP_NONE);
  30. +       bool missing_sprites = _missing_extra_graphics > 0 && !IsReleasedVersion();
  31. +       this->GetWidget<NWidgetStacked>(WID_SGI_BASESET_SELECTION)->SetDisplayedPlane(missing_sprites ? 0 : SZSP_NONE);
  32. +
  33. +       bool missing_lang = _current_language->missing >= _settings_client.gui.missing_strings_threshold && !IsReleasedVersion();
  34. +       this->GetWidget<NWidgetStacked>(WID_SGI_TRANSLATION_SELECTION)->SetDisplayedPlane(missing_lang ? 0 : SZSP_NONE);
  35.     }
  36.  
  37.     virtual void DrawWidget(const Rect &r, int widget) const
  38.     {
  39.         switch (widget) {
  40. +           case WID_SGI_BASESET:
  41. +               SetDParam(0, _missing_extra_graphics);
  42. +               DrawStringMultiLine(r.left, r.right, r.top,  r.bottom, STR_INTRO_BASESET, TC_FROMSTRING, SA_CENTER);
  43. +               break;
  44. +
  45.             case WID_SGI_TRANSLATION:
  46.                 SetDParam(0, _current_language->missing);
  47.                 DrawStringMultiLine(r.left, r.right, r.top,  r.bottom, STR_INTRO_TRANSLATION, TC_FROMSTRING, SA_CENTER);
  48. @@ -76,20 +84,29 @@
  49.  
  50.     virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
  51.     {
  52. +       StringID str = 0;
  53.         switch (widget) {
  54. -           case WID_SGI_TRANSLATION: {
  55. +           case WID_SGI_BASESET:
  56. +               SetDParam(0, _missing_extra_graphics);
  57. +               str = STR_INTRO_BASESET;
  58. +               break;
  59. +
  60. +           case WID_SGI_TRANSLATION:
  61.                 SetDParam(0, _current_language->missing);
  62. -               int height = GetStringHeight(STR_INTRO_TRANSLATION, size->width);
  63. -               if (height > 3 * FONT_HEIGHT_NORMAL) {
  64. -                   /* Don't let the window become too high. */
  65. -                   Dimension textdim = GetStringBoundingBox(STR_INTRO_TRANSLATION);
  66. -                   textdim.height *= 3;
  67. -                   textdim.width -= textdim.width / 2;
  68. -                   *size = maxdim(*size, textdim);
  69. -               } else {
  70. -                   size->height = height + padding.height;
  71. -               }
  72. +               str = STR_INTRO_TRANSLATION;
  73.                 break;
  74. +       }
  75. +
  76. +       if (str != 0) {
  77. +           int height = GetStringHeight(str, size->width);
  78. +           if (height > 3 * FONT_HEIGHT_NORMAL) {
  79. +               /* Don't let the window become too high. */
  80. +               Dimension textdim = GetStringBoundingBox(str);
  81. +               textdim.height *= 3;
  82. +               textdim.width -= textdim.width / 2;
  83. +               *size = maxdim(*size, textdim);
  84. +           } else {
  85. +               size->height = height + padding.height;
  86.             }
  87.         }
  88.     }
  89. @@ -199,6 +216,11 @@
  90.     EndContainer(),
  91.  
  92.     NWidget(NWID_SPACER), SetMinimalSize(0, 7),
  93. +   NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SGI_BASESET_SELECTION),
  94. +       NWidget(NWID_VERTICAL),
  95. +           NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_BASESET), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
  96. +       EndContainer(),
  97. +   EndContainer(),
  98.     NWidget(NWID_SELECTION, INVALID_COLOUR, WID_SGI_TRANSLATION_SELECTION),
  99.         NWidget(NWID_VERTICAL),
  100.             NWidget(WWT_EMPTY, COLOUR_ORANGE, WID_SGI_TRANSLATION), SetMinimalSize(316, 12), SetFill(1, 0), SetPadding(0, 10, 7, 10),
  101. Index: src/lang/english.txt
  102. ===================================================================
  103. --- src/lang/english.txt    (revision 27730)
  104. +++ src/lang/english.txt    (working copy)
  105. @@ -1761,6 +1761,7 @@
  106.  STR_INTRO_TOOLTIP_SCRIPT_SETTINGS                               :{BLACK}Display AI/Game script settings
  107.  STR_INTRO_TOOLTIP_QUIT                                          :{BLACK}Exit 'OpenTTD'
  108.  
  109. +STR_INTRO_BASESET                                               :{BLACK}The currently selected base graphics set is missing {NUM} sprite{P "" s}. Please check for updates for the baseset.
  110.  STR_INTRO_TRANSLATION                                           :{BLACK}This translation misses {NUM} string{P "" s}. Please help make OpenTTD better by signing up as translator. See readme.txt for details.
  111.  
  112.  # Quit window
  113. @@ -2907,8 +2908,6 @@
  114.  STR_NEWGRF_ERROR_CORRUPT_SPRITE                                 :{YELLOW}{RAW_STRING} contains a corrupt sprite. All corrupt sprites will be shown as a red question mark (?)
  115.  STR_NEWGRF_ERROR_MULTIPLE_ACTION_8                              :Contains multiple Action 8 entries (sprite {3:NUM})
  116.  STR_NEWGRF_ERROR_READ_BOUNDS                                    :Read past end of pseudo-sprite (sprite {3:NUM})
  117. -STR_NEWGRF_ERROR_MISSING_SPRITES                                :{WHITE}The currently used base graphics set is missing a number of sprites.{}Please update the base graphics set
  118. -STR_NEWGRF_ERROR_MISSING_SPRITES_UNSTABLE                       :{WHITE}The currently used base graphics set is missing a number of sprites.{}Please update the base graphics set.{}Since you are playing a {YELLOW}development snapshot of OpenTTD{WHITE}, you might also need a {YELLOW}development snapshot of the base graphics{WHITE}
  119.  STR_NEWGRF_ERROR_GRM_FAILED                                     :Requested GRF resources not available (sprite {3:NUM})
  120.  STR_NEWGRF_ERROR_FORCEFULLY_DISABLED                            :{1:RAW_STRING} was disabled by {2:RAW_STRING}
  121.  STR_NEWGRF_ERROR_INVALID_SPRITE_LAYOUT                          :Invalid/unknown sprite layout format (sprite {3:NUM})
  122. Index: src/newgrf.cpp
  123. ===================================================================
  124. --- src/newgrf.cpp  (revision 27730)
  125. +++ src/newgrf.cpp  (working copy)
  126. @@ -5694,35 +5694,6 @@
  127.  }
  128.  
  129.  /**
  130. - * Check whether we are (obviously) missing some of the extra
  131. - * (Action 0x05) sprites that we like to use.
  132. - * When missing sprites are found a warning will be shown.
  133. - */
  134. -void CheckForMissingSprites()
  135. -{
  136. -   /* Don't break out quickly, but allow to check the other
  137. -    * sprites as well, so we can give the best information. */
  138. -   bool missing = false;
  139. -   for (uint8 i = 0; i < lengthof(_action5_types); i++) {
  140. -       const Action5Type *type = &_action5_types[i];
  141. -       if (type->block_type == A5BLOCK_INVALID) continue;
  142. -
  143. -       for (uint j = 0; j < type->max_sprites; j++) {
  144. -           if (!SpriteExists(type->sprite_base + j)) {
  145. -               DEBUG(grf, 0, "%s sprites are missing", type->name);
  146. -               missing = true;
  147. -               /* No need to log more of the same. */
  148. -               break;
  149. -           }
  150. -       }
  151. -   }
  152. -
  153. -   if (missing) {
  154. -       ShowErrorMessage(IsReleasedVersion() ? STR_NEWGRF_ERROR_MISSING_SPRITES : STR_NEWGRF_ERROR_MISSING_SPRITES_UNSTABLE, INVALID_STRING_ID, WL_CRITICAL);
  155. -   }
  156. -}
  157. -
  158. -/**
  159.   * Reads a variable common to VarAction2 and Action7/9/D.
  160.   *
  161.   * Returns VarAction2 variable 'param' resp. Action7/9/D variable '0x80 + param'.
  162. Index: src/newgrf_config.cpp
  163. ===================================================================
  164. --- src/newgrf_config.cpp   (revision 27730)
  165. +++ src/newgrf_config.cpp   (working copy)
  166. @@ -192,6 +192,7 @@
  167.  GRFConfig *_grfconfig;
  168.  GRFConfig *_grfconfig_newgame;
  169.  GRFConfig *_grfconfig_static;
  170. +uint _missing_extra_graphics = 0;
  171.  
  172.  /**
  173.   * Construct a new GRFError.
  174. Index: src/newgrf_config.h
  175. ===================================================================
  176. --- src/newgrf_config.h (revision 27730)
  177. +++ src/newgrf_config.h (working copy)
  178. @@ -202,6 +202,7 @@
  179.  extern GRFConfig *_grfconfig;         ///< First item in list of current GRF set up
  180.  extern GRFConfig *_grfconfig_newgame; ///< First item in list of default GRF set up
  181.  extern GRFConfig *_grfconfig_static;  ///< First item in list of static GRF set up
  182. +extern uint _missing_extra_graphics;  ///< Number of sprites provided by the fallback extra GRF, i.e. missing in the baseset.
  183.  
  184.  /** Callback for NewGRF scanning. */
  185.  struct NewGRFScanCallback {
  186. @@ -214,7 +215,6 @@
  187.  size_t GRFGetSizeOfDataSection(FILE *f);
  188.  
  189.  void ScanNewGRFFiles(NewGRFScanCallback *callback);
  190. -void CheckForMissingSprites();
  191.  const GRFConfig *FindGRFConfig(uint32 grfid, FindGRFConfigMode mode, const uint8 *md5sum = NULL, uint32 desired_version = 0);
  192.  GRFConfig *GetGRFConfig(uint32 grfid, uint32 mask = 0xFFFFFFFF);
  193.  GRFConfig **CopyGRFConfigList(GRFConfig **dst, const GRFConfig *src, bool init_only);
  194. Index: src/openttd.cpp
  195. ===================================================================
  196. --- src/openttd.cpp (revision 27730)
  197. +++ src/openttd.cpp (working copy)
  198. @@ -339,7 +339,6 @@
  199.     _pause_mode = PM_UNPAUSED;
  200.     _cursor.fix_at = false;
  201.  
  202. -   if (load_newgrfs) CheckForMissingSprites();
  203.     CheckForMissingGlyphs();
  204.  
  205.     /* Play main theme */
  206. Index: src/script/api/game/game_window.hpp.sq
  207. ===================================================================
  208. --- src/script/api/game/game_window.hpp.sq  (revision 27730)
  209. +++ src/script/api/game/game_window.hpp.sq  (working copy)
  210. @@ -582,6 +582,8 @@
  211.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_ARCTIC_LANDSCAPE,                  "WID_SGI_ARCTIC_LANDSCAPE");
  212.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_TROPIC_LANDSCAPE,                  "WID_SGI_TROPIC_LANDSCAPE");
  213.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_TOYLAND_LANDSCAPE,                 "WID_SGI_TOYLAND_LANDSCAPE");
  214. +   SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_BASESET_SELECTION,                 "WID_SGI_BASESET_SELECTION");
  215. +   SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_BASESET,                           "WID_SGI_BASESET");
  216.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_TRANSLATION_SELECTION,             "WID_SGI_TRANSLATION_SELECTION");
  217.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_TRANSLATION,                       "WID_SGI_TRANSLATION");
  218.     SQGSWindow.DefSQConst(engine, ScriptWindow::WID_SGI_OPTIONS,                           "WID_SGI_OPTIONS");
  219. Index: src/script/api/script_window.hpp
  220. ===================================================================
  221. --- src/script/api/script_window.hpp    (revision 27730)
  222. +++ src/script/api/script_window.hpp    (working copy)
  223. @@ -1497,8 +1497,10 @@
  224.         WID_SGI_ARCTIC_LANDSCAPE                     = ::WID_SGI_ARCTIC_LANDSCAPE,                     ///< Select arctic landscape button.
  225.         WID_SGI_TROPIC_LANDSCAPE                     = ::WID_SGI_TROPIC_LANDSCAPE,                     ///< Select tropic landscape button.
  226.         WID_SGI_TOYLAND_LANDSCAPE                    = ::WID_SGI_TOYLAND_LANDSCAPE,                    ///< Select toyland landscape button.
  227. +       WID_SGI_BASESET_SELECTION                    = ::WID_SGI_BASESET_SELECTION,                    ///< Baseset selection.
  228. +       WID_SGI_BASESET                              = ::WID_SGI_BASESET,                              ///< Baseset errors.
  229.         WID_SGI_TRANSLATION_SELECTION                = ::WID_SGI_TRANSLATION_SELECTION,                ///< Translation selection.
  230. -       WID_SGI_TRANSLATION                          = ::WID_SGI_TRANSLATION,                          ///< Translation.
  231. +       WID_SGI_TRANSLATION                          = ::WID_SGI_TRANSLATION,                          ///< Translation errors.
  232.         WID_SGI_OPTIONS                              = ::WID_SGI_OPTIONS,                              ///< Options button.
  233.         WID_SGI_HIGHSCORE                            = ::WID_SGI_HIGHSCORE,                            ///< Highscore button.
  234.         WID_SGI_SETTINGS_OPTIONS                     = ::WID_SGI_SETTINGS_OPTIONS,                     ///< Settings button.
  235. Index: src/spritecache.cpp
  236. ===================================================================
  237. --- src/spritecache.cpp (revision 27730)
  238. +++ src/spritecache.cpp (working copy)
  239. @@ -150,6 +150,25 @@
  240.  }
  241.  
  242.  /**
  243. + * Count the sprites which originate from a specific file slot in a range of SpriteIDs.
  244. + * @param file_slot FIOS file slot.
  245. + * @param begin First sprite in range.
  246. + * @param end First sprite not in range.
  247. + * @return Number of sprites.
  248. + */
  249. +uint GetSpriteCountForSlot(uint file_slot, SpriteID begin, SpriteID end)
  250. +{
  251. +   uint count = 0;
  252. +   for (SpriteID i = begin; i != end; i++) {
  253. +       if (SpriteExists(i)) {
  254. +           SpriteCache *sc = GetSpriteCache(i);
  255. +           if (sc->file_slot == file_slot) count++;
  256. +       }
  257. +   }
  258. +   return count;
  259. +}
  260. +
  261. +/**
  262.   * Get a reasonable (upper bound) estimate of the maximum
  263.   * SpriteID used in OpenTTD; there will be no sprites with
  264.   * a higher SpriteID, although there might be up to roughly
  265. Index: src/spritecache.h
  266. ===================================================================
  267. --- src/spritecache.h   (revision 27730)
  268. +++ src/spritecache.h   (working copy)
  269. @@ -32,6 +32,7 @@
  270.  
  271.  SpriteType GetSpriteType(SpriteID sprite);
  272.  uint GetOriginFileSlot(SpriteID sprite);
  273. +uint GetSpriteCountForSlot(uint file_slot, SpriteID begin, SpriteID end);
  274.  uint GetMaxSpriteID();
  275.  
  276.  
  277. Index: src/widgets/intro_widget.h
  278. ===================================================================
  279. --- src/widgets/intro_widget.h  (revision 27730)
  280. +++ src/widgets/intro_widget.h  (working copy)
  281. @@ -24,8 +24,10 @@
  282.     WID_SGI_ARCTIC_LANDSCAPE,      ///< Select arctic landscape button.
  283.     WID_SGI_TROPIC_LANDSCAPE,      ///< Select tropic landscape button.
  284.     WID_SGI_TOYLAND_LANDSCAPE,     ///< Select toyland landscape button.
  285. +   WID_SGI_BASESET_SELECTION,     ///< Baseset selection.
  286. +   WID_SGI_BASESET,               ///< Baseset errors.
  287.     WID_SGI_TRANSLATION_SELECTION, ///< Translation selection.
  288. -   WID_SGI_TRANSLATION,           ///< Translation.
  289. +   WID_SGI_TRANSLATION,           ///< Translation errors.
  290.     WID_SGI_OPTIONS,               ///< Options button.
  291.     WID_SGI_HIGHSCORE,             ///< Highscore button.
  292.     WID_SGI_SETTINGS_OPTIONS,      ///< Settings button.
  293.  

Comments