chiark / gitweb /
WIP route value calculation - compiles, although doesn't run the LP
[ypp-sc-tools.main.git] / yarrg / rscommon.h
1 #ifndef RSCOMMON_H
2 #define RSCOMMON_H
3
4 #include <sqlite3.h>
5
6 #define DEBUG_FLAG_LIST                         \
7    DF(sql)                                      \
8    DF(value)
9
10
11 #define SQL_MUST( call ) ({                                      \
12     /* `call' is an expression returning result, using  const char *sqe; \
13      * chk1 and chk2 are blocks using sqe and  int sqr; */               \
14     const char *sql_must_call_string= #call;                             \
15     int sqr;                                                             \
16     if (DEBUGP(sql)) fprintf(stderr,"SQL %s", sql_must_call_string);     \
17     sqr= (call);                                                         \
18     if (DEBUGP(sql)) fprintf(stderr," = %d\n", sqr);                     \
19     if (sqr) fatal("SQL call failed code %d: %s: %s",                    \
20                    sqr, sqlite3_errmsg(db), sql_must_call_string);       \
21   })
22
23 #define SQL_STEP(ssh) (sql_step_wrap((ssh), #ssh, __FILE__, __LINE__))
24 int sql_step_wrap(sqlite3_stmt *ssh, const char *ssh_string,
25                   const char *file, int line);
26
27 int sql_single_int(const char *stmt);
28
29 #define MAX_ROUTELEN 20
30
31 #include "common.h"
32
33 extern sqlite3 *db;
34
35 void setup(void);
36 void value_route(int nislands, const int *islands);
37 void setup_value(void);
38 void setup_commods(void);
39
40 extern double max_mass, max_volu, max_capi;
41 extern double distance_loss_factor_per_league;
42
43 #define LOSS_FACTOR_PER_DELAY_SLOT (1-1e8)
44
45 #endif /*RSCOMMON_H*/