mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2024-11-21 16:13:55 +00:00
Fixed NaN checks
This commit is contained in:
parent
d1c00d681e
commit
b123b19ca5
3 changed files with 36 additions and 16 deletions
|
@ -1,11 +1,12 @@
|
||||||
# The Modding Tree changelog:
|
# The Modding Tree changelog:
|
||||||
|
|
||||||
|
- Fixed issues with NaN checking. Saves should never break now unless something really unusual happens.
|
||||||
- Fixed demo.html
|
- Fixed demo.html
|
||||||
- You can now use "this" in tabFormat!
|
- 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 onComplete for milestones.
|
||||||
- Added addBuyables.
|
- 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.
|
- Fixed challenges with no currencyDisplayName using "points" instead of the mod's pointsName.
|
||||||
- inChallenge no longer can return undefined.
|
- inChallenge no longer can return undefined.
|
||||||
|
|
|
@ -84,6 +84,7 @@ function setupTempData(layerData, tmpData, funcsData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function updateTemp() {
|
function updateTemp() {
|
||||||
if (tmp === undefined)
|
if (tmp === undefined)
|
||||||
setupTemp()
|
setupTemp()
|
||||||
|
@ -91,16 +92,34 @@ function updateTemp() {
|
||||||
updateTempData(layers, tmp, funcs)
|
updateTempData(layers, tmp, funcs)
|
||||||
|
|
||||||
for (layer in layers){
|
for (layer in layers){
|
||||||
|
let problem = ""
|
||||||
tmp[layer].resetGain = getResetGain(layer)
|
tmp[layer].resetGain = getResetGain(layer)
|
||||||
|
if (checkDecimalNaN(tmp[layer].resetGain))
|
||||||
|
problem = "resetGain"
|
||||||
tmp[layer].nextAt = getNextAt(layer)
|
tmp[layer].nextAt = getNextAt(layer)
|
||||||
|
if (checkDecimalNaN(tmp[layer].nextAt))
|
||||||
|
problem = "nextAt"
|
||||||
tmp[layer].nextAtDisp = getNextAt(layer, true)
|
tmp[layer].nextAtDisp = getNextAt(layer, true)
|
||||||
tmp[layer].canReset = canReset(layer)
|
tmp[layer].canReset = canReset(layer)
|
||||||
tmp[layer].trueGlowColor = tmp[layer].glowColor
|
tmp[layer].trueGlowColor = tmp[layer].glowColor
|
||||||
tmp[layer].notify = shouldNotify(layer)
|
tmp[layer].notify = shouldNotify(layer)
|
||||||
tmp[layer].prestigeNotify = prestigeNotify(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()
|
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 = []
|
tmp.displayThings = []
|
||||||
for (thing in displayThings){
|
for (thing in displayThings){
|
||||||
let text = displayThings[thing]
|
let text = displayThings[thing]
|
||||||
|
@ -123,15 +142,12 @@ function updateTempData(layerData, tmpData, funcsData, useThis) {
|
||||||
|
|
||||||
if (useThis !== undefined) value = layerData[item].bind(useThis)()
|
if (useThis !== undefined) value = layerData[item].bind(useThis)()
|
||||||
else value = layerData[item]()
|
else value = layerData[item]()
|
||||||
if (value !== value || value === decimalNaN){
|
if (value !== value || checkDecimalNaN(value)){
|
||||||
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?")){
|
if (!NaNalert) {
|
||||||
NaNalert = true
|
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.")
|
||||||
value = (value !== value ? 0 : decimalZero)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
player.autosave = false;
|
|
||||||
NaNalert = true;
|
NaNalert = true;
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Vue.set(tmpData, item, value)
|
Vue.set(tmpData, item, value)
|
||||||
|
@ -171,4 +187,8 @@ function setupBuyables(layer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkDecimalNaN(x) {
|
||||||
|
return (x instanceof Decimal) && !x.eq(x)
|
||||||
}
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
// ************ Save stuff ************
|
// ************ Save stuff ************
|
||||||
function save() {
|
function save() {
|
||||||
|
if (NaNalert) return
|
||||||
localStorage.setItem(modInfo.id, btoa(unescape(encodeURIComponent(JSON.stringify(player)))));
|
localStorage.setItem(modInfo.id, btoa(unescape(encodeURIComponent(JSON.stringify(player)))));
|
||||||
}
|
}
|
||||||
function startPlayerBase() {
|
function startPlayerBase() {
|
||||||
|
@ -228,15 +229,12 @@ function NaNcheck(data) {
|
||||||
else if (Array.isArray(data[item])) {
|
else if (Array.isArray(data[item])) {
|
||||||
NaNcheck(data[item]);
|
NaNcheck(data[item]);
|
||||||
}
|
}
|
||||||
else if (data[item] !== data[item] || data[item] === decimalNaN) {
|
else if (data[item] !== data[item] || checkDecimalNaN(data[item])) {
|
||||||
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?")) {
|
if (!NaNalert) {
|
||||||
NaNalert = true;
|
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.")
|
||||||
data[item] = (data[item] !== data[item] ? 0 : decimalZero);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
player.autosave = false;
|
|
||||||
NaNalert = true;
|
NaNalert = true;
|
||||||
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (data[item] instanceof Decimal) { // Convert to Decimal
|
else if (data[item] instanceof Decimal) { // Convert to Decimal
|
||||||
|
@ -247,6 +245,7 @@ function NaNcheck(data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function exportSave() {
|
function exportSave() {
|
||||||
|
if (NaNalert) return
|
||||||
let str = btoa(JSON.stringify(player));
|
let str = btoa(JSON.stringify(player));
|
||||||
|
|
||||||
const el = document.createElement("textarea");
|
const el = document.createElement("textarea");
|
||||||
|
|
Loading…
Reference in a new issue