mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-20 02:42:42 +01:00
Codechange: use std::string_view over const char *
This commit is contained in:
10
src/fios.cpp
10
src/fios.cpp
@@ -672,20 +672,20 @@ static ScenarioScanner _scanner;
|
||||
* Find a given scenario based on its unique ID.
|
||||
* @param ci The content info to compare it to.
|
||||
* @param md5sum Whether to look at the md5sum or the id.
|
||||
* @return The filename of the file, else \c nullptr.
|
||||
* @return The filename of the file, else \c std::nullopt.
|
||||
*/
|
||||
const char *FindScenario(const ContentInfo &ci, bool md5sum)
|
||||
std::optional<std::string_view> FindScenario(const ContentInfo &ci, bool md5sum)
|
||||
{
|
||||
_scanner.Scan(false);
|
||||
|
||||
for (ScenarioIdentifier &id : _scanner) {
|
||||
if (md5sum ? (id.md5sum == ci.md5sum)
|
||||
: (id.scenid == ci.unique_id)) {
|
||||
return id.filename.c_str();
|
||||
return id.filename;
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -696,7 +696,7 @@ const char *FindScenario(const ContentInfo &ci, bool md5sum)
|
||||
*/
|
||||
bool HasScenario(const ContentInfo &ci, bool md5sum)
|
||||
{
|
||||
return (FindScenario(ci, md5sum) != nullptr);
|
||||
return FindScenario(ci, md5sum).has_value();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user