comparison scan.pl @ 18:fd44e3a1f800

fixed the cache. show tradegoodText of sheeps. refined enemy.pl
author "Rex Tsai <chihchun@kalug.linux.org.tw>"
date Wed, 08 Oct 2008 16:10:01 +0800
parents 59f2c435760c
children 5635e75c92d0
comparison
equal deleted inserted replaced
17:5ea88404dc74 18:fd44e3a1f800
78 @islands = $i->viewHomeMap(); 78 @islands = $i->viewHomeMap();
79 } else { 79 } else {
80 die("Usage: $0\nUsage: $0 x y\n"); 80 die("Usage: $0\nUsage: $0 x y\n");
81 } 81 }
82 82
83 foreach my $island (@islands) 83 foreach my $h_island (@islands)
84 { 84 {
85 printf("checking island %d\n", $island->{id}); 85 printf("checking island %d\n", $h_island->{id});
86
87 my $island;
88 if($island = Ikariam::Island->retrieve($h_island->{id})) {
89 foreach my $i (keys(%$h_island)) {
90 $island->set($i => $h_island->{$i});
91 }
92 } else {
93 $island = Ikariam::Island->insert($h_island);
94 }
86 95
87 # scanning the island 96 # scanning the island
88 if($island->{time} < (time - 60*60*12 )) 97 if($island->time le (time - 60*60*12 ))
89 { 98 {
90 my @cities = $i->viewIsland($island->{id}); 99 my @cities = $i->viewIsland($h_island->{id});
91 saveCities($island->{id}, @cities); 100 saveCities($h_island->{id}, @cities);
101 }
92 102
93 $island->{'time'} = time; 103 $island->set('time', time);
94 if(my $c = Ikariam::Island->retrieve($island->{id})) { 104 $island->update();
95 foreach my $i (keys(%$island)) {
96 eval($c->$i($island->{$i}));
97 }
98 } else {
99 Ikariam::Island->insert($island);
100 }
101 }
102 } 105 }
103 $i->logout; 106 $i->logout;
104 # $i->getCityInfo(); 107 # $i->getCityInfo();