Cnass commited on
Commit
d09dd56
·
verified ·
1 Parent(s): dfb6aa6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -9
app.py CHANGED
@@ -69,15 +69,26 @@ def process_repack(job_id: str, asset_path: str, zip_path: str, original_filenam
69
  if obj.type.name == "MonoBehaviour":
70
  raw_data = obj.get_raw_data()
71
  patched_data = bytearray(raw_data)
72
- for orig_str, trans_str in translations.items():
73
- if orig_str == trans_str: continue
74
- orig_bytes = orig_str.encode('utf-8')
75
- orig_pad = (4 - (len(orig_bytes) % 4)) % 4
76
- orig_block = len(orig_bytes).to_bytes(4, 'little') + orig_bytes + (b'\x00' * orig_pad)
77
- trans_bytes = trans_str.encode('utf-8')
78
- trans_pad = (4 - (len(trans_bytes) % 4)) % 4
79
- trans_block = len(trans_bytes).to_bytes(4, 'little') + trans_bytes + (b'\x00' * trans_pad)
80
- patched_data = patched_data.replace(orig_block, trans_block)
 
 
 
 
 
 
 
 
 
 
 
81
  obj.set_raw_data(bytes(patched_data))
82
 
83
  jobs[job_id].update({
 
69
  if obj.type.name == "MonoBehaviour":
70
  raw_data = obj.get_raw_data()
71
  patched_data = bytearray(raw_data)
72
+ # ... (process_repack içindeki for döngüsünde) ...
73
+ for orig_str, trans_str in translations.items():
74
+ if orig_str == trans_str: continue
75
+
76
+ orig_bytes = orig_str.encode('utf-8')
77
+ trans_bytes = trans_str.encode('utf-8')
78
+
79
+ # KRİTİK DEĞİŞİKLİK: 4 baytlık hizalamayı (alignment) zorla yapıyoruz
80
+ # Unity, dosyaları 4'ün katı olan bloklarda okur.
81
+ # Metni değiştirdiğimizde bu bloğu bozarız.
82
+ # Aşağıdaki kod, metni 4 bayta tamamlaya(padding) zorlar.
83
+
84
+ orig_pad = (4 - (len(orig_bytes) % 4)) % 4
85
+ orig_block = len(orig_bytes).to_bytes(4, 'little') + orig_bytes + (b'\x00' * orig_pad)
86
+
87
+ trans_pad = (4 - (len(trans_bytes) % 4)) % 4
88
+ trans_block = len(trans_bytes).to_bytes(4, 'little') + trans_bytes + (b'\x00' * trans_pad)
89
+
90
+ # Bloğu sadece ve sadece %100 eşleşen bayt dizisinde değiştir
91
+ patched_data = patched_data.replace(orig_block, trans_block)
92
  obj.set_raw_data(bytes(patched_data))
93
 
94
  jobs[job_id].update({