/* * Check the room you are logging into is not private */ int check_start_room(UR_OBJECT user) { int was_private; RM_OBJECT rm; rm = user->level == JAILED ? get_room_full(amsys->default_jail) : !user->lroom ? room_first : get_room_full(user->logout_room); was_private = rm && rm != room_first && user->level != JAILED && user->lroom != 2 && !has_room_access(user, rm); user->room = !rm || was_private ? room_first : rm; return was_private; }
/* allows a user to rename their room */ void personal_room_rename(UR_OBJECT user,char *inpstr) { char name[ROOM_NAME_LEN+1]; RM_OBJECT rm; if (!amsys->personal_rooms) { write_user(user,"Personal room functions are currently disabled.\n"); return; } if (word_count<2) { write_usage(user, "%s <nazov>\n", command_table[MYNAME].name); return; } sprintf(name,"(%s)",user->name); strtolower(name); /* get room that user is in */ if ((rm=get_room_full(name))==NULL) { write_user(user,"Sorry, but you cannot use the room renaming feature at this time.\n"); return; } if (user->room!=rm) { write_user(user,"You have to be in your personal room to rename it.\n"); return; } if (strlen(inpstr)>PERSONAL_ROOMNAME_LEN) { write_user(user,"You cannot have a room name that long.\n"); return; } strcpy(rm->real_name,inpstr); vwrite_user(user,"You have now renamed your room to: %s\n",rm->real_name); if (!personal_room_store(user->name,1,rm)) write_syslog(SYSLOG,1,"ERROR: Unable to save personal room status in personal_room_rename()\n"); }
/* * well...Duh! Reload the gun */ void reload_gun(UR_OBJECT user) { RM_OBJECT rm; rm = get_room_full(amsys->default_shoot); if (!rm) { write_user(user, "There is nowhere that you can shoot.\n"); return; } if (user->room != rm) { vwrite_user(user, "Do not be shooting in a public place. Go to the ~OL%s~RS to play.\n", rm->name); return; } if (user->bullets > 0) { vwrite_user(user, "You have ~OL%d~RS bullets left.\n", user->bullets); return; } vwrite_room_except(user->room, user, "~FY%s reloads their gun.\n", user->bw_recap); write_user(user, "~FYYou reload your gun.\n"); user->bullets = 6; }
/* * 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); }
/* * allow a user to bump others from their personal room */ void personal_room_bgone(UR_OBJECT user) { RM_OBJECT rm; UR_OBJECT u; if (!amsys->personal_rooms) { write_user(user, "Personal room functions are currently disabled.\n"); return; } if (word_count < 2) { write_user(user, "Usage: mybgone <user>/all\n"); return; } if (strcmp(user->room->owner, user->name)) { write_user(user, "You have to be in your personal room to bounce people from it.\n"); return; } /* get room to bounce people to */ rm = get_room_full(amsys->default_warp); if (!rm) { write_user(user, "No one can be bounced from your personal room at this time.\n"); return; } strtolower(word[1]); /* bounce everyone out - except GODS */ if (!strcmp(word[1], "all")) { for (u = user_first; u; u = u->next) { if (u == user || u->room != user->room || u->level == GOD) { continue; } vwrite_user(user, "%s~RS is forced to leave the room.\n", u->recap); write_user(u, "You are being forced to leave the room.\n"); move_user(u, rm, 0); } return; } /* send out just the one user */ u = get_user_name(user, word[1]); if (!u) { write_user(user, notloggedon); return; } if (u->room != user->room) { vwrite_user(user, "%s~RS is not in your personal room.\n", u->recap); return; } if (u->level == GOD) { vwrite_user(user, "%s~RS cannot be forced to leave your personal room.\n", u->recap); return; } vwrite_user(user, "%s~RS is forced to leave the room.\n", u->recap); write_user(u, "You are being forced to leave the room.\n"); move_user(u, rm, 0); }
/* * 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); }
/* * Unarrest a user who is currently under arrest and in jail */ void unarrest(UR_OBJECT user) { UR_OBJECT u; RM_OBJECT rm; int on; if (word_count < 2) { write_user(user, "Usage: unarrest <user>\n"); return; } u = retrieve_user(user, word[1]); if (!u) { return; } on = retrieve_user_type == 1; /* error checks */ if (u == user) { write_user(user, "You cannot unarrest yourself.\n"); return; } if (u->level != JAILED) { vwrite_user(user, "%s~RS is not under arrest!\n", u->recap); done_retrieve(u); return; } if (user->level < u->arrestby) { vwrite_user(user, "%s~RS can only be unarrested by a %s or higher.\n", u->recap, user_level[u->arrestby].name); done_retrieve(u); return; } /* do it */ u->level = u->unarrest; u->real_level = u->level; u->arrestby = JAILED; /* FIXME: Use sentinel other JAILED */ user_list_level(u->name, u->level); strcpy(u->date, (long_date(1))); sprintf(text, "~FG~OLYou have been unarrested... Now try to behave!\n"); if (!on) { send_mail(user, u->name, text, 0); vwrite_user(user, "%s has been unarrested.\n", u->name); } else { write_user(u, text); vwrite_user(user, "%s has been unarrested.\n", u->name); write_room(NULL, "The Hand of Justice reaches through the air...\n"); rm = get_room_full(amsys->default_warp); if (!rm) { vwrite_user(user, "Cannot find a room for ex-cons, so %s~RS is still in the %s!\n", u->recap, u->room->name); } else { move_user(u, rm, 2); } } write_syslog(SYSLOG, 1, "%s UNARRESTED %s\n", user->name, u->name); add_history(u->name, 1, "Was ~FGunarrested~RS by %s.\n", user->name); if (!on) { u->socket = -2; strcpy(u->site, u->last_site); } save_user_details(u, on); done_retrieve(u); }
/* * allows a user to store some of the money they have in their hand */ void bank_money(UR_OBJECT user) { static const char *const what[] = { ".", ", Sir.", ", Madam." }; RM_OBJECT rm; int money; if (word_count < 2) { write_user(user, "Usage: bank deposit/withdraw/balance [<amount>]\n"); return; } rm = get_room_full(amsys->default_bank); if (!rm) { write_user(user, "There is nowhere for you to bank your money.\n"); return; } if (user->room != rm) { vwrite_user(user, "You must be in the ~OL%s~RS else the bankteller cannot see you.\n", rm->name); return; } if (!strcasecmp("balance", word[1])) { vwrite_user(user, "~FCThe teller says:~RS You have $%d in the bank%s\n", user->bank, what[user->gender]); return; } if (!strcasecmp("deposit", word[1])) { if (word_count < 3) { write_user(user, "Usage: bank deposit/withdraw/balance [<amount>]\n"); return; } money = atoi(word[2]); if (money > user->money) { write_user(user, "You have not got that much money on you.\n"); return; } if (!money) { write_user(user, "You forgot to say how much money you wanted to deposit.\n"); return; } if (money < 0) { write_user(user, "To take money out of the bank, use the \"withdraw\" option.\n"); return; } user->money -= money; user->bank += money; vwrite_user(user, "You deposit $%d into your account, leaving $%d in your hand.\n", money, user->money); return; } if (!strcasecmp("withdraw", word[1])) { if (word_count < 3) { write_user(user, "Usage: bank deposit/withdraw/balance [<amount>]\n"); return; } money = atoi(word[2]); if (money > user->bank) { write_user(user, "You have not got that much money in your account.\n"); return; } if (!money) { write_user(user, "You forgot to say how much money you wanted to withdraw.\n"); return; } if (money < 0) { write_user(user, "To put money into the bank, use the \"deposit\" option.\n"); return; } user->money += money; user->bank -= money; vwrite_user(user, "You withdraw $%d from your account, leaving $%d in it.\n", money, user->bank); return; } write_user(user, "Usage: bank deposit/withdraw/balance [<amount>]\n"); }
/* * Shoot another user... Fun! Fun! Fun! ;) */ void shoot_user(UR_OBJECT user) { UR_OBJECT user2; RM_OBJECT rm; int prob1, prob2; rm = get_room_full(amsys->default_shoot); if (!rm) { write_user(user, "There is nowhere that you can shoot.\n"); return; } if (user->room != rm) { vwrite_user(user, "Do not be shooting in a public place. Go to the ~OL%s~RS to play.\n", rm->name); return; } if (word_count < 2) { if (!user->bullets) { vwrite_room_except(rm, user, "%s~RS's gun goes *click* as they pull the trigger.\n", user->recap); write_user(user, "Your gun goes *click* as you pull the trigger.\n"); return; } vwrite_room_except(rm, user, "%s~RS fires their gun off into the air.\n", user->recap); write_user(user, "You fire your gun off into the air.\n"); --user->bullets; return; } prob1 = rand() % 100; prob2 = rand() % 100; user2 = get_user_name(user, word[1]); if (!user2) { write_user(user, notloggedon); return; } if (!user->vis) { write_user(user, "Be fair! At least make a decent target--do not be invisible!\n"); return; } if ((!user2->vis && user2->level < user->level) || user2->room != rm) { write_user(user, "You cannot see that person around here.\n"); return; } if (user == user2) { write_user(user, "Watch it! You might shoot yourself in the foot!\n"); return; } if (!user->bullets) { vwrite_room_except(rm, user, "%s~RS's gun goes *click* as they pull the trigger.\n", user->recap); write_user(user, "Your gun goes *click* as you pull the trigger.\n"); return; } if (prob1 > prob2) { vwrite_room(rm, "A bullet flies from %s~RS's gun and ~FR~OLhits~RS %s.\n", user->recap, user2->recap); --user->bullets; ++user->hits; --user2->hps; write_user(user2, "~FR~OLYou have been hit!\n"); write_user(user, "~FG~OLGood shot!\n"); if (user2->hps < 1) { ++user2->deaths; vwrite_user(user, "\nYou have won the shoot out, %s~RS is dead! You may now rejoice!\n", user2->recap); write_user(user2, "\nYou have received a fatal wound, and you feel your warm ~FRblood ~OLooze~RS out of you.\n"); write_user(user2, "The room starts to fade and grow grey...\n"); write_user(user2, "In the bleak mist of Death's shroud you see a man walk towards you.\n"); write_user(user2, "The man is wearing a tall black hat, and a wide grin...\n\n"); user2->hps = 5 * user2->level; write_syslog(SYSLOG, 1, "%s shot dead by %s\n", user2->name, user->name); disconnect_user(user2); ++user->kills; user->hps = user->hps + 5; return; } return; } vwrite_room(rm, "A bullet flies from %s~RS's gun and ~FG~OLmisses~RS %s~RS.\n", user->recap, user2->recap); --user->bullets; ++user->misses; write_user(user2, "~FGThat was a close shave!\n"); write_user(user, "~FRYou could not hit the side of a barn!\n"); }
/* * 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); } }
/* * 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); }
/* * Put annoying user in jail */ void arrest(UR_OBJECT user) { UR_OBJECT u; RM_OBJECT rm; int on; if (word_count < 2) { write_user(user, "Usage: arrest <user>\n"); return; } u = retrieve_user(user, word[1]); if (!u) { return; } on = retrieve_user_type == 1; /* error checks */ if (u == user) { write_user(user, "You cannot arrest yourself.\n"); return; } if (u->level >= user->level) { write_user(user, "You cannot arrest anyone of the same or higher level than yourself.\n"); done_retrieve(u); return; } if (u->level == JAILED) { vwrite_user(user, "%s~RS has already been arrested.\n", u->recap); done_retrieve(u); return; } /* do it */ u->vis = 1; u->unarrest = u->level; u->arrestby = user->level; u->level = JAILED; u->real_level = u->level; user_list_level(u->name, u->level); strcpy(u->date, (long_date(1))); sprintf(text, "~FR~OLYou have been placed under arrest.\n"); if (!on) { send_mail(user, u->name, text, 0); vwrite_user(user, "%s has been placed under arrest.\n", u->name); } else { write_user(u, text); vwrite_user(user, "%s has been placed under arrest.\n", u->name); write_room(NULL, "The Hand of Justice reaches through the air...\n"); rm = get_room_full(amsys->default_jail); if (!rm) { vwrite_user(user, "Cannot find the jail, so %s~RS is arrested but still in the %s.\n", u->recap, u->room->name); } else { move_user(u, rm, 2); } vwrite_room_except_both(NULL, user, u, "%s~RS has been placed under arrest...\n", u->recap); } write_syslog(SYSLOG, 1, "%s ARRESTED %s (at level %s)\n", user->name, u->name, user_level[u->arrestby].name); add_history(u->name, 1, "Was ~FRarrested~RS by %s (at level ~OL%s~RS).\n", user->name, user_level[u->arrestby].name); if (!on) { u->socket = -2; strcpy(u->site, u->last_site); } save_user_details(u, on); done_retrieve(u); }