27 lines
652 B
Go
27 lines
652 B
Go
package memory
|
|
|
|
import (
|
|
"github.com/hectorgimenez/d2go/pkg/data/area"
|
|
)
|
|
|
|
func (gd *GameReader) TerrorZones() (areas []area.ID) {
|
|
const maxActiveZoneCount = 16
|
|
|
|
structPtr := gd.moduleBaseAddressPtr + gd.offset.TZ
|
|
zonesPtr := uintptr(gd.ReadUInt(structPtr, Uint64))
|
|
actualActiveZoneCount := int(gd.ReadUInt(structPtr+0x8, Uint8))
|
|
if zonesPtr == 0 || actualActiveZoneCount <= 0 || actualActiveZoneCount > maxActiveZoneCount {
|
|
return nil
|
|
}
|
|
|
|
for i := 0; i < actualActiveZoneCount; i++ {
|
|
tzArea := gd.ReadUInt(zonesPtr+uintptr(i*Uint32), Uint32)
|
|
id := area.ID(tzArea)
|
|
if id.CanBeTerrorized() {
|
|
areas = append(areas, id)
|
|
}
|
|
}
|
|
|
|
return
|
|
}
|