fixed IDs with numerical IDs not saving powers of 64 correctly.

This commit is contained in:
ferricles 2021-04-20 14:48:29 -07:00
parent f7f244384d
commit d7b90b5d72
2 changed files with 4 additions and 2 deletions

View file

@ -251,12 +251,13 @@ function encodeCustom(custom, verbose) {
let val_max = custom.get("maxRolls").has(id) ? custom.get("maxRolls").get(id) : 0; let val_max = custom.get("maxRolls").has(id) ? custom.get("maxRolls").get(id) : 0;
let sign = (Boolean(val_min / Math.abs(val_min) < 0) | 0) + 2*(Boolean(val_max / Math.abs(val_max) < 0) | 0) // 0 - both pos 1 - min neg max pos 2 - min pos max neg (how?) 3 - min neg max neg let sign = (Boolean(val_min / Math.abs(val_min) < 0) | 0) + 2*(Boolean(val_max / Math.abs(val_max) < 0) | 0) // 0 - both pos 1 - min neg max pos 2 - min pos max neg (how?) 3 - min neg max neg
//console.log(id + ": " + sign); //console.log(id + ": " + sign);
let min_len = Math.max(1,Math.ceil(log(64,Math.abs(val_min)))); let min_len = Math.max(1,Math.ceil(log(64,Math.abs(val_min)+1)));
let max_len = Math.max(1,Math.ceil(log(64,Math.abs(val_max)))); let max_len = Math.max(1,Math.ceil(log(64,Math.abs(val_max)+1)));
let len = Math.max(min_len,max_len); let len = Math.max(min_len,max_len);
val_min = Math.abs(val_min); val_min = Math.abs(val_min);
val_max = Math.abs(val_max); val_max = Math.abs(val_max);
if ( val_min != 0 || val_max != 0 ) { if ( val_min != 0 || val_max != 0 ) {
//hash += Base64.fromIntN(i,2) + Base64.fromIntN(val_min,Math.max(1,Math.ceil(log(64,Math.abs(val_min))))) + ":" + Base64.fromIntN(val_max,Math.max(1,Math.ceil(log(64,Math.abs(val_min))))) + "_"; //hash += Base64.fromIntN(i,2) + Base64.fromIntN(val_min,Math.max(1,Math.ceil(log(64,Math.abs(val_min))))) + ":" + Base64.fromIntN(val_max,Math.max(1,Math.ceil(log(64,Math.abs(val_min))))) + "_";
if (custom.get("fixID")) { if (custom.get("fixID")) {
@ -321,6 +322,7 @@ function decodeCustom(custom_url_tag) {
while (tag !== "") { while (tag !== "") {
let id = ci_save_order[Base64.toInt(tag.slice(0,2))]; let id = ci_save_order[Base64.toInt(tag.slice(0,2))];
let len = Base64.toInt(tag.slice(2,4)); let len = Base64.toInt(tag.slice(2,4));
console.log(id);
if (rolledIDs.includes(id)) { if (rolledIDs.includes(id)) {
let sign = parseInt(tag.slice(4,5),10); let sign = parseInt(tag.slice(4,5),10);
let minRoll = Base64.toInt(tag.slice(5,5+len)); let minRoll = Base64.toInt(tag.slice(5,5+len));

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 18 KiB