Island Wi-Fi for 18 groups of outer islands, by satellite and spur cable (#83)

Each zone (Vanua Levu & Taveuni off Suva, the Out Islands off Nassau, and
16 more) is a pool of island homes at your POP in its city: no node and no
link on the map, its Gbps join the city's demand. Rent backhaul at the
city's teleport (about 35% sign up over GEO, 75% over MEO, 90% over
Starblink from a gateway there) or, from level 3, lay a spur cable and
everyone may sign up. The first order brings the island kit. Islanders pay
island prices, their homes are IPv6-only in the NAT64 pool, and investors
on a revenue share take their cut. A spur can be cut for weeks (failure
'wspur', chaos only): a satellite kept beside it carries the islands. Zones
are off in puzzles, the Architect, scenarios and below level 2.

The satellite geometry works on points now (satSeesAt, satPairAt, satKmAt;
the city functions wrap them, with the same answers). Starblink serves a
zone only from a gateway in its own city (16 of 18; a gateway anywhere in
reach would serve the same 16), with its storm and rival rule; Nunavut and
Southeast Alaska stay on GEO. Rules W6 and F12.
This commit is contained in:
jvanvik 2026-11-12 02:12:21 +01:00
parent 7967a29083
commit 6f0c080875
44 changed files with 1087 additions and 65 deletions

View file

@ -43,7 +43,8 @@ function ip4Need(b){const k=b&&IP4_BIZ[b.type];if(!k||!(b.bw>0))return 0;return
function ip4Use(s=S){const I=s.ip4,r=I.nat,r6=I.n64||IP4_N640;let own=0,inn=0,out=0,B=0,H=0,H6=0;
for(const b of I.b){const n=ip4Sz(b.len);if(b.k==='in')inn+=n;else if(b.out)out+=n;else own+=n;}
for(const b of s.biz)B+=ip4Need(b);
for(const c in s.pops){const p=s.pops[c];if(p.bb){const h=p.bb.d*IP4_BB;H+=h;if(p.bb.v6)H6+=h*p.bb.v6;}}
// Island Wi-Fi homes (46-wisp-zones.js) are IPv6-only from day one: their IPv4 shares the NAT64 pool.
for(const c in s.pops){const p=s.pops[c];if(p.bb){const h=p.bb.d*IP4_BB;H+=h;if(p.bb.v6)H6+=h*p.bb.v6;}if(p.wisp)for(const z in p.wisp){const h=p.wisp[z].d*IP4_BB;H+=h;H6+=h;}}
H=Math.ceil(H);H6=Math.min(H,Math.ceil(H6));const Hd=H-H6,T=own+inn,A=Math.max(0,T-B),p6=Math.ceil(H6/r6),min=Math.ceil(Hd/r),need=p6+min,A2=A-p6;let cg=0,over=0;
if(A2<Hd){if(A2>=min)cg=Math.min(Hd,Math.ceil((Hd-A2)*r/(r-1)));else{cg=Hd;over=need?1-A/need:0;}}
return {T,own,inn,out,B,H,H6,Hd,p6,cg,over,need,free:T-B-need,r,r6};}
@ -73,15 +74,17 @@ const ip4V4=(d=S.day)=>Math.max(IP4_V4_MIN,IP4_V4-IP4_V4_YR*Math.max(0,d)/365.24
function ip4Bill(eye,s=S){const u=ip4Use(s),v4=ip4V4();let lin=0,lout=0;for(const b of s.ip4.b){if(b.k==='in')lin+=b.mo||0;else if(b.out)lout+=b.mo||0;}
const cgS=u.H?u.cg/u.H:0,v6S=u.H?u.H6/u.H:0;
return {u,lin,lout,v4,box:u.cg/IP4_BB*v4*IP4_CGN,box64:u.H6/IP4_BB*v4*IP4_CGN,refund:eye*(cgS*IP4_ANNOY[u.r]+v6S*IP4_ANNOY64[u.r6]*v4/IP4_V4+u.over*IP4_SQZ)};}
// What homes pay a month (broadband and island Wi-Fi), which the refunds scale with: from computeMoney's V, or R.
const ip4Eye=(V=R&&R.rev)=>V?(V.eyeballs||0)+(V.wisp||0):0;
// computeMoney: only what is there, so a network with nothing to pay keeps its money rows as they were.
function ip4Money(C,V){if(!ip4On())return;const b=ip4Bill(V.eyeballs||0),c=Math.round(b.lin+b.box+b.box64+b.refund);if(c>0)C.ip4=c;if(b.lout>0)V.ip4=b.lout;}
function ip4Money(C,V){if(!ip4On())return;const b=ip4Bill(ip4Eye(V)),c=Math.round(b.lin+b.box+b.box64+b.refund);if(c>0)C.ip4=c;if(b.lout>0)V.ip4=b.lout;}
/* A new network gets its /21 from the RIR. An older save gets what it already uses registered to it and a quarter more to
grow into (about a month for a big, fast-growing network), rounded up to /24s in real CIDR blocks (a /21 at the
least), so nothing changes on load; those blocks move like any other two years on.
Their ids are fixed (rir0, rir1…), not uid(): a new game draws no id, so every id after it stays as it was. */
function ip4Grant(s){const d=s.day||0,b=[],add=len=>b.push({id:'rir'+b.length,len,k:'rir',d});let need=0;
for(const x of s.biz||[])need+=ip4Need(x);
for(const c in s.pops||{}){const p=s.pops[c];if(p&&p.bb&&p.bb.d>0)need+=p.bb.d*IP4_BB;}
for(const c in s.pops||{}){const p=s.pops[c];if(p&&p.bb&&p.bb.d>0)need+=p.bb.d*IP4_BB;if(p&&p.wisp&&typeof p.wisp==='object')for(const z in p.wisp)need+=Math.max(0,num(p.wisp[z]&&p.wisp[z].d,0))*IP4_BB;}
need=Math.max(ip4Sz(IP4_START),Math.ceil(need*1.25/256)*256);
while(need>=ip4Sz(IP4_MIN)&&b.length<200){add(IP4_MIN);need-=ip4Sz(IP4_MIN);}
for(let len=IP4_MIN+1;len<=IP4_MAX;len++)if(need>=ip4Sz(len)){add(len);need-=ip4Sz(len);}