refactor(channelserver): extract CharacterRepository for characters table access

Centralizes all characters table SQL behind a CharacterRepository struct
in repo_character.go. The 4 existing helpers (loadCharacterData,
saveCharacterData, readCharacterInt, adjustCharacterInt) now delegate to
the repository, keeping identical signatures so all ~70 callsites remain
unchanged. Direct queries in handlers_session.go, sys_channel_server.go
(DisconnectUser), and handlers_mail.go are also migrated.

Pure refactor with zero behavior change — first step toward eliminating
the ~130 scattered character queries identified in anti-patterns #9.
This commit is contained in:
Houmgaor
2026-02-20 21:38:21 +01:00
parent a369a855bf
commit 197e44d04c
7 changed files with 320 additions and 31 deletions

View File

@@ -193,16 +193,11 @@ func SendMailNotification(s *Session, m *Mail, recipient *Session) {
}
func getCharacterName(s *Session, charID uint32) string {
row := s.server.db.QueryRow("SELECT name FROM characters WHERE id = $1", charID)
charName := ""
err := row.Scan(&charName)
name, err := s.server.charRepo.GetName(charID)
if err != nil {
return ""
}
return charName
return name
}
func handleMsgMhfReadMail(s *Session, p mhfpacket.MHFPacket) {