mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-19 02:46:35 -05:00
38 lines
803 B
Go
38 lines
803 B
Go
|
package Common
|
||
|
|
||
|
import (
|
||
|
"log"
|
||
|
"strings"
|
||
|
|
||
|
"github.com/essial/OpenDiablo2/ResourcePaths"
|
||
|
)
|
||
|
|
||
|
type LevelTypeRecord struct {
|
||
|
Files [32]string
|
||
|
Act int32
|
||
|
}
|
||
|
|
||
|
var LevelTypes []LevelTypeRecord
|
||
|
|
||
|
func LoadLevelTypes(fileProvider FileProvider) {
|
||
|
levelTypesData := fileProvider.LoadFile(ResourcePaths.LevelType)
|
||
|
sr := CreateStreamReader(levelTypesData)
|
||
|
numRecords := sr.GetInt32()
|
||
|
LevelTypes = make([]LevelTypeRecord, numRecords)
|
||
|
for i := range LevelTypes {
|
||
|
for fileIdx := 0; fileIdx < 32; fileIdx++ {
|
||
|
strData, _ := sr.ReadBytes(60)
|
||
|
s := strings.Trim(string(strData), string(0))
|
||
|
if s == "0" {
|
||
|
LevelTypes[i].Files[fileIdx] = ""
|
||
|
} else {
|
||
|
LevelTypes[i].Files[fileIdx] = s
|
||
|
}
|
||
|
|
||
|
}
|
||
|
LevelTypes[i].Act = int32(sr.GetByte())
|
||
|
|
||
|
}
|
||
|
log.Printf("Loaded %d LevelType records", numRecords)
|
||
|
}
|