garten

diff clock.c @ 18:5937504619f2

rename game.h -> modules.h; added some error handling; and more
author meillo@marmaro.de
date Wed, 23 Jul 2008 17:40:55 +0200
parents 5e6c9260913a
children
line diff
     1.1 --- a/clock.c	Wed Jul 23 17:14:38 2008 +0200
     1.2 +++ b/clock.c	Wed Jul 23 17:40:55 2008 +0200
     1.3 @@ -1,10 +1,9 @@
     1.4  #include <stdio.h>
     1.5  #include <stdlib.h>
     1.6  #include "db.h"
     1.7 -#include "game.h"
     1.8  
     1.9  
    1.10 -void inc_time() {
    1.11 +int inc_time() {
    1.12  	/* get current time */
    1.13  	sprintf(query, "select time from game;");
    1.14  	stmt = db_query(query);
    1.15 @@ -12,22 +11,29 @@
    1.16  		gametime = sqlite3_column_int(stmt, 0);
    1.17  	} else {
    1.18  		db_error("get current time");
    1.19 +		return 0;
    1.20  	}
    1.21  	sqlite3_finalize(stmt);
    1.22  
    1.23  	/* increment time */
    1.24  	sprintf(query,
    1.25 -			"update game"
    1.26 +			"update game "
    1.27  			"set time = '%d';"
    1.28  			, ++gametime
    1.29  			);
    1.30  	if (!db_update(query)) {
    1.31  		db_error("time update");
    1.32 +		return 0;
    1.33  	}
    1.34 +	return 1;
    1.35  }
    1.36  
    1.37  
    1.38 -void worldclock(void) {
    1.39 -	inc_time();
    1.40 +int worldclock(void) {
    1.41 +	int ret;
    1.42 +
    1.43 +	ret = inc_time();
    1.44  	printf("gametime: %d\n", gametime);
    1.45 +
    1.46 +	return ret;
    1.47  }