Exemplo n.º 1
0
func main() {
	var address = uint(0x0059B3D8)

	var adrLstPlayerList = xytsocket.AddressList()
	adrLstPlayerList.Name = "Player-list"
	adrLstPlayerList.Pointer = &address
	adrLstPlayerList.Offset = 0x00
	adrLstPlayerList.Next = 0x48
	adrLstPlayerList.Total = 2

	var adrStPlayer = xytsocket.AddressStruct()
	adrStPlayer.Name = "Player"
	adrStPlayer.Offset = 0x00

	var adrName = new(xytsocket.Address)
	adrName.Name = "Name"
	adrName.Offset = 0x00
	adrName.Type = xytsocket.STRING

	var adrId = new(xytsocket.Address)
	adrId.Name = "Id"
	adrId.Offset = 0x38
	adrId.Type = xytsocket.UINT

	adrLstPlayerList.SetStruct(adrStPlayer)
	adrStPlayer.AppendAddress(adrName)
	adrStPlayer.AppendAddress(adrId)

	addresses := adrLstPlayerList.GetAddressMap(0)

	for i, e := range addresses {
		fmt.Printf("Address %d: %x\n", i, e)
	}
}
Exemplo n.º 2
0
//SOFTWARE.

package xytsocket_test

import (
	"github.com/Xustyx/xytsocket"
	"testing"
)

//Test struct to make the test.
type testAddress struct {
	adr      *xytsocket.Address
	expected []uint
}

var adrLstPlayerList = xytsocket.AddressList()
var adrStPlayer = xytsocket.AddressStruct()
var adrName = new(xytsocket.Address)
var adrId = new(xytsocket.Address)

var testGetAddress = []testAddress{
	{&adrLstPlayerList.Address, []uint{0x0059B3D8, 0x0059B420, 0x0059B468}}, //Next
	{&adrStPlayer.Address, []uint{0x00, 0x00, 0x00}},                        //None
	{adrName, []uint{0x10, 0x20, 0x30}},                                     //Offset + Next
	{adrId, []uint{0x00, 0x00, 0x00}},                                       //Offset
}

var testGetAddressSelf = []testAddress{
	{&adrLstPlayerList.Address, []uint{0x11223344, 0x1122338C, 0x112233D4}}, //Next
	{&adrStPlayer.Address, []uint{0x11223345, 0x11223345, 0x11223345}},      //None
	{adrName, []uint{0x11223346, 0x11223366, 0x11223376}},                   //Offset + Next