Example #1
0
/*
 * Set user visible or invisible
 */
void
visibility(UR_OBJECT user, int vis)
{
    if (vis) {
        if (user->vis) {
            write_user(user, "You are already visible.\n");
            return;
        }
        write_user(user,
                "~FB~OLYou recite a melodic incantation and reappear.\n");
        vwrite_room_except(user->room, user,
                "~FB~OLYou hear a melodic incantation chanted and %s materialises!\n",
                user->bw_recap);
        user->vis = 1;
        return;
    }
    if (!user->vis) {
        write_user(user, "You are already invisible.\n");
        return;
    }
    write_user(user, "~FB~OLYou recite a melodic incantation and fade out.\n");
    vwrite_room_except(user->room, user,
            "~FB~OL%s recites a melodic incantation and disappears!\n",
            user->bw_recap);
    user->vis = 0;
}
Example #2
0
/*
 * Called by go() and move()
 */
void
move_user(UR_OBJECT user, RM_OBJECT rm, int teleport)
{
  RM_OBJECT old_room;

  if (teleport != 2 && !has_room_access(user, rm)) {
    write_user(user, "That room is currently private, you cannot enter.\n");
    return;
  }
  /* Reset invite room if in it */
  if (user->invite_room == rm) {
    user->invite_room = NULL;
    *user->invite_by = '\0';
  }
  if (user->vis) {
    switch (teleport) {
    case 0:
      vwrite_room(rm, "%s~RS %s.\n", user->recap, user->in_phrase);
      vwrite_room_except(user->room, user, "%s~RS %s to the %s.\n",
                         user->recap, user->out_phrase, rm->name);
      break;
    case 1:
      vwrite_room(rm, "%s~RS ~FC~OLappears in an explosion of blue magic!\n",
                  user->recap);
      vwrite_room_except(user->room, user,
                         "%s~RS ~FC~OLchants a spell and vanishes into a magical blue vortex!\n",
                         user->recap);
      break;
    case 2:
      write_user(user,
                 "\n~FC~OLA giant hand grabs you and pulls you into a magical blue vortex!\n");
      vwrite_room(rm, "%s~RS ~FC~OLfalls out of a magical blue vortex!\n",
                  user->recap);
#ifdef NETLINKS
      if (!release_nl(user))
#endif
      {
        vwrite_room_except(user->room, user,
                           "~FC~OLA giant hand grabs~RS %s~RS ~FC~OLwho is pulled into a magical blue vortex!\n",
                           user->recap);
      }
      break;
    }

  } else if (user->level < GOD) {
    write_room(rm, invisenter);
    write_room_except(user->room, invisleave, user);
  }
  old_room = user->room;
  user->room = rm;
  reset_access(old_room);
  look(user);
}
Example #3
0
/*
 * 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;
}
Example #4
0
/*
 * clears a room topic
 */
void
clear_topic(UR_OBJECT user)
{
  RM_OBJECT rm;
  const char *name;

  if (word_count < 2) {
    rm = user->room;
    *rm->topic = '\0';
    write_user(user, "Topic has been cleared\n");
    name = user->vis ? user->recap : invisname;
    vwrite_room_except(rm, user, "%s~RS ~FY~OLhas cleared the topic.\n",
                       name);
    return;
  }
  strtolower(word[1]);
  if (!strcmp(word[1], "all")) {
    if (user->level > (enum lvl_value) command_table[CTOPIC].level
        || user->level >= ARCH) {
      for (rm = room_first; rm; rm = rm->next) {
        *rm->topic = '\0';
        write_room_except(rm, "\n~FY~OLThe topic has been cleared.\n", user);
      }
      write_user(user, "All room topics have now been cleared\n");
      return;
    }
    write_user(user,
               "You can only clear the topic of the room you are in.\n");
    return;
  }
  write_user(user, "Usage: ctopic [all]\n");
}
Example #5
0
File: adds.c Project: Lopo/Lotos
/* Restore a user to his original rank from a temp promote.  S.C.  09/27/99 */
void restore(UR_OBJECT user)
{
UR_OBJECT u;

	set_crash();
if (word_count<2) {
   write_usage(user,"restore <user>");
   return;
   }
if (!(u=get_user_name(user,word[1]))) {
   write_user(user, notloggedon);
   return;
   }
if (u->level>u->real_level) {
  u->level=u->real_level;
  vwrite_user(user,"%s Ma odteraz svoj originalny level.\n", u->name);
  vwrite_room_except(u->room,u,"%s begins fading as their power is restored to normal.\n",u->name);
  vwrite_user(u,"Bol obnoveny tvoj originalny level.\n");
  write_syslog(SYSLOG, 1, "%s restored %s to their original level.\n",user->name,u->name);
  sprintf(text,"Had their level restored by %s.\n",user->name);
  add_history(u->name,1,text);
  return;
  }
else {
  write_user(user,"You can't restore a person to their original rank if they're already there.\n");
  return;
  }
}
Example #6
0
/*
 * Wizard moves a user to another room
 */
void
move(UR_OBJECT user)
{
  UR_OBJECT u;
  RM_OBJECT rm;
  const char *name;

  if (word_count < 2) {
    write_user(user, "Usage: move <user> [<room>]\n");
    return;
  }
  u = get_user_name(user, word[1]);
  if (!u) {
    write_user(user, notloggedon);
    return;
  }
  if (u->login) {
    write_user(user, "That user is not logged in.\n");
    return;
  }
  if (word_count < 3) {
    rm = user->room;
  } else {
    rm = get_room(word[2]);
    if (!rm) {
      write_user(user, nosuchroom);
      return;
    }
  }
  if (user == u) {
    write_user(user,
               "Trying to move yourself this way is the fourth sign of madness.\n");
    return;
  }
  if (u->level >= user->level) {
    write_user(user,
               "You cannot move a user of equal or higher level than yourself.\n");
    return;
  }
  if (rm == u->room) {
    vwrite_user(user, "%s~RS is already in the %s.\n", u->recap, rm->name);
    return;
  };
  if (!has_room_access(user, rm)) {
    vwrite_user(user,
                "The %s is currently private, %s~RS cannot be moved there.\n",
                rm->name, u->recap);
    return;
  }
  write_user(user, "~FC~OLYou chant an ancient spell...\n");
  name = user->vis ? user->recap : invisname;
  if (!user->vis) {
    write_monitor(user, user->room, 0);
  }
  vwrite_room_except(user->room, user,
                     "%s~RS ~FC~OLchants an ancient spell...\n", name);
  move_user(u, rm, 2);
  prompt(u);
}
Example #7
0
/*
 * Change whether a rooms access is fixed or not
 */
void
change_room_fix(UR_OBJECT user, int fix)
{
  RM_OBJECT rm;
  const char *name;

  if (word_count < 2) {
    rm = user->room;
  } else {
    rm = get_room(word[1]);
    if (!rm) {
      write_user(user, nosuchroom);
      return;
    }
  }
  if (fix) {
    if (is_fixed_room(rm)) {
      if (rm == user->room) {
        write_user(user, "This room's access is already fixed.\n");
      } else {
        write_user(user, "That room's access is already fixed.\n");
      }
      return;
    }
  } else {
    if (!is_fixed_room(rm)) {
      if (rm == user->room) {
        write_user(user, "This room's access is already unfixed.\n");
      } else {
        write_user(user, "That room's access is already unfixed.\n");
      }
      return;
    }
  }
  rm->access ^= FIXED;
  reset_access(rm);
  write_syslog(SYSLOG, 1, "%s %s access to room %s.\n", user->name,
               is_fixed_room(rm) ? "FIXED" : "UNFIXED", rm->name);
  name = user->vis ? user->recap : invisname;
  if (user->room == rm) {
    vwrite_room_except(rm, user, "%s~RS has %s~RS access for this room.\n",
                       name, is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED");
  } else {
    vwrite_room(rm, "This room's access has been %s~RS.\n",
                is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED");
  }
  vwrite_user(user, "Access for room %s is now %s~RS.\n", rm->name,
              is_fixed_room(rm) ? "~FRFIXED" : "~FGUNFIXED");
}
Example #8
0
File: boards.c Project: Lopo/Lotos
/*** Read the message board ***/
void read_board(UR_OBJECT user)
{
    RM_OBJECT rm=NULL;
    char fname[FNAME_LEN], *name, rmname[ROOM_NAME_LEN+1];
    int ret;

    set_crash();
    if (word_count<2) rm=user->room;
    else {
        if (word_count>=3) {
            if ((rm=get_room(word[1]))==NULL) {
                write_user(user,nosuchroom);
                return;
            }
            read_board_specific(user,rm,atoi(word[2]));
            return;
        }
        if (word_count==2) {
            if (atoi(word[1])) {
                read_board_specific(user,user->room,atoi(word[1]));
                return;
            }
            else {
                if ((rm=get_room(word[1]))==NULL) {
                    write_user(user,nosuchroom);
                    return;
                }
            }
        }
        if (!has_room_access(user,rm)) {
            write_user(user,"That room is currently private, you cannot read the board.\n");
            return;
        }
    }
    vwrite_user(user, message_board_header, rm->name);
    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 (!(ret=more(user, user->socket, fname)))
        vwrite_user(user, read_no_messages, rm->name);
    else if (ret==1) user->misc_op=2;
    if (user->vis) name=user->recap;
    else name=invisname;
    if (rm==user->room) vwrite_room_except(user->room, user, user_read_board_prompt, name);
}
Example #9
0
/*
 * 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);
}
Example #10
0
void pl00x100_respond(UR_OBJECT user, char *str)
{
	char fname[500], line[150], *name;
	int i=0, num=0, total=0;
	FILE *fp;

	set_crash();
	fname[0]='\0';
	line[0]='\0';

	if (word_count<2) {
		write_user(user,"The Magic EightBall will only respond to a question.\n");
		return;
		}
	if (user->vis) name=user->name;
	else name=invisname;

	sprintf(fname,"%s/eightball.8", PLFILES);
	if (!(fp=fopen(fname,"r"))) {
		write_user(user,"EightBall:  Sorry!  Response file was not found.\n");
		return;
		}
	fscanf(fp,"%d\n",&total); /* total file entries */
	num=rand()%total;
	num++;  /* Have to increase because the rand() might leave it 0. */
	/* get the line from the file that contains the random response */
	for (i=0; (i<num && !feof(fp)); i++)
		fgets(line, 161, fp);
	fclose(fp);
	line[strlen(line)-1]='\0';
	terminate(line);

	/* write question to users */
	vwrite_user(user, "%s[You ask the EightBall]%s: %s\n", colors[CSELF], colors[CTEXT], str);
	vwrite_room_except(user->room, user, "%s[%s asks the EightBall]%s: %s\n", colors[CUSER], name, colors[CTEXT], str);
	record(user->room, text);

	/* write response to room */
	vwrite_room(user->room, "~FG[The Magic EightBall]%s: %s\n", colors[CTEXT], line);
	record(user->room, text);
}
Example #11
0
/*
 * 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);
}
Example #12
0
File: boards.c Project: Lopo/Lotos
/*** Write on the message board ***/
void write_board(UR_OBJECT user, char *inpstr, int done_editing)
{
    FILE *fp;
    int cnt,inp;
    char *ptr,*name,fname[FNAME_LEN],rmname[ROOM_NAME_LEN+1];

    set_crash();
    if (user->muzzled) {
        vwrite_user(user, muzzled_cannot, "zapisovat");
        return;
    }
    if (!done_editing) {
        if (word_count<2) {
#ifdef NETLINKS
            if (user->type==REMOTE_TYPE) {
                /* Editor won't work over netlink cos all the prompts will go
                wrong, I'll address this in a later version. */
                write_user(user,"Sorry, due to software limitations remote users cannot use the line editor.\nUse the '.write <mesg>' method instead.\n");
                return;
            }
#endif
            write_user(user, write_edit_header);
            user->misc_op=3;
            editor(user,NULL);
            return;
        }
        ptr=inpstr;
        inp=1;
    }
    else {
        ptr=user->malloc_start;
        inp=0;
    }
    if (user->room->access==PERSONAL_LOCKED || user->room->access==PERSONAL_UNLOCKED) {
        midcpy(user->room->name,rmname,1,strlen(user->room->name)-2);
        rmname[0]=toupper(rmname[0]);
        sprintf(fname,"%s/%s.B", USERROOMS,rmname);
    }
    else sprintf(fname,"%s/%s.B", ROOMFILES, user->room->name);
    if (!(fp=fopen(fname,"a"))) {
        vwrite_user(user,"%s: cannot write to file.\n",syserror);
        write_syslog(ERRLOG,1,"Couldn't open file %s to append in write_board().\n",fname);
        return;
    }
    if (user->vis) name=user->bw_recap;
    else name=invisname;
    /* The posting time (PT) is the time its written in machine readable form, this
       makes it easy for this program to check the age of each message and delete
       as appropriate in check_messages() */
#ifdef NETLINKS
    if (user->type==REMOTE_TYPE) sprintf(text,"PT: %d\r~OLFrom: %s@%s  %s\n",(int)(time(0)),name,user->netlink->service,long_date(0));
    else
#endif
        sprintf(text,"PT: %d\r~OLFrom: %s  %s\n",(int)(time(0)),name,long_date(0));
    fputs(text,fp);
    cnt=0;
    while (*ptr!='\0') {
        putc(*ptr,fp);
        if (*ptr=='\n') cnt=0;
        else ++cnt;
        if (cnt==80) {
            putc('\n',fp);
            cnt=0;
        }
        ++ptr;
    }
    if (inp) fputs("\n\n",fp);
    else putc('\n',fp);
    fclose(fp);
    write_user(user, user_write_end);
    vwrite_room_except(user->room, user, room_write_end, name);
    user->room->mesg_cnt++;
}
Example #13
0
File: boards.c Project: Lopo/Lotos
/* Allows a user to read a specific message number */
void read_board_specific(UR_OBJECT user, RM_OBJECT rm, int msg_number)
{
    FILE *fp;
    int valid,cnt,pt;
    char id[ARR_SIZE],line[ARR_SIZE],fname[FNAME_LEN],*name,rmname[ROOM_NAME_LEN+1];

    set_crash();
    if (!rm->mesg_cnt) {
        vwrite_user(user, read_no_messages, rm->name);
        return;
    }
    if (!msg_number) {
        write_usage(user,"read [<room>] [<message #>]");
        return;
    }
    if (msg_number>rm->mesg_cnt) {
        vwrite_user(user,"There %s only %d message%s posted on the %s board.\n",PLTEXT_IS(rm->mesg_cnt),rm->mesg_cnt,PLTEXT_S(rm->mesg_cnt),rm->name);
        return;
    }
    if (rm!=user->room && !has_room_access(user,rm)) {
        write_user(user,"That room is currently private, you cannot read the board.\n");
        return;
    }
    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 (!(fp=fopen(fname,"r"))) {
        write_user(user,"There was an error trying to read the message board.\n");
        write_syslog(ERRLOG,1,"Unable to open message board for %s in read_board_specific().\n",rm->name);
        return;
    }
    vwrite_user(user, message_board_header, rm->name);
    valid=1;
    cnt=1;
    id[0]='\0';
    fgets(line,ARR_SIZE-1,fp);
    while (!feof(fp)) {
        if (*line=='\n') valid=1;
        sscanf(line,"%s %d",id,&pt);
        if (valid && !strcmp(id,"PT:")) {
            if (msg_number==cnt) {
                while(*line!='\n') {
                    write_user(user,line);
                    fgets(line,ARR_SIZE-1,fp);
                }
            }
            valid=0;
            cnt++;
            if (cnt>msg_number) goto SKIP; /* no point carrying on if read already */
        }
        fgets(line,ARR_SIZE-1,fp);
    }
SKIP:
    fclose(fp);
    vwrite_user(user,"\nMessage number ~FM~OL%d~RS out of ~FM~OL%d~RS.\n\n",msg_number,rm->mesg_cnt);
    if (user->vis) name=user->recap;
    else name=invisname;
    if (rm==user->room)
        if (user->level<GOD || user->vis) vwrite_room_except(user->room,user,"%s~RS reads the message board.\n",name);
}
Example #14
0
File: boards.c Project: Lopo/Lotos
/*** 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);
}
Example #15
0
/*
 * 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");
}
Example #16
0
/*
 * Delete a user
 */
void
delete_user(UR_OBJECT user, int this_user)
{
    char name[USER_NAME_LEN + 1];
    UR_OBJECT u;

    if (this_user) {
        /*
         * User structure gets destructed in disconnect_user(), need to keep a
         * copy of the name
         */
        strcpy(name, user->name);
        write_user(user, "\n~FR~LI~OLACCOUNT DELETED!\n");
        vwrite_room_except(user->room, user, "~OL~LI%s commits suicide!\n",
                user->name);
        write_syslog(SYSLOG, 1, "%s SUICIDED.\n", name);
        disconnect_user(user);
        clean_files(name);
        rem_user_node(name);
        return;
    }
    if (word_count < 2) {
        write_user(user, "Usage: nuke <user>\n");
        return;
    }
    *word[1] = toupper(*word[1]);
    if (!strcmp(word[1], user->name)) {
        write_user(user,
                "Trying to delete yourself is the eleventh sign of madness.\n");
        return;
    }
    if (get_user(word[1])) {
        /* Safety measure just in case. Will have to .kill them first */
        write_user(user,
                "You cannot delete a user who is currently logged on.\n");
        return;
    }
    u = create_user();
    if (!u) {
        vwrite_user(user, "%s: unable to create temporary user object.\n",
                syserror);
        write_syslog(SYSLOG | ERRLOG, 0,
                "ERROR: Unable to create temporary user object in delete_user().\n");
        return;
    }
    strcpy(u->name, word[1]);
    if (!load_user_details(u)) {
        write_user(user, nosuchuser);
        destruct_user(u);
        destructed = 0;
        return;
    }
    if (u->level >= user->level) {
        write_user(user,
                "You cannot delete a user of an equal or higher level than yourself.\n");
        destruct_user(u);
        destructed = 0;
        return;
    }
    clean_files(u->name);
    rem_user_node(u->name);
    vwrite_user(user, "\07~FR~OL~LIUser %s deleted!\n", u->name);
    write_syslog(SYSLOG, 1, "%s DELETED %s.\n", user->name, u->name);
    destruct_user(u);
    destructed = 0;
}
Example #17
0
/*
 * 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");
}
Example #18
0
/*
 * do a promotion of a user that lasts only for the current session
 */
void
temporary_promote(UR_OBJECT user)
{
    UR_OBJECT u;
    enum lvl_value lvl;

    if (word_count < 2) {
        write_user(user, "Usage: tpromote <user> [<level>]\n");
        return;
    }
    u = get_user_name(user, word[1]);
    if (!u) {
        write_user(user, notloggedon);
        return;
    }
    if (u == user) {
        write_user(user,
                "You cannot promote yourself, temporarily or otherwise.\n");
        return;
    }
    /* determine what level to promote them to */
    if (u->level >= user->level) {
        write_user(user,
                "You cannot temporarily promote anyone of the same or greater level than you.\n");
        return;
    }
    if (word_count == 3) {
        lvl = get_level(word[2]);
        if (lvl == NUM_LEVELS) {
            write_user(user, "Usage: tpromote <user> [<level>]\n");
            return;
        }
        if (lvl <= u->level) {
            vwrite_user(user,
                    "You must specify a level higher than %s currently is.\n",
                    u->name);
            return;
        }
    } else {
        lvl = (enum lvl_value) (u->level + 1);
    }
    if (lvl == GOD) {
        vwrite_user(user, "You cannot temporarily promote anyone to level %s.\n",
                user_level[lvl].name);
        return;
    }
    if (lvl >= user->level) {
        write_user(user,
                "You cannot temporarily promote anyone to a higher level than your own.\n");
        return;
    }
    /* if they have already been temp promoted this session then restore normal level first */
    if (u->level > u->real_level) {
        u->level = u->real_level;
    }
    u->real_level = u->level;
    u->level = lvl;
    vwrite_user(user, "You temporarily promote %s to %s.\n", u->name,
            user_level[u->level].name);
    vwrite_room_except(u->room, u,
            "~OL~FG%s~RS~OL~FG starts to glow as their power increases...\n",
            u->bw_recap);
    vwrite_user(u, "~OL~FGYou have been promoted (temporarily) to level %s.\n",
            user_level[u->level].name);
    write_syslog(SYSLOG, 1, "%s TEMPORARILY promote %s to %s.\n", user->name,
            u->name, user_level[u->level].name);
    sprintf(text, "Was temporarily to level %s.\n", user_level[u->level].name);
    add_history(u->name, 1, "%s", text);
}