|
@@ -14,8 +14,9 @@
|
|
|
(loop
|
|
(loop
|
|
|
with last-pos = (file-position s)
|
|
with last-pos = (file-position s)
|
|
|
for line = (read-line s nil nil)
|
|
for line = (read-line s nil nil)
|
|
|
- when line do (progn
|
|
|
|
|
- (funcall thunk line)
|
|
|
|
|
|
|
+ when line do (unwind-protect
|
|
|
|
|
+ (handler-case (funcall thunk line)
|
|
|
|
|
+ (error (e) (log:error e)))
|
|
|
(setf last-pos (file-position s)))
|
|
(setf last-pos (file-position s)))
|
|
|
else do (progn
|
|
else do (progn
|
|
|
(sleep 0.1)
|
|
(sleep 0.1)
|
|
@@ -50,10 +51,11 @@
|
|
|
when (suicidep player kill) sum -1 else sum 1))
|
|
when (suicidep player kill) sum -1 else sum 1))
|
|
|
|
|
|
|
|
(defun get-rankings (&optional (game *game*))
|
|
(defun get-rankings (&optional (game *game*))
|
|
|
- (sort (loop for player across (game-players game)
|
|
|
|
|
- when (player-began player)
|
|
|
|
|
- collect (cons (player-score player) player))
|
|
|
|
|
- #'> :key #'car))
|
|
|
|
|
|
|
+ (when-let (players (game-players game))
|
|
|
|
|
+ (sort (loop for player across players
|
|
|
|
|
+ when (player-began player)
|
|
|
|
|
+ collect (cons (player-score player) player))
|
|
|
|
|
+ #'> :key #'car)))
|
|
|
|
|
|
|
|
(defun game-status (&optional (game *game*))
|
|
(defun game-status (&optional (game *game*))
|
|
|
(let ((ranks (get-rankings)))
|
|
(let ((ranks (get-rankings)))
|
|
@@ -104,7 +106,8 @@
|
|
|
(action (keyify (subseq line 7 sep)))
|
|
(action (keyify (subseq line 7 sep)))
|
|
|
(args (when (and sep (> (length line) (+ 2 sep))) (subseq line (+ 2 sep))))
|
|
(args (when (and sep (> (length line) (+ 2 sep))) (subseq line (+ 2 sep))))
|
|
|
(client (when args (parse-integer args :junk-allowed t)))
|
|
(client (when args (parse-integer args :junk-allowed t)))
|
|
|
- (player (when (and client (<= 0 client (1- (max-players)))) (elt (game-players *game*) client))))
|
|
|
|
|
|
|
+ (player (when (and client (<= 0 client (1- (max-players))))
|
|
|
|
|
+ (elt (game-players *game*) client))))
|
|
|
(setf (game-last-time *game*) (trim-nil time))
|
|
(setf (game-last-time *game*) (trim-nil time))
|
|
|
(case action
|
|
(case action
|
|
|
(:initgame (with-slots (info players is-active) *game*
|
|
(:initgame (with-slots (info players is-active) *game*
|