Mercurial > garten
annotate environment.c @ 17:5e6c9260913a
lots of cleanups and small fixes
author | meillo@marmaro.de |
---|---|
date | Wed, 23 Jul 2008 17:14:38 +0200 |
parents | 8db6497d6065 |
children | 5937504619f2 |
rev | line source |
---|---|
6 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include "db.h" | |
4 #include "game.h" | |
5 | |
6 | |
7 void set_environment() { | |
8 int groundwater, slugs, earthworms; | |
9 | |
10 /* get weather and last environments to calculate the next one * | |
11
176ee28e7464
switched from mysql to sqlite; (+ some cleanups)
meillo@marmaro.de
parents:
6
diff
changeset
|
11 sprintf(query, "select time from simulation"); |
6 | 12 db_query(query); |
13 result = mysql_store_result(conn); | |
14 if (mysql_num_rows(result)) { | |
15 row = mysql_fetch_row(result); | |
16 time = atoi(row[0]); | |
17 } | |
18 mysql_free_result(result); | |
19 */ | |
20 | |
21 groundwater = 20; | |
22 slugs = 5; | |
23 earthworms = 10; | |
24 | |
25 | |
26 /* set weather */ | |
17 | 27 sprintf(query, |
28 "insert into environment " | |
29 "(tick, groundwater, slugs, earthworms) " | |
30 "values ('%d', '%d', '%d', '%d') " | |
31 , gametime | |
32 , groundwater | |
33 , slugs | |
34 , earthworms | |
35 ); | |
12 | 36 if (!db_update(query)) { |
17 | 37 db_error("environment insertion"); |
6 | 38 } |
39 | |
40 } | |
41 | |
42 | |
12 | 43 void environment(void) { |
6 | 44 set_environment(); |
45 } |