big steppy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

38 lines
947 B

  1. // bumps save versions
  2. migrations = [
  3. (save) => {
  4. // does nothing
  5. }
  6. ];
  7. function migrate(save, target=null) {
  8. if (target == null) {
  9. target = migrations.length;
  10. }
  11. let version = save.version;
  12. if (version == undefined) {
  13. alert("This save is from before versioning was added. It can't be automatically updated, and it might lose some settings. Double check that everything's there! Any subsequent saves will work correctly.");
  14. save["version"] = migrations.length;
  15. return false;
  16. }
  17. if (version == 0 ) {
  18. alert("This save is from before v1.0. It can't be automatically migrated, so it may lose some settings. Double check the resulting character. Subsequent saves will function correctly.");
  19. save["version"] = migrations.length;
  20. return false;
  21. }
  22. if (version < target) {
  23. for (let x = version; x < target; x++) {
  24. migrations[x](save);
  25. }
  26. } else {
  27. return false;
  28. }
  29. return true;
  30. }