Last active
November 3, 2022 19:27
-
-
Save uniboi/8dda378adc18aeeb11892abe66e3774f to your computer and use it in GitHub Desktop.
copy scripts to compare for diffs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shit script I cobbled together in an hour | |
import os | |
import glob | |
import shutil | |
# vanilla files coop pr uploads | |
changed_files = [ | |
"sp_crashsite_script.ent", | |
"sp_s2s_script.ent", | |
"_event.gnut", | |
"_passives.gnut", | |
"_remote_functions_sp.gnut", | |
"_respawns.nut", | |
"_script_triggers.gnut", | |
"_sp_coop.gnut", | |
"_start_points.gnut", | |
"_state.gnut", | |
"_trigger_functions_sp.gnut", | |
"_triggers.nut", | |
"bt_genocide.nut", | |
"cl_respawnselect_sp.gnut", | |
"sv_earn_meter.gnut", | |
"sh_coop_custom_precache.gnut", | |
"sh_flag.gnut", | |
"sh_remote_functions_sp_custom.gnut", | |
"sh_sp_coop_lobby.gnut", | |
"_base_gametype_sp.gnut", | |
"_cl_gauntlet.gnut", | |
"_gamestate_sp.gnut", | |
"_sp_introscreen.gnut", | |
"_utility_sp.gnut", | |
"cl_sp_crashsite.nut", | |
"sp_beacon.nut", | |
"sp_beacon_common.nut", | |
"sp_beacon_ending.nut", | |
"sp_beacon_spoke0.nut", | |
"sp_hub_timeshift.nut", | |
"sp_s2s.nut", | |
"sp_timeshift_spoke02.nut", | |
"sp_timeshift_utility.nut", | |
"sh_sp_credits.nut", | |
"sh_start_points.nut", | |
"sp_boomtown.nut", | |
"sp_boomtown_assembly.nut", | |
"sp_boomtown_end.nut", | |
"sp_boomtown_start.nut", | |
"sp_boomtown_utility.nut", | |
"sp_crashsite.nut", | |
"sp_s2s_common.nut", | |
"sp_s2s_dropship.nut", | |
"sp_s2s_flight.nut", | |
"sp_sewer_common.nut", | |
"sp_sewers1.nut", | |
"sp_skyway_v1.nut", | |
"sp_tday.nut", | |
"sp_training.nut", | |
"_titan_hotdrop.gnut", | |
"sh_titan_fastball.nut" | |
] | |
modsDir = "./NorthstarMods/Northstar.Coop/mod/" | |
dumpDir = "./assets_dump/" # download the asset dump at https://salzgrube.club/static/assets_dump.zip | |
extrasDir = "./" # maybe in the future for .ent files | |
outputDir = "./comp/" # folder where the coop and vanilla files get dumped | |
if(os.path.exists(outputDir)): | |
shutil.rmtree(outputDir) # delete existing copies | |
def findScriptNameInDicts(arr, script): | |
for s in arr: | |
if(s["script"] == script): | |
return True | |
return False | |
def findScriptNameInDictsIndex(arr, script): | |
i = 0 # I forgor how for loops work in pyhton so I make my own index tracker | |
for s in arr: | |
if(s["script"] == script): | |
return i | |
i += 1 | |
return -1 | |
scripts_found = [] | |
for filename in glob.iglob(modsDir + '**/**', recursive=True): | |
if(not os.path.isfile(filename)): | |
continue | |
rev = "".join(reversed(filename)) | |
script = filename[len(filename) - rev.index("\\"):] | |
# print(script) | |
if(script in changed_files): | |
# glob iterates over the same files multiples times, but I can't be assed to read documentation | |
if not findScriptNameInDicts(scripts_found, script): | |
scripts_found.append({ | |
"script": script, | |
"filepath": filename | |
}) | |
missing_scripts = [] | |
# for script in changed_files: | |
# if(script not in scripts_found): | |
# missing_scripts.append(script) | |
for script in scripts_found: | |
found = False | |
for expected in changed_files: | |
if script["script"] == expected: | |
found = True | |
break | |
if not found: | |
missing_scripts.append(script["script"]) | |
# print(scripts_found) | |
print("expected files num: " + str(len(changed_files)) + "; found files num: " + str(len(scripts_found)) + "; missing files num: " + str(len(missing_scripts))) | |
van = [] | |
for file in glob.iglob(dumpDir + "**/**", recursive=True): | |
if(not os.path.isfile(file)): | |
continue | |
rev = "".join(reversed(file)) | |
script = file[len(file) - rev.index("\\"):] | |
if(script in changed_files): | |
van.append({ | |
"script": script, | |
"filepath": file | |
}) | |
print("vanilla scripts found: " + str(len(van))) | |
for vanillaScript in van: | |
idx = findScriptNameInDictsIndex(scripts_found, vanillaScript["script"]) | |
if(idx != -1): | |
# print("vanilla: " + str(vanillaScript["filepath"] + "\ncoop: " + str(scripts_found[idx]["filepath"]))) | |
spath = outputDir + vanillaScript["script"] | |
if(os.path.exists(spath)): | |
continue | |
os.makedirs(spath) | |
shutil.copy(vanillaScript["filepath"], spath) | |
os.rename(spath + "/" + vanillaScript["script"], spath + "/vanilla--" + vanillaScript["script"]) | |
for coopscript in scripts_found: | |
spath = outputDir + coopscript["script"] | |
if os.path.exists(spath) and os.path.isdir(spath): | |
shutil.copy(coopscript["filepath"], spath) | |
os.rename(spath + "/" + coopscript["script"], spath + "/coop--" + coopscript["script"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment