Fixing item toggle

Now the toggle is set via per room.
This commit is contained in:
Reason
2023-06-09 22:11:07 -04:00
committed by Martin Michelsen
parent 3ef2f76705
commit 53a9b527e4
4 changed files with 15 additions and 17 deletions
+4 -9
View File
@@ -1123,18 +1123,13 @@ static void proxy_command_switch_assist(shared_ptr<ServerState>,
session.options.switch_assist ? "enabled" : "disabled");
}
static void server_command_drop(shared_ptr<ServerState>s, shared_ptr<Lobby> l,
static void server_command_drop(shared_ptr<ServerState>, shared_ptr<Lobby> l,
shared_ptr<Client> c, const std::u16string&) {
check_is_game(l, true);
check_is_leader(l, c);
if (s->drops_enabled == true) {
send_text_message(c, u"Drops disabled.");
s->drops_enabled = false;
}
else {
send_text_message(c, u"Drops enabled.");
s->drops_enabled = true;
}
l->flags ^= Lobby::Flag::DROPS_ENABLED;
send_text_message_printf(l, "Drops %s",
(l->flags & Lobby::Flag::DROPS_ENABLED) ? "enabled" : "disabled");
}
static void server_command_item(shared_ptr<ServerState>, shared_ptr<Lobby> l,
+1
View File
@@ -36,6 +36,7 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
IS_SPECTATOR_TEAM = 0x00002000, // episode must be EP3 also
SPECTATORS_FORBIDDEN = 0x00004000,
START_BATTLE_PLAYER_IMMEDIATELY = 0x00008000,
DROPS_ENABLED = 0x00010000,
// Flags used only for lobbies
PUBLIC = 0x01000000,
+6 -2
View File
@@ -3150,12 +3150,16 @@ shared_ptr<Lobby> create_game_generic(
bool item_tracking_enabled =
(c->version() == GameVersion::BB) ||
(s->item_tracking_enabled && (mode == GameMode::NORMAL || mode == GameMode::SOLO));
bool drops_enabled =
(s->drops_enabled && (mode == GameMode::NORMAL));
shared_ptr<Lobby> game = s->create_lobby();
game->name = name;
game->flags = flags |
Lobby::Flag::GAME |
(item_tracking_enabled ? Lobby::Flag::ITEM_TRACKING_ENABLED : 0);
Lobby::Flag::GAME |
(item_tracking_enabled ? Lobby::Flag::ITEM_TRACKING_ENABLED : 0) |
(drops_enabled ? Lobby::Flag::DROPS_ENABLED : 0 );
game->password = password;
game->version = c->version();
game->section_id = c->options.override_section_id >= 0
+4 -6
View File
@@ -953,7 +953,6 @@ static void on_sort_inventory_bb(shared_ptr<ServerState>,
// EXP/Drop Item commands
static bool drop_item(
std::shared_ptr<ServerState>s,
std::shared_ptr<Lobby> l,
int64_t enemy_id,
uint8_t area,
@@ -979,7 +978,6 @@ static bool drop_item(
} else {
item.data = l->item_creator->on_box_item_drop(area);
}
item.data.id = l->generate_item_id(0xFF);
if (l->flags & Lobby::Flag::ITEM_TRACKING_ENABLED) {
@@ -989,7 +987,7 @@ static bool drop_item(
return true;
}
static void on_enemy_drop_item_request(shared_ptr<ServerState> s,
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) {
if (!l->is_game()) {
@@ -999,12 +997,12 @@ static void on_enemy_drop_item_request(shared_ptr<ServerState> s,
const auto& cmd = check_size_sc<G_EnemyDropItemRequest_DC_6x60>(data,
sizeof(G_EnemyDropItemRequest_DC_6x60),
sizeof(G_EnemyDropItemRequest_PC_V3_BB_6x60));
if (!drop_item(s, l, cmd.enemy_id, cmd.area, cmd.x, cmd.z, cmd.enemy_id)) {
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>s,
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) {
if (!l->is_game()) {
@@ -1012,7 +1010,7 @@ static void on_box_drop_item_request(shared_ptr<ServerState>s,
}
const auto& cmd = check_size_sc<G_BoxItemDropRequest_6xA2>(data);
if (!drop_item(s, l, -1, cmd.area, cmd.x, cmd.z, cmd.request_id)) {
if (!drop_item(l, -1, cmd.area, cmd.x, cmd.z, cmd.request_id)) {
forward_subcommand(l, c, command, flag, data);
}
}