Merge pull request #304 from antt0n/fix/map-stale-floaters

fix(map): drop the last network's floaters when another one starts
This commit is contained in:
Frederic Jung 2026-11-06 06:33:14 +01:00
commit 4ec3fb4a1a
No known key found for this signature in database
5 changed files with 23 additions and 4 deletions

View file

@ -270,7 +270,7 @@ test('the 2D map paints its pictures again for a new pixel density', () => {
test('money pop-ups on the 2D map fade out as before', () => {
const { ev, errors } = open();
const C = 'CITY[S.home]';
ev(`cam.x=${C}.x;cam.y=${C}.y;cam.z=1;__T+=16;FLOATS.push({x:${C}.x,y:${C}.y,text:'+$1,234',col:'#16A866',t:__T});`);
ev(`cam.x=${C}.x;cam.y=${C}.y;cam.z=1;__T+=16;FLOATS.push({x:${C}.x,y:${C}.y,text:'+$1,234',col:'#16A866',s:S,t:__T});`);
// At 0, 40% and 80% of its life: drawn at opacity 1-a².
const alphas = [];
for (const a of [0, 0.4, 0.8]) {
@ -282,7 +282,7 @@ test('money pop-ups on the 2D map fade out as before', () => {
ev(`__M2D.frame(FLOATS[FLOATS.length-1].t+1700)`);
assert.equal(ev('FLOATS.length'), 0, 'gone after its life');
// The same text in two colours at once: two pictures, each in its own colour.
ev(`FLOATS.push({x:${C}.x,y:${C}.y,text:'+$500',col:'#16A866',t:5000},{x:${C}.x+40,y:${C}.y,text:'+$500',col:'#FF4D5E',t:5000});`);
ev(`FLOATS.push({x:${C}.x,y:${C}.y,text:'+$500',col:'#16A866',s:S,t:5000},{x:${C}.x+40,y:${C}.y,text:'+$500',col:'#FF4D5E',s:S,t:5000});`);
const r = JSON.parse(ev('JSON.stringify(__M2D.pair(5400))'));
assert.deepEqual(problems(r, 'two pop-ups'), []);
assert.deepEqual(errors, []);

View file

@ -238,6 +238,22 @@ test('payday money floaters fade after a long pause instead of piling up', () =>
assert.deepEqual(errors, []);
});
test("a new network starts without the last one's money floating over its map", () => {
const { ev, errors } = load();
bigNet(ev);
ev("closeModal();ACT.animSet({v:'on'});setPref('pauseFurious',false);setPref('pauseIncident',false);window.__clk=5000;performance.now=()=>__clk;last=__clk;UI.speed=1");
const run = (ms) => { for (let t = 0; t < ms; t += 16) ev('__clk+=16;frame(__clk)'); };
run(2000);
ev('while(cal(S.day+1).d!==1)dayTick();acc=DAY_MS');
run(16);
assert.ok(ev('FLOATS.length') > 0, 'payday shows the money');
// A new game straight away: it waits, paused, for the player's first POP, and the clock of the floaters with it.
ev("ACT.newgame();ACT.start({});closeModal();UI.speed=0");
run(100);
assert.equal(ev('FLOATS.length'), 0, "the old network's floaters are gone");
assert.deepEqual(errors, []);
});
test('the map is not drawn while the dashboard covers the whole screen', () => {
const { ev, errors } = load();
bigNet(ev);