Basic end-of-track merging

master
y5nw 2021-08-25 16:45:08 +02:00
parent a54bc69058
commit 6e31a1c2eb
1 changed files with 9 additions and 3 deletions

View File

@ -62,14 +62,20 @@
(connect-dirs (car cons) (car other-cons)
(+ (cadr cons) (cadr other-cons)))
(psetf (aref connections dir) nil (aref connections other) nil))))
(merge-simple-eol (pos connections)
(loop for dir from 0 to 15 for cons across connections
when (and cons (not (car cons))) do
(psetf (car cons) (make-trackside :pos pos :side dir)
(cadr cons) (* 2 (cadr cons)))))
(removable-p (connections) (every #'null connections)))
(loop for pos of-type aux:v3d in (loop for i being the hash-keys of tdb collect i)
for track = (gethash pos tdb)
(loop for pos of-type aux:v3d being the hash-keys of tdb using (hash-value track)
when (and track (not (track-special track))) do
(let ((connections (track-connects track)))
(merge-2way connections)
(when (removable-p connections)
(remhash pos tdb))))))
(remhash pos tdb))))
(loop for pos of-type aux:v3d being the hash-keys of tdb using (hash-value track)
when track do (merge-simple-eol pos (track-connects track)))))
;;; written based on https://gigamonkeys.com/book/practical-parsing-binary-files.html
;;; note that this implementation only reads nodes that are known to be tracks