mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-30 04:22:31 +02:00
fix(lint): automated linting, with simple formatter.
This commit is contained in:
@@ -12,11 +12,11 @@ type ChatType uint8
|
|||||||
// Chat types
|
// Chat types
|
||||||
const (
|
const (
|
||||||
ChatTypeWorld ChatType = 0
|
ChatTypeWorld ChatType = 0
|
||||||
ChatTypeStage = 1
|
ChatTypeStage ChatType = 1
|
||||||
ChatTypeGuild = 2
|
ChatTypeGuild ChatType = 2
|
||||||
ChatTypeAlliance = 3
|
ChatTypeAlliance ChatType = 3
|
||||||
ChatTypeParty = 4
|
ChatTypeParty ChatType = 4
|
||||||
ChatTypeWhisper = 5
|
ChatTypeWhisper ChatType = 5
|
||||||
)
|
)
|
||||||
|
|
||||||
// MsgBinChat is a binpacket for chat messages.
|
// MsgBinChat is a binpacket for chat messages.
|
||||||
|
|||||||
@@ -179,9 +179,7 @@ func handleMsgSysLogout(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
|
|
||||||
func logoutPlayer(s *Session) {
|
func logoutPlayer(s *Session) {
|
||||||
s.server.Lock()
|
s.server.Lock()
|
||||||
if _, exists := s.server.sessions[s.rawConn]; exists {
|
delete(s.server.sessions, s.rawConn)
|
||||||
delete(s.server.sessions, s.rawConn)
|
|
||||||
}
|
|
||||||
s.rawConn.Close()
|
s.rawConn.Close()
|
||||||
delete(s.server.objectIDs, s)
|
delete(s.server.objectIDs, s)
|
||||||
s.server.Unlock()
|
s.server.Unlock()
|
||||||
@@ -244,9 +242,7 @@ func logoutPlayer(s *Session) {
|
|||||||
|
|
||||||
s.server.Lock()
|
s.server.Lock()
|
||||||
for _, stage := range s.server.stages {
|
for _, stage := range s.server.stages {
|
||||||
if _, exists := stage.reservedClientSlots[s.charID]; exists {
|
delete(stage.reservedClientSlots, s.charID)
|
||||||
delete(stage.reservedClientSlots, s.charID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
s.server.Unlock()
|
s.server.Unlock()
|
||||||
|
|
||||||
@@ -366,10 +362,7 @@ func handleMsgSysRightsReload(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
func handleMsgMhfTransitMessage(s *Session, p mhfpacket.MHFPacket) {
|
||||||
pkt := p.(*mhfpacket.MsgMhfTransitMessage)
|
pkt := p.(*mhfpacket.MsgMhfTransitMessage)
|
||||||
|
|
||||||
local := false
|
local := strings.Split(s.rawConn.RemoteAddr().String(), ":")[0] == "127.0.0.1"
|
||||||
if strings.Split(s.rawConn.RemoteAddr().String(), ":")[0] == "127.0.0.1" {
|
|
||||||
local = true
|
|
||||||
}
|
|
||||||
|
|
||||||
var maxResults, port, count uint16
|
var maxResults, port, count uint16
|
||||||
var cid uint32
|
var cid uint32
|
||||||
|
|||||||
@@ -243,9 +243,10 @@ func parseChatCommand(s *Session, command string) {
|
|||||||
sendServerChatMessage(s, s.server.i18n.commands.kqf.version)
|
sendServerChatMessage(s, s.server.i18n.commands.kqf.version)
|
||||||
} else {
|
} else {
|
||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
if args[1] == "get" {
|
switch args[1] {
|
||||||
|
case "get":
|
||||||
sendServerChatMessage(s, fmt.Sprintf(s.server.i18n.commands.kqf.get, s.kqf))
|
sendServerChatMessage(s, fmt.Sprintf(s.server.i18n.commands.kqf.get, s.kqf))
|
||||||
} else if args[1] == "set" {
|
case "set":
|
||||||
if len(args) > 2 && len(args[2]) == 16 {
|
if len(args) > 2 && len(args[2]) == 16 {
|
||||||
hexd, _ := hex.DecodeString(args[2])
|
hexd, _ := hex.DecodeString(args[2])
|
||||||
s.kqf = hexd
|
s.kqf = hexd
|
||||||
@@ -281,13 +282,13 @@ func parseChatCommand(s *Session, command string) {
|
|||||||
if len(args) > 1 {
|
if len(args) > 1 {
|
||||||
for _, course := range mhfcourse.Courses() {
|
for _, course := range mhfcourse.Courses() {
|
||||||
for _, alias := range course.Aliases() {
|
for _, alias := range course.Aliases() {
|
||||||
if strings.ToLower(args[1]) == strings.ToLower(alias) {
|
if strings.EqualFold(args[1], alias) {
|
||||||
if slices.Contains(s.server.erupeConfig.Courses, _config.Course{Name: course.Aliases()[0], Enabled: true}) {
|
if slices.Contains(s.server.erupeConfig.Courses, _config.Course{Name: course.Aliases()[0], Enabled: true}) {
|
||||||
var delta, rightsInt uint32
|
var delta, rightsInt uint32
|
||||||
if mhfcourse.CourseExists(course.ID, s.courses) {
|
if mhfcourse.CourseExists(course.ID, s.courses) {
|
||||||
ei := slices.IndexFunc(s.courses, func(c mhfcourse.Course) bool {
|
ei := slices.IndexFunc(s.courses, func(c mhfcourse.Course) bool {
|
||||||
for _, alias := range c.Aliases() {
|
for _, alias := range c.Aliases() {
|
||||||
if strings.ToLower(args[1]) == strings.ToLower(alias) {
|
if strings.EqualFold(args[1], alias) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -409,7 +410,7 @@ func parseChatCommand(s *Session, command string) {
|
|||||||
}
|
}
|
||||||
case commands["Playtime"].Prefix:
|
case commands["Playtime"].Prefix:
|
||||||
if commands["Playtime"].Enabled || s.isOp() {
|
if commands["Playtime"].Enabled || s.isOp() {
|
||||||
playtime := s.playtime + uint32(time.Now().Sub(s.playtimeTime).Seconds())
|
playtime := s.playtime + uint32(time.Since(s.playtimeTime).Seconds())
|
||||||
sendServerChatMessage(s, fmt.Sprintf(s.server.i18n.commands.playtime, playtime/60/60, playtime/60%60, playtime%60))
|
sendServerChatMessage(s, fmt.Sprintf(s.server.i18n.commands.playtime, playtime/60/60, playtime/60%60, playtime%60))
|
||||||
} else {
|
} else {
|
||||||
sendDisabledCommandMessage(s, commands["Playtime"])
|
sendDisabledCommandMessage(s, commands["Playtime"])
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func handleMsgMhfSavedata(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.playtimeTime = time.Now()
|
s.playtimeTime = time.Now()
|
||||||
|
|
||||||
// Bypass name-checker if new
|
// Bypass name-checker if new
|
||||||
if characterSaveData.IsNewCharacter == true {
|
if characterSaveData.IsNewCharacter {
|
||||||
s.Name = characterSaveData.Name
|
s.Name = characterSaveData.Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ func (guild *Guild) Save(s *Session) error {
|
|||||||
UPDATE guilds SET main_motto=$2, sub_motto=$3, comment=$4, pugi_name_1=$5, pugi_name_2=$6, pugi_name_3=$7,
|
UPDATE guilds SET main_motto=$2, sub_motto=$3, comment=$4, pugi_name_1=$5, pugi_name_2=$6, pugi_name_3=$7,
|
||||||
pugi_outfit_1=$8, pugi_outfit_2=$9, pugi_outfit_3=$10, pugi_outfits=$11, icon=$12, leader_id=$13 WHERE id=$1
|
pugi_outfit_1=$8, pugi_outfit_2=$9, pugi_outfit_3=$10, pugi_outfits=$11, icon=$12, leader_id=$13 WHERE id=$1
|
||||||
`, guild.ID, guild.MainMotto, guild.SubMotto, guild.Comment, guild.PugiName1, guild.PugiName2, guild.PugiName3,
|
`, guild.ID, guild.MainMotto, guild.SubMotto, guild.Comment, guild.PugiName1, guild.PugiName2, guild.PugiName3,
|
||||||
guild.PugiOutfit1, guild.PugiOutfit2, guild.PugiOutfit3, guild.PugiOutfits, guild.Icon, guild.GuildLeader.LeaderCharID)
|
guild.PugiOutfit1, guild.PugiOutfit2, guild.PugiOutfit3, guild.PugiOutfits, guild.Icon, guild.LeaderCharID)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.logger.Error("failed to update guild data", zap.Error(err), zap.Uint32("guildID", guild.ID))
|
s.logger.Error("failed to update guild data", zap.Error(err), zap.Uint32("guildID", guild.ID))
|
||||||
|
|||||||
@@ -50,20 +50,20 @@ func TestGuildCreation(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
guild := &Guild{
|
guild := &Guild{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
Name: tt.guildName,
|
Name: tt.guildName,
|
||||||
MainMotto: tt.motto,
|
MainMotto: tt.motto,
|
||||||
SubMotto: 1,
|
SubMotto: 1,
|
||||||
CreatedAt: time.Now(),
|
CreatedAt: time.Now(),
|
||||||
MemberCount: 1,
|
MemberCount: 1,
|
||||||
RankRP: 0,
|
RankRP: 0,
|
||||||
EventRP: 0,
|
EventRP: 0,
|
||||||
RoomRP: 0,
|
RoomRP: 0,
|
||||||
Comment: "Test guild",
|
Comment: "Test guild",
|
||||||
Recruiting: true,
|
Recruiting: true,
|
||||||
FestivalColor: FestivalColorNone,
|
FestivalColor: FestivalColorNone,
|
||||||
Souls: 0,
|
Souls: 0,
|
||||||
AllianceID: 0,
|
AllianceID: 0,
|
||||||
GuildLeader: GuildLeader{
|
GuildLeader: GuildLeader{
|
||||||
LeaderCharID: tt.leaderId,
|
LeaderCharID: tt.leaderId,
|
||||||
LeaderName: "TestLeader",
|
LeaderName: "TestLeader",
|
||||||
@@ -74,8 +74,8 @@ func TestGuildCreation(t *testing.T) {
|
|||||||
t.Errorf("guild name validity check failed for '%s'", guild.Name)
|
t.Errorf("guild name validity check failed for '%s'", guild.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
if guild.GuildLeader.LeaderCharID != tt.leaderId {
|
if guild.LeaderCharID != tt.leaderId {
|
||||||
t.Errorf("guild leader ID mismatch: got %d, want %d", guild.GuildLeader.LeaderCharID, tt.leaderId)
|
t.Errorf("guild leader ID mismatch: got %d, want %d", guild.LeaderCharID, tt.leaderId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -290,12 +290,12 @@ func TestGuildLeaderAssignment(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if guild.GuildLeader.LeaderCharID != tt.leaderId {
|
if guild.LeaderCharID != tt.leaderId {
|
||||||
t.Errorf("leader ID mismatch: got %d, want %d", guild.GuildLeader.LeaderCharID, tt.leaderId)
|
t.Errorf("leader ID mismatch: got %d, want %d", guild.LeaderCharID, tt.leaderId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if guild.GuildLeader.LeaderName != tt.leaderName {
|
if guild.LeaderName != tt.leaderName {
|
||||||
t.Errorf("leader name mismatch: got %s, want %s", guild.GuildLeader.LeaderName, tt.leaderName)
|
t.Errorf("leader name mismatch: got %s, want %s", guild.LeaderName, tt.leaderName)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ func TestGuildApplicationTypes(t *testing.T) {
|
|||||||
// TestGuildApplicationCreation tests guild application creation
|
// TestGuildApplicationCreation tests guild application creation
|
||||||
func TestGuildApplicationCreation(t *testing.T) {
|
func TestGuildApplicationCreation(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
guildId uint32
|
guildId uint32
|
||||||
charId uint32
|
charId uint32
|
||||||
valid bool
|
valid bool
|
||||||
@@ -481,11 +481,11 @@ func TestGuildMemberCount(t *testing.T) {
|
|||||||
// TestGuildRP tests guild RP (rank points and event points)
|
// TestGuildRP tests guild RP (rank points and event points)
|
||||||
func TestGuildRP(t *testing.T) {
|
func TestGuildRP(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
rankRP uint32
|
rankRP uint32
|
||||||
eventRP uint32
|
eventRP uint32
|
||||||
roomRP uint16
|
roomRP uint16
|
||||||
valid bool
|
valid bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "minimal_rp",
|
name: "minimal_rp",
|
||||||
@@ -580,10 +580,10 @@ func TestGuildCommentHandling(t *testing.T) {
|
|||||||
// TestGuildMottoSelection tests guild motto (main and sub mottos)
|
// TestGuildMottoSelection tests guild motto (main and sub mottos)
|
||||||
func TestGuildMottoSelection(t *testing.T) {
|
func TestGuildMottoSelection(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
mainMot uint8
|
mainMot uint8
|
||||||
subMot uint8
|
subMot uint8
|
||||||
valid bool
|
valid bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "motto_pair_0_0",
|
name: "motto_pair_0_0",
|
||||||
@@ -691,38 +691,38 @@ func TestGuildSoulTracking(t *testing.T) {
|
|||||||
// TestGuildPugiData tests guild pug i (treasure chest) names and outfits
|
// TestGuildPugiData tests guild pug i (treasure chest) names and outfits
|
||||||
func TestGuildPugiData(t *testing.T) {
|
func TestGuildPugiData(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
pugiNames [3]string
|
pugiNames [3]string
|
||||||
pugiOutfits [3]uint8
|
pugiOutfits [3]uint8
|
||||||
valid bool
|
valid bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "empty_pugi_data",
|
name: "empty_pugi_data",
|
||||||
pugiNames: [3]string{"", "", ""},
|
pugiNames: [3]string{"", "", ""},
|
||||||
pugiOutfits: [3]uint8{0, 0, 0},
|
pugiOutfits: [3]uint8{0, 0, 0},
|
||||||
valid: true,
|
valid: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "all_pugi_filled",
|
name: "all_pugi_filled",
|
||||||
pugiNames: [3]string{"Chest1", "Chest2", "Chest3"},
|
pugiNames: [3]string{"Chest1", "Chest2", "Chest3"},
|
||||||
pugiOutfits: [3]uint8{1, 2, 3},
|
pugiOutfits: [3]uint8{1, 2, 3},
|
||||||
valid: true,
|
valid: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "mixed_pugi_data",
|
name: "mixed_pugi_data",
|
||||||
pugiNames: [3]string{"MainChest", "", "AltChest"},
|
pugiNames: [3]string{"MainChest", "", "AltChest"},
|
||||||
pugiOutfits: [3]uint8{5, 0, 10},
|
pugiOutfits: [3]uint8{5, 0, 10},
|
||||||
valid: true,
|
valid: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
guild := &Guild{
|
guild := &Guild{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
PugiName1: tt.pugiNames[0],
|
PugiName1: tt.pugiNames[0],
|
||||||
PugiName2: tt.pugiNames[1],
|
PugiName2: tt.pugiNames[1],
|
||||||
PugiName3: tt.pugiNames[2],
|
PugiName3: tt.pugiNames[2],
|
||||||
PugiOutfit1: tt.pugiOutfits[0],
|
PugiOutfit1: tt.pugiOutfits[0],
|
||||||
PugiOutfit2: tt.pugiOutfits[1],
|
PugiOutfit2: tt.pugiOutfits[1],
|
||||||
PugiOutfit3: tt.pugiOutfits[2],
|
PugiOutfit3: tt.pugiOutfits[2],
|
||||||
@@ -766,7 +766,7 @@ func TestGuildRoomExpiry(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
guild := &Guild{
|
guild := &Guild{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
RoomExpiry: tt.expiry,
|
RoomExpiry: tt.expiry,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -777,7 +777,7 @@ func TestGuildRoomExpiry(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if guild.RoomExpiry == tt.expiry {
|
if guild.RoomExpiry.Equal(tt.expiry) {
|
||||||
// Success - times match
|
// Success - times match
|
||||||
} else if !tt.hasExpiry && guild.RoomExpiry.IsZero() {
|
} else if !tt.hasExpiry && guild.RoomExpiry.IsZero() {
|
||||||
// Success - both zero
|
// Success - both zero
|
||||||
@@ -789,23 +789,23 @@ func TestGuildRoomExpiry(t *testing.T) {
|
|||||||
// TestGuildAllianceRelationship tests guild alliance ID tracking
|
// TestGuildAllianceRelationship tests guild alliance ID tracking
|
||||||
func TestGuildAllianceRelationship(t *testing.T) {
|
func TestGuildAllianceRelationship(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
allianceId uint32
|
allianceId uint32
|
||||||
hasAlliance bool
|
hasAlliance bool
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "no_alliance",
|
name: "no_alliance",
|
||||||
allianceId: 0,
|
allianceId: 0,
|
||||||
hasAlliance: false,
|
hasAlliance: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "single_alliance",
|
name: "single_alliance",
|
||||||
allianceId: 1,
|
allianceId: 1,
|
||||||
hasAlliance: true,
|
hasAlliance: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "large_alliance_id",
|
name: "large_alliance_id",
|
||||||
allianceId: 999999,
|
allianceId: 999999,
|
||||||
hasAlliance: true,
|
hasAlliance: true,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -813,7 +813,7 @@ func TestGuildAllianceRelationship(t *testing.T) {
|
|||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
guild := &Guild{
|
guild := &Guild{
|
||||||
ID: 1,
|
ID: 1,
|
||||||
AllianceID: tt.allianceId,
|
AllianceID: tt.allianceId,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ func makeEventQuest(s *Session, rows *sql.Rows) ([]byte, error) {
|
|||||||
|
|
||||||
data := loadQuestFile(s, questId)
|
data := loadQuestFile(s, questId)
|
||||||
if data == nil {
|
if data == nil {
|
||||||
return nil, fmt.Errorf(fmt.Sprintf("failed to load quest file (%d)", questId))
|
return nil, fmt.Errorf("failed to load quest file (%d)", questId)
|
||||||
}
|
}
|
||||||
|
|
||||||
bf := byteframe.NewByteFrame()
|
bf := byteframe.NewByteFrame()
|
||||||
|
|||||||
@@ -12,9 +12,7 @@ import (
|
|||||||
func removeSessionFromSemaphore(s *Session) {
|
func removeSessionFromSemaphore(s *Session) {
|
||||||
s.server.semaphoreLock.Lock()
|
s.server.semaphoreLock.Lock()
|
||||||
for _, semaphore := range s.server.semaphore {
|
for _, semaphore := range s.server.semaphore {
|
||||||
if _, exists := semaphore.clients[s]; exists {
|
delete(semaphore.clients, s)
|
||||||
delete(semaphore.clients, s)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
s.server.semaphoreLock.Unlock()
|
s.server.semaphoreLock.Unlock()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,10 +392,8 @@ func getRandomEntries(entries []GachaEntry, rolls int, isBox bool) ([]GachaEntry
|
|||||||
for i := range entries {
|
for i := range entries {
|
||||||
totalWeight += entries[i].Weight
|
totalWeight += entries[i].Weight
|
||||||
}
|
}
|
||||||
for {
|
for rolls != len(chosen) {
|
||||||
if rolls == len(chosen) {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if !isBox {
|
if !isBox {
|
||||||
result := rand.Float64() * totalWeight
|
result := rand.Float64() * totalWeight
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
|
|||||||
@@ -195,13 +195,9 @@ func handleMsgSysBackStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, exists := s.stage.reservedClientSlots[s.charID]; exists {
|
delete(s.stage.reservedClientSlots, s.charID)
|
||||||
delete(s.stage.reservedClientSlots, s.charID)
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, exists := s.server.stages[backStage].reservedClientSlots[s.charID]; exists {
|
delete(s.server.stages[backStage].reservedClientSlots, s.charID)
|
||||||
delete(s.server.stages[backStage].reservedClientSlots, s.charID)
|
|
||||||
}
|
|
||||||
|
|
||||||
doStageTransfer(s, pkt.AckHandle, backStage)
|
doStageTransfer(s, pkt.AckHandle, backStage)
|
||||||
}
|
}
|
||||||
@@ -293,9 +289,7 @@ func handleMsgSysUnreserveStage(s *Session, p mhfpacket.MHFPacket) {
|
|||||||
s.Unlock()
|
s.Unlock()
|
||||||
if stage != nil {
|
if stage != nil {
|
||||||
stage.Lock()
|
stage.Lock()
|
||||||
if _, exists := stage.reservedClientSlots[s.charID]; exists {
|
delete(stage.reservedClientSlots, s.charID)
|
||||||
delete(stage.reservedClientSlots, s.charID)
|
|
||||||
}
|
|
||||||
stage.Unlock()
|
stage.Unlock()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -281,12 +281,10 @@ func (s *Server) manageSessions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) invalidateSessions() {
|
func (s *Server) invalidateSessions() {
|
||||||
for {
|
for !s.isShuttingDown {
|
||||||
if s.isShuttingDown {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
for _, sess := range s.sessions {
|
for _, sess := range s.sessions {
|
||||||
if time.Now().Sub(sess.lastPacket) > time.Second*time.Duration(30) {
|
if time.Since(sess.lastPacket) > time.Second*time.Duration(30) {
|
||||||
s.logger.Info("session timeout", zap.String("Name", sess.Name))
|
s.logger.Info("session timeout", zap.String("Name", sess.Name))
|
||||||
logoutPlayer(sess)
|
logoutPlayer(sess)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -115,10 +115,8 @@ func (s *Server) handleEntranceServerConnection(conn net.Conn) {
|
|||||||
fmt.Printf("[Client] -> [Server]\nData [%d bytes]:\n%s\n", len(pkt), hex.Dump(pkt))
|
fmt.Printf("[Client] -> [Server]\nData [%d bytes]:\n%s\n", len(pkt), hex.Dump(pkt))
|
||||||
}
|
}
|
||||||
|
|
||||||
local := false
|
local := strings.Split(conn.RemoteAddr().String(), ":")[0] == "127.0.0.1"
|
||||||
if strings.Split(conn.RemoteAddr().String(), ":")[0] == "127.0.0.1" {
|
|
||||||
local = true
|
|
||||||
}
|
|
||||||
data := makeSv2Resp(s.erupeConfig, s, local)
|
data := makeSv2Resp(s.erupeConfig, s, local)
|
||||||
if len(pkt) > 5 {
|
if len(pkt) > 5 {
|
||||||
data = append(data, makeUsrResp(pkt, s)...)
|
data = append(data, makeUsrResp(pkt, s)...)
|
||||||
|
|||||||
Reference in New Issue
Block a user