Skip to content

Instantly share code, notes, and snippets.

@Shazbot
Last active September 2, 2019 21:44
Show Gist options
  • Save Shazbot/e2af3be146cdf4e2ea8fad86131bc4fa to your computer and use it in GitHub Desktop.
Save Shazbot/e2af3be146cdf4e2ea8fad86131bc4fa to your computer and use it in GitHub Desktop.
Script that compares function signatures inside lua files to those in the Vermintide 2 Source Code
# Pass the mod folder as script argument: python3 sigcheck.py /c/mods/SpawnTweaks
# Put comments inside lua files in the format of
# CHECK followed by the function signature in a new line
# e.g. to check if HordeSpawner.spawn_unit was changed:
# -- CHECK
# -- HordeSpawner.spawn_unit = function (self, hidden_spawn, breed_name, goal_pos, horde)
import os
from os import path
import mmap
import sys
import glob
import re
to_match = list()
p = re.compile(b"--[ ]*CHECK\r\n--[ ]*(.*)\r\n", re.MULTILINE)
dir_to_check = sys.argv[1]
files = glob.glob(dir_to_check + '/**/*.lua', recursive=True)
for file in files:
with open(file) as f:
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
for match in p.findall(s):
to_match.append(match)
print("checking " + str(len(to_match)) + " signatures")
for root, dirs, files in os.walk('/c/Projects/Vermintide-2-Source-Code/scripts'):
for name in files:
fullname = path.join(root, name)
with open(fullname) as f:
s = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ)
for match in list(to_match):
if s.find(match) != -1:
to_match.remove(match)
if not to_match:
print("EVERYTHING IS A-OK")
else:
print("NOT MATCHING:")
for match in to_match:
print(match.decode('utf-8'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment