use scrolling message for rare and max level announcements on BB
This commit is contained in:
@@ -2005,17 +2005,18 @@ static void on_pick_up_item_generic(
|
||||
string p_name = p->disp.name.decode();
|
||||
string desc = s->describe_item(c->version(), fi->data, true);
|
||||
string message = string_printf("$C6%s$C7 found\n%s", p_name.c_str(), desc.c_str());
|
||||
string bb_message = string_printf("$C6%s$C7 has found %s", p_name.c_str(), desc.c_str());
|
||||
if (should_send_global_notif) {
|
||||
for (auto& it : s->channel_to_client) {
|
||||
if (it.second->license &&
|
||||
!is_patch(it.second->version()) &&
|
||||
!is_ep3(it.second->version()) &&
|
||||
it.second->lobby.lock()) {
|
||||
send_text_message(it.second, message);
|
||||
send_text_or_scrolling_message(it.second, message, bb_message);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
send_text_message(l, message);
|
||||
send_text_or_scrolling_message(l, nullptr, message, bb_message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3150,9 +3151,11 @@ static void send_max_level_notification_if_needed(shared_ptr<Client> c) {
|
||||
size_t level_for_str = max_level + 1;
|
||||
string message = string_printf("$CG%s$C6\nGC: %" PRIu32 "\nhas reached Level $CG%zu",
|
||||
name.c_str(), c->license->serial_number, level_for_str);
|
||||
string bb_message = string_printf("$CG%s$C6 (GC: %" PRIu32 ") has reached Level $CG%zu",
|
||||
name.c_str(), c->license->serial_number, level_for_str);
|
||||
for (auto& it : s->channel_to_client) {
|
||||
if ((it.second != c) && it.second->license && !is_patch(it.second->version()) && it.second->lobby.lock()) {
|
||||
send_text_message(it.second, message);
|
||||
send_text_or_scrolling_message(it.second, message, bb_message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -884,6 +884,31 @@ __attribute__((format(printf, 2, 3))) void send_ep3_text_message_printf(shared_p
|
||||
}
|
||||
}
|
||||
|
||||
void send_scrolling_message_bb(shared_ptr<Client> c, const string& text) {
|
||||
if (c->version() != Version::BB_V4) {
|
||||
throw logic_error("cannot send scrolling message to non-BB player");
|
||||
}
|
||||
send_header_text(c->channel, 0x00EE, 0, text, ColorMode::ADD);
|
||||
}
|
||||
|
||||
void send_text_or_scrolling_message(shared_ptr<Client> c, const string& text, const string& scrolling) {
|
||||
if (is_v4(c->version())) {
|
||||
send_scrolling_message_bb(c, scrolling);
|
||||
} else {
|
||||
send_text_message(c, text);
|
||||
}
|
||||
}
|
||||
|
||||
void send_text_or_scrolling_message(
|
||||
std::shared_ptr<Lobby> l, std::shared_ptr<Client> exclude_c, const std::string& text, const std::string& scrolling) {
|
||||
for (const auto& lc : l->clients) {
|
||||
if (!lc || (lc == exclude_c)) {
|
||||
continue;
|
||||
}
|
||||
send_text_or_scrolling_message(lc, text, scrolling);
|
||||
}
|
||||
}
|
||||
|
||||
string prepare_chat_data(
|
||||
Version version,
|
||||
uint8_t language,
|
||||
|
||||
@@ -191,6 +191,10 @@ void send_text_message(Channel& ch, const std::string& text);
|
||||
void send_text_message(std::shared_ptr<Client> c, const std::string& text);
|
||||
void send_text_message(std::shared_ptr<Lobby> l, const std::string& text);
|
||||
void send_text_message(std::shared_ptr<ServerState> s, const std::string& text);
|
||||
void send_scrolling_message_bb(std::shared_ptr<Client> c, const std::string& text);
|
||||
void send_text_or_scrolling_message(std::shared_ptr<Client> c, const std::string& text, const std::string& scrolling);
|
||||
void send_text_or_scrolling_message(
|
||||
std::shared_ptr<Lobby> l, std::shared_ptr<Client> exclude_c, const std::string& text, const std::string& scrolling);
|
||||
|
||||
std::string prepare_chat_data(
|
||||
Version version,
|
||||
|
||||
Reference in New Issue
Block a user