mym2: fixed missing French accents
[neverball] / scripts / check-levels.awk
1 # -----------------------------------------------------------------------------
2
3 BEGIN {
4     required[1]  = "message"
5     required[2]  = "song"
6     required[3]  = "back"
7     required[4]  = "grad"
8     required[5]  = "shot"
9     required[6]  = "goal"
10     required[7]  = "time"
11     required[8]  = "time_hs"
12     required[9]  = "goal_hs"
13     required[10] = "coin_hs"
14     required[11] = "version"
15     required[12] = "author"
16 }
17
18 # -----------------------------------------------------------------------------
19
20 # Fix up newlines.
21 /\r$/ {
22     sub(/\r$/, "")
23 }
24
25 # -----------------------------------------------------------------------------
26
27 # Entity open...
28 !entity && /^\{/ {
29     entity = 1
30
31     for (key in attribs)
32         delete attribs[key]
33
34     next
35 }
36
37 entity && !brush && /^[[:space:]]*"[^"]*"[[:space:]]*"[^"]*"/ {
38     split($0, fields, "\"")
39
40     if (fields[2] == "classname" && fields[4] == "worldspawn")
41         seen_worldspawn = 1
42     else
43         attribs[fields[2]] = fields[4]
44 }
45
46 # Brush open...
47 entity && /^\{/ {
48     brush = 1
49     next
50 }
51
52 # ...brush closed.
53 brush && /^\}/ {
54     brush = 0
55     next
56 }
57
58 # ...entity closed.
59 entity && /^\}/ {
60     entity = 0
61
62     # Dump worlspawn attribs.
63
64     if (seen_worldspawn)
65     {
66         missing = ""
67
68         for (i in required)
69         {
70             key = required[i]
71
72             if (!key in attribs || attribs[key] !~ /[^[:space:]]/)
73                 missing = missing " " key
74         }
75
76         if (missing)
77             print FILENAME ":" missing
78
79         seen_worldspawn = 0
80
81         nextfile
82     }
83
84     next
85 }
86
87 # -----------------------------------------------------------------------------