[SimBot-commits] CVS: simbot/plugins weather.pl,1.70,1.71
Status: Abandoned
Brought to you by:
kstange
|
From: Pete P. <fou...@us...> - 2005-05-07 11:53:24
|
Update of /cvsroot/simbot/simbot/plugins In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28809/plugins Modified Files: weather.pl Log Message: We no longer crash simbot if a forecast is requested in a state with no alerts. Index: weather.pl =================================================================== RCS file: /cvsroot/simbot/simbot/plugins/weather.pl,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -p -r1.70 -r1.71 --- weather.pl 7 May 2005 02:35:59 -0000 1.70 +++ weather.pl 7 May 2005 11:53:13 -0000 1.71 @@ -730,7 +730,7 @@ sub got_alerts { my $cap_alert; - if (!eval { $cap_alert = XMLin($raw_xml, SuppressEmpty => 1, NormaliseSpace => 2); }) { + if (!eval { $cap_alert = XMLin($raw_xml, NormaliseSpace => 2, ForceArray => ('cap:info')); }) { &SimBot::debug(3, "weather: XML parse error for alerts\n"); &SimBot::debug(4, "weather: XML parser failure: $@"); @@ -746,12 +746,15 @@ sub got_alerts { my $cap_info = $cap_alert->{'cap:info'}; - for my $i (0 .. $#$cap_info) { - my $cur_geocode = int $cap_info->[$i]->{'cap:area'}->{'cap:geocode'}; - if($cur_geocode == $geocode) { +# for my $i (0 .. $#$cap_info) { + foreach my $cur_cap_info (@{$cap_alert->{'cap:info'}}) { + #my $cur_geocode = int $cap_info->[$i]->{'cap:area'}->{'cap:geocode'}; + if(defined $cur_cap_info->{'geocode'} + && $cur_cap_info->{'geocode'} == $geocode) + { # We have a warning! - push(@alerts, $cap_info->[$i]->{'cap:event'}); - push(@alerts_link, $cap_info->[$i]->{'cap:web'}); + push(@alerts, $cur_cap_info->{'cap:event'}); + push(@alerts_link, $cur_cap_info->{'cap:web'}); } } |