Commit 7263f6b3 authored by Eugene So's avatar Eugene So
Browse files

LORD2: Catch global application errors

parent 907d73cd
Pipeline #2918 passed with stage
in 9 minutes and 18 seconds
......@@ -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);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment