Fix archaic use of id= in [unit].

This commit is contained in:
Eric S. Raymond 2008-03-12 11:06:33 +00:00
parent 21f53e3349
commit 99e5675ce7
2 changed files with 28 additions and 2 deletions

View file

@ -209,7 +209,7 @@
{PIRATE_GALLEON 6 25}
[unit]
side=3
id=Transport
type=Transport
description="Transport Galleon"
user_description= _ "Transport Galleon"
type=Transport Galleon

View file

@ -1510,7 +1510,33 @@ start_time=-150
if "[/terrain]" in lines[i]:
in_terrain = False
if in_terrain:
lines[i] = lines[i].replace("letter", "terrain")
nl = lines[i].replace("letter", "terrain")
if nl != lines[i]:
modcount += 1
lines[i] = nl
# id= -> type= in [unit]
if upconvert and "1.3.14" in versions:
in_unit = False
id_seen = False
in_modifications = False
for i in range(len(lines)):
if "no-syntax-rewrite" in lines[i]:
break
if "[unit]" in lines[i]:
in_unit = True
if "[/unit]" in lines[i]:
in_unit = False
if "[modifications]" in lines[i]:
in_modifications = True
if "[/modifications]" in lines[i]:
in_modifications = False
if in_unit and not in_modifications and not id_seen and re.search("id *=", lines[i]):
nl = re.sub("id *=", "type=", lines[i])
if nl != lines[i]:
modcount += 1
lines[i] = nl
print '"%s", line %d: [unit] id= -> type=' % (filename, i+1)
id_seen = True
# More syntax transformations would go here.
return (lines, modcount)