]> git.lizzy.rs Git - mt.git/blobdiff - tocltcmds.go
Fix mkserialize.sh
[mt.git] / tocltcmds.go
index 14e42995a4409ac7d0c60fdedbb8b467ce08b7f2..37d7bed084469ea4203f030d0a79bcf3bb7fa349 100644 (file)
@@ -1,11 +1,12 @@
 package mt
 
 import (
-       "crypto/sha1"
        "fmt"
        "image/color"
        "io"
        "math"
+
+       "github.com/Minetest-j45/mt/rudp"
 )
 
 type ToCltCmd interface {
@@ -38,14 +39,17 @@ type ToCltAcceptAuth struct {
        SudoAuthMethods AuthMethods
 }
 
-type ToCltAcceptSudoMode struct{}
+type ToCltAcceptSudoMode struct {
+       SudoAuthMethods AuthMethods
+       //mt:const [15]byte{}
+}
 
 type ToCltDenySudoMode struct{}
 
-// ToCltDisco tells that the client that it has been disconnected by the server.
-type ToCltDisco struct {
-       Reason DiscoReason
-       //mt:assert %s.Reason < maxDiscoReason
+// ToCltKick tells that the client that it has been kicked by the server.
+type ToCltKick struct {
+       Reason KickReason
+       //mt:assert %s.Reason < maxKickReason
 
        //mt:if dr := %s.Reason; dr == Custom || dr == Shutdown || dr == Crash
        Custom string
@@ -56,10 +60,11 @@ type ToCltDisco struct {
        //mt:end
 }
 
-type DiscoReason uint8
+// A KickReason is the reason a ToCltKick has been sent.
+type KickReason uint8
 
 const (
-       WrongPasswd DiscoReason = iota
+       WrongPasswd KickReason = iota
        UnexpectedData
        SrvIsSingleplayer
        UnsupportedVer
@@ -72,10 +77,10 @@ const (
        Custom
        Shutdown
        Crash
-       maxDiscoReason
+       maxKickReason
 )
 
-func (cmd ToCltDisco) String() (msg string) {
+func (cmd ToCltKick) String() (msg string) {
        switch cmd.Reason {
        case WrongPasswd:
                return "wrong password"
@@ -104,7 +109,7 @@ func (cmd ToCltDisco) String() (msg string) {
        case Crash:
                msg = "server crash"
        default:
-               msg = fmt.Sprintf("DiscoReason(%d)", cmd.Reason)
+               msg = fmt.Sprintf("KickReason(%d)", cmd.Reason)
        }
 
        if cmd.Custom != "" {
@@ -172,13 +177,10 @@ type ToCltAddPlayerVel struct {
 
 // ToCltMediaPush is sent when a media file is dynamically added.
 type ToCltMediaPush struct {
-       //mt:const uint16(sha1.Size)
-       SHA1        [sha1.Size]byte
-       Filename    string
-       ShouldCache bool
-
-       //mt:len32
-       Data []byte
+       RawHash       string
+       Filename      string
+       CallbackToken uint32
+       ShouldCache   bool
 }
 
 // ToCltChatMsg tells the client that is has received a chat message.
@@ -209,13 +211,15 @@ const (
 // the AOs that it can see.
 type ToCltAORmAdd struct {
        Remove []AOID
-       Add    []struct {
-               ID AOID
-               //mt:const genericCAO
-               //mt:lenhdr 32
-               InitData AOInitData
-               //mt:end
-       }
+       Add    []AOAdd
+}
+
+type AOAdd struct {
+       ID AOID
+       //mt:const genericCAO
+       //mt:lenhdr 32
+       InitData AOInitData
+       //mt:end
 }
 
 // ToCltAOMsgs updates the client about nearby AOs.
@@ -235,7 +239,7 @@ type ToCltMovePlayer struct {
        Pitch, Yaw float32
 }
 
-type ToCltDiscoLegacy struct {
+type ToCltLegacyKick struct {
        //mt:utf16
        Reason string
 }
@@ -409,12 +413,7 @@ type ToCltAddParticleSpawner struct {
        NodeTile     uint8
 }
 
-type HUDID uint32
-
-// ToCltHUDAdd tells the client to add a HUD.
-type ToCltAddHUD struct {
-       ID HUDID
-
+type HUD struct {
        Type HUDType
 
        Pos      [2]float32
@@ -432,6 +431,14 @@ type ToCltAddHUD struct {
        Text2    string
 }
 
+type HUDID uint32
+
+// ToCltHUDAdd tells the client to add a HUD.
+type ToCltAddHUD struct {
+       ID HUDID
+       HUD
+}
+
 type HUDType uint8
 
 const (
@@ -503,7 +510,7 @@ type ToCltChangeHUD struct {
        //mt:end
 
        //mt:if %s.Field == HUDZIndex
-       ZIndex uint32
+       ZIndex int32
        //mt:end
 
        //mt:if %s.Field == HUDText2
@@ -759,3 +766,9 @@ func (cmd *ToCltMinimapModes) deserialize(r io.Reader) {
                chk(deserialize(r, &cmd.Modes[i]))
        }
 }
+
+type ToCltDisco struct{}
+
+func (*ToCltDisco) cmd()                         {}
+func (*ToCltDisco) toCltCmdNo() uint16           { return 0xffff }
+func (*ToCltDisco) DefaultPktInfo() rudp.PktInfo { return rudp.PktInfo{} }