Multiplayer continues after a player leaves: AI side takeover, background match while menus are open, match chat, five-tile fog start

This commit is contained in:
Richard Zink committed 2026-11-04 18:07:02 +01:00
1 parent 2721638910
commit dc22e27184
11 files changed
+436 -70

No files matched your search

+12 -1
View File
@@ -7,6 +7,7 @@ use crate::map::*;
use std::collections::VecDeque;
const SIGHT: i32 = 6; // tiles a creature sees along open ground
const START_LIGHT: i32 = 5; // tiles of known ground around a master's core
const FOG_EVERY: f32 = 0.4;
// explored tiles in savegames: one bit per tile, base64
@@ -91,8 +92,18 @@ impl Game {
}
}
}
// the master is never blind at home: the shadow starts away from the core
let (cx, cy) = self.map.core;
for dy in -START_LIGHT..=START_LIGHT {
for dx in -START_LIGHT..=START_LIGHT {
let (x, y) = (cx + 1 + dx, cy + 1 + dy);
if inb(x, y) {
vis[idx(x, y)] = true;
}
}
}
// what the creatures and towers see along open ground (walls stop the view)
let mut eyes: Vec<(usize, i32)> = self.ents.iter().filter(|e| e.alive && !e.held && !e.hero && e.side == 0 && !e.chained).map(|e| (e.tile(), SIGHT)).collect();
let mut eyes: Vec<(usize, i32)> = self.ents.iter().filter(|e| e.alive && !e.held && !e.hero && self.is_master(e.side) && !e.chained).map(|e| (e.tile(), SIGHT)).collect();
eyes.extend(self.towers.iter().filter(|t| !t.hero).map(|t| (t.tile, t.range() as i32 + 1)));
let mut stamp = vec![0u32; n];
let mut q = VecDeque::new();