it. Don't try `display vid:#pages#.pnm' as this will consume
truly stupendous quantities of RAM - it wedged my laptop.
+ * #master-newcommods#.txt #local-newcommods#.txt
+
+ Dictionary of newly introduced commodities. When a new commodity
+ appears in Puzzle Pirates, the PCTB server operators need to add it
+ to their database for us to be able to upload data about it.
+
+ It can sometimes take a few days to do this. In the meantime, it
+ is possible to upload partial data - data just omitting that
+ commodity. This is controlled by these files: they list
+ commodities which should be automatically ignored if the PCTB
+ server doesn't know about them. The master file is downloaded and
+ updated automatically from my server. You may create the local
+ file yourself. The format is simple: one commodity per line.
+
+ Unrecognised commodities can also be due to OCR failure so
+ double-check what you're doing before overriding the uploader by
+ telling it to ignore an unrecognised commodity.
+
* #master-char*#.txt #local-char*#.txt
#master-pixmap#.txt #local-pixmap#.txt
2. YPP SC PCTB client dictionary server
=======================================
-This server maintains the master database of character and island name
-images, which is used for the commodity screen OCR and also for
-determining your island name.
+This server maintains the master databases of character and island
+name images, and of new commodity names, which is used for the
+commodity screen OCR, for determining your island name, and for
+checking whether commodities not found on the PCTB server are real.
By default, we ask the server for an updated set of dictionaries every
time we run; this is done with the rsync protocol (indeed, by invoking
rename "#commodmap#.tsv.new","#commodmap#.tsv" or die $!;
}
+our %newcommods;
+
+sub read_newcommods ($) {
+ my ($file) = @_;
+ if (!open NC, "< $file") {
+ $!==&ENOENT or die $!;
+ return;
+ }
+ while (<NC>) {
+ chomp; s/^\s*//; s/\s+$//;
+ next if m/^\#/;
+ next unless m/\S/;
+ $newcommods{$_}= 1;
+ }
+ NC->error and die $!;
+ close NC or die $!;
+}
+
+sub refresh_newcommods() {
+ my $rsync= $ENV{'YPPSC_PCTB_RSYNC'};
+ $rsync= 'rsync' if !defined $rsync;
+
+ my $local= "#master-newcommods#.txt";
+ my $src= $ENV{'YPPSC_PCTB_DICT_UPDATE'};
+ if ($src) {
+ my $remote= "$src/master-newcommods.txt";
+ $!=0; system 'rsync','-Lt','--',$remote,$local;
+ die "$? $!" if $! or $?;
+ }
+ read_newcommods($local);
+ read_newcommods('#local-newcommods#.txt');
+}
+
our (%stallmap, @stallmap);
sub bs_gen_md ($$) {
my $count= 0;
my $o= '';
- foreach $commod (sort {
- $commodmap{$a} <=> $commodmap{$b}
- } keys %commod) {
+ foreach $commod (
+ sort { $commodmap{$a} <=> $commodmap{$b} }
+ grep { exists $commodmap{$_} }
+ keys %commod
+ ) {
#print STDERR "COMMOD $commod\n";
$current= $commod{$commod};
my $l= bs_p($commod,$bs,$sortmul);
my @missing= grep { !exists $commodmap{$_} } keys %commod;
if (@missing) {
refresh_commodmap();
+ refresh_newcommods();
my $missing=0;
foreach $commod (sort keys %commod) {
next if exists $commodmap{$commod};
- printf STDERR "Unknown commodity \`%s'!\n", $commod;
- $missing++;
+ if (exists $newcommods{$commod}) {
+ printf STDERR "Ignoring new commodity \`%s'!\n", $commod;
+ } else {
+ printf STDERR "Unknown commodity \`%s'!\n", $commod;
+ $missing++;
+ }
}
- die "$missing unknown commoditi(es). OCR failure?\n"
+ die "$missing unknown commoditi(es).".
+ " See README (search for \`newcommods').\n"
if $missing;
}
die "@forcerls ?" if grep { $_ ne $forcerl } @forcerls;
my $setisland= {
- 'action' => 'setisland',
- 'filename' => $filename,
- 'forcereload' => $forcerl,
- 'ocean' => $oceanids[0],
- 'island' => $islandid,
};
print STDERR "Setting ocean and island...\n";
- $resp= $ua->post("${url}IWJTEST", $setisland);
+ my $siurl= ($url . "?action=setisland".
+ "&filename=$filename".
+ "&forcereload=$forcerl".
+ "&ocean=$oceanids[0]".
+ "&island=$islandid");
+ $resp= $ua->get($siurl);
+
die $resp->status_line unless $resp->is_success;
$resptxt= $resp->content();
save_upload_html('2', $resptxt);
-
-
-#
-#http://pctb.ilk.org/upload.php?&ocean=2&island=48&action=setisland&forcereload=1244748679&filename=PFayDW' >v.html
-#
-# print ">$filename|$forcerl|@oceanids|$islandid<\n";
+ die unless $resptxt =~ m/your uploaded data has been processed/i;
+ die unless $resptxt =~ m/your data has been integrated into the database/i;
- system 'printenv|grep YPP|sort';
+ $resptxt =~ s/\<a href=\"about:\w+\"\>[^<>]+\<\/a\>//g;
+ save_upload_html('3', $resptxt);
+
+ print "\n" or die $!;
+ system('w3m -T text/html -dump < \#upload-3#.html');
+
+ print "\n" or die $!;
}
if (!screenshot_file)
fatal("could not open screenshots file `%s': %s",
o_screenshot_fn, strerror(errno));
-
- if ((o_flags & ff_upload) && !(o_flags & ff_testservers))
- badusage("must not reuse screenshots for upload to live PCTB database");
}
static void run_analysis(void) {
analyse(tf);
if (o_flags & ff_upload) {
- if (o_flags & ff_singlepage)
+ if (npages<=1)
fatal("Recognition successful, but refusing to upload partial data\n"
" (--single-page specified). Specify an output mode?");
}
if (DEBUGP(rsync))
fprintf(stderr,"executing rsync to fetch %s to %s\n",remote,local);
execlp(rsync, "rsync",
- DEBUGP(rsync) ? "-vLt" : "-Lt",
+ DEBUGP(rsync) ? "-zvLt" : "-zLt",
"--",remote,local,(char*)0);
sysassert(!"exec rsync failed");
}
progress_log("OK for you to move the mouse now.");
}
if (o_mode & mf_readscreenshot) {
+ if ((o_flags & ff_upload) && !(o_flags & ff_testservers))
+ badusage("must not reuse screenshots for upload to live PCTB database");
open_screenshot_file("r");
if (o_flags & ff_singlepage) read_one_screenshot();
else read_screenshots();
void take_screenshots(void) {
Snapshot *current=0, *last=0;
+ RgbImage *page0_store;
prepare_ypp_client();
wait_for_stability(¤t,0, send_pgup_many,
"paging up to top of commodity list...");
+ page0_rgbimage= page0_store= alloc_rgb_image(current->w, current->h);
+
/* now to actually page down */
for (;;) {
debugf("paging page %d\n",npages);
fatal("Paging down seems to generate too many pages - max is %d.",
MAX_PAGES);
- page_images[npages]= convert_page(current, 0);
- free_snapshot(&last); last=current; current=0;
+ page_images[npages]= convert_page(current, page0_store);
+ free_snapshot(&last); last=current; current=0; page0_store=0;
debugf("PAGING page %d converted\n",npages);
debugf("PAGING all done.\n");
progress_log("collected %d screenshots.",npages);
+ assert(!page0_store);
}
void take_one_screenshot(void) {