Bind native manager actions and preserve ongoing Modern standings (by Codex)

This commit is contained in:
Codex committed 2026-10-29 21:24:49 +01:00
1 parent f9f950fc7f
commit cf424b6be1
31 files changed
+466 -100

No files matched your search

+61
View File
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: GPL-3.0-only
#pragma once
#include <algorithm>
#include <cstdint>
#include <optional>
#include <string>
#include <string_view>
namespace bmh::modern {
inline std::optional<std::string> normalized_manager_name(std::string_view raw) {
const auto whitespace = [](uint32_t c) {
return c == 0x20 || c == 0xa0 || c == 0x1680 ||
(c >= 0x2000 && c <= 0x200a) || c == 0x2028 || c == 0x2029 ||
c == 0x202f || c == 0x205f || c == 0x3000 || c == 0xfeff;
};
size_t first = raw.size(), last = 0, count = 0, pending_spaces = 0;
for (size_t at = 0; at < raw.size();) {
const auto start = at;
const auto byte = uint8_t(raw[at++]);
uint32_t value = byte;
int remaining = 0;
if (byte >= 0xc2 && byte <= 0xdf) {
value &= 31;
remaining = 1;
} else if (byte >= 0xe0 && byte <= 0xef) {
value &= 15;
remaining = 2;
} else if (byte >= 0xf0 && byte <= 0xf4) {
value &= 7;
remaining = 3;
} else if (byte >= 128)
return {};
const auto encoded_length = remaining;
while (remaining--) {
if (at == raw.size() || (uint8_t(raw[at]) & 0xc0) != 0x80)
return {};
value = value * 64 + (uint8_t(raw[at++]) & 63);
}
if ((encoded_length == 1 && value < 0x80) ||
(encoded_length == 2 && value < 0x800) ||
(encoded_length == 3 && value < 0x10000) || value > 0x10ffff ||
(value >= 0xd800 && value <= 0xdfff) || value < 32 ||
(value >= 127 && value <= 159))
return {};
if (whitespace(value)) {
if (count)
pending_spaces = std::min(size_t(25), pending_spaces + 1);
continue;
}
if (!count)
first = start;
count += pending_spaces + 1;
pending_spaces = 0;
if (count > 24)
return {};
last = at;
}
if (!count)
return {};
return std::string(raw.substr(first, last - first));
}
}
+1 -1
View File
@@ -154,7 +154,7 @@ A allowed_commands(const ModernState& g, const UiContext& c) {
"session.advance", "lineup.commit", "tactics.commit", "friendly.book", "manager.resign.commit",
"training.commit", "camp.book", "bank.commit", "toto.submit", "quote.request", "contract.offer",
"stadium.commit", "advertising.accept", "budget.commit", "ticket.commit", "transfer.submit",
"sponsor.answer", "environment.commit", "fixture.reschedule", "contract.cancel", "news.update", "balance.commit", "settings.commit"};
"sponsor.answer", "environment.commit", "fixture.reschedule", "contract.cancel", "news.update", "balance.commit", "settings.commit", "manager.join.commit"};
A out;
for (size_t i = 0; i < std::size(kAll); ++i)
if (!national || i < 5 || std::string(kAll[i]) == "settings.commit") out.push_back(kAll[i]);