Playtest fixes: smoke by engine, searchlights, far launch sites that load their chunks, air defence balance, last chance and radar-cued shots, radars in smart raids, echo, Windows release build from a tag
build / mod (push) Successful in 4m4s
release / windows (push) Successful in 23m13s

Smoke: one rule by engine, no heat on trails, no trail on P1-SUN. Searchlights: two lamps a target, off with an empty sky. Halos fade before their reach and their sum is limited. Launch sites load chunks through the server thread, go off-map as a last resort, and reach 4000 blocks. Air defence: ranges x1.5, shots grow with urgency, claims released, /airdef lastchance, long shots on a big radar's tracks. Build: rust-toolchain.toml, airdef.py check, generator manifest and --check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 23:44:14 +03:00
parent 5003376e70
commit ccc3e20902
67 changed files with 4573 additions and 328 deletions
+117 -9
View File
@@ -5,14 +5,21 @@
Поворачивает и масштабирует их движок форка (render.set-models), так что ракурсы больше не нужны.
Координаты элементов — в пределах -16..32 (иначе Horizon отбрасывает модель).
Запуск: python3 tools/gen_models.py
Запуск: python3 tools/gen_models.py [--check]
Скрипт пишет во временный каталог и только потом переносит результат в airdef-mod/. Список созданных им файлов
с sha256 лежит в airdef-mod/generated-manifest.txt (формат sha256sum). Удаляются и перезаписываются только файлы
из этого списка и только если их не правили вручную; чужой файл на пути генерируемого останавливает запуск.
--check ничего не пишет и выходит с кодом 1, если airdef-mod/ отличается от того, что дал бы запуск.
"""
import hashlib
import json
import math
import os
import sys
import random
import shutil
import tempfile
import zlib
from PIL import Image
@@ -1692,13 +1699,10 @@ def write_json(path, obj):
json.dump(obj, f, ensure_ascii=False, indent=1)
def main():
# Только своё: звуки (tools/gen_sounds.py) и sounds.json не трогаем.
for sub in ("blockstates", "items", "lang", "models", "textures"):
shutil.rmtree(os.path.join(ROOT, "assets", NS, sub), ignore_errors=True)
shutil.rmtree(os.path.join(ROOT, "data"), ignore_errors=True)
a = os.path.join(ROOT, "assets", NS)
d = os.path.join(ROOT, "data", NS, "horizon")
def generate(out):
# Пишет весь набор в каталог out (зеркало airdef-mod/). Звуки (tools/gen_sounds.py) и sounds.json не трогаем.
a = os.path.join(out, "assets", NS)
d = os.path.join(out, "data", NS, "horizon")
os.makedirs(os.path.join(a, "textures", "block"))
os.makedirs(os.path.join(a, "textures", "item"))
lang = {}
@@ -1738,7 +1742,111 @@ def main():
lang[f"item.{NS}.cam_{name}"] = title
write_json(os.path.join(a, "lang", "en_us.json"), lang)
write_json(os.path.join(a, "lang", "ru_ru.json"), lang)
print(f"{len(MODELS)} моделей, {len(ITEMS)} предметов, {len(TEXTURES)} текстур -> {ROOT}")
return len(MODELS), len(ITEMS), len(TEXTURES)
MANIFEST = os.path.join(ROOT, "generated-manifest.txt")
def file_sha(path):
with open(path, "rb") as f:
return hashlib.sha256(f.read()).hexdigest()
def read_manifest():
# Строки "<sha256> <путь от airdef-mod>", как у sha256sum. Только файлы, которые записал этот скрипт.
if not os.path.exists(MANIFEST):
return {}
entries = {}
with open(MANIFEST, encoding="utf-8") as f:
for line in f:
digest, rel = line.rstrip("\n").split(" ", 1)
if rel.startswith("/") or ".." in rel.split("/"):
sys.exit(f"{MANIFEST}: недопустимый путь {rel}")
entries[rel] = digest
return entries
def prune_empty(path):
d = os.path.dirname(path)
while d != ROOT and os.path.isdir(d) and not os.listdir(d):
os.rmdir(d)
d = os.path.dirname(d)
def main():
args = sys.argv[1:]
if any(arg != "--check" for arg in args):
sys.exit("Использование: python3 tools/gen_models.py [--check]")
check = "--check" in args
old = read_manifest()
with tempfile.TemporaryDirectory() as stage:
counts = generate(stage)
new = {}
for dirpath, dirs, names in os.walk(stage):
dirs.sort()
for name in sorted(names):
path = os.path.join(dirpath, name)
new[os.path.relpath(path, stage).replace(os.sep, "/")] = file_sha(path)
# create: файла нет; update: файл записан генератором и с тех пор не менялся; same: уже совпадает;
# conflict: на пути лежит чужой или вручную правленный файл, поэтому ничего не пишем.
create, update, same, conflict = [], [], [], []
for rel in sorted(new):
target = os.path.join(ROOT, rel)
if not os.path.exists(target):
create.append(rel)
elif not os.path.isfile(target):
conflict.append(rel)
else:
cur = file_sha(target)
if cur == new[rel]:
same.append(rel)
elif rel in old and old[rel] == cur:
update.append(rel)
else:
conflict.append(rel)
# remove: генератор больше не создаёт файл и он не менялся; keep: не создаёт, но правлен вручную, оставляем.
remove, keep = [], []
for rel in sorted(old):
target = os.path.join(ROOT, rel)
if rel in new or not os.path.isfile(target):
continue
(remove if file_sha(target) == old[rel] else keep).append(rel)
if conflict:
for rel in conflict:
print(f"КОНФЛИКТ: {rel} занят файлом, которого нет в manifest (или он правлен вручную)")
sys.exit("Ничего не записано. Уберите или переименуйте эти файлы и запустите снова.")
manifest_text = "".join(f"{new[rel]} {rel}\n" for rel in sorted(new))
manifest_old = None
if os.path.exists(MANIFEST):
with open(MANIFEST, encoding="utf-8") as f:
manifest_old = f.read()
manifest_changed = manifest_text != manifest_old
for rel in keep:
print(f"ВНИМАНИЕ: {rel} больше не генерируется, но правлен вручную: оставлен, из manifest убран")
for label, rels in (("новый", create), ("обновить", update), ("удалить", remove)):
for rel in rels:
print(f"{label}: {rel}")
if manifest_changed:
print("manifest: обновить")
if check:
differs = create or update or remove or manifest_changed
print("различий нет" if not differs else "различия с генератором: см. выше")
sys.exit(1 if differs else 0)
for rel in create + update:
dst = os.path.join(ROOT, rel)
os.makedirs(os.path.dirname(dst), exist_ok=True)
shutil.copyfile(os.path.join(stage, rel), dst)
for rel in remove:
path = os.path.join(ROOT, rel)
os.remove(path)
prune_empty(path)
if manifest_changed:
with open(MANIFEST, "w", encoding="utf-8", newline="\n") as f:
f.write(manifest_text)
models, items, textures = counts
print(f"{models} моделей, {items} предметов, {textures} текстур -> {ROOT}: "
f"создано {len(create)}, обновлено {len(update)}, удалено {len(remove)}, без изменений {len(same)}")
if __name__ == "__main__":