2019-11-08 01:37:21 -05:00
|
|
|
package tests
|
|
|
|
|
|
|
|
import (
|
2019-11-08 19:52:49 -05:00
|
|
|
"log"
|
2019-11-08 01:37:21 -05:00
|
|
|
"path"
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
2019-11-10 10:44:13 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2data/d2cof"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2data/d2dcc"
|
2019-11-08 19:52:49 -05:00
|
|
|
|
2019-11-10 03:36:53 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2core"
|
2019-11-08 01:37:21 -05:00
|
|
|
|
2019-11-10 08:51:02 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2data/d2mpq"
|
2019-11-10 03:36:53 -05:00
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
2019-11-08 01:37:21 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestMPQScanPerformance(t *testing.T) {
|
2019-11-08 19:52:49 -05:00
|
|
|
log.SetFlags(log.Ldate | log.LUTC | log.Lmicroseconds | log.Llongfile)
|
2019-11-10 08:51:02 -05:00
|
|
|
d2mpq.InitializeCryptoBuffer()
|
2019-11-10 03:36:53 -05:00
|
|
|
d2common.ConfigBasePath = "../"
|
|
|
|
config := d2common.LoadConfiguration()
|
|
|
|
engine := d2core.CreateEngine()
|
2019-11-08 01:37:21 -05:00
|
|
|
for _, fileName := range config.MpqLoadOrder {
|
|
|
|
mpqFile := path.Join(config.MpqPath, fileName)
|
2019-11-10 08:51:02 -05:00
|
|
|
archive, _ := d2mpq.Load(mpqFile)
|
2019-11-08 01:37:21 -05:00
|
|
|
files, err := archive.GetFileList()
|
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
for _, archiveFile := range files {
|
|
|
|
// Temporary until all audio formats are supported
|
|
|
|
if strings.Contains(archiveFile, ".wav") || strings.Contains(archiveFile, ".pif") {
|
|
|
|
continue
|
|
|
|
}
|
2019-11-08 19:52:49 -05:00
|
|
|
parts := strings.Split(archiveFile, ".")
|
|
|
|
switch strings.ToLower(parts[len(parts)-1]) {
|
|
|
|
case "coff":
|
2019-11-10 10:44:13 -05:00
|
|
|
_ = d2cof.LoadCOF(archiveFile, engine)
|
2019-11-08 19:52:49 -05:00
|
|
|
case "dcc":
|
|
|
|
if strings.ContainsAny(archiveFile, "common") {
|
|
|
|
continue
|
|
|
|
}
|
2019-11-10 10:44:13 -05:00
|
|
|
_ = d2dcc.LoadDCC(archiveFile, engine)
|
2019-11-08 19:52:49 -05:00
|
|
|
}
|
|
|
|
|
2019-11-08 01:37:21 -05:00
|
|
|
_, _ = archive.ReadFile(archiveFile)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|