Allow choosing world sync rate.

This commit is contained in:
IQuant 2024-08-01 12:50:13 +03:00
parent ae50e35f63
commit ba8dbca7e8
6 changed files with 69 additions and 39 deletions

View file

@ -7,20 +7,6 @@ connect_steam_connect_invalid_lobby_id = Clipboard does not contain a lobby code
connect_ip = Connect using ip
connect_settings = Game settings
connect_settings_debug = Debug settings
connect_settings_debug_en = Debug/cheat mode
connect_settings_debug_fixed_seed = Use fixed seed
connect_settings_seed = Seed:
connect_settings_wsv = World sync version to use:
connect_settings_player_tether = Player tether enabled
connect_settings_player_tether_desc = Player tether: Teleports clients to host if they get far enough.
connect_settings_player_tether_length = Tether length
connect_settings_item_dedup = Deduplicate (sync) items spawned by world generation.
connect_settings_enemy_hp_scale = Enemy hp scale.
connect_settings_local = Local settings
connect_settings_autostart = Start the game automatically
lang_picker = Choose a language
button_confirm = Confirm
@ -82,3 +68,23 @@ launcher_no_command_2 = Launch command can be specified with --launch-cmd <comma
launcher_no_command_3 = You can put `noita-proxy --launch-cmd "%command%"` in steam's launch options to intercept whatever command steam uses to start the game.
launcher_start_game = Start noita
launcher_only_when_awaiting = Can only launch the game in "waiting for noita connection" state.
connect_settings = Game settings
connect_settings_debug = Debug settings
connect_settings_debug_en = Debug/cheat mode
connect_settings_debug_fixed_seed = Use fixed seed
connect_settings_seed = Seed:
connect_settings_wsv = World sync version to use:
connect_settings_player_tether = Player tether enabled
connect_settings_player_tether_desc = Player tether: Teleports clients to host if they get far enough.
connect_settings_player_tether_length = Tether length
connect_settings_item_dedup = Deduplicate (sync) items spawned by world generation.
connect_settings_enemy_hp_scale = Enemy hp scale.
connect_settings_local = Local settings
connect_settings_autostart = Start the game automatically
## Game settings
Higher-values-result-in-less-performance-impact = Higher values result in less performance impact.
World-will-be-synced-every-this-many-frames = World will be synced every this many frames.

View file

@ -7,20 +7,6 @@ connect_steam_connect_invalid_lobby_id = クリップボードにロビーIDが
connect_ip = IP接続する
connect_settings = ゲーム設定
connect_settings_debug = デバッグ設定
connect_settings_debug_en = デバッグ/チートモード
connect_settings_debug_fixed_seed = 固定Seedを利用する
connect_settings_seed = Seed:
connect_settings_wsv = World syncに利用する同期バージョン:
connect_settings_player_tether = プレイヤーテザーを有効にする
connect_settings_player_tether_desc = プレイヤーテザーとは: 参加者がホストから一定の範囲以上離れた場合にてレポートする
connect_settings_player_tether_length = テザーの長さ
connect_settings_item_dedup = ワールド生成の同期で重複したアイテムを削除する
connect_settings_enemy_hp_scale = 敵HPのスケーリング
connect_settings_local = ローカル設定
connect_settings_autostart = ゲームを自動的に開始する
lang_picker = 言語を選択する
button_confirm = 確認
@ -82,3 +68,23 @@ launcher_no_command_2 = 起動コマンドは --launch-cmd <command> オプシ
launcher_no_command_3 = Steamの起動オプションに `noita-proxy --launch-cmd "%command%"` を入力すると、Steamがゲームを開始する際のコマンドを確認できます。
launcher_start_game = Noitaを開始する
launcher_only_when_awaiting = 「Noita接続待機中」状態のときのみゲームを開始できます。
connect_settings = ゲーム設定
connect_settings_debug = デバッグ設定
connect_settings_debug_en = デバッグ/チートモード
connect_settings_debug_fixed_seed = 固定Seedを利用する
connect_settings_seed = Seed:
connect_settings_wsv = World syncに利用する同期バージョン:
connect_settings_player_tether = プレイヤーテザーを有効にする
connect_settings_player_tether_desc = プレイヤーテザーとは: 参加者がホストから一定の範囲以上離れた場合にてレポートする
connect_settings_player_tether_length = テザーの長さ
connect_settings_item_dedup = ワールド生成の同期で重複したアイテムを削除する
connect_settings_enemy_hp_scale = 敵HPのスケーリング
connect_settings_local = ローカル設定
connect_settings_autostart = ゲームを自動的に開始する
## Game settings
Higher-values-result-in-less-performance-impact = Higher values result in less performance impact.
World-will-be-synced-every-this-many-frames = World will be synced every this many frames.

View file

@ -65,3 +65,8 @@ error_occured = Произошла ошибка:
error_missing_version_field = Лобби было создано очень старой версией прокси.
error_version_mismatch = Версии прокси не совпадают. Версия хоста: { $remote_version }. Установленная сейчас версия: { $current_version }.
error_lobby_does_not_exist = Лобби не существует.
## Game settings
Higher-values-result-in-less-performance-impact = Higher values result in less performance impact
World-will-be-synced-every-this-many-frames = World will be synced every this many frames

View file

@ -42,6 +42,7 @@ pub struct GameSettings {
use_constant_seed: bool,
item_dedup: bool,
enemy_hp_mult: f32,
world_sync_interval: u32,
}
impl Default for GameSettings {
@ -55,6 +56,7 @@ impl Default for GameSettings {
use_constant_seed: false,
item_dedup: true,
enemy_hp_mult: 1.0,
world_sync_interval: 10,
}
}
}
@ -79,6 +81,7 @@ struct AppSavedState {
nickname: Option<String>,
times_started: u32,
lang_id: Option<LanguageIdentifier>,
#[serde(default)]
game_settings: GameSettings,
start_game_automatically: bool,
}
@ -383,20 +386,21 @@ impl App {
fn show_game_settings(&mut self, ui: &mut Ui) {
heading_with_underline(ui, tr("connect_settings"));
let game_settings = &mut self.saved_state.game_settings;
ui.label(tr("connect_settings_debug"));
ui.checkbox(
&mut self.saved_state.game_settings.debug_mode,
&mut game_settings.debug_mode,
tr("connect_settings_debug_en"),
);
ui.checkbox(
&mut self.saved_state.game_settings.use_constant_seed,
&mut game_settings.use_constant_seed,
tr("connect_settings_debug_fixed_seed"),
);
ui.horizontal(|ui| {
ui.label(tr("connect_settings_seed"));
ui.add(DragValue::new(&mut self.saved_state.game_settings.seed));
ui.add(DragValue::new(&mut game_settings.seed));
});
ui.add_space(20.0);
@ -404,32 +408,40 @@ impl App {
ui.label(tr("connect_settings_wsv"));
ui.horizontal(|ui| {
ui.radio_value(
&mut self.saved_state.game_settings.world_sync_version,
&mut game_settings.world_sync_version,
1,
"v1",
);
ui.radio_value(
&mut self.saved_state.game_settings.world_sync_version,
&mut game_settings.world_sync_version,
2,
"v2",
);
});
if game_settings.world_sync_version == 2 {
ui.add_space(10.0);
ui.label(tr("World-will-be-synced-every-this-many-frames"));
ui.label(tr("Higher-values-result-in-less-performance-impact"));
ui.add(Slider::new(&mut game_settings.world_sync_interval, 1..=60));
}
ui.add_space(20.0);
ui.label(tr("connect_settings_player_tether_desc"));
ui.checkbox(
&mut self.saved_state.game_settings.player_tether,
&mut game_settings.player_tether,
tr("connect_settings_player_tether"),
);
ui.add(
Slider::new(&mut self.saved_state.game_settings.tether_length, 10..=5000)
Slider::new(&mut game_settings.tether_length, 10..=5000)
.text(tr("connect_settings_player_tether_length")),
);
ui.add_space(20.0);
ui.checkbox(&mut self.saved_state.game_settings.item_dedup, tr("connect_settings_item_dedup"));
ui.checkbox(&mut game_settings.item_dedup, tr("connect_settings_item_dedup"));
ui.add_space(20.0);
ui.add(Slider::new(&mut self.saved_state.game_settings.enemy_hp_mult, 1.0..=1000.0).logarithmic(true).text(tr("connect_settings_enemy_hp_scale")));
ui.add(Slider::new(&mut game_settings.enemy_hp_mult, 1.0..=1000.0).logarithmic(true).text(tr("connect_settings_enemy_hp_scale")));
heading_with_underline(ui, tr("connect_settings_local"));
ui.checkbox(

View file

@ -325,6 +325,7 @@ impl NetManager {
state.try_ws_write_option("tether_length", settings.tether_length);
state.try_ws_write_option("item_dedup", settings.item_dedup);
state.try_ws_write_option("enemy_hp_scale", settings.enemy_hp_mult);
state.try_ws_write_option("world_sync_interval", settings.world_sync_interval);
state.try_ws_write(ws_encode_proxy("ready", ""));
// TODO? those are currently ignored by mod

View file

@ -25,7 +25,7 @@ function world_sync.on_world_update()
local chunk_map = grid_world.vtable.get_chunk_map(grid_world)
local thread_impl = grid_world.mThreadImpl
if GameGetFrameNum() % 10 == 0 then
if GameGetFrameNum() % ctx.proxy_opt.world_sync_interval == 0 then
local player_data = ctx.my_player
if not EntityGetIsAlive(player_data.entity) then
return