diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03c501b..e0c8a13 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,7 +7,9 @@ All notable changes to this project are documented here. The project follows
## [Unreleased]
- A plug-in optic that is too short for your subsea cable no longer sends you to submarine terminals and optical engineering, which cannot stretch it (#253). The hint now names the optics that do reach, such as the Sienna WaveMagic 1.6T for Perth to Cape Town. Optics the upgrades can stretch still get the advice.
-
+- A network the game once failed to load is no longer stuck as damaged: the next version of the game tries it again, and its menu has a Try again button. Before, it could only be exported or deleted, even after the cause was fixed.
+- Save files of very large networks import again: the limit went from 8 MB to 64 MB.
+- The Networks tab and the zoomed-in map draw faster on big networks.
- 400G cache boxes: a POP whose routers have 400G or faster ports now gets 400G boxes, at $1,000 a month instead of $400 for 100G, so big caches need fewer boxes and cost less per Gbps. Boxes you already have stay as they are.
- Pick a standard POP: in any POP's Infra tab, make its routers the standard, and every new POP gets that model and number of routers right away, while it is still empty (#240).
- Clarovision now peers only over paid PNIs, like the real carrier, and free only with networks at customer level 11 or above (#213). A PNI you already have with it starts paying the fee.
diff --git a/site/i18n/de.js b/site/i18n/de.js
index 27a98e9..65389fe 100644
--- a/site/i18n/de.js
+++ b/site/i18n/de.js
@@ -3691,7 +3691,7 @@
"sites_peering_caches.your_ticket_was_merged_into_another":"Dein Ticket wurde mit einem anderen Ticket zusammengeführt.
Das wurde als Duplikat von deinem geschlossen.",
"slots.continue":"Weiterspielen",
"slots.continue_this_network":"Dieses Netz weiterspielen",
-"slots.damaged_export_or_delete":"Beschädigt: exportieren oder löschen",
+"slots.damaged_export_or_delete":"Beschädigt: nochmal versuchen, exportieren oder löschen",
"slots.delete":"Löschen",
"slots.delete_forever":"Für immer löschen",
"slots.delete_name":"{name} löschen?",
@@ -3727,6 +3727,7 @@
"slots.that_network_is_gone":"Dieses Netz gibt es nicht mehr.
Es wurde gelöscht, vielleicht in einem anderen Fenster.",
"slots.this_window_stepped_aside_so_the":"Du hast es in einem anderen Fenster übernommen, also hat dieses Platz gemacht und speichert nicht mehr. Nichts ist verloren.",
"slots.this_window_stopped_saving_so_it":"In einem anderen Fenster wurde eine neuere Version gespeichert, also speichert dieses nicht mehr, statt sie zu überschreiben.",
+"slots.try_again":"Nochmal versuchen",
"slots.two_windows_one_network":"Zwei Fenster, ein Netz",
"slots.your_networks":"Deine Netze",
"slots.your_other_networks_share_this_browser":"Deine anderen Netze teilen sich den Speicher dieses Browsers. Exportiere die, die du behalten willst, und lösche sie dann hier, um Platz zu schaffen.",
diff --git a/site/i18n/es.js b/site/i18n/es.js
index 6cc49e4..d3b64b1 100644
--- a/site/i18n/es.js
+++ b/site/i18n/es.js
@@ -3689,7 +3689,7 @@
"sites_peering_caches.your_ticket_was_merged_into_another":"Tu ticket se fusionó con otro ticket.
Ese ticket se cerró como duplicado del tuyo.",
"slots.continue":"Continuar",
"slots.continue_this_network":"Continuar esta red",
-"slots.damaged_export_or_delete":"Dañada: expórtala o bórrala",
+"slots.damaged_export_or_delete":"Dañado: inténtalo de nuevo, expórtalo o bórralo",
"slots.delete":"Borrar",
"slots.delete_forever":"Borrar para siempre",
"slots.delete_name":"¿Borrar {name}?",
@@ -3725,6 +3725,7 @@
"slots.that_network_is_gone":"Esa red ya no existe.
Se borró, quizá en otra ventana.",
"slots.this_window_stepped_aside_so_the":"La abriste en otra ventana, así que esta se hizo a un lado y dejó de guardar. No se perdió nada.",
"slots.this_window_stopped_saving_so_it":"Se guardó una versión más nueva en otra ventana, así que esta dejó de guardar en vez de sobrescribirla.",
+"slots.try_again":"Intentar de nuevo",
"slots.two_windows_one_network":"Dos ventanas, una red",
"slots.your_networks":"Tus redes",
"slots.your_other_networks_share_this_browser":"Tus otras redes comparten el almacenamiento de este navegador. Exporta las que quieras conservar y bórralas aquí para hacer sitio.",
diff --git a/site/i18n/fr.js b/site/i18n/fr.js
index 7774ba3..9fbbba5 100644
--- a/site/i18n/fr.js
+++ b/site/i18n/fr.js
@@ -3689,7 +3689,7 @@
"sites_peering_caches.your_ticket_was_merged_into_another":"Votre ticket a été fusionné avec un autre ticket.
Ce ticket a été fermé comme doublon du vôtre.",
"slots.continue":"Continuer",
"slots.continue_this_network":"Continuer ce réseau",
-"slots.damaged_export_or_delete":"Endommagé : exporte-le ou supprime-le",
+"slots.damaged_export_or_delete":"Endommagé : réessayez, exportez-le ou supprimez-le",
"slots.delete":"Supprimer",
"slots.delete_forever":"Supprimer pour de bon",
"slots.delete_name":"Supprimer {name} ?",
@@ -3725,6 +3725,7 @@
"slots.that_network_is_gone":"Ce réseau n'existe plus.
Il a été supprimé, peut-être dans une autre fenêtre.",
"slots.this_window_stepped_aside_so_the":"Tu l'as repris dans une autre fenêtre, alors celle-ci s'est effacée et ne sauvegarde plus. Rien n'est perdu.",
"slots.this_window_stopped_saving_so_it":"Une version plus récente a été sauvegardée dans une autre fenêtre, alors celle-ci a arrêté de sauvegarder au lieu de l'écraser.",
+"slots.try_again":"Réessayer",
"slots.two_windows_one_network":"Deux fenêtres, un réseau",
"slots.your_networks":"Tes réseaux",
"slots.your_other_networks_share_this_browser":"Tes autres réseaux partagent le stockage de ce navigateur. Exporte ceux que tu veux garder, puis supprime-les ici pour faire de la place.",
diff --git a/site/i18n/it.js b/site/i18n/it.js
index 32634d3..9a20361 100644
--- a/site/i18n/it.js
+++ b/site/i18n/it.js
@@ -3689,7 +3689,7 @@
"sites_peering_caches.your_ticket_was_merged_into_another":"Il tuo ticket è stato unito a un altro ticket.
Quel ticket è stato chiuso come duplicato del tuo.",
"slots.continue":"Continua",
"slots.continue_this_network":"Continua questa rete",
-"slots.damaged_export_or_delete":"Danneggiata: esportala o eliminala",
+"slots.damaged_export_or_delete":"Danneggiato: riprova, esportalo o eliminalo",
"slots.delete":"Elimina",
"slots.delete_forever":"Elimina per sempre",
"slots.delete_name":"Eliminare {name}?",
@@ -3725,6 +3725,7 @@
"slots.that_network_is_gone":"Quella rete non c'è più.
È stata eliminata, forse in un'altra finestra.",
"slots.this_window_stepped_aside_so_the":"L'hai presa in un'altra finestra, quindi questa si è fatta da parte e ha smesso di salvare. Non si è perso nulla.",
"slots.this_window_stopped_saving_so_it":"In un'altra finestra è stata salvata una versione più recente, quindi questa ha smesso di salvare invece di sovrascriverla.",
+"slots.try_again":"Riprova",
"slots.two_windows_one_network":"Due finestre, una rete",
"slots.your_networks":"Le tue reti",
"slots.your_other_networks_share_this_browser":"Le tue altre reti condividono lo spazio di questo browser. Esporta quelle che vuoi tenere, poi eliminale qui per fare posto.",
diff --git a/site/i18n/pt.js b/site/i18n/pt.js
index c535ea3..40960d5 100644
--- a/site/i18n/pt.js
+++ b/site/i18n/pt.js
@@ -3689,7 +3689,7 @@
"sites_peering_caches.your_ticket_was_merged_into_another":"Seu chamado foi juntado a outro chamado.
Esse chamado foi fechado como duplicado do seu.",
"slots.continue":"Continuar",
"slots.continue_this_network":"Continuar esta rede",
-"slots.damaged_export_or_delete":"Danificada: exporte ou apague",
+"slots.damaged_export_or_delete":"Danificado: tente de novo, exporte ou apague",
"slots.delete":"Apagar",
"slots.delete_forever":"Apagar para sempre",
"slots.delete_name":"Apagar {name}?",
@@ -3725,6 +3725,7 @@
"slots.that_network_is_gone":"Essa rede não existe mais.
Ela foi apagada, talvez em outra janela.",
"slots.this_window_stepped_aside_so_the":"Você assumiu em outra janela, então esta saiu da frente e parou de salvar. Nada foi perdido.",
"slots.this_window_stopped_saving_so_it":"Uma versão mais nova foi salva em outra janela, então esta parou de salvar em vez de sobrescrevê-la.",
+"slots.try_again":"Tentar de novo",
"slots.two_windows_one_network":"Duas janelas, uma rede",
"slots.your_networks":"Suas redes",
"slots.your_other_networks_share_this_browser":"Suas outras redes dividem o armazenamento deste navegador. Exporte as que quiser manter e apague-as aqui para abrir espaço.",
diff --git a/src/game/70-rules/20-exchanges.js b/src/game/70-rules/20-exchanges.js
index 964a129..b451433 100644
--- a/src/game/70-rules/20-exchanges.js
+++ b/src/game/70-rules/20-exchanges.js
@@ -15,8 +15,12 @@ const premCity=(n,c)=>!!n.premium&&!!n.premAt&&n.premAt.includes(c),premOnlyAt=(
const premOn=t=>!!t.premium&&!!NET[t.net]&&premCity(NET[t.net],t.city);
// What a port costs per Gbps and month before the commit: the premium crossing at Hong Kong prices, anything else at the city's.
const transitPerG=(n,c,prem)=>prem&&premCity(n,c)?n.price*n.premium*netMult(n,'hkg'):n.price*netMult(n,c);
-const onIx=(n,c)=>CITY[c].au&&n.auIx?n.auIx.includes(c):n.ix==='ALL'||Array.isArray(n.ix)&&n.ix.includes(c);
-function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])return S.myIx[c].members.slice();if(!CITY[c].ix)return [];return NETS.filter(n=>onIx(n,c)).map(n=>n.id);}
+// Exchange lists are fixed once the page has loaded, so each is looked up through a Set built on first use.
+const IX_SET=new WeakMap(),inIxList=(a,c)=>{let s=IX_SET.get(a);if(!s)IX_SET.set(a,s=new Set(a));return s.has(c);};
+const onIx=(n,c)=>CITY[c].au&&n.auIx?inIxList(n.auIx,c):n.ix==='ALL'||Array.isArray(n.ix)&&inIxList(n.ix,c);
+function ixMembers(c){if(XIXM[c])return XIXM[c].members.slice();if(S.myIx[c])return S.myIx[c].members.slice();if(!CITY[c].ix)return [];return (IX_MEM[c]||(IX_MEM[c]=NETS.filter(n=>onIx(n,c)).map(n=>n.id))).slice();}
+// A city exchange's members only depend on the networks, which are fixed after load.
+const IX_MEM={};
// LAG: several identical ports bundled into one logical link. Flow hashing is never perfectly even, so a bundle carries ~95% of the sum.
const LAG_MAX=8;
function lagCap(g,n){n=n||1;return g*n*(n>1?0.95:1);}
diff --git a/src/game/90-actions/91-slots.js b/src/game/90-actions/91-slots.js
index 09d9671..f97105b 100644
--- a/src/game/90-actions/91-slots.js
+++ b/src/game/90-actions/91-slots.js
@@ -6,6 +6,8 @@ Object.assign(ACT,{
// Back to the title with this network kept and saved.
toTitle:()=>{if(pzOn()){pzLeave();}slotLeave();gameClear();showTitle();},
slotBack:()=>{if(S&&UI.started)closeModal();else showTitle();},
+ // A damaged save, opened once more: if it loads, it is no longer damaged; if not, it is marked again.
+ slotRetry:({id})=>{const l=slotIdx(),e=l.find(x=>x.id===id);if(!e)return;e.broken=false;slotIdxPut(l);closeModal();ACT.cont({id});},
slotMenu:({id})=>{const h=slotMenuHtml(id);if(h)openModal(h);},
slotExport:({id})=>exportSlot(id),
slotDel:({id,back})=>{const e=slotIdx().find(x=>x.id===id);if(!e)return;
diff --git a/src/game/91-save.js b/src/game/91-save.js
index 63979aa..9737d78 100644
--- a/src/game/91-save.js
+++ b/src/game/91-save.js
@@ -68,7 +68,7 @@ function parseSave(txt){if(typeof txt!=='string')return {err:tr('save.that_file_
if(s.lost)return {err:tr('save.that_network_went_bankrupt_it_cannot')};
for(const c of Object.keys(s.pops))if(!isCity(c))return {err:tr('save.that_save_has_a_pop_in',{city:esc(String(c).slice(0,12))})};
return {s,ver:j.version||'?',name:String(s.name||tr('common.unnamed_network'))};}
-function importFile(file){if(!file)return;if(file.size>8e6){toast(tr('save.that_file_is_too_big_to'),'bad');return;}
+function importFile(file){if(!file)return;if(file.size>64e6){toast(tr('save.that_file_is_too_big_to'),'bad');return;}
const rd=new FileReader();rd.onload=()=>{const r=parseSave(String(rd.result));if(r.err){toast(tr('save.import_failed_err',{err:esc(r.err)}),'bad');sfx('err');return;}
UI.importing=r.s;openModal(`
${esc(dateStr(r.s.day))} · ${tr('save.cash_in_the_bank',{cash:fmt$(r.s.cash)})} · ${trn('save.n_pop',Object.keys(r.s.pops).length)} · ${tr('save.saved_by_v_ver',{ver:esc(r.ver)})}
${tr('slots.it_joins_your_networks_on_this')}
${tr('hud_and_panels.every_network_on_the_map_traffic')}
`; - {const nc=conns().length;if(nc)h+=`${e.at?tr('slots.last_played_ago',{ago:slotAgo(e.at)}):''}${e.size?' · '+tr('slots.size_on_this_device',{size:slotSize(e.size)}):''}
- `;} + `;} const slotSize=n=>n>=1e6?(n/1e6).toFixed(1)+' MB':Math.max(1,Math.round(n/1e3))+' kB'; function slotBusyModal(id){const e=slotIdx().find(x=>x.id===id),nm=esc(e&&e.name||tr('common.unnamed_network')); openModal(`q[1])return false;}} + for(let cx=c0;cx<=c1;cx++)for(let cy=r0;cy<=r1;cy++){const k=cx*8192+cy;let o=LG.get(k);if(!o)LG.set(k,o=[]);o.push(b);}return true;}; const ar=arOn();for(const cp of CABLE_PAIRS){const C=CAB[cp.cid],hot=!!selC&&(cp.a===selC||cp.b===selC);if(!hot&&cached&&z<1.7)continue;if(ar&&!hot&&!(arKind(cp.a)&&arKind(cp.b)))continue;const col=cableCol(C); for(const k of ks){const sp=cp.pts.map(p=>toS(p[0],p[1],k));let mn=Infinity,mx=-Infinity;for(const q of sp){if(q[0]mx)mx=q[0];}if(mx<-20||mn>CW+20)continue; if(hot||!cached){ctx.globalAlpha=hot?0.95:0.4;ctx.strokeStyle=col;ctx.lineWidth=hot?3:1.6;ctx.lineJoin='round';ctx.setLineDash(C.age==='old'?[6,5]:[]);ctx.beginPath();ctx.moveTo(sp[0][0],sp[0][1]);for(let i=1;i =1.7&&!ar))&&lbOk(sp[Math.floor(sp.length/2)][0],sp[Math.floor(sp.length/2)][1]-8,ctx.measureText(C.name).width,sp,hot)){const m=sp[Math.floor(sp.length/2)];ctx.globalAlpha=hot?1:0.75;ctx.lineWidth=3;ctx.strokeStyle='rgba(255,255,255,.85)';ctx.strokeText(C.name,m[0],m[1]-8);ctx.fillStyle=col;ctx.fillText(C.name,m[0],m[1]-8);} + if((hot||(z>=1.7&&!ar))&&lbOk(sp[Math.floor(sp.length/2)][0],sp[Math.floor(sp.length/2)][1]-8,labW(C.name),sp,hot)){const m=sp[Math.floor(sp.length/2)];ctx.globalAlpha=hot?1:0.75;ctx.lineWidth=3;ctx.strokeStyle='rgba(255,255,255,.85)';ctx.strokeText(C.name,m[0],m[1]-8);ctx.fillStyle=col;ctx.fillText(C.name,m[0],m[1]-8);} ctx.globalAlpha=1;}}} function bezGeom(l,at){const A=CITY[l.a],B=CITY[l.b];const i=at!==undefined?at:lineIdx(l);const key=l.id+'|b'+i;const hit=GEO.get(key);if(hit)return hit; const bx=A.x+wrapDx(A.x,B.x),by=B.y;const dx=bx-A.x,dy=by-A.y,len=Math.hypot(dx,dy)||1;let nx=-dy/len,ny=dx/len;if(ny>0){nx=-nx;ny=-ny;} diff --git a/src/game/96-map/88-cable-ships.js b/src/game/96-map/88-cable-ships.js index feb1a78..f5a81dc 100644 --- a/src/game/96-map/88-cable-ships.js +++ b/src/game/96-map/88-cable-ships.js @@ -32,7 +32,7 @@ function shipSprite(x,y,face,sc,col,now,mode){const c=ctx;c.save();c.translate(x if(mode==='work'&&Math.floor(now/350)%2){c.fillStyle='#FFD23F';c.font='900 11px sans-serif';c.textAlign='center';c.fillText('✦',12,-8);} c.restore();} function drawShips(ks,now){SHIP_HITS.length=0;if(!S||pzOn()||!S.fleet)return; - const T=S.day+(UI.speed?clamp(acc/DAY_MS,0,0.999):0),z=cam.z,sc=Math.max(0.9,Math.min(1.6,Math.sqrt(z)))*(lodFar()?1:1.25),list=[]; + const T=S.day+(UI.speed?clamp(acc/DAY_MS,0,0.999):0),z=cam.z,sc=Math.max(0.85,Math.min(1.5,Math.sqrt(z)))*(lodFar()?0.9:1.05),list=[]; for(const s of SHIPS){const p=shipAt(s,T);if(p.m==='port'&&z<1.1)continue;list.push({p,s,col:s.club==='prv'?'#7A5CFF':'#FF4D5E'});} for(const l of S.links)if(layOwn(l)&&l.ready>S.day&&T>=layStart(l)){const g=linkGeom(l),q=layDone(l,T),two=!!l.ship2; const put=(t,k,dir)=>{const [x,y]=polyAt(g.pts,g.cum,clamp(t,0,1)),[x2]=polyAt(g.pts,g.cum,clamp(t+dir*0.01,0,1));list.push({p:{x,y,m:'lay',dx:x2-x||dir},lay:l,k,col:'#16A866'});}; diff --git a/src/i18n/en.js b/src/i18n/en.js index 1e7045e..a323662 100644 --- a/src/i18n/en.js +++ b/src/i18n/en.js @@ -3690,7 +3690,7 @@ "sites_peering_caches.your_ticket_was_merged_into_another":"Your ticket was merged into another ticket.
That ticket was closed as a duplicate of yours.", "slots.continue":"Continue", "slots.continue_this_network":"Continue this network", -"slots.damaged_export_or_delete":"Damaged: export it or delete it", +"slots.damaged_export_or_delete":"Damaged: try again, export it or delete it", "slots.delete":"Delete", "slots.delete_forever":"Delete forever", "slots.delete_name":"Delete {name}?", @@ -3726,6 +3726,7 @@ "slots.that_network_is_gone":"That network is gone.
It was deleted, maybe in another window.", "slots.this_window_stepped_aside_so_the":"You took it over in another window, so this one stepped aside and stopped saving. Nothing was lost.", "slots.this_window_stopped_saving_so_it":"A newer version was saved in another window, so this one stopped saving instead of overwriting it.", +"slots.try_again":"Try again", "slots.two_windows_one_network":"Two windows, one network", "slots.your_networks":"Your networks", "slots.your_other_networks_share_this_browser":"Your other networks share this browser's storage. Export the ones you want to keep, then delete them here to make room.", diff --git a/tests/save-slots.test.js b/tests/save-slots.test.js index 1f7a183..74fbdcf 100644 --- a/tests/save-slots.test.js +++ b/tests/save-slots.test.js @@ -433,3 +433,32 @@ test('the networks list fits a 360 px phone and has a tap target and a ⋯ menu assert.deepEqual(a.errors, [], lang); } }); + +test('a save the game could not load is tried again: by the next version, or with Try again', async () => { + const b = browser(); + const a = load({ browser: b }); + play(a.ev, 'Phoenix'); + const id = a.ev('UI.slot'), q = JSON.stringify(id); + a.ev('save(true)'); + await flush(); + // This version cannot load it (a bug, not the save): it is marked damaged, with the version that failed. + a.ev('ACT.toTitle()'); + await flush(); + a.ev(`window.__m=migrate;migrate=s=>{throw new Error('bug')};ACT.cont({id:${q}})`); + await flush(); + a.ev('migrate=__m'); + assert.equal(idx(a.ev)[0].broken, true); + assert.equal(JSON.parse(b.ls.get('sot-slots')).slots[0].bv, a.ev('APP_VERSION')); + a.ev(`ACT.slotMenu({id:${q}})`); + assert.match(card(a.ev), /Try again/); + // Try again, with the bug gone: it opens, and is no longer damaged. + a.ev(`ACT.slotRetry({id:${q}})`); + await flush(); + assert.equal(a.ev('!!UI.started&&S.name'), 'Phoenix'); + assert.equal(idx(a.ev)[0].broken, false); + // Marked damaged by an older version: the index reads it as worth another try. + const ix = JSON.parse(b.ls.get('sot-slots'));ix.slots[0].broken = true;ix.slots[0].bv = '0.0.1'; + b.ls.set('sot-slots', JSON.stringify(ix)); + assert.equal(JSON.parse(a.ev('JSON.stringify(slotIdx(true))'))[0].broken, false); + assert.deepEqual(a.errors, []); +});