Skip to content

Commit

Permalink
Add filename ignorelist for collision detection
Browse files Browse the repository at this point in the history
And ignore collisions on README.md and LICENSE files.
  • Loading branch information
cyberrumor committed Dec 21, 2024
1 parent dcf297a commit 565b423
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions ammo/controller/mod.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@

log = logging.getLogger(__name__)

# Filenames which won't contribute to collision detection.
IGNORE_COLLISIONS = [
"LICENSE",
"README.md",
]


@dataclass(frozen=True, kw_only=True)
class Game:
Expand Down Expand Up @@ -262,6 +268,8 @@ def stage(self) -> dict:
for index, mod in enumerate(enabled_mods):
# Iterate through the source files of the mod
for src in mod.files:
if src.name in IGNORE_COLLISIONS:
continue
# Get the sanitized full path relative to the game.directory.
if mod.fomod:
corrected_name = (
Expand Down Expand Up @@ -463,6 +471,8 @@ def do_collisions(self, index: int) -> None:
def get_relative_files(mod: Mod):
# Iterate through the source files of the mod
for src in mod.files:
if src.name in IGNORE_COLLISIONS:
continue
# Get the sanitized full path relative to the game.directory.
if mod.fomod:
corrected_name = (
Expand Down Expand Up @@ -549,7 +559,7 @@ def do_log(self) -> None:
if self.game.ammo_log.exists():
with open(self.game.ammo_log, "r") as f:
lines = f.readlines()
_log = ''.join(lines[-min(len(lines), n):])
_log = "".join(lines[-min(len(lines), n) :])

raise Warning(_log)

Expand Down Expand Up @@ -689,7 +699,7 @@ def do_rename_mod(self, index: int, name: str) -> None:

# Move the folder, update the mod.
log.info(f"Renaming MOD {mod.name} to {name}")

mod.location.rename(new_location)
mod.location = new_location
mod.name = name
Expand Down

0 comments on commit 565b423

Please sign in to comment.