mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
fix: bugs in new server ecs systems fixed
This commit is contained in:
parent
ee915671ef
commit
6b0e346ec4
@ -809,7 +809,7 @@ impl Server {
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
for entity in to_delete {
|
||||
let _ = self.state.ecs_mut().delete_entity(entity);
|
||||
let _ = self.state.ecs_mut().delete_entity_synced(entity);
|
||||
}
|
||||
|
||||
let before_tick_7 = Instant::now();
|
||||
|
@ -105,11 +105,13 @@ impl<'a> System<'a> for Sys {
|
||||
})
|
||||
})
|
||||
{
|
||||
for (client, regions, _, _) in &mut subscribers {
|
||||
for (client, regions, client_entity, _) in &mut subscribers {
|
||||
if maybe_key
|
||||
.as_ref()
|
||||
.map(|key| !regions.contains(key))
|
||||
.unwrap_or(true)
|
||||
&& *client_entity != entity
|
||||
// Client doesn't need to know about itself
|
||||
{
|
||||
send_initial_unsynced_components(
|
||||
client,
|
||||
|
@ -58,10 +58,15 @@ impl<'a> System<'a> for Sys {
|
||||
// 7. Determine list of regions that are in range and iterate through it
|
||||
// - check if in hashset (hash calc) if not add it
|
||||
let mut regions_to_remove = Vec::new();
|
||||
for (client, subscription, pos, vd) in
|
||||
(&mut clients, &mut subscriptions, &positions, &players)
|
||||
.join()
|
||||
.filter_map(|(c, s, pos, player)| player.view_distance.map(|v| (c, s, pos, v)))
|
||||
for (client, subscription, pos, vd, client_entity) in (
|
||||
&mut clients,
|
||||
&mut subscriptions,
|
||||
&positions,
|
||||
&players,
|
||||
&entities,
|
||||
)
|
||||
.join()
|
||||
.filter_map(|(c, s, pos, player, e)| player.view_distance.map(|v| (c, s, pos, v, e)))
|
||||
{
|
||||
let chunk = (Vec2::<f32>::from(pos.0))
|
||||
.map2(TerrainChunkSize::RECT_SIZE, |e, sz| e as i32 / sz as i32);
|
||||
@ -137,15 +142,17 @@ impl<'a> System<'a> for Sys {
|
||||
// Send client intial info about the entities in this region
|
||||
if subscription.regions.insert(key) {
|
||||
if let Some(region) = region_map.get(key) {
|
||||
for (uid, pos, vel, ori, character_state, _) in (
|
||||
for (uid, pos, vel, ori, character_state, _, _) in (
|
||||
&uids,
|
||||
&positions,
|
||||
velocities.maybe(),
|
||||
orientations.maybe(),
|
||||
character_states.maybe(),
|
||||
region.entities(),
|
||||
&entities,
|
||||
)
|
||||
.join()
|
||||
.filter(|(_, _, _, _, _, _, e)| *e != client_entity)
|
||||
{
|
||||
super::entity_sync::send_initial_unsynced_components(
|
||||
client,
|
||||
|
@ -145,8 +145,8 @@ impl<'a> System<'a> for Sys {
|
||||
terrain
|
||||
.iter()
|
||||
.map(|(k, _)| k)
|
||||
// Don't every chunk every tick (spread over 16 ticks)
|
||||
.filter(|k| k.x.abs() as u64 % 4 + k.y.abs() as u64 % 8 * 4 == tick.0 % 16)
|
||||
// Don't check every chunk every tick (spread over 16 ticks)
|
||||
.filter(|k| k.x.abs() as u64 % 4 + (k.y.abs() as u64 % 4) * 4 == tick.0 % 16)
|
||||
// There shouldn't be to many pending chunks so we will just check them all
|
||||
.chain(chunk_generator.pending_chunks())
|
||||
.for_each(|chunk_key| {
|
||||
|
Loading…
Reference in New Issue
Block a user