garten
view 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 |
line source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "db.h"
4 #include "game.h"
7 void set_environment() {
8 int groundwater, slugs, earthworms;
10 /* get weather and last environments to calculate the next one *
11 sprintf(query, "select time from simulation");
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 */
21 groundwater = 20;
22 slugs = 5;
23 earthworms = 10;
26 /* set weather */
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 );
36 if (!db_update(query)) {
37 db_error("environment insertion");
38 }
40 }
43 void environment(void) {
44 set_environment();
45 }