aboutsummaryrefslogtreecommitdiff
path: root/server/src/game.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/game.rs')
-rw-r--r--server/src/game.rs21
1 files changed, 8 insertions, 13 deletions
diff --git a/server/src/game.rs b/server/src/game.rs
index 69272159..d7e62413 100644
--- a/server/src/game.rs
+++ b/server/src/game.rs
@@ -25,8 +25,8 @@ use anyhow::{anyhow, bail, Result};
use hurrycurry_protocol::{
glam::{IVec2, Vec2},
movement::MovementBase,
- ClientGamedata, Environment, ItemIndex, ItemLocation, Menu, Message, PacketC, PacketS,
- PlayerID, RecipeIndex, Score, TileIndex,
+ ClientGamedata, ItemIndex, ItemLocation, Menu, Message, PacketC, PacketS, PlayerID,
+ RecipeIndex, Score, TileIndex,
};
use log::{info, warn};
use std::{
@@ -76,8 +76,7 @@ pub struct Game {
end: Option<Instant>,
pub lobby: bool,
- pub environment_next_update: Instant,
- pub environment: Environment,
+ pub environment_effects: HashSet<String>,
pub score_changed: bool,
pub score: Score,
}
@@ -95,13 +94,12 @@ impl Game {
data: Gamedata::default().into(),
players: HashMap::new(),
tiles: HashMap::new(),
- environment_next_update: Instant::now(),
walkable: HashSet::new(),
end: None,
entities: Arc::new(RwLock::new(vec![])),
players_spatial_index: SpatialIndex::default(),
score: Score::default(),
- environment: Environment::default(),
+ environment_effects: HashSet::default(),
score_changed: false,
}
}
@@ -123,7 +121,7 @@ impl Game {
}
self.score = Score::default();
self.end = None;
- self.environment = Environment::default();
+ self.environment_effects.clear();
self.walkable.clear();
}
pub fn load(
@@ -222,7 +220,9 @@ impl Game {
.collect(),
},
});
- out.push(PacketC::UpdateEnvironment(self.environment.clone()));
+ out.push(PacketC::Environment {
+ effects: self.environment_effects.clone(),
+ });
for (&id, player) in &self.players {
out.push(PacketC::AddPlayer {
id,
@@ -599,11 +599,6 @@ impl Game {
let now = Instant::now();
- if self.environment_next_update < now {
- packet_out.push_back(PacketC::UpdateEnvironment(self.environment.clone()));
- self.environment_next_update += Duration::from_secs(5);
- }
-
if let Some(end) = self.end {
self.score.time_remaining = (end - now).as_secs_f64();
if end < now {