From: Ian Jackson Date: Wed, 7 Oct 2009 23:20:57 +0000 (+0100) Subject: WIP routesearch; construct archipelago lookup table X-Git-Tag: 5.0^2~65 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=commitdiff_plain;h=2d200537436a446c0fd7d62921f5a5fec231a696 WIP routesearch; construct archipelago lookup table --- diff --git a/yarrg/rscommon.h b/yarrg/rscommon.h index 873ff30..f0215b2 100644 --- a/yarrg/rscommon.h +++ b/yarrg/rscommon.h @@ -118,6 +118,10 @@ extern int max_dist; extern int islandtablesz; +extern int narches; +extern char **archnames; +extern int *islandid2arch; + #define ONDEMAND(pointer_lvalue, calloc_size_count) \ ((pointer_lvalue) ? : \ diff --git a/yarrg/rssearch.c b/yarrg/rssearch.c index 0a17adf..fa43d89 100644 --- a/yarrg/rssearch.c +++ b/yarrg/rssearch.c @@ -140,9 +140,43 @@ void search(int start_isle, PotentialResult ****strat_base_io) { recurse(start_isle,0,0,1e6); } + +int narches; +char **archnames; +int *islandid2arch; + void setup_search(void) { neighbours= mcalloc(sizeof(*neighbours) * islandtablesz); SQL_PREPARE(ss_neigh, "SELECT biid, dist FROM routes WHERE aiid=?"); + + int max_narches= + sql_single_int(" SELECT count(*) FROM (\n" + " SELECT DISTINCT archipelago\n" + " FROM islands\n" + " )"); + archnames= mcalloc(sizeof(*archnames) * max_narches); + islandid2arch= mmalloc(sizeof(*islandid2arch) * islandtablesz); + int i; + for (i=0; i