Toggle drops.
Through txt command in-game, or through the config file. White space fix. Forgot this part.
This commit is contained in:
@@ -1123,6 +1123,22 @@ static void proxy_command_switch_assist(shared_ptr<ServerState>,
|
|||||||
session.options.switch_assist ? "enabled" : "disabled");
|
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,
|
static void server_command_item(shared_ptr<ServerState>, shared_ptr<Lobby> l,
|
||||||
shared_ptr<Client> c, const std::u16string& args) {
|
shared_ptr<Client> c, const std::u16string& args) {
|
||||||
check_is_game(l, true);
|
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"$type", {server_command_lobby_type, nullptr, u"Usage:\ntype <name>"}},
|
||||||
{u"$warp", {server_command_warp, proxy_command_warp, u"Usage:\nwarp <area-number>"}},
|
{u"$warp", {server_command_warp, proxy_command_warp, u"Usage:\nwarp <area-number>"}},
|
||||||
{u"$what", {server_command_what, nullptr, u"Usage:\nwhat"}},
|
{u"$what", {server_command_what, nullptr, u"Usage:\nwhat"}},
|
||||||
|
{u"$drop", {server_command_drop, nullptr, u"Usage:\nToggles drops"}},
|
||||||
});
|
});
|
||||||
|
|
||||||
struct SplitCommand {
|
struct SplitCommand {
|
||||||
|
|||||||
@@ -953,6 +953,7 @@ static void on_sort_inventory_bb(shared_ptr<ServerState>,
|
|||||||
// EXP/Drop Item commands
|
// EXP/Drop Item commands
|
||||||
|
|
||||||
static bool drop_item(
|
static bool drop_item(
|
||||||
|
std::shared_ptr<ServerState>s,
|
||||||
std::shared_ptr<Lobby> l,
|
std::shared_ptr<Lobby> l,
|
||||||
int64_t enemy_id,
|
int64_t enemy_id,
|
||||||
uint8_t area,
|
uint8_t area,
|
||||||
@@ -988,7 +989,7 @@ static bool drop_item(
|
|||||||
return true;
|
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,
|
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
|
||||||
const string& data) {
|
const string& data) {
|
||||||
if (!l->is_game()) {
|
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,
|
const auto& cmd = check_size_sc<G_EnemyDropItemRequest_DC_6x60>(data,
|
||||||
sizeof(G_EnemyDropItemRequest_DC_6x60),
|
sizeof(G_EnemyDropItemRequest_DC_6x60),
|
||||||
sizeof(G_EnemyDropItemRequest_PC_V3_BB_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);
|
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,
|
shared_ptr<Lobby> l, shared_ptr<Client> c, uint8_t command, uint8_t flag,
|
||||||
const string& data) {
|
const string& data) {
|
||||||
if (!l->is_game()) {
|
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);
|
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);
|
forward_subcommand(l, c, command, flag, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ ServerState::ServerState(const char* config_filename, bool is_replay)
|
|||||||
allow_unregistered_users(false),
|
allow_unregistered_users(false),
|
||||||
allow_saving(true),
|
allow_saving(true),
|
||||||
item_tracking_enabled(true),
|
item_tracking_enabled(true),
|
||||||
|
drops_enabled(true),
|
||||||
episode_3_send_function_call_enabled(false),
|
episode_3_send_function_call_enabled(false),
|
||||||
enable_dol_compression(false),
|
enable_dol_compression(false),
|
||||||
catch_handler_exceptions(true),
|
catch_handler_exceptions(true),
|
||||||
@@ -649,6 +650,13 @@ void ServerState::parse_config(shared_ptr<const JSONObject> config_json) {
|
|||||||
this->item_tracking_enabled = true;
|
this->item_tracking_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
this->drops_enabled = d.at("EnableDrops")->as_bool();
|
||||||
|
}
|
||||||
|
catch (const out_of_range&) {
|
||||||
|
this->drops_enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this->episode_3_send_function_call_enabled = d.at("EnableEpisode3SendFunctionCall")->as_bool();
|
this->episode_3_send_function_call_enabled = d.at("EnableEpisode3SendFunctionCall")->as_bool();
|
||||||
} catch (const out_of_range&) {
|
} catch (const out_of_range&) {
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ struct ServerState {
|
|||||||
bool allow_unregistered_users;
|
bool allow_unregistered_users;
|
||||||
bool allow_saving;
|
bool allow_saving;
|
||||||
bool item_tracking_enabled;
|
bool item_tracking_enabled;
|
||||||
|
bool drops_enabled;
|
||||||
bool episode_3_send_function_call_enabled;
|
bool episode_3_send_function_call_enabled;
|
||||||
bool enable_dol_compression;
|
bool enable_dol_compression;
|
||||||
bool catch_handler_exceptions;
|
bool catch_handler_exceptions;
|
||||||
|
|||||||
@@ -361,6 +361,9 @@
|
|||||||
// be turned off here. This option has no effect on Blue Burst games - item
|
// be turned off here. This option has no effect on Blue Burst games - item
|
||||||
// tracking is always enabled for them.
|
// tracking is always enabled for them.
|
||||||
"EnableItemTracking": true,
|
"EnableItemTracking": true,
|
||||||
|
|
||||||
|
// Disable/Enable drops.
|
||||||
|
"EnableDrops": true,
|
||||||
|
|
||||||
// Whether to enable certain exception handling. Disabling this causes
|
// Whether to enable certain exception handling. Disabling this causes
|
||||||
// newserv to abort when any client causes an exception, which is generally
|
// newserv to abort when any client causes an exception, which is generally
|
||||||
|
|||||||
Reference in New Issue
Block a user