77
88namespace maniac {
99 struct config {
10+ static constexpr int VERSION = 2 ;
11+
1012 static constexpr auto STATIC_HUMANIZATION = 0 ;
1113 static constexpr auto DYNAMIC_HUMANIZATION = 1 ;
1214
1315 int tap_time = 20 ;
1416 bool mirror_mod = false ;
1517 int compensation_offset = -15 ;
1618 int humanization_modifier = 0 ;
17- std::pair<int , int > randomization_range = { 0 , 0 };
19+ int randomization_mean = 0 ;
20+ int randomization_stddev = 0 ;
1821 int humanization_type = DYNAMIC_HUMANIZATION;
1922
2023 // TODO: This isn't configurable yet, use a non-shit config format
@@ -31,12 +34,23 @@ namespace maniac {
3134 return ;
3235 }
3336
37+ int version = -1 ;
38+
39+ file.read (reinterpret_cast <char *>(&version), sizeof version);
40+
41+ if (version != VERSION) {
42+ // TODO: Use a non-shit config format
43+ debug (" config has outdated version, ignoring" );
44+
45+ return ;
46+ }
47+
3448 file.read (reinterpret_cast <char *>(&tap_time), sizeof tap_time);
3549 file.read (reinterpret_cast <char *>(&mirror_mod), sizeof mirror_mod);
3650 file.read (reinterpret_cast <char *>(&compensation_offset), sizeof compensation_offset);
3751 file.read (reinterpret_cast <char *>(&humanization_modifier), sizeof humanization_modifier);
38- file.read (reinterpret_cast <char *>(&randomization_range. first ), sizeof randomization_range. first );
39- file.read (reinterpret_cast <char *>(&randomization_range. second ), sizeof randomization_range. second );
52+ file.read (reinterpret_cast <char *>(&randomization_mean ), sizeof randomization_mean );
53+ file.read (reinterpret_cast <char *>(&randomization_stddev ), sizeof randomization_stddev );
4054 file.read (reinterpret_cast <char *>(&humanization_type), sizeof humanization_type);
4155
4256 debug (" loaded config from file" );
@@ -51,12 +65,15 @@ namespace maniac {
5165 return ;
5266 }
5367
68+ int version = VERSION;
69+
70+ file.write (reinterpret_cast <char *>(&version), sizeof version);
5471 file.write (reinterpret_cast <char *>(&tap_time), sizeof tap_time);
5572 file.write (reinterpret_cast <char *>(&mirror_mod), sizeof mirror_mod);
5673 file.write (reinterpret_cast <char *>(&compensation_offset), sizeof compensation_offset);
5774 file.write (reinterpret_cast <char *>(&humanization_modifier), sizeof humanization_modifier);
58- file.write (reinterpret_cast <char *>(&randomization_range. first ), sizeof randomization_range. first );
59- file.write (reinterpret_cast <char *>(&randomization_range. second ), sizeof randomization_range. second );
75+ file.write (reinterpret_cast <char *>(&randomization_mean ), sizeof randomization_mean );
76+ file.write (reinterpret_cast <char *>(&randomization_stddev ), sizeof randomization_stddev );
6077 file.write (reinterpret_cast <char *>(&humanization_type), sizeof humanization_type);
6178
6279 debug (" wrote config to file" );
0 commit comments