From 1aa2e360876516bb0e5ef73ea82bc648fe35b396 Mon Sep 17 00:00:00 2001 From: wish Date: Sun, 31 Dec 2023 16:30:11 +1100 Subject: [PATCH] simplify World name concatenation --- server/entranceserver/make_resp.go | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/server/entranceserver/make_resp.go b/server/entranceserver/make_resp.go index 481ccae93..164f63871 100644 --- a/server/entranceserver/make_resp.go +++ b/server/entranceserver/make_resp.go @@ -47,20 +47,15 @@ func encodeServerInfo(config *_config.Config, s *Server, local bool) []byte { bf.WriteUint8(si.Recommended) } - if s.erupeConfig.RealClientMode <= _config.F5 { - combined := append(stringsupport.UTF8ToSJIS(si.Name), []byte{0x00}...) - combined = append(combined, stringsupport.UTF8ToSJIS(si.Description)...) - bf.WriteBytes(stringsupport.PaddedString(string(combined), 65, false)) - } else if s.erupeConfig.RealClientMode <= _config.G5 { - combined := append(stringsupport.UTF8ToSJIS(si.Name), []byte{0x00}...) - combined = append(combined, stringsupport.UTF8ToSJIS(si.Description)...) - bf.WriteUint8(uint8(len(combined))) - bf.WriteBytes(combined) + fullName := append(append(stringsupport.UTF8ToSJIS(si.Name), []byte{0x00}...), stringsupport.UTF8ToSJIS(si.Description)...) + if s.erupeConfig.RealClientMode >= _config.G1 && s.erupeConfig.RealClientMode <= _config.G5 { + bf.WriteUint8(uint8(len(fullName))) + bf.WriteBytes(fullName) } else { - bf.WriteUint8(0) // Ignored - combined := append(stringsupport.UTF8ToSJIS(si.Name), []byte{0x00}...) - combined = append(combined, stringsupport.UTF8ToSJIS(si.Description)...) - bf.WriteBytes(stringsupport.PaddedString(string(combined), 65, false)) + if s.erupeConfig.RealClientMode >= _config.G51 { + bf.WriteUint8(0) // Ignored + } + bf.WriteBytes(stringsupport.PaddedString(string(fullName), 65, false)) } if s.erupeConfig.RealClientMode >= _config.GG {