18240 Commits

Author SHA1 Message Date
Groggy Dice
aeb558419d give line number of DEFENSE_ANIM too, when warning that get_hit_sound is also present
Building on our earlier fix pointing this message's line number to the get_hit_sound, it would be even more useful to have the line number of the DEFENSE_ANIM as well. To get this, we change the has_defense_anim variable's value from False to None, and True to i. It is possible that a unit might have two macros for male and female variants, in which case we will assume that the get_hit_sound is most likely associated with the first.
2013-07-26 04:21:49 -04:00
Groggy Dice
77eb8cc8d1 upgrade old {UNIT} macro to 1.4's {LOYAL_UNIT}
Of course, during 1.5, this macro was renamed to {*NAMED_*LOYAL_UNIT}, but we will stick to upgrading to "1.4", and worry about changing LOYAL_UNIT to NAMED_LOYAL_UNIT in the current wmllint.

The basic "if '{UNIT '" condition is more efficient than subjecting every line to a complex regex. However, it would be theoretically possible for a matching line to fail the substitution. Thus, I used subn() instead of sub(), and only report an upgrade to stdout if there is at least one substitution. In the hypothetical case that no substitution is carried out, I alert the user so they can look into it.

The regular expression looks intimidating, so here's an explanation:

field 1: unit type - The authors of this era seem to have been pretty good about enclosing fields in parentheses, but this part of the regex accounts for all three possibilities: a) parentheses used to enclose; b) quotes used to enclose; c) no enclosure, thus ending with the next space.
field 2: id - Basically a clone of the first field.
field 3: name - Clone of the first two fields, except for allowing a translability underscore in the last two cases (though early UMC seems to all follow the practice of including the translatability underscore with the rest of the name inside parentheses.)
field 4: side - We can expect this to be a number. Old add-ons should all be using single digits, but I allow more than one digit to match anyway. In theory, there could be cases which would break the regex (e.g., enclosing the number in parentheses, a macro substitution), but since I don't know of any, I'll just call it a day.
field 5: x coordinate - Usually this will be a number, but it could also be a variable or a macro substitution.
field 6: y coordinate - Clone of field 6, except with y/Y substituted for x/X.

(A side note: after testing this commit, I noticed that the introduction to hack_syntax called for "set[ting] modcount to nonzero" when modifying lines, there are "modcount += 1" lines throughout the animation transformations, and hack_syntax ends with "return (lines, modcount)". Looking into it, however: a) my code was working fine without it, with no change detected after I tested inserting "modcount += 1"; b) I never figured out just what use wmllint was making of the modcount, despite all the care to increment it upwards; c) the last suite in hack_syntax doesn't use modcount, either, and it turns out to have been written by ESR himself in February 2008, after all the other code.)
2013-07-26 04:21:41 -04:00
Groggy Dice
978245b1fb clean up get_hit_sound messages
The first message has a couple of problems. Technically, get_hit_sound is not a tag, and there is a stray quote mark at the end. Also, i+1 points to the line number of the [/unit] tag, which is not particularly helpful information. This can be changed to point to the line of the get_hit_sound attribute.

For the second message, the %d get_hit_sound is an index position, so +1 for the line number.
2013-07-26 04:21:34 -04:00
Groggy Dice
ec6a49a06b print second half of "duplicated attack" warning to stderr also
This warning could become confusing if split up by stdout or stderr being redirected.
2013-07-26 04:21:26 -04:00
Groggy Dice
d80845e1b4 Correct "AMLA TOUGH" to "AMLA_TOUGH"
Admittedly, only a couple of campaigns have this error, but it keeps {AMLA_TOUGH 3} from being updated to {AMLA_DEFAULT}.
2013-07-26 04:21:19 -04:00
Groggy Dice
f6812162d2 insert rstrip() to fix wmllint-crashing assumption that unit files are using Unix newlines
In Linux, many 1.2 unit files would crash wmllint, with tracebacks pointing to the "assert male/female_end != -1" line. Male/female_end's value is set to -1, and when it does not meet the condition for converting to i (line index position), the assert statement fails. The "assert male_end" error crashes files with gender=male, or no gender= key (thus defaulting to male). The "assert female_end" error is the female counterpart, and also covers units with both genders.

I found that after commenting out these assert statements, wmllint no longer barfed on those files. Studying the problem for this commit, however, I saw that "endswith()" included a newline. Could it simply be choking on DOS carriage returns? Doing a dryrun in Windows, which defaults to universal newlines support, I did not get the crashes. Change to binary mode, the crashes returned. Insert rstrip() and delete the newlines, and the crashes stop!
2013-07-26 04:21:11 -04:00
Groggy Dice
44c19c9c80 wmllint: update old "portraits/core/" paths to "portraits/"
These portraits were moved prior to 1.1.9. That was before ESR joined Wesnoth development in April 2007, which may explain why wmllint didn't cover this change. Nevertheless, even many 1.2 campaigns still have the old "portraits/core" filepaths.

These old paths also keep post-1.4 wmllint from updating portrait paths to their current location, after they were moved again in 1.5.9.
2013-07-26 04:21:04 -04:00
Elvish_Hunter
db1debd6c0 wmllint, wmlscope and wmlindent: fixed bug caused by Windows' command prompt appending double quotes to arguments
This is a backport of Elvish Hunter's 2013-02-23T13:04:12Z fix to 1.11.
2013-07-26 04:20:56 -04:00
Groggy Dice
2fc24bf8aa backport: removal of files on Windows before --revert and conversion file rename
Windows won't allow a rename to overwrite an existing file (without Error 183, file already exists).
2013-07-26 04:20:48 -04:00
Eric S. Raymond
8b0bce5d15 copy original wmllint 1.4 into data/tools
Since esr is overwhelmingly the predominant author of early wmllint, I am importing it in the form of a patch from him, so that git blame will bear some resemblance to reality. Those interested in the full development history should refer back to the 1.4 branch.

git blame (without switches) ascribes the following lines to authors other than esr:

48a82a6f5 data/tools/wmllint-1.4   (Elias Pschernig 2007-05-31 19:06:25 +0000   77) from wesnoth.wmltools import *
4be7e8163 data/tools/wmllint-1.4   (Patrick Parker  2007-09-09 06:12:43 +0000   78) from wesnoth.wmliterator import *
68cb53470 data/tools/wmllint-1.4   (Gunter Labes    2007-07-11 21:09:36 +0000  261)         ("holy=", "arcane="),
68cb53470 data/tools/wmllint-1.4   (Gunter Labes    2007-07-11 21:09:36 +0000  291)     ),
c15a9fc9a data/tools/wmllint-1.4   (Gunter Labes    2007-09-20 16:43:35 +0000  295) 	("Halbardier" , "Halberdier"),
ea3323d98 data/tools/wmllint-1.4   (Patrick Parker  2007-09-06 01:57:09 +0000  948)     global versions
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1071)                 break
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1206)     # Garbage-collect any empty [attack] scopes left behind;
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1207)     # this is likely to happen with female-variant units.
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1208)     nullattack = True
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1209)     while nullattack:
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1210)         nullattack = False
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1211)         for i in range(len(lines)-1):
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1212)             if lines[i].strip() == "[attack]" and lines[i+1].strip() == "[/attack]":
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1213)                 nullattack = True
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1215)         if nullattack:
d84b7f63b data/tools/wmllint-1.4   (Jérémy Rosen    2007-09-08 07:51:22 +0000 1216)             lines = lines[:i] + lines[i+2:]
e542a2ada data/tools/wmllint-1.4   (Gunter Labes    2007-09-20 17:29:49 +0000 1469)         name_pos = wmlfind("name=", WmlIterator(lines, filename))
801aa3003 data/tools/wmllint-1.4   (Jérémy Rosen    2007-10-05 19:59:11 +0000 1487) [attack_anim]
801aa3003 data/tools/wmllint-1.4   (Jérémy Rosen    2007-10-05 19:59:11 +0000 1497) [/attack_anim]\
bc4e1d8f3 data/tools/wmllint-1.4   (Patrick Parker  2007-09-09 23:24:29 +0000 1552)     except IndexError:
bc4e1d8f3 data/tools/wmllint-1.4   (Patrick Parker  2007-09-09 23:24:29 +0000 1553)         has_map_content = False
a106067a8 data/tools/wmllint-1.4   (Mark de Wever   2007-05-27 16:19:33 +0000 1602)         if not map_only:
a106067a8 data/tools/wmllint-1.4   (Mark de Wever   2007-05-27 16:19:33 +0000 1603)             line = mfile.pop(0)
a106067a8 data/tools/wmllint-1.4   (Mark de Wever   2007-05-27 16:19:33 +0000 1604)             if verbose >= 3:
a106067a8 data/tools/wmllint-1.4   (Mark de Wever   2007-05-27 16:19:33 +0000 1605)                 sys.stdout.write(line + terminator)
a106067a8 data/tools/wmllint-1.4   (Mark de Wever   2007-05-27 16:19:33 +0000 1606)             lineno += 1
176b29319 data/tools/wmllint-1.4   (Mark de Wever   2007-10-28 10:53:53 +0000 1725)                 # Strip the starting positions out of the edges
176b29319 data/tools/wmllint-1.4   (Mark de Wever   2007-10-28 10:53:53 +0000 1726)                 outermap(lambda n: re.sub(r"[1-9] ", r"", n), outmap)
bb07ea830 data/tools/wmllint-1.4   (Mark de Wever   2007-10-28 09:03:10 +0000 1728)                 outermap(lambda n: n.replace(r"Gg^Fet", r"Gs^Fp"), outmap)
d725c7cdb data/tools/wmllint-1.4   (Gunter Labes    2007-08-24 04:54:04 +0000 1883) Usage: wmllint [options] [dir]
d725c7cdb data/tools/wmllint-1.4   (Gunter Labes    2007-08-24 04:54:04 +0000 1885)     Takes any number of directories as arguments.  Each directory is converted.
d725c7cdb data/tools/wmllint-1.4   (Gunter Labes    2007-08-24 04:54:04 +0000 1886)     If no directories are specified, acts on the current directory.
d725c7cdb data/tools/wmllint-1.4   (Gunter Labes    2007-08-24 04:54:04 +0000 1896)     -D, --diff                 Display diffs between converted and unconverted files.
ea3323d98 data/tools/wmllint-1.4   (Patrick Parker  2007-09-06 01:57:09 +0000 1903)     global versions
2013-07-26 04:20:39 -04:00
Groggy Dice
ffb34c2ffa Windows sys.argv again: sys.exit(1) when too complicated, and deliver a looooooong stderr message
I noted last time that my "fix" could not cover all possibilities. After further thought, I decided that the best thing to do in the hard cases is to sys.exit, and give users a clear explanation in stderr so they can re-enter their paths correctly. I may have gotten carried away, but given that many users nowadays are unfamiliar with the command line (even moreso on Windows), I wanted to give them plenty of hand-holding.

I looked up this issue, and it turns out to be a Windows shell problem after all, not Python, which surprised me.
2013-07-26 03:32:58 -04:00
Groggy Dice
c471ec4847 sys.exit(1) if globbing matches no files/directories
After more testing, I realized that I did not take into account the possibility that the wildcard pattern would not match anything. In that case, the following 'if not arguments' clause would run wmllint on the entire current directory - which could very well be something that you do not want!
2013-07-26 01:32:05 -04:00
mattsc
45611d8fa6 Messenger Micro AI: move duplicate code into a function 2013-07-25 16:30:23 -07:00
Elvish_Hunter
095b7b772f [allow_recruit], [disallow_recruit]: added a less cryptic error message if type= is missing 2013-07-23 22:29:04 +02:00
Elvish_Hunter
a72d1faca5 TSG: fixed 'lich found' message appearing twice in scenario 5 2013-07-23 22:29:03 +02:00
Groggy Dice
f6fca7c4e7 remove '~' in [textdomain] and [binary_path] paths
Although the original purpose of the in_textdomain and in_binary_path code, an aborted effort to update their paths to "data/add-ons/", has been superseded by code that updates those paths on all lines, it can still be put to use.

Our first step is to move that section below the code that updated UMC paths, so our regexes won't have to deal with "@campaigns" and "data/campaigns" strings. Then we delete the 'if 0:' line that was neutralizing this section, as well as the obsolete path-changing code. The rest is de-indented one level.

Then we look for the use of "~" for userdata, which does not work for textdomains and binary paths.

Our regex object, 'tilde', is constituted thusly: (1) We make sure that the line starts with the "path" key. Any line we're interested in ought to start with this, and this will also keep this code from going wild on the campaign includes, if an author forgot a closing tag (no reset to False). (x) There shouldn't be any whitespace around the = sign, but we'll be kind. (2) On the value side, there shouldn't be anything before the tilde except perhaps a quote. Rather than underestimate the ingenuity of authors in coming up with weird code, however, I allow anything except a comment to match for a few characters. But if we haven't hit the '~' after five characters, I figure something's wrong, and bail. (3) Then we come to the tilde. Normally, it would be adjoining "add-ons/", but some authors interpolate a slash, or 'data/' (here represented as an optional string).

If we match, we rebuild the line, except 'data/add-ons' is substituted for group(3), and we log to stdout.
2013-07-22 21:44:25 -04:00
Groggy Dice
8efffbe86f wmllint: activate wildcard globbing on Windows
The Windows cmd shell does not expand wildcards by default, unlike UNIX shells. This imports glob.glob and runs arguments through it on Windows.

Frontported (in modified form) from my 1.4 work!
2013-07-22 21:44:13 -04:00
Groggy Dice
71caf69975 wmllint: extend Elvish Hunter's Windows sys.argv fix to cover more cases
While testing my next commit, I discovered that EH's fix works when there is only one argument, or if the offender is the last argument, but doesn't work with multiple entries. His fix is meant to work on each argument, but the (unintentionally) escaped quote no longer serves to end the argument, causing following arguments to be considered part of the same argument.

Using split() allows us to break apart these misconjoined arguments. With rstrip(), we prevent an empty string that Windows will also complain it cannot find. However, if there are three or more arguments, there will still be lumped-together arguments unless all arguments up to the second from last also end with a backslash and quote. It is impossible to cover every possible case.

The re.sub handles the probably rare case where a backslash before a quote comes within the argument rather than at the end. However, it will only work if there is only one argument.

All this is unnecessary if the OS is not Windows (also, I haven't had the opportunity to test this on a non-Windows system to see if it has any side-effects there). So I've put it under a sys.platform condition.
2013-07-22 21:43:44 -04:00
Elvish_Hunter
5f5279d526 UtBS: fixed the Stun special to handle the automatic ellipse change based on ZoC emission 2013-07-21 14:26:37 +02:00
Elvish_Hunter
b455dad7d0 DW: fixed the Stun special to handle the automatic ellipse change based on ZoC emission 2013-07-21 14:26:36 +02:00
Elvish_Hunter
605911f179 Removed no longer useful ellipse= key from campaign specific units (tutorial) 2013-07-21 14:26:36 +02:00
Elvish_Hunter
a6575f261a Removed no longer useful ellipse= key from campaign specific units (Under the Burning Suns) 2013-07-21 14:26:36 +02:00
Elvish_Hunter
78bcc57baf Removed no longer useful ellipse= key from campaign specific units (The Rise of Wesnoth) 2013-07-21 14:26:36 +02:00
Elvish_Hunter
dfa840133a Removed no longer useful ellipse= key from campaign specific units (The Hammer of Thursagan) 2013-07-21 14:26:35 +02:00
Elvish_Hunter
728cf3f822 Removed no longer useful ellipse= key from campaign specific units (Heir to the Throne) 2013-07-21 14:26:35 +02:00
Elvish_Hunter
235748db12 Removed no longer useful ellipse= key from campaign specific units (Descent into Darkness) 2013-07-21 14:26:34 +02:00
Elvish_Hunter
ece52c9c3e Removed no longer useful ellipse= key from campaign specific units (Dead Water) 2013-07-21 14:26:34 +02:00
Elvish_Hunter
b051385c0b Removed no longer useful ellipse= key from mainline units (wose) 2013-07-21 14:26:34 +02:00
Elvish_Hunter
fd5c9e95bd Removed no longer useful ellipse= key from mainline units (undead) 2013-07-21 14:26:34 +02:00
Elvish_Hunter
82ae407d0a Removed no longer useful ellipse= key from mainline units (trolls) 2013-07-21 14:26:33 +02:00
Elvish_Hunter
2a2e468738 Removed no longer useful ellipse= key from mainline units (saurians) 2013-07-21 14:26:33 +02:00
Elvish_Hunter
ff43c84b9c Removed no longer useful ellipse= key from mainline units (orcs) 2013-07-21 14:26:33 +02:00
Elvish_Hunter
49ccdef502 Removed no longer useful ellipse= key from mainline units (ogres) 2013-07-21 14:26:33 +02:00
Elvish_Hunter
e4c831b2ad Removed no longer useful ellipse= key from mainline units (nagas) 2013-07-21 14:26:32 +02:00
Elvish_Hunter
0828c2fb72 Removed no longer useful ellipse= key from mainline units (monsters) 2013-07-21 14:26:31 +02:00
Elvish_Hunter
695850efed Removed no longer useful ellipse= key from mainline units (merfolk) 2013-07-21 14:26:31 +02:00
Elvish_Hunter
e4fd1af584 Removed no longer useful ellipse= key from mainline units (humans) 2013-07-21 14:26:31 +02:00
Elvish_Hunter
56cfa0e17a Removed no longer useful ellipse= key from mainline units (gryphons) 2013-07-21 14:26:30 +02:00
Elvish_Hunter
58533f8095 Removed no longer useful ellipse= key from mainline units (goblins) 2013-07-21 14:26:30 +02:00
Elvish_Hunter
abb709c725 Removed no longer useful ellipse= key from mainline units (elves) 2013-07-21 14:26:30 +02:00
Elvish_Hunter
ed4e5c1236 Removed no longer useful ellipse= key from mainline units (dwarves) 2013-07-21 14:26:29 +02:00
Elvish_Hunter
e1c329352a Removed no longer useful ellipse= key from mainline units (drakes) 2013-07-21 14:26:28 +02:00
Elvish_Hunter
4a5fef335b Removed no longer useful ellipse= key from mainline units (boats) 2013-07-21 14:26:28 +02:00
Elvish_Hunter
4f8f50051b Removed no longer useful ellipse= key from mainline units (bats)
Since ellipses automatically change depending on the ZoC emission, there is no point to change them manually in the cfgs - we don't want the engine to look for a misc/ellipse-nozoc-nozoc file. This commit is the first of a series that will fix all mainline units, even the campaign-specific ones.
2013-07-21 14:26:28 +02:00
JaMiT
2a5f5df56a Fix some missing commas in the text. 2013-07-20 10:54:23 -05:00
fendrin
5191331565 Grouped the map generators into a folder and added the yamg. 2013-07-20 15:59:29 +02:00
fendrin
414b4eceda LoW 7: Fix side setup. Disable AI controller. 2013-07-20 15:59:29 +02:00
fendrin
c70dadbc33 LoW 4: Loyal units for Cleodil. 2013-07-20 15:59:28 +02:00
fendrin
8dcace3327 LoW 1: Start gold adjusted. 2013-07-20 15:59:28 +02:00
fendrin
284d5ecbbc LoW 3,7,10 map updates. 2013-07-20 15:59:28 +02:00