Skip to content

Commit

Permalink
Update fixup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
revoconner authored Nov 22, 2024
1 parent f09c4fe commit 93a9217
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions fixup.py
Original file line number Diff line number Diff line change
@@ -25,23 +25,19 @@ def fix_redirectors(game_path, batch_size=1, delay_between_batches=2.0, delay_be

processed_count = 0

# Find all redirectors in the path
for path in asset_list:
# Add small delay every 50 items during search to prevent engine strain
if processed_count > 0 and processed_count % 50 == 0:
time.sleep(0.2)

# Skip directories
if unreal.EditorAssetLibrary.does_directory_exist(path):
continue

# Check if asset exists
if unreal.EditorAssetLibrary.does_asset_exist(path):
asset_data = unreal.EditorAssetLibrary.find_asset_data(path)
asset_class = str(asset_data.asset_class)

if asset_class == 'ObjectRedirector':
# Remove the .asset_name part if present
clean_path = path.split(".")[0]
redirectors.append(clean_path)
processed_count += 1
@@ -54,7 +50,6 @@ def fix_redirectors(game_path, batch_size=1, delay_between_batches=2.0, delay_be
total_redirectors = len(redirectors)
unreal.log(f"\nFound {total_redirectors} redirectors to process...")

# Process redirectors in batches
for batch_start in range(0, total_redirectors, batch_size):
batch_end = min(batch_start + batch_size, total_redirectors)
current_batch = redirectors[batch_start:batch_end]
@@ -64,23 +59,18 @@ def fix_redirectors(game_path, batch_size=1, delay_between_batches=2.0, delay_be
unreal.log(f"\nProcessing batch {batch_number}/{total_batches} ({len(current_batch)} redirectors)...")

try:
# Fix redirectors in this batch
unreal.RedirectorFixerBPLibrary.fixup_referencers(current_batch)
unreal.log(f"Successfully processed batch {batch_number}")

# Save after each batch
unreal.log("Saving changes for this batch...")
unreal.EditorAssetLibrary.save_directory(game_path, recursive=True, only_if_is_dirty=False)

# Force garbage collection after each batch
unreal.SystemLibrary.collect_garbage()

# Add delay between items in batch
for i in range(len(current_batch)):
if i > 0: # Don't delay after the last item
time.sleep(delay_between_items)

# Add delay between batches if not the last batch
if batch_end < total_redirectors:
unreal.log(f"Waiting {delay_between_batches}s before next batch...")
time.sleep(delay_between_batches)
@@ -90,7 +80,6 @@ def fix_redirectors(game_path, batch_size=1, delay_between_batches=2.0, delay_be
unreal.log_warning("Waiting additional time before continuing...")
time.sleep(delay_between_batches * 2) # Double delay after error

# Final garbage collection
unreal.SystemLibrary.collect_garbage()

# Final log
@@ -101,12 +90,12 @@ def fix_redirectors(game_path, batch_size=1, delay_between_batches=2.0, delay_be
unreal.log("\nProcess completed!")


############-----------------------------------###################
# ############## replace the path with your desired path #################################
############--------------------------------------------###################
########### replace the path with your desired path ###################

GAME_PATH = "/Game/DLC/Avatars/Modular/"

# ######### CUSTOMISE THESE ############
########## CUSTOMISE THESE-- (Advanced) ############
fix_redirectors(
game_path=GAME_PATH,
batch_size=1, # Process 5 redirectors at a time

0 comments on commit 93a9217

Please sign in to comment.