diff --git a/src/ReceiveCommands.cc b/src/ReceiveCommands.cc index dcb3eef7..2aec0ca0 100644 --- a/src/ReceiveCommands.cc +++ b/src/ReceiveCommands.cc @@ -5546,6 +5546,27 @@ static asio::awaitable on_8A(std::shared_ptr c, Channel::Message& co_return; } + +static asio::awaitable send_brutal_peeps_pc_patch_until_area_load(std::shared_ptr c) { + for (size_t attempt = 1; attempt <= 120; attempt++) { + asio::steady_timer timer(co_await asio::this_coro::executor); + timer.expires_after(std::chrono::milliseconds(500)); + co_await timer.async_wait(asio::use_awaitable); + + if (!c->channel->connected() || (c->version() != Version::PC_V2)) { + co_return; + } + + auto l = c->lobby.lock(); + if (!l || !l->is_game()) { + co_return; + } + + int64_t brutal_peeps_hp_patch_tier = (l->brutal_peeps_tier >= 1) ? l->brutal_peeps_tier : -1; + co_await send_brutal_peeps_hp_patch_bb(c, brutal_peeps_hp_patch_tier); + } +} + static asio::awaitable on_6F(std::shared_ptr c, Channel::Message& msg) { check_size_v(msg.data.size(), 0); @@ -5599,6 +5620,9 @@ static asio::awaitable on_6F(std::shared_ptr c, Channel::Message& if (loading_flag_cleared && (c->version() == Version::BB_V4)) { int64_t brutal_peeps_hp_patch_tier = (l->brutal_peeps_tier >= 1) ? l->brutal_peeps_tier : -1; co_await send_brutal_peeps_hp_patch_bb(c, brutal_peeps_hp_patch_tier); + } else if (loading_flag_cleared && (c->version() == Version::PC_V2)) { + auto s = c->require_server_state(); + asio::co_spawn(*s->io_context, send_brutal_peeps_pc_patch_until_area_load(c), asio::detached); } // DC NTE creates players in the invisible state by default; if the joiner is not DC NTE, it won't send 6x23 to make diff --git a/src/SendCommands.cc b/src/SendCommands.cc index a37b13a0..3c705d65 100644 --- a/src/SendCommands.cc +++ b/src/SendCommands.cc @@ -1208,15 +1208,9 @@ asio::awaitable send_brutal_peeps_hp_patch_bb(std::shared_ptr c, i co_await prepare_client_for_patches(c); const bool is_pc_bp_patch = (c->version() == Version::PC_V2); - const size_t max_attempts = is_pc_bp_patch ? 5 : 1; + const size_t max_attempts = 1; for (size_t attempt = 1; attempt <= max_attempts; attempt++) { - if (is_pc_bp_patch) { - asio::steady_timer timer(co_await asio::this_coro::executor); - timer.expires_after(std::chrono::milliseconds(750)); - co_await timer.async_wait(asio::use_awaitable); - } - auto promises = is_pc_bp_patch ? send_brutal_peeps_hp_patch_pc_now(c, tier) : send_brutal_peeps_hp_patch_bb_now(c, tier); @@ -1246,7 +1240,7 @@ asio::awaitable send_brutal_peeps_hp_patch_bb(std::shared_ptr c, i } } - if (!is_pc_bp_patch || any_success || !any_zero_return || !c->channel->connected()) { + if (!is_pc_bp_patch || any_success || !any_zero_return || !c->channel->connected() || (attempt >= max_attempts)) { break; }