cepheid

An Aurora 4X clone
Log | Files | Refs | README

commit 7b3409f49121468140e0bd348ccd06912042883f
parent 6746c27699ac81ff9a0355675c4589517d2376f4
Author: hhvn <dev@hhvn.uk>
Date:   Sat,  4 Jun 2022 23:34:47 +0100

Generate more data

Diffstat:
Mdata/Makefile | 5+++--
Adata/worlds-order.awk | 27+++++++++++++++++++++++++++
Mdata/worlds-parse.awk | 10++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/data/Makefile b/data/Makefile @@ -3,7 +3,7 @@ HEADERS = $(FONTS:.ttf=.h) all: $(HEADERS) sol -sol: worlds.tsv +sol: worlds.tsv worlds-parse.awk rm -rf sol ./worlds-parse.awk < $< printf "main\tsol\n" > sol/index @@ -11,7 +11,8 @@ sol: worlds.tsv # Thanks Jonathan worlds.tsv: curl https://planet4589.org/space/gcat/tsv/worlds/worlds.tsv | \ - sed 's/ *\t/\t/g' > $@ + sed 's/ *\t/\t/g' | \ + ./worlds-order.awk > $@ .ttf.h: xxd -i < $< > $@ diff --git a/data/worlds-order.awk b/data/worlds-order.awk @@ -0,0 +1,27 @@ +#!/bin/awk -f + +BEGIN { + FS = "\t" + i = 0 +} + +/^#/ + +!/^#/ { + name = $2 + parent = $20 + + # Parents should appear before children + # Does not work for moonmoons, but there aren't any of those in Sol.. right? + if (parent == "-" || parent == "Sol" || parent == "Sun") { + print + next + } else { + children[i++] = $0 + } +} + +END { + for (c in children) + print children[c] +} diff --git a/data/worlds-parse.awk b/data/worlds-parse.awk @@ -1,4 +1,6 @@ #!/bin/awk -f +# This script attempts to generate usable data +# A lot of assumptions, extrapolations and simplifications are made: chiefly the lack of elliptical orbits. BEGIN { FS = "\t" @@ -103,9 +105,17 @@ BEGIN { orbdays = orbdays * 365.25 # good enough } + if (maxorb ~ /^[-?0]/) + maxorb = minorb + if (name != "Sol" && (radius ~ /^[-?0]$/ || maxorb ~ /^[-?0]$/ || mass ~ /^[-?0]$/ || orbdays ~ /^[-?0]$/)) next + added[name] = 1 + + if (added[parent] != 1) + next + file = sprintf("sol/%s", name) system(sprintf("mkdir -p $(dirname \"%s\")", file))