mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-10-25 14:12:49 +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 "ChallengeRoutes.h"
|
||||
#include "GameText.h"
|
||||
#include "LiveEventRoutes.h"
|
||||
#include "LiveWorld.h"
|
||||
#include "DashboardRoutes.h"
|
||||
@@ -46,7 +47,7 @@ namespace {
|
||||
std::string ZoneList(const std::vector<uint32_t>& zones) {
|
||||
if (zones.empty()) return "every zone";
|
||||
std::string text;
|
||||
const auto& names = ZoneNames();
|
||||
const auto& names = GameText::ZoneNames();
|
||||
for (const auto zone : zones) {
|
||||
const auto key = std::to_string(zone);
|
||||
text += (text.empty() ? "" : ", ") + (names.contains(key) ? names[key].get<std::string>() : "zone " + key);
|
||||
@@ -257,7 +258,7 @@ namespace {
|
||||
|
||||
nlohmann::json ZoneOptions() {
|
||||
std::vector<std::pair<uint32_t, std::string>> zones;
|
||||
for (const auto& [id, name] : ZoneNames().items()) {
|
||||
for (const auto& [id, name] : GameText::ZoneNames().items()) {
|
||||
if (const auto zone = GeneralUtils::TryParse<uint32_t>(id); zone && *zone > 0) zones.emplace_back(*zone, name.get<std::string>());
|
||||
}
|
||||
std::sort(zones.begin(), zones.end());
|
||||
@@ -284,7 +285,7 @@ namespace {
|
||||
if (challenge.lot < 0 || (challenge.lot > 0 && !ClientAssets::ObjectName(challenge.lot))) return fail("Unknown LOT");
|
||||
challenge.zones.clear();
|
||||
if (body.contains("zones") && body["zones"].is_array()) {
|
||||
const auto& known = ZoneNames();
|
||||
const auto& known = GameText::ZoneNames();
|
||||
for (const auto& zone : body["zones"]) {
|
||||
if (!zone.is_number_unsigned() || !known.contains(std::to_string(zone.get<uint32_t>()))) return fail("Pick zones from the list");
|
||||
if (std::find(challenge.zones.begin(), challenge.zones.end(), zone.get<uint32_t>()) == challenge.zones.end()) challenge.zones.push_back(zone.get<uint32_t>());
|
||||
|
||||
Reference in New Issue
Block a user