add option to use game creator section ID

This commit is contained in:
Martin Michelsen
2024-03-09 09:45:20 -08:00
parent 64f2cb8f9e
commit 2aae90e65a
9 changed files with 58 additions and 27 deletions
+10 -4
View File
@@ -264,10 +264,13 @@ void Lobby::create_item_creator() {
void Lobby::change_section_id() {
if (this->item_creator) {
uint8_t new_section_id = this->effective_section_id();
this->item_creator->set_section_id(new_section_id);
for (const auto& c : this->clients) {
if (c && c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
send_text_message_printf(c, "$C5Section ID changed\nto %s (%hhu)", name_for_section_id(new_section_id), new_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);
for (const auto& c : this->clients) {
if (c && c->config.check_flag(Client::Flag::DEBUG_ENABLED)) {
send_text_message_printf(c, "$C5Section ID changed\nto %s (%hhu)", name_for_section_id(new_section_id), new_section_id);
}
}
}
}
@@ -277,6 +280,9 @@ uint8_t Lobby::effective_section_id() const {
if (this->override_section_id != 0xFF) {
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);
if (leader) {
return leader->character()->disp.visual.section_id;