ea20cfa

Branches > main > ea20cfa > files

Tick ideas?

Grahp, 2026-08-30

Commit: ea20cfa2050766377a0a9328c96347153db5796c
Parent: cb928b0

5 changed files:

src/net/bowmap/protocol/handle.clj modified (view file)

@@ -16,6 +16,9 @@    [net.bowmap.transport.connection :as connection]))  ; Could eventually just be a seq of both packets and events if that would be nicer to read and write.+; TODO I don't think this belongs at the protocol level, it's really a client/server level thing.+; And this function should 100% take the player!+; Could call this within the tick function, or just use the state atom (defmulti interpret-packet   "Interprets one serverbound packet, returns a map of [:packets :events].    Safe to call within a transaction, but may update refs."

src/net/bowmap/protocol/packet/clientbound.clj modified (view file)

@@ -10,6 +10,8 @@             location-> long-> lpvec3-> nbt-> optional-> or-> string-> ubyte->             uuid-> varint->]])) +; TODO the [::state [::packet-id [schema]]] idea :)+; And document that it's about ::login-disconnect (def packets   {::status-response [:response "Response to serverbound ::status-request" json->]    ::pong-response [:timestamp "The same timestamp as serverbound ::ping-request" long->]

src/net/bowmap/server/logic.clj modified (view file)

@@ -7,6 +7,7 @@    [net.bowmap.stormbow.effect :as effect]    [net.bowmap.stormbow.event :as event])) +; TODO so switch this all to pure functions, and call them from a tick function! (defmulti handle-event   "Returns a sequence of effects and events yielded from an event."   (fn [event]@@ -33,6 +34,7 @@     [{::event/id ::event/broadcast       ::text/component {:text (str (or (::player/username (server/player uuid)) "Unknown Player") " Joined!")}}])) +; TODO if these were atoms, could handle-events even work? (defmethod handle-event ::event/player-left [{:keys! [::player/uuid]}]   (dosync     (let [username (::player/username (server/player uuid))]@@ -64,6 +66,8 @@      ::player/uuid recipient      ::text/component {:text (str (::player/username (server/player uuid)) ": " message)}})) +; TODO because this mutates stuff, it should probably be coupled with the effect handling?+; I also have concerns about stale state, i.e. if you update state, send an effect and another event, and that event updates state to a bad value for the effect (defn handle-events   "Handles the supplied event, and all events returned recursively from this one.    Returns a seq of all effects that are yielded from handling all events recursively."

src/net/bowmap/server/logic2.clj added (view file)

No content changes.

src/net/bowmap/server/tick.clj added (view file)

@@ -0,0 +1,8 @@+(ns net.bowmap.server.tick)++(defonce state (atom {}))++; The server tick function.+; Does all the things+(defn tick []+  (handle-player-join))