|
|
@ -87,19 +87,20 @@ |
|
|
|
(return true)) |
|
|
|
|
|
|
|
(defun-local print-board-piece (piece (* (const board-piece))) |
|
|
|
(printf "Piece %p |
|
|
|
(printf "Piece %c ( %p ) |
|
|
|
\n\tgrid-position %d %d |
|
|
|
\n\tmoving-position %f %f |
|
|
|
\n\tnum-cells %d |
|
|
|
\n\tis-vertical %d |
|
|
|
\n\tis-wall %d |
|
|
|
\n\tis-primary-piece %d\n\n" piece |
|
|
|
(field (path piece > grid-position) X) (field (path piece > grid-position) Y) |
|
|
|
(field (path piece > moving-position) X) (field (path piece > moving-position) Y) |
|
|
|
(path piece > num-cells) |
|
|
|
(path piece > is-vertical) |
|
|
|
(path piece > is-wall) |
|
|
|
(path piece > is-primary-piece))) |
|
|
|
\n\tis-primary-piece %d\n\n" |
|
|
|
(path piece > label) piece |
|
|
|
(field (path piece > grid-position) X) (field (path piece > grid-position) Y) |
|
|
|
(field (path piece > moving-position) X) (field (path piece > moving-position) Y) |
|
|
|
(path piece > num-cells) |
|
|
|
(path piece > is-vertical) |
|
|
|
(path piece > is-wall) |
|
|
|
(path piece > is-primary-piece))) |
|
|
|
|
|
|
|
(defun-local game-board-sync-occupied-state (&return bool) |
|
|
|
;; Zero out to make overlap validation easy |
|
|
@ -115,16 +116,16 @@ |
|
|
|
(< (vec-x (path piece > grid-position)) 0) |
|
|
|
(>= (vec-y (path piece > grid-position)) g-game-board-grid-size) |
|
|
|
(< (vec-y (path piece > grid-position)) 0)) |
|
|
|
(printf "Piece %p origin is off board! Must abort occupied state sync\n" piece) |
|
|
|
(printf "error: Piece %p origin is off board! Must abort occupied state sync\n" piece) |
|
|
|
(return false)) |
|
|
|
(if (path piece > is-vertical) |
|
|
|
(block ;; Vertical |
|
|
|
(when (> (+ num-cells (vec-y (path piece > grid-position))) g-game-board-grid-size) |
|
|
|
(printf "Piece %p vertical is off board! Must abort occupied state sync\n" piece) |
|
|
|
(printf "error: Piece %p vertical is off board! Must abort occupied state sync\n" piece) |
|
|
|
(return false))) |
|
|
|
(block ;; Horizontal |
|
|
|
(when (> (+ num-cells (vec-x (path piece > grid-position))) g-game-board-grid-size) |
|
|
|
(printf "Piece %p horizontal is off board! Must abort occupied state sync\n" piece) |
|
|
|
(printf "error: Piece %p horizontal is off board! Must abort occupied state sync\n" piece) |
|
|
|
(return false))))) |
|
|
|
|
|
|
|
(var cell-offset int 0) |
|
|
@ -141,7 +142,7 @@ |
|
|
|
(var occupy-space-pointer (* (* board-piece)) |
|
|
|
(addr (at (vec-y cell-to-set) (vec-x cell-to-set) g-game-board-occupied-state))) |
|
|
|
(when (deref occupy-space-pointer) |
|
|
|
(printf "Piece %p overlapping %p at (%d, %d)! Aborting\n" |
|
|
|
(printf "error: Piece %p overlapping %p at (%d, %d)! Aborting\n" |
|
|
|
piece (deref occupy-space-pointer) |
|
|
|
(vec-xy cell-to-set)) |
|
|
|
(return false)) |
|
|
@ -263,7 +264,7 @@ Rush Hour database from Michael Fogleman.\n\n") |
|
|
|
(set (field (at 0 g-game-board-pieces) label) 'b') |
|
|
|
|
|
|
|
(set (field (at 1 g-game-board-pieces) num-cells) 3) |
|
|
|
(set (vec-x (field (at 1 g-game-board-pieces) grid-position)) 2) |
|
|
|
(set (vec-x (field (at 1 g-game-board-pieces) grid-position)) 1) |
|
|
|
(set (vec-y (field (at 1 g-game-board-pieces) grid-position)) 3) |
|
|
|
(set (field (at 1 g-game-board-pieces) is-vertical) false) |
|
|
|
(set (field (at 1 g-game-board-pieces) label) 'c') |
|
|
|