diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index aadad89..eeca782 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -10,6 +10,7 @@ (defconstant ATLANTIS-VERSION '(0 1 1)) (load "util.lisp") +(load "networking.lisp") (load "game-objects.lisp") (load "player.lisp") (load "world.lisp") @@ -45,16 +46,18 @@ (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") - (input-string ip) - (while (not (= (count-instances #\. ip) 3)) - (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input-string ip)) + (input-string server-ip) + (while (not (= (count-instances #\. server-ip) 3)) + (format t "~&Not an IP address: ~A. Please reenter:" server-ip) + (input-string server-ip)) + (setf (cassoc ip *server-address*) server-ip) (format t "~&What port does the game run on?") - (while (not (numberp (input port))) - (format t "~&Not a number: ~A. Please reenter:" port)) + (while (not (numberp (input server-port))) + (format t "~&Not a number: ~A. Please reenter:" server-port)) + (setf (cassoc port *server-address*) server-port) (format t "~&What is your player name?") (input-string name) - (format t "~&Joining game on ~A:~A as ~A" ip port name) + (format t "~&Joining game on ~A:~A as ~A" server-ip server-port name) (play-game name)) diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index aadad89..eeca782 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -10,6 +10,7 @@ (defconstant ATLANTIS-VERSION '(0 1 1)) (load "util.lisp") +(load "networking.lisp") (load "game-objects.lisp") (load "player.lisp") (load "world.lisp") @@ -45,16 +46,18 @@ (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") - (input-string ip) - (while (not (= (count-instances #\. ip) 3)) - (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input-string ip)) + (input-string server-ip) + (while (not (= (count-instances #\. server-ip) 3)) + (format t "~&Not an IP address: ~A. Please reenter:" server-ip) + (input-string server-ip)) + (setf (cassoc ip *server-address*) server-ip) (format t "~&What port does the game run on?") - (while (not (numberp (input port))) - (format t "~&Not a number: ~A. Please reenter:" port)) + (while (not (numberp (input server-port))) + (format t "~&Not a number: ~A. Please reenter:" server-port)) + (setf (cassoc port *server-address*) server-port) (format t "~&What is your player name?") (input-string name) - (format t "~&Joining game on ~A:~A as ~A" ip port name) + (format t "~&Joining game on ~A:~A as ~A" server-ip server-port name) (play-game name)) diff --git a/lisp/client.lisp b/lisp/client.lisp index ae72ff7..e51c597 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -14,6 +14,7 @@ (let ((player NIL)) (defun play-game (player-name) "The main game loop" + ;(update-world) ;; Initialize the player if necessary (when (null player) (setf player (get-game-object 'player player-name))) @@ -30,6 +31,8 @@ (input-string command) (while (not (or (equalp command "quit") (equalp command "exit"))) (game-command command player) + ;(server-send (game-command command player)) + ;(update-world) (input-string command)) (format t "~&Goodbye!")))) diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index aadad89..eeca782 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -10,6 +10,7 @@ (defconstant ATLANTIS-VERSION '(0 1 1)) (load "util.lisp") +(load "networking.lisp") (load "game-objects.lisp") (load "player.lisp") (load "world.lisp") @@ -45,16 +46,18 @@ (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") - (input-string ip) - (while (not (= (count-instances #\. ip) 3)) - (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input-string ip)) + (input-string server-ip) + (while (not (= (count-instances #\. server-ip) 3)) + (format t "~&Not an IP address: ~A. Please reenter:" server-ip) + (input-string server-ip)) + (setf (cassoc ip *server-address*) server-ip) (format t "~&What port does the game run on?") - (while (not (numberp (input port))) - (format t "~&Not a number: ~A. Please reenter:" port)) + (while (not (numberp (input server-port))) + (format t "~&Not a number: ~A. Please reenter:" server-port)) + (setf (cassoc port *server-address*) server-port) (format t "~&What is your player name?") (input-string name) - (format t "~&Joining game on ~A:~A as ~A" ip port name) + (format t "~&Joining game on ~A:~A as ~A" server-ip server-port name) (play-game name)) diff --git a/lisp/client.lisp b/lisp/client.lisp index ae72ff7..e51c597 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -14,6 +14,7 @@ (let ((player NIL)) (defun play-game (player-name) "The main game loop" + ;(update-world) ;; Initialize the player if necessary (when (null player) (setf player (get-game-object 'player player-name))) @@ -30,6 +31,8 @@ (input-string command) (while (not (or (equalp command "quit") (equalp command "exit"))) (game-command command player) + ;(server-send (game-command command player)) + ;(update-world) (input-string command)) (format t "~&Goodbye!")))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index b1b46d9..b0af3c7 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -74,6 +74,7 @@ ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) (eql (aref line 0) #\TAB))) + ;; TODO Catch syntax errors (setf current-object (funcall (symbol-function (read-from-string line)) ;; this is a kludge to work around a clisp bug (not diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index aadad89..eeca782 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -10,6 +10,7 @@ (defconstant ATLANTIS-VERSION '(0 1 1)) (load "util.lisp") +(load "networking.lisp") (load "game-objects.lisp") (load "player.lisp") (load "world.lisp") @@ -45,16 +46,18 @@ (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") - (input-string ip) - (while (not (= (count-instances #\. ip) 3)) - (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input-string ip)) + (input-string server-ip) + (while (not (= (count-instances #\. server-ip) 3)) + (format t "~&Not an IP address: ~A. Please reenter:" server-ip) + (input-string server-ip)) + (setf (cassoc ip *server-address*) server-ip) (format t "~&What port does the game run on?") - (while (not (numberp (input port))) - (format t "~&Not a number: ~A. Please reenter:" port)) + (while (not (numberp (input server-port))) + (format t "~&Not a number: ~A. Please reenter:" server-port)) + (setf (cassoc port *server-address*) server-port) (format t "~&What is your player name?") (input-string name) - (format t "~&Joining game on ~A:~A as ~A" ip port name) + (format t "~&Joining game on ~A:~A as ~A" server-ip server-port name) (play-game name)) diff --git a/lisp/client.lisp b/lisp/client.lisp index ae72ff7..e51c597 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -14,6 +14,7 @@ (let ((player NIL)) (defun play-game (player-name) "The main game loop" + ;(update-world) ;; Initialize the player if necessary (when (null player) (setf player (get-game-object 'player player-name))) @@ -30,6 +31,8 @@ (input-string command) (while (not (or (equalp command "quit") (equalp command "exit"))) (game-command command player) + ;(server-send (game-command command player)) + ;(update-world) (input-string command)) (format t "~&Goodbye!")))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index b1b46d9..b0af3c7 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -74,6 +74,7 @@ ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) (eql (aref line 0) #\TAB))) + ;; TODO Catch syntax errors (setf current-object (funcall (symbol-function (read-from-string line)) ;; this is a kludge to work around a clisp bug (not diff --git a/lisp/networking.lisp b/lisp/networking.lisp index 2e22cbe..4ca6b9e 100644 --- a/lisp/networking.lisp +++ b/lisp/networking.lisp @@ -11,14 +11,29 @@ ;;; date: 30/05/2015 ;;; +(defvar *server-address* + '((ip "127.0.0.1") (port 8888))) + +;; XXX Does this need to be a macro? (so the request doesn't have to be quoted) (defun send-server-request (ip port request) "Send a request string to the server" ;; TODO this is a mockup function (server-process-request request)) +(defmacro server-send (request) + "Saves some quoting" + `(send-server-request + (cassoc ip *server-address*) (cassoc port *server-address*) + ',request)) + (defun server-process-request (request) "The game server processes a request" ;; XXX Is simply calling (eval) on the request good enough? ;; Or should I come up with a proper networking protocol? ;; (Considering a possible Python implementation.) + (break) (eval request)) + +(defun update-world () + "Update the world to match the one on the server" + (setf *world* (server-send *world*))) diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index aadad89..eeca782 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -10,6 +10,7 @@ (defconstant ATLANTIS-VERSION '(0 1 1)) (load "util.lisp") +(load "networking.lisp") (load "game-objects.lisp") (load "player.lisp") (load "world.lisp") @@ -45,16 +46,18 @@ (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") - (input-string ip) - (while (not (= (count-instances #\. ip) 3)) - (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input-string ip)) + (input-string server-ip) + (while (not (= (count-instances #\. server-ip) 3)) + (format t "~&Not an IP address: ~A. Please reenter:" server-ip) + (input-string server-ip)) + (setf (cassoc ip *server-address*) server-ip) (format t "~&What port does the game run on?") - (while (not (numberp (input port))) - (format t "~&Not a number: ~A. Please reenter:" port)) + (while (not (numberp (input server-port))) + (format t "~&Not a number: ~A. Please reenter:" server-port)) + (setf (cassoc port *server-address*) server-port) (format t "~&What is your player name?") (input-string name) - (format t "~&Joining game on ~A:~A as ~A" ip port name) + (format t "~&Joining game on ~A:~A as ~A" server-ip server-port name) (play-game name)) diff --git a/lisp/client.lisp b/lisp/client.lisp index ae72ff7..e51c597 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -14,6 +14,7 @@ (let ((player NIL)) (defun play-game (player-name) "The main game loop" + ;(update-world) ;; Initialize the player if necessary (when (null player) (setf player (get-game-object 'player player-name))) @@ -30,6 +31,8 @@ (input-string command) (while (not (or (equalp command "quit") (equalp command "exit"))) (game-command command player) + ;(server-send (game-command command player)) + ;(update-world) (input-string command)) (format t "~&Goodbye!")))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index b1b46d9..b0af3c7 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -74,6 +74,7 @@ ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) (eql (aref line 0) #\TAB))) + ;; TODO Catch syntax errors (setf current-object (funcall (symbol-function (read-from-string line)) ;; this is a kludge to work around a clisp bug (not diff --git a/lisp/networking.lisp b/lisp/networking.lisp index 2e22cbe..4ca6b9e 100644 --- a/lisp/networking.lisp +++ b/lisp/networking.lisp @@ -11,14 +11,29 @@ ;;; date: 30/05/2015 ;;; +(defvar *server-address* + '((ip "127.0.0.1") (port 8888))) + +;; XXX Does this need to be a macro? (so the request doesn't have to be quoted) (defun send-server-request (ip port request) "Send a request string to the server" ;; TODO this is a mockup function (server-process-request request)) +(defmacro server-send (request) + "Saves some quoting" + `(send-server-request + (cassoc ip *server-address*) (cassoc port *server-address*) + ',request)) + (defun server-process-request (request) "The game server processes a request" ;; XXX Is simply calling (eval) on the request good enough? ;; Or should I come up with a proper networking protocol? ;; (Considering a possible Python implementation.) + (break) (eval request)) + +(defun update-world () + "Update the world to match the one on the server" + (setf *world* (server-send *world*))) diff --git a/lisp/util.lisp b/lisp/util.lisp index 7cc1c66..eeeb46d 100644 --- a/lisp/util.lisp +++ b/lisp/util.lisp @@ -20,7 +20,7 @@ syms) ,@body)) -;; DEPRECATED - Needs to be replaced in the current code +;; TODO DEPRECATED - Needs to be replaced in the current code (defmacro simple-input (var &optional (prompt ">>>")) "Take input from terminal and store it in var" `(progn @@ -185,7 +185,7 @@ (format t "~&~S" (eval expr))) (simple-input expr "lisp >")))) -;; XXX Interesting phenomenon of repl (security bug?): +;; FIXME Interesting phenomenon of repl (security bug?): ;; Enter two Lisp expressions that have not had a value assigned to them in the ;; current session (e.g. 'foo ls'). The first will cause the interpreter to ;; exit with an error. The second, however, is still printed to stdout (which is diff --git a/README b/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/README diff --git a/atlantis.txt b/atlantis.txt index e0de6dd..df8813a 100644 --- a/atlantis.txt +++ b/atlantis.txt @@ -8,7 +8,8 @@ Atlantis is a framework for creating an MUD world. It includes an interpreted language for describing places, items, monsters and NPCs; provides networking capabilities for multiplayer games and a text-based user interface. Inspired -and influenced by OpenWorld, it is written in Common Lisp. +by Dungeons and Dragons and influenced by OpenWorld, it is written in +Common Lisp. GAME PLAY @@ -29,6 +30,7 @@ probably passing simple strings around, so that shouldn't be too difficult. The threading is probably more of a challenge. (If it's necessary, that is?) + -> actually, clisp does support networking via sockets. Yeah! :-) Implementation: presumably Atlantis will have to have a server-client model. @@ -37,6 +39,7 @@ -> As stated above, this should be fairly easy to solve with string representations of objects in Lisp. (Just pass the *world* object to the client, for instance.) + -> SECURITY RISK! -> For the sake of better code separation, it would probably be wise to create two Lisp packages (server and client). diff --git a/lisp/atlantis.lisp b/lisp/atlantis.lisp index aadad89..eeca782 100644 --- a/lisp/atlantis.lisp +++ b/lisp/atlantis.lisp @@ -10,6 +10,7 @@ (defconstant ATLANTIS-VERSION '(0 1 1)) (load "util.lisp") +(load "networking.lisp") (load "game-objects.lisp") (load "player.lisp") (load "world.lisp") @@ -45,16 +46,18 @@ (defun join-game () "Join a running game on the server" (format t "~&What is the IP address of the server you want to join?") - (input-string ip) - (while (not (= (count-instances #\. ip) 3)) - (format t "~&Not an IP address: ~A. Please reenter:" ip) - (input-string ip)) + (input-string server-ip) + (while (not (= (count-instances #\. server-ip) 3)) + (format t "~&Not an IP address: ~A. Please reenter:" server-ip) + (input-string server-ip)) + (setf (cassoc ip *server-address*) server-ip) (format t "~&What port does the game run on?") - (while (not (numberp (input port))) - (format t "~&Not a number: ~A. Please reenter:" port)) + (while (not (numberp (input server-port))) + (format t "~&Not a number: ~A. Please reenter:" server-port)) + (setf (cassoc port *server-address*) server-port) (format t "~&What is your player name?") (input-string name) - (format t "~&Joining game on ~A:~A as ~A" ip port name) + (format t "~&Joining game on ~A:~A as ~A" server-ip server-port name) (play-game name)) diff --git a/lisp/client.lisp b/lisp/client.lisp index ae72ff7..e51c597 100644 --- a/lisp/client.lisp +++ b/lisp/client.lisp @@ -14,6 +14,7 @@ (let ((player NIL)) (defun play-game (player-name) "The main game loop" + ;(update-world) ;; Initialize the player if necessary (when (null player) (setf player (get-game-object 'player player-name))) @@ -30,6 +31,8 @@ (input-string command) (while (not (or (equalp command "quit") (equalp command "exit"))) (game-command command player) + ;(server-send (game-command command player)) + ;(update-world) (input-string command)) (format t "~&Goodbye!")))) diff --git a/lisp/interpreter.lisp b/lisp/interpreter.lisp index b1b46d9..b0af3c7 100644 --- a/lisp/interpreter.lisp +++ b/lisp/interpreter.lisp @@ -74,6 +74,7 @@ ((not (or (eql (aref line 0) #\;) (eql (aref line 0) #\SPACE) (eql (aref line 0) #\TAB))) + ;; TODO Catch syntax errors (setf current-object (funcall (symbol-function (read-from-string line)) ;; this is a kludge to work around a clisp bug (not diff --git a/lisp/networking.lisp b/lisp/networking.lisp index 2e22cbe..4ca6b9e 100644 --- a/lisp/networking.lisp +++ b/lisp/networking.lisp @@ -11,14 +11,29 @@ ;;; date: 30/05/2015 ;;; +(defvar *server-address* + '((ip "127.0.0.1") (port 8888))) + +;; XXX Does this need to be a macro? (so the request doesn't have to be quoted) (defun send-server-request (ip port request) "Send a request string to the server" ;; TODO this is a mockup function (server-process-request request)) +(defmacro server-send (request) + "Saves some quoting" + `(send-server-request + (cassoc ip *server-address*) (cassoc port *server-address*) + ',request)) + (defun server-process-request (request) "The game server processes a request" ;; XXX Is simply calling (eval) on the request good enough? ;; Or should I come up with a proper networking protocol? ;; (Considering a possible Python implementation.) + (break) (eval request)) + +(defun update-world () + "Update the world to match the one on the server" + (setf *world* (server-send *world*))) diff --git a/lisp/util.lisp b/lisp/util.lisp index 7cc1c66..eeeb46d 100644 --- a/lisp/util.lisp +++ b/lisp/util.lisp @@ -20,7 +20,7 @@ syms) ,@body)) -;; DEPRECATED - Needs to be replaced in the current code +;; TODO DEPRECATED - Needs to be replaced in the current code (defmacro simple-input (var &optional (prompt ">>>")) "Take input from terminal and store it in var" `(progn @@ -185,7 +185,7 @@ (format t "~&~S" (eval expr))) (simple-input expr "lisp >")))) -;; XXX Interesting phenomenon of repl (security bug?): +;; FIXME Interesting phenomenon of repl (security bug?): ;; Enter two Lisp expressions that have not had a value assigned to them in the ;; current session (e.g. 'foo ls'). The first will cause the interpreter to ;; exit with an error. The second, however, is still printed to stdout (which is diff --git a/lisp/world.lisp b/lisp/world.lisp index 78088c0..0b84a15 100644 --- a/lisp/world.lisp +++ b/lisp/world.lisp @@ -29,7 +29,7 @@ (starting-place "") (game-manager "")) ;The player in charge of the game -(setf *world* (make-world)) +(setf *world* (make-world)) ;XXX Move this to another module? (defun add-game-object (game-object) "Add 'game-object' to *world*"