/* Show users who owns what room by Michael Doig*/ void room_owner(UR_OBJECT user) { RM_OBJECT rm; int rmcnt, pcnt; char usrname[USER_NAME_LEN+1]; char *line="--==[*]-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-[*]==--\n"; if (!amsys->personal_rooms) { write_user(user,"Personal room functions are currently disabled.\n"); return; } strtolower(word[1]); rmcnt=0; write_user(user,"~OL~FG _ _ \n"); write_user(user,"~OL~FG|_) _ _ ._ _ / \\ ._ _ .__\n"); write_user(user,"~OL~FG| \\(_)(_)| | | \\_/\\/\\/| |(/_|_>\n"); write_user(user, line); write_user(user," ~OL~FGPersonal Room Owner Personal Room Name \n"); write_user(user, line); for (rm=room_first; rm!=NULL; rm=rm->next) { if (is_personal_room(rm)) { pcnt=room_visitor_count(rm); midcpy(rm->name,usrname,1,strlen(rm->name)-2); usrname[0]=toupper(usrname[0]); vwrite_user(user," ~OL%-*s~RS ~OL%-*s~RS ~OL~FB\n", USER_NAME_LEN,usrname,ROOM_NAME_LEN,rm->real_name); rmcnt++; } } if (!rmcnt) write_user(user," ~OL~FB ~RS~FRNo personal rooms are currently in memory.\n"); write_user(user, line); write_user(user," ~RSTo visit a room, type ~FR.visit username ~FTeg. ~FR.visit andy\n"); write_user(user, line); return; }
/* * Set room access back to public if not enough users in room */ void reset_access(RM_OBJECT rm) { UR_OBJECT u; if (!rm || is_personal_room(rm) || is_fixed_room(rm) || !is_private_room(rm)) { return; } if (room_visitor_count(rm) < amsys->min_private_users) { /* Reset any invites into the room & clear review buffer */ for (u = user_first; u; u = u->next) { if (u->invite_room == rm) { u->invite_room = NULL; } } clear_revbuff(rm); rm->access &= ~PRIVATE; write_room(rm, "Room access returned to ~FGPUBLIC.\n"); } }
/* * this function allows admin to control personal rooms */ void personal_room_admin(UR_OBJECT user) { char rmname[ROOM_NAME_LEN + 1], filename[80]; RM_OBJECT rm; UR_OBJECT u; int trsize, rmcount, locked, unlocked; if (word_count < 2) { write_user(user, "Usage: rmadmin -l / -m / -u <name> / -d <name>\n"); return; } if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } strtolower(word[1]); /* just display the amount of memory used by personal rooms */ if (!strcmp(word[1], "-m")) { write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, "| ~FC~OLPersonal Room Memory Usage~RS |\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); rmcount = locked = unlocked = 0; for (rm = room_first; rm; rm = rm->next) { if (!is_personal_room(rm)) { continue; } ++rmcount; if (is_private_room(rm)) { ++locked; } else { ++unlocked; } } trsize = rmcount * (sizeof *rm); vwrite_user(user, "| %-15.15s: ~OL%2d~RS locked, ~OL%2d~RS unlocked |\n", "status", locked, unlocked); vwrite_user(user, "| %-15.15s: ~OL%5d~RS * ~OL%8d~RS bytes = ~OL%8d~RS total bytes (%02.3f Mb) |\n", "rooms", rmcount, (int) (sizeof *rm), trsize, trsize / 1048576.0); write_user(user, "+----------------------------------------------------------------------------+\n"); return; } /* list all the personal rooms in memory together with status */ if (!strcmp(word[1], "-l")) { write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, "| ~OL~FCPersonal Room Listings~RS |\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); rmcount = 0; for (rm = room_first; rm; rm = rm->next) { if (!is_personal_room(rm)) { continue; } ++rmcount; vwrite_user(user, "| Owner : ~OL%-*.*s~RS Status : ~OL%s~RS Msg Count : ~OL%2d~RS People : ~OL%2d~RS |\n", USER_NAME_LEN, USER_NAME_LEN, rm->owner, is_private_room(rm) ? "~FRlocked " : "~FGunlocked", rm->mesg_cnt, room_visitor_count(rm)); } if (!rmcount) { write_user(user, "| ~FRNo personal rooms are currently in memory~RS |\n"); } write_user(user, "+----------------------------------------------------------------------------+\n"); if (rmcount) { vwrite_user(user, "| Total personal rooms : ~OL~FM%2d~RS |\n", rmcount); write_user(user, "+----------------------------------------------------------------------------+\n"); } return; } /* unload a room from memory or delete it totally - all rooms files */ if (!strcmp(word[1], "-u") || !strcmp(word[1], "-d")) { if (word_count < 3) { write_user(user, "Usage: rmadmin -l / -m / -u <name> / -d <name>\n"); return; } sprintf(rmname, "(%s)", word[2]); strtolower(rmname); /* first do checks on the room */ rm = get_room_full(rmname); if (!rm) { write_user(user, "That user does not have a personal room built.\n"); return; } if (room_visitor_count(rm)) { write_user(user, "You cannot remove a room if people are in it.\n"); return; } /* okay to remove the room */ /* remove invites */ for (u = user_first; u; u = u->next) { if (u->invite_room == rm) { u->invite_room = NULL; } } /* destroy */ destruct_room(rm); strtolower(word[2]); *word[2] = toupper(*word[2]); /* delete all files */ if (!strcmp(word[1], "-d")) { sprintf(filename, "%s/%s/%s.R", USERFILES, USERROOMS, word[2]); remove(filename); sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, word[2]); remove(filename); write_syslog(SYSLOG, 1, "%s deleted the personal room of %s.\n", user->name, word[2]); vwrite_user(user, "You have now ~OL~FRdeleted~RS the room belonging to %s.\n", word[2]); /* remove all the key flags */ u = retrieve_user(user, word[2]); if (u) { all_unsetbit_flagged_user_entry(u, fufROOMKEY); write_user(user, "All keys to that room have now been destroyed.\n"); done_retrieve(u); } } else { /* just unload from memory */ write_syslog(SYSLOG, 1, "%s unloaded the personal room of %s from memory.\n", user->name, word[2]); vwrite_user(user, "You have now ~OL~FGunloaded~RS the room belonging to %s from memory.\n", word[2]); } return; } /* wrong input given */ write_user(user, "Usage: rmadmin -l | -m | -u <name> | -d <name>\n"); }
/* * lets a user enter their own room. It creates the room if !exists */ void personal_room(UR_OBJECT user) { char rmname[ROOM_NAME_LEN + 1], filename[80]; UR_OBJECT u; RM_OBJECT rm; if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } sprintf(rmname, "(%s)", user->name); strtolower(rmname); rm = get_room_full(rmname); /* if the user wants to delete their room */ if (word_count >= 2) { if (strcmp(word[1], "-d")) { write_user(user, "Usage: myroom [-d]\n"); return; } /* move to the user out of the room if they are in it */ if (!rm) { write_user(user, "You do not have a personal room built.\n"); return; } if (room_visitor_count(rm)) { write_user(user, "You cannot destroy your room if any people are in it.\n"); return; } write_user(user, "~OL~FRYou whistle a sharp spell and watch your room crumble into dust.~RS\n"); /* remove invites */ for (u = user_first; u; u = u->next) { if (u->invite_room == rm) { u->invite_room = NULL; } } /* remove all the key flags */ write_user(user, "~OL~FRAll keys to your room crumble to ashes.~RS\n"); all_unsetbit_flagged_user_entry(user, fufROOMKEY); /* destroy */ destruct_room(rm); /* delete the files */ sprintf(filename, "%s/%s/%s.R", USERFILES, USERROOMS, user->name); remove(filename); sprintf(filename, "%s/%s/%s.B", USERFILES, USERROOMS, user->name); remove(filename); sprintf(filename, "%s/%s/%s.K", USERFILES, USERROOMS, user->name); remove(filename); write_syslog(SYSLOG, 1, "%s destructed their personal room.\n", user->name); return; } /* if the user is moving to their room */ if (user->lroom == 2) { write_user(user, "You have been shackled and cannot move.\n"); return; } /* if room does not exist then create it */ if (!rm) { rm = create_room(); if (!rm) { write_user(user, "Sorry, but your room cannot be created at this time.\n"); write_syslog(SYSLOG | ERRLOG, 0, "ERROR: Cannot create room for in personal_room()\n"); return; } write_user(user, "\nYour room does not exists. Building it now...\n\n"); /* check to see if the room was just unloaded from memory first */ if (!personal_room_store(user->name, 0, rm)) { write_syslog(SYSLOG, 1, "%s creates their own room.\n", user->name); if (!personal_room_store(user->name, 1, rm)) { write_syslog(SYSLOG | ERRLOG, 1, "ERROR: Unable to save personal room status in personal_room()\n"); } } } /* if room just created then should not go in his block */ if (user->room == rm) { write_user(user, "You are already in your own room!\n"); return; } move_user(user, rm, 1); }
/* * Set rooms to public or private */ void set_room_access(UR_OBJECT user, int priv) { UR_OBJECT u; RM_OBJECT rm; const char *name; if (word_count < 2) { rm = user->room; } else { if (user->level < amsys->gatecrash_level) { write_user(user, "You are not a high enough level to use the room option.\n"); return; } rm = get_room(word[1]); if (!rm) { write_user(user, nosuchroom); return; } } if (is_personal_room(rm)) { if (rm == user->room) { write_user(user, "This room's access is personal.\n"); } else { write_user(user, "That room's access is personal.\n"); } return; } if (is_fixed_room(rm)) { if (rm == user->room) { write_user(user, "This room's access is fixed.\n"); } else { write_user(user, "That room's access is fixed.\n"); } return; } if (priv) { if (is_private_room(rm)) { if (rm == user->room) { write_user(user, "This room is already private.\n"); } else { write_user(user, "That room is already private.\n"); } return; } if (room_visitor_count(rm) < amsys->min_private_users && user->level < amsys->ignore_mp_level) { vwrite_user(user, "You need at least %d users/clones in a room before it can be made private.\n", amsys->min_private_users); return; } } else { if (!is_private_room(rm)) { if (rm == user->room) { write_user(user, "This room is already public.\n"); } else { write_user(user, "That room is already public.\n"); } return; } /* Reset any invites into the room & clear review buffer */ for (u = user_first; u; u = u->next) { if (u->invite_room == rm) { u->invite_room = NULL; } } clear_revbuff(rm); } rm->access ^= PRIVATE; name = user->vis ? user->recap : invisname; if (rm == user->room) { vwrite_room_except(rm, user, "%s~RS has set the room to %s~RS.\n", name, is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); } else { vwrite_room(rm, "This room has been set to %s~RS.\n", is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); } vwrite_user(user, "Room set to %s~RS.\n", is_private_room(rm) ? "~FRPRIVATE" : "~FGPUBLIC"); }