noxnet

package
v0.0.0-...-b9edb71 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 20 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MSG_SERVER_CONNECT                 = Op(0)   // 0x00
	MSG_SERVER_ACCEPT                  = Op(1)   // 0x01
	MSG_CODE2                          = Op(2)   // 0x02
	MSG_CODE3                          = Op(3)   // 0x03
	MSG_CODE4                          = Op(4)   // 0x04
	MSG_CODE5                          = Op(5)   // 0x05
	MSG_CLIENT_PING                    = Op(6)   // 0x06
	MSG_CODE7                          = Op(7)   // 0x07
	MSG_CLIENT_PONG                    = Op(8)   // 0x08
	MSG_CODE9                          = Op(9)   // 0x09
	MSG_CLIENT_CLOSE                   = Op(10)  // 0x0A
	MSG_SERVER_CLOSE                   = Op(11)  // 0x0B
	MSG_SERVER_DISCOVER                = Op(12)  // 0x0C
	MSG_SERVER_INFO                    = Op(13)  // 0x0D
	MSG_SERVER_TRY_JOIN                = Op(14)  // 0x0E
	MSG_PASSWORD_REQUIRED              = Op(15)  // 0x0F
	MSG_SERVER_PING                    = Op(16)  // 0x10
	MSG_SERVER_PASSWORD                = Op(17)  // 0x11
	MSG_SERVER_PONG                    = Op(18)  // 0x12
	MSG_SERVER_ERROR                   = Op(19)  // 0x13
	MSG_SERVER_JOIN_OK                 = Op(20)  // 0x14
	MSG_SERVER_JOIN_FAIL               = Op(21)  // 0x15
	MSG_CODE22                         = Op(22)  // 0x16
	MSG_CODE23                         = Op(23)  // 0x17
	MSG_CODE24                         = Op(24)  // 0x18
	MSG_CODE25                         = Op(25)  // 0x19
	MSG_CODE26                         = Op(26)  // 0x1A
	MSG_CODE27                         = Op(27)  // 0x1B
	MSG_CODE28                         = Op(28)  // 0x1C
	MSG_CODE29                         = Op(29)  // 0x1D
	MSG_CODE30                         = Op(30)  // 0x1E
	MSG_ACCEPTED                       = Op(31)  // 0x1F
	MSG_CLIENT_ACCEPT                  = Op(32)  // 0x20
	MSG_SERVER_CLOSE_ACK               = Op(33)  // 0x21
	MSG_CLIENT_CLOSE_ACK               = Op(34)  // 0x22
	MSG_SPEED                          = Op(35)  // 0x23
	MSG_PING                           = Op(36)  // 0x24
	MSG_CODE37                         = Op(37)  // 0x25
	MSG_CODE38                         = Op(38)  // 0x26
	MSG_TIMESTAMP                      = Op(39)  // 0x27
	MSG_FULL_TIMESTAMP                 = Op(40)  // 0x28
	MSG_NEED_TIMESTAMP                 = Op(41)  // 0x29
	MSG_SIMULATED_TIMESTAMP            = Op(42)  // 0x2A
	MSG_USE_MAP                        = Op(43)  // 0x2B
	MSG_JOIN_DATA                      = Op(44)  // 0x2C
	MSG_NEW_PLAYER                     = Op(45)  // 0x2D
	MSG_PLAYER_QUIT                    = Op(46)  // 0x2E
	MSG_SIMPLE_OBJ                     = Op(47)  // 0x2F
	MSG_COMPLEX_OBJ                    = Op(48)  // 0x30
	MSG_DESTROY_OBJECT                 = Op(49)  // 0x31
	MSG_OBJECT_OUT_OF_SIGHT            = Op(50)  // 0x32
	MSG_OBJECT_IN_SHADOWS              = Op(51)  // 0x33
	MSG_OBJECT_FRIEND_ADD              = Op(52)  // 0x34
	MSG_OBJECT_FRIEND_REMOVE           = Op(53)  // 0x35
	MSG_RESET_FRIENDS                  = Op(54)  // 0x36
	MSG_ENABLE_OBJECT                  = Op(55)  // 0x37
	MSG_DISABLE_OBJECT                 = Op(56)  // 0x38
	MSG_DRAW_FRAME                     = Op(57)  // 0x39
	MSG_DESTROY_WALL                   = Op(58)  // 0x3A
	MSG_OPEN_WALL                      = Op(59)  // 0x3B
	MSG_CLOSE_WALL                     = Op(60)  // 0x3C
	MSG_CHANGE_OR_ADD_WALL_MAGIC       = Op(61)  // 0x3D
	MSG_REMOVE_WALL_MAGIC              = Op(62)  // 0x3E
	MSG_PLAYER_INPUT                   = Op(63)  // 0x3F
	MSG_PLAYER_SET_WAYPOINT            = Op(64)  // 0x40
	MSG_REPORT_HEALTH                  = Op(65)  // 0x41
	MSG_REPORT_HEALTH_DELTA            = Op(66)  // 0x42
	MSG_REPORT_PLAYER_HEALTH           = Op(67)  // 0x43
	MSG_REPORT_ITEM_HEALTH             = Op(68)  // 0x44
	MSG_REPORT_MANA                    = Op(69)  // 0x45
	MSG_REPORT_POISON                  = Op(70)  // 0x46
	MSG_REPORT_STAMINA                 = Op(71)  // 0x47
	MSG_REPORT_STATS                   = Op(72)  // 0x48
	MSG_REPORT_ARMOR_VALUE             = Op(73)  // 0x49
	MSG_REPORT_GOLD                    = Op(74)  // 0x4A
	MSG_REPORT_PICKUP                  = Op(75)  // 0x4B
	MSG_REPORT_MODIFIABLE_PICKUP       = Op(76)  // 0x4C
	MSG_REPORT_DROP                    = Op(77)  // 0x4D
	MSG_REPORT_LESSON                  = Op(78)  // 0x4E
	MSG_REPORT_MUNDANE_ARMOR_EQUIP     = Op(79)  // 0x4F
	MSG_REPORT_MUNDANE_WEAPON_EQUIP    = Op(80)  // 0x50
	MSG_REPORT_MODIFIABLE_WEAPON_EQUIP = Op(81)  // 0x51
	MSG_REPORT_MODIFIABLE_ARMOR_EQUIP  = Op(82)  // 0x52
	MSG_REPORT_ARMOR_DEQUIP            = Op(83)  // 0x53
	MSG_REPORT_WEAPON_DEQUIP           = Op(84)  // 0x54
	MSG_REPORT_TREASURE_COUNT          = Op(85)  // 0x55
	MSG_REPORT_FLAG_BALL_WINNER        = Op(86)  // 0x56
	MSG_REPORT_FLAG_WINNER             = Op(87)  // 0x57
	MSG_REPORT_DEATHMATCH_WINNER       = Op(88)  // 0x58
	MSG_REPORT_DEATHMATCH_TEAM_WINNER  = Op(89)  // 0x59
	MSG_REPORT_ENCHANTMENT             = Op(90)  // 0x5A
	MSG_REPORT_ITEM_ENCHANTMENT        = Op(91)  // 0x5B
	MSG_REPORT_LIGHT_COLOR             = Op(92)  // 0x5C
	MSG_REPORT_LIGHT_INTENSITY         = Op(93)  // 0x5D
	MSG_REPORT_Z_PLUS                  = Op(94)  // 0x5E
	MSG_REPORT_Z_MINUS                 = Op(95)  // 0x5F
	MSG_REPORT_EQUIP                   = Op(96)  // 0x60
	MSG_REPORT_DEQUIP                  = Op(97)  // 0x61
	MSG_REPORT_ACQUIRE_SPELL           = Op(98)  // 0x62
	MSG_REPORT_TARGET                  = Op(99)  // 0x63
	MSG_REPORT_CHARGES                 = Op(100) // 0x64
	MSG_REPORT_X_STATUS                = Op(101) // 0x65
	MSG_REPORT_PLAYER_STATUS           = Op(102) // 0x66
	MSG_REPORT_MODIFIER                = Op(103) // 0x67
	MSG_REPORT_STAT_MODIFIER           = Op(104) // 0x68
	MSG_REPORT_NPC                     = Op(105) // 0x69
	MSG_REPORT_CLIENT_STATUS           = Op(106) // 0x6A
	MSG_REPORT_ANIMATION_FRAME         = Op(107) // 0x6B
	MSG_REPORT_ACQUIRE_CREATURE        = Op(108) // 0x6C
	MSG_REPORT_LOSE_CREATURE           = Op(109) // 0x6D
	MSG_REPORT_EXPERIENCE              = Op(110) // 0x6E
	MSG_REPORT_SPELL_AWARD             = Op(111) // 0x6F
	MSG_REPORT_SPELL_START             = Op(112) // 0x70
	MSG_REPORT_INVENTORY_LOADED        = Op(113) // 0x71
	MSG_TRY_DROP                       = Op(114) // 0x72
	MSG_TRY_GET                        = Op(115) // 0x73
	MSG_TRY_USE                        = Op(116) // 0x74
	MSG_TRY_EQUIP                      = Op(117) // 0x75
	MSG_TRY_DEQUIP                     = Op(118) // 0x76
	MSG_TRY_TARGET                     = Op(119) // 0x77
	MSG_TRY_CREATURE_COMMAND           = Op(120) // 0x78
	MSG_TRY_SPELL                      = Op(121) // 0x79
	MSG_TRY_ABILITY                    = Op(122) // 0x7A
	MSG_TRY_COLLIDE                    = Op(123) // 0x7B
	MSG_FX_PARTICLEFX                  = Op(124) // 0x7C
	MSG_FX_PLASMA                      = Op(125) // 0x7D
	MSG_FX_SUMMON                      = Op(126) // 0x7E
	MSG_FX_SUMMON_CANCEL               = Op(127) // 0x7F
	MSG_FX_SHIELD                      = Op(128) // 0x80
	MSG_FX_BLUE_SPARKS                 = Op(129) // 0x81
	MSG_FX_YELLOW_SPARKS               = Op(130) // 0x82
	MSG_FX_CYAN_SPARKS                 = Op(131) // 0x83
	MSG_FX_VIOLET_SPARKS               = Op(132) // 0x84
	MSG_FX_EXPLOSION                   = Op(133) // 0x85
	MSG_FX_LESSER_EXPLOSION            = Op(134) // 0x86
	MSG_FX_COUNTERSPELL_EXPLOSION      = Op(135) // 0x87
	MSG_FX_THIN_EXPLOSION              = Op(136) // 0x88
	MSG_FX_TELEPORT                    = Op(137) // 0x89
	MSG_FX_SMOKE_BLAST                 = Op(138) // 0x8A
	MSG_FX_DAMAGE_POOF                 = Op(139) // 0x8B
	MSG_FX_LIGHTNING                   = Op(140) // 0x8C
	MSG_FX_ENERGY_BOLT                 = Op(141) // 0x8D
	MSG_FX_CHAIN_LIGHTNING_BOLT        = Op(142) // 0x8E
	MSG_FX_DRAIN_MANA                  = Op(143) // 0x8F
	MSG_FX_CHARM                       = Op(144) // 0x90
	MSG_FX_GREATER_HEAL                = Op(145) // 0x91
	MSG_FX_MAGIC                       = Op(146) // 0x92
	MSG_FX_SPARK_EXPLOSION             = Op(147) // 0x93
	MSG_FX_DEATH_RAY                   = Op(148) // 0x94
	MSG_FX_SENTRY_RAY                  = Op(149) // 0x95
	MSG_FX_RICOCHET                    = Op(150) // 0x96
	MSG_FX_JIGGLE                      = Op(151) // 0x97
	MSG_FX_GREEN_BOLT                  = Op(152) // 0x98
	MSG_FX_GREEN_EXPLOSION             = Op(153) // 0x99
	MSG_FX_WHITE_FLASH                 = Op(154) // 0x9A
	MSG_FX_GENERATING_MAP              = Op(155) // 0x9B
	MSG_FX_ASSEMBLING_MAP              = Op(156) // 0x9C
	MSG_FX_POPULATING_MAP              = Op(157) // 0x9D
	MSG_FX_DURATION_SPELL              = Op(158) // 0x9E
	MSG_FX_DELTAZ_SPELL_START          = Op(159) // 0x9F
	MSG_FX_TURN_UNDEAD                 = Op(160) // 0xA0
	MSG_FX_ARROW_TRAP                  = Op(161) // 0xA1
	MSG_FX_VAMPIRISM                   = Op(162) // 0xA2
	MSG_FX_MANA_BOMB_CANCEL            = Op(163) // 0xA3
	MSG_UPDATE_STREAM                  = Op(164) // 0xA4
	MSG_NEW_ALIAS                      = Op(165) // 0xA5
	MSG_AUDIO_EVENT                    = Op(166) // 0xA6
	MSG_AUDIO_PLAYER_EVENT             = Op(167) // 0xA7
	MSG_TEXT_MESSAGE                   = Op(168) // 0xA8
	MSG_INFORM                         = Op(169) // 0xA9
	MSG_IMPORTANT                      = Op(170) // 0xAA
	MSG_IMPORTANT_ACK                  = Op(171) // 0xAB
	MSG_MOUSE                          = Op(172) // 0xAC
	MSG_INCOMING_CLIENT                = Op(173) // 0xAD
	MSG_OUTGOING_CLIENT                = Op(174) // 0xAE
	MSG_GAME_SETTINGS                  = Op(175) // 0xAF
	MSG_GAME_SETTINGS_2                = Op(176) // 0xB0
	MSG_UPDATE_GUI_GAME_SETTINGS       = Op(177) // 0xB1
	MSG_DOOR_ANGLE                     = Op(178) // 0xB2
	MSG_OBELISK_CHARGE                 = Op(179) // 0xB3
	MSG_PENTAGRAM_ACTIVATE             = Op(180) // 0xB4
	MSG_CLIENT_PREDICT_LINEAR          = Op(181) // 0xB5
	MSG_REQUEST_MAP                    = Op(182) // 0xB6
	MSG_CANCEL_MAP                     = Op(183) // 0xB7
	MSG_MAP_SEND_START                 = Op(184) // 0xB8
	MSG_MAP_SEND_PACKET                = Op(185) // 0xB9
	MSG_MAP_SEND_ABORT                 = Op(186) // 0xBA
	MSG_SERVER_CMD                     = Op(187) // 0xBB
	MSG_SYSOP_PW                       = Op(188) // 0xBC
	MSG_SYSOP_RESULT                   = Op(189) // 0xBD
	MSG_KEEP_ALIVE                     = Op(190) // 0xBE
	MSG_RECEIVED_MAP                   = Op(191) // 0xBF
	MSG_CLIENT_READY                   = Op(192) // 0xC0
	MSG_REQUEST_SAVE_PLAYER            = Op(193) // 0xC1
	MSG_XFER_MSG                       = Op(194) // 0xC2
	MSG_PLAYER_OBJ                     = Op(195) // 0xC3
	MSG_TEAM_MSG                       = Op(196) // 0xC4
	MSG_KICK_NOTIFICATION              = Op(197) // 0xC5
	MSG_TIMEOUT_NOTIFICATION           = Op(198) // 0xC6
	MSG_SERVER_QUIT                    = Op(199) // 0xC7
	MSG_SERVER_QUIT_ACK                = Op(200) // 0xC8
	MSG_TRADE                          = Op(201) // 0xC9
	MSG_CHAT_KILL                      = Op(202) // 0xCA
	MSG_MESSAGES_KILL                  = Op(203) // 0xCB
	MSG_SEQ_IMPORTANT                  = Op(204) // 0xCC
	MSG_REPORT_ABILITY_AWARD           = Op(205) // 0xCD
	MSG_REPORT_ABILITY_STATE           = Op(206) // 0xCE
	MSG_REPORT_ACTIVE_ABILITIES        = Op(207) // 0xCF
	MSG_DIALOG                         = Op(208) // 0xD0
	MSG_REPORT_GUIDE_AWARD             = Op(209) // 0xD1
	MSG_INTERESTING_ID                 = Op(210) // 0xD2
	MSG_TIMER_STATUS                   = Op(211) // 0xD3
	MSG_REQUEST_TIMER_STATUS           = Op(212) // 0xD4
	MSG_JOURNAL_MSG                    = Op(213) // 0xD5
	MSG_CHAPTER_END                    = Op(214) // 0xD6
	MSG_REPORT_ALL_LATENCY             = Op(215) // 0xD7
	MSG_REPORT_FLAG_STATUS             = Op(216) // 0xD8
	MSG_REPORT_BALL_STATUS             = Op(217) // 0xD9
	MSG_REPORT_OBJECT_POISON           = Op(218) // 0xDA
	MSG_REPORT_MONITOR_CREATURE        = Op(219) // 0xDB
	MSG_REPORT_UNMONITOR_CREATURE      = Op(220) // 0xDC
	MSG_REPORT_TOTAL_HEALTH            = Op(221) // 0xDD
	MSG_REPORT_TOTAL_MANA              = Op(222) // 0xDE
	MSG_REPORT_SPELL_STAT              = Op(223) // 0xDF
	MSG_REPORT_SECONDARY_WEAPON        = Op(224) // 0xE0
	MSG_REPORT_LAST_QUIVER             = Op(225) // 0xE1
	MSG_INFO_BOOK_DATA                 = Op(226) // 0xE2
	MSG_SOCIAL                         = Op(227) // 0xE3
	MSG_FADE_BEGIN                     = Op(228) // 0xE4
	MSG_MUSIC_EVENT                    = Op(229) // 0xE5
	MSG_MUSIC_PUSH_EVENT               = Op(230) // 0xE6
	MSG_MUSIC_POP_EVENT                = Op(231) // 0xE7
	MSG_PLAYER_DIED                    = Op(232) // 0xE8
	MSG_PLAYER_RESPAWN                 = Op(233) // 0xE9
	MSG_FORGET_DRAWABLES               = Op(234) // 0xEA
	MSG_RESET_ABILITIES                = Op(235) // 0xEB
	MSG_RATE_CHANGE                    = Op(236) // 0xEC
	MSG_REPORT_CREATURE_CMD            = Op(237) // 0xED
	MSG_VOTE                           = Op(238) // 0xEE
	MSG_STAT_MULTIPLIERS               = Op(239) // 0xEF
	MSG_GAUNTLET                       = Op(240) // 0xF0
	MSG_INVENTORY_FAIL                 = Op(241) // 0xF1
)
View Source
const (
	InfoSpellErr       = InformCode(0)
	InfoSpellOK        = InformCode(1)
	InfoAbility        = InformCode(2)
	InfoPlayerTimeout  = InformCode(3)
	InfoFlagRetrieve   = InformCode(4)
	InfoFlagCapture    = InformCode(5)
	InfoFlagPickup     = InformCode(6)
	InfoFlagDrop       = InformCode(7)
	InfoFlagRespawn    = InformCode(8)
	InfoBallScore      = InformCode(9)
	InfoCrownPickup    = InformCode(10)
	InfoCrownDrop      = InformCode(11)
	InfoObserver       = InformCode(12)
	InfoPlayerState    = InformCode(13)
	InfoKill           = InformCode(14)
	InfoStringID       = InformCode(15)
	InfoWrongTeam      = InformCode(16)
	InfoClassChanged   = InformCode(17)
	InfoPlayerExit     = InformCode(18)
	InfoPlayerWarp     = InformCode(19)
	InfoPlayerSecret   = InformCode(20)
	InfoPlayerWarpWait = InformCode(21)
)
View Source
const (
	CCOrientation            = CtrlCode(1)
	CCMoveForward            = CtrlCode(2)
	CCMoveBackward           = CtrlCode(3)
	CCMoveLeft               = CtrlCode(4)
	CCMoveRight              = CtrlCode(5)
	CCAction                 = CtrlCode(6)
	CCJump                   = CtrlCode(7)
	CCChat                   = CtrlCode(8)
	CCTeamChat               = CtrlCode(9)
	CCReadSpellbook          = CtrlCode(10)
	CCToggleConsole          = CtrlCode(11)
	CCIncreaseWindowSize     = CtrlCode(12)
	CCDecreaseWindowSize     = CtrlCode(13)
	CCIncreaseGamma          = CtrlCode(14)
	CCDecreaseGamma          = CtrlCode(15)
	CCQuit                   = CtrlCode(16)
	CCQuitMenu               = CtrlCode(17)
	CCReadMap                = CtrlCode(18)
	CCInventory              = CtrlCode(19)
	CCSpellGestureUp         = CtrlCode(20)
	CCSpellGestureDown       = CtrlCode(21)
	CCSpellGestureLeft       = CtrlCode(22)
	CCSpellGestureRight      = CtrlCode(23)
	CCSpellGestureUpperRight = CtrlCode(24)
	CCSpellGestureUpperLeft  = CtrlCode(25)
	CCSpellGestureLowerRight = CtrlCode(26)
	CCSpellGestureLowerLeft  = CtrlCode(27)
	CCSpellPatternEnd        = CtrlCode(28)
	CCCastQueuedSpell        = CtrlCode(29)
	CCCastMostRecentSpell    = CtrlCode(30)
	CCCastSpell1             = CtrlCode(31)
	CCCastSpell2             = CtrlCode(32)
	CCCastSpell3             = CtrlCode(33)
	CCCastSpell4             = CtrlCode(34)
	CCCastSpell5             = CtrlCode(35)
	CCMapZoomIn              = CtrlCode(36)
	CCMapZoomOut             = CtrlCode(37)
	CCNextWeapon             = CtrlCode(38)
	CCQuickHealthPotion      = CtrlCode(39)
	CCQuickManaPotion        = CtrlCode(40)
	CCQuickCurePoisonPotion  = CtrlCode(41)
	CCNextSpellSet           = CtrlCode(42)
	CCPreviousSpellSet       = CtrlCode(43)
	CCSelectSpellSet         = CtrlCode(44)
	CCBuildTrap              = CtrlCode(45)
	CCServerOptions          = CtrlCode(46)
	CCTaunt                  = CtrlCode(47)
	CCLaugh                  = CtrlCode(48)
	CCPoint                  = CtrlCode(49)
	CCInvertSpellTarget      = CtrlCode(50)
	CCToggleRank             = CtrlCode(51)
	CCToggleNetstat          = CtrlCode(52)
	CCToggleGUI              = CtrlCode(53)
	CCAutoSave               = CtrlCode(54)
	CCAutoLoad               = CtrlCode(55)
	CCScreenShot             = CtrlCode(56)
)
View Source
const (
	ErrLowPing = ConnectError(iota)
	ErrHighPing
	ErrLowLevel
	ErrHighLevel
	ErrClosed
	ErrBanned
	ErrWrongPassword
	ErrIllegalClass
	ErrTimeOut
	ErrFindFailed
	ErrNeedRefresh
	ErrFull
	ErrDupSerial
	ErrWrongVer
)
View Source
const (
	TextTeam      = TextFlags(0x1)
	TextUTF8      = TextFlags(0x2)
	TextFlag4     = TextFlags(0x2)
	TextLocalized = TextFlags(0x8)
	TextNotice    = TextFlags(0x10)
	TextFlag20    = TextFlags(0x20)
	TextFlag40    = TextFlags(0x40)
	TextExt       = TextFlags(0x80) // unused in vanilla
)
View Source
const (
	DefaultPort    = 18590
	ProtoVersion   = 0x1039a // 0.1.922
	ProtoVersionHD = 0xf039a // 0.15.922
)
View Source
const (
	MaxStreams     = 128
	ServerStreamID = StreamID(0)
	MaxStreamID    = StreamID(MaxStreams - 1)
)

Variables

View Source
var (
	ErrPasswordRequired = errors.New("password required")
	ErrJoinFailed       = errors.New("join failed")
)

Functions

func AppendPacket

func AppendPacket(data []byte, p Message) ([]byte, error)

func DecodePacket

func DecodePacket(data []byte, p Message) (int, error)

func EncodePacket

func EncodePacket(data []byte, p Message) (int, error)

func EncodePacketSize

func EncodePacketSize(p Message) int

func NewPipe

func NewPipe(log *slog.Logger, buf int) (srv *PipeConn, cli *PipeConn)

func RegisterMessage

func RegisterMessage(p Message, dynamic bool)

Types

type Client

type Client struct {
	Port *Port
	// contains filtered or unexported fields
}

func NewClient

func NewClient(log *slog.Logger, conn PacketConn) *Client

func NewClientWithPort

func NewClientWithPort(log *slog.Logger, port *Port) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) Connect

func (c *Client) Connect(ctx context.Context, addr netip.AddrPort, req *MsgClientAccept) error

func (*Client) Discover

func (c *Client) Discover(ctx context.Context, port int, out chan<- ServerInfoResp) error

func (*Client) LocalAddr

func (c *Client) LocalAddr() netip.AddrPort

func (*Client) Reset

func (c *Client) Reset()

func (*Client) SetServerAddr

func (c *Client) SetServerAddr(addr netip.AddrPort)

func (*Client) TryJoin

func (c *Client) TryJoin(ctx context.Context, addr netip.AddrPort, req MsgServerTryJoin) error

func (*Client) TryPassword

func (c *Client) TryPassword(ctx context.Context, pass string) error

type ComplexObjectUpdate

type ComplexObjectUpdate struct {
	Unk0 byte
	Unk1 byte
	Unk2 byte
}

type Conn

type Conn struct {
	// contains filtered or unexported fields
}

func (*Conn) Ack

func (p *Conn) Ack() error

func (*Conn) CancelReliable

func (p *Conn) CancelReliable(pid PacketID)

func (*Conn) Encrypt

func (p *Conn) Encrypt(key byte)

func (*Conn) OnMessage

func (p *Conn) OnMessage(fnc OnMessageFunc)

func (*Conn) Port

func (p *Conn) Port() *Port

func (*Conn) QueueReliable

func (p *Conn) QueueReliable(ctx context.Context, sid StreamID, data []byte, done, timeout func()) PacketID

func (*Conn) QueueReliableMsg

func (p *Conn) QueueReliableMsg(ctx context.Context, sid StreamID, arr []Message, done, timeout func()) (PacketID, error)

func (*Conn) QueuedFor

func (p *Conn) QueuedFor(sid StreamID) int

func (*Conn) RemoteAddr

func (p *Conn) RemoteAddr() netip.AddrPort

func (*Conn) Reset

func (p *Conn) Reset()

func (*Conn) ResetFor

func (p *Conn) ResetFor(sid StreamID)

func (*Conn) SendQueue

func (p *Conn) SendQueue() error

func (*Conn) SendReliable

func (p *Conn) SendReliable(ctx context.Context, sid StreamID, data []byte) error

func (*Conn) SendReliableMsg

func (p *Conn) SendReliableMsg(ctx context.Context, sid StreamID, m Message) error

func (*Conn) SendUnreliable

func (p *Conn) SendUnreliable(sid StreamID, data []byte) error

func (*Conn) SendUnreliableMsg

func (p *Conn) SendUnreliableMsg(sid StreamID, m Message) error

func (*Conn) UpdateQueue

func (p *Conn) UpdateQueue(fnc func(pid PacketID, sid StreamID, data []byte) bool)

func (*Conn) ViewQueue

func (p *Conn) ViewQueue(fnc func(sid StreamID, data []byte))

func (*Conn) WithID

func (p *Conn) WithID(sid StreamID) *Stream

type ConnectError

type ConnectError byte

func (ConnectError) Error

func (e ConnectError) Error() string

func (ConnectError) Name

func (e ConnectError) Name() string

type CtrlCode

type CtrlCode byte

func (CtrlCode) DataSize

func (code CtrlCode) DataSize() int

func (CtrlCode) String

func (code CtrlCode) String() string

type Encoded

type Encoded interface {
	EncodeSize() int
	Encode(data []byte) (int, error)
	Decode(data []byte) (int, error)
}

type Engine

type Engine interface {
	ServerInfo(addr netip.AddrPort) *MsgServerInfo
	PreJoin(addr netip.AddrPort, req *MsgServerTryJoin) error
	CheckPass(addr netip.AddrPort, pass string) error
	Connect(addr netip.AddrPort) (Player, error)
}

type ErrorMsg

type ErrorMsg interface {
	Message
	Error() error
}

func ErrorToMsg

func ErrorToMsg(err error) (ErrorMsg, bool)

type Inform

type Inform interface {
	InformCode() InformCode
	Encoded
}

type InformClassChanged

type InformClassChanged struct {
}

func (*InformClassChanged) Decode

func (m *InformClassChanged) Decode(data []byte) (int, error)

func (*InformClassChanged) Encode

func (m *InformClassChanged) Encode(data []byte) (int, error)

func (*InformClassChanged) EncodeSize

func (*InformClassChanged) EncodeSize() int

func (*InformClassChanged) InformCode

func (*InformClassChanged) InformCode() InformCode

type InformCode

type InformCode byte

type InformKill

type InformKill struct {
	Unk1 uint16
	Unk2 uint16
	Unk3 uint16
	Unk4 uint16
	Unk5 byte
}

func (*InformKill) Decode

func (m *InformKill) Decode(data []byte) (int, error)

func (*InformKill) Encode

func (m *InformKill) Encode(data []byte) (int, error)

func (*InformKill) EncodeSize

func (*InformKill) EncodeSize() int

func (*InformKill) InformCode

func (*InformKill) InformCode() InformCode

type InformObserver

type InformObserver struct {
	Prompt uint32
}

func (*InformObserver) Decode

func (m *InformObserver) Decode(data []byte) (int, error)

func (*InformObserver) Encode

func (m *InformObserver) Encode(data []byte) (int, error)

func (*InformObserver) EncodeSize

func (*InformObserver) EncodeSize() int

func (*InformObserver) InformCode

func (*InformObserver) InformCode() InformCode

type InformPlayer

type InformPlayer struct {
	Code     InformCode
	PlayerID uint32
}

func (*InformPlayer) Decode

func (m *InformPlayer) Decode(data []byte) (int, error)

func (*InformPlayer) Encode

func (m *InformPlayer) Encode(data []byte) (int, error)

func (*InformPlayer) EncodeSize

func (*InformPlayer) EncodeSize() int

func (*InformPlayer) InformCode

func (m *InformPlayer) InformCode() InformCode

type InformPlayerState

type InformPlayerState struct {
	State uint32
}

func (*InformPlayerState) Decode

func (m *InformPlayerState) Decode(data []byte) (int, error)

func (*InformPlayerState) Encode

func (m *InformPlayerState) Encode(data []byte) (int, error)

func (*InformPlayerState) EncodeSize

func (*InformPlayerState) EncodeSize() int

func (*InformPlayerState) InformCode

func (*InformPlayerState) InformCode() InformCode

type InformSpell

type InformSpell struct {
	Code InformCode
	Ind  uint32
}

func (*InformSpell) Decode

func (m *InformSpell) Decode(data []byte) (int, error)

func (*InformSpell) Encode

func (m *InformSpell) Encode(data []byte) (int, error)

func (*InformSpell) EncodeSize

func (*InformSpell) EncodeSize() int

func (*InformSpell) InformCode

func (m *InformSpell) InformCode() InformCode

type InformStringID

type InformStringID struct {
	IsSign   byte
	StringID string
}

func (*InformStringID) Decode

func (m *InformStringID) Decode(data []byte) (int, error)

func (*InformStringID) Encode

func (m *InformStringID) Encode(data []byte) (int, error)

func (*InformStringID) EncodeSize

func (m *InformStringID) EncodeSize() int

func (*InformStringID) InformCode

func (*InformStringID) InformCode() InformCode

type InformTeam

type InformTeam struct {
	Code   InformCode
	TeamID uint32
}

func (*InformTeam) Decode

func (m *InformTeam) Decode(data []byte) (int, error)

func (*InformTeam) Encode

func (m *InformTeam) Encode(data []byte) (int, error)

func (*InformTeam) EncodeSize

func (*InformTeam) EncodeSize() int

func (*InformTeam) InformCode

func (m *InformTeam) InformCode() InformCode

type InformTeamPlayer

type InformTeamPlayer struct {
	Code     InformCode
	PlayerID uint32
	TeamID   uint32
}

func (*InformTeamPlayer) Decode

func (m *InformTeamPlayer) Decode(data []byte) (int, error)

func (*InformTeamPlayer) Encode

func (m *InformTeamPlayer) Encode(data []byte) (int, error)

func (*InformTeamPlayer) EncodeSize

func (*InformTeamPlayer) EncodeSize() int

func (*InformTeamPlayer) InformCode

func (m *InformTeamPlayer) InformCode() InformCode

type InformWarpWait

type InformWarpWait struct {
	Stage uint32
}

func (*InformWarpWait) Decode

func (m *InformWarpWait) Decode(data []byte) (int, error)

func (*InformWarpWait) Encode

func (m *InformWarpWait) Encode(data []byte) (int, error)

func (*InformWarpWait) EncodeSize

func (*InformWarpWait) EncodeSize() int

func (*InformWarpWait) InformCode

func (*InformWarpWait) InformCode() InformCode

type Mapper

type Mapper interface {
	NewPlayer(addr netip.AddrPort, cli Player, p Player) (StreamID, error)
	GetPlayer(addr netip.AddrPort, sid StreamID) Player
	GetPlayerPeer(addr netip.AddrPort, cli Player, sid StreamID) Player
	DelPlayer(addr netip.AddrPort, cli Player, sid StreamID) bool
}

func NewMapper

func NewMapper() Mapper

type Message

type Message interface {
	NetOp() Op
	Encoded
}

func DecodeAnyPacket

func DecodeAnyPacket(data []byte) (Message, int, error)

type MsgAccept

type MsgAccept struct {
	ID byte
}

func (*MsgAccept) Decode

func (p *MsgAccept) Decode(data []byte) (int, error)

func (*MsgAccept) Encode

func (p *MsgAccept) Encode(data []byte) (int, error)

func (*MsgAccept) EncodeSize

func (*MsgAccept) EncodeSize() int

func (*MsgAccept) NetOp

func (*MsgAccept) NetOp() Op

type MsgClientAccept

type MsgClientAccept struct {
	PlayerName  string // 0-65
	PlayerClass byte   // 66
	IsFemale    byte   // 67
	Unk70       [29]byte
	Screen      image.Point // 97-104
	Serial      string      // 105-126
	Unk129      [26]byte
}

func (*MsgClientAccept) Decode

func (p *MsgClientAccept) Decode(data []byte) (int, error)

func (*MsgClientAccept) Encode

func (p *MsgClientAccept) Encode(data []byte) (int, error)

func (*MsgClientAccept) EncodeSize

func (*MsgClientAccept) EncodeSize() int

func (*MsgClientAccept) NetOp

func (*MsgClientAccept) NetOp() Op

type MsgClientPing

type MsgClientPing struct {
	T time.Duration // in ms
}

func (*MsgClientPing) Decode

func (m *MsgClientPing) Decode(data []byte) (int, error)

func (*MsgClientPing) Encode

func (m *MsgClientPing) Encode(data []byte) (int, error)

func (*MsgClientPing) EncodeSize

func (*MsgClientPing) EncodeSize() int

func (*MsgClientPing) NetOp

func (*MsgClientPing) NetOp() Op

func (*MsgClientPing) Pong

func (m *MsgClientPing) Pong() *MsgClientPong

type MsgClientPong

type MsgClientPong struct {
	T time.Duration // in ms
}

func (*MsgClientPong) Decode

func (m *MsgClientPong) Decode(data []byte) (int, error)

func (*MsgClientPong) Encode

func (m *MsgClientPong) Encode(data []byte) (int, error)

func (*MsgClientPong) EncodeSize

func (*MsgClientPong) EncodeSize() int

func (*MsgClientPong) NetOp

func (*MsgClientPong) NetOp() Op

type MsgConnect

type MsgConnect struct {
}

func (*MsgConnect) Decode

func (p *MsgConnect) Decode(data []byte) (int, error)

func (*MsgConnect) Encode

func (p *MsgConnect) Encode(data []byte) (int, error)

func (*MsgConnect) EncodeSize

func (*MsgConnect) EncodeSize() int

func (*MsgConnect) NetOp

func (*MsgConnect) NetOp() Op

type MsgDiscover

type MsgDiscover struct {
	Unk0  [5]byte
	Token uint32
}

func (*MsgDiscover) Decode

func (p *MsgDiscover) Decode(data []byte) (int, error)

func (*MsgDiscover) Encode

func (p *MsgDiscover) Encode(data []byte) (int, error)

func (*MsgDiscover) EncodeSize

func (*MsgDiscover) EncodeSize() int

func (*MsgDiscover) NetOp

func (*MsgDiscover) NetOp() Op

type MsgFadeBegin

type MsgFadeBegin struct {
	Out  byte
	Menu byte
}

func (*MsgFadeBegin) Decode

func (p *MsgFadeBegin) Decode(data []byte) (int, error)

func (*MsgFadeBegin) Encode

func (p *MsgFadeBegin) Encode(data []byte) (int, error)

func (*MsgFadeBegin) EncodeSize

func (*MsgFadeBegin) EncodeSize() int

func (*MsgFadeBegin) NetOp

func (*MsgFadeBegin) NetOp() Op

type MsgFullTimestamp

type MsgFullTimestamp struct {
	T Timestamp
}

func (*MsgFullTimestamp) Decode

func (m *MsgFullTimestamp) Decode(data []byte) (int, error)

func (*MsgFullTimestamp) Encode

func (m *MsgFullTimestamp) Encode(data []byte) (int, error)

func (*MsgFullTimestamp) EncodeSize

func (*MsgFullTimestamp) EncodeSize() int

func (*MsgFullTimestamp) NetOp

func (*MsgFullTimestamp) NetOp() Op

type MsgFxJiggle

type MsgFxJiggle struct {
	Val byte
}

func (*MsgFxJiggle) Decode

func (p *MsgFxJiggle) Decode(data []byte) (int, error)

func (*MsgFxJiggle) Encode

func (p *MsgFxJiggle) Encode(data []byte) (int, error)

func (*MsgFxJiggle) EncodeSize

func (*MsgFxJiggle) EncodeSize() int

func (*MsgFxJiggle) NetOp

func (*MsgFxJiggle) NetOp() Op

type MsgImportant

type MsgImportant struct {
	ID uint32
}

func (*MsgImportant) Decode

func (m *MsgImportant) Decode(data []byte) (int, error)

func (*MsgImportant) Encode

func (m *MsgImportant) Encode(data []byte) (int, error)

func (*MsgImportant) EncodeSize

func (*MsgImportant) EncodeSize() int

func (*MsgImportant) NetOp

func (*MsgImportant) NetOp() Op

type MsgImportantAck

type MsgImportantAck struct {
	ID uint32
}

func (*MsgImportantAck) Decode

func (m *MsgImportantAck) Decode(data []byte) (int, error)

func (*MsgImportantAck) Encode

func (m *MsgImportantAck) Encode(data []byte) (int, error)

func (*MsgImportantAck) EncodeSize

func (*MsgImportantAck) EncodeSize() int

func (*MsgImportantAck) NetOp

func (*MsgImportantAck) NetOp() Op

type MsgInform

type MsgInform struct {
	Inform Inform
}

func (*MsgInform) Decode

func (m *MsgInform) Decode(data []byte) (int, error)

func (*MsgInform) Encode

func (m *MsgInform) Encode(data []byte) (int, error)

func (*MsgInform) EncodeSize

func (m *MsgInform) EncodeSize() int

func (*MsgInform) NetOp

func (*MsgInform) NetOp() Op

type MsgJoinData

type MsgJoinData struct {
	NetCode uint16
	Unk2    uint32
}

func (*MsgJoinData) Decode

func (m *MsgJoinData) Decode(data []byte) (int, error)

func (*MsgJoinData) Encode

func (m *MsgJoinData) Encode(data []byte) (int, error)

func (*MsgJoinData) EncodeSize

func (*MsgJoinData) EncodeSize() int

func (*MsgJoinData) NetOp

func (*MsgJoinData) NetOp() Op

type MsgJoinFailed

type MsgJoinFailed struct {
}

func (*MsgJoinFailed) Decode

func (p *MsgJoinFailed) Decode(data []byte) (int, error)

func (*MsgJoinFailed) Encode

func (p *MsgJoinFailed) Encode(data []byte) (int, error)

func (*MsgJoinFailed) EncodeSize

func (*MsgJoinFailed) EncodeSize() int

func (*MsgJoinFailed) Error

func (*MsgJoinFailed) Error() error

func (*MsgJoinFailed) NetOp

func (*MsgJoinFailed) NetOp() Op

type MsgJoinOK

type MsgJoinOK struct {
}

func (*MsgJoinOK) Decode

func (p *MsgJoinOK) Decode(data []byte) (int, error)

func (*MsgJoinOK) Encode

func (p *MsgJoinOK) Encode(data []byte) (int, error)

func (*MsgJoinOK) EncodeSize

func (*MsgJoinOK) EncodeSize() int

func (*MsgJoinOK) NetOp

func (*MsgJoinOK) NetOp() Op

type MsgKeepAlive

type MsgKeepAlive struct {
}

func (*MsgKeepAlive) Decode

func (m *MsgKeepAlive) Decode(data []byte) (int, error)

func (*MsgKeepAlive) Encode

func (m *MsgKeepAlive) Encode(data []byte) (int, error)

func (*MsgKeepAlive) EncodeSize

func (*MsgKeepAlive) EncodeSize() int

func (*MsgKeepAlive) NetOp

func (*MsgKeepAlive) NetOp() Op

type MsgMapReceived

type MsgMapReceived struct {
}

func (*MsgMapReceived) Decode

func (*MsgMapReceived) Decode(data []byte) (int, error)

func (*MsgMapReceived) Encode

func (*MsgMapReceived) Encode(data []byte) (int, error)

func (*MsgMapReceived) EncodeSize

func (*MsgMapReceived) EncodeSize() int

func (*MsgMapReceived) NetOp

func (*MsgMapReceived) NetOp() Op

type MsgMapSendAbort

type MsgMapSendAbort struct {
	Code byte
}

func (*MsgMapSendAbort) Decode

func (p *MsgMapSendAbort) Decode(data []byte) (int, error)

func (*MsgMapSendAbort) Encode

func (p *MsgMapSendAbort) Encode(data []byte) (int, error)

func (*MsgMapSendAbort) EncodeSize

func (*MsgMapSendAbort) EncodeSize() int

func (*MsgMapSendAbort) NetOp

func (*MsgMapSendAbort) NetOp() Op

type MsgMapSendPacket

type MsgMapSendPacket struct {
	Unk   byte
	Block uint16
	Data  []byte
}

func (*MsgMapSendPacket) Decode

func (p *MsgMapSendPacket) Decode(data []byte) (int, error)

func (*MsgMapSendPacket) Encode

func (p *MsgMapSendPacket) Encode(data []byte) (int, error)

func (*MsgMapSendPacket) EncodeSize

func (p *MsgMapSendPacket) EncodeSize() int

func (*MsgMapSendPacket) NetOp

func (*MsgMapSendPacket) NetOp() Op

type MsgMapSendStart

type MsgMapSendStart struct {
	Unk1    [3]byte
	MapSize uint32
	MapName binenc.String
}

func (*MsgMapSendStart) Decode

func (p *MsgMapSendStart) Decode(data []byte) (int, error)

func (*MsgMapSendStart) Encode

func (p *MsgMapSendStart) Encode(data []byte) (int, error)

func (*MsgMapSendStart) EncodeSize

func (*MsgMapSendStart) EncodeSize() int

func (*MsgMapSendStart) NetOp

func (*MsgMapSendStart) NetOp() Op

type MsgMouse

type MsgMouse struct {
	X, Y uint16
}

func (*MsgMouse) Decode

func (m *MsgMouse) Decode(data []byte) (int, error)

func (*MsgMouse) Encode

func (m *MsgMouse) Encode(data []byte) (int, error)

func (*MsgMouse) EncodeSize

func (*MsgMouse) EncodeSize() int

func (*MsgMouse) NetOp

func (*MsgMouse) NetOp() Op

type MsgNewAlias

type MsgNewAlias struct {
	Alias    UpdateAlias
	ID       UpdateObjectID
	Deadline Timestamp
}

func (*MsgNewAlias) Decode

func (m *MsgNewAlias) Decode(data []byte) (int, error)

func (*MsgNewAlias) Encode

func (m *MsgNewAlias) Encode(data []byte) (int, error)

func (*MsgNewAlias) EncodeSize

func (*MsgNewAlias) EncodeSize() int

func (*MsgNewAlias) NetOp

func (*MsgNewAlias) NetOp() Op

type MsgPasswordRequired

type MsgPasswordRequired struct {
}

func (*MsgPasswordRequired) Decode

func (p *MsgPasswordRequired) Decode(data []byte) (int, error)

func (*MsgPasswordRequired) Encode

func (p *MsgPasswordRequired) Encode(data []byte) (int, error)

func (*MsgPasswordRequired) EncodeSize

func (*MsgPasswordRequired) EncodeSize() int

func (*MsgPasswordRequired) Error

func (*MsgPasswordRequired) Error() error

func (*MsgPasswordRequired) NetOp

func (*MsgPasswordRequired) NetOp() Op

type MsgPlayerInput

type MsgPlayerInput struct {
	Inputs []PlayerInput
}

func (*MsgPlayerInput) Decode

func (m *MsgPlayerInput) Decode(data []byte) (int, error)

func (*MsgPlayerInput) Encode

func (m *MsgPlayerInput) Encode(data []byte) (int, error)

func (*MsgPlayerInput) EncodeSize

func (m *MsgPlayerInput) EncodeSize() int

func (*MsgPlayerInput) NetOp

func (*MsgPlayerInput) NetOp() Op

type MsgRateChange

type MsgRateChange struct {
	Rate byte
}

func (*MsgRateChange) Decode

func (p *MsgRateChange) Decode(data []byte) (int, error)

func (*MsgRateChange) Encode

func (p *MsgRateChange) Encode(data []byte) (int, error)

func (*MsgRateChange) EncodeSize

func (*MsgRateChange) EncodeSize() int

func (*MsgRateChange) NetOp

func (*MsgRateChange) NetOp() Op

type MsgServerAccept

type MsgServerAccept struct {
	ID     uint32
	XorKey byte
}

func (*MsgServerAccept) Decode

func (p *MsgServerAccept) Decode(data []byte) (int, error)

func (*MsgServerAccept) Encode

func (p *MsgServerAccept) Encode(data []byte) (int, error)

func (*MsgServerAccept) EncodeSize

func (*MsgServerAccept) EncodeSize() int

func (*MsgServerAccept) NetOp

func (*MsgServerAccept) NetOp() Op

type MsgServerCmd

type MsgServerCmd struct {
	ID      byte
	NetCode uint16
	Cmd     string
}

func (*MsgServerCmd) Decode

func (p *MsgServerCmd) Decode(data []byte) (int, error)

func (*MsgServerCmd) Encode

func (p *MsgServerCmd) Encode(data []byte) (int, error)

func (*MsgServerCmd) EncodeSize

func (p *MsgServerCmd) EncodeSize() int

func (*MsgServerCmd) NetOp

func (*MsgServerCmd) NetOp() Op

type MsgServerError

type MsgServerError struct {
	Err ConnectError
}

func (*MsgServerError) Decode

func (p *MsgServerError) Decode(data []byte) (int, error)

func (*MsgServerError) Encode

func (p *MsgServerError) Encode(data []byte) (int, error)

func (*MsgServerError) EncodeSize

func (*MsgServerError) EncodeSize() int

func (*MsgServerError) Error

func (p *MsgServerError) Error() error

func (*MsgServerError) NetOp

func (*MsgServerError) NetOp() Op

type MsgServerInfo

type MsgServerInfo struct {
	PlayersCur byte     // 0
	PlayersMax byte     // 1
	Unk2       [5]byte  // 2-6
	MapName    string   // 7-15
	Status1    byte     // 16
	Status2    byte     // 17
	Unk19      [7]byte  // 18-24
	Flags      uint16   // 25-26
	Unk27      [2]byte  // 27-28
	Unk29      [8]byte  // 29-36
	Unk37      [4]byte  // 37-40
	Token      uint32   // 41-44
	Unk45      [20]byte // 45-64
	Unk65      [4]byte  // 65-68
	ServerName string   // 69+
}

func (*MsgServerInfo) Decode

func (p *MsgServerInfo) Decode(data []byte) (int, error)

func (*MsgServerInfo) Encode

func (p *MsgServerInfo) Encode(data []byte) (int, error)

func (*MsgServerInfo) EncodeSize

func (p *MsgServerInfo) EncodeSize() int

func (*MsgServerInfo) NetOp

func (*MsgServerInfo) NetOp() Op

type MsgServerPass

type MsgServerPass struct {
	Unk0 byte   // 0
	Pass string // 1-19
}

func (*MsgServerPass) Decode

func (p *MsgServerPass) Decode(data []byte) (int, error)

func (*MsgServerPass) Encode

func (p *MsgServerPass) Encode(data []byte) (int, error)

func (*MsgServerPass) EncodeSize

func (*MsgServerPass) EncodeSize() int

func (*MsgServerPass) NetOp

func (*MsgServerPass) NetOp() Op

type MsgServerPing

type MsgServerPing struct {
	Ind byte
	T   time.Duration // in ms
}

func (*MsgServerPing) Decode

func (m *MsgServerPing) Decode(data []byte) (int, error)

func (*MsgServerPing) Encode

func (m *MsgServerPing) Encode(data []byte) (int, error)

func (*MsgServerPing) EncodeSize

func (*MsgServerPing) EncodeSize() int

func (*MsgServerPing) NetOp

func (*MsgServerPing) NetOp() Op

func (*MsgServerPing) Pong

func (m *MsgServerPing) Pong() *MsgServerPong

type MsgServerPong

type MsgServerPong struct {
	Ind byte
	T   time.Duration // in ms
}

func (*MsgServerPong) Decode

func (m *MsgServerPong) Decode(data []byte) (int, error)

func (*MsgServerPong) Encode

func (m *MsgServerPong) Encode(data []byte) (int, error)

func (*MsgServerPong) EncodeSize

func (*MsgServerPong) EncodeSize() int

func (*MsgServerPong) NetOp

func (*MsgServerPong) NetOp() Op

type MsgServerTryJoin

type MsgServerTryJoin struct {
	Unk0        byte     // 0
	PlayerName  string   // 1-50
	PlayerClass byte     // 51
	PlayerLevel byte     // 52
	Serial      string   // 53-76
	Version     uint32   // 77-80
	Team        uint32   // 81-84
	Unk85       [10]byte // 85-88
	Unk95       byte     // 95
	Unk96       byte     // 96
}

func (*MsgServerTryJoin) Decode

func (p *MsgServerTryJoin) Decode(data []byte) (int, error)

func (*MsgServerTryJoin) Encode

func (p *MsgServerTryJoin) Encode(data []byte) (int, error)

func (*MsgServerTryJoin) EncodeSize

func (*MsgServerTryJoin) EncodeSize() int

func (*MsgServerTryJoin) NetOp

func (*MsgServerTryJoin) NetOp() Op

type MsgSpeed

type MsgSpeed struct {
	Speed int32 // 256 KB / T ms (or -1)
}

func (*MsgSpeed) Decode

func (m *MsgSpeed) Decode(data []byte) (int, error)

func (*MsgSpeed) Encode

func (m *MsgSpeed) Encode(data []byte) (int, error)

func (*MsgSpeed) EncodeSize

func (*MsgSpeed) EncodeSize() int

func (*MsgSpeed) NetOp

func (*MsgSpeed) NetOp() Op

type MsgStatMult

type MsgStatMult struct {
	Health   float32
	Mana     float32
	Speed    float32
	Strength float32
}

func (*MsgStatMult) Decode

func (p *MsgStatMult) Decode(data []byte) (int, error)

func (*MsgStatMult) Encode

func (p *MsgStatMult) Encode(data []byte) (int, error)

func (*MsgStatMult) EncodeSize

func (*MsgStatMult) EncodeSize() int

func (*MsgStatMult) NetOp

func (*MsgStatMult) NetOp() Op

type MsgText

type MsgText struct {
	NetCode uint16
	Flags   TextFlags
	PosX    uint16
	PosY    uint16
	Size    byte
	Dur     uint16
	Data    []byte // max: 510
}

func (*MsgText) Decode

func (p *MsgText) Decode(data []byte) (int, error)

func (*MsgText) Encode

func (p *MsgText) Encode(data []byte) (int, error)

func (*MsgText) EncodeSize

func (p *MsgText) EncodeSize() int

func (*MsgText) NetOp

func (*MsgText) NetOp() Op

func (*MsgText) Payload

func (p *MsgText) Payload() []byte

func (*MsgText) Text

func (p *MsgText) Text() string

type MsgTimestamp

type MsgTimestamp struct {
	T uint16
}

func (*MsgTimestamp) Decode

func (m *MsgTimestamp) Decode(data []byte) (int, error)

func (*MsgTimestamp) Encode

func (m *MsgTimestamp) Encode(data []byte) (int, error)

func (*MsgTimestamp) EncodeSize

func (*MsgTimestamp) EncodeSize() int

func (*MsgTimestamp) NetOp

func (*MsgTimestamp) NetOp() Op

type MsgUnknown

type MsgUnknown struct {
	Op   Op
	Data []byte
}

func (*MsgUnknown) Decode

func (p *MsgUnknown) Decode(data []byte) (int, error)

func (*MsgUnknown) Encode

func (p *MsgUnknown) Encode(data []byte) (int, error)

func (*MsgUnknown) EncodeSize

func (p *MsgUnknown) EncodeSize() int

func (*MsgUnknown) NetOp

func (p *MsgUnknown) NetOp() Op

type MsgUpdateStream

type MsgUpdateStream struct {
	ID      UpdateID
	Pos     image.Point
	Flags   byte
	Unk4    byte // anim frame?
	Unk5    byte
	Objects []ObjectUpdate
}

func (*MsgUpdateStream) Decode

func (p *MsgUpdateStream) Decode(data []byte) (int, error)

func (*MsgUpdateStream) Encode

func (p *MsgUpdateStream) Encode(data []byte) (int, error)

func (*MsgUpdateStream) EncodeSize

func (*MsgUpdateStream) EncodeSize() int

func (*MsgUpdateStream) NetOp

func (*MsgUpdateStream) NetOp() Op

type MsgUseMap

type MsgUseMap struct {
	MapName binenc.String
	CRC     uint32
	T       Timestamp
}

func (*MsgUseMap) Decode

func (m *MsgUseMap) Decode(data []byte) (int, error)

func (*MsgUseMap) Encode

func (m *MsgUseMap) Encode(data []byte) (int, error)

func (*MsgUseMap) EncodeSize

func (*MsgUseMap) EncodeSize() int

func (*MsgUseMap) NetOp

func (*MsgUseMap) NetOp() Op

type MsgWallDestroy

type MsgWallDestroy struct {
	ID uint16
}

func (*MsgWallDestroy) Decode

func (p *MsgWallDestroy) Decode(data []byte) (int, error)

func (*MsgWallDestroy) Encode

func (p *MsgWallDestroy) Encode(data []byte) (int, error)

func (*MsgWallDestroy) EncodeSize

func (*MsgWallDestroy) EncodeSize() int

func (*MsgWallDestroy) NetOp

func (*MsgWallDestroy) NetOp() Op

type MsgXfer

type MsgXfer struct {
	Msg netxfer.Msg
}

func (*MsgXfer) Decode

func (m *MsgXfer) Decode(data []byte) (int, error)

func (*MsgXfer) Encode

func (m *MsgXfer) Encode(data []byte) (int, error)

func (*MsgXfer) EncodeSize

func (m *MsgXfer) EncodeSize() int

func (*MsgXfer) NetOp

func (*MsgXfer) NetOp() Op

type ObjectUpdate

type ObjectUpdate struct {
	ID      UpdateID
	Pos     image.Point
	Complex *ComplexObjectUpdate
}

func (*ObjectUpdate) Decode

func (p *ObjectUpdate) Decode(data []byte, par image.Point) (int, error)

type OnMessageFunc

type OnMessageFunc func(conn *Conn, sid StreamID, m Message) bool

type Op

type Op byte

func (Op) Len

func (op Op) Len() int

func (Op) String

func (i Op) String() string

type PacketConn

type PacketConn interface {
	LocalAddr() net.Addr
	WriteToUDPAddrPort(b []byte, addr netip.AddrPort) (int, error)
	ReadFromUDPAddrPort(b []byte) (int, netip.AddrPort, error)
	Close() error
}

type PacketID

type PacketID uintptr

type PipeConn

type PipeConn struct {
	Log   *slog.Logger
	Addr  netip.AddrPort
	Port  *Port
	Drop  func(data []byte) bool
	Debug bool
	// contains filtered or unexported fields
}

func (*PipeConn) Close

func (c *PipeConn) Close() error

func (*PipeConn) LocalAddr

func (c *PipeConn) LocalAddr() net.Addr

func (*PipeConn) ReadFromUDPAddrPort

func (c *PipeConn) ReadFromUDPAddrPort(data []byte) (int, netip.AddrPort, error)

func (*PipeConn) WriteToUDPAddrPort

func (c *PipeConn) WriteToUDPAddrPort(data []byte, addr netip.AddrPort) (int, error)

type Player

type Player interface {
	PlayerID() PlayerID
	PlayerName() string
	Disconnect()
}

type PlayerID

type PlayerID uint32

type PlayerInput

type PlayerInput interface {
	CtrlCode() CtrlCode
	Encoded
}

type PlayerInput0

type PlayerInput0 struct {
	Code CtrlCode
}

func (*PlayerInput0) CtrlCode

func (p *PlayerInput0) CtrlCode() CtrlCode

func (*PlayerInput0) Decode

func (*PlayerInput0) Decode(data []byte) (int, error)

func (*PlayerInput0) Encode

func (*PlayerInput0) Encode(data []byte) (int, error)

func (*PlayerInput0) EncodeSize

func (*PlayerInput0) EncodeSize() int

type PlayerInput1

type PlayerInput1 struct {
	Code CtrlCode
	Val  byte
}

func (*PlayerInput1) CtrlCode

func (p *PlayerInput1) CtrlCode() CtrlCode

func (*PlayerInput1) Decode

func (p *PlayerInput1) Decode(data []byte) (int, error)

func (*PlayerInput1) Encode

func (p *PlayerInput1) Encode(data []byte) (int, error)

func (*PlayerInput1) EncodeSize

func (*PlayerInput1) EncodeSize() int

type PlayerInput4

type PlayerInput4 struct {
	Code CtrlCode
	Val  uint32
}

func (*PlayerInput4) CtrlCode

func (p *PlayerInput4) CtrlCode() CtrlCode

func (*PlayerInput4) Decode

func (p *PlayerInput4) Decode(data []byte) (int, error)

func (*PlayerInput4) Encode

func (p *PlayerInput4) Encode(data []byte) (int, error)

func (*PlayerInput4) EncodeSize

func (*PlayerInput4) EncodeSize() int

type Port

type Port struct {
	OnConn func(c *Conn) bool
	// contains filtered or unexported fields
}

func NewPort

func NewPort(log *slog.Logger, conn PacketConn, isServer bool) *Port

func (*Port) BroadcastMsg

func (p *Port) BroadcastMsg(port int, m Message) error

func (*Port) Close

func (p *Port) Close()

func (*Port) Conn

func (p *Port) Conn(addr netip.AddrPort) *Conn

func (*Port) LocalAddr

func (p *Port) LocalAddr() netip.AddrPort

func (*Port) OnMessage

func (p *Port) OnMessage(fnc OnMessageFunc)

func (*Port) Reset

func (p *Port) Reset()

func (*Port) Start

func (p *Port) Start()

func (*Port) WriteMsg

func (p *Port) WriteMsg(addr netip.AddrPort, b1, b2 byte, m Message, xor byte) error

type Server

type Server struct {
	Port *Port
	// contains filtered or unexported fields
}

func NewServer

func NewServer(log *slog.Logger, conn PacketConn, e Engine, opts *ServerOptions) *Server

func NewServerWithPort

func NewServerWithPort(log *slog.Logger, port *Port, e Engine, opts *ServerOptions) *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) LocalAddr

func (s *Server) LocalAddr() netip.AddrPort

func (*Server) Reset

func (s *Server) Reset()

type ServerInfoResp

type ServerInfoResp struct {
	Addr netip.AddrPort
	Info MsgServerInfo
}

type ServerOptions

type ServerOptions struct {
	PlayerMap Mapper
	NoXor     bool
}

type Stream

type Stream struct {
	// contains filtered or unexported fields
}

func (*Stream) Addr

func (p *Stream) Addr() netip.AddrPort

func (*Stream) CancelReliable

func (p *Stream) CancelReliable(id PacketID)

func (*Stream) Conn

func (p *Stream) Conn() *Conn

func (*Stream) OnMessage

func (p *Stream) OnMessage(fnc OnMessageFunc)

func (*Stream) QueueReliable

func (p *Stream) QueueReliable(ctx context.Context, data []byte, done, timeout func()) PacketID

func (*Stream) QueueReliableMsg

func (p *Stream) QueueReliableMsg(ctx context.Context, arr []Message, done, timeout func()) (PacketID, error)

func (*Stream) Reset

func (p *Stream) Reset()

func (*Stream) SID

func (p *Stream) SID() StreamID

func (*Stream) SendQueue

func (p *Stream) SendQueue() error

func (*Stream) SendReliable

func (p *Stream) SendReliable(ctx context.Context, data []byte) error

func (*Stream) SendReliableMsg

func (p *Stream) SendReliableMsg(ctx context.Context, m Message) error

func (*Stream) SendUnreliable

func (p *Stream) SendUnreliable(data []byte) error

func (*Stream) SendUnreliableMsg

func (p *Stream) SendUnreliableMsg(m Message) error

type StreamID

type StreamID byte

type TextFlags

type TextFlags byte

func (TextFlags) Has

func (f TextFlags) Has(f2 TextFlags) bool

type Timestamp

type Timestamp uint32

func (Timestamp) Dur

func (t Timestamp) Dur(fps int) time.Duration

func (*Timestamp) Set

func (t *Timestamp) Set(v Timestamp)

func (*Timestamp) Set16

func (t *Timestamp) Set16(v uint16)

type UpdateAlias

type UpdateAlias byte

type UpdateID

type UpdateID interface {
	// contains filtered or unexported methods
}

type UpdateObjectID

type UpdateObjectID struct {
	ID   uint16
	Type uint16
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL