Skip to content
Snippets Groups Projects
Commit 4e416cd3 authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Two Smackrod related issues

- Fix update_space() to move to correct location every tim
  Resulted in "ghost" player character after using smackrod
- Load the map and set lastx/lasty when loading an existing
  player record.  Undefined lastx/lasty would crash the game,
  and using the smackrod on joining allowed that.
parent c6b890a7
No related branches found
No related tags found
No related merge requests found
...@@ -1697,6 +1697,18 @@ function load_player() ...@@ -1697,6 +1697,18 @@ function load_player()
var i; var i;
var p; var p;
function post_load() {
map = load_map(player.map);
// Force move to home on invalid map (can be triggered by a crash in the glen which no longer happens. :)
if (map === null) {
player.map = 0;
player.x = 0;
player.y = 0;
}
player.lastx = player.x;
player.lasty = player.y;
}
for (i = 0; i < pfile.length; i++) { for (i = 0; i < pfile.length; i++) {
p = pfile.get(i); p = pfile.get(i);
if (p.deleted === 1) if (p.deleted === 1)
...@@ -1708,21 +1720,14 @@ function load_player() ...@@ -1708,21 +1720,14 @@ function load_player()
ufile.new(); ufile.new();
update_rec = ufile.get(player.Record); update_rec = ufile.get(player.Record);
} }
post_load();
return; return;
} }
} }
player = new RecordFileRecord(pfile); player = new RecordFileRecord(pfile);
player.reInit(); player.reInit();
player.realname = dk.user.full_name; player.realname = dk.user.full_name;
map = load_map(player.map); post_load();
// Force move to home on invalid map (can be triggered by a crash in the glen which no longer happens. :)
if (map === null) {
player.map = 0;
player.x = 0;
player.y = 0;
}
player.lastx = player.x;
player.lasty = player.y;
} }
function erase_player() function erase_player()
...@@ -1747,7 +1752,6 @@ function update_space(x, y) ...@@ -1747,7 +1752,6 @@ function update_space(x, y)
{ {
var oa = dk.console.attr.value; var oa = dk.console.attr.value;
dk.console.gotoxy(x, y);
x += 1; x += 1;
y += 1; y += 1;
...@@ -1759,10 +1763,11 @@ function update_space(x, y) ...@@ -1759,10 +1763,11 @@ function update_space(x, y)
// Note that 'busy' is what 'offmap' toggles, not what 'busy' does. *sigh* // Note that 'busy' is what 'offmap' toggles, not what 'busy' does. *sigh*
if (i === player.Record) { if (i === player.Record) {
erase_player(); erase_player();
dk.console.gotoxy(x - 1, y - 1);
foreground(15); foreground(15);
background(map.mapinfo[getoffset(u.x-1, u.y-1)].backcolour); background(map.mapinfo[getoffset(u.x-1, u.y-1)].backcolour);
dk.console.print('\x02'); dk.console.print('\x02');
last_draw = {x:player.x - 1, y:player.y - 1}; last_draw = {x:u.x - 1, y:u.y - 1};
} }
else { else {
if (u.busy === 0) { if (u.busy === 0) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment