Skip to content

Commit ce60917

Browse files
committed
Refactored Mudlet GUI and Mapper configuration sending
Added: - sendMudletMapperInstall function to handle mapper package installation via Client.GUI Changed: - Reordered GMCP messages to send Client.Map before Client.GUI for proper Mudlet client handling - Refactored sendMudletConfig to use dedicated functions instead of inline payload creation Removed: - Unnecessary user record fetch in sendMudletConfig function - Duplicate payload construction for mapper installation
1 parent 3870bab commit ce60917

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

modules/gmcp/gmcp.Mudlet.go

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,25 @@ func (g *GMCPMudletHandler) sendMudletMapConfig(userId int) {
308308
mudlog.Debug("GMCP", "type", "Mudlet", "action", "Sent Mudlet map config", "userId", userId)
309309
}
310310

311+
// Send Mudlet mapper package installation message
312+
func (g *GMCPMudletHandler) sendMudletMapperInstall(userId int) {
313+
if userId < 1 {
314+
return
315+
}
316+
317+
// Read config values dynamically to get latest overrides
318+
payload := struct {
319+
Version string `json:"version"`
320+
URL string `json:"url"`
321+
}{
322+
Version: getConfigString("mapper_version"),
323+
URL: getConfigString("mapper_url"),
324+
}
325+
326+
sendGMCP(userId, "Client.GUI", payload)
327+
mudlog.Debug("GMCP", "type", "Mudlet", "action", "Sent Mudlet mapper install config", "userId", userId)
328+
}
329+
311330
// Send Mudlet UI package installation message
312331
func (g *GMCPMudletHandler) sendMudletUIInstall(userId int) {
313332
if userId < 1 {
@@ -365,22 +384,11 @@ func (g *GMCPMudletHandler) sendMudletConfig(userId int) {
365384
return
366385
}
367386

368-
// Read config values dynamically to get latest overrides
369-
// Send mapper info
370-
payload := struct {
371-
Version string `json:"version"`
372-
URL string `json:"url"`
373-
}{
374-
Version: getConfigString("mapper_version"),
375-
URL: getConfigString("mapper_url"),
376-
}
377-
sendGMCP(userId, "Client.GUI", payload)
387+
// Send Client.Map first (before Client.GUI)
388+
g.sendMudletMapConfig(userId)
378389

379-
// Get the user record
380-
user := users.GetByUserId(userId)
381-
if user == nil {
382-
return
383-
}
390+
// Then send Client.GUI with mapper package installation info
391+
g.sendMudletMapperInstall(userId)
384392

385393
// Send Discord info if enabled
386394
g.sendDiscordInfo(userId)

0 commit comments

Comments
 (0)