Skip to content

Commit

Permalink
Communicate to the asset loader when parsing localize file failed
Browse files Browse the repository at this point in the history
  • Loading branch information
Laupetin committed Dec 31, 2023
1 parent eb06565 commit 9d0beaa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/ObjLoading/Localize/LocalizeCommonAssetLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ bool LocalizeCommonAssetLoader::LoadLocalizeAsset(const std::string& assetName,

auto* zoneState = manager->GetAssetLoadingContext()->GetZoneAssetLoaderState<LocalizeReadingZoneState>();
LocalizeFileReader reader(*file.m_stream, assetName, zone->m_language, zoneState);
const auto localizeEntries = reader.ReadLocalizeFile();

std::vector<CommonLocalizeEntry> localizeEntries;
if (!reader.ReadLocalizeFile(localizeEntries))
return false;

for (const auto& entry : localizeEntries)
{
Expand Down
9 changes: 6 additions & 3 deletions src/ObjLoading/Localize/Parsing/LocalizeFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void LocalizeFileReader::SetupStreamProxies()
m_stream = m_open_streams.back().get();
}

std::vector<CommonLocalizeEntry> LocalizeFileReader::ReadLocalizeFile()
bool LocalizeFileReader::ReadLocalizeFile(std::vector<CommonLocalizeEntry>& entries)
{
SimpleLexer::Config lexerConfig;
lexerConfig.m_emit_new_line_tokens = true;
Expand All @@ -41,8 +41,11 @@ std::vector<CommonLocalizeEntry> LocalizeFileReader::ReadLocalizeFile()
const auto parser = std::make_unique<LocalizeFileParser>(lexer.get(), m_language, m_zone_state);

if (parser->Parse())
return parser->GetParsedValues();
{
entries = parser->GetParsedValues();
return true;
}

std::cerr << "Parsing localization file failed!" << std::endl;
return std::vector<CommonLocalizeEntry>();
return false;
}
2 changes: 1 addition & 1 deletion src/ObjLoading/Localize/Parsing/LocalizeFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ class LocalizeFileReader
public:
LocalizeFileReader(std::istream& stream, std::string fileName, GameLanguage language, LocalizeReadingZoneState* zoneState);

std::vector<CommonLocalizeEntry> ReadLocalizeFile();
bool ReadLocalizeFile(std::vector<CommonLocalizeEntry>& entries);
};

0 comments on commit 9d0beaa

Please sign in to comment.