X-Git-Url: http://git.pond.sub.org/?p=eow;a=blobdiff_plain;f=empire.lisp;h=8a83ac0082f6a1806dab2c98a55cf48c9157b15d;hp=2f3452e3af8113b120fd87fd0a6873c70231ae7e;hb=534a13f805a930866db4a55e58bc86dc1608dce4;hpb=a4f36e2bf190fa6f14347a00e309af5a3d74f159 diff --git a/empire.lisp b/empire.lisp index 2f3452e..8a83ac0 100644 --- a/empire.lisp +++ b/empire.lisp @@ -303,20 +303,24 @@ (char= +special-command-char+ (aref line 0)))) (defclass xdump-mode (play-mode) - ((table-buffer - :initform nil - :accessor table-buffer - :documentation "Intermediate storage for incomplete table dump."))) + ((parser :initform (xdump:make-parser)) + (phase :initform :meta-meta))) (defmethod handle-data ((m xdump-mode) message) - (with-slots (connection table-buffer) m - (if (char= #\/ (aref message 0)) - (progn - (format t "table: ~a~%" table-buffer) - (set-new-mode m 'play-mode))) - ;XXX check table size - (with-input-from-string (s (format nil "(~a)" message)) - (setf table-buffer (cons (read s) table-buffer))))) + (with-slots (connection parser phase) m + (if (xdump:parse-line parser message) + ;;XXX consider something like a 'pop-mode function + (ccase phase + (:meta-meta + (setf phase :meta-table + parser (xdump:make-parser)) + (send-message connection "xdump meta table")) + (:meta-table + (setf phase :table + parser (xdump:make-parser)) + (send-message connection "xdump table *")) + (:table + (set-new-mode (connection-mode connection) 'play-mode)))))) (defmethod special-xup ((c connection)) (send-message c "xdump meta meta" :next-mode 'xdump-mode))