Send game options to player at connection
This commit is contained in:
parent
ad574ec381
commit
6ba4e37bab
@ -2,7 +2,7 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct GameOptions {
|
pub struct GameOptions {
|
||||||
pub values: HashMap<GameOption, GameOptionValue>,
|
pub values: HashMap<GameOption, GameOptionValue>,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ use crate::{
|
|||||||
announcer::Announcement,
|
announcer::Announcement,
|
||||||
game::{
|
game::{
|
||||||
Game, GameManager, NetPlayer,
|
Game, GameManager, NetPlayer,
|
||||||
opts::{GameOption, GameOptionValue},
|
opts::{GameOption, GameOptionValue, GameOptions},
|
||||||
},
|
},
|
||||||
game_settings::GameSettingsManager,
|
game_settings::GameSettingsManager,
|
||||||
net::{net_stats::Stats, util::NetVector3},
|
net::{net_stats::Stats, util::NetVector3},
|
||||||
@ -321,6 +321,7 @@ pub enum Package {
|
|||||||
NewPlayer(NetPlayer),
|
NewPlayer(NetPlayer),
|
||||||
PlayerLeft(NetPlayer),
|
PlayerLeft(NetPlayer),
|
||||||
SetTeam(u16, u8),
|
SetTeam(u16, u8),
|
||||||
|
GameOptions(GameOptions),
|
||||||
GameOptionChanged(GameOption, GameOptionValue),
|
GameOptionChanged(GameOption, GameOptionValue),
|
||||||
ChatMessage(u16, String),
|
ChatMessage(u16, String),
|
||||||
|
|
||||||
|
|||||||
@ -264,6 +264,10 @@ impl NetworkManager {
|
|||||||
self_id,
|
self_id,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
peer.send_reliable(
|
||||||
|
&connection.address,
|
||||||
|
Package::GameOptions(game.bind().opts.clone()),
|
||||||
|
);
|
||||||
peer.broadcast_reliable(Package::NewPlayer(
|
peer.broadcast_reliable(Package::NewPlayer(
|
||||||
game.bind().find_player(self_id).unwrap().clone().into(),
|
game.bind().find_player(self_id).unwrap().clone().into(),
|
||||||
));
|
));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user