Guard unsupported TeamSync team mutations
This commit is contained in:
@@ -6262,6 +6262,11 @@ static asio::awaitable<void> on_EA_BB(std::shared_ptr<Client> c, Channel::Messag
|
|||||||
case 0x0FEA: { // Set team flag
|
case 0x0FEA: { // Set team flag
|
||||||
auto team = c->team();
|
auto team = c->team();
|
||||||
if (team && team->members.at(c->login->account->account_id).check_flag(TeamIndex::Team::Member::Flag::IS_MASTER)) {
|
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<C_SetTeamFlag_BB_0FEA>(msg.data);
|
const auto& cmd = check_size_t<C_SetTeamFlag_BB_0FEA>(msg.data);
|
||||||
s->team_index->set_flag_data(team->team_id, cmd.flag_data);
|
s->team_index->set_flag_data(team->team_id, cmd.flag_data);
|
||||||
send_team_metadata_change_notifications(s, team, 0, TeamMetadataChange::FLAG_DATA);
|
send_team_metadata_change_notifications(s, team, 0, TeamMetadataChange::FLAG_DATA);
|
||||||
@@ -6271,6 +6276,12 @@ static asio::awaitable<void> on_EA_BB(std::shared_ptr<Client> c, Channel::Messag
|
|||||||
case 0x10EA: { // Disband team
|
case 0x10EA: { // Disband team
|
||||||
auto team = c->team();
|
auto team = c->team();
|
||||||
if (team && team->members.at(c->login->account->account_id).check_flag(TeamIndex::Team::Member::Flag::IS_MASTER)) {
|
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);
|
s->team_index->disband(team->team_id);
|
||||||
send_command(c, 0x10EA, 0x00000000);
|
send_command(c, 0x10EA, 0x00000000);
|
||||||
send_team_metadata_change_notifications(s, team, 0, TeamMetadataChange::TEAM_DISBANDED);
|
send_team_metadata_change_notifications(s, team, 0, TeamMetadataChange::TEAM_DISBANDED);
|
||||||
@@ -6285,6 +6296,13 @@ static asio::awaitable<void> on_EA_BB(std::shared_ptr<Client> c, Channel::Messag
|
|||||||
throw std::runtime_error("this command cannot be used to modify your own permissions");
|
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
|
// The client only sends this command with flag = 0x00, 0x30, or 0x40
|
||||||
switch (msg.flag) {
|
switch (msg.flag) {
|
||||||
case 0x00: // Demote member
|
case 0x00: // Demote member
|
||||||
@@ -6342,6 +6360,12 @@ static asio::awaitable<void> on_EA_BB(std::shared_ptr<Client> c, Channel::Messag
|
|||||||
throw std::runtime_error("team reward already purchased");
|
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);
|
s->team_index->buy_reward(team->team_id, reward.key, reward.team_points, reward.reward_flag);
|
||||||
|
|
||||||
if (reward.reward_flag != TeamIndex::Team::RewardFlag::NONE) {
|
if (reward.reward_flag != TeamIndex::Team::RewardFlag::NONE) {
|
||||||
@@ -6366,6 +6390,10 @@ static asio::awaitable<void> on_EA_BB(std::shared_ptr<Client> c, Channel::Messag
|
|||||||
send_command(c, 0x1FEA, 0x00000001);
|
send_command(c, 0x1FEA, 0x00000001);
|
||||||
} else if (s->team_index->get_by_name(new_team_name)) {
|
} else if (s->team_index->get_by_name(new_team_name)) {
|
||||||
send_command(c, 0x1FEA, 0x00000002);
|
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 {
|
} else {
|
||||||
s->team_index->rename(team->team_id, new_team_name);
|
s->team_index->rename(team->team_id, new_team_name);
|
||||||
send_command(c, 0x1FEA, 0x00000000);
|
send_command(c, 0x1FEA, 0x00000000);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#include "SendCommands.hh"
|
#include "SendCommands.hh"
|
||||||
#include "StaticGameData.hh"
|
#include "StaticGameData.hh"
|
||||||
#include "Text.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).
|
// 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<Client> c, Subco
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto s = c->require_server_state();
|
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();
|
auto p = c->character_file();
|
||||||
const auto& limits = *s->item_stack_limits(c->version());
|
const auto& limits = *s->item_stack_limits(c->version());
|
||||||
auto item = p->remove_item(cmd.item_id, cmd.amount, limits);
|
auto item = p->remove_item(cmd.item_id, cmd.amount, limits);
|
||||||
|
|||||||
Reference in New Issue
Block a user