added player_rejoin_cooldown option for servers and turned that off for local play

This commit is contained in:
Eric 2023-12-20 10:06:52 -08:00
parent 32c37c0f21
commit 1389fcf519
No known key found for this signature in database
GPG Key ID: 89C93F0F8D6D5A98
11 changed files with 109 additions and 84 deletions

66
.efrocachemap generated
View File

@ -427,7 +427,7 @@
"build/assets/ba_data/data/languages/chinese.json": "ff9a595726f0aff42a39be576d0ff037",
"build/assets/ba_data/data/languages/chinesetraditional.json": "f858da49be0a5374157c627857751078",
"build/assets/ba_data/data/languages/croatian.json": "766532c67af5bd0144c2d63cab0516fa",
"build/assets/ba_data/data/languages/czech.json": "cd21ad8c6b8e9ed700284cf1e1aecbf8",
"build/assets/ba_data/data/languages/czech.json": "c9d518a324870066b987b8f412881dd3",
"build/assets/ba_data/data/languages/danish.json": "3fd69080783d5c9dcc0af737f02b6f1e",
"build/assets/ba_data/data/languages/dutch.json": "22b44a33bf81142ba2befad14eb5746e",
"build/assets/ba_data/data/languages/english.json": "2434e127b6788e3128d3523fcb1b8994",
@ -440,17 +440,17 @@
"build/assets/ba_data/data/languages/hindi.json": "8848f6b0caec0fcf9d85bc6e683809ec",
"build/assets/ba_data/data/languages/hungarian.json": "796a290a8c44a1e7635208c2ff5fdc6e",
"build/assets/ba_data/data/languages/indonesian.json": "408fb026e84c24a8dd7a43cb2b794541",
"build/assets/ba_data/data/languages/italian.json": "1824b50a9154594e7039883f6d35504f",
"build/assets/ba_data/data/languages/italian.json": "61c5308638bed44194f0ec24f19bf3cb",
"build/assets/ba_data/data/languages/korean.json": "03fd99d5e1155e81053fc028f69df982",
"build/assets/ba_data/data/languages/malay.json": "832562ce997fc70704b9234c95fb2e38",
"build/assets/ba_data/data/languages/persian.json": "d9de4a0b17331434859e0a6a9ae160c5",
"build/assets/ba_data/data/languages/polish.json": "df97beb156e03a3f9c932c9a600d58a1",
"build/assets/ba_data/data/languages/persian.json": "4c3394f6662bb6dcf55728cfe213d750",
"build/assets/ba_data/data/languages/polish.json": "3a90b2d9e2c59305580c96f8098fc839",
"build/assets/ba_data/data/languages/portuguese.json": "bc3b97a8213427ebbd1cfa43b4c5e6b6",
"build/assets/ba_data/data/languages/romanian.json": "aeebdd54f65939c2facc6ac50c117826",
"build/assets/ba_data/data/languages/russian.json": "e93713be12870dd0a01e2d1359d7c792",
"build/assets/ba_data/data/languages/serbian.json": "d7452dd72ac0e51680cb39b5ebaa1c69",
"build/assets/ba_data/data/languages/slovak.json": "27962d53dc3f7dd4e877cd40faafeeef",
"build/assets/ba_data/data/languages/spanish.json": "b4a51de7298ca2273bae804a98b3804d",
"build/assets/ba_data/data/languages/spanish.json": "42f857c40dbd4b637e3866849489f7d1",
"build/assets/ba_data/data/languages/swedish.json": "5142a96597d17d8344be96a603da64ac",
"build/assets/ba_data/data/languages/tamil.json": "b4de1a2851afe4869c82e9acd94cd89c",
"build/assets/ba_data/data/languages/thai.json": "77755219bbf5fb7eea0d6b226684f403",
@ -4060,26 +4060,26 @@
"build/assets/windows/Win32/ucrtbased.dll": "2def5335207d41b21b9823f6805997f1",
"build/assets/windows/Win32/vc_redist.x86.exe": "b08a55e2e77623fe657bea24f223a3ae",
"build/assets/windows/Win32/vcruntime140d.dll": "865b2af4d1e26a1a8073c89acb06e599",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "aab12ef3644cfdb3bce807bc046620e7",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "79ee4d6521943e79893c9883f2a548d8",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "b20f62bc58a08d8399b1246e7b3d1b8f",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "c0469461fe759e3826bb7bd8850852ad",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "6fce2f51f1bc935116bc127e527247af",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "eed595ac5934d3596bd5ed56031b09f5",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "fb0d04aa303e344619828b5d3b92e519",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "2e811248fdae63d5b7aabbe774d32e83",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "1e315db5e874312b5e36589c5c968733",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "bb4335a1815782929103aff48bee5b1d",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "bce3c2dbb267e3fed1a1c0f2745707b0",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "faae1a0abcc9bf88524d4f328e3a17be",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "5e500602394893d352da05721c42dcd3",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "36605011ccba79eafb36a985331ef439",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "be2ee4efa762275b51837185df5a1bcd",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "728155371cf98f79470a10d67c267ffd",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "aff99e4d9ec01c384c1d47e1edb1ac21",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "8046e2df68d61c99179b4e903e06f945",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "4cda95214bb4f60845ca7d72e852edb8",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "7378c0364421fb0a44373758634fc449",
"build/prefab/full/linux_arm64_gui/debug/ballisticakit": "accfe77598232e6e7cabb654f9e9ca0b",
"build/prefab/full/linux_arm64_gui/release/ballisticakit": "22c2f0a9044cf96157ef19dba17eaa5c",
"build/prefab/full/linux_arm64_server/debug/dist/ballisticakit_headless": "0f104075c5270088012c20634b4c4b53",
"build/prefab/full/linux_arm64_server/release/dist/ballisticakit_headless": "f1ff6a5d060157cd561e8b7045b3ac5b",
"build/prefab/full/linux_x86_64_gui/debug/ballisticakit": "9d22975d45cdbf1fe70c096a09a2bd84",
"build/prefab/full/linux_x86_64_gui/release/ballisticakit": "6b5ef9ad5524bb0cc67562b43643fe1e",
"build/prefab/full/linux_x86_64_server/debug/dist/ballisticakit_headless": "01e963e9f6d4e006bdf47947925b1e59",
"build/prefab/full/linux_x86_64_server/release/dist/ballisticakit_headless": "43c2c61d7a4d0b6a0fe65f23b4964aa2",
"build/prefab/full/mac_arm64_gui/debug/ballisticakit": "2114164d4fcb6766a9702397e3012810",
"build/prefab/full/mac_arm64_gui/release/ballisticakit": "67c4ecda6bd18a1de5ddcc62bddb486b",
"build/prefab/full/mac_arm64_server/debug/dist/ballisticakit_headless": "d030cf1e4ca12b75b1b3fbfe0db2668a",
"build/prefab/full/mac_arm64_server/release/dist/ballisticakit_headless": "022802e8aa2679864ee95af10ade0612",
"build/prefab/full/mac_x86_64_gui/debug/ballisticakit": "79525886ddef78e9c71698c1f6e0b7d9",
"build/prefab/full/mac_x86_64_gui/release/ballisticakit": "1155ff51a06813c846dc7494a221aaa0",
"build/prefab/full/mac_x86_64_server/debug/dist/ballisticakit_headless": "9f298a922a1342512adb113da69a7674",
"build/prefab/full/mac_x86_64_server/release/dist/ballisticakit_headless": "29179179655fb01220791b2e8320ee6c",
"build/prefab/full/windows_x86_gui/debug/BallisticaKit.exe": "f8e0f7099b0ed90bd2b35d5b06468842",
"build/prefab/full/windows_x86_gui/release/BallisticaKit.exe": "0d880f0947d10de7ba3b6561d2d722cb",
"build/prefab/full/windows_x86_server/debug/dist/BallisticaKitHeadless.exe": "22e969bf3722c553db0e2c90acf8a720",
"build/prefab/full/windows_x86_server/release/dist/BallisticaKitHeadless.exe": "e98c4651be654bcdf891dbe7fb89aaac",
"build/prefab/lib/linux_arm64_gui/debug/libballisticaplus.a": "db535f0ca1e01af825f75f204fbc8928",
"build/prefab/lib/linux_arm64_gui/release/libballisticaplus.a": "97d51afca996ae15b61fd9f409a00459",
"build/prefab/lib/linux_arm64_server/debug/libballisticaplus.a": "db535f0ca1e01af825f75f204fbc8928",
@ -4096,14 +4096,14 @@
"build/prefab/lib/mac_x86_64_gui/release/libballisticaplus.a": "452623f0495dd4375e5b5d9b80d643d5",
"build/prefab/lib/mac_x86_64_server/debug/libballisticaplus.a": "ca49b32ed573feea11613d62cd89840c",
"build/prefab/lib/mac_x86_64_server/release/libballisticaplus.a": "452623f0495dd4375e5b5d9b80d643d5",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "e4c7a9180c9acf5d8f994ae82f143283",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "b8dd6533992f85e417b0c4fa6a7b684f",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "700d83921b479353a1103f5a8ed67165",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "268b4f49e92b7d698d81560d2d520d8a",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "d82aba360937c288f6a7c70182a20b5a",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "688261618d3dfcaad36813794f3574ac",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "37904f43d7b995044e783f0fe48dfb5d",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "5ccbe5ed00e56319070d59e820a2c589",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.lib": "1af7ac233ae61be912be9710eafb3c3a",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitGenericPlus.pdb": "7ddb4c8bf41a341a63c561d8dd13d35a",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.lib": "e4a63d2cf8a19a2778aea819423eeadf",
"build/prefab/lib/windows/Debug_Win32/BallisticaKitHeadlessPlus.pdb": "2c48a7cfc476526ce9ce75b4633dbc5d",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.lib": "7a95714de260a88f73f343fc411a28b1",
"build/prefab/lib/windows/Release_Win32/BallisticaKitGenericPlus.pdb": "be1f30593475b80aa55a7bc5b0c26c84",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.lib": "0133baed39774c154f097c74d1d2be6e",
"build/prefab/lib/windows/Release_Win32/BallisticaKitHeadlessPlus.pdb": "864f2f2639c7b785ebcda497abcc31bf",
"src/assets/ba_data/python/babase/_mgen/__init__.py": "f885fed7f2ed98ff2ba271f9dbe3391c",
"src/assets/ba_data/python/babase/_mgen/enums.py": "28323912b56ec07701eda3d41a6a4101",
"src/ballistica/base/mgen/pyembed/binding_base.inc": "72bfed2cce8ff19741989dec28302f3f",

View File

@ -1,4 +1,4 @@
### 1.7.32 (build 21737, api 8, 2023-12-19)
### 1.7.32 (build 21739, api 8, 2023-12-20)
- Fixed a screen message that no one will ever see (Thanks vishal332008?...)
- Plugins window now displays 'No Plugins Installed' when no plugins are present (Thanks vishal332008!)
- Old messages are now displayed as soon as you press 'Unmute Chat' (Thanks vishal332008!)
@ -11,6 +11,13 @@
- Fixed a bug where no profile is selected by default in the profile tab (Thanks vishal332008!)
- Fixed a number of UI screens so that ugly window edges are no longer visible
in corners on modern ultra wide phone displays.
- Added a `player_rejoin_cooldown` server config option. This defaults to 10
seconds for servers but 0 for normal gui clients. This mechanism had been
introduced recently to combat multiplayer fast-rejoin exploits and was set to
10 seconds everywhere, but it could tend to be annoying for local single
player play, dev testing, etc. Hopefully this strikes a good balance now.
- Removed the player-rejoin-cooldown mechanism from the C++ layer since it was
redundant with the Python level one and didn't cover as many cases.
### 1.7.31 (build 21727, api 8, 2023-12-17)
- Added `bascenev1.get_connection_to_host_info_2()` which is an improved

View File

@ -423,6 +423,10 @@ class ServerController:
bascenev1.set_public_party_stats_url(self._config.stats_url)
bascenev1.set_public_party_enabled(self._config.party_is_public)
bascenev1.set_player_rejoin_cooldown(
self._config.player_rejoin_cooldown
)
# And here.. we.. go.
if self._config.stress_test_players is not None:
# Special case: run a stress test.

View File

@ -52,7 +52,7 @@ if TYPE_CHECKING:
# Build number and version of the ballistica binary we expect to be
# using.
TARGET_BALLISTICA_BUILD = 21737
TARGET_BALLISTICA_BUILD = 21739
TARGET_BALLISTICA_VERSION = '1.7.32'

View File

@ -228,7 +228,7 @@ from bascenev1._settings import (
IntSetting,
Setting,
)
from bascenev1._session import Session
from bascenev1._session import Session, set_player_rejoin_cooldown
from bascenev1._stats import PlayerScoredMessage, PlayerRecord, Stats
from bascenev1._team import SessionTeam, Team, EmptyTeam
from bascenev1._teamgame import TeamGameActivity
@ -419,6 +419,7 @@ __all__ = [
'set_public_party_name',
'set_public_party_queue_enabled',
'set_public_party_stats_url',
'set_player_rejoin_cooldown',
'set_replay_speed_exponent',
'set_touchscreen_editing',
'setmusic',

View File

@ -18,10 +18,16 @@ if TYPE_CHECKING:
import bascenev1
# How long someone who left the session (but not the party) must
# How many seconds someone who left the session (but not the party) must
# wait to rejoin the session again. Intended to prevent game exploits
# such as skipping respawn waits.
REJOIN_COOLDOWN = 10
_g_player_rejoin_cooldown: float = 0.0
def set_player_rejoin_cooldown(cooldown: float) -> None:
"""Set the cooldown for individual players rejoining after leaving."""
global _g_player_rejoin_cooldown # pylint: disable=global-statement
_g_player_rejoin_cooldown = max(0.0, cooldown)
class Session:
@ -270,7 +276,11 @@ class Session:
leave_time = self._players_on_wait.get(identifier)
if leave_time:
diff = str(
math.ceil(REJOIN_COOLDOWN - babase.apptime() + leave_time)
math.ceil(
_g_player_rejoin_cooldown
- babase.apptime()
+ leave_time
)
)
_bascenev1.broadcastmessage(
babase.Lstr(
@ -310,7 +320,7 @@ class Session:
self._players_on_wait[identifier] = babase.apptime()
with babase.ContextRef.empty():
self._waitlist_timers[identifier] = babase.AppTimer(
REJOIN_COOLDOWN,
_g_player_rejoin_cooldown,
babase.Call(self._remove_player_from_waitlist, identifier),
)

View File

@ -906,12 +906,20 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) {
ALCint connected{-1};
alcGetIntegerv(device, ALC_CONNECTED, sizeof(connected), &connected);
CHECK_AL_ERROR;
if (connected == 0) {
reconnect_fail_count_++;
} else {
reconnect_fail_count_ = 0;
if (connected != 0) {
last_connected_time_ = real_time_seconds;
// reconnect_fail_count_ = 0;
}
if (connected == 0 && real_time_seconds - last_reset_attempt_time_ > 10.0) {
// else {
// reconnect_fail_count_ = 0;
// }
// Retry less often once we've been failing for a while.
seconds_t retry_interval =
real_time_seconds - last_connected_time_ > 20.0 ? 10.0 : 3.0;
if (connected == 0
&& real_time_seconds - last_reset_attempt_time_ >= retry_interval) {
Log(LogLevel::kInfo, "OpenAL device disconnected; resetting...");
if (g_buildconfig.ostype_android()) {
std::scoped_lock lock(openalsoft_android_log_mutex_);
@ -936,15 +944,15 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) {
// Otherwise plugging in headphones and then unplugging them immediately
// will result in 10 seconds of silence.
if (result == ALC_TRUE) {
last_reset_attempt_time_ = -999.0;
// last_reset_attempt_time_ = -999.0;
if (g_buildconfig.ostype_android()) {
std::scoped_lock lock(openalsoft_android_log_mutex_);
openalsoft_android_log_ += "DEVICE RESET SUCCESSFUL\n";
openalsoft_android_log_ += "DEVICE RESET CALL SUCCESSFUL\n";
}
} else {
if (g_buildconfig.ostype_android()) {
std::scoped_lock lock(openalsoft_android_log_mutex_);
openalsoft_android_log_ += "DEVICE RESET FAILED\n";
openalsoft_android_log_ += "DEVICE RESET CALL FAILED\n";
}
}
@ -975,12 +983,14 @@ void AudioServer::ProcessDeviceDisconnects_(seconds_t real_time_seconds) {
// }
}
// If we've failed at reconnecting a few times in a row, ship logs.
if (reconnect_fail_count_ == 3) {
// If we've failed at reconnecting for a while, ship logs once.
if (real_time_seconds - last_connected_time_ > 20.0
&& !shipped_reconnect_logs_) {
shipped_reconnect_logs_ = true;
if (g_buildconfig.ostype_android()) {
std::scoped_lock lock(openalsoft_android_log_mutex_);
Log(LogLevel::kWarning,
"Got 3 reconnect fails in a row; dumping OpenAL log.\n"
"Have been disconnected for a while; dumping OpenAL log.\n"
"------------------------"
" OPENALSOFT-RECONNECT-LOG-BEGIN ----------------------\n"
+ openalsoft_android_log_

View File

@ -123,10 +123,12 @@ class AudioServer {
bool suspended_{};
bool shutdown_completed_{};
bool shutting_down_{};
bool shipped_reconnect_logs_{};
// bool report_reset_results_{};
// int reset_result_reports_remaining_{3};
int reconnect_fail_count_{};
// int reconnect_fail_count_{};
int al_source_count_{};
seconds_t last_connected_time_{};
seconds_t last_reset_attempt_time_{-999.0};
seconds_t shutdown_start_time_{};
seconds_t last_started_playing_time_{};

View File

@ -654,42 +654,28 @@ void ConnectionToClient::HandleMessagePacket(
if (auto* hs =
dynamic_cast<HostSession*>(appmode->GetForegroundSession())) {
if (!cid->AttachedToPlayer()) {
millisecs_t seconds_since_last_left =
(g_core->GetAppTimeMillisecs() - last_remove_player_time_) / 1000;
int min_seconds_since_left = 10;
bool still_waiting_for_auth =
(appmode->require_client_authentication()
&& !got_info_from_master_server_);
// If someone on this connection left less than 10 seconds ago,
// prevent them from immediately jumping back in.
if (seconds_since_last_left < min_seconds_since_left) {
// If we're not allowing peer client-info and have yet to get
// master-server info for this client, delay their join (we'll
// eventually give up and just give them a blank slate).
if (still_waiting_for_auth
&& (g_core->GetAppTimeMillisecs() - creation_time() < 10000)) {
SendScreenMessage(
"{\"t\":[\"serverResponses\",\"You can join in ${COUNT} "
"seconds.\"],\"s\":[[\"${COUNT}\",\""
+ std::to_string(min_seconds_since_left
- seconds_since_last_left)
+ "\"]]}",
"{\"v\":\"${A}...\",\"s\":[[\"${A}\",{\"r\":"
"\"loadingTryAgainText\",\"f\":\"loadingText\"}]]}",
1, 1, 0);
} else {
bool still_waiting = (appmode->require_client_authentication()
&& !got_info_from_master_server_);
// If we're not allowing peer client-info and have yet to get
// master-server info for this client, delay their join (we'll
// eventually give up and just give them a blank slate).
if (still_waiting
&& (g_core->GetAppTimeMillisecs() - creation_time() < 10000)) {
SendScreenMessage(
"{\"v\":\"${A}...\",\"s\":[[\"${A}\",{\"r\":"
"\"loadingTryAgainText\",\"f\":\"loadingText\"}]]}",
1, 1, 0);
} else {
// Either timed out or have info; let the request go through.
if (still_waiting) {
Log(LogLevel::kError,
"Allowing player-request without client\'s master-server "
"info (build "
+ std::to_string(build_number_) + ")");
}
hs->RequestPlayer(cid_d);
// Either timed out or have info; let the request go through.
if (still_waiting_for_auth) {
Log(LogLevel::kError,
"Allowing player-request without client\'s master-server "
"info (build "
+ std::to_string(build_number_) + ")");
}
hs->RequestPlayer(cid_d);
}
}
} else {

View File

@ -39,7 +39,7 @@ auto main(int argc, char** argv) -> int {
namespace ballistica {
// These are set automatically via script; don't modify them here.
const int kEngineBuildNumber = 21737;
const int kEngineBuildNumber = 21739;
const char* kEngineVersion = "1.7.32";
const int kEngineApiVersion = 8;

View File

@ -152,6 +152,11 @@ class ServerConfig:
# (internal) stress-testing mode.
stress_test_players: int | None = None
# How many seconds individual players from a given account must wait
# before rejoining the game. This can help suppress exploits
# involving leaving and rejoining or switching teams rapidly.
player_rejoin_cooldown: float = 10.0
# NOTE: as much as possible, communication from the server-manager to the
# child-process should go through these and not ad-hoc Python string commands