1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-20 22:25:24 +00:00

Prevent some map load crashes. (#206)

This commit is contained in:
Tim Sarbin 2019-11-17 22:55:31 -05:00 committed by GitHub
parent 30b680d9d1
commit 908d186fea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View File

@ -161,7 +161,7 @@ func (v *AnimatedEntity) Render(target *ebiten.Image, offsetX, offsetY int) {
}
}
}
if v.currentFrame < 0 || v.frames == nil || v.currentFrame > len(v.frames) || v.frames[v.currentFrame] == nil {
if v.currentFrame < 0 || v.frames == nil || v.currentFrame >= len(v.frames) || v.frames[v.currentFrame] == nil {
return
}
localX := (v.subcellX - v.subcellY) * 16
@ -248,7 +248,7 @@ func (v *AnimatedEntity) updateFrameCache() {
if v.Cof.CofLayers[cofLayerIdx].Transparent {
transparency = byte(128)
}
if animationIdx > len(dccLayer.Directions[v.direction].Frames) {
if animationIdx >= len(dccLayer.Directions[v.direction].Frames) {
log.Printf("Invalid animation index of %d for animated entity", animationIdx)
continue
}

View File

@ -203,6 +203,9 @@ func (v *Region) renderWall(tile d2ds1.WallRecord, offsetX, offsetY int, target
img := v.GetImageCacheRecord(tile.MainIndex, tile.SubIndex, tile.Orientation)
if img == nil {
img = v.generateWallCache(tile)
if img == nil {
return
}
}
tileData := v.getTile(int32(tile.MainIndex), int32(tile.SubIndex), int32(tile.Orientation))
if tileData == nil {