Address bug #18016: Please add next_scenario checks to wmllint.

This commit is contained in:
Eric S. Raymond 2011-05-11 16:16:57 +00:00
parent ea71aa54ba
commit 389de25030
2 changed files with 16 additions and 2 deletions

View file

@ -4,7 +4,7 @@
name= _ "Judgment"
{UNDERGROUND}
turns=-1
next_scenario=10b_New_Life
next_scenario=null # Next was to be called 10b_New_Life
victory_when_enemies_defeated=no
map_data="{campaigns/Northern_Rebirth/maps/09b_Judgment.map}"

View file

@ -529,7 +529,7 @@ def validate_on_pop(tagstack, closer, filename, lineno):
if verbose >= 3:
print '"%s", line %d: closing %s I see %s with %s' % (filename, lineno, closer, tag, attributes)
# Detect a malformation that will cause the game to barf while attempting
# to deserialize an empty unit. The final "and attributes" ias a blatant
# to deserialize an empty unit. The final "and attributes" is a blatant
# hack; some compaigns like to generate entire side declarations with
# macros.
if "scenario" in ancestors and closer == "side" and "type" not in attributes and ("no_leader" not in attributes or attributes["no_leader"] != "yes") and "multiplayer" not in ancestors and attributes:
@ -635,6 +635,8 @@ movetypes = []
unit_movetypes = []
races = []
unit_races = []
nextrefs = []
scenario_to_filename = {}
# Attributes that should have translation marks
translatables = re.compile( \
@ -844,6 +846,12 @@ def local_sanity_check(filename, nav, key, prefix, value, comment):
# Bad [recruit] attribute
if parent in ("[allow_recruit]", "[disallow_recruit]") and key == "recruit":
print errlead + "recruit= should be type="
# Accumulate data to check for missing next scenarios
if parent == '[scenario] or parent == None':
if key == "next_scenario" and value != "null":
nextrefs.append((filename, nav.lineno, value))
if key == 'id':
scenario_to_filename[value] = filename
def global_sanity_check(filename, lines):
"Perform sanity and consistency checks on input files."
@ -1405,6 +1413,12 @@ def consistency_check():
if bad_advancements:
print '"%s", line %d: %s has unknown advancements %s' \
% (filename, lineno, unit_id, bad_advancements)
# Check next-scenario pointers
#print "Scenario ID map", scenario_to_filename
for (filename, lineno, value) in nextrefs:
if value not in scenario_to_filename:
print '"%s", line %d: unresolved scenario reference %s' % \
(filename, lineno, value)
# Syntax transformations