Skip to content

Commit

Permalink
debug: action
Browse files Browse the repository at this point in the history
  • Loading branch information
szsdk committed Aug 4, 2024
1 parent d4ae6b8 commit 72ae5cb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions emcfile/_pattern_sone_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def read_indexed_array(
s, e = idx_con[0]
e = arr_idx[e]
s = arr_idx[s]
fin.seek(I4 * int(s - e0), os.SEEK_CUR)
_log.warning(f"{arr_idx.dtype} s={s}, e={e}, e0={e0},")
fin.seek(I4 * (int(s) - e0), os.SEEK_CUR)
return np.fromfile(fin, count=int(e - s), dtype=np.int32), int(e) - int(
arr_idx[-1]
)
Expand All @@ -59,9 +60,9 @@ def read_indexed_array(
for s, e in idx_con:
e = arr_idx[e]
s = arr_idx[s]
fin.seek(I4 * int(s - e0), os.SEEK_CUR)
fin.seek(I4 * (int(s) - e0), os.SEEK_CUR)
ans.append(np.frombuffer(fin.read(int(e - s) * I4), dtype=np.int32))
e0 = e
e0 = int(e)
return (
np.concatenate(ans) if len(ans) > 0 else np.array([], np.int32),
int(e0) - int(arr_idx[-1]),
Expand All @@ -77,8 +78,11 @@ def read_patterns(
) -> tuple[npt.NDArray[np.uint32], npt.NDArray[np.uint32], npt.NDArray[np.int32]]:
seek_start = PatternsSOneEMC.HEADER_BYTES + I4 * (len(ones_idx) - 1) * 2
fin.seek(seek_start)
_log.warning("CP0 ones")
place_ones, e0 = read_indexed_array(fin, idx_con, ones_idx, 0)
_log.warning(f"CP0 place_multi e0 {e0}")
place_multi, e0 = read_indexed_array(fin, idx_con, multi_idx, e0)
_log.warning(f"CP0 count_multi e0 {e0}")
count_multi, e0 = read_indexed_array(fin, idx_con, multi_idx, e0)
fin.seek(I4 * (-e0), os.SEEK_CUR)
if fin.read(1):
Expand Down

0 comments on commit 72ae5cb

Please sign in to comment.