mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-01 08:54:20 -04:00
Fixed LevelTypes load (#84)
This commit is contained in:
parent
18ec052133
commit
c32c24739e
@ -8,30 +8,44 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LevelTypeRecord struct {
|
type LevelTypeRecord struct {
|
||||||
Files [32]string
|
Name string
|
||||||
Act int32
|
Id int
|
||||||
|
Files [32]string
|
||||||
|
Beta bool
|
||||||
|
Act int
|
||||||
|
Expansion bool
|
||||||
}
|
}
|
||||||
|
|
||||||
var LevelTypes []LevelTypeRecord
|
var LevelTypes []LevelTypeRecord
|
||||||
|
|
||||||
func LoadLevelTypes(fileProvider FileProvider) {
|
func LoadLevelTypes(fileProvider FileProvider) {
|
||||||
levelTypesData := fileProvider.LoadFile(ResourcePaths.LevelType)
|
data := strings.Split(string(fileProvider.LoadFile(ResourcePaths.LevelType)), "\r\n")[1:]
|
||||||
sr := CreateStreamReader(levelTypesData)
|
LevelTypes = make([]LevelTypeRecord, len(data))
|
||||||
numRecords := sr.GetInt32()
|
for i, line := range data {
|
||||||
LevelTypes = make([]LevelTypeRecord, numRecords)
|
idx := -1
|
||||||
for i := range LevelTypes {
|
inc := func() int {
|
||||||
for fileIdx := 0; fileIdx < 32; fileIdx++ {
|
idx++
|
||||||
strData, _ := sr.ReadBytes(60)
|
return idx
|
||||||
s := strings.Trim(string(strData), string(0))
|
}
|
||||||
if s == "0" {
|
if len(line) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
parts := strings.Split(line, "\t")
|
||||||
|
if parts[0] == "Expansion" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
LevelTypes[i].Name = parts[inc()]
|
||||||
|
LevelTypes[i].Id = StringToInt(parts[inc()])
|
||||||
|
for fileIdx := range LevelTypes[i].Files {
|
||||||
|
LevelTypes[i].Files[fileIdx] = parts[inc()]
|
||||||
|
if LevelTypes[i].Files[fileIdx] == "0" {
|
||||||
LevelTypes[i].Files[fileIdx] = ""
|
LevelTypes[i].Files[fileIdx] = ""
|
||||||
} else {
|
|
||||||
LevelTypes[i].Files[fileIdx] = s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
LevelTypes[i].Act = int32(sr.GetByte())
|
LevelTypes[i].Beta = parts[inc()] != "1"
|
||||||
|
LevelTypes[i].Act = StringToInt(parts[inc()])
|
||||||
|
LevelTypes[i].Expansion = parts[inc()] != "1"
|
||||||
}
|
}
|
||||||
log.Printf("Loaded %d LevelType records", numRecords)
|
log.Printf("Loaded %d LevelType records", len(LevelTypes))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user