summaryrefslogtreecommitdiff
path: root/src/global_json.rs
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2020-04-20 20:03:48 +0200
committerJustin Wernick <justin@worthe-it.co.za>2020-04-20 20:03:48 +0200
commit52ade984643c6482ccf0deeea98f7f63fa74045d (patch)
tree7fdac25e3f5cae097d7053f2d8dd284d6d49b4ee /src/global_json.rs
parent7f2d82e15459fc3d365674e3772aed6c3d443ca2 (diff)
Split oils and muds into their own lists
Now memory for one isn't affected by memory usage of the other!
Diffstat (limited to 'src/global_json.rs')
-rw-r--r--src/global_json.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/global_json.rs b/src/global_json.rs
index af69157..7ac109a 100644
--- a/src/global_json.rs
+++ b/src/global_json.rs
@@ -101,13 +101,17 @@ impl JsonState {
Ok(GameState {
status: GameStatus::Continue,
players: [self.players[0].to_player()?, self.players[1].to_player()?],
- obstacles: Rc::new(
+ muds: Rc::new(
self.blocks
.iter()
- .filter(|cell| {
- cell.surface_object == JsonSurfaceObject::Mud
- || cell.surface_object == JsonSurfaceObject::OilSpill
- })
+ .filter(|cell| cell.surface_object == JsonSurfaceObject::Mud)
+ .map(|cell| cell.position.to_position())
+ .collect(),
+ ),
+ oil_spills: Rc::new(
+ self.blocks
+ .iter()
+ .filter(|cell| cell.surface_object == JsonSurfaceObject::OilSpill)
.map(|cell| cell.position.to_position())
.collect(),
),