Send game options to player at connection

This commit is contained in:
Sofia 2026-08-03 19:51:49 +03:00
parent ad574ec381
commit 6ba4e37bab
3 changed files with 7 additions and 2 deletions

View File

@ -2,7 +2,7 @@ use std::collections::HashMap;
use serde::{Deserialize, Serialize};
#[derive(Debug)]
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GameOptions {
pub values: HashMap<GameOption, GameOptionValue>,
}

View File

@ -12,7 +12,7 @@ use crate::{
announcer::Announcement,
game::{
Game, GameManager, NetPlayer,
opts::{GameOption, GameOptionValue},
opts::{GameOption, GameOptionValue, GameOptions},
},
game_settings::GameSettingsManager,
net::{net_stats::Stats, util::NetVector3},
@ -321,6 +321,7 @@ pub enum Package {
NewPlayer(NetPlayer),
PlayerLeft(NetPlayer),
SetTeam(u16, u8),
GameOptions(GameOptions),
GameOptionChanged(GameOption, GameOptionValue),
ChatMessage(u16, String),

View File

@ -264,6 +264,10 @@ impl NetworkManager {
self_id,
),
);
peer.send_reliable(
&connection.address,
Package::GameOptions(game.bind().opts.clone()),
);
peer.broadcast_reliable(Package::NewPlayer(
game.bind().find_player(self_id).unwrap().clone().into(),
));