From 2d200537436a446c0fd7d62921f5a5fec231a696 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 8 Oct 2009 00:20:57 +0100 Subject: [PATCH] WIP routesearch; construct archipelago lookup table --- yarrg/rscommon.h | 4 ++++ yarrg/rssearch.c | 34 ++++++++++++++++++++++++++++++++++ yarrg/x.gdb | 5 +++-- 3 files changed, 41 insertions(+), 2 deletions(-) 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