From e616789a73febe3e5a548674e767abe7e22c4c4c Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Mon, 30 May 2022 01:03:34 +0200 Subject: [PATCH] Expose supported serialize and proto versions to Lua --- auth.go | 6 +++--- hydra.go | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/auth.go b/auth.go index cfac361..a58aba3 100644 --- a/auth.go +++ b/auth.go @@ -69,9 +69,9 @@ func (auth *Auth) connect() { go func() { for auth.client.state == csConnected && auth.state == asInit { auth.client.conn.SendCmd(&mt.ToSrvInit{ - SerializeVer: 28, - MinProtoVer: 39, - MaxProtoVer: 39, + SerializeVer: serializeVer, + MinProtoVer: protoVer, + MaxProtoVer: protoVer, PlayerName: auth.username, }) time.Sleep(500 * time.Millisecond) diff --git a/hydra.go b/hydra.go index 009731c..3bc7414 100644 --- a/hydra.go +++ b/hydra.go @@ -13,6 +13,9 @@ import ( var lastTime = time.Now() var canceled = false +var serializeVer uint8 = 28 +var protoVer uint16 = 39 + //go:embed builtin/luax/init.lua var builtinLuaX string @@ -97,6 +100,8 @@ func main() { hydra := l.SetFuncs(l.NewTable(), hydraFuncs) l.SetField(hydra, "BS", lua.LNumber(10.0)) + l.SetField(hydra, "serialize_ver", lua.LNumber(serializeVer)) + l.SetField(hydra, "proto_ver", lua.LNumber(protoVer)) l.SetGlobal("hydra", hydra) l.SetField(l.NewTypeMetatable("hydra.auth"), "__index", l.SetFuncs(l.NewTable(), authFuncs)) -- 2.44.0