More impprovements in macro type checking. No conflicts in mainline.

This commit is contained in:
Eric S. Raymond 2010-02-11 20:26:35 +00:00
parent c2cb87f20d
commit d72fb9cca7
5 changed files with 32 additions and 28 deletions

View file

@ -1,6 +1,6 @@
#textdomain wesnoth
#define AI_CONTROLLER AFFIX PLAYER_SIDE ALLY_SIDES VARIABLES
#define AI_CONTROLLER AFFIX PLAYER_SIDES ALLY_SIDES VARIABLES
# expects $order_type to be set
[event]
name=apply_ai_params
@ -126,7 +126,7 @@
# This block contains all the default settings and options.
[literal]
enabled=yes
player_side={PLAYER_SIDE}
player_side={PLAYER_SIDES}
ally_sides={ALLY_SIDES}
disabled_for_sides=0

View file

@ -1345,42 +1345,42 @@
[/magic_missile_flare_frame]
#enddef
#define MERMAID_STAFF_FLARE X_POSITION Y_POSITION
#define MERMAID_STAFF_FLARE X_OFFSET Y_OFFSET
flare_start_time=-420
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-1.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-2.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-3.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-4.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-5.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-6.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=60
halo=halo/merfolk/staff-flare-7.png
halo_x,halo_y={X_POSITION},{Y_POSITION}
halo_x,halo_y={X_OFFSET},{Y_OFFSET}
[/flare_frame]
[flare_frame]
duration=10
@ -1934,7 +1934,7 @@ Wo,Ww,Ww^Vm,Chs,Chw,Ss,Qxu,Ql,Qlf#enddef
[/attack_anim]
#enddef
#define DRAKE_FIRE_ANIM_N_DIAGONAL_CURRENT DRAKE_NAME OFFSET
#define DRAKE_FIRE_ANIM_N_DIAGONAL_CURRENT DRAKE_NAME OFFSET_POSITION
[attack_anim]
[filter_attack]
name=fire breath
@ -1944,7 +1944,7 @@ Wo,Ww,Ww^Vm,Chs,Chw,Ss,Qxu,Ql,Qlf#enddef
begin=-400
end=100
halo=projectiles/fire-breath-ne-1.png:80,projectiles/fire-breath-ne-2.png:80,projectiles/fire-breath-ne-3.png:80,projectiles/fire-breath-ne-4.png:80,projectiles/fire-breath-ne-5.png:80
halo_x,halo_y={OFFSET}
halo_x,halo_y={OFFSET_POSITION}
[/missile_frame]
start_time=-900
[if]
@ -2008,7 +2008,7 @@ Wo,Ww,Ww^Vm,Chs,Chw,Ss,Qxu,Ql,Qlf#enddef
[/attack_anim]
#enddef
#define DRAKE_FIRE_ANIM_S DRAKE_NAME OFFSET
#define DRAKE_FIRE_ANIM_S DRAKE_NAME OFFSET_POSITION
[attack_anim]
[filter_attack]
name=fire breath
@ -2018,7 +2018,7 @@ Wo,Ww,Ww^Vm,Chs,Chw,Ss,Qxu,Ql,Qlf#enddef
begin=-400
end=100
halo=projectiles/fire-breath-s-1.png:80,projectiles/fire-breath-s-2.png:80,projectiles/fire-breath-s-3.png:80,projectiles/fire-breath-s-4.png:80,projectiles/fire-breath-s-5.png:80
halo_x,halo_y={OFFSET}
halo_x,halo_y={OFFSET_POSITION}
[/missile_frame]
start_time=-900
[if]
@ -2082,7 +2082,7 @@ Wo,Ww,Ww^Vm,Chs,Chw,Ss,Qxu,Ql,Qlf#enddef
[/attack_anim]
#enddef
#define DRAKE_FIRE_ANIM_N_CURRENT DRAKE_NAME OFFSET
#define DRAKE_FIRE_ANIM_N_CURRENT DRAKE_NAME OFFSET_POSITION
[attack_anim]
[filter_attack]
name=fire breath
@ -2092,7 +2092,7 @@ Wo,Ww,Ww^Vm,Chs,Chw,Ss,Qxu,Ql,Qlf#enddef
begin=-400
end=100
halo=projectiles/fire-breath-n-1.png:80,projectiles/fire-breath-n-2.png:80,projectiles/fire-breath-n-3.png:80,projectiles/fire-breath-n-4.png:80,projectiles/fire-breath-n-5.png:80
halo_x,halo_y={OFFSET}
halo_x,halo_y={OFFSET_POSITION}
[/missile_frame]
start_time=-900
[if]

View file

@ -93,7 +93,7 @@
[/item]
#enddef
#define PICKUPPABLE_ITEM ID X Y CAN_TAKE_FILTER IMAGE MESSAGE CANNOT_TAKE_MESSAGE OBJECT
#define PICKUPPABLE_ITEM ID X Y CAN_TAKE_FILTER IMAGE TEXT CANNOT_TAKE_TEXT OBJECT
# This places an item on the map which can be picked up once, but allows the
# player to choose whether the unit stepping on it should take it or not.
# The "object" doesn't necessarily need to be an [object], any action works.
@ -141,7 +141,7 @@
[then]
[message]
speaker=narrator
message={MESSAGE}
message={TEXT}
image={IMAGE}
[option]
@ -183,7 +183,7 @@
[then]
[message]
speaker=narrator
message={CANNOT_TAKE_MESSAGE}
message={CANNOT_TAKE_TEXT}
image={IMAGE}
for_side=$side_number
# the above is used to prevent an AI side from

View file

@ -214,7 +214,7 @@
{CLEAR_VARIABLE MODIFY_UNIT_store}
#enddef
#define MOVE_UNIT_BY FILTER X_OFFSET Y_OFFSET
#define MOVE_UNIT_BY FILTER OFFSET_X OFFSET_Y
#TODO COMMENT
[store_unit]
[filter]
@ -226,8 +226,8 @@
[/store_unit]
{FOREACH MOVE_UNIT_store unit}
{VARIABLE_OP MOVE_UNIT_store[$unit].x add {X_OFFSET}}
{VARIABLE_OP MOVE_UNIT_store[$unit].y add {Y_OFFSET}}
{VARIABLE_OP MOVE_UNIT_store[$unit].x add {OFFSET_X}}
{VARIABLE_OP MOVE_UNIT_store[$unit].y add {OFFSET_Y}}
[unstore_unit]
variable=MOVE_UNIT_store[$unit]
find_vacant=no
@ -379,8 +379,8 @@
# FIXME: Documentation for these is needed.
#define MENU_IMG_TXT IMG TXT
"&"+{IMG}+"="+{TXT}#enddef
#define MENU_IMG_TXT IMAGE TEXT
"&"+{IMAGE}+"="+{TEXT}#enddef
#define MENU_IMG_TXT2 IMG TXT1 TXT2
"&"+{IMG}+"="+{TXT1}+"="+{TXT2}#enddef

View file

@ -145,12 +145,14 @@ def formaltype(f):
# Deduce the expected type of the formal
if f.startswith("_"):
f = f[1:]
if f in ("SIDE", "X", "Y", "RED", "GREEN", "BLUE", "TURN", "RADIUS", "PROB", "LAYER") or f.endswith("NUMBER") or f.endswith("AMOUNT") or f.endswith("COST") or f.endswith("_X") or f.endswith("_Y") or f.endswith("_INCREMENT") or f.endswith("_FACTOR"):
if f in ("SIDE", "X", "Y", "RED", "GREEN", "BLUE", "TURN", "RADIUS", "PROB", "LAYER") or f.endswith("_SIDE") or f.endswith("NUMBER") or f.endswith("AMOUNT") or f.endswith("COST") or f.endswith("_X") or f.endswith("_Y") or f.endswith("_INCREMENT") or f.endswith("_FACTOR"):
ftype = "numeric"
elif f in ("POSITION",):
elif f in ("POSITION",) or f.endswith("_POSITION"):
ftype = "position"
elif f.endswith("_SPAN") or f == "SIDES":
elif f.endswith("_SPAN"):
ftype = "span"
elif f == "SIDES" or f.endswith("_SIDES"):
ftype = "alliance"
elif f in ("RANGE",):
ftype = "range"
elif f in ("ALIGN",):
@ -185,7 +187,7 @@ def actualtype(a):
# Deduce the type of the actual
if a.isdigit() or a.startswith("-") and a[1:].isdigit():
atype = "numeric"
elif re.match(r"[0-9]+,[0-9]+\Z", a):
elif re.match(r"-?[0-9]+,-?[0-9]+\Z", a):
atype = "position"
elif re.match(r"([0-9]+\-[0-9]+,?|[0-9]+,?)+\Z", a):
atype = "span"
@ -239,6 +241,8 @@ def argmatch(formals, actuals):
pass
elif atype in ("shortname",) and ftype == "terrain_code":
pass
elif atype in ("numeric", "position", "span", "empty") and ftype == "alliance":
pass
elif atype != ftype and ftype is not None and atype is not None:
return False
return True