2019-11-10 08:51:02 -05:00
|
|
|
package d2datadict
|
2019-11-03 11:04:58 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2019-11-10 08:51:02 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2resource"
|
|
|
|
|
2019-11-10 03:36:53 -05:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
2019-11-03 11:04:58 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type LevelWarpRecord struct {
|
|
|
|
Id int32
|
|
|
|
SelectX int32
|
|
|
|
SelectY int32
|
|
|
|
SelectDX int32
|
|
|
|
SelectDY int32
|
|
|
|
ExitWalkX int32
|
|
|
|
ExitWalkY int32
|
|
|
|
OffsetX int32
|
|
|
|
OffsetY int32
|
|
|
|
LitVersion bool
|
|
|
|
Tiles int32
|
|
|
|
Direction string
|
|
|
|
}
|
|
|
|
|
|
|
|
var LevelWarps map[int]*LevelWarpRecord
|
|
|
|
|
2019-11-10 03:36:53 -05:00
|
|
|
func LoadLevelWarps(fileProvider d2interface.FileProvider) {
|
2019-11-03 11:04:58 -05:00
|
|
|
LevelWarps = make(map[int]*LevelWarpRecord)
|
2019-11-10 08:51:02 -05:00
|
|
|
levelWarpData := fileProvider.LoadFile(d2resource.LevelWarp)
|
2019-11-10 03:36:53 -05:00
|
|
|
streamReader := d2common.CreateStreamReader(levelWarpData)
|
2019-11-03 11:04:58 -05:00
|
|
|
numRecords := int(streamReader.GetInt32())
|
|
|
|
for i := 0; i < numRecords; i++ {
|
|
|
|
id := int(streamReader.GetInt32())
|
|
|
|
LevelWarps[id] = &LevelWarpRecord{}
|
|
|
|
LevelWarps[id].Id = int32(id)
|
|
|
|
LevelWarps[id].SelectX = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].SelectY = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].SelectDX = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].SelectDY = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].ExitWalkX = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].ExitWalkY = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].OffsetX = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].OffsetY = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].LitVersion = streamReader.GetInt32() == 1
|
|
|
|
LevelWarps[id].Tiles = streamReader.GetInt32()
|
|
|
|
LevelWarps[id].Direction = string(streamReader.GetByte())
|
|
|
|
streamReader.SkipBytes(3)
|
|
|
|
}
|
|
|
|
log.Printf("Loaded %d level warps", len(LevelWarps))
|
|
|
|
}
|