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
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@17 27 sprintf(query,
meillo@17 28 "insert into environment "
meillo@17 29 "(tick, groundwater, slugs, earthworms) "
meillo@17 30 "values ('%d', '%d', '%d', '%d') "
meillo@17 31 , gametime
meillo@17 32 , groundwater
meillo@17 33 , slugs
meillo@17 34 , earthworms
meillo@17 35 );
meillo@12 36 if (!db_update(query)) {
meillo@17 37 db_error("environment insertion");
meillo@6 38 }
meillo@6 39
meillo@6 40 }
meillo@6 41
meillo@6 42
meillo@12 43 void environment(void) {
meillo@6 44 set_environment();
meillo@6 45 }