1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-10-31 16:27:18 -04:00
OpenDiablo2/Common/LevelTypes.go
Tim Sarbin 1afd86005e
Changes necessary for migration to org account (#67)
* Replaced old repo path with org path.

* Added editorconfig. Fixed line endings to LF.

* Fixed travis build badge path
2019-11-02 17:38:39 -04:00

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)
}