refactored gametime and utils folder which decouples entrance and sign from channel servers

This commit is contained in:
stratic-dev
2024-10-09 08:34:13 +01:00
parent 4348aa02a8
commit e8fc650d49
496 changed files with 1484 additions and 1443 deletions

View File

@@ -0,0 +1,50 @@
package pascalstring
import (
"erupe-ce/utils/byteframe"
"golang.org/x/text/encoding/japanese"
"golang.org/x/text/transform"
)
func Uint8(bf *byteframe.ByteFrame, x string, t bool) {
if t {
e := japanese.ShiftJIS.NewEncoder()
xt, _, err := transform.String(e, x)
if err != nil {
bf.WriteUint8(0)
return
}
x = xt
}
bf.WriteUint8(uint8(len(x) + 1))
bf.WriteNullTerminatedBytes([]byte(x))
}
func Uint16(bf *byteframe.ByteFrame, x string, t bool) {
if t {
e := japanese.ShiftJIS.NewEncoder()
xt, _, err := transform.String(e, x)
if err != nil {
bf.WriteUint16(0)
return
}
x = xt
}
bf.WriteUint16(uint16(len(x) + 1))
bf.WriteNullTerminatedBytes([]byte(x))
}
func Uint32(bf *byteframe.ByteFrame, x string, t bool) {
if t {
e := japanese.ShiftJIS.NewEncoder()
xt, _, err := transform.String(e, x)
if err != nil {
bf.WriteUint32(0)
return
}
x = xt
}
bf.WriteUint32(uint32(len(x) + 1))
bf.WriteNullTerminatedBytes([]byte(x))
}