From 01f14566861d5f3683265c9230c107d3fa32564d Mon Sep 17 00:00:00 2001 From: John Chadwick Date: Sun, 11 Jun 2023 23:08:36 -0400 Subject: [PATCH] Incremental improvements. --- game/conn.go | 102 +++++++++++++++++++--------- game/msgclient.go | 7 ++ game/msgserver.go | 154 +++++++++++++++++++++++------------------- pangya/iff/generic.go | 20 +++--- pangya/iff/item.go | 18 ++--- web/ui.go | 1 + 6 files changed, 183 insertions(+), 119 deletions(-) diff --git a/game/conn.go b/game/conn.go index 3d30e2f..d3fc77e 100755 --- a/game/conn.go +++ b/game/conn.go @@ -232,10 +232,11 @@ func (c *Conn) Handle(ctx context.Context) error { self := RoomListUser{ ConnID: uint32(session.SessionID), Nickname: player.Nickname.String, + Rank: uint8(player.Rank), GuildName: "", Slot: 1, CharTypeID: playerGameData.EquippedCharacter.CharTypeID, - Flag2: 520, // ? + Flag2: 520, GuildEmblemImage: "guildmark", UserID: uint32(player.PlayerID), CharacterData: playerGameData.EquippedCharacter, @@ -244,9 +245,11 @@ func (c *Conn) Handle(ctx context.Context) error { ConnID: 0xFEEE, Nickname: "other", GuildName: "", + PortraitSlotID: 0x38C00083, + Rank: uint8(pangya.JuniorA), Slot: 2, - CharTypeID: 0x04000005, - Flag2: 520, + CharTypeID: 0x04000007, + Flag2: 0, GuildEmblemImage: "guildmark", UserID: 0x2000, CharacterData: pangya.PlayerCharacterData{ @@ -270,39 +273,47 @@ func (c *Conn) Handle(ctx context.Context) error { case *ClientAssistModeToggle: c.SendMessage(&ServerAssistModeToggled{}) // TODO: Should send user status update; need to look at packet dumps. - case *ClientPlayerReady: + case *ClientPlayerReady, *ClientPlayerStartGame: c.SendMessage(&Server0230{}) c.SendMessage(&Server0231{}) + c.SendRaw([]byte{0x77, 0x00, 0x64, 0x00, 0x00, 0x00}) c.SendMessage(&ServerGameInit{ - NumPlayers: 2, - Players: []GamePlayer{ - { - Number: 1, - Info: PlayerInfo{ - Username: player.Username, - Nickname: player.Nickname.String, + SubType: GameInitTypeFull, + Full: &GameInitFull{ + NumPlayers: 2, + Players: []GamePlayer{ + { + Number: 1, + Info: PlayerInfo{ + Username: player.Username, + Nickname: player.Nickname.String, + ConnID: uint32(session.SessionID), + UserID: uint32(player.PlayerID), + }, + Stats: PlayerStats{}, + Character: playerGameData.EquippedCharacter, + Caddie: playerGameData.EquippedCaddie, + ClubSet: playerGameData.EquippedClub, + Mascot: playerGameData.EquippedMascot, + StartTime: pangya.SystemTime{}, + NumCards: 0, }, - Game: PlayerGameInfo{}, - Character: playerGameData.EquippedCharacter, - Caddie: playerGameData.EquippedCaddie, - ClubSet: playerGameData.EquippedClub, - Mascot: playerGameData.EquippedMascot, - StartTime: pangya.SystemTime{}, - NumCards: 0, - }, - { - Number: 2, - Info: PlayerInfo{ - Username: "otheru", - Nickname: "other", + { + Number: 2, + Info: PlayerInfo{ + Username: "otheru", + Nickname: "other", + ConnID: uint32(0xFEEE), + UserID: uint32(0x2000), + }, + Stats: PlayerStats{}, + Character: playerGameData.EquippedCharacter, + Caddie: playerGameData.EquippedCaddie, + ClubSet: playerGameData.EquippedClub, + Mascot: playerGameData.EquippedMascot, + StartTime: pangya.SystemTime{}, + NumCards: 0, }, - Game: PlayerGameInfo{}, - Character: playerGameData.EquippedCharacter, - Caddie: playerGameData.EquippedCaddie, - ClubSet: playerGameData.EquippedClub, - Mascot: playerGameData.EquippedMascot, - StartTime: pangya.SystemTime{}, - NumCards: 0, }, }, }) @@ -325,6 +336,35 @@ func (c *Conn) Handle(ctx context.Context) error { }) } c.SendMessage(gameData) + /*c.SendMessage(&ServerRoomGameData{ + Course: 11, + Unknown: 0, + HoleProgression: 3, + NumHoles: 3, + Unknown2: 0, + ShotTimerMS: 300000, + GameTimerMS: 0, + Holes: []HoleInfo{ + { + HoleID: 2159514729, + Pin: 0, + Course: 11, + Num: 14, + }, + { + HoleID: 358258534, + Pin: 1, + Course: 11, + Num: 6, + }, + { + HoleID: 3739427069, + Pin: 2, + Course: 11, + Num: 3, + }, + }, + })*/ // (currently crashes...) case *ClientRequestInboxList: // TODO: need new sql message table diff --git a/game/msgclient.go b/game/msgclient.go index fe6a918..aa74b6d 100755 --- a/game/msgclient.go +++ b/game/msgclient.go @@ -32,6 +32,7 @@ var ClientMessageTable = common.NewMessageTable(map[uint16]ClientMessage{ 0x000B: &ClientTutorialStart{}, 0x000C: &ClientRoomUserEquipmentChange{}, 0x000D: &ClientPlayerReady{}, + 0x000E: &ClientPlayerStartGame{}, 0x000F: &ClientRoomLeave{}, 0x001A: &Client001A{}, 0x001D: &ClientBuyItem{}, @@ -146,6 +147,12 @@ type ClientPlayerReady struct { State byte } +// ClientPlayerStartGame +type ClientPlayerStartGame struct { + ClientMessage_ + Unknown uint32 +} + // ClientRoomLeave is sent by the client when leaving a room back to lobby type ClientRoomLeave struct { ClientMessage_ diff --git a/game/msgserver.go b/game/msgserver.go index 24dc8b3..7b1d886 100755 --- a/game/msgserver.go +++ b/game/msgserver.go @@ -47,6 +47,7 @@ var ServerMessageTable = common.NewMessageTable(map[uint16]ServerMessage{ 0x00F6: &ServerMultiplayerLeft{}, 0x010E: &Server010E{}, 0x011F: &ServerTutorialStatus{}, + 0x0158: &ServerPlayerStats{}, 0x01F6: &Server01F6{}, 0x0210: &ServerInboxNotify{}, 0x0211: &ServerInboxList{}, @@ -125,81 +126,70 @@ type ServerCharData struct { type PlayerInfo struct { Username string `struct:"[22]byte"` Nickname string `struct:"[22]byte"` - GuildName string `struct:"[17]byte"` - GuildEmblemImage string `struct:"[12]byte"` - Unknown [71]byte - Flag byte - Unknown2 uint16 - Unknown3 uint16 + GuildName string `struct:"[21]byte"` + GuildEmblemImage string `struct:"[24]byte"` + ConnID uint32 + Unknown [12]byte + Unknown2 uint32 + Unknown3 uint32 Unknown4 uint16 - Unknown5 uint16 + Unknown5 [6]byte Unknown6 [16]byte GlobalID string `struct:"[128]byte"` + UserID uint32 } -type PlayerGameInfo struct { - Stroke uint32 - Putt uint32 - Time uint32 - StrokeTime uint32 - Unknown float32 - Unknown2 uint32 - Unknown3 uint32 - Unknown4 uint32 - Unknown5 uint32 - Unknown6 uint32 - Unknown7 uint32 - Unknown8 uint16 - Unknown9 uint32 - Unknown10 uint32 - Unknown11 uint32 - Unknown12 uint32 - Unknown13 float32 - Unknown14 float32 - Unknown15 uint32 - Level byte - Pang uint64 - Unknown16 uint32 - Unknown17 [6]byte - Unknown18 [5]uint64 - Unknown19 uint64 - Unknown20 uint32 - Unknown21 uint32 - Unknown22 uint32 - Unknown23 uint32 - Unknown24 uint32 - Unknown25 uint32 - Unknown26 uint32 - Unknown27 uint32 - Unknown28 uint32 - Unknown29 uint32 - Unknown30 uint32 - Unknown31 uint32 - Unknown32 uint64 - Unknown33 uint32 - Unknown34 uint32 - Unknown35 uint32 - Unknown36 uint32 - Unknown37 uint32 - Unknown38 uint32 - Unknown39 uint16 - Unknown40 uint32 - Unknown41 uint32 - Unknown42 uint32 - Unknown43 uint32 - Unknown44 uint32 - Unknown45 uint32 - Unknown46 uint32 - Unknown47 uint32 - Unknown48 uint32 - Unknown49 uint16 +type PlayerStats struct { + TotalStrokes uint32 + TotalPutts uint32 + Time uint32 + StrokeTime uint32 + LongestDrive float32 + Unknown1 uint32 + Unknown2 uint32 + Unknown3 uint32 + Unknown4 uint32 + TotalHoles uint32 + Unknown5 uint32 + TotalHIO uint32 + Unknown6 uint16 + Unknown7 uint32 + TotalAlbatross uint32 + Unknown8 uint32 + Unknown9 uint32 + LongestPutt float32 + LongestChip float32 + TotalXP uint32 + Level byte + Pang uint64 + TotalScore int32 + Unknown10 [5]byte + Unknown11 [49]byte + Unknown12 uint32 + Unknown13 uint32 + Unknown14 uint32 + Unknown15 uint32 + Unknown16 uint32 + Unknown17 [16]byte + ComboNum uint32 + ComboDenom uint32 + Unknown18 uint32 + PangBattleTotal int32 + Unknown19 uint32 + Unknown20 uint32 + Unknown21 uint32 + Unknown22 uint32 + Unknown23 uint32 + Unknown24 [10]byte + Unknown25 uint32 + Unknown26 [8]byte } type GamePlayer struct { Number uint16 Info PlayerInfo - Game PlayerGameInfo - Unknown [11430]byte + Stats PlayerStats + Unknown [78]byte Character pangya.PlayerCharacterData Caddie pangya.PlayerCaddieData ClubSet pangya.PlayerClubData @@ -208,13 +198,30 @@ type GamePlayer struct { NumCards uint8 } -type ServerGameInit struct { - ServerMessage_ - Unknown byte +type GameInitFull struct { NumPlayers byte `struct:"sizeof=Players"` Players []GamePlayer } +type GameInitMinimal struct { + Unknown uint32 + Time pangya.SystemTime +} + +type GameInitType byte + +const ( + GameInitTypeFull = 0 + GameInitTypeMinimal = 4 +) + +type ServerGameInit struct { + ServerMessage_ + SubType byte + Full *GameInitFull `struct-if:"SubType == 0"` + Minimal *GameInitMinimal `struct-if:"SubType == 4"` +} + // ServerUserInfo contains requested user information. type ServerUserInfo struct { ServerMessage_ @@ -334,7 +341,7 @@ type ServerRoomList struct { type RoomListUser struct { ConnID uint32 Nickname string `struct:"[22]byte"` - GuildName string `struct:"[20]byte"` + GuildName string `struct:"[17]byte"` Slot uint8 Flag uint32 TitleID uint32 @@ -347,6 +354,7 @@ type RoomListUser struct { SkinUnknown2 uint32 Flag2 uint16 Rank uint8 + UnknownPadding [3]byte Unknown uint8 Unknown2 uint16 GuildID uint32 @@ -523,6 +531,14 @@ type ServerTutorialStatus struct { Unknown [6]byte } +type ServerPlayerStats struct { + ServerMessage_ + + SessionID uint32 + Unknown byte + Stats PlayerStats +} + type Server01F6 struct { ServerMessage_ Unknown []byte diff --git a/pangya/iff/generic.go b/pangya/iff/generic.go index 158044b..7881d6b 100644 --- a/pangya/iff/generic.go +++ b/pangya/iff/generic.go @@ -9,7 +9,7 @@ type Item struct { Active bool ID uint32 Name string - MaxRank byte + Rank byte Icon string Price uint32 DiscountPrice uint32 @@ -36,7 +36,7 @@ func (i ItemV11_78) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -56,7 +56,7 @@ func (i ItemV11_98) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -76,7 +76,7 @@ func (i ItemV11_B0) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -98,7 +98,7 @@ func (i ItemV11_C0) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -120,7 +120,7 @@ func (i ItemV11_D8_1) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -142,7 +142,7 @@ func (i ItemV11_D8_2) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -164,7 +164,7 @@ func (i ItemV13_E0) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -187,7 +187,7 @@ func (i ItemV11_C4) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, @@ -209,7 +209,7 @@ func (i ItemV13_F8) Generic() Item { Active: i.Active, ID: i.ID, Name: i.Name, - MaxRank: i.MaxRank, + Rank: i.Rank, Icon: i.Icon, Price: i.Price, DiscountPrice: i.DiscountPrice, diff --git a/pangya/iff/item.go b/pangya/iff/item.go index 1997e44..85fd326 100644 --- a/pangya/iff/item.go +++ b/pangya/iff/item.go @@ -10,7 +10,7 @@ type ItemV11_78 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[40]byte"` - /* 0x30 */ MaxRank byte + /* 0x30 */ Rank byte /* 0x31 */ Icon string `struct:"[40]byte"` /* 0x59 */ _ [3]byte /* 0x5C */ Price uint32 @@ -31,7 +31,7 @@ type ItemV11_98 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[40]byte"` - /* 0x30 */ MaxRank byte + /* 0x30 */ Rank byte /* 0x31 */ Icon string `struct:"[40]byte"` /* 0x59 */ _ [3]byte /* 0x5C */ Price uint32 @@ -54,7 +54,7 @@ type ItemV11_B0 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[64]byte"` - /* 0x48 */ MaxRank byte + /* 0x48 */ Rank byte /* 0x49 */ Icon string `struct:"[40]byte"` /* 0x71 */ _ [3]byte /* 0x74 */ Price uint32 @@ -77,7 +77,7 @@ type ItemV11_C0 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[40]byte"` - /* 0x30 */ MaxRank byte + /* 0x30 */ Rank byte /* 0x31 */ Icon string `struct:"[40]byte"` /* 0x59 */ _ [3]byte /* 0x5C */ Price uint32 @@ -101,7 +101,7 @@ type ItemV11_D8_1 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[64]byte"` - /* 0x48 */ MaxRank byte + /* 0x48 */ Rank byte /* 0x49 */ Icon string `struct:"[40]byte"` /* 0x71 */ _ [3]byte /* 0x74 */ Price uint32 @@ -125,7 +125,7 @@ type ItemV11_D8_2 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[64]byte"` - /* 0x48 */ MaxRank byte + /* 0x48 */ Rank byte /* 0x49 */ Icon string `struct:"[40]byte"` /* 0x71 */ _ [3]byte /* 0x74 */ Price uint32 @@ -149,7 +149,7 @@ type ItemV11_C4 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[40]byte"` - /* 0x30 */ MaxRank byte + /* 0x30 */ Rank byte /* 0x31 */ Icon string `struct:"[40]byte"` /* 0x59 */ _ [3]byte /* 0x5C */ Price uint32 @@ -174,7 +174,7 @@ type ItemV13_E0 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[40]byte"` - /* 0x30 */ MaxRank byte + /* 0x30 */ Rank byte /* 0x31 */ Icon string `struct:"[40]byte"` /* 0x59 */ _ [3]byte /* 0x5C */ Price uint32 @@ -200,7 +200,7 @@ type ItemV13_F8 struct { /* 0x01 */ _ [3]byte /* 0x04 */ ID uint32 /* 0x08 */ Name string `struct:"[64]byte"` - /* 0x48 */ MaxRank byte + /* 0x48 */ Rank byte /* 0x49 */ Icon string `struct:"[40]byte"` /* 0x71 */ _ [3]byte /* 0x74 */ Price uint32 diff --git a/web/ui.go b/web/ui.go index 8b98a3f..3f45e72 100644 --- a/web/ui.go +++ b/web/ui.go @@ -89,6 +89,7 @@ func (l *Handler) handleRegisterPost(w http.ResponseWriter, r *http.Request, _ h } // The client will MD5 the password before sending it. + // TODO: only US passwordMD5 := md5.Sum([]byte(password)) passwordMD5Hex := strings.ToUpper(hex.EncodeToString(passwordMD5[:]))