garten

view 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 source
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include "db.h"
4 #include "game.h"
7 void inc_time() {
8 /* get current time */
9 sprintf(query, "select time from game;");
10 stmt = db_query(query);
11 if (sqlite3_step(stmt) == SQLITE_ROW) {
12 gametime = sqlite3_column_int(stmt, 0);
13 } else {
14 db_error("get current time");
15 }
16 sqlite3_finalize(stmt);
18 /* increment time */
19 sprintf(query,
20 "update game"
21 "set time = '%d';"
22 , ++gametime
23 );
24 if (!db_update(query)) {
25 db_error("time update");
26 }
27 }
30 void worldclock(void) {
31 inc_time();
32 printf("gametime: %d\n", gametime);
33 }