mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-11 11:06:30 -05:00
* Comments and newlines in engine.go * Comments and newlines in object.go * Comments and newlines in animated_entity.go * Comments and newlines in missile.go * Comments and newlines in npc.go * Comments and newlines in player.go * Removed object.go (incorrectly merged it in during rebase). * Comments and newlines in renderer.go. * Comments and newlines in map_entity.go. * Comments and newlines in walk_mesh.go. * Comments and newlines in viewport.go and tile_cache.go. * Comments and newlines in stamp.go and wilderness_tile_types.go. * Comments and newlines in everything else.
29 lines
1006 B
Go
29 lines
1006 B
Go
package d2maprenderer
|
|
|
|
import (
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
|
)
|
|
|
|
var imageCacheRecords map[uint32]d2interface.Surface
|
|
|
|
// InvalidateImageCache the global region image cache. Call this when you are changing regions.
|
|
func InvalidateImageCache() {
|
|
imageCacheRecords = nil
|
|
}
|
|
|
|
func (mr *MapRenderer) getImageCacheRecord(style, sequence byte, tileType d2enum.TileType, randomIndex byte) d2interface.Surface {
|
|
lookupIndex := uint32(style)<<24 | uint32(sequence)<<16 | uint32(tileType)<<8 | uint32(randomIndex)
|
|
return imageCacheRecords[lookupIndex]
|
|
}
|
|
|
|
func (mr *MapRenderer) setImageCacheRecord(style, sequence byte, tileType d2enum.TileType, randomIndex byte, image d2interface.Surface) {
|
|
lookupIndex := uint32(style)<<24 | uint32(sequence)<<16 | uint32(tileType)<<8 | uint32(randomIndex)
|
|
|
|
if imageCacheRecords == nil {
|
|
imageCacheRecords = make(map[uint32]d2interface.Surface)
|
|
}
|
|
|
|
imageCacheRecords[lookupIndex] = image
|
|
}
|