Toggle drops.

Through txt command in-game, or through the config file.

White space fix.

Forgot this part.
This commit is contained in:
Reason
2023-06-08 17:33:43 -04:00
committed by Martin Michelsen
parent a963c3316c
commit 95346118f0
5 changed files with 34 additions and 4 deletions
+17
View File
@@ -1123,6 +1123,22 @@ 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,
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;
}
}
static void server_command_item(shared_ptr<ServerState>, shared_ptr<Lobby> l,
shared_ptr<Client> c, const std::u16string& args) {
check_is_game(l, true);
@@ -1262,6 +1278,7 @@ static const unordered_map<u16string, ChatCommandDefinition> chat_commands({
{u"$type", {server_command_lobby_type, nullptr, u"Usage:\ntype <name>"}},
{u"$warp", {server_command_warp, proxy_command_warp, u"Usage:\nwarp <area-number>"}},
{u"$what", {server_command_what, nullptr, u"Usage:\nwhat"}},
{u"$drop", {server_command_drop, nullptr, u"Usage:\nToggles drops"}},
});
struct SplitCommand {
+5 -4
View File
@@ -953,6 +953,7 @@ 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,
@@ -988,7 +989,7 @@ static bool drop_item(
return true;
}
static void on_enemy_drop_item_request(shared_ptr<ServerState>,
static void on_enemy_drop_item_request(shared_ptr<ServerState>s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!l->is_game()) {
@@ -998,12 +999,12 @@ static void on_enemy_drop_item_request(shared_ptr<ServerState>,
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(l, cmd.enemy_id, cmd.area, cmd.x, cmd.z, cmd.enemy_id)) {
if (!drop_item(s, 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>,
static void on_box_drop_item_request(shared_ptr<ServerState>s,
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
const string& data) {
if (!l->is_game()) {
@@ -1011,7 +1012,7 @@ static void on_box_drop_item_request(shared_ptr<ServerState>,
}
const auto& cmd = check_size_sc<G_BoxItemDropRequest_6xA2>(data);
if (!drop_item(l, -1, cmd.area, cmd.x, cmd.z, cmd.request_id)) {
if (!drop_item(s, l, -1, cmd.area, cmd.x, cmd.z, cmd.request_id)) {
forward_subcommand(l, c, command, flag, data);
}
}
+8
View File
@@ -23,6 +23,7 @@ ServerState::ServerState(const char* config_filename, bool is_replay)
allow_unregistered_users(false),
allow_saving(true),
item_tracking_enabled(true),
drops_enabled(true),
episode_3_send_function_call_enabled(false),
enable_dol_compression(false),
catch_handler_exceptions(true),
@@ -649,6 +650,13 @@ void ServerState::parse_config(shared_ptr<const JSONObject> config_json) {
this->item_tracking_enabled = true;
}
try {
this->drops_enabled = d.at("EnableDrops")->as_bool();
}
catch (const out_of_range&) {
this->drops_enabled = true;
}
try {
this->episode_3_send_function_call_enabled = d.at("EnableEpisode3SendFunctionCall")->as_bool();
} catch (const out_of_range&) {
+1
View File
@@ -54,6 +54,7 @@ struct ServerState {
bool allow_unregistered_users;
bool allow_saving;
bool item_tracking_enabled;
bool drops_enabled;
bool episode_3_send_function_call_enabled;
bool enable_dol_compression;
bool catch_handler_exceptions;
+3
View File
@@ -361,6 +361,9 @@
// be turned off here. This option has no effect on Blue Burst games - item
// tracking is always enabled for them.
"EnableItemTracking": true,
// Disable/Enable drops.
"EnableDrops": true,
// Whether to enable certain exception handling. Disabling this causes
// newserv to abort when any client causes an exception, which is generally