garten

diff clock.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 diff
     1.1 --- a/clock.c	Wed Jul 23 16:49:10 2008 +0200
     1.2 +++ b/clock.c	Wed Jul 23 17:14:38 2008 +0200
     1.3 @@ -1,29 +1,29 @@
     1.4  #include <stdio.h>
     1.5  #include <stdlib.h>
     1.6 -
     1.7  #include "db.h"
     1.8  #include "game.h"
     1.9  
    1.10  
    1.11 -
    1.12 -
    1.13  void inc_time() {
    1.14  	/* get current time */
    1.15  	sprintf(query, "select time from game;");
    1.16 -	db_query(query);
    1.17 +	stmt = db_query(query);
    1.18  	if (sqlite3_step(stmt) == SQLITE_ROW) {
    1.19  		gametime = sqlite3_column_int(stmt, 0);
    1.20  	} else {
    1.21 -		fprintf(stderr, "error: %s\n", sqlite3_errmsg(db));
    1.22 +		db_error("get current time");
    1.23  	}
    1.24  	sqlite3_finalize(stmt);
    1.25  
    1.26  	/* increment time */
    1.27 -	sprintf(query, " update game set time = '%d';", ++gametime);
    1.28 +	sprintf(query,
    1.29 +			"update game"
    1.30 +			"set time = '%d';"
    1.31 +			, ++gametime
    1.32 +			);
    1.33  	if (!db_update(query)) {
    1.34 -		printf("error: time update failed: %s\n", sqlite3_errmsg(db));
    1.35 +		db_error("time update");
    1.36  	}
    1.37 -	sqlite3_finalize(stmt);
    1.38  }
    1.39  
    1.40