Remember each used customer name once
S.usedNames only answers "was this name used?", but every offer pushed its name again, also once all names were taken: a 5,500-day save holds 560,345 entries for 129 names, 11.8 of its 22.4 million characters. Names are now added once (useName), and sanitize() drops duplicates from older saves. Player save, 30 days from load, against main: routing and the whole state except usedNames identical, usedNames identical as a set; save 22.4 -> 10.6 million characters, first save in Firefox 95 -> 55 ms, JSON.stringify 68 -> 42 ms. Still over Firefox's quota on this save.
This commit is contained in:
parent
d7301747f7
commit
22817c83c5
7 changed files with 19 additions and 5 deletions
|
|
@ -6,6 +6,9 @@ const pct=x=>Math.round(x*100)+'%';
|
|||
const reachPct=x=>x>0.999?'100%':x>=0.99?(Math.floor(x*1000)/10).toFixed(1)+'%':pct(x);
|
||||
const clamp=(v,a,b)=>Math.max(a,Math.min(b,v));
|
||||
const pick=a=>a[Math.floor(Math.random()*a.length)];
|
||||
// Names already given to customers, each once: only whether a name is in the list counts. Once every name had been
|
||||
// used, the same names were added again every day (half a million entries, half of a late-game save).
|
||||
const useName=n=>{if(!S.usedNames.includes(n))S.usedNames.push(n);};
|
||||
const esc=s=>String(s).replace(/[&<>"']/g,c=>({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||||
function dateStr(d){const y=1+Math.floor(d/360),m=Math.floor(d/30)%12,dd=d%30+1;return tr('helpers.y_y_mon_d',{y,mon:MONTHS[m],d:dd});}
|
||||
function wrapDx(a,b){let dx=b-a;if(dx>W/2)dx-=W;if(dx<-W/2)dx+=W;return dx;}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue