do not return temporary track database; (SBCL) declare global variables as always bound
parent
0bdfb513b2
commit
222df8116d
|
@ -6,7 +6,6 @@
|
||||||
;; Databases
|
;; Databases
|
||||||
(defparameter *ildb* nil)
|
(defparameter *ildb* nil)
|
||||||
(defparameter *trackdb* nil)
|
(defparameter *trackdb* nil)
|
||||||
(defparameter *trackdb-temp* nil)
|
|
||||||
|
|
||||||
;; Command-line arguments
|
;; Command-line arguments
|
||||||
(defparameter *debugp* nil)
|
(defparameter *debugp* nil)
|
||||||
|
@ -16,21 +15,25 @@
|
||||||
(defparameter *server-port* nil)
|
(defparameter *server-port* nil)
|
||||||
(defparameter *server* nil)
|
(defparameter *server* nil)
|
||||||
|
|
||||||
|
#+sbcl(declaim (sb-ext:always-bound *ildb* *trackdb*
|
||||||
|
*debugp* *gcp* *world-path* *server-port* *server*))
|
||||||
|
|
||||||
(defmacro ensure-world-path (path)
|
(defmacro ensure-world-path (path)
|
||||||
`(uiop:ensure-pathname ,path :defaults (uiop:getcwd) :ensure-directory t
|
`(uiop:ensure-pathname ,path :defaults (uiop:getcwd) :ensure-directory t
|
||||||
:want-existing t :ensure-absolute t))
|
:want-existing t :ensure-absolute t))
|
||||||
|
|
||||||
(defmacro savefilepath (name)
|
(defmacro savefilepath (name)
|
||||||
`(uiop:subpathname *world-path* (concatenate 'string "advtrains_" ,name)))
|
`(uiop:subpathname *world-path* ,(if (stringp name)
|
||||||
|
(concatenate 'string "advtrains_" name)
|
||||||
|
`(concatenate 'string "advtrains_" ,name))))
|
||||||
|
|
||||||
(defun load-data ()
|
(defun load-data ()
|
||||||
(let* ((ildb (atil:load-ildb (savefilepath "interlocking.ls"))))
|
(let* ((ildb (atil:load-ildb (savefilepath "interlocking.ls")))
|
||||||
(multiple-value-bind (tdb tdbtemp) (tracks:load-trackdb (savefilepath "ndb4.ls"))
|
(tdb (tracks:load-trackdb (savefilepath "ndb4.ls"))))
|
||||||
(if *debugp* (setf *trackdb-temp* tdbtemp))
|
(psetf *ildb* ildb *trackdb* tdb)
|
||||||
(psetf *ildb* ildb *trackdb* tdb)))
|
(when *gcp*
|
||||||
(when *gcp*
|
#+sbcl(sb-ext:gc :full t))
|
||||||
#+sbcl(sb-ext:gc :full t))
|
(hunchentoot:acceptor-log-message *server* :info "Database updated")))
|
||||||
(hunchentoot:acceptor-log-message *server* :info "Database updated"))
|
|
||||||
|
|
||||||
(defmacro mainloop ()
|
(defmacro mainloop ()
|
||||||
`(loop (load-data) (sleep 20)))
|
`(loop (load-data) (sleep 20)))
|
||||||
|
|
|
@ -133,7 +133,7 @@
|
||||||
(push adj (aref connects (dir-c i))))
|
(push adj (aref connects (dir-c i))))
|
||||||
(setf (get-track tdb pos) (make-track :connects connects))))
|
(setf (get-track tdb pos) (make-track :connects connects))))
|
||||||
(optimize-track-database tdb)
|
(optimize-track-database tdb)
|
||||||
(values tdb tmpdb)))
|
tdb))
|
||||||
|
|
||||||
(defun gvdump (tdb)
|
(defun gvdump (tdb)
|
||||||
(with-output-to-string (stream)
|
(with-output-to-string (stream)
|
||||||
|
|
Loading…
Reference in New Issue