Add .leaders command to replay map records in T5 and T6
This commit is contained in:
@@ -44,7 +44,7 @@ function functions(source) {
|
||||
function engine(game) {
|
||||
const source = readFileSync(new URL(`${game}/tws_${game}_leaderboard.gsc`, root), 'utf8');
|
||||
const all = functions(source);
|
||||
const excluded = new Set(['lb_worker', 'lb_welcome', 'lb_get', 'lb_collect', 'lb_log', 'lb_show_hud', 'lb_hud_help_visible', 'lb_hud_end_game', 'lb_hud_destroy']);
|
||||
const excluded = new Set(['lb_worker', 'lb_welcome', 'lb_get', 'lb_collect', 'lb_log', 'lb_show_hud', 'lb_hud_help_visible', 'lb_hud_end_game', 'lb_hud_destroy', 'lb_chat_listener', 'lb_request', 'lb_hud_disconnect']);
|
||||
const table = [];
|
||||
for (let i = 1; i < 256; i++) table[String.fromCharCode(i)] = i;
|
||||
const dvars = { mapname: game === 't5' ? 'zombie_theater' : 'zm_transit', ui_gametype: 'zstandard', ui_zm_mapstartlocation: 'town' };
|
||||
@@ -52,6 +52,7 @@ function engine(game) {
|
||||
const context = vm.createContext({
|
||||
level: { tws_lb_game: game, tws_lb_override: '', tws_lb_bytes: table },
|
||||
GetDvar: (key) => dvars[key] ?? '',
|
||||
getTime: () => 1000000,
|
||||
spawnStruct: () => ({}),
|
||||
isDefined: (value) => value !== undefined && value !== null,
|
||||
gscType: (value) => value === undefined || value === null ? 'undefined' : typeof value === 'object' ? 'array'
|
||||
@@ -96,6 +97,20 @@ for (const game of ['t5', 't6']) {
|
||||
if (game === 't6') assert(!all.get('lb_welcome').includes('self.hasSpawned'));
|
||||
assert(source.includes('register_connect_handler(::lb_welcome)'));
|
||||
});
|
||||
check(`${game} record replay uses only a fresh complete cache`, () => {
|
||||
assert.equal(c.lb_cached_record(), undefined);
|
||||
const snapshot = { saved_at: 1000000, round: 52, lines: ['Alice'] };
|
||||
c.level.tws_lb_cache = snapshot;
|
||||
assert.equal(c.lb_cached_record(), snapshot);
|
||||
snapshot.saved_at = 100000;
|
||||
assert.equal(c.lb_cached_record(), snapshot);
|
||||
snapshot.saved_at--;
|
||||
assert.equal(c.lb_cached_record(), undefined);
|
||||
c.level.tws_lb_cache = { saved_at: 1000000, round: 0, lines: [] };
|
||||
assert.equal(c.lb_cached_record().round, 0);
|
||||
c.level.tws_lb_cache = undefined;
|
||||
assert.equal(queries.length, 0);
|
||||
});
|
||||
check(`${game} unicode and URL encoding`, () => {
|
||||
assert.equal(c.lb_url_encode(bytes('t6:zm_transit:town /?&=#é')), 't6%3Azm_transit%3Atown%20%2F%3F%26%3D%23%C3%A9');
|
||||
assert.equal(text(c.lb_display_text(bytes('^1Alice\n^7 René 🧟'), 64)), 'Alice René 🧟');
|
||||
|
||||
Reference in New Issue
Block a user