Author: esr
Date: Tue Apr 24 13:22:43 2007
New Revision: 17027
URL: http://svn.gna.org/viewcvs/wesnoth?rev=17027&view=rev
Log:
Make map_convert.pl cope better with bogus map_data lines and report errors
in a format compatible with Emacs compile mode. This code is going to
go away soon, these improvements were for doing regression tests
against the new Python version.
Modified:
trunk/data/tools/map_convert.pl
Modified: trunk/data/tools/map_convert.pl
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/map_convert.pl?rev=17027&r1=17026&r2=17027&view=diff
==============================================================================
--- trunk/data/tools/map_convert.pl (original)
+++ trunk/data/tools/map_convert.pl Tue Apr 24 13:22:43 2007
@@ -146,7 +146,11 @@
$width=$max_len+2;
open(MAP, "<$map_file");
@mfile=();
-$map_only=1;
+if ($map_file=~/.cfg$/) {
+ $map_only=0;
+} else {
+ $map_only=1;
+}
while($line=<MAP>){
push(@mfile,$line);
if($line=~/map_data/){
@@ -160,9 +164,14 @@
@map=();
close(MAP);
+$lineno = $baseline = 0;
while($#mfile){
$line=shift(@mfile);
- if($map_only || $line=~/map_data/){
+ $lineno++;
+ # Don't start parsing on map_data="{, let the WML preprocessor have it
+ # Non-alphanumerics that can appear are / | \ & _ ~ ? [ ]'
+ if($map_only || ($line=~/map_data=\"[A-Za-z0-9\/|\\&_~?\[\]]{2,}\r?/)){
+ $baseline = $lineno;
$cont=1;
#read map assumes map is more than 1 line long.
if(!$map_only){
@@ -172,6 +181,11 @@
# print "$line\n";
while(($cont) && ($#mfile)){
$line=shift(@mfile);
+ $lineno++;
+ if($line=~/^#/) {
+ push(@newfile,$line);
+ next;
+ }
if($line=~/\"/){
$cont=0;
($line,$dummy)=split('"',$line);
@@ -184,6 +198,7 @@
push(@newfile,$line);
}
$y=0;
+ $format="%${width}.${max_len}s";
foreach(@map){
chomp;
if($_=~/,/){die "map file appears to be converted already\n";}
@@ -192,12 +207,15 @@
$hex='';
$char=substr($_,$x,1);
# print "$char";
- $format="%${width}.${max_len}s";
- if(defined($conversion{$char})){
+ if ($char=~/\r/) {
+ $hex="\r"
+ }elsif(defined($conversion{$char})){
$hex=sprintf($format,$conversion{$char});
}else{
$ord=ord($char);
- die "error, unrecognized map character at
($x,$y):[$ord]$char";
+ $errline = $baseline + $y + 1;
+ print "mapconvert.pl: \"$map_file\", line $errline:
unrecognized map character '$char' ($ord) at ($x,$y)\n";
+ exit 1;
# $hex=sprintf($format,$char);
}
if($hex=~/_K/){
@@ -211,8 +229,8 @@
$ca=$conversion{$a};
if(!defined($ca)){
$ord=ord($a);
- print "error in adjacent hexes:\n";
- print "($x,$y,$i)[$ord]:$a\n";
+ $errline = $baseline + $y + 1;
+ print "mapconvert.pl: \"$map_file\", line
$errline: error in adjacent hexes: ($x,$y,$i)[$ord]:$a\n";
}
if($ca=~/^C/){ #this is a castle hex
$hexcount{$ca}++;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits