diff --git a/TODO b/TODO index 2fde511..31330e0 100644 --- a/TODO +++ b/TODO @@ -19,15 +19,14 @@ -> SEVERE -* Naledi occasionally hangs on `q` - -> Too many player threads started? +* ... -> NON-SEVERE -* ... +* Lakes are created -> HEISENBUGS * occasionally, scrolling the map will lag, causing an "inertia" effect (reloading resolves this, but what's the cause?) - -> hasn't occurred in a long time (11/12/2018) + -> hasn't occurred in a long time (as of 11/12/2018) diff --git a/TODO b/TODO index 2fde511..31330e0 100644 --- a/TODO +++ b/TODO @@ -19,15 +19,14 @@ -> SEVERE -* Naledi occasionally hangs on `q` - -> Too many player threads started? +* ... -> NON-SEVERE -* ... +* Lakes are created -> HEISENBUGS * occasionally, scrolling the map will lag, causing an "inertia" effect (reloading resolves this, but what's the cause?) - -> hasn't occurred in a long time (11/12/2018) + -> hasn't occurred in a long time (as of 11/12/2018) diff --git a/src/server.lisp b/src/server.lisp index aec9fb8..c113434 100644 --- a/src/server.lisp +++ b/src/server.lisp @@ -52,7 +52,6 @@ "Start the game server" ;;FIXME cannot restart -> ADDRESS-IN-USE ERROR ;; -> comes from not closing connections properly? - ;;FIXME causes Naledi to hang on `q' -> Is this really the problem? ;;XXX change force back to NIL? (when force (reset-server-threads) @@ -91,7 +90,7 @@ (defun update-loop () "The main loop, updating the world in the background" ;;XXX split this up into two or more functions, to be run by - ;; different threads? + ;; different threads? (e.g. player- & world-update threads) (logging "UPDATE ~S" uptime) ;;Update all items and occupants in each patch (dotimes (y (world-size)) @@ -114,12 +113,15 @@ (usocket:with-socket-listener (socket "127.0.0.1" *port*) (while running (usocket:wait-for-input socket) - (let ((thread (bt:make-thread - #'(lambda () (handle-connection socket)) - :name (string-from-list (list "player-thread" - (length player-threads)) "-")))) - (setf player-threads (cons thread player-threads)) - (sleep 1))))) ;;give the socket a chance to connect + (when (eq (usocket:socket-state socket) ':read) + (let ((thread (bt:make-thread + #'(lambda () + (handle-connection socket)) + :name (string-from-list + (list "player-thread" + (length player-threads)) "-")))) + (setf player-threads (cons thread player-threads)) + (sleep 1)))))) ;;give the socket a chance to connect (defun handle-connection (socket) "Answer requests until the player disconnects"