/* * let a user go into another user's personal room if it is unlocked */ void personal_room_visit(UR_OBJECT user) { char rmname[ROOM_NAME_LEN + 1]; RM_OBJECT rm; if (word_count < 2) { write_user(user, "Usage: visit <user>\n"); return; } if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } /* check if not same user */ if (!strcasecmp(user->name, word[1])) { vwrite_user(user, "To go to your own room use the \"%s\" command.\n", command_table[MYROOM].name); return; } /* see if there is such a user */ if (!find_user_listed(word[1])) { write_user(user, nosuchuser); return; } /* get room to go to */ sprintf(rmname, "(%s)", word[1]); strtolower(rmname); rm = get_room_full(rmname); if (!rm) { write_user(user, nosuchroom); return; } /* can they go there? */ if (!has_room_access(user, rm)) { write_user(user, "That room is currently private, you cannot enter.\n"); return; } move_user(user, rm, 1); }
/* * this function allows users to give access to others even if their personal room * has been locked */ void personal_room_key(UR_OBJECT user) { RM_OBJECT rm; FU_OBJECT fu; if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } /* if no name was given then display keys given */ if (word_count < 2) { char text2[ARR_SIZE]; int found = 0, cnt = 0; *text2 = '\0'; for (fu = user->fu_first; fu; fu = fu->next) { if (fu->flags & fufROOMKEY) { if (!found++) { write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, "| ~OL~FCYou have given the following people a key to your room~RS |\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); } switch (++cnt) { case 1: sprintf(text, "| %-24s", fu->name); strcat(text2, text); break; case 2: sprintf(text, " %-24s", fu->name); strcat(text2, text); break; default: sprintf(text, " %-24s |\n", fu->name); strcat(text2, text); write_user(user, text2); cnt = 0; *text2 = '\0'; break; } } } if (!found) { write_user(user, "You have not given anyone a personal room key yet.\n"); return; } if (cnt == 1) { strcat(text2, " |\n"); write_user(user, text2); } else if (cnt == 2) { strcat(text2, " |\n"); write_user(user, text2); } write_user(user, "+----------------------------------------------------------------------------+\n"); return; } { char rmname[ROOM_NAME_LEN + 1]; /* see if user has a room created */ sprintf(rmname, "(%s)", user->name); strtolower(rmname); rm = get_room_full(rmname); if (!rm) { write_user(user, "Sorry, but you have not created a personal room yet.\n"); return; } } /* actually add/remove a user */ strtolower(word[1]); *word[1] = toupper(*word[1]); if (!strcmp(user->name, word[1])) { write_user(user, "You already have access to your own room!\n"); return; } /* * check to see if the user is already listed before the adding part. * This is to ensure you can remove a user even if they have, for * instance, suicided. */ if (has_room_key(word[1], rm)) { if (!personal_key_remove(user, word[1])) { write_user(user, "There was an error taking the key away from that user.\n"); return; } vwrite_user(user, "You take your personal room key away from ~FC~OL%s~RS.\n", word[1]); vwrite_user(get_user(word[1]), "%s takes back their personal room key.\n", user->name); } else { /* see if there is such a user */ if (!find_user_listed(word[1])) { write_user(user, nosuchuser); return; } /* give them a key */ if (!personal_key_add(user, word[1])) { write_user(user, "There was an error giving the key to that user.\n"); return; } vwrite_user(user, "You give ~FC~OL%s~RS a key to your personal room.\n", word[1]); vwrite_user(get_user(word[1]), "%s gives you a key to their room.\n", user->name); } }
/* * get users which to send copies of smail to */ void copies_to(UR_OBJECT user) { int i, found, x, y; char *remote; if (com_num == NOCOPIES) { for (i = 0; i < MAX_COPIES; ++i) { *user->copyto[i] = '\0'; } write_user(user, "Sending no copies of your next smail.\n"); return; } if (word_count < 2) { *text = '\0'; found = 0; for (i = 0; i < MAX_COPIES; ++i) { if (!*user->copyto[i]) { continue; } if (!found++) { write_user(user, "Sending copies of your next smail to...\n"); } strcat(text, " "); strcat(text, user->copyto[i]); } strcat(text, "\n\n"); if (!found) { write_user(user, "You are not sending a copy to anyone.\n"); } else { write_user(user, text); } return; } if (word_count > MAX_COPIES + 1) { /* +1 because 1 count for command */ vwrite_user(user, "You can only copy to a maximum of %d people.\n", MAX_COPIES); return; } /* check to see the user is not trying to send duplicates */ for (x = 1; x < word_count; ++x) { for (y = x + 1; y < word_count; ++y) { if (!strcasecmp(word[x], word[y])) { write_user(user, "Cannot send to same person more than once.\n"); return; } } } write_user(user, "\n"); for (i = 0; i < MAX_COPIES; ++i) { *user->copyto[i] = '\0'; } i = 0; for (x = 1; x < word_count; ++x) { /* See if its to another site */ if (*word[x] == '@') { vwrite_user(user, "Name missing before @ sign for copy to name \"%s\".\n", word[x]); continue; } remote = strchr(word[x], '@'); if (!remote) { *word[x] = toupper(*word[x]); /* See if user exists */ if (get_user(word[x]) == user && user->level < ARCH) { write_user(user, "You cannot send yourself a copy.\n"); continue; } if (!find_user_listed(word[x])) { vwrite_user(user, "There is no such user with the name \"%s\" to copy to.\n", word[x]); continue; } } strcpy(user->copyto[i++], word[x]); } *text = '\0'; found = 0; for (i = 0; i < MAX_COPIES; ++i) { if (!*user->copyto[i]) { continue; } if (!found++) { write_user(user, "Sending copies of your next smail to...\n"); } strcat(text, " "); strcat(text, user->copyto[i]); } strcat(text, "\n\n"); if (!found) { write_user(user, "You are not sending a copy to anyone.\n"); } else { write_user(user, text); } }
void show_spodlist(UR_OBJECT user) { int start_pos = 1, end_pos, listed, pos = 0, hilight = 0; SP_OBJECT sp; calc_spodlist(); sp = first_spod; listed = people_in_spodlist(); if (*word[1]) { /* We will assume it is a position they want. If it is a name then we can easily overwrite it */ hilight = atoi(word[1]); if (!hilight) { if (!find_user_listed(word[1])) { write_user(user, nosuchuser); return; } else { hilight = find_spodlist_position(word[1]); } } if (hilight > listed) { start_pos = listed - 16; hilight = 0; } else { start_pos = hilight - 8; if (start_pos < 1) { start_pos = 1; } } } else { /* I personally like it defaulting to a user name */ hilight = find_spodlist_position(user->name); start_pos = hilight - 8; if (start_pos < 1) { start_pos = 1; } } end_pos = start_pos + 16; if (end_pos > listed) { end_pos = listed; start_pos = end_pos - 16; } /* Create the page */ write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, "| ~FC~OLSpod List~RS |\n"); write_user(user, "+----------------------------------------------------------------------------+\n"); for (pos = 1; pos <= end_pos && sp; ++pos, sp = sp->next) { if (pos >= start_pos) { vwrite_user(user, "| %s%4d. %-20s %45s~RS |\n", (pos == hilight ? "~OL~FG" : ""), pos, sp->name, word_time(sp->login)); } } if (start_pos < 1) { start_pos = 1; } write_user(user, "+----------------------------------------------------------------------------+\n"); write_user(user, align_string(0, 78, 1, "|", " Positions %d to %d (out of %d users) ", start_pos, end_pos, listed)); write_user(user, "+----------------------------------------------------------------------------+\n"); }