From: Ian Jackson Date: Thu, 29 Oct 2009 18:57:44 +0000 (+0000) Subject: Merge branch 'refs/remote/t.fa.mason' X-Git-Tag: 5.1~1 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=commitdiff_plain;h=6a4d494e0e31f95bdd6dd54b814e8b2381ad95b2;hp=3e2580712c6d5e87a6c6a35836cd3e492fae8445;p=ypp-sc-tools.db-test.git Merge branch 'refs/remote/t.fa.mason' --- diff --git a/yarrg/Commods.pm b/yarrg/Commods.pm index 372fe16..f74571d 100644 --- a/yarrg/Commods.pm +++ b/yarrg/Commods.pm @@ -51,7 +51,33 @@ BEGIN { @EXPORT_OK = qw(); } -our $masterinfoversion= 2; # version we understand +our $masterinfoversion= 2; # version we understand. +# +# To extend the source-info.txt format: +# +# * Commods.pm:parse_info1 +# add code to parse new version +# +# * source-info.txt +# add new information +# +# If new data should NOT be in master-info.txt too: +# +# * update-master-info:process_some_info +# check that code for converting source-info to master-info +# removes the extra info; add code to remove it if necessary +# +# * db-idempotent-populate +# if database schema is extended, add code to copy data +# +# If new data DOES need to be in master-info.txt too: +# +# * Commods.pm:$masterinfoversion +# increment +# +# * update-master-info:process_some_info +# add code to convert new version to old, by removing +# extra info conditionally depending on version our %oceans; # eg $oceans{'Midnight'}{'Ruby'}{'Eta Island'}= $sources; our %clients; # eg $clients{'ypp-sc-tools'}= [ qw(last-page) ]; diff --git a/yarrg/Makefile b/yarrg/Makefile index a9c833b..44441bc 100644 --- a/yarrg/Makefile +++ b/yarrg/Makefile @@ -1,4 +1,3 @@ - # This is part of ypp-sc-tools, a set of third-party tools for assisting # players of Yohoho Puzzle Pirates. # @@ -9,6 +8,12 @@ # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # +# The parts of the code used for the website (including the web/ +# directory and the rs*.[ch] which make up the routesearch program) +# are released instead under the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -31,10 +36,14 @@ DEBUG=-g CFLAGS += $(WARNINGS) $(WERROR) $(OPTIMISE) $(DEBUG) -TARGETS= yarrg +TARGETS_CLIENT= yarrg +TARGETS_SERVER= routesearch +TARGETS= $(TARGETS_CLIENT) $(TARGETS_SERVER) -default: clean-other-directory $(TARGETS) -all: default routesearch +default: clean-other-directory client +client: $(TARGETS_CLIENT) +server: $(TARGETS_SERVER) +all: client server CONVERT_OBJS= convert.o ocr.o pages.o structure.o rgbimage.o resolve.o COMMON_OBJS= common.o diff --git a/yarrg/README b/yarrg/README index d5062ac..10555f4 100644 --- a/yarrg/README +++ b/yarrg/README @@ -178,7 +178,8 @@ Copyright (C) 2009 Steve Early This program is free software: you can redistribute it and/or modify it under the terms of - (a) for the website code, the GNU Affero General Public License and + (a) for the website code including the route searcher, + the GNU Affero General Public License and (b) for the rest of the code, GNU General Public License as published by the Free Software Foundation, either version 3 of each applicable the License, or (at your option) any later version. diff --git a/yarrg/TODO b/yarrg/TODO index 8e85c93..d9d1b69 100644 --- a/yarrg/TODO +++ b/yarrg/TODO @@ -1,3 +1,6 @@ +unticking trades doesn't work?! + + UPLOADER -------- diff --git a/yarrg/db-idempotent-populate b/yarrg/db-idempotent-populate index 1d106f2..c4bd4a7 100755 --- a/yarrg/db-idempotent-populate +++ b/yarrg/db-idempotent-populate @@ -5,7 +5,7 @@ # # usage: ./db-idempotent-populate # creates or updates OCEAN-Oceanname.db -# from master-master.txt +# from source-info.txt # This is part of ypp-sc-tools, a set of third-party tools for assisting # players of Yohoho Puzzle Pirates. diff --git a/yarrg/notes.linear-programming b/yarrg/notes.linear-programming deleted file mode 100644 index e3c684c..0000000 --- a/yarrg/notes.linear-programming +++ /dev/null @@ -1,7 +0,0 @@ -use glpk's standalone solver with cplex input, see - glpk refman.ps.gz p84 for example -don't use it own modelling language which is very complex - -Math::LP would be nice but depends on Math::LP::Solve which is not in - Debian. - diff --git a/yarrg/rscommon.h b/yarrg/rscommon.h index 45a5b31..237cab1 100644 --- a/yarrg/rscommon.h +++ b/yarrg/rscommon.h @@ -1,3 +1,30 @@ +/* + * Route searcher - common definitions + */ +/* + * This is part of the YARRG website, a tool for assisting + * players of Yohoho Puzzle Pirates. + * + * Copyright (C) 2009 Ian Jackson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + * are used without permission. This program is not endorsed or + * sponsored by Three Rings. + */ + #ifndef RSCOMMON_H #define RSCOMMON_H diff --git a/yarrg/rsmain.c b/yarrg/rsmain.c index 774f507..67d338b 100644 --- a/yarrg/rsmain.c +++ b/yarrg/rsmain.c @@ -1,4 +1,29 @@ -/**/ +/* + * Route searcher - command line parsing and result printing + */ +/* + * This is part of the YARRG website, a tool for assisting + * players of Yohoho Puzzle Pirates. + * + * Copyright (C) 2009 Ian Jackson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + * are used without permission. This program is not endorsed or + * sponsored by Three Rings. + */ #include "rscommon.h" diff --git a/yarrg/rssearch.c b/yarrg/rssearch.c index 1dd29e5..245070e 100644 --- a/yarrg/rssearch.c +++ b/yarrg/rssearch.c @@ -1,4 +1,29 @@ -/**/ +/* + * Route searcher - recursive iteration over all routes + */ +/* + * This is part of the YARRG website, a tool for assisting + * players of Yohoho Puzzle Pirates. + * + * Copyright (C) 2009 Ian Jackson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + * are used without permission. This program is not endorsed or + * sponsored by Three Rings. + */ #include "rscommon.h" diff --git a/yarrg/rssql.c b/yarrg/rssql.c index 23b3bd0..043e34e 100644 --- a/yarrg/rssql.c +++ b/yarrg/rssql.c @@ -1,3 +1,29 @@ +/* + * Route searcher - database helper functions + */ +/* + * This is part of the YARRG website, a tool for assisting + * players of Yohoho Puzzle Pirates. + * + * Copyright (C) 2009 Ian Jackson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + * are used without permission. This program is not endorsed or + * sponsored by Three Rings. + */ #include "rscommon.h" diff --git a/yarrg/rsvalue.c b/yarrg/rsvalue.c index d3ffeeb..b469378 100644 --- a/yarrg/rsvalue.c +++ b/yarrg/rsvalue.c @@ -1,4 +1,29 @@ -/**/ +/* + * Route searcher - route evaluation + */ +/* + * This is part of the YARRG website, a tool for assisting + * players of Yohoho Puzzle Pirates. + * + * Copyright (C) 2009 Ian Jackson + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + * Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + * are used without permission. This program is not endorsed or + * sponsored by Three Rings. + */ #include diff --git a/yarrg/web/devel b/yarrg/web/devel index fecd77d..fed459f 100755 --- a/yarrg/web/devel +++ b/yarrg/web/devel @@ -35,8 +35,10 @@ YARRG (Yet Another Revenue Research Gatherer) + + +

YARRG development, contribution and troubleshooting

@@ -141,4 +145,5 @@ Email Ian Jackson ijackson (at) chiark.greenend.org.uk. Or talk to any Fleet Officer or above of the crew Special Circumstances on the Midnight Ocean. +
<& footer, isdevel => 1 &> diff --git a/yarrg/web/docs b/yarrg/web/docs index 9feaa6b..02cbeeb 100755 --- a/yarrg/web/docs +++ b/yarrg/web/docs @@ -34,8 +34,10 @@ Website documentation - YARRG + + +

Looking up data in YARRG

@@ -202,4 +206,5 @@ them for 20 PoE each, and then buy 2000 beans at B for 10 PoE each and sail them to C to sell for 20 PoE each even if such a trade would in fact be possible. In practice this is unlikely to be a problem! +
<& footer &> diff --git a/yarrg/web/dumptable b/yarrg/web/dumptable index 739f14d..4e1fb3e 100644 --- a/yarrg/web/dumptable +++ b/yarrg/web/dumptable @@ -59,7 +59,7 @@ $cols => $sth->{NAME} $qa => undef % if (!$qa || $qa->{'debug'}) { - +
% foreach my $field (@$cols) {
<% $field |h %> diff --git a/yarrg/web/intro b/yarrg/web/intro index 1580b2c..8e993a0 100755 --- a/yarrg/web/intro +++ b/yarrg/web/intro @@ -35,8 +35,10 @@ YARRG (Yet Another Revenue Research Gatherer) + + +

Introduction to YARRG

YARRG (Yet Another Revenue Research Gatherer) is a third-party tool @@ -122,4 +125,5 @@ Email Ian Jackson ijackson (at) chiark.greenend.org.uk. Or talk to any Fleet Officer or above of the crew Special Circumstances on the Midnight Ocean. +
<& footer &> diff --git a/yarrg/web/lookup b/yarrg/web/lookup index 56b34fc..365ed58 100755 --- a/yarrg/web/lookup +++ b/yarrg/web/lookup @@ -128,12 +128,13 @@ $ours <% ucfirst $ahtml{Query} %> - YARRG <&| script &> function register_onload(f) { @@ -147,6 +148,7 @@ tr.datarow1 { background: #ffffff; } % if (!printable($m)) { +
% } @@ -272,15 +275,14 @@ $debug => 0 } &> -

- %#---------- debugging and epilogue ---------- % if ($debug) { -

+

 Debug log:
 
+
% } <&| script &> diff --git a/yarrg/web/query_age b/yarrg/web/query_age index 7cfe54e..fd2044d 100644 --- a/yarrg/web/query_age +++ b/yarrg/web/query_age @@ -52,6 +52,7 @@ my $sth= $dbh->prepare("SELECT archipelago, islandid, islandname, timestamp $sth->execute(); +
<& SELF:pageload &> <%method pageload> @@ -69,12 +70,11 @@ $sth->execute(); $now $fetchrow - +
% my $row; % my %da_ages; % my %ts_sortkeys; @@ -142,6 +142,7 @@ Time since this page loaded: <& "lookup:formhidden", ours => sub { 0; } &> + <%init> use POSIX; use CommodsWeb; diff --git a/yarrg/web/query_commod b/yarrg/web/query_commod index 3b2bf35..8d55f26 100644 --- a/yarrg/web/query_commod +++ b/yarrg/web/query_commod @@ -50,6 +50,7 @@ my ($commodname,$cmid); my $qa= \%ARGS; +

Commodity enquiry

% $prselector->('BuySell'); @@ -69,10 +70,13 @@ my $qa= \%ARGS; %#========== results ========== +
+
<%perl> $emsgokorprint->($emsg) or $cmid=undef; -return unless defined $cmid; +print("
"), return + unless defined $cmid; $someresults->(); #---------- actually compute the results and print them ---------- @@ -109,7 +113,7 @@ foreach my $bs (split /_/, $ARGS{BuySell}) { % my $rowix= 0; % while ($island= $islands->fetchrow_hashref) { % if (!$rowix) { -
Archipelago Island Age -
+
@@ -212,3 +216,4 @@ No offers. <%perl> } + diff --git a/yarrg/web/query_offers b/yarrg/web/query_offers index 76f45c0..779d804 100644 --- a/yarrg/web/query_offers +++ b/yarrg/web/query_offers @@ -54,6 +54,7 @@ my ($commodname,$cmid); my $qa= \%ARGS; +

Prices for commodity at location(s)

% $prselector->('BuySell'); @@ -79,12 +80,15 @@ my $qa= \%ARGS; <& "lookup:formhidden", ours => $ours &> +
+
%#========== results ========== <%perl> $emsgokorprint->($emsg) or $cmid=undef; -return unless defined $cmid and @islandids; +print("
"), return + unless defined $cmid and @islandids; foreach my $wf (@warningfs) { $wf->(); } @@ -166,7 +170,7 @@ foreach my $bs (split /_/, $qa->{BuySell}) { % while ($row= $sth->fetchrow_arrayref) { % if (!$rowix) { -
+
@@ -221,3 +225,5 @@ database. This will be a pain for you to program, slow to run, and pointlessly overload our server. Instead, see our information for developers to find out how to get testing data or a real-time feed.) + + diff --git a/yarrg/web/query_route b/yarrg/web/query_route index fb32bcd..a4e9a06 100644 --- a/yarrg/web/query_route +++ b/yarrg/web/query_route @@ -64,8 +64,6 @@ my $goupdate= sub { $be_post ? 'Update' : 'Go' }; -

Specify route

- % # Sadly we need to do this rather hacky thing to make it be a POST % # form if the user has already selected some thing(s) % if (!$qa->{Dropdowns}) { @@ -77,6 +75,10 @@ my $goupdate= sub { $be_post ? 'Update' : 'Go' }; % } (0..$qa->{Dropdowns}-1)); % } +
+ +

Specify route

+ % $prselector->('ShowStalls'); <& enter_route, qa => $qa, dbh => $dbh, emsg_r => \$emsg, @@ -100,6 +102,8 @@ my $goupdate= sub { $be_post ? 'Update' : 'Go' }; % }; <& "lookup:formhidden", ours => $ours &> +
+
<%perl> #========== results ========== @@ -122,4 +126,5 @@ foreach my $warningf (@warningfs) { routeparams => $routeparams &> % } +
diff --git a/yarrg/web/query_routesearch b/yarrg/web/query_routesearch index 89a8137..9c583b8 100644 --- a/yarrg/web/query_routesearch +++ b/yarrg/web/query_routesearch @@ -67,6 +67,7 @@ my $maxcountea=15; +

Find most profitable routes and trades

% if ($qa->{Dropdowns}) { @@ -102,6 +103,8 @@ This feature is not available from the "drop down menus" interface. % } +
+
<%perl> if (!$emsg && $maxdist > $maxmaxdist) { @@ -109,10 +112,12 @@ if (!$emsg && $maxdist > $maxmaxdist) { " supported, sorry."; } -$emsgokorprint->($emsg) or return; -@islandids or return; -$allargs->{'submit'} or return; -defined $routeparams->{MaxMass} or defined $routeparams->{MaxVolume} or return; +print("
"), return + unless $emsgokorprint->($emsg) + and @islandids + and $allargs->{'submit'} + and (defined $routeparams->{MaxMass} or + defined $routeparams->{MaxVolume}); #---------- prepare island names ---------- @@ -273,7 +278,7 @@ $someresults->(); % } else {

Best routes for profit per league

% } -
+
@@ -293,7 +298,6 @@ $someresults->();
Start Via Finish -
% my $datarow=0; % my %sortkeys; @@ -345,7 +349,4 @@ Per league values count each island visited as one to be sailed. All profit figures are somewhat approximate; get a complete trading plan for a route for accurate information. -<%perl> - - - + diff --git a/yarrg/web/routetrade b/yarrg/web/routetrade index 09e908b..ce319fa 100644 --- a/yarrg/web/routetrade +++ b/yarrg/web/routetrade @@ -625,7 +625,7 @@ Generated by YARRG at <% %

Voyage trading plan

- > +
> % my $tbody= sub { % if (!printable($m)) { return ''; } %# return "' : '';

Relevant trades

-

"; @@ -857,7 +857,7 @@ Islands shown in reverse order of visits.
% my $cdspan= $qa->{ShowStalls} ? ' colspan=2' : ''; % my $cdstall= $qa->{ShowStalls} ? '
Stall
+
<% $qa->{ShowStalls} ? '' : '' %> @@ -965,7 +965,7 @@ Islands shown in reverse order of visits.
throw => 'trades_sort', tbrow => 'trades_total' &> ts_sortkeys= <% to_json_protecttags(\%ts_sortkeys) %>; - +

% } # !printable diff --git a/yarrg/web/style.css b/yarrg/web/style.css new file mode 100755 index 0000000..a397e5c --- /dev/null +++ b/yarrg/web/style.css @@ -0,0 +1,48 @@ +<%doc> + + This is part of the YARRG website. YARRG is a tool and website + for assisting players of Yohoho Puzzle Pirates. + + Copyright (C) 2009 Ian Jackson + Copyright (C) 2009 Clare Boothby + + YARRG's client code etc. is covered by the ordinary GNU GPL (v3 or later). + The YARRG website is covered by the GNU Affero GPL v3 or later, which + basically means that every installation of the website will let you + download the source. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + + Yohoho and Puzzle Pirates are probably trademarks of Three Rings and + are used without permission. This program is not endorsed or + sponsored by Three Rings. + + + This Mason component generates the top-level stylesheet which applies + to everything including lookups and documentation. + + +<%flags> +inherit => undef + +<%init> +$r->content_type('text/css') + if $m->callers(-1) == $m->callers(0); + + + body { margin: 0; } + div.navoptbar { padding: 1em; background: #e0e0ff; } + address { background: #d7d8b3; padding: 1em; } + div.docs { padding: 1em; } + hr { display: none; }