Enrich macro type checking some more and simplify the type inference rules.
Also head off a potential bug noted by Mordante with WML that looks like {X_SPAN},{Y_SPAN}.
This commit is contained in:
parent
2cd537a2b1
commit
0ee463c8cf
14 changed files with 48 additions and 47 deletions
|
@ -171,9 +171,10 @@
|
|||
# locations across all possible locations at once, the RNG could theoretically
|
||||
# clump all the ambushers into a single corner of the map.
|
||||
|
||||
#define UNDEAD_AMBUSH_AREA SIDE XSPAN YSPAN NUMBER
|
||||
#define UNDEAD_AMBUSH_AREA SIDE X_SPAN Y_SPAN NUMBER
|
||||
[store_locations]
|
||||
x,y={XSPAN},{YSPAN}
|
||||
x={X_SPAN}
|
||||
y={Y_SPAN}
|
||||
terrain=Ss
|
||||
|
||||
[filter_adjacent_location]
|
||||
|
|
|
@ -237,12 +237,13 @@
|
|||
# locations across all possible locations at once, the RNG could theoretically
|
||||
# clump all the ambushers into a single corner of the map.
|
||||
|
||||
#define ORC_AMBUSH_AREA SIDE XSPAN YSPAN NUMBER
|
||||
#define ORC_AMBUSH_AREA SIDE X_SPAN Y_SPAN NUMBER
|
||||
# Any hill that's completely surrounded by other hills, mountains or
|
||||
# forest is eligible as an ambush location.
|
||||
|
||||
[store_locations]
|
||||
x,y={XSPAN},{YSPAN}
|
||||
x={XSPAN}
|
||||
y={YSPAN}
|
||||
terrain=Hh
|
||||
|
||||
[not]
|
||||
|
|
|
@ -36,11 +36,11 @@
|
|||
{CLEAR_VARIABLE chgtype_store}
|
||||
#enddef
|
||||
|
||||
#define CHG_TERRAIN LETTER XSPAN YSPAN
|
||||
#define CHG_TERRAIN LETTER X_SPAN Y_SPAN
|
||||
[terrain]
|
||||
letter={LETTER}
|
||||
x={XSPAN}
|
||||
y={YSPAN}
|
||||
x={X_SPAN}
|
||||
y={Y_SPAN}
|
||||
[/terrain]
|
||||
#enddef
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@
|
|||
[/ai]
|
||||
[/side]
|
||||
|
||||
#define NORTH_GUARD X Y DESCRIPTION USER_DESCRIPTION SECOND_TRAIT
|
||||
#define NORTH_GUARD X Y DESCRIPTION USER_DESCRIPTION SECOND_TRAIT_WML
|
||||
[unit]
|
||||
#ifdef EASY
|
||||
type=Shock Trooper
|
||||
|
@ -112,7 +112,7 @@
|
|||
y={Y}
|
||||
[modifications]
|
||||
{TRAIT_LOYAL}
|
||||
{SECOND_TRAIT}
|
||||
{SECOND_TRAIT_WML}
|
||||
[/modifications]
|
||||
[/unit]
|
||||
#enddef
|
||||
|
|
|
@ -348,7 +348,7 @@
|
|||
|
||||
# This sets up some unit variables for sides that
|
||||
# will suffer thirst
|
||||
#define SETUP_ENEMY_THIRST SIDE THIRST
|
||||
#define SETUP_ENEMY_THIRST SIDE THIRST_NUMBER
|
||||
[store_unit]
|
||||
variable=enemy
|
||||
kill=yes
|
||||
|
@ -357,7 +357,7 @@
|
|||
[/filter]
|
||||
[/store_unit]
|
||||
{FOREACH enemy i}
|
||||
{VARIABLE enemy[$i].variables.dehydration {THIRST}}
|
||||
{VARIABLE enemy[$i].variables.dehydration {THIRST_NUMBER}}
|
||||
{VARIABLE enemy[$i].variables.full_hitpoints $enemy[$i].hitpoints}
|
||||
{VARIABLE enemy[$i].variables.max_hitpoints $enemy[$i].max_hitpoints}
|
||||
[unstore_unit]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#textdomain wesnoth-utbs
|
||||
# The file contains useful macros I use within the campaign
|
||||
|
||||
#define RANDOM_TRAIT_UNIT SIDE TYPE X Y DESCRIPTION USER_DESCRIPTION WML_FRAGMENT
|
||||
#define RANDOM_TRAIT_UNIT SIDE TYPE X Y DESCRIPTION USER_DESCRIPTION TRAIT_WML
|
||||
[unit]
|
||||
side={SIDE}
|
||||
type={TYPE}
|
||||
|
@ -11,7 +11,7 @@
|
|||
user_description={USER_DESCRIPTION}
|
||||
upkeep=full
|
||||
animate=yes
|
||||
{WML_FRAGMENT}
|
||||
{TRAIT_WML}
|
||||
[/unit]
|
||||
#enddef
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
|||
{VARIABLE_OP random_string format "0..$random_placement_locations.length"}
|
||||
#enddef
|
||||
|
||||
#define PLACE_UNITS_RANDOMLY NUMBER SIDE TYPE DESCRIPTION USER_DESCRIPTION WML_FRAGMENT
|
||||
#define PLACE_UNITS_RANDOMLY NUMBER SIDE TYPE DESCRIPTION USER_DESCRIPTION TRAIT_WML
|
||||
{VARIABLE number {NUMBER}}
|
||||
{VARIABLE i 0}
|
||||
[while]
|
||||
|
@ -48,7 +48,7 @@
|
|||
user_description={USER_DESCRIPTION}
|
||||
upkeep=full
|
||||
animate=yes
|
||||
{WML_FRAGMENT}
|
||||
{TRAIT_WML}
|
||||
[/unit]
|
||||
{VARIABLE_OP i add 1}
|
||||
[/do]
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
[/frame]
|
||||
[/attack_anim]
|
||||
|
||||
#define ELDER_MAGE_LIGHTNING DIRECTION
|
||||
#define ELDER_MAGE_LIGHTNING DIRECTION_NUMBER
|
||||
[attack_anim]
|
||||
[attack_filter]
|
||||
name=lightning
|
||||
|
@ -99,7 +99,7 @@
|
|||
[missile_frame]
|
||||
begin=-250
|
||||
end=150
|
||||
halo=halo/lightning-bolt-{DIRECTION}-1.png~FL(vert):100,halo/lightning-bolt-{DIRECTION}-2.png~FL(vert):100,halo/lightning-bolt-{DIRECTION}-3.png~FL(vert):100,halo/lightning-bolt-{DIRECTION}-4.png~FL(vert):100
|
||||
halo=halo/lightning-bolt-{DIRECTION_NUMBER}-1.png~FL(vert):100,halo/lightning-bolt-{DIRECTION_NUMBER}-2.png~FL(vert):100,halo/lightning-bolt-{DIRECTION_NUMBER}-3.png~FL(vert):100,halo/lightning-bolt-{DIRECTION_NUMBER}-4.png~FL(vert):100
|
||||
halo_y=-125
|
||||
offset=1.0
|
||||
[/missile_frame]
|
||||
|
@ -110,7 +110,7 @@
|
|||
[missile_frame]
|
||||
begin=-250
|
||||
end=150
|
||||
halo=halo/lightning-bolt-{DIRECTION}-1.png:100,halo/lightning-bolt-{DIRECTION}-2.png:100,halo/lightning-bolt-{DIRECTION}-3.png:100,halo/lightning-bolt-{DIRECTION}-4.png:100
|
||||
halo=halo/lightning-bolt-{DIRECTION_NUMBER}-1.png:100,halo/lightning-bolt-{DIRECTION_NUMBER}-2.png:100,halo/lightning-bolt-{DIRECTION_NUMBER}-3.png:100,halo/lightning-bolt-{DIRECTION_NUMBER}-4.png:100
|
||||
halo_y=-125
|
||||
offset=1.0
|
||||
[/missile_frame]
|
||||
|
|
|
@ -267,15 +267,15 @@
|
|||
[/clear_variable]
|
||||
#enddef
|
||||
|
||||
#define SET_LABEL X Y MESSAGE
|
||||
# Puts MESSAGE on the map at X,Y. Strictly a syntactic shortcut.
|
||||
#define SET_LABEL X Y STRING
|
||||
# Puts STRING on the map at X,Y. Strictly a syntactic shortcut.
|
||||
#
|
||||
# For example:
|
||||
#! {SET_LABEL 4 7 _ "There be dragons here!"}
|
||||
[label]
|
||||
x={X}
|
||||
y={Y}
|
||||
text={MESSAGE}
|
||||
text={STRING}
|
||||
[/label]
|
||||
#enddef
|
||||
|
||||
|
@ -291,15 +291,15 @@
|
|||
[/label]
|
||||
#enddef
|
||||
|
||||
#define SET_LABEL_PERSISTANT X Y MESSAGE
|
||||
#define SET_LABEL_PERSISTANT X Y STRING
|
||||
# Sets a label on tile x,y that gets reset every sideturn in case
|
||||
# someone clears it.
|
||||
#
|
||||
# Example:
|
||||
#! {SET_LABEL_PERSISTANT 4 7 _ "There really will be dragons here!!"}
|
||||
{SET_LABEL {X} {Y} ({MESSAGE}) }
|
||||
{SET_LABEL {X} {Y} ({STRING}) }
|
||||
{ON_SIDETURN (
|
||||
{SET_LABEL {X} {Y} ({MESSAGE}) }
|
||||
{SET_LABEL {X} {Y} ({STRING}) }
|
||||
)}
|
||||
#enddef
|
||||
|
||||
|
@ -324,9 +324,9 @@
|
|||
[/removeitem]
|
||||
#enddef
|
||||
|
||||
#define SET_IMAGE_AND_LABEL_PERSISTANT X Y IMAGE MESSAGE
|
||||
#define SET_IMAGE_AND_LABEL_PERSISTANT X Y IMAGE STRING
|
||||
# Shorthand for setting both a persistant label and image at once.
|
||||
{SET_LABEL_PERSISTANT {X} {Y} ({MESSAGE}) }
|
||||
{SET_LABEL_PERSISTANT {X} {Y} ({STRING}) }
|
||||
{SET_IMAGE {X} {Y} ({IMAGE}) }
|
||||
#enddef
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
# These macros don't depend on any others. Please don't change this.
|
||||
# ! in comments is used in generating HTML documentation, ignore it otherwise.
|
||||
|
||||
#define SET_OBJECTIVES SIDE SUMMARY NOTE CONDITIONS
|
||||
#define SET_OBJECTIVES SIDE SUMMARY NOTE CONDITION_WML
|
||||
# Sets the objectives for a given player
|
||||
# Side 0 means every player. Does not affect gameplay,
|
||||
# except that it tells the player what the objectives of a scenario are.
|
||||
|
@ -17,7 +17,7 @@
|
|||
side = {SIDE}
|
||||
summary = {SUMMARY}
|
||||
note = {NOTE}
|
||||
{CONDITIONS}
|
||||
{CONDITION_WML}
|
||||
[/objectives]
|
||||
#enddef
|
||||
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
# to be placed directly under your [scenario] tag, and not within an event
|
||||
# such as start or prestart.
|
||||
|
||||
#define LIMIT_CONTEMPORANEOUS_RECRUITS SIDE FILTER LIMIT
|
||||
#define LIMIT_CONTEMPORANEOUS_RECRUITS SIDE FILTER LIMIT_NUMBER
|
||||
# Limit the number of units passing a specified filter that a side
|
||||
# can have simultaneously. When the number of matching units
|
||||
# side has reaches or exceeds LIMIT, that side is prevented from
|
||||
# side has reaches or exceeds LIMIT_NUMBER, that side is prevented from
|
||||
# recruiting more until the number of units of that type drops
|
||||
# below LIMIT again.
|
||||
# below LIMIT_NUMBER again.
|
||||
#
|
||||
# Allow side 2 no more than 2 Troll Rocklobbers at a time
|
||||
#! {LIMIT_CONTEMPORANEOUS_RECRUITS 2 type="Troll Rocklobber" 2}
|
||||
|
@ -38,7 +38,7 @@
|
|||
[if]
|
||||
[variable]
|
||||
name=LIMIT_CONTEMPORANEOUS_RECRUITS_temp.length
|
||||
greater_than_equal_to={LIMIT}
|
||||
greater_than_equal_to={LIMIT_NUMBER}
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
|
@ -83,7 +83,7 @@
|
|||
[if]
|
||||
[variable]
|
||||
name=LIMIT_CONTEMPORANEOUS_RECRUITS_temp.length
|
||||
greater_than_equal_to={LIMIT}
|
||||
greater_than_equal_to={LIMIT_NUMBER}
|
||||
[/variable]
|
||||
|
||||
[then]
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
#enddef
|
||||
# wmlindent: stop ignoring
|
||||
|
||||
#define REPEAT NUMBER WML_FRAGMENT
|
||||
#define REPEAT NUMBER BODY_WML
|
||||
{VARIABLE REPEAT_i 0}
|
||||
|
||||
[while]
|
||||
|
@ -113,7 +113,7 @@
|
|||
[/variable]
|
||||
|
||||
[do]
|
||||
{WML_FRAGMENT}
|
||||
{BODY_WML}
|
||||
|
||||
{VARIABLE_OP REPEAT_i add 1}
|
||||
[/do]
|
||||
|
@ -563,7 +563,7 @@
|
|||
#define MENU_IMG_TXT2 IMG TXT1 TXT2
|
||||
"&"+{IMG}+"="+{TXT1}+"="+{TXT2}#enddef
|
||||
|
||||
#define TIME_ACTIONS CONTENTS
|
||||
#define TIME_ACTIONS CONTENT_WML
|
||||
# Measure (in milliseconds) the time arbitrary event WML takes to execute.
|
||||
|
||||
# Afterwards, the time the enclosed WML took to execute is found in the variable
|
||||
|
@ -581,7 +581,7 @@
|
|||
#! [/event]
|
||||
{VARIABLE_OP TIME_ACTIONS_time_begin time stamp}
|
||||
|
||||
{CONTENTS}
|
||||
{CONTENT_WML}
|
||||
|
||||
{VARIABLE_OP TIME_ACTIONS_time_end time stamp}
|
||||
|
||||
|
|
|
@ -947,10 +947,10 @@
|
|||
{VARIABLE main_spawns[$main_group].spawn_number $spawn_id}
|
||||
#enddef
|
||||
|
||||
#define DEFINE_SPAWN_LOCATION XSPAN YSPAN
|
||||
#define DEFINE_SPAWN_LOCATION X_SPAN Y_SPAN
|
||||
{VARIABLE_OP location add 1}
|
||||
{VARIABLE spawn_place[$location].x {XSPAN}}
|
||||
{VARIABLE spawn_place[$location].y {YSPAN}}
|
||||
{VARIABLE spawn_place[$location].x {X_SPAN}}
|
||||
{VARIABLE spawn_place[$location].y {Y_SPAN}}
|
||||
#enddef
|
||||
|
||||
#define DEFINE_FIXED_GROUP X Y
|
||||
|
|
|
@ -66,13 +66,13 @@ def formaltype(f):
|
|||
ftype = "numeric"
|
||||
elif f in ("POSITION",):
|
||||
ftype = "position"
|
||||
elif f in ("XSPAN", "YSPAN"):
|
||||
elif f.endswith("_SPAN"):
|
||||
ftype = "span"
|
||||
elif f in ("RANGE",):
|
||||
ftype = "range"
|
||||
elif f in ("NAME", "VAR", "IMAGESTEM", "ID"):
|
||||
elif f in ("NAME", "VAR", "IMAGESTEM", "ID") or f.endswith("_NAME"):
|
||||
ftype = "name"
|
||||
elif f in ("TYPE", "TERRAIN", "TEXT"):
|
||||
elif f in ("STRING", "TYPE", "TERRAIN", "TEXT"):
|
||||
ftype = "string"
|
||||
elif f in ("DESCRIPTION", "USER_DESCRIPTION",):
|
||||
ftype = "optional_string"
|
||||
|
@ -82,7 +82,7 @@ def formaltype(f):
|
|||
ftype = "sound"
|
||||
elif f in ("FILTER", "ACTION"):
|
||||
ftype = "filter"
|
||||
elif f in ("WML_FRAGMENT",):
|
||||
elif f.endswith("_WML"):
|
||||
ftype = "wml"
|
||||
elif f in ("VALUE",):
|
||||
ftype = "any"
|
||||
|
|
|
@ -159,11 +159,9 @@ class CrossRefLister(CrossRef):
|
|||
print name
|
||||
def unchecked(self, fp):
|
||||
"List all macro definitions with untyped formals."
|
||||
sorted = self.xref.keys()
|
||||
sorted.sort()
|
||||
unchecked = []
|
||||
totalcount = 0
|
||||
for name in sorted:
|
||||
for name in self.xref.keys():
|
||||
for defn in self.xref[name]:
|
||||
totalcount += 1
|
||||
if None in map(formaltype, defn.args):
|
||||
|
@ -171,6 +169,7 @@ class CrossRefLister(CrossRef):
|
|||
if unchecked:
|
||||
print "# %d of %d macro definitions have untyped formals:" \
|
||||
% (len(unchecked), totalcount)
|
||||
unchecked.sort(lambda a, b: cmp(a[1], b[1]))
|
||||
for (name, defn) in unchecked:
|
||||
print "%s: %s(%s)" % (defn, name, ", ".join(defn.args))
|
||||
def extracthelp(self, pref, fp):
|
||||
|
|
Loading…
Add table
Reference in a new issue