diff --git a/core/Engine.go b/core/Engine.go index 6415f014..7b054aa4 100644 --- a/core/Engine.go +++ b/core/Engine.go @@ -259,8 +259,11 @@ func (v *Engine) LoadFile(fileName string) []byte { if !mpq.FileExists(fileName) { continue } - v.Files[fileName] = path.Join(v.Settings.MpqPath, mpqFile) result, _ := mpq.ReadFile(fileName) + if len(result) == 0 { + continue + } + v.Files[fileName] = path.Join(v.Settings.MpqPath, mpqFile) return result } log.Fatalf("Could not load %s from MPQs", fileName) diff --git a/mpq/MPQ.go b/mpq/MPQ.go index 60554102..fe2e8953 100644 --- a/mpq/MPQ.go +++ b/mpq/MPQ.go @@ -227,7 +227,7 @@ func (v MPQ) getFileHashEntry(fileName string) (HashTableEntry, error) { func (v MPQ) GetFileBlockData(fileName string) (BlockTableEntry, error) { fileName = strings.ReplaceAll(fileName, "{LANG}", resourcepaths.LanguageCode) fileEntry, err := v.getFileHashEntry(fileName) - if err != nil { + if err != nil || fileEntry.BlockIndex >= uint32(len(v.BlockTableEntries)) { return BlockTableEntry{}, err } return v.BlockTableEntries[fileEntry.BlockIndex], nil