2020-06-21 18:40:37 -04:00
|
|
|
package d2maprenderer
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2enum"
|
2020-06-29 00:41:58 -04:00
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
|
2020-06-21 18:40:37 -04:00
|
|
|
)
|
|
|
|
|
2020-06-29 00:41:58 -04:00
|
|
|
var imageCacheRecords map[uint32]d2interface.Surface
|
2020-06-21 18:40:37 -04:00
|
|
|
|
2020-07-09 16:11:01 -04:00
|
|
|
// InvalidateImageCache the global region image cache. Call this when you are changing regions.
|
2020-06-21 18:40:37 -04:00
|
|
|
func InvalidateImageCache() {
|
|
|
|
imageCacheRecords = nil
|
|
|
|
}
|
|
|
|
|
2020-06-29 00:41:58 -04:00
|
|
|
func (mr *MapRenderer) getImageCacheRecord(style, sequence byte, tileType d2enum.TileType, randomIndex byte) d2interface.Surface {
|
2020-06-21 18:40:37 -04:00
|
|
|
lookupIndex := uint32(style)<<24 | uint32(sequence)<<16 | uint32(tileType)<<8 | uint32(randomIndex)
|
|
|
|
return imageCacheRecords[lookupIndex]
|
|
|
|
}
|
|
|
|
|
2020-06-29 00:41:58 -04:00
|
|
|
func (mr *MapRenderer) setImageCacheRecord(style, sequence byte, tileType d2enum.TileType, randomIndex byte, image d2interface.Surface) {
|
2020-06-21 18:40:37 -04:00
|
|
|
lookupIndex := uint32(style)<<24 | uint32(sequence)<<16 | uint32(tileType)<<8 | uint32(randomIndex)
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
if imageCacheRecords == nil {
|
2020-06-29 00:41:58 -04:00
|
|
|
imageCacheRecords = make(map[uint32]d2interface.Surface)
|
2020-06-21 18:40:37 -04:00
|
|
|
}
|
2020-07-09 16:11:01 -04:00
|
|
|
|
2020-06-21 18:40:37 -04:00
|
|
|
imageCacheRecords[lookupIndex] = image
|
|
|
|
}
|