wmllint: avoid inserting image=wesnoth-icon.png if there's already an image

(cherry-picked from commit 3b8a684551)
This commit is contained in:
Elvish_Hunter 2018-08-09 20:11:14 +02:00
parent 8fe84b9815
commit ef51a288d8

View file

@ -2272,7 +2272,7 @@ def hack_syntax(filename, lines):
j += 1
# Ensure that every speaker=narrator block without an image uses
# wesnoth-icon.png as an image.
need_image = in_message = False
narrator = has_image = in_message = False
for i in range(len(lines)):
if "no-syntax-rewrite" in lines[i]:
break
@ -2280,16 +2280,16 @@ def hack_syntax(filename, lines):
if '[message]' in precomment:
in_message = True
if "speaker=narrator" in precomment:
need_image = True
narrator = True
elif precomment.strip().startswith("image"):
need_image = False
has_image = True
elif '[/message]' in precomment:
if need_image:
if narrator and not has_image:
# This line presumes the code has been through wmlindent
if verbose:
print('"%s", line %d: inserting "image=wesnoth-icon.png"'%(filename, i+1))
lines.insert(i, leader(precomment) + baseindent + "image=wesnoth-icon.png\n")
need_image = in_message = False
narrator = has_image = in_message = False
# Hack tracking-map macros from 1.4 and earlier. The idea is to lose
# all assumptions about colors in the names
for i in range(len(lines)):