mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-15 09:04:10 +00:00
refactor(dashboard): routes name zones, objects and phrases through GameText
The routes' own zone name helpers and the CDClient's English zone and leaderboard header copies give way to GameText, so every name comes from the locale in the viewer's language; the Network page's world labels, mail, missions, leaderboards, item info (cached per language) and the settings/vanity help strings too. Reward code 4 and the plaque text name their zone from the locale. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "ClientAssets.h"
|
||||
#include "GameText.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
@@ -15,7 +16,6 @@
|
||||
#include "CDClientDatabase.h"
|
||||
#include "Game.h"
|
||||
#include "Logger.h"
|
||||
#include "Locale.h"
|
||||
#include "dConfig.h"
|
||||
#include "eHTTPMethod.h"
|
||||
#include "GeneralUtils.h"
|
||||
@@ -27,7 +27,7 @@ namespace {
|
||||
constexpr uint32_t MAX_ITEMS_PER_REQUEST = 500;
|
||||
constexpr size_t MAX_LISTING_ENTRIES = 2000;
|
||||
|
||||
std::map<LOT, nlohmann::json> g_ItemCache;
|
||||
std::map<std::pair<std::string, LOT>, nlohmann::json> g_ItemCache; // by language (GameText) and LOT
|
||||
std::map<LOT, std::vector<int>> g_ItemSetsByLot; // lot -> set ids containing it
|
||||
bool g_ItemSetsLoaded = false;
|
||||
|
||||
@@ -95,9 +95,9 @@ namespace {
|
||||
return data;
|
||||
}
|
||||
|
||||
// In the viewer's language (GameText.h)
|
||||
std::string Phrase(const std::string& key) {
|
||||
const auto& phrase = Locale::GetPhrase(key);
|
||||
return phrase;
|
||||
return GameText::Phrase(key);
|
||||
}
|
||||
|
||||
struct Stats {
|
||||
@@ -243,7 +243,7 @@ namespace ClientAssets {
|
||||
}
|
||||
|
||||
std::string ItemName(LOT lot) {
|
||||
const auto& localized = Locale::GetPhrase("Objects_" + std::to_string(lot) + "_name");
|
||||
const auto& localized = GameText::Phrase(GameText::Key("Objects", lot));
|
||||
if (!localized.empty()) return localized;
|
||||
const auto& table = ObjectNameTable();
|
||||
const auto it = table.find(lot);
|
||||
@@ -252,7 +252,8 @@ namespace ClientAssets {
|
||||
}
|
||||
|
||||
nlohmann::json ItemInfo(LOT lot) {
|
||||
if (const auto cached = g_ItemCache.find(lot); cached != g_ItemCache.end()) return cached->second;
|
||||
const auto cacheKey = std::make_pair(GameText::Language(), lot);
|
||||
if (const auto cached = g_ItemCache.find(cacheKey); cached != g_ItemCache.end()) return cached->second;
|
||||
|
||||
nlohmann::json info{ {"lot", lot}, {"name", ItemName(lot)} };
|
||||
|
||||
@@ -284,7 +285,7 @@ namespace ClientAssets {
|
||||
info["stats"] = StatsJson(stats);
|
||||
info["set"] = ItemSet(lot);
|
||||
|
||||
g_ItemCache[lot] = info;
|
||||
g_ItemCache[cacheKey] = info;
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user