Skip to content

Commit

Permalink
fix: make .str parsing with ZB useful
Browse files Browse the repository at this point in the history
  • Loading branch information
diamante0018 committed Dec 3, 2024
1 parent 4d79e89 commit bf5ac3e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ To use the `iw4x.dll`, you must have a valid Modern Warfare 2 installation with
| `-nosteam` | Disable friends feature and do not update Steam about the game's current status just like an invisible mode. |
| `-unprotect-dvars` | Allow the server to modify saved/archive dvars. |
| `-zonebuilder` | Start the interactive zonebuilder tool console instead of starting the game. |
| `-original-str-parsing` | (ZoneBuilder mode only) Parse .str files in the same manner as the CoD4 Mod Tools. |
| `-disable-notifies` | Disable "Anti-CFG" checks |
| `-disable-mongoose` | Disable Mongoose HTTP server |
| `-disable-rate-limit-check` | Disable RCon rate limit checks |
Expand Down
26 changes: 14 additions & 12 deletions src/Components/Modules/AssetInterfaces/ILocalizeEntry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,34 @@ namespace Assets
}

void ILocalizeEntry::ParseLocalizedStringsFile(Components::ZoneBuilder::Zone* builder, const std::string& name, const std::string& filename)
{
std::vector<Game::LocalizeEntry*> assets;
const auto _0 = gsl::finally([]
{
if (Components::Flags::HasFlag("-original-str-parsing"))
{
Components::Localization::ParseOutput(nullptr);
Components::Localization::PrefixOverride = {};
});

Components::Localization::PrefixOverride = Utils::String::ToUpper(name) + "_";
Components::Localization::ParseOutput([&assets](Game::LocalizeEntry* asset)
{
assets.push_back(asset);
});
Components::Localization::PrefixOverride = Utils::String::ToUpper(name) + "_";
}

const auto* psLoadedFile = Game::SE_Load(filename.data(), false);
if (psLoadedFile)
{
Game::Com_PrintError(Game::CON_CHANNEL_SYSTEM, "^1Localization ERROR: %s\n", psLoadedFile);
Components::Localization::PrefixOverride = {};
return;
}

std::vector<Game::LocalizeEntry*> assets;
Components::Localization::ParseOutput([&assets](Game::LocalizeEntry* asset)
{
assets.push_back(asset);
});

auto type = Game::DB_GetXAssetNameType("localize");
for (const auto& entry : assets)
{
builder->addRawAsset(type, entry);
}

Components::Localization::ParseOutput(nullptr);
Components::Localization::PrefixOverride = {};
}

void ILocalizeEntry::ParseLocalizedStringsJSON(Components::ZoneBuilder::Zone* builder, Components::FileSystem::File& file)
Expand Down

0 comments on commit bf5ac3e

Please sign in to comment.