reformat some files after clang-format option change

This commit is contained in:
Martin Michelsen
2023-05-02 09:27:34 -07:00
parent 4f2e333d6c
commit 6654030bd3
7 changed files with 356 additions and 352 deletions
+10 -11
View File
@@ -170,8 +170,8 @@ ItemData ItemCreator::on_monster_item_drop_with_norm_area(
if (item.empty()) {
uint32_t item_class_determinant =
this->should_allow_meseta_drops()
? this->rand_int(3)
: (this->rand_int(2) + 1);
? this->rand_int(3)
: (this->rand_int(2) + 1);
uint32_t item_class;
switch (item_class_determinant) {
@@ -189,7 +189,7 @@ ItemData ItemCreator::on_monster_item_drop_with_norm_area(
}
this->log.info("Rare drop not chosen; item class determinant is %" PRIu32 "; item class is %" PRIu32,
item_class_determinant, item_class);
item_class_determinant, item_class);
switch (item_class) {
case 0: // Weapon
@@ -211,7 +211,7 @@ ItemData ItemCreator::on_monster_item_drop_with_norm_area(
item.data1[0] = 0x04;
item.data2d = this->choose_meseta_amount(
this->pt->enemy_meseta_ranges, enemy_type) &
0xFFFF;
0xFFFF;
break;
default:
return item;
@@ -423,8 +423,7 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
// Note: PSO GC doesn't check for 0x61 or 0x62 here since those items
// (HP/Resurrection and TP/Resurrection) only exist on BB.
if (item.data1[0] == 1) {
if ((item.data1[1] == 3) && (((item.data1[2] >= 0x33) && (item.data1[2] <= 0x38)) ||
(item.data1[2] == 0x61) || (item.data1[2] == 0x62))) {
if ((item.data1[1] == 3) && (((item.data1[2] >= 0x33) && (item.data1[2] <= 0x38)) || (item.data1[2] == 0x61) || (item.data1[2] == 0x62))) {
this->log.info("Restricted: restore items not allowed in Challenge mode");
item.clear();
}
@@ -476,7 +475,7 @@ void ItemCreator::clear_item_if_restricted(ItemData& item) const {
break;
case Restrictions::TechDiskMode::LIMIT_LEVEL:
this->log.info("Restricted: tech disk level limited to %hhu",
static_cast<uint8_t>(this->restrictions->max_tech_disk_level + 1));
static_cast<uint8_t>(this->restrictions->max_tech_disk_level + 1));
if (this->restrictions->max_tech_disk_level == 0) {
item.data1[2] = 0;
} else {
@@ -532,7 +531,7 @@ void ItemCreator::generate_common_item_variances(
case 4:
item.data2d = this->choose_meseta_amount(
this->pt->box_meseta_ranges, norm_area) &
0xFFFF;
0xFFFF;
break;
default:
// Note: The original code does the following here:
@@ -836,7 +835,7 @@ template <typename IntT, size_t X, size_t Y>
IntT ItemCreator::get_rand_from_weighted_tables_2d_vertical(
const parray<parray<IntT, X>, Y>& tables, size_t offset) {
return ItemCreator::get_rand_from_weighted_tables<IntT>(tables[0].data(),
offset, Y, X);
offset, Y, X);
}
// Note: There are clearly better ways of doing this, but this implementation
@@ -1477,8 +1476,8 @@ void ItemCreator::generate_weapon_shop_item_grind(
uint8_t favored_weapon = favored_weapon_by_section_id.at(this->section_id);
bool is_favored = (favored_weapon != 0xFF) && (item.data1[1] == favored_weapon);
const auto* range = is_favored
? this->weapon_random_set->get_favored_grind_range(table_index)
: this->weapon_random_set->get_standard_grind_range(table_index);
? this->weapon_random_set->get_favored_grind_range(table_index)
: this->weapon_random_set->get_standard_grind_range(table_index);
const auto& weapon_def = this->item_parameter_table->get_weapon(
item.data1[1], item.data1[2]);
+1 -1
View File
@@ -165,7 +165,7 @@ void player_use_item(shared_ptr<Client> c, size_t item_index) {
// used item. On GC and later versions, this does not happen, so we should
// delete the item here.
bool should_delete_item = (c->version() != GameVersion::DC) &&
(c->version() != GameVersion::PC);
(c->version() != GameVersion::PC);
auto& item = c->game_data.player()->inventory.items[item_index];
if (item.data.data1w[0] == 0x0203) { // technique disk
+14 -8
View File
@@ -10,7 +10,10 @@
using namespace std;
License::License() : serial_number(0), privileges(0), ban_end_time(0) {}
License::License()
: serial_number(0),
privileges(0),
ban_end_time(0) {}
string License::str() const {
string ret = string_printf("License(serial_number=%" PRIu32, this->serial_number);
@@ -37,10 +40,13 @@ string License::str() const {
return ret + ")";
}
LicenseManager::LicenseManager() : filename(""), autosave(false) {}
LicenseManager::LicenseManager()
: filename(""),
autosave(false) {}
LicenseManager::LicenseManager(const string& filename)
: filename(filename), autosave(true) {
: filename(filename),
autosave(true) {
try {
auto licenses = load_vector_file<License>(this->filename);
for (const auto& read_license : licenses) {
@@ -58,7 +64,7 @@ LicenseManager::LicenseManager(const string& filename)
} catch (const cannot_open_file&) {
license_log.warning("File %s does not exist; no licenses are registered",
this->filename.c_str());
this->filename.c_str());
}
}
@@ -80,7 +86,7 @@ void LicenseManager::set_autosave(bool autosave) {
}
shared_ptr<const License> LicenseManager::verify_pc(uint32_t serial_number,
const string& access_key) const {
const string& access_key) const {
try {
auto& license = this->serial_number_to_license.at(serial_number);
if (!license->access_key.eq_n(access_key, 8)) {
@@ -97,7 +103,7 @@ shared_ptr<const License> LicenseManager::verify_pc(uint32_t serial_number,
}
shared_ptr<const License> LicenseManager::verify_gc(uint32_t serial_number,
const string& access_key) const {
const string& access_key) const {
try {
auto& license = this->serial_number_to_license.at(serial_number);
if (!license->access_key.eq_n(access_key, 12)) {
@@ -113,7 +119,7 @@ shared_ptr<const License> LicenseManager::verify_gc(uint32_t serial_number,
}
shared_ptr<const License> LicenseManager::verify_gc(uint32_t serial_number,
const string& access_key, const string& password) const {
const string& access_key, const string& password) const {
try {
auto& license = this->serial_number_to_license.at(serial_number);
if (!license->access_key.eq_n(access_key, 12)) {
@@ -132,7 +138,7 @@ shared_ptr<const License> LicenseManager::verify_gc(uint32_t serial_number,
}
shared_ptr<const License> LicenseManager::verify_bb(const string& username,
const string& password) const {
const string& password) const {
try {
auto& license = this->bb_username_to_license.at(username);
if (license->bb_password != password) {
+2 -2
View File
@@ -214,8 +214,8 @@ void Lobby::move_client_to_lobby(
dest_lobby->add_client(c, required_client_id);
}
shared_ptr<Client> Lobby::find_client(const u16string* identifier,
uint64_t serial_number) {
shared_ptr<Client> Lobby::find_client(
const u16string* identifier, uint64_t serial_number) {
for (size_t x = 0; x < this->max_clients; x++) {
if (!this->clients[x]) {
continue;
+168 -168
View File
File diff suppressed because it is too large Load Diff
+141 -141
View File
@@ -65,7 +65,7 @@ static const unordered_set<uint8_t> watcher_subcommands({
});
static void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
uint8_t command, uint8_t flag, const void* data, size_t size) {
uint8_t command, uint8_t flag, const void* data, size_t size) {
// if the command is an Ep3-only command, make sure an Ep3 client sent it
bool command_is_ep3 = (command & 0xF0) == 0xC0;
@@ -103,8 +103,8 @@ static void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
// battle, forward everything to watcher lobbies.
if (size &&
(watcher_subcommands.count(*reinterpret_cast<const uint8_t*>(data) ||
(l->ep3_server_base &&
l->ep3_server_base->server->setup_phase != Episode3::SetupPhase::REGISTRATION)))) {
(l->ep3_server_base &&
l->ep3_server_base->server->setup_phase != Episode3::SetupPhase::REGISTRATION)))) {
for (const auto& watcher_lobby : l->watcher_lobbies) {
forward_subcommand(watcher_lobby, c, command, flag, data, size);
}
@@ -112,39 +112,39 @@ static void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
if (l->battle_record && l->battle_record->battle_in_progress()) {
auto type = ((command & 0xF0) == 0xC0)
? Episode3::BattleRecord::Event::Type::EP3_GAME_COMMAND
: Episode3::BattleRecord::Event::Type::GAME_COMMAND;
? Episode3::BattleRecord::Event::Type::EP3_GAME_COMMAND
: Episode3::BattleRecord::Event::Type::GAME_COMMAND;
l->battle_record->add_command(type, data, size);
}
}
}
static void forward_subcommand(shared_ptr<Lobby> l, shared_ptr<Client> c,
uint8_t command, uint8_t flag, const string& data) {
uint8_t command, uint8_t flag, const string& data) {
forward_subcommand(l, c, command, flag, data.data(), data.size());
}
static void on_invalid(shared_ptr<ServerState>,
shared_ptr<Lobby>, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby>, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_UnusedHeader>(
data, sizeof(G_UnusedHeader), 0xFFFF);
if (command_is_private(command)) {
c->log.error("Invalid subcommand: %02hhX (private to %hhu)",
cmd.subcommand, flag);
cmd.subcommand, flag);
} else {
c->log.error("Invalid subcommand: %02hhX (public)", cmd.subcommand);
}
}
static void on_unimplemented(shared_ptr<ServerState>,
shared_ptr<Lobby>, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby>, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_UnusedHeader>(
data, sizeof(G_UnusedHeader), 0xFFFF);
if (command_is_private(command)) {
c->log.warning("Unknown subcommand: %02hhX (private to %hhu)",
cmd.subcommand, flag);
cmd.subcommand, flag);
} else {
c->log.warning("Unknown subcommand: %02hhX (public)", cmd.subcommand);
}
@@ -154,15 +154,15 @@ static void on_unimplemented(shared_ptr<ServerState>,
}
static void on_forward_check_size(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
check_size_sc<G_UnusedHeader>(data, sizeof(G_UnusedHeader), 0xFFFF);
forward_subcommand(l, c, command, flag, data);
}
static void on_forward_check_game(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!l->is_game()) {
return;
}
@@ -170,8 +170,8 @@ static void on_forward_check_game(shared_ptr<ServerState>,
}
static void on_forward_check_game_loading(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!l->is_game() || !l->any_client_loading()) {
return;
}
@@ -179,8 +179,8 @@ static void on_forward_check_game_loading(shared_ptr<ServerState>,
}
static void on_forward_check_size_client(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_ClientIDHeader>(
data, sizeof(G_ClientIDHeader), 0xFFFF);
if (cmd.client_id != c->lobby_client_id) {
@@ -190,8 +190,8 @@ static void on_forward_check_size_client(shared_ptr<ServerState>,
}
static void on_forward_check_size_game(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
check_size_sc<G_UnusedHeader>(data, sizeof(G_UnusedHeader), 0xFFFF);
if (!l->is_game()) {
return;
@@ -200,8 +200,8 @@ static void on_forward_check_size_game(shared_ptr<ServerState>,
}
static void on_forward_check_size_ep3_lobby(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
check_size_sc<G_UnusedHeader>(data, sizeof(G_UnusedHeader), 0xFFFF);
if (l->is_game() || !l->is_ep3()) {
return;
@@ -210,8 +210,8 @@ static void on_forward_check_size_ep3_lobby(shared_ptr<ServerState>,
}
static void on_forward_check_size_ep3_game(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
check_size_sc<G_UnusedHeader>(data, sizeof(G_UnusedHeader), 0xFFFF);
if (!l->is_game() || !l->is_ep3()) {
return;
@@ -223,8 +223,8 @@ static void on_forward_check_size_ep3_game(shared_ptr<ServerState>,
// Ep3 subcommands
static void on_ep3_battle_subs(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& orig_data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& orig_data) {
const auto& header = check_size_sc<G_CardBattleCommandHeader>(
orig_data, sizeof(G_CardBattleCommandHeader), 0xFFFF);
if (!l->is_game() || !l->is_ep3()) {
@@ -260,8 +260,8 @@ static void on_ep3_battle_subs(shared_ptr<ServerState> s,
// Chat commands and the like
static void on_send_guild_card(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!command_is_private(command) || !l || (flag >= l->max_clients) ||
(!l->clients[flag])) {
return;
@@ -297,8 +297,8 @@ static void on_send_guild_card(shared_ptr<ServerState>,
// client sends a symbol chat
static void on_symbol_chat(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_SymbolChat_6x07>(data);
if (!c->can_chat || (cmd.client_id != c->lobby_client_id)) {
@@ -309,8 +309,8 @@ static void on_symbol_chat(shared_ptr<ServerState>,
// client sends a word select chat
static void on_word_select(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_WordSelect_6x74>(data);
if (!c->can_chat || (cmd.header.client_id != c->lobby_client_id)) {
@@ -322,8 +322,8 @@ static void on_word_select(shared_ptr<ServerState>,
// client is done loading into a lobby (we use this to trigger arrow updates)
static void on_set_player_visibility(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_SetPlayerVisibility_6x22_6x23>(data);
if (cmd.header.client_id != c->lobby_client_id) {
@@ -341,8 +341,8 @@ static void on_set_player_visibility(shared_ptr<ServerState>,
// Game commands used by cheat mechanisms
static void on_change_area(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_InterLevelWarp_6x21>(data);
if (!l->is_game()) {
return;
@@ -353,8 +353,8 @@ static void on_change_area(shared_ptr<ServerState>,
// when a player is hit by an enemy, heal them if infinite HP is enabled
static void on_hit_by_enemy(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_ClientIDHeader>(data, sizeof(G_ClientIDHeader), 0xFFFF);
if (!l->is_game() || (cmd.client_id != c->lobby_client_id)) {
return;
@@ -367,8 +367,8 @@ static void on_hit_by_enemy(shared_ptr<ServerState>,
// when a player casts a tech, restore TP if infinite TP is enabled
static void on_cast_technique_finished(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_CastTechniqueComplete_6x48>(data);
if (!l->is_game() || (cmd.header.client_id != c->lobby_client_id)) {
return;
@@ -380,10 +380,10 @@ static void on_cast_technique_finished(shared_ptr<ServerState>,
}
static void on_attack_finished(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_AttackFinished_6x46>(data,
offsetof(G_AttackFinished_6x46, entries), sizeof(G_AttackFinished_6x46));
offsetof(G_AttackFinished_6x46, entries), sizeof(G_AttackFinished_6x46));
size_t allowed_count = min<size_t>(cmd.header.size - 2, 11);
if (cmd.count > allowed_count) {
throw runtime_error("invalid attack finished command");
@@ -392,10 +392,10 @@ static void on_attack_finished(shared_ptr<ServerState> s,
}
static void on_cast_technique(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_CastTechnique_6x47>(data,
offsetof(G_CastTechnique_6x47, targets), sizeof(G_CastTechnique_6x47));
offsetof(G_CastTechnique_6x47, targets), sizeof(G_CastTechnique_6x47));
size_t allowed_count = min<size_t>(cmd.header.size - 2, 10);
if (cmd.target_count > allowed_count) {
throw runtime_error("invalid cast technique command");
@@ -404,10 +404,10 @@ static void on_cast_technique(shared_ptr<ServerState> s,
}
static void on_subtract_pb_energy(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_SubtractPBEnergy_6x49>(data,
offsetof(G_SubtractPBEnergy_6x49, entries), sizeof(G_SubtractPBEnergy_6x49));
offsetof(G_SubtractPBEnergy_6x49, entries), sizeof(G_SubtractPBEnergy_6x49));
size_t allowed_count = min<size_t>(cmd.header.size - 3, 14);
if (cmd.entry_count > allowed_count) {
throw runtime_error("invalid subtract PB energy command");
@@ -416,8 +416,8 @@ static void on_subtract_pb_energy(shared_ptr<ServerState> s,
}
static void on_switch_state_changed(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
auto& cmd = check_size_t<G_SwitchStateChanged_6x05>(data);
if (!l->is_game()) {
return;
@@ -431,7 +431,7 @@ static void on_switch_state_changed(shared_ptr<ServerState>,
send_text_message(c, u"$C5Switch assist");
}
forward_subcommand(l, c, command, flag, &c->last_switch_enabled_command,
sizeof(c->last_switch_enabled_command));
sizeof(c->last_switch_enabled_command));
send_command_t(c, command, flag, c->last_switch_enabled_command);
}
c->last_switch_enabled_command = cmd;
@@ -442,8 +442,8 @@ static void on_switch_state_changed(shared_ptr<ServerState>,
template <typename CmdT>
void on_movement(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<CmdT>(data);
if (cmd.header.client_id != c->lobby_client_id) {
@@ -460,8 +460,8 @@ void on_movement(shared_ptr<ServerState>,
// Item commands
static void on_player_drop_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_DropItem_6x2A>(data);
if ((cmd.header.client_id != c->lobby_client_id)) {
@@ -474,12 +474,12 @@ static void on_player_drop_item(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu dropped item %08" PRIX32 " (%s) at %hu:(%g, %g)",
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str(),
cmd.area.load(), cmd.x.load(), cmd.z.load());
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str(),
cmd.area.load(), cmd.x.load(), cmd.z.load());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: drop %08" PRIX32 "\n%s",
cmd.item_id.load(), name.c_str());
cmd.item_id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
}
@@ -488,10 +488,10 @@ static void on_player_drop_item(shared_ptr<ServerState>,
}
static void on_create_inventory_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_CreateInventoryItem_DC_6x2B>(data,
sizeof(G_CreateInventoryItem_DC_6x2B), sizeof(G_CreateInventoryItem_PC_V3_BB_6x2B));
sizeof(G_CreateInventoryItem_DC_6x2B), sizeof(G_CreateInventoryItem_PC_V3_BB_6x2B));
if ((cmd.header.client_id != c->lobby_client_id)) {
return;
@@ -511,11 +511,11 @@ static void on_create_inventory_item(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu created inventory item %08" PRIX32 " (%s)",
cmd.header.client_id.load(), cmd.item.id.load(), name.c_str());
cmd.header.client_id.load(), cmd.item.id.load(), name.c_str());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: create %08" PRIX32 "\n%s",
cmd.item.id.load(), name.c_str());
cmd.item.id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
}
@@ -524,10 +524,10 @@ static void on_create_inventory_item(shared_ptr<ServerState>,
}
static void on_drop_partial_stack(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_DropStackedItem_DC_6x5D>(data,
sizeof(G_DropStackedItem_DC_6x5D), sizeof(G_DropStackedItem_PC_V3_BB_6x5D));
sizeof(G_DropStackedItem_DC_6x5D), sizeof(G_DropStackedItem_PC_V3_BB_6x5D));
// TODO: Should we check the client ID here too?
if (!l->is_game()) {
@@ -548,12 +548,12 @@ static void on_drop_partial_stack(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu split stack to create ground item %08" PRIX32 " (%s) at %hu:(%g, %g)",
cmd.header.client_id.load(), item.data.id.load(), name.c_str(),
cmd.area.load(), cmd.x.load(), cmd.z.load());
cmd.header.client_id.load(), item.data.id.load(), name.c_str(),
cmd.area.load(), cmd.x.load(), cmd.z.load());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: split %08" PRIX32 "\n%s",
item.data.id.load(), name.c_str());
item.data.id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
}
@@ -562,8 +562,8 @@ static void on_drop_partial_stack(shared_ptr<ServerState>,
}
static void on_drop_partial_stack_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_SplitStackedItem_6xC3>(data);
@@ -593,12 +593,12 @@ static void on_drop_partial_stack_bb(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu split stack %08" PRIX32 " (removed: %s) at %hu:(%g, %g)",
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str(),
cmd.area.load(), cmd.x.load(), cmd.z.load());
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str(),
cmd.area.load(), cmd.x.load(), cmd.z.load());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: split/BB %08" PRIX32 "\n%s",
cmd.item_id.load(), name.c_str());
cmd.item_id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
@@ -610,8 +610,8 @@ static void on_drop_partial_stack_bb(shared_ptr<ServerState>,
}
static void on_buy_shop_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_BuyShopItem_6x5E>(data);
if (!l->is_game() || (cmd.header.client_id != c->lobby_client_id)) {
@@ -630,11 +630,11 @@ static void on_buy_shop_item(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu bought item %08" PRIX32 " (%s) from shop",
cmd.header.client_id.load(), item.data.id.load(), name.c_str());
cmd.header.client_id.load(), item.data.id.load(), name.c_str());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: buy %08" PRIX32 "\n%s",
item.data.id.load(), name.c_str());
item.data.id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
}
@@ -643,10 +643,10 @@ static void on_buy_shop_item(shared_ptr<ServerState>,
}
static void on_box_or_enemy_item_drop(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_DropItem_DC_6x5F>(data,
sizeof(G_DropItem_DC_6x5F), sizeof(G_DropItem_PC_V3_BB_6x5F));
sizeof(G_DropItem_DC_6x5F), sizeof(G_DropItem_PC_V3_BB_6x5F));
if (!l->is_game() || (c->lobby_client_id != l->leader_id)) {
return;
@@ -664,11 +664,11 @@ static void on_box_or_enemy_item_drop(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Leader created ground item %08" PRIX32 " (%s) at %hhu:(%g, %g)",
item.data.id.load(), name.c_str(), cmd.area, cmd.x.load(), cmd.z.load());
item.data.id.load(), name.c_str(), cmd.area, cmd.x.load(), cmd.z.load());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: drop %08" PRIX32 "\n%s",
item.data.id.load(), name.c_str());
item.data.id.load(), name.c_str());
}
}
@@ -676,8 +676,8 @@ static void on_box_or_enemy_item_drop(shared_ptr<ServerState>,
}
static void on_pick_up_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
auto& cmd = check_size_sc<G_PickUpItem_6x59>(data);
if (!l->is_game()) {
@@ -699,11 +699,11 @@ static void on_pick_up_item(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu picked up %08" PRIX32 " (%s)",
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: pick %08" PRIX32 "\n%s",
cmd.item_id.load(), name.c_str());
cmd.item_id.load(), name.c_str());
}
effective_c->game_data.player()->print_inventory(stderr);
}
@@ -712,8 +712,8 @@ static void on_pick_up_item(shared_ptr<ServerState>,
}
static void on_pick_up_item_request(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
// This is handled by the server on BB, and by the leader on other versions
if (l->version == GameVersion::BB) {
auto& cmd = check_size_sc<G_PickUpItemRequest_6x5A>(data);
@@ -731,11 +731,11 @@ static void on_pick_up_item_request(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Player %hu picked up %08" PRIX32 " (%s)",
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: pick/BB %08" PRIX32 "\n%s",
cmd.item_id.load(), name.c_str());
cmd.item_id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
@@ -747,8 +747,8 @@ static void on_pick_up_item_request(shared_ptr<ServerState>,
}
static void on_equip_unequip_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_EquipOrUnequipItem_6x25_6x26>(data);
if (cmd.header.client_id != c->lobby_client_id) {
@@ -772,8 +772,8 @@ static void on_equip_unequip_item(shared_ptr<ServerState>,
}
static void on_use_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_UseItem_6x27>(data);
if (cmd.header.client_id != c->lobby_client_id) {
@@ -793,10 +793,10 @@ static void on_use_item(shared_ptr<ServerState>,
player_use_item(c, index);
l->log.info("Player used item %hu:%08" PRIX32 " (%s)",
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
if (c->options.debug) {
send_text_message_printf(c, "$C5Items: use %08" PRIX32 "\n%s",
cmd.item_id.load(), colored_name.c_str());
cmd.item_id.load(), colored_name.c_str());
}
c->game_data.player()->print_inventory(stderr);
}
@@ -805,8 +805,8 @@ static void on_use_item(shared_ptr<ServerState>,
}
static void on_open_shop_bb_or_ep3_battle_subs(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (l->is_ep3()) {
on_ep3_battle_subs(s, l, c, command, flag, data);
@@ -845,7 +845,7 @@ static void on_open_shop_bb_or_ep3_battle_subs(shared_ptr<ServerState> s,
}
static void on_open_bank_bb_or_card_trade_counter_ep3(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag, const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag, const string& data) {
if ((l->version == GameVersion::BB) && l->is_game()) {
send_bank(c);
} else if ((l->version == GameVersion::GC) && l->is_ep3()) {
@@ -854,7 +854,7 @@ static void on_open_bank_bb_or_card_trade_counter_ep3(shared_ptr<ServerState>,
}
static void on_bank_action_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t, const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t, const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_BankAction_BB_6xBD>(data);
@@ -904,8 +904,8 @@ static void on_bank_action_bb(shared_ptr<ServerState>,
}
static void on_sort_inventory_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t,
const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_SortInventory_6xC4>(data);
@@ -974,23 +974,23 @@ static bool drop_item(
}
static void on_enemy_drop_item_request(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!l->is_game()) {
return;
}
const auto& cmd = check_size_sc<G_EnemyDropItemRequest_DC_6x60>(data,
sizeof(G_EnemyDropItemRequest_DC_6x60),
sizeof(G_EnemyDropItemRequest_PC_V3_BB_6x60));
sizeof(G_EnemyDropItemRequest_DC_6x60),
sizeof(G_EnemyDropItemRequest_PC_V3_BB_6x60));
if (!drop_item(l, cmd.enemy_id, cmd.area, cmd.x, cmd.z, cmd.enemy_id)) {
forward_subcommand(l, c, command, flag, data);
}
}
static void on_box_drop_item_request(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!l->is_game()) {
return;
}
@@ -1002,8 +1002,8 @@ static void on_box_drop_item_request(shared_ptr<ServerState>,
}
static void on_phase_setup(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (c->version() == GameVersion::DC || c->version() == GameVersion::PC) {
forward_subcommand(l, c, command, flag, data);
return;
@@ -1054,8 +1054,8 @@ static void on_phase_setup(shared_ptr<ServerState>,
// enemy hit by player
static void on_enemy_hit(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_EnemyHitByPlayer_6x0A>(data);
@@ -1077,8 +1077,8 @@ static void on_enemy_hit(shared_ptr<ServerState>,
}
static void on_enemy_killed(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
forward_subcommand(l, c, command, flag, data);
if (l->version == GameVersion::BB) {
@@ -1136,7 +1136,7 @@ static void on_enemy_killed(shared_ptr<ServerState> s,
send_give_experience(l, other_c, exp);
if (other_c->options.debug) {
send_text_message_printf(other_c, "$C5+%" PRIu32 " E-%hX (%s)",
exp, cmd.enemy_id.load(), e.type_name);
exp, cmd.enemy_id.load(), e.type_name);
}
bool leveled_up = false;
@@ -1159,8 +1159,8 @@ static void on_enemy_killed(shared_ptr<ServerState> s,
}
static void on_destroy_inventory_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_DeleteInventoryItem_6x29>(data);
if (!l->is_game()) {
return;
@@ -1173,11 +1173,11 @@ static void on_destroy_inventory_item(shared_ptr<ServerState>,
cmd.item_id, cmd.amount, c->version() != GameVersion::BB);
auto name = item.data.name(false);
l->log.info("Inventory item %hu:%08" PRIX32 " destroyed (%s)",
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
cmd.header.client_id.load(), cmd.item_id.load(), name.c_str());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: destroy %08" PRIX32 "\n%s",
cmd.item_id.load(), name.c_str());
cmd.item_id.load(), name.c_str());
}
c->game_data.player()->print_inventory(stderr);
forward_subcommand(l, c, command, flag, data);
@@ -1185,8 +1185,8 @@ static void on_destroy_inventory_item(shared_ptr<ServerState>,
}
static void on_destroy_ground_item(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
const auto& cmd = check_size_sc<G_DestroyGroundItem_6x63>(data);
if (!l->is_game()) {
return;
@@ -1195,19 +1195,19 @@ static void on_destroy_ground_item(shared_ptr<ServerState>,
auto item = l->remove_item(cmd.item_id);
auto name = item.data.name(false);
l->log.info("Ground item %08" PRIX32 " destroyed (%s)", cmd.item_id.load(),
name.c_str());
name.c_str());
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: destroy/ground %08" PRIX32 "\n%s",
cmd.item_id.load(), name.c_str());
cmd.item_id.load(), name.c_str());
}
forward_subcommand(l, c, command, flag, data);
}
}
static void on_identify_item_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_AcceptItemIdentification_BB_6xB8>(data);
if (!l->is_game()) {
@@ -1240,8 +1240,8 @@ static void on_identify_item_bb(shared_ptr<ServerState>,
}
static void on_accept_identify_item_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_AcceptItemIdentification_BB_6xBA>(data);
@@ -1266,7 +1266,7 @@ static void on_accept_identify_item_bb(shared_ptr<ServerState>,
}
static void on_sell_item_at_shop_bb(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag, const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag, const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_SellItemAtShop_BB_6xC0>(data);
@@ -1283,12 +1283,12 @@ static void on_sell_item_at_shop_bb(shared_ptr<ServerState> s,
auto name = item.data.name(false);
l->log.info("Inventory item %hu:%08" PRIX32 " destroyed via sale (%s)",
c->lobby_client_id, cmd.item_id.load(), name.c_str());
c->lobby_client_id, cmd.item_id.load(), name.c_str());
c->game_data.player()->print_inventory(stderr);
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: destroy/sale %08" PRIX32 "\n+%zu Meseta\n%s",
cmd.item_id.load(), price, name.c_str());
cmd.item_id.load(), price, name.c_str());
}
forward_subcommand(l, c, command, flag, data);
@@ -1296,7 +1296,7 @@ static void on_sell_item_at_shop_bb(shared_ptr<ServerState> s,
}
static void on_buy_shop_item_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t, const string& data) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t, const string& data) {
if (l->version == GameVersion::BB) {
const auto& cmd = check_size_sc<G_BuyShopItem_BB_6xB7>(data);
if (!(l->flags & Lobby::Flag::ITEM_TRACKING_ENABLED)) {
@@ -1324,18 +1324,18 @@ static void on_buy_shop_item_bb(shared_ptr<ServerState>,
auto name = item.data.name(false);
l->log.info("Inventory item %hu:%08" PRIX32 " created via purchase (%s) for %zu meseta",
c->lobby_client_id, cmd.inventory_item_id.load(), name.c_str(), price);
c->lobby_client_id, cmd.inventory_item_id.load(), name.c_str(), price);
c->game_data.player()->print_inventory(stderr);
if (c->options.debug) {
string name = item.data.name(true);
send_text_message_printf(c, "$C5Items: create/purchase %08" PRIX32 "\n-%zu Meseta\n%s",
cmd.inventory_item_id.load(), price, name.c_str());
cmd.inventory_item_id.load(), price, name.c_str());
}
}
}
static void on_medical_center_bb(shared_ptr<ServerState>,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t, const string&) {
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t, uint8_t, const string&) {
if (l->version == GameVersion::BB) {
if (c->game_data.player()->disp.meseta < 10) {
@@ -1351,8 +1351,8 @@ static void on_medical_center_bb(shared_ptr<ServerState>,
// the handler function, and flags that tell when to allow the command. See command-input-subs.h
// for more information on flags. The maximum size is not enforced if it's zero.
typedef void (*subcommand_handler_t)(shared_ptr<ServerState> s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data);
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data);
subcommand_handler_t subcommand_handlers[0x100] = {
/* 00 */ on_invalid,
@@ -1614,7 +1614,7 @@ subcommand_handler_t subcommand_handlers[0x100] = {
};
void on_subcommand(shared_ptr<ServerState> s, shared_ptr<Lobby> l,
shared_ptr<Client> c, uint8_t command, uint8_t flag, const string& data) {
shared_ptr<Client> c, uint8_t command, uint8_t flag, const string& data) {
if (data.empty()) {
throw runtime_error("game command is empty");
}
+20 -21
View File
@@ -181,7 +181,7 @@ bool ServerState::change_client_lobby(
}
void ServerState::send_lobby_join_notifications(shared_ptr<Lobby> l,
shared_ptr<Client> joining_client) {
shared_ptr<Client> joining_client) {
for (auto& other_client : l->clients) {
if (!other_client) {
continue;
@@ -259,7 +259,7 @@ void ServerState::remove_lobby(uint32_t lobby_id) {
}
shared_ptr<Client> ServerState::find_client(const std::u16string* identifier,
uint64_t serial_number, shared_ptr<Lobby> l) {
uint64_t serial_number, shared_ptr<Lobby> l) {
if ((serial_number == 0) && identifier) {
try {
@@ -397,15 +397,15 @@ void ServerState::create_menus(shared_ptr<const JSONObject> config_json) {
shared_ptr<vector<u16string>> information_contents(new vector<u16string>());
information_menu_v3->emplace_back(InformationMenuItemID::GO_BACK, u"Go back",
u"Return to the\nmain menu", 0);
u"Return to the\nmain menu", 0);
{
uint32_t item_id = 0;
for (const auto& item : d.at("InformationMenuContents")->as_list()) {
auto& v = item->as_list();
information_menu_v2->emplace_back(item_id, decode_sjis(v.at(0)->as_string()),
decode_sjis(v.at(1)->as_string()), 0);
decode_sjis(v.at(1)->as_string()), 0);
information_menu_v3->emplace_back(item_id, decode_sjis(v.at(0)->as_string()),
decode_sjis(v.at(1)->as_string()), MenuItem::Flag::REQUIRES_MESSAGE_BOXES);
decode_sjis(v.at(1)->as_string()), MenuItem::Flag::REQUIRES_MESSAGE_BOXES);
information_contents->emplace_back(decode_sjis(v.at(2)->as_string()));
item_id++;
}
@@ -428,16 +428,16 @@ void ServerState::create_menus(shared_ptr<const JSONObject> config_json) {
ret_pds.clear();
ret_menu.emplace_back(ProxyDestinationsMenuItemID::GO_BACK, u"Go back",
u"Return to the\nmain menu", 0);
u"Return to the\nmain menu", 0);
ret_menu.emplace_back(ProxyDestinationsMenuItemID::OPTIONS, u"Options",
u"Set proxy options", 0);
u"Set proxy options", 0);
uint32_t item_id = 0;
for (const auto& item : sorted_jsons) {
const string& netloc_str = item.second->as_string();
const string& description = "$C7Remote server:\n$C6" + netloc_str;
ret_menu.emplace_back(item_id, decode_sjis(item.first),
decode_sjis(description), 0);
decode_sjis(description), 0);
ret_pds.emplace_back(parse_netloc(netloc_str));
item_id++;
}
@@ -490,9 +490,9 @@ void ServerState::create_menus(shared_ptr<const JSONObject> config_json) {
}
this->main_menu.emplace_back(MainMenuItemID::GO_TO_LOBBY, u"Go to lobby",
u"Join the lobby", 0);
u"Join the lobby", 0);
this->main_menu.emplace_back(MainMenuItemID::INFORMATION, u"Information",
u"View server\ninformation", MenuItem::Flag::INVISIBLE_ON_DCNTE | MenuItem::Flag::REQUIRES_MESSAGE_BOXES);
u"View server\ninformation", MenuItem::Flag::INVISIBLE_ON_DCNTE | MenuItem::Flag::REQUIRES_MESSAGE_BOXES);
uint32_t proxy_destinations_menu_item_flags =
// DCNTE doesn't support multiple ship select menus without changing
// servers (via a 19 command) apparently :(
@@ -503,24 +503,24 @@ void ServerState::create_menus(shared_ptr<const JSONObject> config_json) {
(this->proxy_destinations_xb.empty() ? MenuItem::Flag::INVISIBLE_ON_XB : 0) |
MenuItem::Flag::INVISIBLE_ON_BB;
this->main_menu.emplace_back(MainMenuItemID::PROXY_DESTINATIONS, u"Proxy server",
u"Connect to another\nserver", proxy_destinations_menu_item_flags);
u"Connect to another\nserver", proxy_destinations_menu_item_flags);
this->main_menu.emplace_back(MainMenuItemID::DOWNLOAD_QUESTS, u"Download quests",
u"Download quests", MenuItem::Flag::INVISIBLE_ON_DCNTE | MenuItem::Flag::INVISIBLE_ON_BB);
u"Download quests", MenuItem::Flag::INVISIBLE_ON_DCNTE | MenuItem::Flag::INVISIBLE_ON_BB);
if (!this->is_replay) {
if (!this->function_code_index->patch_menu_empty()) {
this->main_menu.emplace_back(MainMenuItemID::PATCHES, u"Patches",
u"Change game\nbehaviors", MenuItem::Flag::GC_ONLY | MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL);
u"Change game\nbehaviors", MenuItem::Flag::GC_ONLY | MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL);
}
if (!this->dol_file_index->empty()) {
this->main_menu.emplace_back(MainMenuItemID::PROGRAMS, u"Programs",
u"Run GameCube\nprograms", MenuItem::Flag::GC_ONLY | MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL | MenuItem::Flag::REQUIRES_SAVE_DISABLED);
u"Run GameCube\nprograms", MenuItem::Flag::GC_ONLY | MenuItem::Flag::REQUIRES_SEND_FUNCTION_CALL | MenuItem::Flag::REQUIRES_SAVE_DISABLED);
}
}
this->main_menu.emplace_back(MainMenuItemID::DISCONNECT, u"Disconnect",
u"Disconnect", 0);
u"Disconnect", 0);
this->main_menu.emplace_back(MainMenuItemID::CLEAR_LICENSE, u"Clear license",
u"Disconnect with an\ninvalid license error\nso you can enter a\ndifferent serial\nnumber, access key,\nor password",
MenuItem::Flag::INVISIBLE_ON_DCNTE | MenuItem::Flag::INVISIBLE_ON_BB);
u"Disconnect with an\ninvalid license error\nso you can enter a\ndifferent serial\nnumber, access key,\nor password",
MenuItem::Flag::INVISIBLE_ON_DCNTE | MenuItem::Flag::INVISIBLE_ON_BB);
try {
this->welcome_message = decode_sjis(d.at("WelcomeMessage")->as_string());
@@ -647,7 +647,7 @@ void ServerState::parse_config(shared_ptr<const JSONObject> config_json) {
this->local_address = this->all_addresses.at(local_address_str);
string addr_str = string_for_address(this->local_address);
config_log.info("Added local address: %s (%s)", addr_str.c_str(),
local_address_str.c_str());
local_address_str.c_str());
} catch (const out_of_range&) {
this->local_address = address_for_string(local_address_str.c_str());
config_log.info("Added local address: %s", local_address_str.c_str());
@@ -659,7 +659,7 @@ void ServerState::parse_config(shared_ptr<const JSONObject> config_json) {
this->external_address = this->all_addresses.at(external_address_str);
string addr_str = string_for_address(this->external_address);
config_log.info("Added external address: %s (%s)", addr_str.c_str(),
external_address_str.c_str());
external_address_str.c_str());
} catch (const out_of_range&) {
this->external_address = address_for_string(external_address_str.c_str());
config_log.info("Added external address: %s", external_address_str.c_str());
@@ -747,8 +747,7 @@ void ServerState::parse_config(shared_ptr<const JSONObject> config_json) {
for (const auto& it : d.at("CardAuctionPool")->as_dict()) {
const auto& card_name = it.first;
const auto& card_cfg_json = it.second->as_list();
this->ep3_card_auction_pool.emplace(card_name, make_pair(
card_cfg_json.at(0)->as_int(), card_cfg_json.at(1)->as_int()));
this->ep3_card_auction_pool.emplace(card_name, make_pair(card_cfg_json.at(0)->as_int(), card_cfg_json.at(1)->as_int()));
}
} catch (const out_of_range&) {
}