add option to use game creator section ID
This commit is contained in:
@@ -50,6 +50,7 @@ void ItemCreator::set_random_crypt(shared_ptr<PSOLFGEncryption> new_random_crypt
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ItemCreator::set_section_id(uint8_t new_section_id) {
|
void ItemCreator::set_section_id(uint8_t new_section_id) {
|
||||||
|
if (this->section_id != new_section_id) {
|
||||||
this->section_id = new_section_id;
|
this->section_id = new_section_id;
|
||||||
this->log.prefix = string_printf("[ItemCreator:%s/%s/%s/%c/%hhu] ",
|
this->log.prefix = string_printf("[ItemCreator:%s/%s/%s/%c/%hhu] ",
|
||||||
name_for_enum(stack_limits->version),
|
name_for_enum(stack_limits->version),
|
||||||
@@ -59,6 +60,7 @@ void ItemCreator::set_section_id(uint8_t new_section_id) {
|
|||||||
this->section_id);
|
this->section_id);
|
||||||
this->pt = common_item_set->get_table(this->episode, this->mode, this->difficulty, this->section_id);
|
this->pt = common_item_set->get_table(this->episode, this->mode, this->difficulty, this->section_id);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool ItemCreator::are_rare_drops_allowed() const {
|
bool ItemCreator::are_rare_drops_allowed() const {
|
||||||
// Note: The client has an additional check here, which appears to be a subtle
|
// Note: The client has an additional check here, which appears to be a subtle
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ public:
|
|||||||
inline void set_restrictions(std::shared_ptr<const BattleRules> restrictions) {
|
inline void set_restrictions(std::shared_ptr<const BattleRules> restrictions) {
|
||||||
this->restrictions = restrictions;
|
this->restrictions = restrictions;
|
||||||
}
|
}
|
||||||
|
inline uint8_t get_section_id() const {
|
||||||
|
return this->section_id;
|
||||||
|
}
|
||||||
void set_section_id(uint8_t new_section_id);
|
void set_section_id(uint8_t new_section_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -264,6 +264,8 @@ void Lobby::create_item_creator() {
|
|||||||
void Lobby::change_section_id() {
|
void Lobby::change_section_id() {
|
||||||
if (this->item_creator) {
|
if (this->item_creator) {
|
||||||
uint8_t new_section_id = this->effective_section_id();
|
uint8_t new_section_id = this->effective_section_id();
|
||||||
|
if (this->item_creator->get_section_id() != new_section_id) {
|
||||||
|
this->log.info("Changing section ID to %s", name_for_section_id(new_section_id));
|
||||||
this->item_creator->set_section_id(new_section_id);
|
this->item_creator->set_section_id(new_section_id);
|
||||||
for (const auto& c : this->clients) {
|
for (const auto& c : this->clients) {
|
||||||
if (c && c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
if (c && c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
|
||||||
@@ -272,11 +274,15 @@ void Lobby::change_section_id() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t Lobby::effective_section_id() const {
|
uint8_t Lobby::effective_section_id() const {
|
||||||
if (this->override_section_id != 0xFF) {
|
if (this->override_section_id != 0xFF) {
|
||||||
return this->override_section_id;
|
return this->override_section_id;
|
||||||
}
|
}
|
||||||
|
if (this->check_flag(Lobby::Flag::USE_CREATOR_SECTION_ID)) {
|
||||||
|
return this->creator_section_id;
|
||||||
|
}
|
||||||
auto leader = this->clients.at(this->leader_id);
|
auto leader = this->clients.at(this->leader_id);
|
||||||
if (leader) {
|
if (leader) {
|
||||||
return leader->character()->disp.visual.section_id;
|
return leader->character()->disp.visual.section_id;
|
||||||
|
|||||||
+4
-2
@@ -56,9 +56,9 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
|
|||||||
uint32_t reassign_all_item_ids(uint32_t next_item_id);
|
uint32_t reassign_all_item_ids(uint32_t next_item_id);
|
||||||
};
|
};
|
||||||
enum class Flag {
|
enum class Flag {
|
||||||
|
// clang-format off
|
||||||
GAME = 0x00000001,
|
GAME = 0x00000001,
|
||||||
PERSISTENT = 0x00000002,
|
PERSISTENT = 0x00000002,
|
||||||
|
|
||||||
// Flags used only for games
|
// Flags used only for games
|
||||||
CHEATS_ENABLED = 0x00000100,
|
CHEATS_ENABLED = 0x00000100,
|
||||||
QUEST_IN_PROGRESS = 0x00000200,
|
QUEST_IN_PROGRESS = 0x00000200,
|
||||||
@@ -68,11 +68,12 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
|
|||||||
SPECTATORS_FORBIDDEN = 0x00004000,
|
SPECTATORS_FORBIDDEN = 0x00004000,
|
||||||
START_BATTLE_PLAYER_IMMEDIATELY = 0x00008000,
|
START_BATTLE_PLAYER_IMMEDIATELY = 0x00008000,
|
||||||
CANNOT_CHANGE_CHEAT_MODE = 0x00010000,
|
CANNOT_CHANGE_CHEAT_MODE = 0x00010000,
|
||||||
|
USE_CREATOR_SECTION_ID = 0x00020000,
|
||||||
// Flags used only for lobbies
|
// Flags used only for lobbies
|
||||||
PUBLIC = 0x01000000,
|
PUBLIC = 0x01000000,
|
||||||
DEFAULT = 0x02000000,
|
DEFAULT = 0x02000000,
|
||||||
IS_OVERFLOW = 0x08000000,
|
IS_OVERFLOW = 0x08000000,
|
||||||
|
// clang-format on
|
||||||
};
|
};
|
||||||
enum class DropMode {
|
enum class DropMode {
|
||||||
DISABLED = 0,
|
DISABLED = 0,
|
||||||
@@ -107,6 +108,7 @@ struct Lobby : public std::enable_shared_from_this<Lobby> {
|
|||||||
// bits are indexed as (1 << version), where version is a value from the
|
// bits are indexed as (1 << version), where version is a value from the
|
||||||
// Version enum.
|
// Version enum.
|
||||||
uint16_t allowed_versions;
|
uint16_t allowed_versions;
|
||||||
|
uint8_t creator_section_id;
|
||||||
uint8_t override_section_id;
|
uint8_t override_section_id;
|
||||||
Episode episode;
|
Episode episode;
|
||||||
GameMode mode;
|
GameMode mode;
|
||||||
|
|||||||
@@ -4178,11 +4178,15 @@ shared_ptr<Lobby> create_game_generic(
|
|||||||
if (!s->behavior_can_be_overridden(s->cheat_mode_behavior)) {
|
if (!s->behavior_can_be_overridden(s->cheat_mode_behavior)) {
|
||||||
game->set_flag(Lobby::Flag::CANNOT_CHANGE_CHEAT_MODE);
|
game->set_flag(Lobby::Flag::CANNOT_CHANGE_CHEAT_MODE);
|
||||||
}
|
}
|
||||||
|
if (s->use_game_creator_section_id) {
|
||||||
|
game->set_flag(Lobby::Flag::USE_CREATOR_SECTION_ID);
|
||||||
|
}
|
||||||
if (watched_lobby || battle_player) {
|
if (watched_lobby || battle_player) {
|
||||||
game->set_flag(Lobby::Flag::IS_SPECTATOR_TEAM);
|
game->set_flag(Lobby::Flag::IS_SPECTATOR_TEAM);
|
||||||
}
|
}
|
||||||
game->password = password;
|
game->password = password;
|
||||||
|
|
||||||
|
game->creator_section_id = p->disp.visual.section_id;
|
||||||
game->override_section_id = c->config.override_section_id;
|
game->override_section_id = c->config.override_section_id;
|
||||||
game->episode = episode;
|
game->episode = episode;
|
||||||
game->mode = mode;
|
game->mode = mode;
|
||||||
|
|||||||
@@ -728,6 +728,7 @@ void ServerState::load_config_early() {
|
|||||||
|
|
||||||
this->persistent_game_idle_timeout_usecs = this->config_json->get_int("PersistentGameIdleTimeout", 0);
|
this->persistent_game_idle_timeout_usecs = this->config_json->get_int("PersistentGameIdleTimeout", 0);
|
||||||
this->cheat_mode_behavior = parse_behavior_switch("CheatModeBehavior", BehaviorSwitch::OFF_BY_DEFAULT);
|
this->cheat_mode_behavior = parse_behavior_switch("CheatModeBehavior", BehaviorSwitch::OFF_BY_DEFAULT);
|
||||||
|
this->use_game_creator_section_id = this->config_json->get_bool("UseGameCreatorSectionID", false);
|
||||||
this->default_rare_notifs_enabled_v1_v2 = this->config_json->get_bool("RareNotificationsEnabledByDefault", false);
|
this->default_rare_notifs_enabled_v1_v2 = this->config_json->get_bool("RareNotificationsEnabledByDefault", false);
|
||||||
this->default_rare_notifs_enabled_v3_v4 = this->default_rare_notifs_enabled_v1_v2;
|
this->default_rare_notifs_enabled_v3_v4 = this->default_rare_notifs_enabled_v1_v2;
|
||||||
this->default_rare_notifs_enabled_v1_v2 = this->config_json->get_bool("RareNotificationsEnabledByDefaultV1V2", this->default_rare_notifs_enabled_v1_v2);
|
this->default_rare_notifs_enabled_v1_v2 = this->config_json->get_bool("RareNotificationsEnabledByDefaultV1V2", this->default_rare_notifs_enabled_v1_v2);
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ struct ServerState : public std::enable_shared_from_this<ServerState> {
|
|||||||
bool hide_download_commands = true;
|
bool hide_download_commands = true;
|
||||||
RunShellBehavior run_shell_behavior = RunShellBehavior::DEFAULT;
|
RunShellBehavior run_shell_behavior = RunShellBehavior::DEFAULT;
|
||||||
BehaviorSwitch cheat_mode_behavior = BehaviorSwitch::OFF_BY_DEFAULT;
|
BehaviorSwitch cheat_mode_behavior = BehaviorSwitch::OFF_BY_DEFAULT;
|
||||||
|
bool use_game_creator_section_id = false;
|
||||||
bool default_rare_notifs_enabled_v1_v2 = false;
|
bool default_rare_notifs_enabled_v1_v2 = false;
|
||||||
bool default_rare_notifs_enabled_v3_v4 = false;
|
bool default_rare_notifs_enabled_v3_v4 = false;
|
||||||
std::vector<std::shared_ptr<const PSOBBEncryption::KeyFile>> bb_private_keys;
|
std::vector<std::shared_ptr<const PSOBBEncryption::KeyFile>> bb_private_keys;
|
||||||
|
|||||||
@@ -814,7 +814,17 @@
|
|||||||
// drop modes in all game versions. If you want to scale the drop rates for
|
// drop modes in all game versions. If you want to scale the drop rates for
|
||||||
// only some versions, use the --multiply option to the convert-rare-item-set
|
// only some versions, use the --multiply option to the convert-rare-item-set
|
||||||
// action instead.
|
// action instead.
|
||||||
"ServerGlobalDropRateMultiplier": 1,
|
"ServerGlobalDropRateMultiplier": 1.0,
|
||||||
|
|
||||||
|
// Whether to retain server drop tables when game leaders change. The client
|
||||||
|
// reloads its drop tables when the leader joins a game or returns to Pioneer
|
||||||
|
// 2; this leads to some edge cases that could be confusing for players, so
|
||||||
|
// newserv instead switches its server tables instantly to the new leader's
|
||||||
|
// section ID when the leader leaves the game. This option, if enabled, causes
|
||||||
|
// the server to instead use the game creator's section ID for the entire
|
||||||
|
// duration of the game. On versions other than BB, this only has an effect in
|
||||||
|
// server drop modes.
|
||||||
|
"UseGameCreatorSectionID": false,
|
||||||
|
|
||||||
// BB team reward definitions. Team rewards have the following fields:
|
// BB team reward definitions. Team rewards have the following fields:
|
||||||
// Key: Internal name of the reward. Must be unique across all rewards.
|
// Key: Internal name of the reward. Must be unique across all rewards.
|
||||||
|
|||||||
@@ -297,6 +297,8 @@
|
|||||||
"031000",
|
"031000",
|
||||||
],
|
],
|
||||||
"BBGlobalEXPMultiplier": 1,
|
"BBGlobalEXPMultiplier": 1,
|
||||||
|
"ServerGlobalDropRateMultiplier": 1.0,
|
||||||
|
"UseGameCreatorSectionID": false,
|
||||||
|
|
||||||
"TeamRewards": [
|
"TeamRewards": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user