moved multikills to gc response, fixed multikills being incorrectly tracked
This commit is contained in:
@@ -63,6 +63,16 @@ func SteamId2AccountId(steamId uint64) uint32 {
|
|||||||
return uint32(steamId - 76561197960265728)
|
return uint32(steamId - 76561197960265728)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func playerStatsFromRound(round *protobuf.CMsgGCCStrike15V2_MatchmakingServerRoundStats, p *ent.Player) (int32, int32, int32, int32, int32, int32) {
|
||||||
|
for i, acc := range round.GetReservation().GetAccountIds() {
|
||||||
|
if AccountId2SteamId(acc) == p.ID {
|
||||||
|
return round.GetKills()[i], round.GetDeaths()[i], round.GetAssists()[i], round.GetEnemyHeadshots()[i], round.GetScores()[i], round.GetMvps()[i]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0, 0, 0, 0, 0, 0
|
||||||
|
}
|
||||||
|
|
||||||
func (d *DemoMatchLoader) HandleGCPacket(pkg *gamecoordinator.GCPacket) {
|
func (d *DemoMatchLoader) HandleGCPacket(pkg *gamecoordinator.GCPacket) {
|
||||||
switch pkg.MsgType {
|
switch pkg.MsgType {
|
||||||
case uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientWelcome):
|
case uint32(protobuf.EGCBaseClientMsg_k_EMsgGCClientWelcome):
|
||||||
@@ -364,6 +374,7 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
log.Warningf("[DL] Failure to get match-details for %d from GC: %v", demo.MatchId, err)
|
log.Warningf("[DL] Failure to get match-details for %d from GC: %v", demo.MatchId, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
matchZero := matchDetails.GetMatches()[0]
|
matchZero := matchDetails.GetMatches()[0]
|
||||||
lastRound := matchZero.GetRoundstatsall()[len(matchZero.Roundstatsall)-1]
|
lastRound := matchZero.GetRoundstatsall()[len(matchZero.Roundstatsall)-1]
|
||||||
var players []*ent.Player
|
var players []*ent.Player
|
||||||
@@ -403,23 +414,55 @@ func (d *DemoMatchLoader) gcWorker(apiKey string, rl ratelimit.Limiter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i, mPlayer := range players {
|
for i, mPlayer := range players {
|
||||||
var teamId int
|
var (
|
||||||
|
teamId int
|
||||||
|
mk2 uint
|
||||||
|
mk3 uint
|
||||||
|
mk4 uint
|
||||||
|
mk5 uint
|
||||||
|
)
|
||||||
|
|
||||||
if i > 4 {
|
if i > 4 {
|
||||||
teamId = 2
|
teamId = 2
|
||||||
} else {
|
} else {
|
||||||
teamId = 1
|
teamId = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var oldKills int32
|
||||||
|
for _, round := range matchZero.GetRoundstatsall() {
|
||||||
|
kills, _, _, _, _, _ := playerStatsFromRound(round, mPlayer)
|
||||||
|
|
||||||
|
killDiff := kills - oldKills
|
||||||
|
|
||||||
|
switch killDiff {
|
||||||
|
case 2:
|
||||||
|
mk2++
|
||||||
|
case 3:
|
||||||
|
mk3++
|
||||||
|
case 4:
|
||||||
|
mk4++
|
||||||
|
case 5:
|
||||||
|
mk5++
|
||||||
|
}
|
||||||
|
oldKills = kills
|
||||||
|
}
|
||||||
|
|
||||||
|
kills, deaths, assists, hs, score, mvp := playerStatsFromRound(lastRound, mPlayer)
|
||||||
d.lock.Lock()
|
d.lock.Lock()
|
||||||
err := d.db.Stats.Create().
|
err := d.db.Stats.Create().
|
||||||
SetMatches(tMatch).
|
SetMatches(tMatch).
|
||||||
SetPlayers(mPlayer).
|
SetPlayers(mPlayer).
|
||||||
SetTeamID(teamId).
|
SetTeamID(teamId).
|
||||||
SetKills(int(lastRound.GetKills()[i])).
|
SetKills(int(kills)).
|
||||||
SetDeaths(int(lastRound.GetDeaths()[i])).
|
SetDeaths(int(deaths)).
|
||||||
SetAssists(int(lastRound.GetAssists()[i])).
|
SetAssists(int(assists)).
|
||||||
SetMvp(uint(lastRound.GetMvps()[i])).
|
SetMvp(uint(mvp)).
|
||||||
SetScore(int(lastRound.GetScores()[i])).
|
SetScore(int(score)).
|
||||||
SetHeadshot(int(lastRound.GetEnemyHeadshots()[i])).
|
SetHeadshot(int(hs)).
|
||||||
|
SetMk2(mk2).
|
||||||
|
SetMk3(mk3).
|
||||||
|
SetMk4(mk4).
|
||||||
|
SetMk5(mk5).
|
||||||
Exec(context.Background())
|
Exec(context.Background())
|
||||||
d.lock.Unlock()
|
d.lock.Unlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@@ -147,7 +147,6 @@ func (p *DemoParser) parseWorker() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
killMap := make(map[uint64]int, 10)
|
|
||||||
eqMap := make(map[uint64][]*struct {
|
eqMap := make(map[uint64][]*struct {
|
||||||
Eq int
|
Eq int
|
||||||
HitGroup int
|
HitGroup int
|
||||||
@@ -218,26 +217,6 @@ func (p *DemoParser) parseWorker() {
|
|||||||
Spent int
|
Spent int
|
||||||
}{Round: gs.TotalRoundsPlayed(), EqV: p.EquipmentValueCurrent(), Bank: p.Money(), Spent: p.MoneySpentThisRound()})
|
}{Round: gs.TotalRoundsPlayed(), EqV: p.EquipmentValueCurrent(), Bank: p.Money(), Spent: p.MoneySpentThisRound()})
|
||||||
}
|
}
|
||||||
|
|
||||||
// track multikills
|
|
||||||
for _, igp := range gs.Participants().Playing() {
|
|
||||||
if igp != nil && igp.SteamID64 != 0 {
|
|
||||||
killDiff := igp.Kills() - killMap[igp.SteamID64]
|
|
||||||
tPlayer := p.getMatchPlayerBySteamID(tStats, igp.SteamID64)
|
|
||||||
|
|
||||||
switch killDiff {
|
|
||||||
case 2:
|
|
||||||
tPlayer.Mk2++
|
|
||||||
case 3:
|
|
||||||
tPlayer.Mk3++
|
|
||||||
case 4:
|
|
||||||
tPlayer.Mk4++
|
|
||||||
case 5:
|
|
||||||
tPlayer.Mk5++
|
|
||||||
}
|
|
||||||
killMap[igp.SteamID64] = igp.Kills()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// onPlayerFlashed
|
// onPlayerFlashed
|
||||||
@@ -336,10 +315,6 @@ func (p *DemoParser) parseWorker() {
|
|||||||
SetUdFlash(tMatchPlayer.UdFlash).
|
SetUdFlash(tMatchPlayer.UdFlash).
|
||||||
SetUdSmoke(tMatchPlayer.UdSmoke).
|
SetUdSmoke(tMatchPlayer.UdSmoke).
|
||||||
SetUdFlames(tMatchPlayer.UdFlames).
|
SetUdFlames(tMatchPlayer.UdFlames).
|
||||||
SetMk2(tMatchPlayer.Mk2).
|
|
||||||
SetMk3(tMatchPlayer.Mk3).
|
|
||||||
SetMk4(tMatchPlayer.Mk4).
|
|
||||||
SetMk5(tMatchPlayer.Mk5).
|
|
||||||
SetRankOld(tMatchPlayer.RankOld).
|
SetRankOld(tMatchPlayer.RankOld).
|
||||||
SetRankNew(tMatchPlayer.RankNew).
|
SetRankNew(tMatchPlayer.RankNew).
|
||||||
SetColor(tMatchPlayer.Color).
|
SetColor(tMatchPlayer.Color).
|
||||||
|
Reference in New Issue
Block a user