OpenTTD Source 20260721-master-g25ec12c62d
base_media_func.h File Reference

Generic function implementations for base data (graphics, sounds). More...

#include "base_media_base.h"
#include "debug.h"
#include "ini_type.h"
#include "string_func.h"
#include "error_func.h"
#include "core/string_consumer.hpp"
#include "3rdparty/fmt/ranges.h"
#include "network/core/tcp_content_type.h"

Go to the source code of this file.

Functions

void CheckExternalFiles ()
 Checks whether the MD5 checksums of the files are correct.
constexpr uint32_t DecodeShortName (std::string_view shortname)
 Helper to decode a 4 character short name into an uint32_t representation.
template<class Tbase_set>
std::optional< std::string_view > TryGetBaseSetFile (const ContentInfo &ci, bool md5sum, std::span< const std::unique_ptr< Tbase_set > > sets)
 Check whether there's a base set matching some information.

Detailed Description

Generic function implementations for base data (graphics, sounds).

Definition in file base_media_func.h.

Function Documentation

◆ CheckExternalFiles()

void CheckExternalFiles ( )
extern

Checks whether the MD5 checksums of the files are correct.

Note
Also checks sample.cat and other required non-NewGRF GRFs for corruption.

Definition at line 112 of file gfxinit.cpp.

References Baseset, BaseSet< SoundsSet >::CheckMD5(), GraphicsSet::CheckMD5(), Debug, BaseSet< T >::files, BaseSet< T >::GetNumInvalid(), BaseMedia< GraphicsSet >::GetUsedSet(), BaseMedia< SoundsSet >::GetUsedSet(), MD5File::Match, MD5File::Mismatch, BaseSet< T >::name, and BaseSet< SoundsSet >::NUM_FILES.

Referenced by BaseMedia< Tbase_set >::SetSet().

◆ DecodeShortName()

uint32_t DecodeShortName ( std::string_view shortname)
constexpr

Helper to decode a 4 character short name into an uint32_t representation.

Parameters
shortnameThe short name.
Returns
The uint32_t representation.

Definition at line 55 of file base_media_func.h.

◆ TryGetBaseSetFile()

template<class Tbase_set>
std::optional< std::string_view > TryGetBaseSetFile ( const ContentInfo & ci,
bool md5sum,
std::span< const std::unique_ptr< Tbase_set > > sets )

Check whether there's a base set matching some information.

Parameters
ciThe content info to compare it to.
md5sumShould the MD5 checksum be tested as well?
setsThe span with sets.
Returns
The filename of the first file of the base set, or std::nullopt if there is no match.

Definition at line 341 of file base_media_func.h.

References MD5File::hash, ContentInfo::md5sum, and ContentInfo::unique_id.

Referenced by ContentInfo::GetTextfile(), and BaseMedia< Tbase_set >::HasSet().