move models into model folder. Some models not moved due to local type.

This commit is contained in:
stratic-dev
2024-10-17 02:09:32 +01:00
parent e9ae953993
commit b6f24ae22d
32 changed files with 790 additions and 748 deletions

View File

@@ -0,0 +1,11 @@
package model
type Achievement struct {
Level uint8
Value uint32
NextValue uint16
Required uint32
Updated bool
Progress uint32
Trophy uint8
}

12
internal/model/airou.go Normal file
View File

@@ -0,0 +1,12 @@
package model
type Airou struct {
ID uint32
Name []byte
Task uint8
Personality uint8
Class uint8
Experience uint32
WeaponType uint8
WeaponID uint16
}

10
internal/model/cafe.go Normal file
View File

@@ -0,0 +1,10 @@
package model
type CafeBonus struct {
ID uint32 `db:"id"`
TimeReq uint32 `db:"time_req"`
ItemType uint32 `db:"item_type"`
ItemID uint32 `db:"item_id"`
Quantity uint32 `db:"quantity"`
Claimed bool `db:"claimed"`
}

View File

@@ -0,0 +1,41 @@
package model
import "time"
type CampaignEvent struct {
ID uint32
Unk0 uint32
MinHR int16
MaxHR int16
MinSR int16
MaxSR int16
MinGR int16
MaxGR int16
Unk1 uint16
Unk2 uint8
Unk3 uint8
Unk4 uint16
Unk5 uint16
Start time.Time
End time.Time
Unk6 uint8
String0 string
String1 string
String2 string
String3 string
Link string
Prefix string
Categories []uint16
}
type CampaignCategory struct {
ID uint16
Type uint8
Title string
Description string
}
type CampaignLink struct {
CategoryID uint16
CampaignID uint32
}

View File

@@ -0,0 +1,27 @@
package model
import "time"
type Distribution struct {
ID uint32 `db:"id"`
Deadline time.Time `db:"deadline"`
Rights uint32 `db:"rights"`
TimesAcceptable uint16 `db:"times_acceptable"`
TimesAccepted uint16 `db:"times_accepted"`
MinHR int16 `db:"min_hr"`
MaxHR int16 `db:"max_hr"`
MinSR int16 `db:"min_sr"`
MaxSR int16 `db:"max_sr"`
MinGR int16 `db:"min_gr"`
MaxGR int16 `db:"max_gr"`
EventName string `db:"event_name"`
Description string `db:"description"`
Selection bool `db:"selection"`
}
type DistributionItem struct {
ItemType uint8 `db:"item_type"`
ID uint32 `db:"id"`
ItemID uint32 `db:"item_id"`
Quantity uint32 `db:"quantity"`
}

31
internal/model/event.go Normal file
View File

@@ -0,0 +1,31 @@
package model
import "time"
type Event struct {
EventType uint16
Unk1 uint16
Unk2 uint16
Unk3 uint16
Unk4 uint16
Unk5 uint32
Unk6 uint32
QuestFileIDs []uint16
}
type LoginBoost struct {
WeekReq uint8 `db:"week_req"`
WeekCount uint8
Active bool
Expiration time.Time `db:"expiration"`
Reset time.Time `db:"reset"`
}
type ActiveFeature struct {
StartTime time.Time `db:"start_time"`
ActiveFeatures uint32 `db:"featured"`
}
type TrendWeapon struct {
WeaponType uint8
WeaponID uint16
}

32
internal/model/festa.go Normal file
View File

@@ -0,0 +1,32 @@
package model
type FestaTrial struct {
ID uint32 `db:"id"`
Objective uint16 `db:"objective"`
GoalID uint32 `db:"goal_id"`
TimesReq uint16 `db:"times_req"`
Locale uint16 `db:"locale_req"`
Reward uint16 `db:"reward"`
Monopoly FestivalColor `db:"monopoly"`
Unk uint16
}
type FestaReward struct {
Unk0 uint8
Unk1 uint8
ItemType uint16
Quantity uint16
ItemID uint16
Unk5 uint16
Unk6 uint16
Unk7 uint8
}
type FestaPrize struct {
ID uint32 `db:"id"`
Tier uint32 `db:"tier"`
SoulsReq uint32 `db:"souls_req"`
ItemID uint32 `db:"item_id"`
NumItem uint32 `db:"num_item"`
Claimed int `db:"claimed"`
}

58
internal/model/gacha.go Normal file
View File

@@ -0,0 +1,58 @@
package model
type ShopItem struct {
ID uint32 `db:"id"`
ItemID uint32 `db:"item_id"`
Cost uint32 `db:"cost"`
Quantity uint16 `db:"quantity"`
MinHR uint16 `db:"min_hr"`
MinSR uint16 `db:"min_sr"`
MinGR uint16 `db:"min_gr"`
StoreLevel uint8 `db:"store_level"`
MaxQuantity uint16 `db:"max_quantity"`
UsedQuantity uint16 `db:"used_quantity"`
RoadFloors uint16 `db:"road_floors"`
RoadFatalis uint16 `db:"road_fatalis"`
}
type Gacha struct {
ID uint32 `db:"id"`
MinGR uint32 `db:"min_gr"`
MinHR uint32 `db:"min_hr"`
Name string `db:"name"`
URLBanner string `db:"url_banner"`
URLFeature string `db:"url_feature"`
URLThumbnail string `db:"url_thumbnail"`
Wide bool `db:"wide"`
Recommended bool `db:"recommended"`
GachaType uint8 `db:"gacha_type"`
Hidden bool `db:"hidden"`
}
type GachaEntry struct {
EntryType uint8 `db:"entry_type"`
ID uint32 `db:"id"`
ItemType uint8 `db:"item_type"`
ItemNumber uint32 `db:"item_number"`
ItemQuantity uint16 `db:"item_quantity"`
Weight float64 `db:"weight"`
Rarity uint8 `db:"rarity"`
Rolls uint8 `db:"rolls"`
FrontierPoints uint16 `db:"frontier_points"`
DailyLimit uint8 `db:"daily_limit"`
Name string `db:"name"`
}
type GachaItem struct {
ItemType uint8 `db:"item_type"`
ItemID uint16 `db:"item_id"`
Quantity uint16 `db:"quantity"`
}
type FPointExchange struct {
ID uint32 `db:"id"`
ItemType uint8 `db:"item_type"`
ItemID uint16 `db:"item_id"`
Quantity uint16 `db:"quantity"`
FPoints uint16 `db:"fpoints"`
Buyable bool `db:"buyable"`
}

102
internal/model/guild.go Normal file
View File

@@ -0,0 +1,102 @@
package model
import "time"
type GuildAdventure struct {
ID uint32 `db:"id"`
Destination uint32 `db:"destination"`
Charge uint32 `db:"charge"`
Depart uint32 `db:"depart"`
Return uint32 `db:"return"`
CollectedBy string `db:"collected_by"`
}
type GuildTreasureHunt struct {
HuntID uint32 `db:"id"`
HostID uint32 `db:"host_id"`
Destination uint32 `db:"destination"`
Level uint32 `db:"level"`
Start time.Time `db:"start"`
Acquired bool `db:"acquired"`
Collected bool `db:"collected"`
HuntData []byte `db:"hunt_data"`
Hunters uint32 `db:"hunters"`
Claimed bool `db:"claimed"`
}
type GuildTreasureSouvenir struct {
Destination uint32
Quantity uint32
}
type FestivalColor string
type GuildApplicationType string
type GuildIconPart struct {
Index uint16
ID uint16
Page uint8
Size uint8
Rotation uint8
Red uint8
Green uint8
Blue uint8
PosX uint16
PosY uint16
}
type GuildApplication struct {
ID int `db:"id"`
GuildID uint32 `db:"guild_id"`
CharID uint32 `db:"character_id"`
ActorID uint32 `db:"actor_id"`
ApplicationType GuildApplicationType `db:"application_type"`
CreatedAt time.Time `db:"created_at"`
}
type GuildLeader struct {
LeaderCharID uint32 `db:"leader_id"`
LeaderName string `db:"leader_name"`
}
type MessageBoardPost struct {
ID uint32 `db:"id"`
StampID uint32 `db:"stamp_id"`
Title string `db:"title"`
Body string `db:"body"`
AuthorID uint32 `db:"author_id"`
Timestamp time.Time `db:"created_at"`
LikedBy string `db:"liked_by"`
}
type GuildMeal struct {
ID uint32 `db:"id"`
MealID uint32 `db:"meal_id"`
Level uint32 `db:"level"`
CreatedAt time.Time `db:"created_at"`
}
type GuildMission struct {
ID uint32
Unk uint32
Type uint16
Goal uint16
Quantity uint16
SkipTickets uint16
GR bool
RewardType uint16
RewardLevel uint16
}
type GuildAllianceInvite struct {
GuildID uint32
LeaderID uint32
Unk0 uint16
Unk1 uint16
Members uint16
GuildName string
LeaderName string
}
type UnkGuildInfo struct {
Unk0 uint8
Unk1 uint8
Unk2 uint8
}

17
internal/model/house.go Normal file
View File

@@ -0,0 +1,17 @@
package model
import "time"
type HouseData struct {
CharID uint32 `db:"id"`
HR uint16 `db:"hr"`
GR uint16 `db:"gr"`
Name string `db:"name"`
HouseState uint8 `db:"house_state"`
HousePassword string `db:"house_password"`
}
type Title struct {
ID uint16 `db:"id"`
Acquired time.Time `db:"unlocked_at"`
Updated time.Time `db:"updated_at"`
}

40
internal/model/paper.go Normal file
View File

@@ -0,0 +1,40 @@
package model
import "time"
type PaperMissionTimetable struct {
Start time.Time
End time.Time
}
type PaperMissionData struct {
Unk0 uint8
Unk1 uint8
Unk2 int16
Reward1ID uint16
Reward1Quantity uint8
Reward2ID uint16
Reward2Quantity uint8
}
type PaperMission struct {
Timetables []PaperMissionTimetable
Data []PaperMissionData
}
type PaperData struct {
Unk0 uint16
Unk1 int16
Unk2 int16
Unk3 int16
Unk4 int16
Unk5 int16
Unk6 int16
}
type PaperGift struct {
Unk0 uint16
Unk1 uint8
Unk2 uint8
Unk3 uint16
}

View File

@@ -0,0 +1,36 @@
package model
import "time"
type RyoudamaReward struct {
Unk0 uint8
Unk1 uint8
Unk2 uint16
Unk3 uint16
Unk4 uint16
Unk5 uint16
}
type RyoudamaKeyScore struct {
Unk0 uint8
Unk1 int32
}
type RyoudamaCharInfo struct {
CID uint32
Unk0 int32
Name string
}
type RyoudamaBoostInfo struct {
Start time.Time
End time.Time
}
type Ryoudama struct {
Reward []RyoudamaReward
KeyScore []RyoudamaKeyScore
CharInfo []RyoudamaCharInfo
BoostInfo []RyoudamaBoostInfo
Score []int32
}

View File

@@ -0,0 +1,53 @@
package model
import "time"
type SeibattleTimetable struct {
Start time.Time
End time.Time
}
type SeibattleKeyScore struct {
Unk0 uint8
Unk1 int32
}
type SeibattleCareer struct {
Unk0 uint16
Unk1 uint16
Unk2 uint16
}
type SeibattleOpponent struct {
Unk0 int32
Unk1 int8
}
type SeibattleConventionResult struct {
Unk0 uint32
Unk1 uint16
Unk2 uint16
Unk3 uint16
Unk4 uint16
}
type SeibattleCharScore struct {
Unk0 uint32
}
type SeibattleCurResult struct {
Unk0 uint32
Unk1 uint16
Unk2 uint16
Unk3 uint16
}
type Seibattle struct {
Timetable []SeibattleTimetable
KeyScore []SeibattleKeyScore
Career []SeibattleCareer
Opponent []SeibattleOpponent
ConventionResult []SeibattleConventionResult
CharScore []SeibattleCharScore
CurResult []SeibattleCurResult
}

View File

@@ -0,0 +1,45 @@
package model
import "time"
type TournamentInfo0 struct {
ID uint32
MaxPlayers uint32
CurrentPlayers uint32
Unk1 uint16
TextColor uint16
Unk2 uint32
Time1 time.Time
Time2 time.Time
Time3 time.Time
Time4 time.Time
Time5 time.Time
Time6 time.Time
Unk3 uint8
Unk4 uint8
MinHR uint32
MaxHR uint32
Unk5 string
Unk6 string
}
type TournamentInfo21 struct {
Unk0 uint32
Unk1 uint32
Unk2 uint32
Unk3 uint8
}
type TournamentInfo22 struct {
Unk0 uint32
Unk1 uint32
Unk2 uint32
Unk3 uint8
Unk4 string
}
type TournamentReward struct {
Unk0 uint16
Unk1 uint16
Unk2 uint16
}

99
internal/model/tower.go Normal file
View File

@@ -0,0 +1,99 @@
package model
import "time"
type TowerInfoTRP struct {
TR int32
TRP int32
}
type TowerInfoSkill struct {
TSP int32
Skills []int16 // 64
}
type TowerInfoHistory struct {
Unk0 []int16 // 5
Unk1 []int16 // 5
}
type TowerInfoLevel struct {
Floors int32
Unk1 int32
Unk2 int32
Unk3 int32
}
type GemInfo struct {
Gem uint16
Quantity uint16
}
type GemHistory struct {
Gem uint16
Message uint16
Timestamp time.Time
Sender string
}
type TenrouiraiProgress struct {
Page uint8
Mission1 uint16
Mission2 uint16
Mission3 uint16
}
type TenrouiraiReward struct {
Index uint8
Item []uint16 // 5
Quantity []uint8 // 5
}
type TenrouiraiKeyScore struct {
Unk0 uint8
Unk1 int32
}
type TenrouiraiData struct {
Block uint8
Mission uint8
// 1 = Floors climbed
// 2 = Collect antiques
// 3 = Open chests
// 4 = Cats saved
// 5 = TRP acquisition
// 6 = Monster slays
Goal uint16
Cost uint16
Skill1 uint8 // 80
Skill2 uint8 // 40
Skill3 uint8 // 40
Skill4 uint8 // 20
Skill5 uint8 // 40
Skill6 uint8 // 50
}
type TenrouiraiCharScore struct {
Score int32
Name string
}
type TenrouiraiTicket struct {
Unk0 uint8
RP uint32
Unk2 uint32
}
type Tenrouirai struct {
Progress []TenrouiraiProgress
Reward []TenrouiraiReward
KeyScore []TenrouiraiKeyScore
Data []TenrouiraiData
CharScore []TenrouiraiCharScore
Ticket []TenrouiraiTicket
}
type TowerInfo struct {
TRP []TowerInfoTRP
Skill []TowerInfoSkill
History []TowerInfoHistory
Level []TowerInfoLevel
}

View File

@@ -3,6 +3,7 @@ package channelserver
import (
"encoding/binary"
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/utils/db"
"erupe-ce/utils/gametime"
"erupe-ce/utils/mhfcourse"
@@ -1176,81 +1177,31 @@ func handleMsgMhfGetSenyuDailyCount(s *Session, db *sqlx.DB, p mhfpacket.MHFPack
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
type SeibattleTimetable struct {
Start time.Time
End time.Time
}
type SeibattleKeyScore struct {
Unk0 uint8
Unk1 int32
}
type SeibattleCareer struct {
Unk0 uint16
Unk1 uint16
Unk2 uint16
}
type SeibattleOpponent struct {
Unk0 int32
Unk1 int8
}
type SeibattleConventionResult struct {
Unk0 uint32
Unk1 uint16
Unk2 uint16
Unk3 uint16
Unk4 uint16
}
type SeibattleCharScore struct {
Unk0 uint32
}
type SeibattleCurResult struct {
Unk0 uint32
Unk1 uint16
Unk2 uint16
Unk3 uint16
}
type Seibattle struct {
Timetable []SeibattleTimetable
KeyScore []SeibattleKeyScore
Career []SeibattleCareer
Opponent []SeibattleOpponent
ConventionResult []SeibattleConventionResult
CharScore []SeibattleCharScore
CurResult []SeibattleCurResult
}
func handleMsgMhfGetSeibattle(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetSeibattle)
var data []*byteframe.ByteFrame
seibattle := Seibattle{
Timetable: []SeibattleTimetable{
seibattle := model.Seibattle{
Timetable: []model.SeibattleTimetable{
{gametime.TimeMidnight(), gametime.TimeMidnight().Add(time.Hour * 8)},
{gametime.TimeMidnight().Add(time.Hour * 8), gametime.TimeMidnight().Add(time.Hour * 16)},
{gametime.TimeMidnight().Add(time.Hour * 16), gametime.TimeMidnight().Add(time.Hour * 24)},
},
KeyScore: []SeibattleKeyScore{
KeyScore: []model.SeibattleKeyScore{
{0, 0},
},
Career: []SeibattleCareer{
Career: []model.SeibattleCareer{
{0, 0, 0},
},
Opponent: []SeibattleOpponent{
Opponent: []model.SeibattleOpponent{
{1, 1},
},
ConventionResult: []SeibattleConventionResult{
ConventionResult: []model.SeibattleConventionResult{
{0, 0, 0, 0, 0},
},
CharScore: []SeibattleCharScore{
CharScore: []model.SeibattleCharScore{
{0},
},
CurResult: []SeibattleCurResult{
CurResult: []model.SeibattleCurResult{
{0, 0, 0, 0},
},
}
@@ -1415,14 +1366,9 @@ func handleMsgMhfGetLobbyCrowd(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 0x320))
}
type TrendWeapon struct {
WeaponType uint8
WeaponID uint16
}
func handleMsgMhfGetTrendWeapon(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetTrendWeapon)
trendWeapons := [14][3]TrendWeapon{}
trendWeapons := [14][3]model.TrendWeapon{}
for i := uint8(0); i < 14; i++ {
rows, err := db.Query(`SELECT weapon_id FROM trend_weapons WHERE weapon_type=$1 ORDER BY count DESC LIMIT 3`, i)

View File

@@ -1,6 +1,7 @@
package channelserver
import (
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"fmt"
@@ -32,19 +33,9 @@ var achievementCurveMap = map[uint8][]int32{
32: achievementCurves[3],
}
type Achievement struct {
Level uint8
Value uint32
NextValue uint16
Required uint32
Updated bool
Progress uint32
Trophy uint8
}
func GetAchData(id uint8, score int32) Achievement {
func GetAchData(id uint8, score int32) model.Achievement {
curve := achievementCurveMap[id]
var ach Achievement
var ach model.Achievement
for i, v := range curve {
temp := score - v
if temp < 0 {

View File

@@ -1,6 +1,7 @@
package channelserver
import (
"erupe-ce/internal/model"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
"erupe-ce/utils/gametime"
@@ -108,15 +109,6 @@ func handleMsgMhfGetCafeDuration(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
type CafeBonus struct {
ID uint32 `db:"id"`
TimeReq uint32 `db:"time_req"`
ItemType uint32 `db:"item_type"`
ItemID uint32 `db:"item_id"`
Quantity uint32 `db:"quantity"`
Claimed bool `db:"claimed"`
}
func handleMsgMhfGetCafeDurationBonusInfo(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetCafeDurationBonusInfo)
bf := byteframe.NewByteFrame()
@@ -136,7 +128,7 @@ func handleMsgMhfGetCafeDurationBonusInfo(s *Session, db *sqlx.DB, p mhfpacket.M
} else {
for rows.Next() {
count++
cafeBonus := &CafeBonus{}
cafeBonus := &model.CafeBonus{}
err = rows.StructScan(&cafeBonus)
if err != nil {
s.Logger.Error("Error scanning cafebonus", zap.Error(err))
@@ -178,7 +170,7 @@ func handleMsgMhfReceiveCafeDurationBonus(s *Session, db *sqlx.DB, p mhfpacket.M
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
} else {
for rows.Next() {
cafeBonus := &CafeBonus{}
cafeBonus := &model.CafeBonus{}
err = rows.StructScan(cafeBonus)
if err != nil {
continue
@@ -198,7 +190,7 @@ func handleMsgMhfReceiveCafeDurationBonus(s *Session, db *sqlx.DB, p mhfpacket.M
func handleMsgMhfPostCafeDurationBonusReceived(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPostCafeDurationBonusReceived)
var cafeBonus CafeBonus
var cafeBonus model.CafeBonus
for _, cbID := range pkt.CafeBonusID {
err := db.QueryRow(`
SELECT cb.id, item_type, quantity FROM cafebonus cb WHERE cb.id=$1

View File

@@ -1,61 +1,24 @@
package channelserver
import (
"erupe-ce/internal/model"
"erupe-ce/config"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
ps "erupe-ce/utils/pascalstring"
"erupe-ce/utils/stringsupport"
"time"
"github.com/jmoiron/sqlx"
)
type CampaignEvent struct {
ID uint32
Unk0 uint32
MinHR int16
MaxHR int16
MinSR int16
MaxSR int16
MinGR int16
MaxGR int16
Unk1 uint16
Unk2 uint8
Unk3 uint8
Unk4 uint16
Unk5 uint16
Start time.Time
End time.Time
Unk6 uint8
String0 string
String1 string
String2 string
String3 string
Link string
Prefix string
Categories []uint16
}
type CampaignCategory struct {
ID uint16
Type uint8
Title string
Description string
}
type CampaignLink struct {
CategoryID uint16
CampaignID uint32
}
func handleMsgMhfEnumerateCampaign(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateCampaign)
bf := byteframe.NewByteFrame()
events := []CampaignEvent{}
categories := []CampaignCategory{}
var campaignLinks []CampaignLink
events := []model.CampaignEvent{}
categories := []model.CampaignCategory{}
var campaignLinks []model.CampaignLink
if len(events) > 255 {
bf.WriteUint8(255)
@@ -88,7 +51,7 @@ func handleMsgMhfEnumerateCampaign(s *Session, db *sqlx.DB, p mhfpacket.MHFPacke
ps.Uint8(bf, event.String3, true)
ps.Uint8(bf, event.Link, true)
for i := range event.Categories {
campaignLinks = append(campaignLinks, CampaignLink{event.Categories[i], event.ID})
campaignLinks = append(campaignLinks, model.CampaignLink{event.Categories[i], event.ID})
}
}

View File

@@ -1,51 +1,18 @@
package channelserver
import (
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/stringsupport"
"time"
"github.com/jmoiron/sqlx"
)
type RyoudamaReward struct {
Unk0 uint8
Unk1 uint8
Unk2 uint16
Unk3 uint16
Unk4 uint16
Unk5 uint16
}
type RyoudamaKeyScore struct {
Unk0 uint8
Unk1 int32
}
type RyoudamaCharInfo struct {
CID uint32
Unk0 int32
Name string
}
type RyoudamaBoostInfo struct {
Start time.Time
End time.Time
}
type Ryoudama struct {
Reward []RyoudamaReward
KeyScore []RyoudamaKeyScore
CharInfo []RyoudamaCharInfo
BoostInfo []RyoudamaBoostInfo
Score []int32
}
func handleMsgMhfGetRyoudama(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetRyoudama)
var data []*byteframe.ByteFrame
ryoudama := Ryoudama{Score: []int32{0}}
ryoudama := model.Ryoudama{Score: []int32{0}}
switch pkt.Request2 {
case 4:
for _, score := range ryoudama.Score {

View File

@@ -2,6 +2,7 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/utils/gametime"
"erupe-ce/utils/mhfmon"
"erupe-ce/utils/stringsupport"
@@ -199,7 +200,7 @@ func handleMsgMhfLoadScenarioData(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
var paperGiftData = map[uint32][]PaperGift{
var paperGiftData = map[uint32][]model.PaperGift{
6001: {
{11159, 1, 1, 5000},
{11160, 1, 1, 3350},
@@ -963,59 +964,22 @@ var paperGiftData = map[uint32][]PaperGift{
},
}
type PaperMissionTimetable struct {
Start time.Time
End time.Time
}
type PaperMissionData struct {
Unk0 uint8
Unk1 uint8
Unk2 int16
Reward1ID uint16
Reward1Quantity uint8
Reward2ID uint16
Reward2Quantity uint8
}
type PaperMission struct {
Timetables []PaperMissionTimetable
Data []PaperMissionData
}
type PaperData struct {
Unk0 uint16
Unk1 int16
Unk2 int16
Unk3 int16
Unk4 int16
Unk5 int16
Unk6 int16
}
type PaperGift struct {
Unk0 uint16
Unk1 uint8
Unk2 uint8
Unk3 uint16
}
func handleMsgMhfGetPaperData(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetPaperData)
var data []*byteframe.ByteFrame
var paperData []PaperData
var paperMissions PaperMission
var paperGift []PaperGift
var paperData []model.PaperData
var paperMissions model.PaperMission
var paperGift []model.PaperGift
switch pkt.Unk2 {
case 0:
paperMissions = PaperMission{
[]PaperMissionTimetable{{gametime.TimeMidnight(), gametime.TimeMidnight().Add(24 * time.Hour)}},
[]PaperMissionData{},
paperMissions = model.PaperMission{
[]model.PaperMissionTimetable{{gametime.TimeMidnight(), gametime.TimeMidnight().Add(24 * time.Hour)}},
[]model.PaperMissionData{},
}
case 5:
paperData = []PaperData{
paperData = []model.PaperData{
// getTowerQuestTowerLevel
{1001, 1, 0, 0, 0, 0, 0},
{1001, 2, 0, 0, 0, 0, 0},
@@ -1080,7 +1044,7 @@ func handleMsgMhfGetPaperData(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
{2001, 2, mhfmon.Dyuragaua, 60, 0, 16, 1000},
}
case 6:
paperData = []PaperData{
paperData = []model.PaperData{
// updateClearTowerFloor
{1002, 100, 0, 0, 0, 0, 0},
// give_gem_func

View File

@@ -2,38 +2,21 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
ps "erupe-ce/utils/pascalstring"
"fmt"
"time"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
)
type Distribution struct {
ID uint32 `db:"id"`
Deadline time.Time `db:"deadline"`
Rights uint32 `db:"rights"`
TimesAcceptable uint16 `db:"times_acceptable"`
TimesAccepted uint16 `db:"times_accepted"`
MinHR int16 `db:"min_hr"`
MaxHR int16 `db:"max_hr"`
MinSR int16 `db:"min_sr"`
MaxSR int16 `db:"max_sr"`
MinGR int16 `db:"min_gr"`
MaxGR int16 `db:"max_gr"`
EventName string `db:"event_name"`
Description string `db:"description"`
Selection bool `db:"selection"`
}
func handleMsgMhfEnumerateDistItem(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateDistItem)
var itemDists []Distribution
var itemDists []model.Distribution
bf := byteframe.NewByteFrame()
rows, err := db.Queryx(`
@@ -51,7 +34,7 @@ func handleMsgMhfEnumerateDistItem(s *Session, db *sqlx.DB, p mhfpacket.MHFPacke
`, s.CharID, pkt.DistType)
if err == nil {
var itemDist Distribution
var itemDist model.Distribution
for rows.Next() {
err = rows.StructScan(&itemDist)
if err != nil {
@@ -123,22 +106,15 @@ func handleMsgMhfEnumerateDistItem(s *Session, db *sqlx.DB, p mhfpacket.MHFPacke
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
type DistributionItem struct {
ItemType uint8 `db:"item_type"`
ID uint32 `db:"id"`
ItemID uint32 `db:"item_id"`
Quantity uint32 `db:"quantity"`
}
func getDistributionItems(s *Session, i uint32) []DistributionItem {
func getDistributionItems(s *Session, i uint32) []model.DistributionItem {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
var distItems []DistributionItem
var distItems []model.DistributionItem
rows, err := db.Queryx(`SELECT id, item_type, COALESCE(item_id, 0) AS item_id, COALESCE(quantity, 0) AS quantity FROM distribution_items WHERE distribution_id=$1`, i)
if err == nil {
var distItem DistributionItem
var distItem model.DistributionItem
for rows.Next() {
err = rows.StructScan(&distItem)
if err != nil {

View File

@@ -2,6 +2,7 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/utils/gametime"
"erupe-ce/utils/token"
"math"
@@ -13,22 +14,11 @@ import (
"github.com/jmoiron/sqlx"
)
type Event struct {
EventType uint16
Unk1 uint16
Unk2 uint16
Unk3 uint16
Unk4 uint16
Unk5 uint32
Unk6 uint32
QuestFileIDs []uint16
}
func handleMsgMhfEnumerateEvent(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateEvent)
bf := byteframe.NewByteFrame()
events := []Event{}
events := []model.Event{}
bf.WriteUint8(uint8(len(events)))
for _, event := range events {
@@ -50,15 +40,10 @@ func handleMsgMhfEnumerateEvent(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
type activeFeature struct {
StartTime time.Time `db:"start_time"`
ActiveFeatures uint32 `db:"featured"`
}
func handleMsgMhfGetWeeklySchedule(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetWeeklySchedule)
var features []activeFeature
var features []model.ActiveFeature
times := []time.Time{
gametime.TimeMidnight().Add(-24 * time.Hour),
gametime.TimeMidnight(),
@@ -66,7 +51,7 @@ func handleMsgMhfGetWeeklySchedule(s *Session, db *sqlx.DB, p mhfpacket.MHFPacke
}
for _, t := range times {
var temp activeFeature
var temp model.ActiveFeature
err := db.QueryRowx(`SELECT start_time, featured FROM feature_weapon WHERE start_time=$1`, t).StructScan(&temp)
if err != nil || temp.StartTime.IsZero() {
weapons := token.RNG.Intn(config.GetConfig().GameplayOptions.MaxFeatureWeapons-config.GetConfig().GameplayOptions.MinFeatureWeapons+1) + config.GetConfig().GameplayOptions.MinFeatureWeapons
@@ -88,7 +73,7 @@ func handleMsgMhfGetWeeklySchedule(s *Session, db *sqlx.DB, p mhfpacket.MHFPacke
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
func generateFeatureWeapons(count int) activeFeature {
func generateFeatureWeapons(count int) model.ActiveFeature {
_max := 14
if config.GetConfig().ClientID < config.ZZ {
_max = 13
@@ -120,15 +105,7 @@ func generateFeatureWeapons(count int) activeFeature {
for _, num := range nums {
result += int(math.Pow(2, float64(num)))
}
return activeFeature{ActiveFeatures: uint32(result)}
}
type loginBoost struct {
WeekReq uint8 `db:"week_req"`
WeekCount uint8
Active bool
Expiration time.Time `db:"expiration"`
Reset time.Time `db:"reset"`
return model.ActiveFeature{ActiveFeatures: uint32(result)}
}
func handleMsgMhfGetKeepLoginBoostStatus(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
@@ -136,7 +113,7 @@ func handleMsgMhfGetKeepLoginBoostStatus(s *Session, db *sqlx.DB, p mhfpacket.MH
bf := byteframe.NewByteFrame()
var loginBoosts []loginBoost
var loginBoosts []model.LoginBoost
rows, err := db.Queryx("SELECT week_req, expiration, reset FROM login_boost WHERE char_id=$1 ORDER BY week_req", s.CharID)
if err != nil || config.GetConfig().GameplayOptions.DisableLoginBoost {
rows.Close()
@@ -144,13 +121,13 @@ func handleMsgMhfGetKeepLoginBoostStatus(s *Session, db *sqlx.DB, p mhfpacket.MH
return
}
for rows.Next() {
var temp loginBoost
var temp model.LoginBoost
rows.StructScan(&temp)
loginBoosts = append(loginBoosts, temp)
}
if len(loginBoosts) == 0 {
temp := gametime.TimeWeekStart()
loginBoosts = []loginBoost{
loginBoosts = []model.LoginBoost{
{WeekReq: 1, Expiration: temp},
{WeekReq: 2, Expiration: temp},
{WeekReq: 3, Expiration: temp},

View File

@@ -2,9 +2,11 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
"erupe-ce/utils/gametime"
ps "erupe-ce/utils/pascalstring"
"erupe-ce/utils/token"
@@ -156,28 +158,6 @@ func generateFestaTimestamps(s *Session, start uint32, debug bool) []uint32 {
return timestamps
}
type FestaTrial struct {
ID uint32 `db:"id"`
Objective uint16 `db:"objective"`
GoalID uint32 `db:"goal_id"`
TimesReq uint16 `db:"times_req"`
Locale uint16 `db:"locale_req"`
Reward uint16 `db:"reward"`
Monopoly FestivalColor `db:"monopoly"`
Unk uint16
}
type FestaReward struct {
Unk0 uint8
Unk1 uint8
ItemType uint16
Quantity uint16
ItemID uint16
Unk5 uint16
Unk6 uint16
Unk7 uint8
}
func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfInfoFesta)
bf := byteframe.NewByteFrame()
@@ -219,8 +199,8 @@ func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
bf.WriteUint32(blueSouls)
bf.WriteUint32(redSouls)
var trials []FestaTrial
var trial FestaTrial
var trials []model.FestaTrial
var trial model.FestaTrial
rows, _ = db.Queryx(`SELECT ft.*,
COALESCE(CASE
WHEN COUNT(gc.id) FILTER (WHERE fr.team = 'blue' AND gc.trial_vote = ft.id) >
@@ -257,7 +237,7 @@ func handleMsgMhfInfoFesta(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
// The Winner and Loser Armor IDs are missing
// Item 7011 may not exist in older versions, remove to prevent crashes
rewards := []FestaReward{
rewards := []model.FestaReward{
{1, 0, 7, 350, 1520, 0, 0, 0},
{1, 0, 7, 1000, 7011, 0, 0, 1},
{1, 0, 12, 1000, 0, 0, 0, 0},
@@ -520,15 +500,6 @@ func handleMsgMhfAcquireFestaIntermediatePrize(s *Session, db *sqlx.DB, p mhfpac
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type Prize struct {
ID uint32 `db:"id"`
Tier uint32 `db:"tier"`
SoulsReq uint32 `db:"souls_req"`
ItemID uint32 `db:"item_id"`
NumItem uint32 `db:"num_item"`
Claimed int `db:"claimed"`
}
func handleMsgMhfEnumerateFestaPersonalPrize(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateFestaPersonalPrize)
@@ -536,7 +507,7 @@ func handleMsgMhfEnumerateFestaPersonalPrize(s *Session, db *sqlx.DB, p mhfpacke
var count uint32
prizeData := byteframe.NewByteFrame()
for rows.Next() {
prize := &Prize{}
prize := &model.FestaPrize{}
err := rows.StructScan(&prize)
if err != nil {
continue
@@ -563,7 +534,7 @@ func handleMsgMhfEnumerateFestaIntermediatePrize(s *Session, db *sqlx.DB, p mhfp
var count uint32
prizeData := byteframe.NewByteFrame()
for rows.Next() {
prize := &Prize{}
prize := &model.FestaPrize{}
err := rows.StructScan(&prize)
if err != nil {
continue

View File

@@ -6,6 +6,7 @@ import (
"encoding/json"
"errors"
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/utils/db"
"erupe-ce/utils/gametime"
"erupe-ce/utils/mhfitem"
@@ -25,86 +26,55 @@ import (
"go.uber.org/zap"
)
type FestivalColor string
type Guild struct {
ID uint32 `db:"id"`
Name string `db:"name"`
MainMotto uint8 `db:"main_motto"`
SubMotto uint8 `db:"sub_motto"`
CreatedAt time.Time `db:"created_at"`
MemberCount uint16 `db:"member_count"`
RankRP uint32 `db:"rank_rp"`
EventRP uint32 `db:"event_rp"`
RoomRP uint16 `db:"room_rp"`
RoomExpiry time.Time `db:"room_expiry"`
Comment string `db:"comment"`
PugiName1 string `db:"pugi_name_1"`
PugiName2 string `db:"pugi_name_2"`
PugiName3 string `db:"pugi_name_3"`
PugiOutfit1 uint8 `db:"pugi_outfit_1"`
PugiOutfit2 uint8 `db:"pugi_outfit_2"`
PugiOutfit3 uint8 `db:"pugi_outfit_3"`
PugiOutfits uint32 `db:"pugi_outfits"`
Recruiting bool `db:"recruiting"`
FestivalColor model.FestivalColor `db:"festival_color"`
Souls uint32 `db:"souls"`
AllianceID uint32 `db:"alliance_id"`
Icon *GuildIcon `db:"icon"`
model.GuildLeader
}
type GuildIcon struct {
Parts []model.GuildIconPart
}
const (
FestivalColorNone FestivalColor = "none"
FestivalColorBlue FestivalColor = "blue"
FestivalColorRed FestivalColor = "red"
FestivalColorNone model.FestivalColor = "none"
FestivalColorBlue model.FestivalColor = "blue"
FestivalColorRed model.FestivalColor = "red"
)
var FestivalColorCodes = map[FestivalColor]int16{
var FestivalColorCodes = map[model.FestivalColor]int16{
FestivalColorNone: -1,
FestivalColorBlue: 0,
FestivalColorRed: 1,
}
type GuildApplicationType string
const (
GuildApplicationTypeApplied GuildApplicationType = "applied"
GuildApplicationTypeInvited GuildApplicationType = "invited"
GuildApplicationTypeApplied model.GuildApplicationType = "applied"
GuildApplicationTypeInvited model.GuildApplicationType = "invited"
)
type Guild struct {
ID uint32 `db:"id"`
Name string `db:"name"`
MainMotto uint8 `db:"main_motto"`
SubMotto uint8 `db:"sub_motto"`
CreatedAt time.Time `db:"created_at"`
MemberCount uint16 `db:"member_count"`
RankRP uint32 `db:"rank_rp"`
EventRP uint32 `db:"event_rp"`
RoomRP uint16 `db:"room_rp"`
RoomExpiry time.Time `db:"room_expiry"`
Comment string `db:"comment"`
PugiName1 string `db:"pugi_name_1"`
PugiName2 string `db:"pugi_name_2"`
PugiName3 string `db:"pugi_name_3"`
PugiOutfit1 uint8 `db:"pugi_outfit_1"`
PugiOutfit2 uint8 `db:"pugi_outfit_2"`
PugiOutfit3 uint8 `db:"pugi_outfit_3"`
PugiOutfits uint32 `db:"pugi_outfits"`
Recruiting bool `db:"recruiting"`
FestivalColor FestivalColor `db:"festival_color"`
Souls uint32 `db:"souls"`
AllianceID uint32 `db:"alliance_id"`
Icon *GuildIcon `db:"icon"`
GuildLeader
}
type GuildLeader struct {
LeaderCharID uint32 `db:"leader_id"`
LeaderName string `db:"leader_name"`
}
type GuildIconPart struct {
Index uint16
ID uint16
Page uint8
Size uint8
Rotation uint8
Red uint8
Green uint8
Blue uint8
PosX uint16
PosY uint16
}
type GuildApplication struct {
ID int `db:"id"`
GuildID uint32 `db:"guild_id"`
CharID uint32 `db:"character_id"`
ActorID uint32 `db:"actor_id"`
ApplicationType GuildApplicationType `db:"application_type"`
CreatedAt time.Time `db:"created_at"`
}
type GuildIcon struct {
Parts []GuildIconPart
}
func (gi *GuildIcon) Scan(val interface{}) (err error) {
switch v := val.(type) {
case []byte:
@@ -209,7 +179,7 @@ func (guild *Guild) Save(s *Session) error {
return nil
}
func (guild *Guild) CreateApplication(s *Session, charID uint32, applicationType GuildApplicationType, transaction *sql.Tx) error {
func (guild *Guild) CreateApplication(s *Session, charID uint32, applicationType model.GuildApplicationType, transaction *sql.Tx) error {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
@@ -454,7 +424,7 @@ func (guild *Guild) ArrangeCharacters(s *Session, charIDs []uint32) error {
return nil
}
func (guild *Guild) GetApplicationForCharID(s *Session, charID uint32, applicationType GuildApplicationType) (*GuildApplication, error) {
func (guild *Guild) GetApplicationForCharID(s *Session, charID uint32, applicationType model.GuildApplicationType) (*model.GuildApplication, error) {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
@@ -463,7 +433,7 @@ func (guild *Guild) GetApplicationForCharID(s *Session, charID uint32, applicati
SELECT * from guild_applications WHERE character_id = $1 AND guild_id = $2 AND application_type = $3
`, charID, guild.ID, applicationType)
application := &GuildApplication{}
application := &model.GuildApplication{}
err = row.StructScan(application)
@@ -1161,12 +1131,7 @@ func HandleMsgMhfInfoGuild(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
}
}
type UnkGuildInfo struct {
Unk0 uint8
Unk1 uint8
Unk2 uint8
}
unkGuildInfo := []UnkGuildInfo{}
unkGuildInfo := []model.UnkGuildInfo{}
bf.WriteUint8(uint8(len(unkGuildInfo)))
for _, info := range unkGuildInfo {
bf.WriteUint8(info.Unk0)
@@ -1174,16 +1139,7 @@ func HandleMsgMhfInfoGuild(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
bf.WriteUint8(info.Unk2)
}
type AllianceInvite struct {
GuildID uint32
LeaderID uint32
Unk0 uint16
Unk1 uint16
Members uint16
GuildName string
LeaderName string
}
allianceInvites := []AllianceInvite{}
allianceInvites := []model.GuildAllianceInvite{}
bf.WriteUint8(uint8(len(allianceInvites)))
for _, invite := range allianceInvites {
bf.WriteUint32(invite.GuildID)
@@ -1697,10 +1653,10 @@ func HandleMsgMhfUpdateGuildIcon(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
icon := &GuildIcon{}
icon.Parts = make([]GuildIconPart, len(pkt.IconParts))
icon.Parts = make([]model.GuildIconPart, len(pkt.IconParts))
for i, p := range pkt.IconParts {
icon.Parts[i] = GuildIconPart{
icon.Parts[i] = model.GuildIconPart{
Index: p.Index,
ID: p.ID,
Page: p.Page,
@@ -1742,22 +1698,10 @@ func HandleMsgMhfReadGuildcard(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
s.DoAckBufSucceed(pkt.AckHandle, resp.Data())
}
type GuildMission struct {
ID uint32
Unk uint32
Type uint16
Goal uint16
Quantity uint16
SkipTickets uint16
GR bool
RewardType uint16
RewardLevel uint16
}
func HandleMsgMhfGetGuildMissionList(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetGuildMissionList)
bf := byteframe.NewByteFrame()
missions := []GuildMission{
missions := []model.GuildMission{
{431201, 574, 1, 4761, 35, 1, false, 2, 1},
{431202, 755, 0, 95, 12, 2, false, 3, 2},
{431203, 746, 0, 95, 6, 1, false, 1, 1},
@@ -1811,13 +1755,6 @@ func HandleMsgMhfCancelGuildMissionTarget(s *Session, db *sqlx.DB, p mhfpacket.M
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type GuildMeal struct {
ID uint32 `db:"id"`
MealID uint32 `db:"meal_id"`
Level uint32 `db:"level"`
CreatedAt time.Time `db:"created_at"`
}
func HandleMsgMhfLoadGuildCooking(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfLoadGuildCooking)
@@ -1828,8 +1765,8 @@ func HandleMsgMhfLoadGuildCooking(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 2))
return
}
var meals []GuildMeal
var temp GuildMeal
var meals []model.GuildMeal
var temp model.GuildMeal
for data.Next() {
err = data.StructScan(&temp)
if err != nil {
@@ -1939,16 +1876,6 @@ func HandleMsgMhfGuildHuntdata(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
s.DoAckBufSucceed(pkt.AckHandle, bf.Data())
}
type MessageBoardPost struct {
ID uint32 `db:"id"`
StampID uint32 `db:"stamp_id"`
Title string `db:"title"`
Body string `db:"body"`
AuthorID uint32 `db:"author_id"`
Timestamp time.Time `db:"created_at"`
LikedBy string `db:"liked_by"`
}
func HandleMsgMhfEnumerateGuildMessageBoard(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateGuildMessageBoard)
@@ -1966,7 +1893,7 @@ func HandleMsgMhfEnumerateGuildMessageBoard(s *Session, db *sqlx.DB, p mhfpacket
bf := byteframe.NewByteFrame()
var postCount uint32
for msgs.Next() {
postData := &MessageBoardPost{}
postData := &model.MessageBoardPost{}
err = msgs.StructScan(&postData)
if err != nil {
continue

View File

@@ -3,6 +3,7 @@ package channelserver
import (
"time"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/gametime"
@@ -12,15 +13,6 @@ import (
"go.uber.org/zap"
)
type GuildAdventure struct {
ID uint32 `db:"id"`
Destination uint32 `db:"destination"`
Charge uint32 `db:"charge"`
Depart uint32 `db:"depart"`
Return uint32 `db:"return"`
CollectedBy string `db:"collected_by"`
}
func HandleMsgMhfLoadGuildAdventure(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfLoadGuildAdventure)
@@ -35,7 +27,7 @@ func HandleMsgMhfLoadGuildAdventure(s *Session, db *sqlx.DB, p mhfpacket.MHFPack
count := 0
for data.Next() {
count++
adventureData := &GuildAdventure{}
adventureData := &model.GuildAdventure{}
err = data.StructScan(&adventureData)
if err != nil {
continue

View File

@@ -2,6 +2,7 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/gametime"
@@ -11,19 +12,6 @@ import (
"github.com/jmoiron/sqlx"
)
type TreasureHunt struct {
HuntID uint32 `db:"id"`
HostID uint32 `db:"host_id"`
Destination uint32 `db:"destination"`
Level uint32 `db:"level"`
Start time.Time `db:"start"`
Acquired bool `db:"acquired"`
Collected bool `db:"collected"`
HuntData []byte `db:"hunt_data"`
Hunters uint32 `db:"hunters"`
Claimed bool `db:"claimed"`
}
func HandleMsgMhfEnumerateGuildTresure(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateGuildTresure)
guild, err := GetGuildInfoByCharacterId(s, s.CharID)
@@ -31,8 +19,8 @@ func HandleMsgMhfEnumerateGuildTresure(s *Session, db *sqlx.DB, p mhfpacket.MHFP
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 4))
return
}
var hunts []TreasureHunt
var hunt TreasureHunt
var hunts []model.GuildTreasureHunt
var hunt model.GuildTreasureHunt
switch pkt.MaxHunts {
case 1:
@@ -140,16 +128,11 @@ func HandleMsgMhfOperateGuildTresureReport(s *Session, db *sqlx.DB, p mhfpacket.
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type TreasureSouvenir struct {
Destination uint32
Quantity uint32
}
func HandleMsgMhfGetGuildTresureSouvenir(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetGuildTresureSouvenir)
bf := byteframe.NewByteFrame()
bf.WriteUint32(0)
souvenirs := []TreasureSouvenir{}
souvenirs := []model.GuildTreasureSouvenir{}
bf.WriteUint16(uint16(len(souvenirs)))
for _, souvenir := range souvenirs {
bf.WriteUint32(souvenir.Destination)

View File

@@ -2,6 +2,7 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
@@ -11,7 +12,6 @@ import (
"erupe-ce/utils/token"
"fmt"
"io"
"time"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
@@ -49,21 +49,12 @@ func handleMsgMhfUpdateInterior(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type HouseData struct {
CharID uint32 `db:"id"`
HR uint16 `db:"hr"`
GR uint16 `db:"gr"`
Name string `db:"name"`
HouseState uint8 `db:"house_state"`
HousePassword string `db:"house_password"`
}
func handleMsgMhfEnumerateHouse(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateHouse)
bf := byteframe.NewByteFrame()
bf.WriteUint16(0)
var houses []HouseData
var houses []model.HouseData
houseQuery := `SELECT c.id, hr, gr, name, COALESCE(ub.house_state, 2) as house_state, COALESCE(ub.house_password, '') as house_password
FROM characters c LEFT JOIN user_binary ub ON ub.id = c.id WHERE c.id=$1`
switch pkt.Method {
@@ -72,7 +63,7 @@ func handleMsgMhfEnumerateHouse(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
db.QueryRow("SELECT friends FROM characters WHERE id=$1", s.CharID).Scan(&friendsList)
cids := stringsupport.CSVElems(friendsList)
for _, cid := range cids {
house := HouseData{}
house := model.HouseData{}
row := db.QueryRowx(houseQuery, cid)
err := row.StructScan(&house)
if err == nil {
@@ -89,7 +80,7 @@ func handleMsgMhfEnumerateHouse(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
break
}
for _, member := range guildMembers {
house := HouseData{}
house := model.HouseData{}
row := db.QueryRowx(houseQuery, member.CharID)
err = row.StructScan(&house)
if err == nil {
@@ -99,7 +90,7 @@ func handleMsgMhfEnumerateHouse(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
case 3:
houseQuery = `SELECT c.id, hr, gr, name, COALESCE(ub.house_state, 2) as house_state, COALESCE(ub.house_password, '') as house_password
FROM characters c LEFT JOIN user_binary ub ON ub.id = c.id WHERE name ILIKE $1`
house := HouseData{}
house := model.HouseData{}
rows, _ := db.Queryx(houseQuery, fmt.Sprintf(`%%%s%%`, pkt.Name))
for rows.Next() {
err := rows.StructScan(&house)
@@ -108,7 +99,7 @@ func handleMsgMhfEnumerateHouse(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
}
}
case 4:
house := HouseData{}
house := model.HouseData{}
row := db.QueryRowx(houseQuery, pkt.CharID)
err := row.StructScan(&house)
if err == nil {
@@ -328,12 +319,6 @@ func handleMsgMhfSaveDecoMyset(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type Title struct {
ID uint16 `db:"id"`
Acquired time.Time `db:"unlocked_at"`
Updated time.Time `db:"updated_at"`
}
func handleMsgMhfEnumerateTitle(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfEnumerateTitle)
@@ -347,7 +332,7 @@ func handleMsgMhfEnumerateTitle(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
return
}
for rows.Next() {
title := &Title{}
title := &model.Title{}
err = rows.StructScan(&title)
if err != nil {
continue

View File

@@ -2,6 +2,7 @@ package channelserver
import (
config "erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/server/channelserver/compression/deltacomp"
"erupe-ce/server/channelserver/compression/nullcomp"
@@ -329,23 +330,12 @@ func handleMsgMhfEnumerateAiroulist(s *Session, db *sqlx.DB, p mhfpacket.MHFPack
s.DoAckBufSucceed(pkt.AckHandle, resp.Data())
}
type Airou struct {
ID uint32
Name []byte
Task uint8
Personality uint8
Class uint8
Experience uint32
WeaponType uint8
WeaponID uint16
}
func getGuildAirouList(s *Session) []Airou {
func getGuildAirouList(s *Session) []model.Airou {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
var guildCats []Airou
var guildCats []model.Airou
bannedCats := make(map[uint32]int)
guild, err := GetGuildInfoByCharacterId(s, s.CharID)
if err != nil {
@@ -408,11 +398,11 @@ func getGuildAirouList(s *Session) []Airou {
return guildCats
}
func GetAirouDetails(bf *byteframe.ByteFrame) []Airou {
func GetAirouDetails(bf *byteframe.ByteFrame) []model.Airou {
catCount := bf.ReadUint8()
cats := make([]Airou, catCount)
cats := make([]model.Airou, catCount)
for x := 0; x < int(catCount); x++ {
var catDef Airou
var catDef model.Airou
// cat sometimes has additional bytes for whatever reason, gift items? timestamp?
// until actual variance is known we can just seek to end based on start
catDefLen := bf.ReadUint32()

View File

@@ -2,6 +2,7 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/db"
@@ -13,56 +14,7 @@ import (
"github.com/jmoiron/sqlx"
)
type ShopItem struct {
ID uint32 `db:"id"`
ItemID uint32 `db:"item_id"`
Cost uint32 `db:"cost"`
Quantity uint16 `db:"quantity"`
MinHR uint16 `db:"min_hr"`
MinSR uint16 `db:"min_sr"`
MinGR uint16 `db:"min_gr"`
StoreLevel uint8 `db:"store_level"`
MaxQuantity uint16 `db:"max_quantity"`
UsedQuantity uint16 `db:"used_quantity"`
RoadFloors uint16 `db:"road_floors"`
RoadFatalis uint16 `db:"road_fatalis"`
}
type Gacha struct {
ID uint32 `db:"id"`
MinGR uint32 `db:"min_gr"`
MinHR uint32 `db:"min_hr"`
Name string `db:"name"`
URLBanner string `db:"url_banner"`
URLFeature string `db:"url_feature"`
URLThumbnail string `db:"url_thumbnail"`
Wide bool `db:"wide"`
Recommended bool `db:"recommended"`
GachaType uint8 `db:"gacha_type"`
Hidden bool `db:"hidden"`
}
type GachaEntry struct {
EntryType uint8 `db:"entry_type"`
ID uint32 `db:"id"`
ItemType uint8 `db:"item_type"`
ItemNumber uint32 `db:"item_number"`
ItemQuantity uint16 `db:"item_quantity"`
Weight float64 `db:"weight"`
Rarity uint8 `db:"rarity"`
Rolls uint8 `db:"rolls"`
FrontierPoints uint16 `db:"frontier_points"`
DailyLimit uint8 `db:"daily_limit"`
Name string `db:"name"`
}
type GachaItem struct {
ItemType uint8 `db:"item_type"`
ItemID uint16 `db:"item_id"`
Quantity uint16 `db:"quantity"`
}
func writeShopItems(bf *byteframe.ByteFrame, items []ShopItem) {
func writeShopItems(bf *byteframe.ByteFrame, items []model.ShopItem) {
bf.WriteUint16(uint16(len(items)))
bf.WriteUint16(uint16(len(items)))
for _, item := range items {
@@ -93,13 +45,13 @@ func writeShopItems(bf *byteframe.ByteFrame, items []ShopItem) {
}
}
func getShopItems(s *Session, shopType uint8, shopID uint32) []ShopItem {
func getShopItems(s *Session, shopType uint8, shopID uint32) []model.ShopItem {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
var items []ShopItem
var temp ShopItem
var items []model.ShopItem
var temp model.ShopItem
rows, err := db.Queryx(`SELECT id, item_id, cost, quantity, min_hr, min_sr, min_gr, store_level, max_quantity,
COALESCE((SELECT bought FROM shop_items_bought WHERE shop_item_id=si.id AND character_id=$3), 0) as used_quantity,
@@ -144,8 +96,8 @@ func handleMsgMhfEnumerateShop(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
return
}
bf := byteframe.NewByteFrame()
var gacha Gacha
var gachas []Gacha
var gacha model.Gacha
var gachas []model.Gacha
for rows.Next() {
err = rows.StructScan(&gacha)
if err == nil {
@@ -194,9 +146,9 @@ func handleMsgMhfEnumerateShop(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
var divisor float64
db.QueryRow(`SELECT COALESCE(SUM(weight) / 100000.0, 0) AS chance FROM gacha_entries WHERE gacha_id = $1`, pkt.ShopID).Scan(&divisor)
var entry GachaEntry
var entries []GachaEntry
var item GachaItem
var entry model.GachaEntry
var entries []model.GachaEntry
var item model.GachaItem
for rows.Next() {
err = rows.StructScan(&entry)
if err == nil {
@@ -205,7 +157,7 @@ func handleMsgMhfEnumerateShop(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
}
bf.WriteUint16(uint16(len(entries)))
for _, ge := range entries {
var items []GachaItem
var items []model.GachaItem
bf.WriteUint8(ge.EntryType)
bf.WriteUint32(ge.ID)
bf.WriteUint8(ge.ItemType)
@@ -373,13 +325,13 @@ func transactGacha(s *Session, gachaID uint32, rollID uint8) (error, int) {
return nil, rolls
}
func getGuaranteedItems(s *Session, gachaID uint32, rollID uint8) []GachaItem {
func getGuaranteedItems(s *Session, gachaID uint32, rollID uint8) []model.GachaItem {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
}
var rewards []GachaItem
var reward GachaItem
var rewards []model.GachaItem
var reward model.GachaItem
items, err := db.Queryx(`SELECT item_type, item_id, quantity FROM gacha_items WHERE entry_id = (SELECT id FROM gacha_entries WHERE entry_type = $1 AND gacha_id = $2)`, rollID, gachaID)
if err == nil {
@@ -391,7 +343,7 @@ func getGuaranteedItems(s *Session, gachaID uint32, rollID uint8) []GachaItem {
return rewards
}
func addGachaItem(s *Session, items []GachaItem) {
func addGachaItem(s *Session, items []model.GachaItem) {
db, err := db.GetDB()
if err != nil {
s.Logger.Fatal(fmt.Sprintf("Failed to get database instance: %s", err))
@@ -404,7 +356,7 @@ func addGachaItem(s *Session, items []GachaItem) {
data = data[1:]
oldItem := byteframe.NewByteFrameFromBytes(data)
for i := 0; i < numItems; i++ {
items = append(items, GachaItem{
items = append(items, model.GachaItem{
ItemType: oldItem.ReadUint8(),
ItemID: oldItem.ReadUint16(),
Quantity: oldItem.ReadUint16(),
@@ -421,8 +373,8 @@ func addGachaItem(s *Session, items []GachaItem) {
db.Exec(`UPDATE characters SET gacha_items = $1 WHERE id = $2`, newItem.Data(), s.CharID)
}
func getRandomEntries(entries []GachaEntry, rolls int, isBox bool) ([]GachaEntry, error) {
var chosen []GachaEntry
func getRandomEntries(entries []model.GachaEntry, rolls int, isBox bool) ([]model.GachaEntry, error) {
var chosen []model.GachaEntry
var totalWeight float64
for i := range entries {
totalWeight += entries[i].Weight
@@ -484,10 +436,10 @@ func handleMsgMhfReceiveGachaItem(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket
func handleMsgMhfPlayNormalGacha(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPlayNormalGacha)
bf := byteframe.NewByteFrame()
var entries []GachaEntry
var entry GachaEntry
var rewards []GachaItem
var reward GachaItem
var entries []model.GachaEntry
var entry model.GachaEntry
var rewards []model.GachaItem
var reward model.GachaItem
err, rolls := transactGacha(s, pkt.GachaID, pkt.RollType)
if err != nil {
@@ -537,10 +489,10 @@ func handleMsgMhfPlayNormalGacha(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
func handleMsgMhfPlayStepupGacha(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPlayStepupGacha)
bf := byteframe.NewByteFrame()
var entries []GachaEntry
var entry GachaEntry
var rewards []GachaItem
var reward GachaItem
var entries []model.GachaEntry
var entry model.GachaEntry
var rewards []model.GachaItem
var reward model.GachaItem
err, rolls := transactGacha(s, pkt.GachaID, pkt.RollType)
if err != nil {
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 1))
@@ -643,10 +595,10 @@ func handleMsgMhfGetBoxGachaInfo(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
func handleMsgMhfPlayBoxGacha(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfPlayBoxGacha)
bf := byteframe.NewByteFrame()
var entries []GachaEntry
var entry GachaEntry
var rewards []GachaItem
var reward GachaItem
var entries []model.GachaEntry
var entry model.GachaEntry
var rewards []model.GachaItem
var reward model.GachaItem
err, rolls := transactGacha(s, pkt.GachaID, pkt.RollType)
if err != nil {
s.DoAckBufSucceed(pkt.AckHandle, make([]byte, 1))
@@ -722,21 +674,12 @@ func handleMsgMhfExchangeItem2Fpoint(s *Session, db *sqlx.DB, p mhfpacket.MHFPac
s.DoAckSimpleSucceed(pkt.AckHandle, bf.Data())
}
type FPointExchange struct {
ID uint32 `db:"id"`
ItemType uint8 `db:"item_type"`
ItemID uint16 `db:"item_id"`
Quantity uint16 `db:"quantity"`
FPoints uint16 `db:"fpoints"`
Buyable bool `db:"buyable"`
}
func handleMsgMhfGetFpointExchangeList(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetFpointExchangeList)
bf := byteframe.NewByteFrame()
var exchange FPointExchange
var exchanges []FPointExchange
var exchange model.FPointExchange
var exchanges []model.FPointExchange
var buyables uint16
rows, err := db.Queryx(`SELECT id, item_type, item_id, quantity, fpoints, buyable FROM fpoint_items ORDER BY buyable DESC`)

View File

@@ -1,58 +1,22 @@
package channelserver
import (
"erupe-ce/internal/model"
"erupe-ce/network/mhfpacket"
"erupe-ce/utils/byteframe"
"erupe-ce/utils/gametime"
ps "erupe-ce/utils/pascalstring"
"time"
"github.com/jmoiron/sqlx"
)
type TournamentInfo0 struct {
ID uint32
MaxPlayers uint32
CurrentPlayers uint32
Unk1 uint16
TextColor uint16
Unk2 uint32
Time1 time.Time
Time2 time.Time
Time3 time.Time
Time4 time.Time
Time5 time.Time
Time6 time.Time
Unk3 uint8
Unk4 uint8
MinHR uint32
MaxHR uint32
Unk5 string
Unk6 string
}
type TournamentInfo21 struct {
Unk0 uint32
Unk1 uint32
Unk2 uint32
Unk3 uint8
}
type TournamentInfo22 struct {
Unk0 uint32
Unk1 uint32
Unk2 uint32
Unk3 uint8
Unk4 string
}
func handleMsgMhfInfoTournament(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfInfoTournament)
bf := byteframe.NewByteFrame()
tournamentInfo0 := []TournamentInfo0{}
tournamentInfo21 := []TournamentInfo21{}
tournamentInfo22 := []TournamentInfo22{}
tournamentInfo0 := []model.TournamentInfo0{}
tournamentInfo21 := []model.TournamentInfo21{}
tournamentInfo22 := []model.TournamentInfo22{}
switch pkt.Unk0 {
case 0:
@@ -113,15 +77,9 @@ func handleMsgMhfEntryTournament(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket)
s.DoAckSimpleSucceed(pkt.AckHandle, make([]byte, 4))
}
type TournamentReward struct {
Unk0 uint16
Unk1 uint16
Unk2 uint16
}
func handleMsgMhfAcquireTournament(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfAcquireTournament)
rewards := []TournamentReward{}
rewards := []model.TournamentReward{}
bf := byteframe.NewByteFrame()
bf.WriteUint8(uint8(len(rewards)))
for _, reward := range rewards {

View File

@@ -2,9 +2,9 @@ package channelserver
import (
"erupe-ce/config"
"erupe-ce/internal/model"
"fmt"
"strings"
"time"
"github.com/jmoiron/sqlx"
"go.uber.org/zap"
@@ -14,28 +14,6 @@ import (
"erupe-ce/utils/stringsupport"
)
type TowerInfoTRP struct {
TR int32
TRP int32
}
type TowerInfoSkill struct {
TSP int32
Skills []int16 // 64
}
type TowerInfoHistory struct {
Unk0 []int16 // 5
Unk1 []int16 // 5
}
type TowerInfoLevel struct {
Floors int32
Unk1 int32
Unk2 int32
Unk3 int32
}
func EmptyTowerCSV(len int) string {
temp := make([]string, len)
for i := range temp {
@@ -47,18 +25,12 @@ func EmptyTowerCSV(len int) string {
func handleMsgMhfGetTowerInfo(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetTowerInfo)
var data []*byteframe.ByteFrame
type TowerInfo struct {
TRP []TowerInfoTRP
Skill []TowerInfoSkill
History []TowerInfoHistory
Level []TowerInfoLevel
}
towerInfo := TowerInfo{
TRP: []TowerInfoTRP{{0, 0}},
Skill: []TowerInfoSkill{{0, make([]int16, 64)}},
History: []TowerInfoHistory{{make([]int16, 5), make([]int16, 5)}},
Level: []TowerInfoLevel{{0, 0, 0, 0}, {0, 0, 0, 0}},
towerInfo := model.TowerInfo{
TRP: []model.TowerInfoTRP{{0, 0}},
Skill: []model.TowerInfoSkill{{0, make([]int16, 64)}},
History: []model.TowerInfoHistory{{make([]int16, 5), make([]int16, 5)}},
Level: []model.TowerInfoLevel{{0, 0, 0, 0}, {0, 0, 0, 0}},
}
var tempSkills string
@@ -149,7 +121,7 @@ func handleMsgMhfPostTowerInfo(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
}
// Default missions
var tenrouiraiData = []TenrouiraiData{
var tenrouiraiData = []model.TenrouiraiData{
{1, 1, 80, 0, 2, 2, 1, 1, 2, 2},
{1, 4, 16, 0, 2, 2, 1, 1, 2, 2},
{1, 6, 50, 0, 2, 2, 1, 0, 2, 2},
@@ -185,71 +157,14 @@ var tenrouiraiData = []TenrouiraiData{
{2, 6, 40, 0, 3, 1, 0, 0, 1, 1},
}
type TenrouiraiProgress struct {
Page uint8
Mission1 uint16
Mission2 uint16
Mission3 uint16
}
type TenrouiraiReward struct {
Index uint8
Item []uint16 // 5
Quantity []uint8 // 5
}
type TenrouiraiKeyScore struct {
Unk0 uint8
Unk1 int32
}
type TenrouiraiData struct {
Block uint8
Mission uint8
// 1 = Floors climbed
// 2 = Collect antiques
// 3 = Open chests
// 4 = Cats saved
// 5 = TRP acquisition
// 6 = Monster slays
Goal uint16
Cost uint16
Skill1 uint8 // 80
Skill2 uint8 // 40
Skill3 uint8 // 40
Skill4 uint8 // 20
Skill5 uint8 // 40
Skill6 uint8 // 50
}
type TenrouiraiCharScore struct {
Score int32
Name string
}
type TenrouiraiTicket struct {
Unk0 uint8
RP uint32
Unk2 uint32
}
type Tenrouirai struct {
Progress []TenrouiraiProgress
Reward []TenrouiraiReward
KeyScore []TenrouiraiKeyScore
Data []TenrouiraiData
CharScore []TenrouiraiCharScore
Ticket []TenrouiraiTicket
}
func handleMsgMhfGetTenrouirai(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetTenrouirai)
var data []*byteframe.ByteFrame
tenrouirai := Tenrouirai{
Progress: []TenrouiraiProgress{{1, 0, 0, 0}},
tenrouirai := model.Tenrouirai{
Progress: []model.TenrouiraiProgress{{1, 0, 0, 0}},
Data: tenrouiraiData,
Ticket: []TenrouiraiTicket{{0, 0, 0}},
Ticket: []model.TenrouiraiTicket{{0, 0, 0}},
}
switch pkt.Unk1 {
@@ -316,7 +231,7 @@ func handleMsgMhfGetTenrouirai(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
}
rows, _ := db.Query(fmt.Sprintf(`SELECT name, tower_mission_%d FROM guild_characters gc INNER JOIN characters c ON gc.character_id = c.id WHERE guild_id=$1 AND tower_mission_%d IS NOT NULL ORDER BY tower_mission_%d DESC`, pkt.Unk3, pkt.Unk3, pkt.Unk3), pkt.GuildID)
for rows.Next() {
temp := TenrouiraiCharScore{}
temp := model.TenrouiraiCharScore{}
rows.Scan(&temp.Name, &temp.Score)
tenrouirai.CharScore = append(tenrouirai.CharScore, temp)
}
@@ -409,28 +324,16 @@ func handleMsgMhfPresentBox(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
s.DoAckEarthSucceed(pkt.AckHandle, data)
}
type GemInfo struct {
Gem uint16
Quantity uint16
}
type GemHistory struct {
Gem uint16
Message uint16
Timestamp time.Time
Sender string
}
func handleMsgMhfGetGemInfo(s *Session, db *sqlx.DB, p mhfpacket.MHFPacket) {
pkt := p.(*mhfpacket.MsgMhfGetGemInfo)
var data []*byteframe.ByteFrame
gemInfo := []GemInfo{}
gemHistory := []GemHistory{}
gemInfo := []model.GemInfo{}
gemHistory := []model.GemHistory{}
var tempGems string
db.QueryRow(`SELECT COALESCE(gems, $1) FROM tower WHERE char_id=$2`, EmptyTowerCSV(30), s.CharID).Scan(&tempGems)
for i, v := range stringsupport.CSVElems(tempGems) {
gemInfo = append(gemInfo, GemInfo{uint16((i / 5 << 8) + (i%5 + 1)), uint16(v)})
gemInfo = append(gemInfo, model.GemInfo{uint16((i / 5 << 8) + (i%5 + 1)), uint16(v)})
}
switch pkt.Unk0 {