Address bug #10521.
get_hit_sound conversion is now in wmllint, and all instances in mainline are converted.
This commit is contained in:
parent
cf54dc7006
commit
127e5eb3d3
6 changed files with 66 additions and 17 deletions
|
@ -15,7 +15,7 @@
|
|||
cost=40
|
||||
usage=scout
|
||||
unit_description= _ "Shhhh! The Gryphon is sleeping! You'd better not wake it up!"
|
||||
get_hit_sound=groan.wav
|
||||
{DEFENSE_ANIM "gryphon-sleeping.png" "gryphon-sleeping.png" groan.wav}
|
||||
#
|
||||
# Note: do not set this unit's movement to zero (causes weird infinite movement behavior)
|
||||
# Also, do not remove this unit's attack (causes game to crash)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
cost=20
|
||||
usage=fighter
|
||||
unit_description= _ "This thing is impossible to describe, no one has seen anything like it before."+{SPECIAL_NOTES}+{SPECIAL_NOTES_MAGICAL}
|
||||
get_hit_sound=wail.wav
|
||||
{DEFENSE_ANIM blank.png blank.png wail.wav}
|
||||
[attack]
|
||||
name=energy ray
|
||||
description= _"energy ray"
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
usage=fighter
|
||||
unit_description= _ "This thing is impossible to describe, no one has seen anything like it before."+{SPECIAL_NOTES}+{SPECIAL_NOTES_MAGICAL}
|
||||
die_sound=wail-long.wav
|
||||
get_hit_sound=wail.wav
|
||||
{DEFENSE_ANIM blank.png blank.png wail.wav}
|
||||
[attack]
|
||||
name=energy ray
|
||||
description= _"energy ray"
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
usage=fighter
|
||||
unit_description= _ "This thing is impossible to describe, no one has seen anything like it before."+{SPECIAL_NOTES}+{SPECIAL_NOTES_MAGICAL}
|
||||
die_sound=wail-long.wav
|
||||
get_hit_sound=wail.wav
|
||||
{DEFENSE_ANIM blank.png blank.png wail.wav}
|
||||
[attack]
|
||||
name=energy ray
|
||||
description= _"energy ray"
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
blade=100
|
||||
pierce=100
|
||||
[/resistance]
|
||||
get_hit_sound=staff.wav
|
||||
{DEFENSE_ANIM "units/quintain.png" "units/quintain.png" staff.wav}
|
||||
[attack]
|
||||
name=flail
|
||||
description= _"flail"
|
||||
|
|
|
@ -530,6 +530,17 @@ notepairs = (
|
|||
trait_note = dict(notepairs)
|
||||
note_trait = dict(map(lambda p: (p[1], p[0]), notepairs))
|
||||
|
||||
def parse_attribute(str):
|
||||
"Parse a WML key-value pair from a line."
|
||||
if '=' not in str:
|
||||
return None
|
||||
m = re.match(r"(^\s*[a-z0-9_]+\s*=\s*)(.+)((?<=\S)\s*#?.*\s*)", str)
|
||||
if not m:
|
||||
return None
|
||||
# Four fields: stripped key, part of line before value,
|
||||
# value, trailing whitespace and comments
|
||||
return (m.group(1).replace("=", "").strip(),) + m.groups()
|
||||
|
||||
def sanity_check(filename, lines):
|
||||
"Perform sanity and considtency checks on input lines"
|
||||
in_unit = False
|
||||
|
@ -580,7 +591,7 @@ def sanity_check(filename, lines):
|
|||
has_special_notes = False
|
||||
if in_unit and not in_attack_filter:
|
||||
if "id=" in lines[i] and not unit_id:
|
||||
(dummy, unit_id) = lines[i].strip().split("=")
|
||||
(key, prefix, unit_id, comment) = parse_attribute(lines[i])
|
||||
if unit_id[0] == "_":
|
||||
unit_id = unit_id[1:].strip()
|
||||
unit_id = " " + unit_id
|
||||
|
@ -668,6 +679,55 @@ def hack_syntax(filename, lines):
|
|||
lines.insert(i, leader(precomment) + baseindent + "image=wesnoth-icon.png\n")
|
||||
modcount += 1
|
||||
need_image = False
|
||||
# Remove get_hit_sound fields
|
||||
in_unit = False
|
||||
unit_id = ""
|
||||
unit_image = None
|
||||
unit_sound = None
|
||||
get_hit_sound = None
|
||||
has_defense_anim = False
|
||||
has_special_notes = False
|
||||
for i in range(len(lines)):
|
||||
if "[unit]" in lines[i]:
|
||||
in_unit = i+1
|
||||
continue
|
||||
elif "[/unit]" in lines[i]:
|
||||
if unit_id and get_hit_sound:
|
||||
if has_defense_anim:
|
||||
print 'wmllint: "%s", line %d: unit%s has both deprecated get_hit_sound tag and a DEFENSE_ANIM"'%(filename, i+1, unit_id)
|
||||
else:
|
||||
new_anim = "{DEFENSE_ANIM %s %s %s}" % \
|
||||
(unit_image, unit_image, unit_sound)
|
||||
(key, prefix, val, comment) = parse_attribute(lines[get_hit_sound])
|
||||
print 'wmllint: "%s", line %d: unit%s gets %s'%(filename, get_hit_sound, unit_id, new_anim)
|
||||
lines[get_hit_sound] = leader(lines[get_hit_sound]) \
|
||||
+ new_anim + comment
|
||||
modcount += 1
|
||||
in_unit = None
|
||||
unit_id = ""
|
||||
unit_image = None
|
||||
unit_sound = None
|
||||
get_hit_sound = None
|
||||
has_defense_anim = False
|
||||
has_special_notes = False
|
||||
if in_unit:
|
||||
if "{DEFENSE_ANIM" in lines[i]:
|
||||
has_defense_anim = True
|
||||
else:
|
||||
fields = parse_attribute(lines[i])
|
||||
if fields is None:
|
||||
continue
|
||||
(key, prefix, value, comment) = fields
|
||||
if key == "id" and not unit_id:
|
||||
unit_id = value
|
||||
if unit_id[0] == "_":
|
||||
unit_id = unit_id[1:].strip()
|
||||
unit_id = " " + unit_id
|
||||
elif key == "get_hit_sound":
|
||||
get_hit_sound = i
|
||||
unit_sound = value
|
||||
elif key == "image" and not unit_image:
|
||||
unit_image = value
|
||||
# Boucman's transformation of animation syntax
|
||||
class anim_frame:
|
||||
def __init__(self, attackline, attackname, lineno, female, variation):
|
||||
|
@ -1545,17 +1605,6 @@ if __name__ == '__main__':
|
|||
return True
|
||||
return False
|
||||
|
||||
def parse_attribute(str):
|
||||
"Parse a WML key-value pair from a line."
|
||||
if '=' not in str:
|
||||
return None
|
||||
m = re.match(r"(^\s*[a-z0-9_]+\s*=\s*)(\S+)(\s*#?.*\s*)", str)
|
||||
if not m:
|
||||
return None
|
||||
# Four fields: stripped key, part of line before value,
|
||||
# value, trailing whitespace and comments
|
||||
return (m.group(1).replace("=", "").strip(),) + m.groups()
|
||||
|
||||
def texttransform(filename, lineno, line):
|
||||
"Resource-name transformation on text lines."
|
||||
transformed = line
|
||||
|
|
Loading…
Add table
Reference in a new issue