2020-01-26 00:39:13 -05:00
|
|
|
package d2datadict
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
|
|
|
)
|
|
|
|
|
2020-06-30 09:17:07 -04:00
|
|
|
// LevelWarpRecord is a representation of a row from lvlwarp.txt
|
|
|
|
// it describes the warp graphics offsets and dimensions for levels
|
2020-01-26 00:39:13 -05:00
|
|
|
type LevelWarpRecord struct {
|
2020-07-07 08:56:31 -04:00
|
|
|
Name string
|
|
|
|
ID int
|
|
|
|
SelectX int
|
|
|
|
SelectY int
|
|
|
|
SelectDX int
|
|
|
|
SelectDY int
|
|
|
|
ExitWalkX int
|
|
|
|
ExitWalkY int
|
|
|
|
OffsetX int
|
|
|
|
OffsetY int
|
2020-01-26 00:39:13 -05:00
|
|
|
LitVersion bool
|
2020-07-07 08:56:31 -04:00
|
|
|
Tiles int
|
2020-01-26 00:39:13 -05:00
|
|
|
Direction string
|
|
|
|
}
|
|
|
|
|
2020-06-29 12:37:11 -04:00
|
|
|
// LevelWarps loaded from txt records
|
2020-06-30 09:17:07 -04:00
|
|
|
//nolint:gochecknoglobals // Currently global by design, only written once
|
2020-01-26 00:39:13 -05:00
|
|
|
var LevelWarps map[int]*LevelWarpRecord
|
|
|
|
|
2020-06-29 12:37:11 -04:00
|
|
|
// LoadLevelWarps loads LevelWarpRecord's from text file data
|
2020-07-07 08:56:31 -04:00
|
|
|
func LoadLevelWarps(file []byte) {
|
2020-01-26 00:39:13 -05:00
|
|
|
LevelWarps = make(map[int]*LevelWarpRecord)
|
2020-06-29 12:37:11 -04:00
|
|
|
|
2020-07-07 08:56:31 -04:00
|
|
|
d := d2common.LoadDataDictionary(file)
|
|
|
|
for d.Next() {
|
|
|
|
record := &LevelWarpRecord{
|
|
|
|
Name: d.String("Name"),
|
2020-07-23 12:56:50 -04:00
|
|
|
ID: d.Number("ID"),
|
2020-07-07 08:56:31 -04:00
|
|
|
SelectX: d.Number("SelectX"),
|
|
|
|
SelectY: d.Number("SelectY"),
|
|
|
|
SelectDX: d.Number("SelectDX"),
|
|
|
|
SelectDY: d.Number("SelectDY"),
|
|
|
|
ExitWalkX: d.Number("ExitWalkX"),
|
|
|
|
ExitWalkY: d.Number("ExitWalkY"),
|
|
|
|
OffsetX: d.Number("OffsetX"),
|
|
|
|
OffsetY: d.Number("OffsetY"),
|
|
|
|
LitVersion: d.Bool("LitVersion"),
|
|
|
|
Tiles: d.Number("Tiles"),
|
|
|
|
Direction: d.String("Direction"),
|
|
|
|
}
|
|
|
|
LevelWarps[record.ID] = record
|
2020-01-26 00:39:13 -05:00
|
|
|
}
|
2020-06-29 12:37:11 -04:00
|
|
|
|
2020-01-26 00:39:13 -05:00
|
|
|
log.Printf("Loaded %d level warps", len(LevelWarps))
|
|
|
|
}
|