From cf380e93d27467cc3719cfcf8a7dfa2a37b93f12 Mon Sep 17 00:00:00 2001 From: Your Name Date: Fri, 12 Jun 2026 13:02:06 -0400 Subject: [PATCH] Guard unsupported TeamSync team mutations --- src/ReceiveCommands.cc | 28 ++++++++++++++++++++++++++++ src/ReceiveSubcommands.cc | 7 +++++++ 2 files changed, 35 insertions(+) diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index 87e233a8..d027757e 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -6262,6 +6262,11 @@ static asio::awaitable on_EA_BB(std::shared_ptr c, Channel::Messag case 0x0FEA: { // Set team flag auto team = c->team(); if (team && team->members.at(c->login->account->account_id).check_flag(TeamIndex::Team::Member::Flag::IS_MASTER)) { + if (TeamSync::relay_team_actions_enabled()) { + // TeamSync phase 1 is membership-only. Do not mutate local-only team + // metadata that would be erased by the next authority apply. + break; + } const auto& cmd = check_size_t(msg.data); s->team_index->set_flag_data(team->team_id, cmd.flag_data); send_team_metadata_change_notifications(s, team, 0, TeamMetadataChange::FLAG_DATA); @@ -6271,6 +6276,12 @@ static asio::awaitable on_EA_BB(std::shared_ptr c, Channel::Messag case 0x10EA: { // Disband team auto team = c->team(); if (team && team->members.at(c->login->account->account_id).check_flag(TeamIndex::Team::Member::Flag::IS_MASTER)) { + if (TeamSync::relay_team_actions_enabled()) { + // TeamSync phase 1 is membership-only. Disband is not yet routed + // through the authority. + send_command(c, 0x10EA, 0x00000001); + break; + } s->team_index->disband(team->team_id); send_command(c, 0x10EA, 0x00000000); send_team_metadata_change_notifications(s, team, 0, TeamMetadataChange::TEAM_DISBANDED); @@ -6285,6 +6296,13 @@ static asio::awaitable on_EA_BB(std::shared_ptr c, Channel::Messag throw std::runtime_error("this command cannot be used to modify your own permissions"); } + if (TeamSync::relay_team_actions_enabled()) { + // TeamSync phase 1 is membership-only. Privilege/master changes are + // not yet routed through the authority. + send_command(c, 0x11EA, 0x00000005); + break; + } + // The client only sends this command with flag = 0x00, 0x30, or 0x40 switch (msg.flag) { case 0x00: // Demote member @@ -6342,6 +6360,12 @@ static asio::awaitable on_EA_BB(std::shared_ptr c, Channel::Messag throw std::runtime_error("team reward already purchased"); } + if (TeamSync::relay_team_actions_enabled()) { + // TeamSync phase 1 is membership-only. Rewards/points are not yet + // routed through the authority. + break; + } + s->team_index->buy_reward(team->team_id, reward.key, reward.team_points, reward.reward_flag); if (reward.reward_flag != TeamIndex::Team::RewardFlag::NONE) { @@ -6366,6 +6390,10 @@ static asio::awaitable on_EA_BB(std::shared_ptr c, Channel::Messag send_command(c, 0x1FEA, 0x00000001); } else if (s->team_index->get_by_name(new_team_name)) { send_command(c, 0x1FEA, 0x00000002); + } else if (TeamSync::relay_team_actions_enabled()) { + // TeamSync phase 1 is membership-only. Rename is not yet routed + // through the authority. + send_command(c, 0x1FEA, 0x00000001); } else { s->team_index->rename(team->team_id, new_team_name); send_command(c, 0x1FEA, 0x00000000); diff --git a/src/ReceiveSubcommands.cc b/src/ReceiveSubcommands.cc index 4ceb89a7..d2cdd4b1 100644 --- a/src/ReceiveSubcommands.cc +++ b/src/ReceiveSubcommands.cc @@ -22,6 +22,7 @@ #include "SendCommands.hh" #include "StaticGameData.hh" #include "Text.hh" +#include "TeamSync.hh" // The functions in this file are called when a client sends a game command (60, 62, 6C, 6D, C9, or CB). @@ -4785,6 +4786,12 @@ static void on_exchange_item_for_team_points_bb(std::shared_ptr c, Subco } auto s = c->require_server_state(); + if (TeamSync::relay_team_actions_enabled()) { + // TeamSync phase 1 is membership-only. Team points are not yet routed + // through the authority, so do not consume the item locally. + return; + } + auto p = c->character_file(); const auto& limits = *s->item_stack_limits(c->version()); auto item = p->remove_item(cmd.item_id, cmd.amount, limits);