IPv6-only broadband: 464XLAT city by city, a NAT64 pool next to CGNAT
A broadband city can swap its home routers for ones with a CLAT (ip6Go / ip6Stop, from the city panel's Home broadband). Over 30 to 180 days an even share of the homes moves each day, paid as the routers go in ($4 a home), waiting while cash is short; starting needs only the first day's share. New homes in a swapping or finished city get the new router at the same price. The panel says how many addresses it frees and what it does to the monthly IPv4 bill. ip4Use splits homes into public, behind CGNAT and IPv6-only: the NAT64 pool (ceil(IPv6-only homes / NAT64 ratio), 64/128/256, default 128) comes right after business blocks, before dual-stack homes. NAT64 gateways cost the same per Gbps of IPv4 as CGNAT boxes; NAT64 refunds sit under CGNAT's at the same ratio and never reach zero. The IPv4 share of home traffic is now a curve: 0.55 on day 0, two points less a year, floor 0.2. Out-of-space advice names the sharing left to stretch. Everything is under rule ip4; old saves load unchanged (no field means dual stack).
This commit is contained in:
parent
3bc1641a46
commit
69328ce257
25 changed files with 812 additions and 54 deletions
|
|
@ -4,7 +4,7 @@ Object.assign(ACT,{
|
|||
if(!w&&!p){toast(tr('customers.nothing_spare_to_sell_on_this'),'bad');sfx('err');return;}const L=l.list||(l.list={w:0,p:0});L.w+=w;L.p+=p;
|
||||
toast(tr('broker.listed',{a:CITY[l.a].name,b:CITY[l.b].name}),'good');sfx('click');after();},
|
||||
unlistFiber:({id})=>{const l=S.links.find(x=>x.id===id);if(!l||!l.list)return;delete l.list;sfx('click');after();},
|
||||
accept:({id,auto=false})=>{const o=S.offers.find(x=>x.id===id);if(!o)return;if(!ip4Fits(o)){const n=ip4Need(o);toast(tr('ip4.no_space',{name:esc(o.name),p:ip4Cidr(n),n:ip4N(n),free:ip4N(Math.max(0,ip4Use().free))}),'bad',[{l:tr('ip4.section'),act:'ip4Open'}]);sfx('err');return;}const customer=auto?autoOffer(o):offerCustomer(o);if(!customer)return;if(!bHas(o)){toast(tr('customers.you_need_a_pop_in_every'),'bad');return;}
|
||||
accept:({id,auto=false})=>{const o=S.offers.find(x=>x.id===id);if(!o)return;if(!ip4Fits(o)){const n=ip4Need(o),u=ip4Use(),k=ip4Pools(u),v={name:esc(o.name),p:ip4Cidr(n),n:ip4N(n),free:ip4N(Math.max(0,u.free))};toast(k===1?tr('ip4.no_space_v6',v):k?tr('ip4.no_space_both',v):tr('ip4.no_space',v),'bad',[{l:tr('ip4.section'),act:'ip4Open'}]);sfx('err');return;}const customer=auto?autoOffer(o):offerCustomer(o);if(!customer)return;if(!bHas(o)){toast(tr('customers.you_need_a_pop_in_every'),'bad');return;}
|
||||
if(o.type==='wwave'){const l=S.links.find(x=>x.id===o.link);if(!l||chMax(l)-(l.ch||[]).length-soldSlots(l)-xpSlots(l)<o.slots){toast(tr('customers.not_enough_free_channels_on_that'),'bad');return;}}
|
||||
if(BIZ_T[o.type].event&&S.day>=o.start){toast(tr('customers.too_late_the_event_has_already'),'bad');return;}
|
||||
// A carrier renting more alien waves on a fiber it already rents grows its contract, like a real order for extra waves,
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
/* Address space (#150, 33-address-space.js): buy, lease in, lease out, sell, hand back, and the CGNAT ratio. Every block
|
||||
change keeps room for the customers already signed, with every home behind CGNAT. */
|
||||
/* Address space (#150, 33-address-space.js): buy, lease in, lease out, sell, hand back, and the CGNAT and NAT64 ratios.
|
||||
Every block change keeps room for the customers already signed, with every dual-stack home behind CGNAT. */
|
||||
const ip4Re=()=>{after();renderBank();};
|
||||
function ip4Can(){if(ip4On())return true;toast(tr('ip4.off'),'bad');sfx('err');return false;}
|
||||
const ip4Blk=id=>S.ip4.b.find(b=>b.id===id);
|
||||
function ip4Busy(){toast(tr('ip4.in_use'),'bad');sfx('err');}
|
||||
function ip4Busy(){toast(ip4InUse(),'bad');sfx('err');}
|
||||
// No more blocks than a save keeps (IP4_BLK): a new one is refused with the way out.
|
||||
function ip4Room(){if(!ip4Full())return true;toast(tr('ip4.too_many',{n:IP4_BLK}),'bad');sfx('err');return false;}
|
||||
Object.assign(ACT,{
|
||||
|
|
@ -25,5 +25,8 @@ Object.assign(ACT,{
|
|||
S.ip4.b=S.ip4.b.filter(x=>x!==b);sfx('click');ip4Re();},
|
||||
// Fewer homes per address needs more addresses: refused when the customers already signed would not fit.
|
||||
ip4Nat:({v})=>{if(!ip4Can())return;const r=Number(v);if(!IP4_NAT.includes(r)||r===S.ip4.nat)return;const u=ip4Use();
|
||||
if(r<S.ip4.nat&&u.T-u.B<Math.ceil(u.H/r)){ip4Busy();UI._bh=null;renderBank();return;}S.ip4.nat=r;sfx('click');ip4Re();},
|
||||
if(r<S.ip4.nat&&u.T-u.B<u.p6+Math.ceil(u.Hd/r)){ip4Busy();UI._bh=null;renderBank();return;}S.ip4.nat=r;sfx('click');ip4Re();},
|
||||
// The same for the NAT64 pool of the IPv6-only homes (34-ipv6-only.js).
|
||||
ip4Nat64:({v})=>{if(!ip4Can())return;const r=Number(v);if(!IP4_N64.includes(r)||r===S.ip4.n64)return;const u=ip4Use();
|
||||
if(r<S.ip4.n64&&u.T-u.B<Math.ceil(u.H6/r)+Math.ceil(u.Hd/u.r)){ip4Busy();UI._bh=null;renderBank();return;}S.ip4.n64=r;sfx('click');ip4Re();},
|
||||
});
|
||||
|
|
|
|||
9
src/game/90-actions/55-ipv6-only.js
Normal file
9
src/game/90-actions/55-ipv6-only.js
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
/* IPv6-only broadband (34-ipv6-only.js): start a city's home-router swap, or stop it. The routers are paid for as they go
|
||||
in, so a stop owes nothing and gives nothing back. */
|
||||
Object.assign(ACT,{
|
||||
ip6Go:({city})=>{if(!ip4Can())return;const why=ip6Why(city);if(why){toast(why,'bad');sfx('err');return;}const p=ip6Pop(city);
|
||||
if(S.cash<ip6First(city)){toast(tr('interface.not_enough_cash_wait_for_revenue'),'bad');sfx('err');return;}const n=Math.ceil(ip6Homes(p)),days=ip6Days(city);
|
||||
p.bb.v6e=S.day+days;sfx('build');toast(tr('ip6.started',{city:esc(CITY[city].name),routers:trn('ip6.n_routers',n,{n:ip4N(n)}),days}),'good');after();},
|
||||
ip6Stop:({city})=>{if(!ip4Can())return;const p=ip6Pop(city);if(!p||!p.bb||!p.bb.v6e)return;delete p.bb.v6e;sfx('click');
|
||||
toast(tr('ip6.stopped',{city:esc(CITY[city].name),p:pct(p.bb.v6||0)}),'');after();},
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue