Item price support
This commit is contained in:
@@ -18,16 +18,19 @@ type MappingCache struct {
|
||||
byID map[int]*MappingItem
|
||||
byName map[string]*MappingItem
|
||||
cacheDir string
|
||||
game string
|
||||
}
|
||||
|
||||
// NewMappingCache creates a mapping cache backed by the given client.
|
||||
func NewMappingCache(client *Client) *MappingCache {
|
||||
// The game parameter scopes the cache file (e.g. "osrs" or "rs3").
|
||||
func NewMappingCache(client *Client, game string) *MappingCache {
|
||||
home, _ := os.UserHomeDir()
|
||||
return &MappingCache{
|
||||
client: client,
|
||||
byID: make(map[int]*MappingItem),
|
||||
byName: make(map[string]*MappingItem),
|
||||
cacheDir: filepath.Join(home, ".rsw", "cache"),
|
||||
game: game,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +84,8 @@ func (mc *MappingCache) index() {
|
||||
}
|
||||
|
||||
func (mc *MappingCache) cachePath() string {
|
||||
return filepath.Join(mc.cacheDir, "mapping.json")
|
||||
filename := mc.game + "_mapping.json"
|
||||
return filepath.Join(mc.cacheDir, filename)
|
||||
}
|
||||
|
||||
func (mc *MappingCache) loadFromDisk() bool {
|
||||
|
||||
Reference in New Issue
Block a user