#include "msgbase.h"
#include "serv_chat.h"
#include "citserver.h"
+#include "control.h"
/*
* Generic routine for determining user access to rooms
-/*
- * Create a database key for storage of message lists
- */
-void msglist_key(char *dbkey, struct quickroom *whichroom) {
- int a;
-
- sprintf(dbkey, "%s%ld", whichroom->QRname, whichroom->QRgen);
- for (a=0; a<strlen(dbkey); ++a) dbkey[a]=tolower(dbkey[a]);
- }
-
/*
* get_msglist() - retrieve room message pointers
*/
void get_msglist(struct quickroom *whichroom) {
struct cdbdata *cdbfr;
- char dbkey[256];
- msglist_key(dbkey, whichroom);
-
if (CC->msglist != NULL) {
free(CC->msglist);
}
CC->msglist = NULL;
CC->num_msgs = 0;
- cdbfr = cdb_fetch(CDB_MSGLISTS, dbkey, strlen(dbkey));
+ cdbfr = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
if (cdbfr == NULL) {
return;
}
* put_msglist() - retrieve room message pointers
*/
void put_msglist(struct quickroom *whichroom) {
- char dbkey[256];
- msglist_key(dbkey, whichroom);
- cdb_store(CDB_MSGLISTS, dbkey, strlen(dbkey),
+ cdb_store(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long),
CC->msglist, CC->num_msgs * sizeof(long));
}
* like "gdbm: illegal data" (no big deal, but could use fixing).
*/
void delete_msglist(struct quickroom *whichroom) {
- char dbkey[256];
- msglist_key(dbkey, whichroom);
- cdb_delete(CDB_MSGLISTS, dbkey, strlen(dbkey));
+ cdb_delete(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
}
* may not be the current room (as is the case with cmd_move() for example).
*/
void AddMessageToRoom(struct quickroom *whichroom, long newmsgid) {
- char dbkey[256];
struct cdbdata *cdbfr;
int num_msgs;
long *msglist;
- msglist_key(dbkey, whichroom);
- cdbfr = cdb_fetch(CDB_MSGLISTS, dbkey, strlen(dbkey));
+ cdbfr = cdb_fetch(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long));
if (cdbfr == NULL) {
msglist = NULL;
num_msgs = 0;
msglist[num_msgs - 1] = newmsgid;
/* Write it back to disk. */
- cdb_store(CDB_MSGLISTS, dbkey, strlen(dbkey),
+ cdb_store(CDB_MSGLISTS, &whichroom->QRnumber, sizeof(long),
msglist, num_msgs * sizeof(long));
/* And finally, free up the memory we used. */
strncpy(qrbuf.QRname,new_room_name,ROOMNAMELEN);
strncpy(qrbuf.QRpasswd,new_room_pass,9);
qrbuf.QRflags = QR_INUSE;
+ qrbuf.QRnumber = get_new_room_number();
if (new_room_type > 0) qrbuf.QRflags=(qrbuf.QRflags|QR_PRIVATE);
if (new_room_type == 1) qrbuf.QRflags=(qrbuf.QRflags|QR_GUESSNAME);
if (new_room_type == 2) qrbuf.QRflags=(qrbuf.QRflags|QR_PASSWORDED);
CitControl.MMhighest = atol(value);
if (!strcasecmp(key, "mmnextuser"))
CitControl.MMnextuser = atol(value);
+ if (!strcasecmp(key, "mmnextroom"))
+ CitControl.MMnextroom = atol(value);
}
put_control();
fprintf(exfp, "globals%c", 0);
fprintf(exfp, "mmhighest%c%ld%c", 0, CitControl.MMhighest, 0);
fprintf(exfp, "mmnextuser%c%ld%c", 0, CitControl.MMnextuser, 0);
+ fprintf(exfp, "mmnextroom%c%ld%c", 0, CitControl.MMnextroom, 0);
fprintf(exfp, "mmflags%c%d%c", 0, CitControl.MMflags, 0);
fprintf(exfp, "endsection%c", 0);