Esempio n. 1
0
static ssize_t
pdt_write(void *handle, char *buf, size_t size)
{ pdt_console *c = find_console(NULL, handle);
  char *e = buf+size;
  size_t written = 0;

  while(buf < e)
  { char *em;
    ssize_t rc;

    for(em=buf; *em != ESC && em < e; em++)
      ;
    rc = (*c->org_output_functions->write)(handle, buf, em-buf);
    if ( rc < 0 )
      return rc;
    written += (em-buf);
    if ( rc != (em-buf) )
      return written;
    if ( em != e )
    { static char esc[2] = {ESC,ESC};

      if ( (*c->org_output_functions->write)(handle, esc, 2) != 2 )
	return -1;
      em++;
    }
    buf = em;
  }

  return written;
}
Esempio n. 2
0
void set_prompt(dbref console)
{
  hship *ship;
  hconsole *con;
  char *prompt;
  dbref player;

  if (IsShip(console))
  {
    con = NULL;
    ship = find_ship_by_nav(console);
    prompt = &(ship->prompt);
  }
  else if (IsConsole(console))
  {
    con = find_console(console);
    if (!con)
    {
      notify_console(console, "Unable to find console! Contact your local flight mechanic immediately!");
      return;
    }
    
    ship = find_ship(console);
    prompt = &(con->prompt);
  }
  else
  {
    ship = NULL;
    con = NULL;
  }
  
  if (!ship || !prompt)
  {
    notify_console(console, "Unable to find ship! Contact your local flight mechanic immediately!");
    return;
  }

  player = get_user(console);
  if (!IsPlayer(player))
  {
    notify_console(console, "Only players may receive prompts.");
    return;
  }

  *prompt = HasFlag(atr_parse_integer(player, "HSPROMPT_FREQUENCY", 1), HS_PROMPT_FREQUENCY);
  FlagOn(*prompt, atr_parse_flags(player, hs_prompt_flags, "HSPROMPT_FLAGS"));
  
  hs_std_notice(console, "Prompt flags reloaded.");
  return;
}
Esempio n. 3
0
/* unman console command */
void unman_console(dbref player)
{
  dbref curman, console;
  hship *ship;
  hconsole *con;

  console = atr_parse_dbref(player, "MANNING");
  if (!IsConsole(console) && !IsShip(console))
  {
    notify(player, "You are not manning a console.");
    return;
  }
  
  curman = get_user(console);
  
  if (curman != player)
  {
    notify(player, "You aren't manning that.");
    return;
  }
  
  ship = find_ship_by_nav(console);
  if (!ship)
  {
    con = find_console(console);
    if (!con)
    {
      notify(player, "That console has not been activated.");
      return;
    }
    
    load_weapon(console, &(con->primary), HS_PRIMARY);
    load_weapon(console, &(con->secondary), HS_SECONDARY);
  } else {
    load_weapon(console, &(ship->primary), HS_PRIMARY);
    load_weapon(console, &(ship->secondary), HS_SECONDARY);
  }

  set_user(console, NOTHING);
  notify(player, tprintf("You unman the %s.", Name(console)));
  notify_except(console, Location(console), player,
             tprintf("%s unmans the %s.", Name(player), Name(console)), 0);

  execute_trigger(console, "AUNMAN", ship);
}
Esempio n. 4
0
static ssize_t
pdt_read(void *handle, char *buf, size_t size)
{ pdt_console *c = find_console(handle, NULL);
  IOSTREAM *out;

  if ( c &&
       PL_ttymode(Suser_input) == PL_RAWTTY  &&
       (out = Suser_output) )
  { ssize_t rc;
    static char go_single[] = {ESC, 's'};

    if ( (*c->org_output_functions->write)(out->handle, go_single, 2) == 2 )
    { rc = (*c->org_input_functions->read)(handle, buf, 2);
      if ( rc == 2 )
	rc = 1;				/* drop \n */
      return rc;
    }
  }

  return (*c->org_input_functions->read)(handle, buf, size);
}
Esempio n. 5
0
static foreign_t
pdt_wrap_console()
{ IOSTREAM *in, *out;

  if ( (in=Suser_input) && (out=Suser_output) )
  { pdt_console *c;

    assert(in->functions->read != pdt_read);
    assert(out->functions->write != pdt_write);

    if ( (c=find_console(in->handle, out->handle)) )
    { in->functions = &c->input_functions;
      in->functions->read  = pdt_read;
      in->functions->close = pdt_close_in;
      out->functions = &c->output_functions;
      out->functions->write = pdt_write;
      out->functions->close = pdt_close_out;
    }
  }

  return TRUE;
}
Esempio n. 6
0
/* man console command */
void man_console(dbref player, char *where)
{
  hship *ship;
  hconsole *con;
  dbref   console;
  dbref   manner, manning;
  hweapon *pri, *sec;
  char *prompt;
  int ptype, stype, type;

  if (Typeof(player) != TYPE_PLAYER && hs_options.forbid_puppets)
  {
    notify(player, "Only players may man this console.");
    return;
  }
  
  console = match_result(player, where, TYPE_THING, MAT_NEAR_THINGS);

  switch (console)
  {
  case NOTHING:
    notify(player, "I don't see that here.");
    return;

  case AMBIGUOUS:
    notify(player, "I don't know which you mean!");
    return;
  }

  /* don't need to do this now because we want to allow you
     to reman consoles easily for equipment changes */

  /*manner = get_user(console);
  if (manner == player)
  {
    notify(player, "You are already manning that console.");
    return;
  }*/

  if (!IsConsole(console) && !IsShip(console))
  {
    notify(player, "You cannot man that.");
    return;
  }
  
  if (IsConsole(console))
  {
    con = find_console(console);
    if (!con)
    {
      notify(player, "That console has not been activated.");
      return;
    }
    
    pri = &(con->primary);
    sec = &(con->secondary);
    prompt = &(con->prompt);
    
    ship = find_ship(console);
  }
  else if (IsShip(console))
  {
    con = NULL;
    ship = find_ship_by_nav(console);
    
    if (ship)
    {
      pri = &(ship->primary);
      sec = &(ship->secondary);
      prompt = &(ship->prompt);
    }
    
  } else{
    ship = NULL;
  }
  
  if (!ship)
  {
    notify(player, "Invalid ship object. Please contact your flight mechanic immediately!");
    return;
  }
    

  if (InCombat(ship))
  {
    notify(player, "Can't reload weapons in combat!");
    stype = sec->type;
    ptype = pri->type;
  } else {
    ptype = load_weapon(player, pri, HS_PRIMARY);
    stype = load_weapon(player, sec, HS_SECONDARY);
  }
  
  type = HasFlag(ptype | stype, HS_ANY_WEAPON);

  if (con)
  {
    /* this is an auxiliary console */
    /* no missiles on the aux consoles */
    if (HasFlag(type, HS_MISSILE))
    {
      clear_weapon(pri);
      clear_weapon(sec);
      
      notify(player, "You may not man an auxiliary console with missiles equipped.");
      return;
    }
    
    if (HasFlag(type, HS_WIRETAP))
      con->type = HS_OPS;
    else if (HasFlag(type, HS_CAPACITOR))
      con->type = HS_ENG;
    else if (HasFlag(type, HS_CANNON | HS_EMITTER | HS_WEAPON))
      con->type = HS_GUN;
    else
      con->type = HS_CIV;
    
  } else {
    /* this is a nav console */
    /* no cans, caps or taps */
    
    if (HasFlag(type, HS_CANNON))
    {
      clear_weapon(pri);
      clear_weapon(sec);
      
      notify(player, "You may not man a navigation console with a cannon equipped.");
      return;
    }
  }
  
  /* the equipment slots check out, and the console
     has been set to the appropriate type, if needed */

  if (prompt)
  {
    *prompt = HasFlag(atr_parse_integer(player, "HSPROMPT_FREQUENCY", 1), HS_PROMPT_FREQUENCY);
    FlagOn(*prompt, atr_parse_flags(player, hs_prompt_flags, "HSPROMPT_FLAGS"));
  }
  
  manning = get_console(player);
  if (manning != NOTHING)
  {
    manner = get_user(manning);
    if (manner == player)
    {
      con = find_console(manning);
      if (con)
      {
        load_weapon(manning, &(con->primary), HS_PRIMARY);
        load_weapon(manning, &(con->secondary), HS_SECONDARY);
      }
      
      set_user(manning, NOTHING);
      
      notify(player, tprintf("You unman the %s.", Name(manning)));
      notify_except(manning, Location(manning), player,
              tprintf("%s unmans the %s.", Name(player), Name(manning)), 0);
    }
  }
  
  /* set the HSPACE attribute in case something was fishy */
  if (!IsSim(ship->objnum))
  {
    atr_add(player, "HSPACE", unparse_dbref(ship->objnum), hs_options.space_wiz, 0);
  }

  set_user(console, player);

  execute_trigger(console, "AMAN", ship);

  if (con)
  {
    notify(player, tprintf("You man the %s (%s%s%s).", Name(console),
          ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL));
    notify_except(console, Location(console), player,
    	  tprintf("%s mans the %s (%s%s%s).", Name(player), Name(console),
    	  ANSI_HILITE, STR(hs_console_types, con->type), ANSI_NORMAL), 0);
  } else {
    notify(player, tprintf("You man the %s.", Name(console)));
    notify_except(console, Location(console), player,
    	  tprintf("%s mans the %s.", Name(player), Name(console)), 0);
  }
}