/* * See if a user has access to a room. If room is fixed to private then * it is considered a wizroom so grant permission to any user of WIZ and * above for those. */ int has_room_access(UR_OBJECT user, RM_OBJECT rm) { size_t i; /* level room checks */ for (i = 0; priv_room[i].name; ++i) { if (!strcmp(rm->name, priv_room[i].name)) { break; } } if (user->invite_room == rm) { return 1; } if (priv_room[i].name && user->level < priv_room[i].level) { return 0; } if (!is_private_room(rm)) { return 1; } if (is_personal_room(rm)) { return is_my_room(user, rm) || has_room_key(user->name, rm) || user->level == GOD; } if (is_fixed_room(rm)) { return user->level >= WIZ; } return user->level >= amsys->gatecrash_level; }
/* * put speech in a music notes */ void sing_it(UR_OBJECT user, char *inpstr) { #if !!0 static const char usage[] = "Usage: sing [<text>]\n"; #endif const char *name; /* FIXME: Use sentinel other JAILED */ if (user->muzzled != JAILED) { write_user(user, "You are muzzled, you cannot sing.\n"); return; } switch (amsys->ban_swearing) { case SBMAX: if (contains_swearing(inpstr)) { write_user(user, noswearing); return; } break; case SBMIN: if (!is_private_room(user->room)) { inpstr = censor_swear_words(inpstr); } break; case SBOFF: default: /* do nothing as ban_swearing is off */ break; } if (!user->vis) { write_monitor(user, user->room, 0); } name = user->vis ? user->recap : invisname; if (word_count < 2) { sprintf(text, "%s~RS sings a tune...BADLY!\n", name); } else { sprintf(text, "%s~RS sings o/~ %s~RS o/~\n", name, inpstr); } record(user->room, text); write_room(user->room, text); }
/* * Invite a user into a private room */ void invite(UR_OBJECT user) { UR_OBJECT u; RM_OBJECT rm; const char *name; if (word_count < 2) { write_user(user, "Invite who?\n"); return; } rm = user->room; if (!is_private_room(rm)) { write_user(user, "This room is currently public.\n"); return; } u = get_user_name(user, word[1]); if (!u) { write_user(user, notloggedon); return; } if (u == user) { write_user(user, "Inviting yourself to somewhere is the third sign of madness.\n"); return; } if (u->room == rm) { vwrite_user(user, "%s~RS is already here!\n", u->recap); return; } if (u->invite_room == rm) { vwrite_user(user, "%s~RS has already been invited into here.\n", u->recap); return; } vwrite_user(user, "You invite %s~RS in.\n", u->recap); name = user->vis || u->level >= user->level ? user->recap : invisname; vwrite_user(u, "%s~RS has invited you into the %s.\n", name, rm->name); u->invite_room = rm; strcpy(u->invite_by, user->name); }
/* * 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"); } }
/* * Ask to be let into a private room */ void letmein(UR_OBJECT user) { RM_OBJECT rm; int i; if (word_count < 2) { write_user(user, "Knock on what door?\n"); return; } rm = get_room(word[1]); if (!rm) { write_user(user, nosuchroom); return; } if (rm == user->room) { vwrite_user(user, "You are already in the %s!\n", rm->name); return; } for (i = 0; i < MAX_LINKS; ++i) if (user->room->link[i] == rm) { break; } if (i >= MAX_LINKS) { vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); return; } if (!is_private_room(rm)) { vwrite_user(user, "The %s is currently public.\n", rm->name); return; } vwrite_user(user, "You knock asking to be let into the %s.\n", rm->name); vwrite_room_except(user->room, user, "%s~RS knocks asking to be let into the %s.\n", user->recap, rm->name); vwrite_room(rm, "%s~RS knocks asking to be let in.\n", user->recap); }
/* * allows a user to lock their room out to access from anyone */ void personal_room_lock(UR_OBJECT user) { if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } if (strcmp(user->room->owner, user->name)) { write_user(user, "You have to be in your personal room to lock and unlock it.\n"); return; } user->room->access ^= PRIVATE; if (is_private_room(user->room)) { write_user(user, "You have now ~OL~FRlocked~RS your room to all the other users.\n"); } else { write_user(user, "You have now ~OL~FGunlocked~RS your room to all the other users.\n"); } if (!personal_room_store(user->name, 1, user->room)) write_syslog(SYSLOG | ERRLOG, 1, "ERROR: Unable to save personal room status in personal_room_lock()\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"); }
/* * Show talker rooms */ void rooms(UR_OBJECT user, int show_topics, int wrap) { RM_OBJECT rm; UR_OBJECT u; #ifdef NETLINKS NL_OBJECT nl; char serv[SERV_NAME_LEN + 1], nstat[9]; char rmaccess[9]; #endif int cnt, rm_cnt, rm_pub, rm_priv; if (word_count < 2) { if (!wrap) { user->wrap_room = room_first; } if (show_topics) { write_user(user, "\n+----------------------------------------------------------------------------+\n"); write_user(user, "~FC~OLpl u/m~RS | ~OL~FCname~RS - ~FC~OLtopic\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); } else { write_user(user, "\n+----------------------------------------------------------------------------+\n"); write_user(user, "~FC~OLRoom name ~RS|~FC~OL Access Users Mesgs Inlink LStat Service\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); } rm_cnt = 0; for (rm = user->wrap_room; rm; rm = rm->next) { if (is_personal_room(rm)) { continue; } if (rm_cnt == user->pager - 4) { switch (show_topics) { case 0: user->misc_op = 10; break; case 1: user->misc_op = 11; break; } write_user(user, "~BB~FG-=[*]=- PRESS <RETURN>, E TO EXIT:~RS "); return; } cnt = 0; for (u = user_first; u; u = u->next) if (u->type != CLONE_TYPE && u->room == rm) { ++cnt; } if (show_topics) { vwrite_user(user, "%c%c %2d/%-2d | %s%-20.20s~RS - %s\n", is_private_room(rm) ? 'P' : ' ', is_fixed_room(rm) ? '*' : ' ', cnt, rm->mesg_cnt, is_private_room(rm) ? "~FR~OL" : "", rm->name, rm->topic); } #ifdef NETLINKS else { if (is_private_room(rm)) { strcpy(rmaccess, " ~FRPRIV"); } else { strcpy(rmaccess, " ~FGPUB "); } if (is_fixed_room(rm)) { *rmaccess = '*'; } nl = rm->netlink; *serv = '\0'; if (!nl) { if (rm->inlink) { strcpy(nstat, " ~FRDOWN"); } else { strcpy(nstat, " -"); } } else { if (nl->type == UNCONNECTED) { strcpy(nstat, " ~FRDOWN"); } else if (nl->stage == UP) { strcpy(nstat, " ~FGUP"); } else { strcpy(nstat, " ~FYVER"); } } if (nl) { strcpy(serv, nl->service); } vwrite_user(user, "%-20s | %9s~RS %5d %5d %-6s %s~RS %s\n", rm->name, rmaccess, cnt, rm->mesg_cnt, noyes[rm->inlink], nstat, serv); } #endif ++rm_cnt; user->wrap_room = rm->next; } user->misc_op = 0; rm_pub = rm_priv = 0; for (rm = room_first; rm; rm = rm->next) { if (is_personal_room(rm)) { continue; } if (is_private_room(rm)) { ++rm_priv; } else { ++rm_pub; } } write_user(user, "+----------------------------------------------------------------------------+\n"); vwrite_user(user, "There is a total of ~OL%d~RS rooms. ~OL%d~RS %s public, and ~OL%d~RS %s private.\n", rm_priv + rm_pub, rm_pub, PLTEXT_IS(rm_pub), rm_priv, PLTEXT_IS(rm_priv)); write_user(user, "+----------------------------------------------------------------------------+\n\n"); return; } if (!strcasecmp(word[1], "-l")) { write_user(user, "The following rooms are default...\n\n"); vwrite_user(user, "Default main room : ~OL%s~RS\n", room_first->name); vwrite_user(user, "Default warp room : ~OL%s~RS\n", *amsys->default_warp ? amsys->default_warp : "<none>"); vwrite_user(user, "Default jail room : ~OL%s~RS\n", *amsys->default_jail ? amsys->default_jail : "<none>"); #ifdef GAMES vwrite_user(user, "Default bank room : ~OL%s~RS\n", *amsys->default_bank ? amsys->default_bank : "<none>"); vwrite_user(user, "Default shoot room : ~OL%s~RS\n", *amsys->default_shoot ? amsys->default_shoot : "<none>"); #endif if (!priv_room[0].name) { write_user(user, "\nThere are no level specific rooms currently availiable.\n\n"); return; } write_user(user, "\nThe following rooms are level specific...\n\n"); for (cnt = 0; priv_room[cnt].name; ++cnt) { vwrite_user(user, "~FC%s~RS is for users of level ~OL%s~RS and above.\n", priv_room[cnt].name, user_level[priv_room[cnt].level].name); } vwrite_user(user, "\nThere is a total of ~OL%d~RS level specific rooms.\n\n", cnt); return; } write_user(user, "Usage: rooms [-l]\n"); }
/* * 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"); }