Revert "Add hand list updates (not working)"

This reverts commit 8f0cc07de2.
master
HimbeerserverDE 2021-02-22 17:10:39 +01:00
parent 30a5f27b33
commit a09b15346f
6 changed files with 3 additions and 123 deletions

View File

@ -186,10 +186,7 @@ func processPktCommand(src, dst *Peer, pkt *rudp.Pkt) bool {
} else if id == dst.localPlayerCao {
id = dst.currentPlayerCao
}
binary.BigEndian.PutUint16(pkt.Data[107+texturelen:109+texturelen], id)
case ToClientInventory:
processInventory(dst, pkt.Data[2:])
return false
binary.BigEndian.PutUint16(pkt.Data[107+texturelen : 109+texturelen], id)
default:
return false
}

View File

@ -1,54 +0,0 @@
package main
import (
"strings"
"github.com/anon55555/mt/rudp"
)
func processInventory(p *Peer, data []byte) {
lists := make(map[string]bool)
inv := string(data)
lines := strings.Split(inv, "\n")
for _, line := range lines {
list := strings.Split(line, " ")
name := list[0]
if name == "EndInventory" || name == "end" {
return
}
if name == "List" {
listname := list[1]
lists[listname] = true
}
if name == "KeepList" {
listname := list[1]
lists[listname] = true
}
}
p.invlists = lists
}
func updateHandList(p *Peer, t *ToolCapabs) error {
item := " 1 0 " + t.String()
list := "Width 1\n"
list += "Item " + item + "\n"
list += "EndInventoryList\n"
inv := "List hand 1\n"
inv += list
for invlist := range p.invlists {
inv += "KeepList " + invlist + "\n"
}
inv += "EndInventory\n"
p.invlists = make(map[string]bool)
_, err := p.Send(rudp.Pkt{Data: []byte(inv)})
if err != nil {
return err
}
return nil
}

View File

@ -5,14 +5,8 @@ import (
"compress/zlib"
"encoding/binary"
"io"
"log"
"math"
"strconv"
)
const (
MetaBegin = "\x01"
MetaKVDelim = "\x02"
MetaPairDelim = "\x03"
)
var itemdef []byte
@ -110,55 +104,6 @@ func (t *ToolCapabs) SetPunchAttackUses(uses uint16) {
t.punchAttackUses = uses
}
// String returns a minetest meta string with the tool capabilities
func (t *ToolCapabs) String() string {
r := MetaBegin
r += "tool_capabilities"
r += MetaKVDelim
r += "{\n"
r += "\t"
r += "\"damage_groups\" : \n"
r += "\t{\n"
for group, value := range t.DamageGroups() {
r += "\t\t\"" + group + "\" : "
r += strconv.Itoa(int(value)) + ",\n"
}
r += "\t},\n"
r += "\t\"full_punch_interval\" : "
r += strconv.FormatFloat(float64(t.PunchInt()), byte('e'), -1, 32)
r += ",\n"
r += "\t\"groupcaps\" : \n"
r += "\t{\n"
for name, cap := range t.GroupCaps() {
r += "\t\t\"" + name + "\" : \n"
r += "\t\t{\n"
r += "\t\t\t\"name\" : " + cap.Name() + ",\n"
r += "\t\t\t\"uses\" : " + strconv.Itoa(int(cap.Uses())) + ",\n"
r += "\t\t\t\"max_level\" : " + strconv.Itoa(int(cap.MaxLevel())) + ",\n"
r += "\t\t\t\"times\" : \n"
r += "\t\t\t{\n"
for k, v := range cap.Times() {
r += "\t\t\t\t\"" + strconv.Itoa(int(k)) + "\" : "
r += strconv.FormatFloat(float64(v), byte('e'), -1, 32)
r += ",\n"
}
r += "\t\t\t},\n"
r += "\t\t},\n"
}
r += "\t},\n"
r += "\t\"max_drop_level\" : " + strconv.Itoa(int(t.MaxDropLevel())) + ",\n"
r += "\t\"punch_attack_uses\" : " + strconv.Itoa(int(t.PunchAttackUses())) + "\n"
r += MetaPairDelim
return r
}
func rmToolCapabs(def []byte) []byte {
itemNameLen := binary.BigEndian.Uint16(def[2:4])
desclen := binary.BigEndian.Uint16(def[4+itemNameLen : 6+itemNameLen])
@ -307,6 +252,7 @@ func mergeItemdefs(mgrs map[string][]byte) error {
}
handdata := rmToolCapabs(handDef)
log.Print(handdata)
var compHanddata bytes.Buffer
handZw := zlib.NewWriter(&compHanddata)

View File

@ -51,7 +51,6 @@ func (l *Listener) Accept() (*Peer, error) {
clt.modChs = make(map[string]bool)
clt.huds = make(map[uint32]bool)
clt.sounds = make(map[int32]bool)
clt.invlists = make(map[string]bool)
maxPeers, ok := GetConfKey("player_limit").(int)
if !ok {

View File

@ -46,8 +46,6 @@ type Peer struct {
huds map[uint32]bool
sounds map[int32]bool
invlists map[string]bool
}
// Username returns the username of the Peer

View File

@ -145,12 +145,6 @@ func (p *Peer) Redirect(newsrv string) error {
p.sounds = make(map[int32]bool)
// Update hand capabs
err = updateHandList(p, handcapabs[newsrv])
if err != nil {
return err
}
// Update detached inventories
if len(detachedinvs[newsrv]) > 0 {
for i := range detachedinvs[newsrv] {