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 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)) {
		db_error("environment insertion");
	}

}


void environment(void) {
	set_environment();
}