garten

changeset 1:3ff1fbe4693d

moved gamecheck and some vars out
author meillo@marmaro.de
date Wed, 14 May 2008 21:07:33 +0200
parents 831599184108
children 8369454d4ec9
files game.h
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/game.h	Wed May 14 21:07:33 2008 +0200
     1.3 @@ -0,0 +1,25 @@
     1.4 +char query[1024];
     1.5 +char* gamename;
     1.6 +int gameid;
     1.7 +int gametime;
     1.8 +
     1.9 +
    1.10 +void check_game() {
    1.11 +	int rows;
    1.12 +	MYSQL_ROW row;
    1.13 +
    1.14 +	sprintf(query, "select id, time from game where name = '%s' ", gamename);
    1.15 +	db_query(query);
    1.16 +	result = mysql_store_result(conn);
    1.17 +	rows = mysql_num_rows(result);
    1.18 +	row = mysql_fetch_row(result);
    1.19 +	gameid = atoi(row[0]);
    1.20 +	gametime = atoi(row[1]);
    1.21 +	mysql_free_result(result);
    1.22 +	
    1.23 +	if (rows != 1) {
    1.24 +		printf("game '%s' does not exist\n", gamename);
    1.25 +		exit(1);
    1.26 +	}
    1.27 +}
    1.28 +