diff --git a/xtrn/lord2/lord2.js b/xtrn/lord2/lord2.js index 9e75eb3bce843f35d7252a899d507d9c9e60061f..b7ffb7b72e0620236532d029d3cf7c7120be45c7 100644 --- a/xtrn/lord2/lord2.js +++ b/xtrn/lord2/lord2.js @@ -4437,85 +4437,89 @@ function setup_time_warnings() time_warnings.push(0); } -// TODO: Actually send this font to SyncTERM too. -if (file_exists(getfname('fonts/lord2.fnt'))) { - if (dk.system.mode === 'local') - conio.loadfont(getfname('fonts/lord2.fnt')); -} -load_player(); -load_time(); - -var done = false; -for (arg in argv) { - var m = argv[arg].match(/^(.*)\+(.*)$/); - if (m != null) { - run_ref(m[1], m[2]); - done = true; +try { + // TODO: Actually send this font to SyncTERM too. + if (file_exists(getfname('fonts/lord2.fnt'))) { + if (dk.system.mode === 'local') + conio.loadfont(getfname('fonts/lord2.fnt')); } -} -if (done) - exit(0); + load_player(); + load_time(); + + var done = false; + for (arg in argv) { + var m = argv[arg].match(/^(.*)\+(.*)$/); + if (m != null) { + run_ref(m[1], m[2]); + done = true; + } + } + if (done) + exit(0); -run_ref('rules', 'rules.ref'); -hail_cleanup(); + run_ref('rules', 'rules.ref'); + hail_cleanup(); -setup_time_warnings(); + setup_time_warnings(); -js.on_exit('killfiles.forEach(function(f) { if (f.is_open) { f.close(); } file_remove(f.name); });'); + js.on_exit('killfiles.forEach(function(f) { if (f.is_open) { f.close(); } file_remove(f.name); });'); -var tfile = new File(getfname(maildir + 'talk'+(player.Record + 1)+'.tmp')); -if (!tfile.open('w+b')) - throw new Error('Unable to open '+tfile.name); -killfiles.push(tfile); -tfile.close(); + var tfile = new File(getfname(maildir + 'talk'+(player.Record + 1)+'.tmp')); + if (!tfile.open('w+b')) + throw new Error('Unable to open '+tfile.name); + killfiles.push(tfile); + tfile.close(); -var lfile = new File(getfname(maildir + 'log'+(player.Record + 1)+'.tmp')); -if (!lfile.open('w+b')) - throw new Error('Unable to open '+lfile.name); -killfiles.push(lfile); -lfile.close(); + var lfile = new File(getfname(maildir + 'log'+(player.Record + 1)+'.tmp')); + if (!lfile.open('w+b')) + throw new Error('Unable to open '+lfile.name); + killfiles.push(lfile); + lfile.close(); -var cfile = new File(getfname(maildir + 'con'+(player.Record + 1)+'.tmp')); -if (!cfile.open('ab')) - throw new Error('Unable to open '+cfile.name); -killfiles.push(cfile); -cfile.close(); + var cfile = new File(getfname(maildir + 'con'+(player.Record + 1)+'.tmp')); + if (!cfile.open('ab')) + throw new Error('Unable to open '+cfile.name); + killfiles.push(cfile); + cfile.close(); -if (player.Record === undefined) { - if (pfile.length >= 200) { - pick_deleted(); - if (player.Record === undefined) { - run_ref('full', 'gametxt.ref'); - exit(0); + if (player.Record === undefined) { + if (pfile.length >= 200) { + pick_deleted(); + if (player.Record === undefined) { + run_ref('full', 'gametxt.ref'); + exit(0); + } } + run_ref('newplayer', 'gametxt.ref'); } - run_ref('newplayer', 'gametxt.ref'); -} -if (player.Record === undefined) - exit(0); + if (player.Record === undefined) + exit(0); -if (player.battle) { - if (player.lastsaved < (savetime() - (idle_timeout / 60 * 2))) { - player.battle = false; - player_put(); + if (player.battle) { + if (player.lastsaved < (savetime() - (idle_timeout / 60 * 2))) { + player.battle = false; + player_put(); + } + else + run_ref('busy', 'gametxt.ref'); } - else - run_ref('busy', 'gametxt.ref'); -} -run_ref('startgame', 'gametxt.ref'); - -js.on_exit('if (player !== undefined) { update_rec.onnow = 0; update_rec.busy = 0; update_rec.battle = 0; update_rec.map = player.map; update_rec.x = player.x; update_rec.y = player.y; update_rec.put(); ufile.close(); player.onnow = 0; player.busy = 0; player.battle = 0; player.lastsaved = savetime(); player.put(); pfile.close() }'); -players[player.Record] = update_rec; -player.onnow = 1; -player.busy = 0; -player.battle = 0; -if (pending_timeout !== undefined) - handle_timeout(pending_timeout); -player.lastdayon = state.time; -player.lastdayplayed = state.time; -player_put(); - -mail_check(false); -do_map(); + run_ref('startgame', 'gametxt.ref'); + + js.on_exit('if (player !== undefined) { update_rec.onnow = 0; update_rec.busy = 0; update_rec.battle = 0; update_rec.map = player.map; update_rec.x = player.x; update_rec.y = player.y; update_rec.put(); ufile.close(); player.onnow = 0; player.busy = 0; player.battle = 0; player.lastsaved = savetime(); player.put(); pfile.close() }'); + players[player.Record] = update_rec; + player.onnow = 1; + player.busy = 0; + player.battle = 0; + if (pending_timeout !== undefined) + handle_timeout(pending_timeout); + player.lastdayon = state.time; + player.lastdayplayed = state.time; + player_put(); + + mail_check(false); + do_map(); +} catch (err) { + log(LOG_ERR, "Lord2: " + err); +}