A day that reroutes no longer stops the page at x8: every routing it needs goes to the route worker
The day split of #312 on its own, from 3.0.0, without its routing core, save or map changes. On a big network at x8 the game stopped whenever a day rerouted: after a failure, an event, the NOC intern's shift or the sales desk's signing, dayPost() routed on the page. * The day is a generator (dayRun(), dayPreRun(), dayPost()): each yield is a compute() it needs. dayTick() answers them on the spot (tests, fallback); in play rwGo() posts each one to the route worker. A failure (failureRun()), a DDoS and Auto-RTBH (ddosNewsRun()), the chaos monkey's snip (mkSnipRun()), an event's cut (eventRun()), the intern's shift (opsRun()) and the sales desk (slAutoRun(), its trials answered by the worker with offerTrial()) are steps of the day. fireFailure(), opsDay() and slAutoDay() still play them in one go. * yield DAY_REST lets a long day draw a frame between two steps (half a frame, 3 to 8 ms, RW.budget). One day in flight at a time, resting or routing: the clock waits for the day, and a half day is never saved. * UI.tick is set around every step (dayStep()), so quiet notifications hold in play, not only in dayTick(). * The daily mood check works out the land islands once per pass over the customers (TERR), instead of walking every land link for each customer afraid of sharks. This fix is thesysadmindev's, from #310; here the islands are worked out again if something routed meanwhile (RW.gen), since the mood loop can now rest between customers. Same game either way: tests/day-steps.test.js plays a second page as the worker and compares each day with dayTick(), the intern on every order, failures, events, DDoS and the monkey forced. Thanks to thesysadmindev for the profiling in #310 that pointed at the reroutes, and for the sharks fix.
This commit is contained in:
parent
9d64aa0144
commit
3c45d7dca1
26 changed files with 497 additions and 127 deletions
|
|
@ -2,7 +2,12 @@
|
|||
const anchorProne=l=>!!(l.cable&&CAB[l.cable]&&CAB[l.cable].anchor)||anchorPair(l);
|
||||
// The wet season in the tropical north (November to April): floods close the tracks, so a cut on land takes twice as long to reach.
|
||||
const wetSeason=()=>{const m=cal(S.day).m;return m>=10||m<=3;},wetCut=l=>!l.sub&&!!(CITY[l.a].wet||CITY[l.b].wet)&&wetSeason();
|
||||
function fireFailure(only){
|
||||
/* failureRun() is a failure as a step of the day (10-day-tick.js): its yield is the routing that tells what it cost,
|
||||
done by the route worker in play. fireFailure() is the same failure all at once, routed on the spot. */
|
||||
function fireFailure(only){runNow(failureRun(only));}
|
||||
// A step of the day played all at once: every routing it asks for, on the spot (tests, a failure outside a day).
|
||||
function runNow(g){dayGo(g,(g,v)=>g.next(v));}
|
||||
function* failureRun(only){
|
||||
const opts=[];
|
||||
const live=S.links.filter(l=>l.kind!=='vxc'&&!linkDown(l));const fabsUsed=[...new Set(S.links.filter(l=>l.kind==='vxc').map(l=>l.prov))];
|
||||
if(live.length){opts.push(['cut',2+Math.min(6,live.length/2)]);}
|
||||
|
|
@ -111,9 +116,9 @@ function fireFailure(only){
|
|||
}else if(type==='fabric'){
|
||||
const f=pick(fabsUsed);S.ev.fab=S.ev.fab||{};S.ev.fab[f]=S.day+2+Math.floor(Math.random()*3);
|
||||
addInc({type,ref:f,until:S.ev.fab[f],msg:tr('failures.fabric_is_having_a_bad_day',{fabric:FAB[f].name}),cost:0});
|
||||
}else if(type==='ddos'){ddosAttack();return;
|
||||
}else if(type==='ddos'){ddosAttack(false);yield;yield* ddosNewsRun();return;
|
||||
}
|
||||
compute();
|
||||
yield;
|
||||
const last=S.inc[S.inc.length-1];
|
||||
last.impact=Math.max(0,before-R.served);
|
||||
if(before>1&&last.impact<before*0.03&&type!=='ddos'){S.stats.survived++;toast(`<b>${incTitle(type)}</b><br>${esc(last.msg)} ${tr('failures.traffic_rerouted_customers_barely')}`,'good',[],incOpen(last));}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue