Skip to content

Commit

Permalink
Update to new API name
Browse files Browse the repository at this point in the history
  • Loading branch information
TeamSpen210 committed Oct 30, 2024
1 parent ba596e3 commit 6c7ece8
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/hammeraddons/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
import re
import sys

from srctools import AtomicWriter, Keyvalues, logger
from srctools import AtomicWriter, Keyvalues, conv_int, logger
from srctools.filesys import FileSystem, FileSystemChain, RawFileSystem, VPKFileSystem
from srctools.game import Game
import attrs

from .plugin import BUILTIN as BUILTIN_PLUGIN, PluginFinder, Source as PluginSource
from .props_config import Opt, Options

from srctools.game_mount import GetApp
from srctools.steam import find_app

LOGGER = logger.get_logger(__name__)
CONF_NAME: Final = 'srctools.vdf'
Expand Down Expand Up @@ -196,21 +196,21 @@ def parse(map_path: Path, game_folder: Optional[str]='') -> Config:
raise ValueError('Config "searchpaths" value cannot have children.')
assert isinstance(kv.value, str)

st = None
if (end := kv.value.find(">")) and kv.value.startswith("<"): #Game mount, we just replace the <appid> with a path, this will ensure compatibility with .vpk
st = kv.value[1:end] # Omit the first character, <
appid = 0
# Game mount, we just replace the <appid> with a path, this will ensure compatibility with .vpk
if (end := kv.value.find(">")) and kv.value.startswith("<"):
appid = conv_int(kv.value[1:end])

if appid != -1:
LOGGER.info("Mounting appid {}", appid)
try:
st = int(st)
except ValueError: #Cannot convert
st = None

if st:
LOGGER.info(f"Mounting appid {st}")
if (st := GetApp(st)): #Ensure we can locate the game
name, apath = st #unpack
LOGGER.info(f"Mounted game {st[0]} with path: {str(st[1])}")
kv.value = apath.as_posix() + "/" + kv.value[end + 1:]

info = find_app(appid)
except KeyError:
LOGGER.warning("No game with appid {} found!", appid)
else:
LOGGER.info(f"Mounted game {info.name} with path: {info.path}")
kv.value = (info.path / kv.value[end + 1:]).as_posix()

if kv.value.endswith('.vpk'):
fsys = VPKFileSystem(str(expand_path(kv.value)))
else:
Expand Down

0 comments on commit 6c7ece8

Please sign in to comment.