migration.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. "use strict"
  2. const DefaultSettings = {
  3. skills: {
  4. jitterCompensation: true,
  5. retryCount: 3, // Number of times to retry each skill (0 = disabled). Recommended 1-3.
  6. retryMs: 25, /* Time to wait between each retry.
  7. SKILL_RETRY_MS * SKILL_RETRY_COUNT should be under 100, otherwise skills may go off twice.
  8. */
  9. longRetryCount: 5, // Only used for Warrior: Blade Waltz
  10. longRetryMs: 80,
  11. retryJittercomp: 15, // Skills that support retry will be sent this much earlier than estimated by jitter compensation.
  12. delayOnFail: true, // Basic initial desync compensation. Useless at low ping (<50ms).
  13. chargeJitterMax: 50, /* Maximum jitter delay to add to charging skills.
  14. Detected network jitter will be capped by this number. Skill-specific jitter is not capped.
  15. */
  16. serverTimeout: 400, /* This number is added to your maximum ping + skill retry period to set the failure threshold for skills.
  17. If animations are being cancelled while damage is still applied, increase this number.
  18. */
  19. forceClipStrict: true, /* Set this to false for smoother, less accurate iframing near walls.
  20. Warning: Will cause occasional clipping through gates when disabled. Do NOT abuse this.
  21. */
  22. defendSuccessStrict: true // [Brawler] Set this to false to see the Perfect Block icon at very high ping (warning: may crash client).
  23. },
  24. ping: {
  25. interval: 4300, // Interval between pings. Recommended 2000-3000ms for WiFi or unstable connections, 6000ms for wired.
  26. timeout: 30000, // Milliseconds to wait before giving up and retrying ping.
  27. maxHistory: 30 // Maximum number of ping samples used to calculate min/max/avg values.
  28. },
  29. debug: {
  30. skills: false,
  31. loc: false,
  32. glyphs: false,
  33. projectiles: false,
  34. abnormals: false
  35. }
  36. }
  37. function MigrateSettings(from_ver, to_ver, settings) {
  38. if (from_ver === undefined) {
  39. // Migrate legacy config file
  40. return Object.assign(Object.assign({}, DefaultSettings), settings);
  41. } else if (from_ver === null) {
  42. // No config file exists, use default settings
  43. return DefaultSettings;
  44. } else {
  45. // Migrate from older version (using the new system) to latest one
  46. if (from_ver + 1 < to_ver) {
  47. // Recursively upgrade in one-version steps
  48. settings = MigrateSettings(from_ver, from_ver + 1, settings);
  49. return MigrateSettings(from_ver + 1, to_ver, settings);
  50. }
  51. // If we reach this point it's guaranteed that from_ver === to_ver - 1, so we can implement
  52. // a switch for each version step that upgrades to the next version. This enables us to
  53. // upgrade from any version to the latest version without additional effort!
  54. switch(to_ver)
  55. {
  56. // keep old settings that still exist, add new ones
  57. default:
  58. let oldsettings = settings;
  59. settings = Object.assign(DefaultSettings, {});
  60. for(let option in oldsettings)
  61. if(settings[option]) settings[option] = oldsettings[option];
  62. break;
  63. }
  64. return settings;
  65. }
  66. }
  67. module.exports = MigrateSettings;