-
Notifications
You must be signed in to change notification settings - Fork 1
/
setting_migration.js
71 lines (63 loc) · 1.58 KB
/
setting_migration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
'use strict'
let DefaultSettings = {
"enabled": true,
"loadExtra": false,
"safeMode": true,
"blockedZones": [
9950
],
"loadExtraMs": {
"value": 1000,
"name": "Load Extra Ms"
},
"loadDistance": {
"value": 1000,
"name": "Load Distance"
}
}
module.exports = function MigrateSettings(from_ver, to_ver, settings) {
if(from_ver === undefined) {
return Object.assign(Object.assign({}, DefaultSettings), settings);
} else if(from_ver === null) {
return DefaultSettings;
} else {
if (from_ver + 1 < to_ver) {
settings = MigrateSettings(from_ver, from_ver + 1, settings);
return MigrateSettings(from_ver + 1, to_ver, settings);
}
switch(to_ver)
{
case 2:
settings.enabled = true;
break;
case 3: //safe mode and new config format
settings.options = {
loadDistance: {
name: "Load Distance",
value: settings.loadDistance
},
loadExtraMs: {
name: "Load Extra Ms",
value: settings.loadExtraMs
}
};
settings.safeMode = true;
delete settings.loadDistance;
delete settings.loadExtraMs;
delete settings.skipCutscenes;
delete settings.skipCutscenesZones;
break;
case 4: //remove redundant options
settings.loadDistance = {
name: settings.options.loadDistance.name,
value: settings.options.loadDistance.value
};
settings.loadExtraMs = {
name: settings.options.loadExtraMs.name,
value: settings.options.loadExtraMs.value
};
delete settings.options;
}
return settings;
}
}