Mercurial > garten
view environment.c @ 7:b1e309dc0b98
added growth module (quite static and limited implementation)
author | meillo@marmaro.de |
---|---|
date | Thu, 15 May 2008 21:42:01 +0200 |
parents | e3679f888813 |
children | 176ee28e7464 |
line wrap: on
line source
#include <stdio.h> #include <stdlib.h> #include <mysql.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 where name = '%s' ", gamename); 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, game_id, groundwater, slugs, earthworms) \ values ('%d', '%d', '%d', '%d', '%d') ", gametime, gameid, groundwater, slugs, earthworms); db_query(query); if (mysql_affected_rows(conn) > 0) { printf("environment successful inserted\n"); } else { printf("E: environment insertion failed\n"); } } int main(int argc, char* argv[]) { printf(" --> environment\n"); /* init */ if (argc != 2) { printf("usage: %s <game>\n", argv[0]); exit(1); } gamename = argv[1]; db_connect(); check_game(); set_environment(); db_close(); printf(" --< environment\n"); return 0; }