Пример #1
0
void stp_init(unsigned int size)
{
	unsigned char	*na_page[2];

	if (lasttop != 0)
	{
		na_page[0] = na_page[1]
			   = stringpool.top + sizeof(int4);
		reset_access(na_page, stringpool.prvprt);
	}

	/* Allocate the size requested plus one longword so that loops that index through the stringpool can go one
	   iteration beyond the end of the stringpool without running off the end of the allocated memory region.
	   After the requested size plus the extra longword, allocate an additional region two machine pages int4 in
	   order to ensure that this additional region contains at least one aligned machine page; mark that aligned
	   page non-accessible so that memory accesses too far beyond the intended end of the stringpool (caused by
	   "runaway" loops, for example) will cause ACCVIO errors.
	*/
	stringpool.base = stringpool.free
			= (unsigned char *) malloc (size + sizeof(int4) + 2*OS_PAGE_SIZE);

	na_page[0] = na_page[1]
		   = (unsigned char *)
		(((unsigned) stringpool.base + size + sizeof(int4) + 2*OS_PAGE_SIZE & ~(OS_PAGE_SIZE - 1)) - OS_PAGE_SIZE);

	stringpool.lasttop = lasttop;
	lasttop = stringpool.top
		= na_page[0] - sizeof(int4);

	set_noaccess (na_page, &stringpool.prvprt);

	return;
}
Пример #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);
}
Пример #3
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");
}