add option to override name colors by game version
This commit is contained in:
@@ -846,6 +846,12 @@ static void on_sync_joining_player_disp_and_inventory(
|
||||
|
||||
parsed->transcode_inventory_items(c_v, target_v, s->item_parameter_table_for_encode(target_v));
|
||||
parsed->visual.enforce_lobby_join_limits_for_version(target_v);
|
||||
if (s->version_name_colors) {
|
||||
parsed->visual.name_color = s->name_color_for_version(c_v);
|
||||
if (is_v1_or_v2(c_v)) {
|
||||
parsed->visual.compute_name_color_checksum();
|
||||
}
|
||||
}
|
||||
|
||||
switch (target_v) {
|
||||
case Version::DC_NTE:
|
||||
|
||||
+31
-4
@@ -1703,6 +1703,11 @@ static void send_join_spectator_team(shared_ptr<Client> c, shared_ptr<Lobby> l)
|
||||
: wc_p->disp.stats.level.load();
|
||||
e.name_color = wc_p->disp.visual.name_color;
|
||||
|
||||
if (s->version_name_colors) {
|
||||
p.disp.visual.name_color = s->name_color_for_version(wc->version());
|
||||
e.name_color = p.disp.visual.name_color;
|
||||
}
|
||||
|
||||
player_count++;
|
||||
}
|
||||
|
||||
@@ -1766,6 +1771,11 @@ static void send_join_spectator_team(shared_ptr<Client> c, shared_ptr<Lobby> l)
|
||||
: other_p->disp.stats.level.load();
|
||||
cmd_e.name_color = other_p->disp.visual.name_color;
|
||||
|
||||
if (s->version_name_colors) {
|
||||
cmd_p.disp.visual.name_color = s->name_color_for_version(other_c->version());
|
||||
cmd_e.name_color = cmd_p.disp.visual.name_color;
|
||||
}
|
||||
|
||||
player_count++;
|
||||
}
|
||||
}
|
||||
@@ -1867,10 +1877,14 @@ void send_join_game(shared_ptr<Client> c, shared_ptr<Lobby> l) {
|
||||
for (size_t x = 0; x < 4; x++) {
|
||||
if (l->clients[x]) {
|
||||
auto other_p = l->clients[x]->character();
|
||||
cmd.players_ep3[x].inventory = other_p->inventory;
|
||||
cmd.players_ep3[x].inventory.encode_for_client(c);
|
||||
cmd.players_ep3[x].disp = convert_player_disp_data<PlayerDispDataDCPCV3>(other_p->disp, c->language(), other_p->inventory.language);
|
||||
cmd.players_ep3[x].disp.enforce_lobby_join_limits_for_version(c->version());
|
||||
auto& cmd_p = cmd.players_ep3[x];
|
||||
cmd_p.inventory = other_p->inventory;
|
||||
cmd_p.inventory.encode_for_client(c);
|
||||
cmd_p.disp = convert_player_disp_data<PlayerDispDataDCPCV3>(other_p->disp, c->language(), other_p->inventory.language);
|
||||
cmd_p.disp.enforce_lobby_join_limits_for_version(c->version());
|
||||
if (s->version_name_colors) {
|
||||
cmd_p.disp.visual.name_color = s->name_color_for_version(l->clients[x]->version());
|
||||
}
|
||||
}
|
||||
}
|
||||
send_command_t(c, 0x64, player_count, cmd);
|
||||
@@ -1987,6 +2001,12 @@ void send_join_lobby_t(shared_ptr<Client> c, shared_ptr<Lobby> l, shared_ptr<Cli
|
||||
} else {
|
||||
e.disp = convert_player_disp_data<DispDataT>(lp->disp, c->language(), lp->inventory.language);
|
||||
e.disp.enforce_lobby_join_limits_for_version(c->version());
|
||||
if (s->version_name_colors) {
|
||||
e.disp.visual.name_color = s->name_color_for_version(lc->version());
|
||||
if (is_v1_or_v2(c->version())) {
|
||||
e.disp.visual.compute_name_color_checksum();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2053,6 +2073,9 @@ void send_join_lobby_xb(shared_ptr<Client> c, shared_ptr<Lobby> l, shared_ptr<Cl
|
||||
e.inventory.encode_for_client(c);
|
||||
e.disp = convert_player_disp_data<PlayerDispDataDCPCV3>(lp->disp, c->language(), lp->inventory.language);
|
||||
e.disp.enforce_lobby_join_limits_for_version(c->version());
|
||||
if (s->version_name_colors) {
|
||||
e.disp.visual.name_color = s->name_color_for_version(lc->version());
|
||||
}
|
||||
}
|
||||
|
||||
send_command(c, command, used_entries, &cmd, cmd.size(used_entries));
|
||||
@@ -2101,6 +2124,10 @@ void send_join_lobby_dc_nte(shared_ptr<Client> c, shared_ptr<Lobby> l,
|
||||
} else {
|
||||
e.disp = convert_player_disp_data<PlayerDispDataDCPCV3>(lp->disp, c->language(), lp->inventory.language);
|
||||
e.disp.enforce_lobby_join_limits_for_version(c->version());
|
||||
if (s->version_name_colors) {
|
||||
e.disp.visual.name_color = s->name_color_for_version(lc->version());
|
||||
e.disp.visual.compute_name_color_checksum();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -888,6 +888,20 @@ void ServerState::load_config_early() {
|
||||
this->allow_gc_xb_games = this->config_json->get_bool("AllowGCXBGames", true);
|
||||
this->enable_chat_commands = this->config_json->get_bool("EnableChatCommands", true);
|
||||
|
||||
this->version_name_colors.reset();
|
||||
try {
|
||||
const auto& colors_json = this->config_json->get_list("VersionNameColors");
|
||||
if (colors_json.size() != NUM_NON_PATCH_VERSIONS) {
|
||||
throw runtime_error("VersionNameColors list length is incorrect");
|
||||
}
|
||||
auto new_colors = make_unique<std::array<uint32_t, NUM_NON_PATCH_VERSIONS>>();
|
||||
for (size_t z = 0; z < NUM_NON_PATCH_VERSIONS; z++) {
|
||||
new_colors->at(z) = colors_json.at(z)->as_int();
|
||||
}
|
||||
this->version_name_colors = std::move(new_colors);
|
||||
} catch (const out_of_range&) {
|
||||
}
|
||||
|
||||
for (auto& order : this->public_lobby_search_orders) {
|
||||
order.clear();
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
bool allow_dc_pc_games = true;
|
||||
bool allow_gc_xb_games = true;
|
||||
bool enable_chat_commands = true;
|
||||
std::unique_ptr<std::array<uint32_t, NUM_NON_PATCH_VERSIONS>> version_name_colors;
|
||||
uint8_t allowed_drop_modes_v1_v2_normal = 0x1F;
|
||||
uint8_t allowed_drop_modes_v1_v2_battle = 0x07;
|
||||
uint8_t allowed_drop_modes_v1_v2_challenge = 0x07;
|
||||
@@ -293,6 +294,10 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
||||
|
||||
const std::vector<uint32_t> public_lobby_search_order(Version version) const;
|
||||
|
||||
inline uint32_t name_color_for_version(Version v) const {
|
||||
return this->version_name_colors ? this->version_name_colors->at(static_cast<size_t>(v) - NUM_PATCH_VERSIONS) : 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<const std::vector<std::string>> information_contents_for_client(std::shared_ptr<const Client> c) const;
|
||||
std::shared_ptr<const QuestIndex> quest_index(Version version) const;
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@ constexpr size_t NUM_VERSIONS = static_cast<size_t>(Version::BB_V4) + 1;
|
||||
constexpr size_t NUM_PATCH_VERSIONS = static_cast<size_t>(Version::BB_PATCH) + 1;
|
||||
constexpr size_t NUM_NON_PATCH_VERSIONS = NUM_VERSIONS - NUM_PATCH_VERSIONS;
|
||||
|
||||
static_assert(NUM_NON_PATCH_VERSIONS == 12, "Don't forget to update VersionNameColors in config.json");
|
||||
|
||||
template <>
|
||||
const char* name_for_enum<Version>(Version v);
|
||||
template <>
|
||||
|
||||
@@ -963,6 +963,25 @@
|
||||
"AllowDCPCGames": false,
|
||||
"AllowGCXBGames": true,
|
||||
|
||||
// This option causes the server to override name colors for all players based
|
||||
// on which version of the game they're using. If this option is missing or
|
||||
// commented out (the default), the server does not override any name colors.
|
||||
// There must be 12 entries in this list, and colors are specified as ARGB32.
|
||||
// "VersionNameColors": [
|
||||
// 0xFFBBBBBB, // DC NTE
|
||||
// 0xFF666666, // DC 11/2000
|
||||
// 0xFFFFFFFF, // DC v1
|
||||
// 0xFFFFAE35, // DC v2
|
||||
// 0xFF875C1C, // PC NTE
|
||||
// 0xFFFFAE35, // PC v2
|
||||
// 0xFF663366, // GC NTE
|
||||
// 0xFFFFBBFF, // GC
|
||||
// 0xFF666600, // Ep3 NTE
|
||||
// 0xFFDFF56E, // Ep3
|
||||
// 0xFFBBFFBB, // Xbox
|
||||
// 0xFF55FDE3, // BB (the official Episode 4 color is probably 0xFFC69141)
|
||||
// ],
|
||||
|
||||
// These options control which item drop modes are used by default, and which
|
||||
// can be chosen by the player. The AllowedDropModes fields are a bitmask
|
||||
// specifying which modes players can choose with the $dropmode command. The
|
||||
|
||||
Reference in New Issue
Block a user