#include "control.h"
#include "tools.h"
+struct floor *floorcache[MAXFLOORS];
+
/*
* Generic routine for determining user access to rooms
*/
}
+/*
+ * cgetfloor() - Get floor record from *cache* (loads from disk if needed)
+ *
+ * This is strictly a performance hack.
+ */
+struct floor *cgetfloor(int floor_num) {
+
+ if (floorcache[floor_num] == NULL) {
+ floorcache[floor_num] = mallok(sizeof(struct floor));
+ getfloor(floorcache[floor_num], floor_num);
+ }
+
+ return(floorcache[floor_num]);
+}
+
+
+
/*
* putfloor() - store floor data on disk
*/
{
cdb_store(CDB_FLOORTAB, &floor_num, sizeof(int),
flbuf, sizeof(struct floor));
+
+ /* If we've cached this, clear it out, 'cuz it's WRONG now! */
+ if (floorcache[floor_num] != NULL) {
+ phree(floorcache[floor_num]);
+ }
}
void cmd_setr(char *args)
{
char buf[SIZ];
+ struct floor *fl;
struct floor flbuf;
char old_name[ROOMNAMELEN];
int old_floor;
if (num_parms(args) >= 6) {
- getfloor(&flbuf, extract_int(args, 5));
- if ((flbuf.f_flags & F_INUSE) == 0) {
+ fl = cgetfloor(extract_int(args, 5));
+ if ((fl->f_flags & F_INUSE) == 0) {
cprintf("%d Invalid floor number.\n",
ERROR + INVALID_FLOOR_OPERATION);
return;
char aaa[SIZ];
unsigned newflags;
struct quickroom qrbuf;
- struct floor flbuf;
+ struct floor *fl;
cre8_ok = extract_int(args, 0);
extract(new_room_name, args, 1);
}
if (num_parms(args) >= 5) {
- getfloor(&flbuf, extract_int(args, 4));
- if ((flbuf.f_flags & F_INUSE) == 0) {
+ fl = cgetfloor(extract_int(args, 4));
+ if ((fl->f_flags & F_INUSE) == 0) {
cprintf("%d Invalid floor number.\n",
ERROR + INVALID_FLOOR_OPERATION);
return;