chiark / gitweb /
WIP route value calculation - compiles, although doesn't run the LP
[ypp-sc-tools.db-live.git] / yarrg / rscommon.h
index 6fd394ea008d7eb0829189426633106b6572a5b0..b1003bf2325c47b6bcf9ca68c5d3a94e4e99eede 100644 (file)
@@ -4,13 +4,42 @@
 #include <sqlite3.h>
 
 #define DEBUG_FLAG_LIST                                \
-   DF(sql)
+   DF(sql)                                     \
+   DF(value)
 
 
+#define SQL_MUST( call ) ({                                     \
+    /* `call' is an expression returning result, using  const char *sqe; \
+     * chk1 and chk2 are blocks using sqe and  int sqr; */              \
+    const char *sql_must_call_string= #call;                            \
+    int sqr;                                                            \
+    if (DEBUGP(sql)) fprintf(stderr,"SQL %s", sql_must_call_string);    \
+    sqr= (call);                                                        \
+    if (DEBUGP(sql)) fprintf(stderr," = %d\n", sqr);                    \
+    if (sqr) fatal("SQL call failed code %d: %s: %s",                   \
+                  sqr, sqlite3_errmsg(db), sql_must_call_string);       \
+  })
+
+#define SQL_STEP(ssh) (sql_step_wrap((ssh), #ssh, __FILE__, __LINE__))
+int sql_step_wrap(sqlite3_stmt *ssh, const char *ssh_string,
+                 const char *file, int line);
+
+int sql_single_int(const char *stmt);
+
+#define MAX_ROUTELEN 20
+
 #include "common.h"
 
-extern struct sqlite *db;
+extern sqlite3 *db;
 
+void setup(void);
 void value_route(int nislands, const int *islands);
+void setup_value(void);
+void setup_commods(void);
+
+extern double max_mass, max_volu, max_capi;
+extern double distance_loss_factor_per_league;
+
+#define LOSS_FACTOR_PER_DELAY_SLOT (1-1e8)
 
 #endif /*RSCOMMON_H*/