projects
/
mudsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rearchitect so that the world can init with a game-spec, not just a room-spec
[mudsync.git]
/
mudsync
/
game-master.scm
diff --git
a/mudsync/game-master.scm
b/mudsync/game-master.scm
index 732427850fc72b5e9601a112b95afd077b53cd01..0d2051ec48bd43df10abfd3e56e1e38203f3c845 100644
(file)
--- a/
mudsync/game-master.scm
+++ b/
mudsync/game-master.scm
@@
-33,10
+33,6
@@
(special-dir #:init-thunk make-hash-table
#:getter gm-special-dir)
(special-dir #:init-thunk make-hash-table
#:getter gm-special-dir)
- ;; Room directory. Room symbols to locations.
- (room-dir #:init-thunk make-hash-table
- #:getter gm-room-dir)
-
;; A mapping of client ids to in-game actors
;; and a reverse ;p
(client-dir #:init-thunk make-hash-table
;; A mapping of client ids to in-game actors
;; and a reverse ;p
(client-dir #:init-thunk make-hash-table
@@
-57,7
+53,7
@@
(make-action-dispatch
(init-world (wrap-apply gm-init-world))
(client-input (wrap-apply gm-handle-client-input))
(make-action-dispatch
(init-world (wrap-apply gm-init-world))
(client-input (wrap-apply gm-handle-client-input))
- (lookup-
room (wrap-apply gm-lookup-room
))
+ (lookup-
special (wrap-apply gm-lookup-special
))
(new-client (wrap-apply gm-new-client))
(write-home (wrap-apply gm-write-home)))))
(new-client (wrap-apply gm-new-client))
(write-home (wrap-apply gm-write-home)))))
@@
-69,7
+65,7
@@
;; TODO
;; Init basic rooms / structure
;; TODO
;; Init basic rooms / structure
- (gm-init-
rooms gm (message-ref message 'room
-spec))
+ (gm-init-
game-spec gm (message-ref message 'game
-spec))
;; Restore database-based actors
;; TODO
;; Restore database-based actors
;; TODO
@@
-77,30
+73,43
@@
;; Set up the network
(gm-setup-network gm))
;; Set up the network
(gm-setup-network gm))
-(define (gm-init-rooms gm rooms-spec)
- "Initialize the prebuilt rooms"
- (define rooms
+(define (gm-init-game-spec gm game-spec)
+ "Initialize the prebuilt special objects"
+ (define set-locs '())
+ (define specials
(map
(match-lambda
(map
(match-lambda
- ((room-symbol room-class
- room-args ...)
- ;; initialize the room
- (let ((room
- (apply create-actor* gm room-class "room"
+ ((symbol class loc args ...)
+ ;; initialize the special object
+ (let ((special-obj
+ (apply create-actor* gm class
+ ;; set cookie to be the object's symbol
+ (symbol->string symbol)
#:gm (actor-id gm)
#:gm (actor-id gm)
- room-args)))
- ;; register the room
- (hash-set! (gm-room-dir gm) room-symbol room)
+ args)))
+ ;; register the object
+ (hash-set! (gm-special-dir gm) symbol special-obj)
+ ;; Give ourselves an instruction to set the location
+ (set! set-locs (cons (cons special-obj loc) set-locs))
;; pass it back to the map
;; pass it back to the map
-
room
)))
-
rooms
-spec))
+
special-obj
)))
+
game
-spec))
- ;; now wire up all the exits
+ ;; Set all initial locations
+ (for-each
+ (match-lambda
+ ((special-obj . loc)
+ (if loc
+ (<-wait gm special-obj 'set-loc!
+ #:loc (hash-ref (gm-special-dir gm) loc)))))
+ set-locs)
+
+ ;; now init all the objects
(for-each
(for-each
- (lambda (
room
)
- (format #t "
Wiring up ~s...\n" (address->string room
))
- (<-wait gm
room 'wire-exits!
))
-
room
s))
+ (lambda (
special-obj
)
+ (format #t "
Initializing ~s...\n" (address->string special-obj
))
+ (<-wait gm
special-obj 'init
))
+
special
s))
(define (gm-setup-network gm)
(define (gm-setup-network gm)
@@
-135,9
+144,9
@@
(<- actor player 'handle-input
#:input input))
(<- actor player 'handle-input
#:input input))
-(define-mhandler (gm-lookup-
room
actor message symbol)
+(define-mhandler (gm-lookup-
special
actor message symbol)
(<-reply actor message
(<-reply actor message
- #:room-id (hash-ref (slot-ref actor '
room
-dir) symbol)))
+ #:room-id (hash-ref (slot-ref actor '
special
-dir) symbol)))
(define-mhandler (gm-write-home actor message text)
(define client-id (hash-ref (gm-reverse-client-dir actor)
(define-mhandler (gm-write-home actor message text)
(define client-id (hash-ref (gm-reverse-client-dir actor)
@@
-177,7
+186,7
@@
with an anonymous persona"
(let* ((guest-name (string-append "Guest-"
(number->string count)))
(room-id
(let* ((guest-name (string-append "Guest-"
(number->string count)))
(room-id
- (hash-ref (gm-
room
-dir gm) default-room))
+ (hash-ref (gm-
special
-dir gm) default-room))
;; create and register the player
(player
(create-actor* gm (@@ (mudsync player) <player>) "player"
;; create and register the player
(player
(create-actor* gm (@@ (mudsync player) <player>) "player"