1
0
Fork 0

Compare commits

...

4 Commits

Author SHA1 Message Date
Peter Nelson 8120791f22
Merge 76a35badb0 into 7546c1acab 2025-07-14 08:01:51 +00:00
Peter Nelson 7546c1acab
Codefix f220ed179d: GetUnicodeGlyph takes a unicode character. (#14438)
Previous change erroneously changed type to GlyphID, based on naming. It should actually be char32_t.
2025-07-14 08:01:42 +00:00
Peter Nelson a6143eea21
Codechange: Include more relevant headers for script_storage. (#14437) 2025-07-14 07:49:50 +01:00
Peter Nelson 76a35badb0
Change: Throw out per-grf industry tile limit.
The industry tile limit was set based on the premise that action 3 ids might later be extended. They have since been extended.

Limit is now the total number of custom tiles that can be used.
2024-02-26 08:49:52 +00:00
5 changed files with 19 additions and 19 deletions

View File

@ -43,26 +43,26 @@ SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
}
/**
* Get SpriteID associated with a GlyphID.
* @param key Glyph to find.
* @return SpriteID of glyph, or 0 if not present.
* Get SpriteID associated with a character.
* @param key Character to find.
* @return SpriteID for character, or 0 if not present.
*/
SpriteID SpriteFontCache::GetUnicodeGlyph(GlyphID key)
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key)
{
const auto found = this->glyph_to_spriteid_map.find(key & ~SPRITE_GLYPH);
if (found == std::end(this->glyph_to_spriteid_map)) return 0;
const auto found = this->char_map.find(key);
if (found == std::end(this->char_map)) return 0;
return found->second;
}
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
{
this->glyph_to_spriteid_map[key] = sprite;
this->char_map[key] = sprite;
}
void SpriteFontCache::InitializeUnicodeGlyphMap()
{
/* Clear out existing glyph map if it exists */
this->glyph_to_spriteid_map.clear();
this->char_map.clear();
SpriteID base;
switch (this->fs) {

View File

@ -28,8 +28,8 @@ public:
bool IsBuiltInFont() override { return true; }
private:
std::unordered_map<GlyphID, SpriteID> glyph_to_spriteid_map{}; ///< Mapping of glyphs to sprite IDs.
SpriteID GetUnicodeGlyph(GlyphID key);
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
SpriteID GetUnicodeGlyph(char32_t key);
};
#endif /* SPRITEFONTCACHE_H */

View File

@ -45,13 +45,13 @@ static const IndustryType NEW_INDUSTRYOFFSET = 37; ///< origi
static const IndustryType NUM_INDUSTRYTYPES = 240; ///< total number of industry types, new and old; limited to 240 because we need some special ids like IT_INVALID, IT_AI_UNKNOWN, IT_AI_TOWN, ...
static const IndustryType IT_INVALID = 0xFF;
static const IndustryGfx NUM_INDUSTRYTILES_PER_GRF = 255; ///< Maximum number of industry tiles per NewGRF; limited to 255 to allow extending Action3 with an extended byte later on.
static const IndustryGfx INDUSTRYTILE_NOANIM = 0xFF; ///< flag to mark industry tiles as having no animation
static const IndustryGfx NEW_INDUSTRYTILEOFFSET = 175; ///< original number of tiles
static const IndustryGfx NUM_INDUSTRYTILES = 512; ///< total number of industry tiles, new and old
static const IndustryGfx INVALID_INDUSTRYTILE = NUM_INDUSTRYTILES; ///< one above amount is considered invalid
static const IndustryGfx NUM_INDUSTRYTILES_PER_GRF = NUM_INDUSTRYTILES - NEW_INDUSTRYTILEOFFSET; ///< Maximum number of industry tiles per NewGRF.
static const int INDUSTRY_COMPLETED = 3; ///< final stage of industry construction.
static const int INDUSTRY_NUM_INPUTS = 16; ///< Number of cargo types an industry can accept

View File

@ -24,10 +24,12 @@
#include "api/script_event.hpp"
#include "api/script_log.hpp"
#include "../company_base.h"
#include "../company_func.h"
#include "../company_type.h"
#include "../fileio_func.h"
#include "../goal_type.h"
#include "../league_type.h"
#include "../signs_type.h"
#include "../story_type.h"
#include "../misc/endian_buffer.hpp"
#include "../safeguards.h"

View File

@ -12,12 +12,10 @@
#include <queue>
#include "../signs_func.h"
#include "../vehicle_func.h"
#include "../command_type.h"
#include "../company_type.h"
#include "../rail_type.h"
#include "../road_type.h"
#include "../group.h"
#include "../goal_type.h"
#include "../story_type.h"
#include "script_types.hpp"
#include "script_log_types.hpp"