MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / GetSpriteCountForFile

Function GetSpriteCountForFile

src/spritecache.cpp:176–192  ·  view source on GitHub ↗

* Count the sprites which originate from a specific file in a range of SpriteIDs. * @param file The loaded SpriteFile. * @param begin First sprite in range. * @param end First sprite not in range. * @return Number of sprites. */

Source from the content-addressed store, hash-verified

174 * @return Number of sprites.
175 */
176uint GetSpriteCountForFile(const std::string &filename, SpriteID begin, SpriteID end)
177{
178 SpriteFile *file = GetCachedSpriteFileByName(filename);
179 if (file == nullptr) return 0;
180
181 uint count = 0;
182 for (SpriteID i = begin; i != end; i++) {
183 if (SpriteExists(i)) {
184 SpriteCache *sc = GetSpriteCache(i);
185 if (sc->file == file) {
186 count++;
187 Debug(sprite, 4, "Sprite: {}", i);
188 }
189 }
190 }
191 return count;
192}
193
194/**
195 * Get a reasonable (upper bound) estimate of the maximum

Callers 1

LoadSpriteTablesFunction · 0.85

Calls 3

SpriteExistsFunction · 0.85
GetSpriteCacheFunction · 0.85

Tested by

no test coverage detected