Mercurial > garten
view 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 | 8db6497d6065 |
children | 5e6c9260913a |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include "db.h" #include "game.h" void set_environment() { int groundwater, slugs, earthworms; /* get weather and last environments to calculate the next one * sprintf(query, "select time from simulation"); db_query(query); result = mysql_store_result(conn); if (mysql_num_rows(result)) { row = mysql_fetch_row(result); time = atoi(row[0]); } mysql_free_result(result); */ groundwater = 20; slugs = 5; earthworms = 10; /* set weather */ sprintf(query, " insert into environment \ (tick, groundwater, slugs, earthworms) \ values ('%d', '%d', '%d', '%d') ", gametime, groundwater, slugs, earthworms); if (!db_update(query)) { printf("error: environment insertion failed: %s\n", sqlite3_errmsg(db)); } } void environment(void) { set_environment(); }