Mercurial > 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 wrap: on
line diff
--- a/clock.c Wed Jul 23 16:49:10 2008 +0200 +++ b/clock.c Wed Jul 23 17:14:38 2008 +0200 @@ -1,29 +1,29 @@ #include <stdio.h> #include <stdlib.h> - #include "db.h" #include "game.h" - - void inc_time() { /* get current time */ sprintf(query, "select time from game;"); - db_query(query); + stmt = db_query(query); if (sqlite3_step(stmt) == SQLITE_ROW) { gametime = sqlite3_column_int(stmt, 0); } else { - fprintf(stderr, "error: %s\n", sqlite3_errmsg(db)); + db_error("get current time"); } sqlite3_finalize(stmt); /* increment time */ - sprintf(query, " update game set time = '%d';", ++gametime); + sprintf(query, + "update game" + "set time = '%d';" + , ++gametime + ); if (!db_update(query)) { - printf("error: time update failed: %s\n", sqlite3_errmsg(db)); + db_error("time update"); } - sqlite3_finalize(stmt); }