1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-10-31 16:27:18 -04:00
OpenDiablo2/Common/LevelWarp.go
ndechiara 46a60398d4 Load Objects.txt (#68)
* Missiles Parsing

* Missiles.txt lookup table and  fixes

* lost work

* Replaced old repo path with org path.

* Added editorconfig. Fixed line endings to LF.

* Fixed travis build badge path

* Added level warp data

* Added object type data load

* Load objects.txt

New Common class, Objects.go will load all of the object records in objects.txt
2019-11-03 11:04:58 -05:00

50 lines
1.4 KiB
Go

package Common
import (
"log"
"github.com/OpenDiablo2/OpenDiablo2/ResourcePaths"
)
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
func LoadLevelWarps(fileProvider FileProvider) {
LevelWarps = make(map[int]*LevelWarpRecord)
levelWarpData := fileProvider.LoadFile(ResourcePaths.LevelWarp)
streamReader := CreateStreamReader(levelWarpData)
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))
}