File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,10 @@ const PACKED_LEN: usize = {
11
11
}
12
12
} ;
13
13
14
+ pub fn empty ( ) -> Vec < Packed > {
15
+ ( 0 ..PACKED_LEN ) . map ( |_| 0 ) . collect ( )
16
+ }
17
+
14
18
pub fn pack_bools ( bools : & [ bool ] ) -> Vec < Packed > {
15
19
let mut bytes = Vec :: with_capacity ( bools. len ( ) / PACKED_SIZE + 1 ) ;
16
20
for chunk in bools. chunks ( PACKED_SIZE ) {
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ use serde::Deserialize;
4
4
5
5
use tracing:: error;
6
6
7
- use common:: saves:: pack_bools;
7
+ use common:: saves:: { empty , pack_bools} ;
8
8
9
9
#[ derive( Debug , Deserialize ) ]
10
10
pub struct SaveFile {
@@ -37,6 +37,9 @@ pub fn read_save_packed(path: &Path) -> Option<Vec<common::saves::Packed>> {
37
37
let save = SaveFile :: load ( path)
38
38
. inspect_err ( |e| error ! ( "failed to load save file: {e}" ) )
39
39
. ok ( ) ?;
40
+ if save. fact_saves . is_empty ( ) {
41
+ return Some ( empty ( ) ) ;
42
+ }
40
43
let bools = save. learned_as_bools ( ) ;
41
44
Some ( pack_bools ( & bools) )
42
45
}
You can’t perform that action at this time.
0 commit comments