Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _datafiles/html/public/viewconfig.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h3>Server Config: </h3>
<th>Name</th>
<th>Value</th>
</tr>
{{range $name, $value := ($config.AllConfigData "*port" "seed*" "folder*" "file*" "seedint") }}
{{range $name, $value := ($config.AllConfigData "bannednames" "*startroom*" "script*" "publicfileurl" "onlogin*" "nextroomid*" "mob*" "*port" "seed*" "folder*" "file*" "seedint" "carefulsavefiles" "lootgoblin*" "maxcpucores" "*roommessagewrapper" "logintervalroundcount" ) }}
<tr>
<td>{{ $name }}</td>
<td>{{ $value }}</td>
Expand Down
11 changes: 9 additions & 2 deletions _datafiles/html/static/public/css/gomud.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
/* Table Specific Colors */
--table-border-color: #000;
--table-header-color: var(--header-background);
--table-text-color: #000;
--table-cell-text-color: #000;
--table-header-text-color: var(--text-primary-color);
--table-cell-color: #c9e2db;
--table-cell-alt-color: #80a5a9;
}
Expand Down Expand Up @@ -171,10 +172,10 @@ footer a:hover {

table {
width: 100%;
color:var(--table-text-color)
}
table th {
background-color:var(--header-background);
color:var(--table-header-text-color);
padding:1em;
}
table tr {
Expand All @@ -188,4 +189,10 @@ table td {
padding:.1em;
font-family: monospace;
text-align:left;
color:var(--table-cell-text-color)
}
@media (max-width: 768px) {
table td {
font-size: 3.2vw;
}
}
Binary file modified _datafiles/html/static/public/images/web_bg.webp
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 19 additions & 29 deletions _datafiles/world/default/templates/goodbye.template
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
{{/*

<ansi fg='black' bold='0'>
┌────────────────────────────────────────────────────────────────┐
│ BBBBBBBBBBBBBBBBB │
│ B::::::::::::::::B │
│ B::::::BBBBBB:::::B │
│ BB:::::B B:::::B │
│ B::::B B:::::Byyyyyyy yyyyyyy eeeeeeeeeeee │
│ B::::B B:::::B y:::::y y:::::yee::::::::::::ee │
│ B::::BBBBBB:::::B y:::::y y:::::ye::::::eeeee:::::ee │
│ B:::::::::::::BB y:::::y y:::::ye::::::e e:::::e │
│ B::::BBBBBB:::::B y:::::y y:::::y e:::::::eeeee::::::e │
│ B::::B B:::::B y:::::y y:::::y e:::::::::::::::::e │
│ B::::B B:::::B y:::::y:::::y e::::::eeeeeeeeeee │
│ B::::B B:::::B y:::::::::y e:::::::e │
│ BB:::::BBBBBB::::::B y:::::::y e::::::::e │
│ B:::::::::::::::::B y:::::y e::::::::eeeeeeee │
│ B::::::::::::::::B y:::::y ee:::::::::::::e │
│ BBBBBBBBBBBBBBBBB y:::::y eeeeeeeeeeeeee │
│ y:::::y │
│ y:::::y │
│ y:::::y │
│ y:::::y │
│ yyyyyyy │
└────────────────────────────────────────────────────────────────┘
</ansi>
*/}}
Bye!
<ansi fg='white' bold='0'>
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡤⠒⠒⠢⢄⡀⠀⠀⢠⡏⠉⠉⠉⠑⠒⠤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡞⠀⠀⠀⠀⠀⠙⢦⠀⡇⡇⠀⠀⠀⠀⠀⠀⠈⠱⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠊⠉⠉⠙⠒⢤⡀⠀⣼⠀⠀⢀⣶⣤⠀⠀⠀⢣⡇⡇⠀⠀⢴⣶⣦⠀⠀⠀⢳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣠⠤⢄⠀⠀⢰⡇⠀⠀⣠⣀⠀⠀⠈⢦⡿⡀⠀⠈⡟⣟⡇⠀⠀⢸⡇⡆⠀⠀⡼⢻⣠⠀⠀⠀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⢀⠖⠉⠀⠀⠀⣱⡀⡞⡇⠀⠀⣿⣿⢣⠀⠀⠈⣧⣣⠀⠀⠉⠋⠀⠀⠀⣸⡇⠇⠀⠀⠈⠉⠀⠀⠀⢀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣠⠏⠀⠀⣴⢴⣿⣿⠗⢷⡹⡀⠀⠘⠾⠾⠀⠀⠀⣿⣿⣧⡀⠀⠀⠀⢀⣴⠇⣇⣆⣀⢀⣀⣀⣀⣀⣤⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⠀⠀⢸⢻⡞⠋⠀⠀⠀⢿⣷⣄⠀⠀⠀⠀⠀⣠⡇⠙⢿⣽⣷⣶⣶⣿⠋⢰⣿⣿⣿⣿⣿⣿⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡿⡄⠀⠈⢻⣝⣶⣶⠀⠀⠀⣿⣿⣱⣶⣶⣶⣾⡟⠀⠀⠀⢈⡉⠉⢩⡖⠒⠈⠉⡏⡴⡏⠉⠉⠉⠉⠉⠉⠉⠉⡇⠀⠀⢀⣴⠒⠢⠤⣀
⢣⣸⣆⡀⠀⠈⠉⠁⠀⠀⣠⣷⠈⠙⠛⠛⠛⠉⢀⣴⡊⠉⠁⠈⢢⣿⠀⠀⠀⢸⠡⠀⠁⠀⠀⠀⣠⣀⣀⣀⣀⡇⠀⢰⢁⡇⠀⠀⠀⢠
⠀⠻⣿⣟⢦⣤⡤⣤⣴⣾⡿⢃⡠⠔⠒⠉⠛⠢⣾⢿⣿⣦⡀⠀⠀⠉⠀⠀⢀⡇⢸⠀⠀⠀⠀⠀⠿⠿⠿⣿⡟⠀⢀⠇⢸⠀⠀⠀⠀⠘
⠀⠀⠈⠙⠛⠿⠿⠿⠛⠋⢰⡋⠀⠀⢠⣤⡄⠀⠈⡆⠙⢿⣿⣦⣀⠀⠀⠀⣜⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⢀⠃⠀⡸⠀⠇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢣⠀⠀⠈⠛⠁⠀⢴⠥⡀⠀⠙⢿⡿⡆⠀⠀⢸⠀⢸⢰⠀⠀⠀⢀⣿⣶⣶⡾⠀⢀⠇⣸⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡀⢇⠀⠀⠀⢀⡀⠀⠀⠈⢢⠀⠀⢃⢱⠀⠀⠀⡇⢸⢸⠀⠀⠀⠈⠉⠉⠉⢱⠀⠼⣾⣿⣿⣷⣦⠴⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢱⠘⡄⠀⠀⢹⣿⡇⠀⠀⠈⡆⠀⢸⠈⡇⢀⣀⣵⢨⣸⣦⣤⣤⣄⣀⣀⣀⡞⠀⣠⡞⠉⠈⠉⢣⡀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢃⠘⡄⠀⠀⠉⠀⠀⣠⣾⠁⠀⠀⣧⣿⣿⡿⠃⠸⠿⣿⣿⣿⣿⣿⣿⠟⠁⣼⣾⠀⠀⠀⠀⢠⠇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡄⠹⣀⣀⣤⣶⣿⡿⠃⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠀⠀⢻⣿⣷⣦⣤⣤⠎⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣤⣿⡿⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠀⠀⠀⠀⠀
</ansi>
48 changes: 19 additions & 29 deletions _datafiles/world/empty/templates/goodbye.template
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
{{/*

<ansi fg='black' bold='0'>
┌────────────────────────────────────────────────────────────────┐
│ BBBBBBBBBBBBBBBBB │
│ B::::::::::::::::B │
│ B::::::BBBBBB:::::B │
│ BB:::::B B:::::B │
│ B::::B B:::::Byyyyyyy yyyyyyy eeeeeeeeeeee │
│ B::::B B:::::B y:::::y y:::::yee::::::::::::ee │
│ B::::BBBBBB:::::B y:::::y y:::::ye::::::eeeee:::::ee │
│ B:::::::::::::BB y:::::y y:::::ye::::::e e:::::e │
│ B::::BBBBBB:::::B y:::::y y:::::y e:::::::eeeee::::::e │
│ B::::B B:::::B y:::::y y:::::y e:::::::::::::::::e │
│ B::::B B:::::B y:::::y:::::y e::::::eeeeeeeeeee │
│ B::::B B:::::B y:::::::::y e:::::::e │
│ BB:::::BBBBBB::::::B y:::::::y e::::::::e │
│ B:::::::::::::::::B y:::::y e::::::::eeeeeeee │
│ B::::::::::::::::B y:::::y ee:::::::::::::e │
│ BBBBBBBBBBBBBBBBB y:::::y eeeeeeeeeeeeee │
│ y:::::y │
│ y:::::y │
│ y:::::y │
│ y:::::y │
│ yyyyyyy │
└────────────────────────────────────────────────────────────────┘
</ansi>
*/}}
Bye!
<ansi fg='white' bold='0'>
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡤⠒⠒⠢⢄⡀⠀⠀⢠⡏⠉⠉⠉⠑⠒⠤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡞⠀⠀⠀⠀⠀⠙⢦⠀⡇⡇⠀⠀⠀⠀⠀⠀⠈⠱⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⠊⠉⠉⠙⠒⢤⡀⠀⣼⠀⠀⢀⣶⣤⠀⠀⠀⢣⡇⡇⠀⠀⢴⣶⣦⠀⠀⠀⢳⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⢀⣠⠤⢄⠀⠀⢰⡇⠀⠀⣠⣀⠀⠀⠈⢦⡿⡀⠀⠈⡟⣟⡇⠀⠀⢸⡇⡆⠀⠀⡼⢻⣠⠀⠀⠀⣸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⢀⠖⠉⠀⠀⠀⣱⡀⡞⡇⠀⠀⣿⣿⢣⠀⠀⠈⣧⣣⠀⠀⠉⠋⠀⠀⠀⣸⡇⠇⠀⠀⠈⠉⠀⠀⠀⢀⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣠⠏⠀⠀⣴⢴⣿⣿⠗⢷⡹⡀⠀⠘⠾⠾⠀⠀⠀⣿⣿⣧⡀⠀⠀⠀⢀⣴⠇⣇⣆⣀⢀⣀⣀⣀⣀⣤⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⠀⠀⢸⢻⡞⠋⠀⠀⠀⢿⣷⣄⠀⠀⠀⠀⠀⣠⡇⠙⢿⣽⣷⣶⣶⣿⠋⢰⣿⣿⣿⣿⣿⣿⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⡿⡄⠀⠈⢻⣝⣶⣶⠀⠀⠀⣿⣿⣱⣶⣶⣶⣾⡟⠀⠀⠀⢈⡉⠉⢩⡖⠒⠈⠉⡏⡴⡏⠉⠉⠉⠉⠉⠉⠉⠉⡇⠀⠀⢀⣴⠒⠢⠤⣀
⢣⣸⣆⡀⠀⠈⠉⠁⠀⠀⣠⣷⠈⠙⠛⠛⠛⠉⢀⣴⡊⠉⠁⠈⢢⣿⠀⠀⠀⢸⠡⠀⠁⠀⠀⠀⣠⣀⣀⣀⣀⡇⠀⢰⢁⡇⠀⠀⠀⢠
⠀⠻⣿⣟⢦⣤⡤⣤⣴⣾⡿⢃⡠⠔⠒⠉⠛⠢⣾⢿⣿⣦⡀⠀⠀⠉⠀⠀⢀⡇⢸⠀⠀⠀⠀⠀⠿⠿⠿⣿⡟⠀⢀⠇⢸⠀⠀⠀⠀⠘
⠀⠀⠈⠙⠛⠿⠿⠿⠛⠋⢰⡋⠀⠀⢠⣤⡄⠀⠈⡆⠙⢿⣿⣦⣀⠀⠀⠀⣜⠀⢸⠀⠀⠀⠀⠀⠀⠀⠀⢀⠃⠀⡸⠀⠇⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇⢣⠀⠀⠈⠛⠁⠀⢴⠥⡀⠀⠙⢿⡿⡆⠀⠀⢸⠀⢸⢰⠀⠀⠀⢀⣿⣶⣶⡾⠀⢀⠇⣸⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠹⡀⢇⠀⠀⠀⢀⡀⠀⠀⠈⢢⠀⠀⢃⢱⠀⠀⠀⡇⢸⢸⠀⠀⠀⠈⠉⠉⠉⢱⠀⠼⣾⣿⣿⣷⣦⠴⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢱⠘⡄⠀⠀⢹⣿⡇⠀⠀⠈⡆⠀⢸⠈⡇⢀⣀⣵⢨⣸⣦⣤⣤⣄⣀⣀⣀⡞⠀⣠⡞⠉⠈⠉⢣⡀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢃⠘⡄⠀⠀⠉⠀⠀⣠⣾⠁⠀⠀⣧⣿⣿⡿⠃⠸⠿⣿⣿⣿⣿⣿⣿⠟⠁⣼⣾⠀⠀⠀⠀⢠⠇⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⡄⠹⣀⣀⣤⣶⣿⡿⠃⠀⠀⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠁⠀⠀⢻⣿⣷⣦⣤⣤⠎⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣤⣿⡿⠟⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠀⠀⠀⠀⠀
</ansi>
14 changes: 6 additions & 8 deletions internal/configs/configs.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,8 @@ func (c Config) AllConfigData(excludeStrings ...string) map[string]any {
continue
}

mapName := name

if _, ok := lockedLoookup[strings.ToLower(name)]; ok {
mapName = fmt.Sprintf(`%s (locked)`, name)
}

if len(excludeStrings) > 0 {
testName := strings.ToLower(mapName)
testName := strings.ToLower(name)
skip := false
for _, s := range excludeStrings {
if util.StringWildcardMatch(testName, s) {
Expand All @@ -254,6 +248,10 @@ func (c Config) AllConfigData(excludeStrings ...string) map[string]any {
}
}

if _, ok := lockedLoookup[strings.ToLower(name)]; ok {
name = fmt.Sprintf(`%s (locked)`, name)
}

itm := items.Field(i)
if itm.Type().Kind() == reflect.Slice {

Expand Down Expand Up @@ -284,7 +282,7 @@ func (c Config) AllConfigData(excludeStrings ...string) map[string]any {
}

} else {
output[mapName] = itm.Interface()
output[name] = itm.Interface()
}

}
Expand Down
10 changes: 8 additions & 2 deletions internal/events/eventtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,20 @@ func (s ScriptedEvent) Type() string { return `ScriptedEvent` }

// Entered the world
type PlayerSpawn struct {
UserId int
UserId int
RoomId int
Username string
CharacterName string
}

func (p PlayerSpawn) Type() string { return `PlayerSpawn` }

// Left the world
type PlayerDespawn struct {
UserId int
UserId int
RoomId int
Username string
CharacterName string
}

func (p PlayerDespawn) Type() string { return `PlayerDespawn` }
Expand Down
16 changes: 8 additions & 8 deletions internal/events/listeners.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ import (

type ListenerId uint64

type ListenerWrapper struct {
id ListenerId
listner Listener
}

// Return false to stop further handling of this event.
type Listener func(Event) bool

var (
listenerLock = sync.RWMutex{}
// listeners that want to handle an event first.
Expand Down Expand Up @@ -116,11 +124,3 @@ func DoListeners(e Event) bool {

return true
}

type ListenerWrapper struct {
id ListenerId
listner Listener
}

// Return false to stop further handling of this event.
type Listener func(Event) bool
7 changes: 6 additions & 1 deletion internal/hooks/PlayerDespawn_HandleLeave.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ func HandleLeave(e events.Event) bool {

evt, typeOk := e.(events.PlayerDespawn)
if !typeOk {
mudlog.Error("Event", "Expected Type", "DeSpawned", "Actual Type", e.Type())
mudlog.Error("Event", "Expected Type", "PlayerDespawn", "Actual Type", e.Type())
return false
}

user := users.GetByUserId(evt.UserId)
if user == nil {
mudlog.Error("HandleLeave", "error", fmt.Sprintf(`user %d not found`, evt.UserId))
return false
}

Expand Down Expand Up @@ -77,9 +78,13 @@ func HandleLeave(e events.Event) bool {
}
}

tplTxt, _ := templates.Process("goodbye", nil, templates.AnsiTagsPreParse)
connections.SendTo([]byte(tplTxt), connId)

if err := users.LogOutUserByConnectionId(connId); err != nil {
mudlog.Error("Log Out Error", "connectionId", connId, "error", err)
}
connections.Remove(connId)

return true
}
4 changes: 2 additions & 2 deletions internal/hooks/PlayerSpawn_HandleJoin.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ func HandleJoin(e events.Event) bool {

evt, typeOk := e.(events.PlayerSpawn)
if !typeOk {
mudlog.Error("Event", "Expected Type", "Spawned", "Actual Type", e.Type())
mudlog.Error("Event", "Expected Type", "PlayerSpawn", "Actual Type", e.Type())
return false
}

user := users.GetByUserId(evt.UserId)
if user == nil {
mudlog.Error("EnterWorld", "error", fmt.Sprintf(`user %d not found`, user.Character.RoomId))
mudlog.Error("HandleJoin", "error", fmt.Sprintf(`user %d not found`, evt.UserId))
return false
}

Expand Down
9 changes: 7 additions & 2 deletions internal/usercommands/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,15 @@ func Start(rest string, user *users.UserRecord, room *rooms.Room, flags events.E

if user.Character.RaceId == 0 {

raceOptions := []races.Race{}
raceOptions := []templates.NameDescription{}

for _, r := range races.GetRaces() {
if r.Selectable {
raceOptions = append(raceOptions, r)
raceOptions = append(raceOptions, templates.NameDescription{
Id: r.RaceId,
Name: r.Name,
Description: r.Description,
})
}
}
sort.SliceStable(raceOptions, func(i, j int) bool {
Expand Down
32 changes: 24 additions & 8 deletions world.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ func NewWorld(osSignalChan chan os.Signal) *World {
// Send input to the world.
// Just sends via a channel. Will block until read.
func (w *World) SendInput(i WorldInput) {
/*
if _, ok := w.ignoreInput[i.FromId]; ok {
return // discard
}
*/
w.worldInput <- i
}

Expand Down Expand Up @@ -106,7 +101,14 @@ func (w *World) logOutUserByConnectionId(connectionId connections.ConnectionId)

func (w *World) enterWorld(userId int, roomId int) {

events.AddToQueue(events.PlayerSpawn{UserId: userId})
if userInfo := users.GetByUserId(userId); userInfo != nil {
events.AddToQueue(events.PlayerSpawn{
UserId: userInfo.UserId,
RoomId: userInfo.Character.RoomId,
Username: userInfo.Username,
CharacterName: userInfo.Character.Name,
})
}

w.UpdateStats()

Expand Down Expand Up @@ -647,7 +649,14 @@ loop:
case leaveWorldUserId := <-w.leaveWorldUserId: // int

util.LockMud()
events.AddToQueue(events.PlayerDespawn{UserId: leaveWorldUserId})
if userInfo := users.GetByUserId(leaveWorldUserId); userInfo != nil {
events.AddToQueue(events.PlayerDespawn{
UserId: userInfo.UserId,
RoomId: userInfo.Character.RoomId,
Username: userInfo.Username,
CharacterName: userInfo.Character.Name,
})
}
util.UnlockMud()

case logoutConnectionId := <-w.logoutConnectionId: // connections.ConnectionId
Expand Down Expand Up @@ -1048,7 +1057,14 @@ func (w *World) EventLoop() {
w.Kick(sys.Data.(int))
} else if sys.Command == `leaveworld` {

events.AddToQueue(events.PlayerDespawn{UserId: sys.Data.(int)})
if userInfo := users.GetByUserId(sys.Data.(int)); userInfo != nil {
events.AddToQueue(events.PlayerDespawn{
UserId: userInfo.UserId,
RoomId: userInfo.Character.RoomId,
Username: userInfo.Username,
CharacterName: userInfo.Character.Name,
})
}

} else if sys.Command == `logoff` {
w.logOff(sys.Data.(int))
Expand Down
22 changes: 6 additions & 16 deletions world.roundtick.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ package main
import (
"fmt"

"github.com/volte6/gomud/internal/connections"
"github.com/volte6/gomud/internal/events"
"github.com/volte6/gomud/internal/mudlog"
"github.com/volte6/gomud/internal/rooms"
"github.com/volte6/gomud/internal/templates"
"github.com/volte6/gomud/internal/users"
)

Expand All @@ -19,19 +16,12 @@ func (w *World) logOff(userId int) {

users.SaveUser(*user)

events.AddToQueue(events.PlayerDespawn{UserId: userId})

connId := user.ConnectionId()

tplTxt, _ := templates.Process("goodbye", nil, templates.AnsiTagsPreParse)

connections.SendTo([]byte(tplTxt), connId)

if err := users.LogOutUserByConnectionId(connId); err != nil {
mudlog.Error("Log Out Error", "connectionId", connId, "error", err)
}

connections.Remove(connId)
events.AddToQueue(events.PlayerDespawn{
UserId: user.UserId,
RoomId: user.Character.RoomId,
Username: user.Username,
CharacterName: user.Character.Name,
})

}

Expand Down
Loading