mirror of
https://git.ngram.ca/OpenJam/rc-servers
synced 2026-08-23 23:08:52 +00:00
Don't send BA map elements to non-players, fix #83
This commit is contained in:
@@ -1617,7 +1617,10 @@ fn is_any_users_in_mode<'a>(wants_mode: ConnectionMode, mut descriptors: impl st
|
|||||||
fn is_all_users_in_mode<'a>(wants_mode: ConnectionMode, mut descriptors: impl std::iter::Iterator<Item = &'a UserDescriptor>) -> bool {
|
fn is_all_users_in_mode<'a>(wants_mode: ConnectionMode, mut descriptors: impl std::iter::Iterator<Item = &'a UserDescriptor>) -> bool {
|
||||||
descriptors.all(|desc| {
|
descriptors.all(|desc| {
|
||||||
let mode = ConnectionMode::from_u8(desc.state.mode.load(std::sync::atomic::Ordering::Relaxed));
|
let mode = ConnectionMode::from_u8(desc.state.mode.load(std::sync::atomic::Ordering::Relaxed));
|
||||||
desc.descriptor.user_id.is_some()
|
desc.descriptor.user_id.is_none()
|
||||||
|
|| (
|
||||||
|
desc.descriptor.user_id.is_some()
|
||||||
&& (mode.to_u8() == wants_mode.to_u8() || matches!(mode, ConnectionMode::Disconnected))
|
&& (mode.to_u8() == wants_mode.to_u8() || matches!(mode, ConnectionMode::Disconnected))
|
||||||
|
)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1352,7 +1352,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn extra_sync_events(&self, generic: &crate::matches::GenericGamemodeEngine<Self>, _connection: &crate::matches::generic::UserConnection, _player: &crate::matches::generic::UserDescriptor) -> Vec<crate::matches::RlnlPacket> {
|
async fn extra_sync_events(&self, generic: &crate::matches::GenericGamemodeEngine<Self>, _connection: &crate::matches::generic::UserConnection, player: &crate::matches::generic::UserDescriptor) -> Vec<crate::matches::RlnlPacket> {
|
||||||
vec![
|
vec![
|
||||||
Some(crate::matches::RlnlPacket {
|
Some(crate::matches::RlnlPacket {
|
||||||
event: rlnl::event_code::NetworkEvent::GameModeSettings,
|
event: rlnl::event_code::NetworkEvent::GameModeSettings,
|
||||||
@@ -1363,7 +1363,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
// TeamBase
|
// TeamBase
|
||||||
if generic.map_config.bases.is_empty() {
|
if generic.map_config.bases.is_empty() || player.descriptor.user_id.is_none() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(crate::matches::RlnlPacket {
|
Some(crate::matches::RlnlPacket {
|
||||||
@@ -1383,7 +1383,7 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
// RegisterCapturePoints
|
// RegisterCapturePoints
|
||||||
if generic.map_config.capture_points.is_empty() {
|
if generic.map_config.capture_points.is_empty() || player.descriptor.user_id.is_none() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(crate::matches::RlnlPacket {
|
Some(crate::matches::RlnlPacket {
|
||||||
@@ -1399,17 +1399,21 @@ impl CustomGameLogic for BattleArenaLogic {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
// RegisterEqualizer
|
// RegisterEqualizer
|
||||||
Some(crate::matches::RlnlPacket {
|
if player.descriptor.user_id.is_none() {
|
||||||
event: rlnl::event_code::NetworkEvent::RegisterEqualizer,
|
None
|
||||||
property: literustlib::packet::Property::ReliableOrdered,
|
} else {
|
||||||
data: Box::new(rlnl::events::sync::GetEqualizer {
|
Some(crate::matches::RlnlPacket {
|
||||||
pos: rlnl::types::PosQuatPair {
|
event: rlnl::event_code::NetworkEvent::RegisterEqualizer,
|
||||||
pos: (generic.map_config.equalizer.x, generic.map_config.equalizer.y, generic.map_config.equalizer.z).into(),
|
property: literustlib::packet::Property::ReliableOrdered,
|
||||||
rot: (0.0, 0.0, 0.0, 0.0).into(),
|
data: Box::new(rlnl::events::sync::GetEqualizer {
|
||||||
},
|
pos: rlnl::types::PosQuatPair {
|
||||||
total_health: self.config.equalizer_health as i32,
|
pos: (generic.map_config.equalizer.x, generic.map_config.equalizer.y, generic.map_config.equalizer.z).into(),
|
||||||
}),
|
rot: (0.0, 0.0, 0.0, 0.0).into(),
|
||||||
}),
|
},
|
||||||
|
total_health: self.config.equalizer_health as i32,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
},
|
||||||
// SetShieldState
|
// SetShieldState
|
||||||
/*if generic.map_config.bases.contains_key(&0) {
|
/*if generic.map_config.bases.contains_key(&0) {
|
||||||
Some(crate::matches::RlnlPacket {
|
Some(crate::matches::RlnlPacket {
|
||||||
|
|||||||
Reference in New Issue
Block a user