[svn r7957] Added Martin's changes to the do_link_ent function, adding error handling.

This commit is contained in:
aaron
2008-01-18 17:47:58 +01:00
parent 424b3c0deb
commit 14cfa4ef90

View File

@@ -502,39 +502,51 @@ sub parse_csv {
# 2nd arg - the entrance of the cave to which the link goes
# Returns nothing
sub do_link_ent {
my $linkfile = $_[0];
my $linkent = $_[1];
my $linkname = $_[2];
my $storedoffset;
my $linkfile = $_[0];
my $linkent = $_[1];
my $linkname = $_[2];
my $storedoffset;
$storedoffset = tell(CSV);
seek(CSV, 0, 0);
$storedoffset = tell(CSV);
seek(CSV, 0, 0);
while (<CSV>) {
chomp;
if (grep(/,\"$linkfile\",/, $_)) {
if ((&parse_csv($_))[5] eq $linkfile) {
if ((&parse_csv($_))[4] eq "yes") {
while ((&parse_csv($_))[2] ne $linkent) {
$_ = <CSV>;
chomp;
if ((&parse_csv($_))[4] eq "last entrance" && (&parse_csv($_))[2] ne $linkent) {
print STDERR "Warning: Link entrance for $linkname not found\n\n";
$warnings = 1;
seek(CSV, $storedoffset, 0);
return;
}
}
}
my (undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, undef, $lent_name, $ltag_punkt, $lother_punkt, $ldesc_other_punkt, $lexact_punkt, $lfix_type, $lgpspresa, $lgpspostsa, $lnorthing, $leasting, $laltitude, undef, undef, undef, undef, undef, undef, $lmarking) = &parse_csv($_);
do_ent($ltag_punkt,$lother_punkt,$lexact_punkt,$lgpspostsa,$lgpspresa,$leasting,$lnorthing,$laltitude,$lent_name,$lfix_type,$ldesc_other_punkt, $lmarking);
seek(CSV, $storedoffset, 0);
return;
}
}
}
while (<CSV>) {
chomp;
if ((&parse_csv($_))[5] eq $linkfile) {
if ((&parse_csv($_))[4] eq "yes") {
while ((&parse_csv($_))[2] ne $linkent) {
$_ = <CSV>;
chomp;
if ((&parse_csv($_))[4] eq
"last entrance" && (&parse_csv($_))[2] ne $linkent) {
print STDERR "Warning:
Link entrance for $linkname not found, please specify Link
Entrance\n\n";
$warnings = 1;
seek(CSV, $storedoffset, 0);
return;
}
}
}
my (undef, undef, undef, undef, undef, undef,
undef, undef, undef, undef, undef, undef, undef, undef, undef, undef,
undef, undef, undef, undef, undef, undef, undef, undef, undef,
$lent_name, $ltag_punkt, $lother_punkt, $ldesc_other_punkt,
$lexact_punkt, $lfix_type, $lgpspresa, $lgpspostsa, $lnorthing,
$leasting, $laltitude, undef, undef, undef, undef, undef, undef,
$lmarking) = &parse_csv($_);
do_ent($ltag_punkt,$lother_punkt,$lexact_punkt,$lgpspostsa,$lgpspresa,$leasting,$lnorthing,$laltitude,$lent_name,$lfix_type,$ldesc_other_punkt,
$lmarking);
seek(CSV, $storedoffset, 0);
return;
}
}
print STDERR "Warning: Link file for $linkname not found\n\n";
$warnings = 1;
seek(CSV, $storedoffset, 0);
return;
}
# Process the location data for the entrance