Exemplo n.º 1
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);
}
Exemplo n.º 2
0
Arquivo: adds.c Projeto: Lopo/Lotos
void follow(UR_OBJECT user)
{
	UR_OBJECT ur;
	int i;

	set_crash();
	for (ur=user_first; ur!=NULL; ur=ur->next) {
		if (strcmp(ur->follow, user->name)) continue;
		if (ur->room==user->room) continue; /* inac by (asi) vznikol nekonecny cyklus */
		if (ur->level<command_table[FOLLOW].level) { /* kvoli demote */
			ur->follow[0]='\0';
			continue;
			}
		if (!has_room_access(ur, user->room)) {
			vwrite_user(ur, "Smola, ale %s is%s do miestnosti, kde ty nemas pristup,\nnemozes %s uz dalej sledovat ...\n",
				user->name, grm_gnd(7, user->gender), grm_gnd(8, user->gender));
			ur->follow[0]='\0';
			continue;
			}
		if (ur->level<WIZ) { /* len ak je do roomy linka */
			if (user->room->transp!=NULL) {
				if ((user->room->transp->go) || user->room->link[user->room->transp->out]!=ur->room) {
					vwrite_user(ur, "Smola, ale %s is%s do miestnosti, kde sa teraz odtialto nedostanes,\nnemozes %s dalej sledovat ...\n",
						user->name, grm_gnd(7, user->gender), grm_gnd(8, user->gender));
					continue;
					}
				vwrite_user(ur, "Sledujes %s do miestnosti %s\n",
					user->name, user->room->name);
				move_user(ur, user->room, 0);
				follow(ur);
				continue;
				}
			else {
				for (i=0; i<MAX_LINKS; ++i) {
					if (ur->room->link[i]==user->room) {
						vwrite_user(ur, "Sledujes %s do miestnosti %s\n",
							user->name, user->room->name);
						move_user(ur, user->room, 0);
						follow(ur);
						continue;
						}
					}
				}
			vwrite_user(ur, "Smola, ale %s is%s do miestnosti, kde sa teraz odtialto nedostanes,\nnemozes %s dalej sledovat ...\n",
				user->name, grm_gnd(7, user->gender), grm_gnd(8, user->gender));
			continue;
			}
		vwrite_user(ur, "Sledujes %s do miestnosti %s\n",
			user->name, user->room->name);
		move_user(ur, user->room, 0);
		follow(ur); /* ak aj jeho niekto sleduje */
		continue;
		}
}
Exemplo n.º 3
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);
}
Exemplo n.º 4
0
Arquivo: boards.c Projeto: Lopo/Lotos
/*** Show list of people board posts are from without seeing the whole lot ***/
void board_from(UR_OBJECT user)
{
    FILE *fp;
    int cnt;
    char id[ARR_SIZE],line[ARR_SIZE],fname[FNAME_LEN],rmname[ROOM_NAME_LEN+1];
    RM_OBJECT rm;

    set_crash();
    if (word_count<2) rm=user->room;
    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;
        }
    }
    if (!rm->mesg_cnt) {
        write_user(user,"That room has no messages on it's 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 message board.\n");
        write_syslog(ERRLOG,1,"Unable to open message board for %s in board_from().\n",rm->name);
        return;
    }
    vwrite_user(user,"\n~FG~BB*** Posts on the %s message board from ***\n\n",rm->name);
    cnt=0;
    line[0]='\0';
    fgets(line,ARR_SIZE-1,fp);
    while (!feof(fp)) {
        sscanf(line,"%s",id);
        if (!strcmp(id,"PT:")) {
            cnt++;
            vwrite_user(user,"~FT%2d)~RS %s", cnt, remove_first(remove_first(remove_first(line))));
        }
        line[0]='\0';
        fgets(line,ARR_SIZE-1,fp);
    }
    fclose(fp);
    vwrite_user(user,"\nTotal of ~OL%d~RS messages.\n\n", rm->mesg_cnt);
}
Exemplo n.º 5
0
/*
 * 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;
}
Exemplo n.º 6
0
Arquivo: boards.c Projeto: 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);
}
Exemplo n.º 7
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);
}
Exemplo n.º 8
0
Arquivo: boards.c Projeto: 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);
}