20 lines
959 B
Python
20 lines
959 B
Python
"""Prepare the isolated graphical test world. Run GameTests first."""
|
|
from pathlib import Path
|
|
import gzip
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
source = root / "run/gameTestServer/world/level.dat"
|
|
destination = root / "run/clientSmoke/saves/smoke"
|
|
destination.mkdir(parents=True, exist_ok=True)
|
|
data = gzip.decompress(source.read_bytes())
|
|
for key, value in [("SpawnX", 0), ("SpawnY", -59), ("SpawnZ", 0)]:
|
|
needle = b"\x03" + len(key).to_bytes(2, "big") + key.encode()
|
|
position = data.find(needle)
|
|
if position < 0:
|
|
raise ValueError(f"Missing spawn tag: {key}")
|
|
position += len(needle)
|
|
data = data[:position] + value.to_bytes(4, "big", signed=True) + data[position + 4:]
|
|
(destination / "level.dat").write_bytes(gzip.compress(data))
|
|
run = root / "run/clientSmoke"
|
|
(run / "options.txt").write_text("guiScale:2\nlang:fr_fr\nrenderDistance:5\nsimulationDistance:5\nmaxFps:30\n")
|
|
(run / "counter-smoke.ok").unlink(missing_ok=True)
|