Fix walking off-map

This commit is contained in:
Jaidyn Ann 2023-07-15 14:20:52 -05:00
parent a73dcad7ea
commit 9517ee14e5

View File

@ -299,16 +299,16 @@ Very kindly removes a list of parameters to be returned by the overworld state-f
;; Change the entitys world coordinates…
(when (walkable-tile-p map x y)
(setf (getf (getf-entity-data map entity :coords) :x) x)
(setf (getf (getf-entity-data map entity :coords) :y) y))
;; If the entitys moved into a different screen-chunk (and so into a different
;; sub-alist of MAP hash-tables :entities), move its list into the new chunks.
(when (not (eq old-chunk new-chunk))
;; Add it to the new chunk list…
(setf (assoc-utils:aget (assoc-utils:aget (gethash :entities map) new-chunk) entity)
(cdr (getf-entity map entity)))
;; Delete it from the old list…
(alexandria:deletef (assoc-utils:aget (gethash :entities map) old-chunk) entity
:test (lambda (id alist) (eq id (car alist)))))))
(setf (getf (getf-entity-data map entity :coords) :y) y)
;; If the entitys moved into a different screen-chunk (and so into a different
;; sub-alist of MAP hash-tables :entities), move its list into the new chunks.
(when (not (eq old-chunk new-chunk))
;; Add it to the new chunk list…
(setf (assoc-utils:aget (assoc-utils:aget (gethash :entities map) new-chunk) entity)
(cdr (getf-entity map entity)))
;; Delete it from the old list…
(alexandria:deletef (assoc-utils:aget (gethash :entities map) old-chunk) entity
:test (lambda (id alist) (eq id (car alist))))))))