mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-11 19:17:09 -05:00
MPQ memory improvements (#399)
This commit is contained in:
parent
2835ff4cf1
commit
0c27ae63e6
@ -160,11 +160,13 @@ func (v *MPQ) loadHashTable() {
|
|||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
hashData := make([]uint32, v.Data.HashTableEntries*4)
|
hashData := make([]uint32, v.Data.HashTableEntries*4)
|
||||||
err = binary.Read(v.File, binary.LittleEndian, &hashData)
|
hash := make([]byte, 4)
|
||||||
if err != nil {
|
for i := range hashData {
|
||||||
log.Panic(err)
|
v.File.Read(hash[:])
|
||||||
|
hashData[i] = binary.LittleEndian.Uint32(hash)
|
||||||
}
|
}
|
||||||
decrypt(hashData, hashString("(hash table)", 3))
|
decrypt(hashData, hashString("(hash table)", 3))
|
||||||
|
|
||||||
for i := uint32(0); i < v.Data.HashTableEntries; i++ {
|
for i := uint32(0); i < v.Data.HashTableEntries; i++ {
|
||||||
v.HashEntryMap.Insert(&HashTableEntry{
|
v.HashEntryMap.Insert(&HashTableEntry{
|
||||||
NamePartA: hashData[i*4],
|
NamePartA: hashData[i*4],
|
||||||
@ -182,12 +184,15 @@ func (v *MPQ) loadBlockTable() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
blockData := make([]uint32, v.Data.BlockTableEntries*4)
|
blockData := make([]uint32, v.Data.BlockTableEntries*4)
|
||||||
err = binary.Read(v.File, binary.LittleEndian, &blockData)
|
hash := make([]byte, 4)
|
||||||
if err != nil {
|
for i := range blockData {
|
||||||
log.Panic(err)
|
v.File.Read(hash[:])
|
||||||
|
blockData[i] = binary.LittleEndian.Uint32(hash)
|
||||||
}
|
}
|
||||||
decrypt(blockData, hashString("(block table)", 3))
|
decrypt(blockData, hashString("(block table)", 3))
|
||||||
|
|
||||||
for i := uint32(0); i < v.Data.BlockTableEntries; i++ {
|
for i := uint32(0); i < v.Data.BlockTableEntries; i++ {
|
||||||
v.BlockTableEntries = append(v.BlockTableEntries, BlockTableEntry{
|
v.BlockTableEntries = append(v.BlockTableEntries, BlockTableEntry{
|
||||||
FilePosition: blockData[(i * 4)],
|
FilePosition: blockData[(i * 4)],
|
||||||
|
Loading…
Reference in New Issue
Block a user