1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-09 03:37:17 -05:00
OpenDiablo2/tests/MPQ_test.go
Tim Sarbin ed88d0e00d
Test updates. MPQ file name changes. (#119)
* Modified path logic to hopefully fix some issues
2019-11-08 19:52:49 -05:00

49 lines
1.2 KiB
Go

package tests
import (
"log"
"path"
"strings"
"testing"
"github.com/OpenDiablo2/OpenDiablo2/core"
"github.com/OpenDiablo2/OpenDiablo2/mpq"
"github.com/OpenDiablo2/OpenDiablo2/common"
)
func TestMPQScanPerformance(t *testing.T) {
log.SetFlags(log.Ldate | log.LUTC | log.Lmicroseconds | log.Llongfile)
mpq.InitializeCryptoBuffer()
common.ConfigBasePath = "../"
config := common.LoadConfiguration()
engine := core.CreateEngine()
for _, fileName := range config.MpqLoadOrder {
mpqFile := path.Join(config.MpqPath, fileName)
archive, _ := mpq.Load(mpqFile)
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
}
parts := strings.Split(archiveFile, ".")
switch strings.ToLower(parts[len(parts)-1]) {
case "coff":
_ = common.LoadCof(archiveFile, engine)
case "dcc":
if strings.ContainsAny(archiveFile, "common") {
continue
}
_ = common.LoadDCC(archiveFile, engine)
}
_, _ = archive.ReadFile(archiveFile)
}
}
}