Can't place player on a corrupted ZZT board
kristomu opened this issue · 2 comments
If KevEdit encounters a board where the player object's stats is set to a tile that's not the player, then it's impossible to place the player onto the board because F1, Z just moves whatever is at the tile that stats 0 points to.
I've made a crude hack to get what I think is better behavior, where the type of the tile is forced to ZZT_PLAYER after moving it:
int zztPlotPlayer(ZZTworld * world, int x, int y)
{
ZZTboard* brd = zztBoardGetCurPtr(world);
/* Simple case */
if (x == brd->plx && y == brd->ply) {
zztTileAt(brd->bigboard, x, y).type = ZZT_PLAYER;
return 1;
}
/* Error if board cannot be decompressed */
if (!zztBoardDecompress(brd))
return 0;
zztTileMove(brd->bigboard, brd->plx, brd->ply, x, y);
/* Record the change */
brd->plx = x; brd->ply = y;
zztTileAt(brd->bigboard, x, y).type = ZZT_PLAYER;
return 1;
}
There may be a better way to do it, so I didn't think it would warrant an entire pull request on its own.
I've done pull requests for one-liners, go right ahead IMO. I think this is a good enough fix, myself - the scenario is super rare...
Alternate suggestion: if the tile type is not the player, create a new stat (if possible) for the stat on this tile, then create a fresh stat 0 for the player.