77
88 "github.com/volte6/gomud/internal/connections"
99 "github.com/volte6/gomud/internal/events"
10+ "github.com/volte6/gomud/internal/mapper"
1011 "github.com/volte6/gomud/internal/mudlog"
1112 "github.com/volte6/gomud/internal/rooms"
1213 "github.com/volte6/gomud/internal/users"
@@ -106,13 +107,36 @@ func LocationGMCPUpdates(e events.Event) events.ListenerReturn {
106107 roomInfoStr .WriteString (`"area": "` + newRoom .Zone + `", ` )
107108 roomInfoStr .WriteString (`"environment": "` + newRoom .GetBiome ().Name () + `", ` )
108109
110+ // build coords
111+ // room coordinates (string of numbers separated by commas - area,X,Y,Z)
112+ // GoMud doesn't use numbers for areas, so will use string.
113+ roomInfoStr .WriteString (`"coords": "` + newRoom .Zone + `, ` )
114+ m := mapper .GetZoneMapper (newRoom .Zone )
115+ x , y , z , err := m .GetCoordinates (newRoom .RoomId )
116+ if err != nil {
117+ roomInfoStr .WriteString (`999999999999999999,999999999999999999,999999999999999999` )
118+ } else {
119+ roomInfoStr .WriteString (strconv .Itoa (x ))
120+ roomInfoStr .WriteString (`, ` )
121+ roomInfoStr .WriteString (strconv .Itoa (y ))
122+ roomInfoStr .WriteString (`, ` )
123+ roomInfoStr .WriteString (strconv .Itoa (z ))
124+ }
125+ roomInfoStr .WriteString (`", ` )
126+ // end coords
127+
109128 // build exits
110129 roomInfoStr .WriteString (`"exits": {` )
111130 exitCt := 0
112131 for name , exitInfo := range newRoom .Exits {
113132 if exitInfo .Secret {
114133 continue
115134 }
135+
136+ if ! mapper .IsCompassDirection (name ) {
137+ continue
138+ }
139+
116140 if exitCt > 0 {
117141 roomInfoStr .WriteString (`, ` )
118142 }
@@ -124,6 +148,56 @@ func LocationGMCPUpdates(e events.Event) events.ListenerReturn {
124148 roomInfoStr .WriteString (`}, ` )
125149 // End exits
126150
151+ // build exits "extra" (exits that map to roomId AND include x/y/z delta information)
152+ roomInfoStr .WriteString (`"exitsv2": {` )
153+ exitCt = 0
154+ deltaX , deltaY , deltaZ := 0 , 0 , 0
155+ for name , exitInfo := range newRoom .Exits {
156+
157+ if exitInfo .Secret {
158+ continue
159+ }
160+
161+ if exitCt > 0 {
162+ roomInfoStr .WriteString (`, ` )
163+ }
164+
165+ if len (exitInfo .MapDirection ) > 0 {
166+ deltaX , deltaY , deltaZ = mapper .GetDelta (exitInfo .MapDirection )
167+ } else {
168+ deltaX , deltaY , deltaZ = mapper .GetDelta (name )
169+ }
170+
171+ roomInfoStr .WriteString (`"` + name + `": { "num": ` )
172+ roomInfoStr .WriteString (strconv .Itoa (exitInfo .RoomId ))
173+ roomInfoStr .WriteString (`, "dx": ` )
174+ roomInfoStr .WriteString (strconv .Itoa (deltaX ))
175+ roomInfoStr .WriteString (`, "dy": ` )
176+ roomInfoStr .WriteString (strconv .Itoa (deltaY ))
177+ roomInfoStr .WriteString (`, "dz": ` )
178+ roomInfoStr .WriteString (strconv .Itoa (deltaZ ))
179+
180+ if exitInfo .HasLock () {
181+ roomInfoStr .WriteString (`, "locked": true` )
182+
183+ lockId := fmt .Sprintf (`%d-%s` , newRoom .RoomId , name )
184+
185+ hasKey , hasSequence := user .Character .HasKey (lockId , int (exitInfo .Lock .Difficulty ))
186+
187+ roomInfoStr .WriteString (`, "haskey": ` )
188+ roomInfoStr .WriteString (strconv .FormatBool (hasKey ))
189+
190+ roomInfoStr .WriteString (`, "haspickcombo": ` )
191+ roomInfoStr .WriteString (strconv .FormatBool (hasSequence ))
192+ }
193+
194+ roomInfoStr .WriteString (`}` )
195+
196+ exitCt ++
197+ }
198+ roomInfoStr .WriteString (`}, ` )
199+ // End exits
200+
127201 // build details
128202 roomInfoStr .WriteString (`"details": [` )
129203
0 commit comments