Mercurial > 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 wrap: on
line diff
--- a/clock.c Wed Jul 23 17:14:38 2008 +0200 +++ b/clock.c Wed Jul 23 17:40:55 2008 +0200 @@ -1,10 +1,9 @@ #include <stdio.h> #include <stdlib.h> #include "db.h" -#include "game.h" -void inc_time() { +int inc_time() { /* get current time */ sprintf(query, "select time from game;"); stmt = db_query(query); @@ -12,22 +11,29 @@ gametime = sqlite3_column_int(stmt, 0); } else { db_error("get current time"); + return 0; } sqlite3_finalize(stmt); /* increment time */ sprintf(query, - "update game" + "update game " "set time = '%d';" , ++gametime ); if (!db_update(query)) { db_error("time update"); + return 0; } + return 1; } -void worldclock(void) { - inc_time(); +int worldclock(void) { + int ret; + + ret = inc_time(); printf("gametime: %d\n", gametime); + + return ret; }