1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 09:21:46 +00:00

Fixed NaN checks

This commit is contained in:
Harley White 2021-06-02 17:39:19 -04:00
parent d1c00d681e
commit b123b19ca5
3 changed files with 36 additions and 16 deletions

View file

@ -1,11 +1,12 @@
# The Modding Tree changelog:
- Fixed issues with NaN checking. Saves should never break now unless something really unusual happens.
- Fixed demo.html
- You can now use "this" in tabFormat!
- The prestige/sec display now shows decimals.
- resetsNothing now works immediately on a reset that enables it.
- Added onComplete for milestones.
- Added addBuyables.
- The prestige/sec display now shows decimals.
- resetsNothing now works immediately on a reset that enables it.
- Fixed challenges with no currencyDisplayName using "points" instead of the mod's pointsName.
- inChallenge no longer can return undefined.

View file

@ -84,6 +84,7 @@ function setupTempData(layerData, tmpData, funcsData) {
}
}
function updateTemp() {
if (tmp === undefined)
setupTemp()
@ -91,16 +92,34 @@ function updateTemp() {
updateTempData(layers, tmp, funcs)
for (layer in layers){
let problem = ""
tmp[layer].resetGain = getResetGain(layer)
if (checkDecimalNaN(tmp[layer].resetGain))
problem = "resetGain"
tmp[layer].nextAt = getNextAt(layer)
if (checkDecimalNaN(tmp[layer].nextAt))
problem = "nextAt"
tmp[layer].nextAtDisp = getNextAt(layer, true)
tmp[layer].canReset = canReset(layer)
tmp[layer].trueGlowColor = tmp[layer].glowColor
tmp[layer].notify = shouldNotify(layer)
tmp[layer].prestigeNotify = prestigeNotify(layer)
if (problem && !NaNalert) {
confirm("Invalid value found in temp." + layer + "." + problem + ". Please let the creator of this mod know! You can refresh the page, and you will be un-NaNed.")
clearInterval(interval);
NaNalert = true;
return
}
}
tmp.pointGen = getPointGen()
if (checkDecimalNaN(tmp.pointGen) && !NaNalert) {
confirm("Invalid value found in temp.pointGen. Please let the creator of this mod know! You can refresh the page, and you will be un-NaNed.")
clearInterval(interval);
NaNalert = true;
return
}
tmp.displayThings = []
for (thing in displayThings){
let text = displayThings[thing]
@ -123,15 +142,12 @@ function updateTempData(layerData, tmpData, funcsData, useThis) {
if (useThis !== undefined) value = layerData[item].bind(useThis)()
else value = layerData[item]()
if (value !== value || value === decimalNaN){
if (NaNalert === true || confirm ("Invalid value found in tmp, named '" + item + "'. Please let the creator of this mod know! Would you like to try to auto-fix the save and keep going?")){
NaNalert = true
value = (value !== value ? 0 : decimalZero)
}
else {
if (value !== value || checkDecimalNaN(value)){
if (!NaNalert) {
confirm("Invalid value found in tmp, named '" + item + "'. Please let the creator of this mod know! You can refresh the page, and you will be un-NaNed.")
clearInterval(interval);
player.autosave = false;
NaNalert = true;
return
}
}
Vue.set(tmpData, item, value)
@ -172,3 +188,7 @@ function setupBuyables(layer) {
}
}
}
function checkDecimalNaN(x) {
return (x instanceof Decimal) && !x.eq(x)
}

View file

@ -1,5 +1,6 @@
// ************ Save stuff ************
function save() {
if (NaNalert) return
localStorage.setItem(modInfo.id, btoa(unescape(encodeURIComponent(JSON.stringify(player)))));
}
function startPlayerBase() {
@ -228,15 +229,12 @@ function NaNcheck(data) {
else if (Array.isArray(data[item])) {
NaNcheck(data[item]);
}
else if (data[item] !== data[item] || data[item] === decimalNaN) {
if (NaNalert === true || confirm("Invalid value found in player, named '" + item + "'. Please let the creator of this mod know! Would you like to try to auto-fix the save and keep going?")) {
NaNalert = true;
data[item] = (data[item] !== data[item] ? 0 : decimalZero);
}
else {
else if (data[item] !== data[item] || checkDecimalNaN(data[item])) {
if (!NaNalert) {
confirm("Invalid value found in player, named '" + item + "'. Please let the creator of this mod know! You can refresh the page, and you will be un-NaNed.")
clearInterval(interval);
player.autosave = false;
NaNalert = true;
return
}
}
else if (data[item] instanceof Decimal) { // Convert to Decimal
@ -247,6 +245,7 @@ function NaNcheck(data) {
}
}
function exportSave() {
if (NaNalert) return
let str = btoa(JSON.stringify(player));
const el = document.createElement("textarea");