File: check-levels.awk

package info (click to toggle)
neverball 1.5.4-5
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 94,644 kB
  • sloc: ansic: 22,125; makefile: 438; sh: 150; xml: 129; awk: 69
file content (87 lines) | stat: -rw-r--r-- 1,640 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# -----------------------------------------------------------------------------

BEGIN {
    required[1]  = "message"
    required[2]  = "song"
    required[3]  = "back"
    required[4]  = "grad"
    required[5]  = "shot"
    required[6]  = "goal"
    required[7]  = "time"
    required[8]  = "time_hs"
    required[9]  = "goal_hs"
    required[10] = "coin_hs"
    required[11] = "version"
    required[12] = "author"
}

# -----------------------------------------------------------------------------

# Fix up newlines.
/\r$/ {
    sub(/\r$/, "")
}

# -----------------------------------------------------------------------------

# Entity open...
!entity && /^\{/ {
    entity = 1

    for (key in attribs)
        delete attribs[key]

    next
}

entity && !brush && /^[[:space:]]*"[^"]*"[[:space:]]*"[^"]*"/ {
    split($0, fields, "\"")

    if (fields[2] == "classname" && fields[4] == "worldspawn")
        seen_worldspawn = 1
    else
        attribs[fields[2]] = fields[4]
}

# Brush open...
entity && /^\{/ {
    brush = 1
    next
}

# ...brush closed.
brush && /^\}/ {
    brush = 0
    next
}

# ...entity closed.
entity && /^\}/ {
    entity = 0

    # Dump worlspawn attribs.

    if (seen_worldspawn)
    {
        missing = ""

        for (i in required)
        {
            key = required[i]

            if (!key in attribs || attribs[key] !~ /[^[:space:]]/)
                missing = missing " " key
        }

        if (missing)
            print FILENAME ":" missing

        seen_worldspawn = 0

        nextfile
    }

    next
}

# -----------------------------------------------------------------------------