|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import json |
| 3 | +import os |
| 4 | + |
| 5 | +def fix_timestamps(): |
| 6 | + # Define the packet files and their starting timestamps |
| 7 | + files = [ |
| 8 | + ("godot/assets/packets/stage1_packets.json", 100_000), |
| 9 | + ("godot/assets/packets/stage1_real_packets.json", 100_000), |
| 10 | + ("godot/assets/packets/stage2_packets.json", 100_000), |
| 11 | + ("godot/assets/packets/stage3_packets.json", 100_000), |
| 12 | + ("godot/assets/packets/stage4_packets.json", 100_000), |
| 13 | + ("godot/assets/packets/stage5_packets.json", 100_000), |
| 14 | + ] |
| 15 | + |
| 16 | + for file_path, start_timestamp in files: |
| 17 | + print(f"Processing {file_path}...") |
| 18 | + |
| 19 | + # Read the JSON file |
| 20 | + with open(file_path, 'r', encoding='utf-8') as f: |
| 21 | + data = json.load(f) |
| 22 | + |
| 23 | + # Update timestamps incrementally |
| 24 | + current_timestamp = start_timestamp |
| 25 | + for packet in data['packets']: |
| 26 | + packet['timestamp'] = current_timestamp |
| 27 | + current_timestamp += 150_000 # Increment by 150 microseconds |
| 28 | + |
| 29 | + # Write back to file |
| 30 | + with open(file_path, 'w', encoding='utf-8') as f: |
| 31 | + json.dump(data, f, indent=2, ensure_ascii=False) |
| 32 | + |
| 33 | + print(f" Updated {len(data['packets'])} packets, timestamps from {start_timestamp} to {current_timestamp - 150}") |
| 34 | + |
| 35 | +if __name__ == "__main__": |
| 36 | + fix_timestamps() |
| 37 | + print("All timestamps fixed!") |
0 commit comments