Skip to content
Commits on Source (2)
......@@ -5,13 +5,13 @@
struct room
{
int32_t num; /* room number */
char *name; /* room name */
char *desc; /* description */
char *prompt; /* alternate prompt */
int32_t hidden; /* cant find room using 'room' command */
int32_t sproof; /* soundproof? */
int32_t locked; /* locked? */
int32_t num; /* room number */
char *name; /* room name */
char *desc; /* description */
char *prompt; /* alternate prompt */
int32_t hidden; /* cant find room using 'room' command */
int32_t sproof; /* soundproof? */
int32_t locked; /* locked? */
};
void RoomInit(struct room *room);
......
......@@ -189,32 +189,30 @@ void db_free(struct db_result *result)
char * db_room_get(int room, const char *opt)
{
struct db_result *old;
struct db_result *qres;
char *value;
char *out = NULL;
char *query = sqlite3_mprintf("SELECT * from "USERDB_ROOMS" WHERE room=%d AND opt=%Q", room, opt);
old = db_query(USERSQL, query, 1);
qres = db_query(USERSQL, query, 1);
sqlite3_free(query);
if (old == NULL) return NULL;
if (db_numrows(old) < 1) goto out_dbfree;
if (qres == NULL) return NULL;
if (db_numrows(qres) < 1) goto out_dbfree;
if ((value = db_item(old, 0, "arg"))==NULL)
if ((value = db_item(qres, 0, "arg"))==NULL)
goto out_dbfree;
out = strdup(value);
out_dbfree:
db_free(old);
db_free(qres);
return out;
}
void db_room_set(int room, const char *opt, const char *arg)
{
struct db_result *old;
struct db_result *qres;
char *query = sqlite3_mprintf("SELECT * from "USERDB_ROOMS" WHERE room=%d AND opt=%Q", room, opt);
old = db_query(USERSQL, query, 1);
qres = db_query(USERSQL, query, 1);
sqlite3_free(query);
/* set a new value */
......@@ -224,7 +222,7 @@ void db_room_set(int room, const char *opt, const char *arg)
db_free(db_query(USERSQL, q, 1));
sqlite3_free(q);
}else
if (old != NULL && old->rows > 0) {
if (qres != NULL && qres->rows > 0) {
char *q= sqlite3_mprintf("UPDATE "USERDB_ROOMS" SET arg=%Q WHERE room=%d AND opt=%Q", arg, room, opt);
db_free(db_query(USERSQL, q, 1));
sqlite3_free(q);
......@@ -244,5 +242,5 @@ void db_room_set(int room, const char *opt, const char *arg)
db_free(res);
sqlite3_free(q);
}
db_free(old);
db_free(qres);
}