implement team item rewards
This commit is contained in:
@@ -3289,7 +3289,7 @@ struct S_Unknown_BB_0CEA {
|
||||
|
||||
// 0EEA (S->C): Team name
|
||||
|
||||
struct S_Unknown_BB_0EEA {
|
||||
struct S_TeamName_BB_0EEA {
|
||||
parray<uint8_t, 0x10> unused;
|
||||
pstring<TextEncoding::UTF16, 0x10> team_name;
|
||||
} __packed__;
|
||||
@@ -3433,7 +3433,9 @@ struct C_Unknown_BB_1EEA {
|
||||
// response to whatever 1EEA does.
|
||||
|
||||
// 20EA: Unknown
|
||||
// header.flag is used, but no other arguments
|
||||
// header.flag is used, but no other arguments. When sent by the server,
|
||||
// header.flag is an error code, similar to various other result commands in
|
||||
// this section.
|
||||
|
||||
// EB (S->C): Add player to spectator team (Episode 3)
|
||||
// Same format and usage as 65 and 68 commands, but sent to spectators in a
|
||||
|
||||
@@ -4615,7 +4615,7 @@ static void on_EA_BB(shared_ptr<Client> c, uint16_t command, uint32_t flag, stri
|
||||
case 0x0DEA: {
|
||||
auto team = c->team();
|
||||
if (team) {
|
||||
S_Unknown_BB_0EEA cmd;
|
||||
S_TeamName_BB_0EEA cmd;
|
||||
cmd.team_name.encode(team->name, c->language());
|
||||
send_command_t(c, 0x0EEA, 0x00000000, cmd);
|
||||
} else {
|
||||
@@ -4736,13 +4736,6 @@ static void on_EA_BB(shared_ptr<Client> c, uint16_t command, uint32_t flag, stri
|
||||
throw runtime_error("team reward already purchased");
|
||||
}
|
||||
|
||||
if (!reward.reward_item.empty()) {
|
||||
// TODO: How do we do this? Do we just send a 6xBE in the lobby?
|
||||
// (Once this is figured out, don't forget to move this block to after
|
||||
// the reward is actually purchased)
|
||||
throw runtime_error("team reward items are not implemented");
|
||||
}
|
||||
|
||||
s->team_index->buy_reward(team->team_id, reward.key, reward.team_points, reward.reward_flag);
|
||||
|
||||
if (reward.reward_flag != TeamIndex::Team::RewardFlag::NONE) {
|
||||
@@ -4754,6 +4747,9 @@ static void on_EA_BB(shared_ptr<Client> c, uint16_t command, uint32_t flag, stri
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!reward.reward_item.empty()) {
|
||||
c->game_data.character()->bank.add_item(reward.reward_item);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -3453,11 +3453,16 @@ void send_team_reward_list(std::shared_ptr<Client> c, bool show_purchased) {
|
||||
}
|
||||
auto s = c->require_server_state();
|
||||
|
||||
bool show_item_rewards = show_purchased || (c->game_data.character()->bank.num_items < 200);
|
||||
|
||||
vector<S_TeamRewardList_BB_19EA_1AEA::Entry> entries;
|
||||
for (const auto& reward : s->team_index->reward_definitions()) {
|
||||
if (team->has_reward(reward.key) != show_purchased) {
|
||||
continue;
|
||||
}
|
||||
if (!show_item_rewards && !reward.reward_item.empty()) {
|
||||
continue;
|
||||
}
|
||||
bool has_all_prerequisites = true;
|
||||
for (const auto& key : reward.prerequisite_keys) {
|
||||
if (!team->has_reward(key)) {
|
||||
|
||||
Reference in New Issue
Block a user