Created
March 14, 2021 16:59
-
-
Save NodusCursorius/259d46dc0d303d85ccc7c6034fcae14f to your computer and use it in GitHub Desktop.
valheim m_serverPlayerLimit increase
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
#!/bin/python3 | |
import os | |
file_path = "./serverfiles/valheim_server_Data/Managed/assembly_valheim.dll" | |
input_file = open(file_path,"rb") | |
input_data = input_file.read() | |
input_file.close() | |
original_signature_1 = b'\x1F\x0A\x7D\x4C\x0A\x00\x04' | |
patch_signature_1 = b'\x1F\x14\x7D\x4C\x0A\x00\x04' | |
original_signature_2 = b'\x1F\x0A\x7D\x3C\x0C\x00\x04' | |
patch_signature_2 = b'\x1F\x14\x7D\x3C\x0C\x00\x04' | |
signature_count_1 = input_data.count(original_signature_1) | |
signature_count_2 = input_data.count(original_signature_2) | |
if signature_count_1 < 1 or signature_count_2 < 1: | |
print("Aborting, signature not found!") | |
elif signature_count_1 > 1 or signature_count_2 > 1: | |
print("Aborting, signature found more than once") | |
elif signature_count_1 == 1 and signature_count_2 == 1: | |
output_data = input_data.replace(original_signature_1, patch_signature_1) | |
output_data = output_data.replace(original_signature_2, patch_signature_2) | |
backup_file_path = "%s.original" % file_path | |
print("Renaming %s to %s" % (file_path, backup_file_path)) | |
os.rename(file_path, backup_file_path) | |
print("Creating new patched file %s" % file_path) | |
f_new = open(file_path, "wb") | |
f_new.write(output_data) | |
f_new.close() | |
print("Updating permissions on %s" % file_path) | |
os.chmod(file_path, 0o775) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment