annotate environment.c @ 13:f1d43b52ed36
and here now is the main program
author |
meillo@marmaro.de |
date |
Wed, 23 Jul 2008 15:20:35 +0200 |
parents |
176ee28e7464 |
children |
5e6c9260913a |
rev |
line source |
meillo@6
|
1 #include <stdio.h>
|
meillo@6
|
2 #include <stdlib.h>
|
meillo@6
|
3 #include "db.h"
|
meillo@6
|
4 #include "game.h"
|
meillo@6
|
5
|
meillo@6
|
6
|
meillo@6
|
7 void set_environment() {
|
meillo@6
|
8 int groundwater, slugs, earthworms;
|
meillo@6
|
9
|
meillo@6
|
10 /* get weather and last environments to calculate the next one *
|
meillo@11
|
11 sprintf(query, "select time from simulation");
|
meillo@6
|
12 db_query(query);
|
meillo@6
|
13 result = mysql_store_result(conn);
|
meillo@6
|
14 if (mysql_num_rows(result)) {
|
meillo@6
|
15 row = mysql_fetch_row(result);
|
meillo@6
|
16 time = atoi(row[0]);
|
meillo@6
|
17 }
|
meillo@6
|
18 mysql_free_result(result);
|
meillo@6
|
19 */
|
meillo@6
|
20
|
meillo@6
|
21 groundwater = 20;
|
meillo@6
|
22 slugs = 5;
|
meillo@6
|
23 earthworms = 10;
|
meillo@6
|
24
|
meillo@6
|
25
|
meillo@6
|
26 /* set weather */
|
meillo@6
|
27 sprintf(query, " insert into environment \
|
meillo@11
|
28 (tick, groundwater, slugs, earthworms) \
|
meillo@11
|
29 values ('%d', '%d', '%d', '%d') ",
|
meillo@11
|
30 gametime, groundwater, slugs, earthworms);
|
meillo@12
|
31 if (!db_update(query)) {
|
meillo@11
|
32 printf("error: environment insertion failed: %s\n", sqlite3_errmsg(db));
|
meillo@6
|
33 }
|
meillo@6
|
34
|
meillo@6
|
35 }
|
meillo@6
|
36
|
meillo@6
|
37
|
meillo@12
|
38 void environment(void) {
|
meillo@6
|
39 set_environment();
|
meillo@6
|
40 }
|