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