diff --git a/TODO b/TODO index 5d3f975..2fde511 100644 --- a/TODO +++ b/TODO @@ -12,8 +12,6 @@ * implement players and player list -* implement client/server communication - * (I am legion...) @@ -21,7 +19,8 @@ -> SEVERE -* ... +* Naledi occasionally hangs on `q` + -> Too many player threads started? -> NON-SEVERE @@ -31,3 +30,4 @@ * 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) diff --git a/TODO b/TODO index 5d3f975..2fde511 100644 --- a/TODO +++ b/TODO @@ -12,8 +12,6 @@ * implement players and player list -* implement client/server communication - * (I am legion...) @@ -21,7 +19,8 @@ -> SEVERE -* ... +* Naledi occasionally hangs on `q` + -> Too many player threads started? -> NON-SEVERE @@ -31,3 +30,4 @@ * 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) diff --git a/naledi.lisp b/naledi.lisp index d469630..8deabe5 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -64,33 +64,37 @@ ((:up :down) (croatoan:update-menu mw event) (croatoan:draw-menu mw)) - (#\newline ;;XXX this clause is too long - ;;FIXME starting a local game doesn't work anymore... + (#\newline (cond ((equalp (croatoan:current-item mw) "Start a local game") - ;;TODO choose world size - (start-server) - (setf *host* (first *defaulthost*) - *port* (second *defaulthost*)) - ;;give the server time to start - ;(while (not (runningp)) ;;TODO replace with `loop' - (sleep 1) - (connect-server)) + (start-local-game scr)) ((equalp (croatoan:current-item mw) "Connect to a remote server") - (setf *host* (query-user scr "Server IP/URL:" :cls T)) - (setf *port* - (read-from-string - (query-user scr "Server port:" - :default (second *defaulthost*) :cls T))) - (if (user-confirm-p scr - (format nil "Connect to ~A:~S?" *host* *port*) - T) - (connect-server) - (start-or-connect-to-server scr))) - (return-from croatoan:event-case)))))) + (connect-remote-game scr))) + (return-from croatoan:event-case))))) + +(defun start-local-game (scr) + "Start a local game" + ;;TODO choose world size + (start-server) + (setf *host* (first *defaulthost*) + *port* (second *defaulthost*)) + ;;give the server time to start + (while (not (runningp)) ;;TODO replace with `loop' + (sleep 0.5)) + (connect-server)) ;;TODO (choose-world-size) +(defun connect-remote-game (scr) + "Ask the user which server to connect to and do so" + (setf *host* (query-user scr "Server IP/URL:" :cls T)) + (setf *port* (read-from-string + (query-user scr "Server port:" + :default (second *defaulthost*) :cls T))) + (if (user-confirm-p scr (format nil "Connect to ~A:~S?" *host* *port*) T) + (connect-server) + (start-or-connect-to-server scr))) + (defun user-interface (scr) "Create the screen on the ncurses interface and hand over to window functions" (let* ((width (croatoan:.width scr)) (height (1- (croatoan:.height scr))) diff --git a/TODO b/TODO index 5d3f975..2fde511 100644 --- a/TODO +++ b/TODO @@ -12,8 +12,6 @@ * implement players and player list -* implement client/server communication - * (I am legion...) @@ -21,7 +19,8 @@ -> SEVERE -* ... +* Naledi occasionally hangs on `q` + -> Too many player threads started? -> NON-SEVERE @@ -31,3 +30,4 @@ * 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) diff --git a/naledi.lisp b/naledi.lisp index d469630..8deabe5 100644 --- a/naledi.lisp +++ b/naledi.lisp @@ -64,33 +64,37 @@ ((:up :down) (croatoan:update-menu mw event) (croatoan:draw-menu mw)) - (#\newline ;;XXX this clause is too long - ;;FIXME starting a local game doesn't work anymore... + (#\newline (cond ((equalp (croatoan:current-item mw) "Start a local game") - ;;TODO choose world size - (start-server) - (setf *host* (first *defaulthost*) - *port* (second *defaulthost*)) - ;;give the server time to start - ;(while (not (runningp)) ;;TODO replace with `loop' - (sleep 1) - (connect-server)) + (start-local-game scr)) ((equalp (croatoan:current-item mw) "Connect to a remote server") - (setf *host* (query-user scr "Server IP/URL:" :cls T)) - (setf *port* - (read-from-string - (query-user scr "Server port:" - :default (second *defaulthost*) :cls T))) - (if (user-confirm-p scr - (format nil "Connect to ~A:~S?" *host* *port*) - T) - (connect-server) - (start-or-connect-to-server scr))) - (return-from croatoan:event-case)))))) + (connect-remote-game scr))) + (return-from croatoan:event-case))))) + +(defun start-local-game (scr) + "Start a local game" + ;;TODO choose world size + (start-server) + (setf *host* (first *defaulthost*) + *port* (second *defaulthost*)) + ;;give the server time to start + (while (not (runningp)) ;;TODO replace with `loop' + (sleep 0.5)) + (connect-server)) ;;TODO (choose-world-size) +(defun connect-remote-game (scr) + "Ask the user which server to connect to and do so" + (setf *host* (query-user scr "Server IP/URL:" :cls T)) + (setf *port* (read-from-string + (query-user scr "Server port:" + :default (second *defaulthost*) :cls T))) + (if (user-confirm-p scr (format nil "Connect to ~A:~S?" *host* *port*) T) + (connect-server) + (start-or-connect-to-server scr))) + (defun user-interface (scr) "Create the screen on the ncurses interface and hand over to window functions" (let* ((width (croatoan:.width scr)) (height (1- (croatoan:.height scr))) diff --git a/src/params.lisp b/src/params.lisp index 3dfdf97..b354c37 100644 --- a/src/params.lisp +++ b/src/params.lisp @@ -22,13 +22,13 @@ (defparameter *framerate* 1000) ;;Localhost defaults -(defparameter *defaulthost* '("127.0.0.1" 21895)) +(defparameter *defaulthost* '("127.0.0.1" 21896)) ;default port: 21895 ;;Host server address to connect to -(defparameter *host* "127.0.0.1") +(defparameter *host* (first *defaulthost*)) ;;Network port to use -(defparameter *port* 21895) +(defparameter *port* (second *defaulthost*)) ;;Compass directions needed for spatial functions (defparameter *directions* '(N NE E SE S SW W NW))