/* 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; }
/* * 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; }
/* * Move to another room */ void go(UR_OBJECT user) { RM_OBJECT rm; int i; if (user->lroom == 2) { write_user(user, "You have been shackled and cannot move.\n"); return; } if (word_count < 2) { rm = get_room_full(amsys->default_warp); if (!rm) { write_user(user, "You cannot warp to the main room at this time.\n"); return; } if (user->room == rm) { vwrite_user(user, "You are already in the %s!\n", rm->name); return; } move_user(user, rm, 1); return; } #ifdef NETLINKS release_nl(user); if (transfer_nl(user)) { return; } #endif 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; } /* See if link from current room */ for (i = 0; i < MAX_LINKS; ++i) { if (user->room->link[i] == rm) { break; } } if (i < MAX_LINKS) { move_user(user, rm, 0); return; } if (is_personal_room(rm)) { write_user(user, "To go to another user's home you must \".visit\" them.\n"); return; } if (user->level < WIZ) { vwrite_user(user, "The %s is not adjoined to here.\n", rm->name); return; } move_user(user, rm, 1); }
/* * Set the room topic */ void set_topic(UR_OBJECT user, char *inpstr) { RM_OBJECT rm; const char *name; rm = user->room; if (word_count < 2) { if (!*rm->topic) { write_user(user, "No topic has been set yet.\n"); return; } vwrite_user(user, "The current topic is: %s\n", rm->topic); return; } if (strlen(inpstr) > TOPIC_LEN) { write_user(user, "Topic too long.\n"); return; } switch (amsys->ban_swearing) { case SBMAX: if (contains_swearing(inpstr)) { write_user(user, noswearing); return; } break; case SBMIN: if (!is_personal_room(user->room)) { inpstr = censor_swear_words(inpstr); } break; case SBOFF: default: /* do nothing as ban_swearing is off */ break; } vwrite_user(user, "Topic set to: %s\n", inpstr); name = user->vis ? user->recap : invisname; vwrite_room_except(rm, user, "%s~RS has set the topic to: %s\n", name, inpstr); strcpy(rm->topic, inpstr); }
/* * 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"); } }
/*** Wipe some messages off the board ***/ void wipe_board(UR_OBJECT user) { int cnt; char fname[FNAME_LEN],*name,rmname[ROOM_NAME_LEN+1]; RM_OBJECT rm=user->room; set_crash(); if (word_count<2 && ((user->level>=WIZ && !is_personal_room(rm)) || (is_personal_room(rm) && (is_my_room(user,rm) || user->level>=GOD)))) { write_usage(user,"wipe all"); write_usage(user,"wipe <#>"); write_usage(user,"wipe to <#>"); write_usage(user,"wipe from <#> to <#>"); return; } else if (word_count<2 && ((user->level<WIZ && !is_personal_room(rm)) || (is_personal_room(rm) && !is_my_room(user,rm) && user->level<GOD ) ) ) { write_usage(user,"wipe <#>"); return; } switch (is_personal_room(rm)) { case 0: if (user->level<WIZ && !(check_board_wipe(user))) return; else if (get_wipe_parameters(user)==-1) return; break; case 1: if (!is_my_room(user,rm) && user->level<GOD && !check_board_wipe(user)) return; else if (get_wipe_parameters(user)==-1) return; break; } if (user->vis) name=user->recap; else name=invisname; if (rm->access==PERSONAL_LOCKED || rm->access==PERSONAL_UNLOCKED) { midcpy(rm->name,rmname,1,strlen(rm->name)-2); rmname[0]=toupper(rmname[0]); sprintf(fname,"%s/%s.B", USERROOMS, rmname); } else sprintf(fname,"%s/%s.B", ROOMFILES, rm->name); if (!rm->mesg_cnt) { write_user(user, wipe_empty_board); return; } if (user->wipe_from==-1) { unlink(fname); write_user(user, wipe_user_all_deleted); if (user->level<GOD || user->vis) vwrite_room_except(rm, user, wipe_room_all_deleted, name); write_syslog(SYSLOG,1,"%s wiped all messages from the board in the %s.\n",user->name,rm->name); rm->mesg_cnt=0; return; } if (user->wipe_from>rm->mesg_cnt) { vwrite_user(user,"There %s only %d message%s on the board.\n",PLTEXT_IS(rm->mesg_cnt),rm->mesg_cnt,PLTEXT_S(rm->mesg_cnt)); return; } cnt=wipe_messages(fname,user->wipe_from,user->wipe_to,0); if (cnt==rm->mesg_cnt) { unlink(fname); vwrite_user(user, wipe_too_many, rm->mesg_cnt, grm_num(8, rm->mesg_cnt)); if (user->level<GOD || user->vis) vwrite_room_except(rm,user,"%s maze nastenku.\n",name); write_syslog(SYSLOG,1,"%s wiped all messages from the board in the %s.\n",user->name,rm->name); rm->mesg_cnt=0; return; } rm->mesg_cnt-=cnt; vwrite_user(user, wipe_user_delete_range, cnt, grm_num(8, cnt), grm_num(9, cnt)); if (user->level<GOD || user->vis) vwrite_room_except(rm,user,"%s wipes some messages from the board.\n",name); write_syslog(SYSLOG,1,"%s wiped %d message%s from the board in the %s.\n",user->name,cnt,PLTEXT_S(cnt),rm->name); }
/* * 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"); }
/* * Reloads the description for one or all rooms--incase you have edited the * file and do not want to reboot the talker to to make the changes displayed */ void reload_room_description(UR_OBJECT user) { int c, i, error; RM_OBJECT rm; char filename[80]; FILE *fp; if (word_count < 2) { write_user(user, "Usage: rloadrm -a/<room name>\n"); return; } /* if reload all of the rooms */ if (!strcmp(word[1], "-a")) { error = 0; for (rm = room_first; rm; rm = rm->next) { if (is_personal_room(rm)) { continue; } sprintf(filename, "%s/%s.R", DATAFILES, rm->name); fp = fopen(filename, "r"); if (!fp) { vwrite_user(user, "Sorry, cannot reload the description file for the room \"%s\".\n", rm->name); write_syslog(SYSLOG | ERRLOG, 0, "ERROR: Cannot reload the description file for room %s.\n", rm->name); ++error; continue; } i = 0; for (c = getc(fp); c != EOF; c = getc(fp)) { if (i == ROOM_DESC_LEN) { break; } rm->desc[i++] = c; } if (c != EOF) { vwrite_user(user, "The description is too long for the room \"%s\".\n", rm->name); write_syslog(SYSLOG | ERRLOG, 0, "ERROR: Description too long when reloading for room %s.\n", rm->name); } rm->desc[i] = '\0'; fclose(fp); } if (!error) { write_user(user, "You have now reloaded all room descriptions.\n"); } else { write_user(user, "You have now reloaded all room descriptions that you can.\n"); } write_syslog(SYSLOG, 1, "%s reloaded all of the room descriptions.\n", user->name); return; } /* if it is just one room to reload */ rm = get_room(word[1]); if (!rm) { write_user(user, nosuchroom); return; } /* check first for personal room, and do not reload */ if (is_personal_room(rm)) { write_user(user, "Sorry, but you cannot reload personal room descriptions.\n"); return; } sprintf(filename, "%s/%s.R", DATAFILES, rm->name); fp = fopen(filename, "r"); if (!fp) { vwrite_user(user, "Sorry, cannot reload the description file for the room \"%s\".\n", rm->name); write_syslog(SYSLOG | ERRLOG, 0, "ERROR: Cannot reload the description file for room %s.\n", rm->name); return; } i = 0; for (c = getc(fp); c != EOF; c = getc(fp)) { if (i == ROOM_DESC_LEN) { break; } rm->desc[i++] = c; } if (c != EOF) { vwrite_user(user, "The description is too long for the room \"%s\".\n", rm->name); write_syslog(SYSLOG | ERRLOG, 0, "ERROR: Description too long when reloading for room %s.\n", rm->name); } rm->desc[i] = '\0'; fclose(fp); vwrite_user(user, "You have now reloaded the description for the room \"%s\".\n", rm->name); write_syslog(SYSLOG, 1, "%s reloaded the description for the room %s\n", user->name, rm->name); }
/* * 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"); }