Au, acabat
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
def load_saves(path):
|
||||
files = sorted(os.listdir(path))
|
||||
saves = []
|
||||
size = None
|
||||
|
||||
for f in files:
|
||||
full = os.path.join(path, f)
|
||||
if not os.path.isfile(full):
|
||||
continue
|
||||
with open(full, "rb") as fh:
|
||||
data = fh.read()
|
||||
if size is None:
|
||||
size = len(data)
|
||||
elif len(data) != size:
|
||||
print("Tamaños inconsistentes, abortando.")
|
||||
sys.exit(1)
|
||||
saves.append(data)
|
||||
|
||||
print(f"Cargados {len(saves)} saves de {size} bytes.")
|
||||
return saves, size
|
||||
|
||||
|
||||
def is_one_way_flag(seq):
|
||||
"""Devuelve True si el valor nunca vuelve a 0 después de ser 1."""
|
||||
seen_one = False
|
||||
for v in seq:
|
||||
if v == 1:
|
||||
seen_one = True
|
||||
if seen_one and v == 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Uso: python3 detect_armarios.py <directorio>")
|
||||
sys.exit(1)
|
||||
|
||||
saves, size = load_saves(sys.argv[1])
|
||||
num_saves = len(saves)
|
||||
|
||||
# Transponer: valores por offset
|
||||
flags = [] # lista de (offset, seq)
|
||||
|
||||
for off in range(size):
|
||||
seq = [s[off] for s in saves]
|
||||
values = set(seq)
|
||||
|
||||
# Solo nos interesan offsets con valores 0/1
|
||||
if values.issubset({0, 1}) and len(values) > 1:
|
||||
if is_one_way_flag(seq):
|
||||
flags.append(off)
|
||||
|
||||
print(f"\nEncontrados {len(flags)} offsets que parecen flags de armarios.\n")
|
||||
|
||||
# Agrupar offsets contiguos
|
||||
if not flags:
|
||||
return
|
||||
|
||||
blocks = []
|
||||
start = flags[0]
|
||||
prev = flags[0]
|
||||
|
||||
for off in flags[1:]:
|
||||
if off == prev + 1:
|
||||
prev = off
|
||||
else:
|
||||
blocks.append((start, prev))
|
||||
start = off
|
||||
prev = off
|
||||
blocks.append((start, prev))
|
||||
|
||||
print("Bloques sospechosos:")
|
||||
for a, b in blocks:
|
||||
count = b - a + 1
|
||||
print(f" 0x{a:05X} – 0x{b:05X} ({count} bytes)")
|
||||
|
||||
print("\nSi ves un bloque de ~80 bytes, probablemente son los armarios.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user