Skip to content

Commit 89d8088

Browse files
committed
ref: extract constructor
1 parent 9555a06 commit 89d8088

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

crates/legacy-zebra/src/thordb.rs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,7 @@ static unmove_mask_lo: [u32; 100] = init_move_masks()[3];
7070
static mut database_head: Option<Box<DatabaseType>> = None;
7171
static mut players: PlayerDatabaseType =
7272
PlayerDatabaseType{prolog:
73-
PrologType{creation_century: 0,
74-
creation_year: 0,
75-
creation_month: 0,
76-
creation_day: 0,
77-
game_count: 0,
78-
item_count: 0,
79-
origin_year: 0,
80-
reserved: 0,},
73+
PrologType::new(),
8174
name_buffer:
8275
b"",
8376
player_list: Vec::new(),};
@@ -95,14 +88,7 @@ static mut thor_search: SearchResultType =
9588
};
9689
static mut tournaments: TournamentDatabaseType =
9790
TournamentDatabaseType{prolog:
98-
PrologType{creation_century: 0,
99-
creation_year: 0,
100-
creation_month: 0,
101-
creation_day: 0,
102-
game_count: 0,
103-
item_count: 0,
104-
origin_year: 0,
105-
reserved: 0,},
91+
PrologType::new(),
10692
name_buffer: b"",
10793
tournament_list: Vec::new()};
10894
static mut thor_opening_tree: ThorOpeningTree = ThorOpeningTree::new();

crates/thordb-types/thordb-types.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl PlayerDatabaseType {
7676
};
7777
}
7878
}
79-
#[derive(Copy, Clone)]
79+
#[derive(Clone)]
8080
#[repr(C)]
8181
pub struct PrologType {
8282
pub creation_century: i32,
@@ -88,6 +88,22 @@ pub struct PrologType {
8888
pub origin_year: i32,
8989
pub reserved: i32,
9090
}
91+
92+
impl PrologType {
93+
pub const fn new() -> PrologType {
94+
PrologType {
95+
creation_century: 0,
96+
creation_year: 0,
97+
creation_month: 0,
98+
creation_day: 0,
99+
game_count: 0,
100+
item_count: 0,
101+
origin_year: 0,
102+
reserved: 0,
103+
}
104+
}
105+
}
106+
91107
#[derive(Clone)]
92108
#[repr(C)]
93109
pub struct DatabaseType {

0 commit comments

Comments
 (0)