mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-10-31 16:27:18 -04:00
1afd86005e
* Replaced old repo path with org path. * Added editorconfig. Fixed line endings to LF. * Fixed travis build badge path
38 lines
808 B
Go
38 lines
808 B
Go
package Common
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
|
|
"github.com/OpenDiablo2/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)
|
|
}
|