Skip to content

Commit

Permalink
Optimize by using precalculated hash, remove unneeded nil checks
Browse files Browse the repository at this point in the history
  • Loading branch information
icza committed Jun 16, 2018
1 parent fa83cbd commit 6549c22
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/s2prot/s2prot.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (

const (
appName = "s2prot"
appVersion = "v1.3.0"
appVersion = "v1.4.0"
appAuthor = "Andras Belicza"
appHome = "https://github.com/icza/s2prot"
)
Expand Down
8 changes: 4 additions & 4 deletions rep/rep.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ func newRep(m *mpq.MPQ, game, message, tracker bool) (parsedRep *Rep, errRes err
rep.protocol = p

data, err := m.FileByHash(620083690, 3548627612, 4013960850) // "replay.details"
if err != nil || data == nil || len(data) == 0 {
if err != nil || len(data) == 0 {
// Attempt to open the anonymized version
data, err = m.FileByName("replay.details.backup")
data, err = m.FileByHash(1421087648, 3590964654, 3400061273) // "replay.details.backup"
if err != nil || len(data) == 0 {
return nil, ErrInvalidRepFile
}
}
rep.Details = Details{Struct: p.DecodeDetails(data)}

data, err = m.FileByHash(3544165653, 1518242780, 4280631132) // "replay.initData"
if err != nil || data == nil || len(data) == 0 {
if err != nil || len(data) == 0 {
// Attempt to open the anonymized version
data, err = m.FileByName("replay.initData.backup")
data, err = m.FileByHash(868899905, 1282002788, 1614930827) // "replay.initData.backup"
if err != nil || len(data) == 0 {
return nil, ErrInvalidRepFile
}
Expand Down

0 comments on commit 6549c22

Please sign in to comment.