From ba1c1e1a35a8db68aa16c052195544c161c1869f Mon Sep 17 00:00:00 2001
From: Danilo Carbonaro <107484701+daniloctdev@users.noreply.github.com>
Date: Sat, 24 Oct 2026 18:18:47 +0200
Subject: [PATCH] Fix the game freezing when a peer drops you at a rival
exchange
Peering sessions at a second or third exchange in a city are keyed like
"drz@mil~2". The de-peering toast looked the city up as CITY['mil~2'],
threw, and the exception stopped the animation loop for good: time and
the map froze until a reload.
---
site/index.html | 2 +-
tests/peering.test.js | 11 +++++++++++
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/site/index.html b/site/index.html
index 0d70c11..3093f36 100644
--- a/site/index.html
+++ b/site/index.html
@@ -1889,7 +1889,7 @@ function dayTick(){
if(R&&R.demand>0)S.stats.clean=R.served/R.demand>=0.995?(S.stats.clean||0)+1:0;
if(S.ev.php===d)toast('The internet is back.
Half of it, anyway. Everything was patched in a hurry and nobody learned anything.','good');
for(const k in S.peers){const [id,c]=k.split('@'),sn=snub(id,c);if(!sn)continue;delete S.peers[k];S.stats.depeered=(S.stats.depeered||0)+1;
- toast(`${esc(NET[id].name)} de-peered you in ${esc(CITY[c].name)}.
${esc(sn.why)} Traffic falls back to your next best path.`,'bad');}
+ toast(`${esc(NET[id].name)} de-peered you in ${esc(CITY[ixCity(c)].name)}.
${esc(sn.why)} Traffic falls back to your next best path.`,'bad');}
if(S.cnLic&&S.cnLic.state==='pending'&&d>=S.cnLic.ready){S.cnLic.state='ok';toast('License granted!
Your joint venture can now build POPs in mainland China.','goal');sfx('coin');}
// resolve incidents
for(const i of S.inc.slice())if(i.until<=d){clearInc(i);toast(`Resolved: ${incTitle(i.type).toLowerCase()} is fixed.`,'good');}
diff --git a/tests/peering.test.js b/tests/peering.test.js
index b3f5d54..696907b 100644
--- a/tests/peering.test.js
+++ b/tests/peering.test.js
@@ -113,3 +113,14 @@ test('DE-KICKS hides prices, haggles, harmonises upwards, auto-enrolls add-ons a
assert.equal(ev("ixPortMo('ams',1)"), ev("Math.round(PORT[1].ix*ixMul('ams'))"), 'other IXs keep open pricing');
assert.deepEqual(errors, []);
});
+
+test('a peer at a rival exchange can de-peer you without stopping the game', () => {
+ const { ev, errors } = load();
+ ev('ACT.start({})');
+ const ix = ev('Object.keys(XIXM)[0]');
+ ev(`S.peers['ggl@${ix}']=true;window.snub=()=>({why:'Testing.'})`);
+ ev('dayTick()');
+ assert.equal(ev(`'ggl@${ix}' in S.peers`), false);
+ assert.match(ev("document.getElementById('toasts').textContent"), new RegExp(`de-peered you in ${ev(`CITY[ixCity('${ix}')].name`)}`));
+ assert.deepEqual(errors, []);
+});