Beispiel #1
0
Datei: pb-xform.c Projekt: mpw/p2
BOOLEAN
is_member_of (IDENT *s, char *f)
{
  MCURSOR *mcurs = new_mcursor(s);
  char    field[MAX_IDENT_LEN];
  char    *p;

#ifndef NDEBUG
  if (!(aggregate_ctype(s->ctype)))
    assertion_failed("arg 1 to is_member_of must be an aggregate");
#endif /* NDEBUG */

  if (s->members == NULL)
    return(FALSE);

  /* The string f is a field designator, but it also might include index
     offsets, such as in "next2[4]".  We need to strip off the string "[4]"
     in order to do the membership test comparison.  The first step is to
     strip is part of the field string off (DSB). */

  strcpy(field, f);
  p = strchr(field, '[');
  if (p)
    *p = '\0';

  /* Search the list of fields */

  FOREACH_MEMBER(mcurs) {
    if (strcmp(name_of(mcurs),field) == 0)
      return(TRUE);
  }
  return(FALSE);
}
Beispiel #2
0
/*
 * generate_linkage -- make code for the linkage part of an individual
 *	interface. Assumes Bodyfp.
 */
void
generate_linkage(ENTRY *function)
{
	char	*library_name = db_get_current_library(),
		*function_name;
	char	composite_name[MAXLINE];

	errlog(BEGIN, "generate_linkage() {");

	function_name = name_of(function);
	(void) snprintf(composite_name, sizeof (composite_name),
		"%s_%s", library_name, function_name);

	/* Print the predeclaration of the interceptor. */
	generate_interface_predeclaration(composite_name, function);
	/* Collect things we'll use more than once. */

	/* Next the struct used to pass parameters. */
	(void) fprintf(Bodyfp, "static abisym_t __abi_%s_%s_sym;\n",
		library_name, function_name);

	/* The linkage function, */
	generate_linkage_function(library_name, function_name);

	(void) fputs("\n\n", Bodyfp);
	errlog(END, "}");
}
Beispiel #3
0
Datei: pb-xform.c Projekt: mpw/p2
void
copy_member (IDENT *ident, MCURSOR *mcurs)
{
  IDENT *i = new_ident1(MBR, name_of(mcurs), ctype_of(mcurs),
                        members_of(mcurs), FALSE);
  add_ident_to_symlist(&ident->members, i);
}
Beispiel #4
0
			static bool check(lua_State* L, int index, Handler&& handler, record& tracking) {
				tracking.use(1);
				type t = type_of(L, index);
				if (t == type::nil || t == type::none || t == type::function) {
					// allow for nil to be returned
					return true;
				}
				if (t != type::userdata && t != type::table) {
					handler(L, index, type::function, t);
					return false;
				}
				// Do advanced check for call-style userdata?
				static const auto& callkey = name_of(meta_function::call);
				if (lua_getmetatable(L, index) == 0) {
					// No metatable, no __call key possible
					handler(L, index, type::function, t);
					return false;
				}
				if (lua_isnoneornil(L, -1)) {
					lua_pop(L, 1);
					handler(L, index, type::function, t);
					return false;
				}
				lua_getfield(L, -1, &callkey[0]);
				if (lua_isnoneornil(L, -1)) {
					lua_pop(L, 2);
					handler(L, index, type::function, t);
					return false;
				}
				// has call, is definitely a function
				lua_pop(L, 2);
				return true;
			}
Beispiel #5
0
 string resolve_path(string path, string base)
 {
   if (!path.empty() && path[0] == '/') return path; // Absolute
   string const base_name = name_of(base);
   if (base_name == "." || base_name == "..") base += "/";
   else if(!base_name.empty()) base = dir_of(base);
   return base + path;
 }
Beispiel #6
0
Datei: pb-xform.c Projekt: mpw/p2
void
position_member(MCURSOR *mcurs, char *field)
{
  assert(field != 0);
  assert(field[0] != '\0');
  FOREACH_MEMBER(mcurs) {
    if (strcmp(name_of(mcurs),field) == 0)
      return; 
  }
  error("field \"%s\" not a member of aggregate \"%s\"",
        field, mcurs->ident->name);
}
Beispiel #7
0
Datei: pb-xform.c Projekt: mpw/p2
void
print_fields(IDENT *i)
{
  MCURSOR *mcurs = new_mcursor(i);

  printf("name of ident: %s\n", i->name);
  FOREACH_MEMBER(mcurs) {
    printf("%s\n", name_of(mcurs));
  }
  printf("\n");
  xfree(mcurs);
}
Beispiel #8
0
static void x2j_element( store::Item_t const &element,
                         store::Item_t *json_item ) {
  ZORBA_ASSERT( json_item );
  store::Item_t attributes_item;
  vector<store::Item_t> elements;

  push_back( &elements, name_of( element ) );
  x2j_attributes( element, &attributes_item );
  if ( !!attributes_item )
    elements.push_back( attributes_item );
  x2j_children( element, &elements );
  GENV_ITEMFACTORY->createJSONArray( *json_item, elements );
}
Beispiel #9
0
Datei: pb-xform.c Projekt: mpw/p2
char *
type_of (MCURSOR *mcurs)
{
  CTYPE *ctype = ctype_of(mcurs);

  if (ctypematch1(ctype, int_read_only_ctype, TRUE))
    return("int");
  else if (ctypematch1(ctype, string_read_only_ctype, TRUE))
    return("str");
  else {
    warning(3, "illegal mcursor ctype, field %s must be int or str,"
            " assuming int", name_of(mcurs));
    return("int");
  }
}
Beispiel #10
0
bool get_attribute_value( store::Item_t const &element, char const *att_name,
                          zstring *att_value ) {
  store::Iterator_t i( element->getAttributes() );
  bool found = false;
  i->open();
  store::Item_t att_item;
  while ( i->next( att_item ) ) {
    if ( name_of( att_item ) == att_name ) {
      att_item->getStringValue2( *att_value );
      found = true;
      break;
    }
  }
  i->close();
  return found;
}
Beispiel #11
0
void move_inputs(graph_t& graph, graph_t::vertex_descriptor vd)
{
    vertex_ptr v = graph[vd];
    cell::ptr m = v->cell();
    const std::string name = m->name();
#if defined(ECTO_LOGGING)
    const std::size_t tick = v->tick();
#endif

    graph_t::in_edge_iterator inbegin, inend;
    tie(inbegin, inend) = boost::in_edges(vd, graph);

    for (; inbegin != inend; ++inbegin) {
        edge_ptr e = graph[*inbegin];
        if (e->empty()) {
            // TODO (JTF): This can be true if a cell requests a DO_OVER, so how do
            // we validate inputs correctly?
            continue;
        }

        tendril& from = e->front();
        tendril& to = *(m->inputs[e->to_port()]);
        ECTO_LOG_DEBUG("Moving inputs to cell %s: tick=%u, from.tick=%u",
                       name % tick % e->tick());

        try {
            to << from;
        } catch(const ecto::except::EctoException& ex) {
            BOOST_THROW_EXCEPTION(except::CellException()
                                  << except::type(name_of(typeid(ex)))
                                  << except::what(ex.what())
                                  << except::cell_name(name)
                                  << except::when(boost::str(
                                          boost::format("Copying %s to %s")%e->from_port()%e->to_port())));
            throw;
        }
        e->pop_front(); // TODO: Make this use a pool instead of popping (to get rid of allocations).
    }
    // Verify that all inputs have been set.
    m->verify_inputs();
}
Beispiel #12
0
  ReturnCode
  cell::process()
  {
    configure();
    //trigger all parameter change callbacks...
    tendrils::iterator begin = parameters.begin(), end = parameters.end();

    while (begin != end)
    {
      try
      {
        begin->second->notify();
      } catch (const std::exception& e)
      {
        ECTO_TRACE_EXCEPTION("const std::exception& outside of CATCH ALL");
        BOOST_THROW_EXCEPTION(except::CellException()
                              << except::type(name_of(typeid(e)))
                              << except::what(e.what())
                              << except::cell_name(name())
                              << except::function_name(__FUNCTION__)
                              << except::when("While triggering param change callbacks"))
          ;
      }
      ++begin;
    }
    try
    {
      try
      {
        const ReturnCode rc = dispatch_process(inputs, outputs);
        return rc;
      } catch (const boost::thread_interrupted&) {
        ECTO_TRACE_EXCEPTION("const boost::thread_interrupted&, returning QUIT instead of rethrow");
        return ecto::QUIT;
      }
    } CATCH_ALL()
  }
Beispiel #13
0
void
read_scroll(void)
{
	short ch;
	object *obj;
	char msg[DCOLS];

	ch = pack_letter("read what?", SCROL);

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("no such item.", 0);
		return;
	}
	if (obj->what_is != SCROL) {
		message("you can't read that", 0);
		return;
	}
	switch(obj->which_kind) {
		case SCARE_MONSTER:
			message("you hear a maniacal laughter in the distance",
			0);
			break;
		case HOLD_MONSTER:
			hold_monster();
			break;
		case ENCH_WEAPON:
			if (rogue.weapon) {
				if (rogue.weapon->what_is == WEAPON) {
					sprintf(msg, "your %sglow%s %sfor a moment",
					name_of(rogue.weapon),
					((rogue.weapon->quantity <= 1) ? "s" : ""),
					get_ench_color());
					message(msg, 0);
					if (coin_toss()) {
						rogue.weapon->hit_enchant++;
					} else {
						rogue.weapon->d_enchant++;
					}
				}
				rogue.weapon->is_cursed = 0;
			} else {
				message("your hands tingle", 0);
			}
			break;
		case ENCH_ARMOR:
			if (rogue.armor) {
				sprintf(msg, "your armor glows %sfor a moment",
				get_ench_color());
				message(msg, 0);
				rogue.armor->d_enchant++;
				rogue.armor->is_cursed = 0;
				print_stats(STAT_ARMOR);
			} else {
				message("your skin crawls", 0);
			}
			break;
		case IDENTIFY:
			message("this is a scroll of identify", 0);
			obj->identified = 1;
			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
			idntfy();
			break;
		case TELEPORT:
			tele();
			break;
		case SLEEP:
			message("you fall asleep", 0);
			take_a_nap();
			break;
		case PROTECT_ARMOR:
			if (rogue.armor) {
				message( "your armor is covered by a shimmering gold shield",0);
				rogue.armor->is_protected = 1;
				rogue.armor->is_cursed = 0;
			} else {
				message("your acne seems to have disappeared", 0);
			}
			break;
		case REMOVE_CURSE:
				message((!halluc) ?
					"you feel as though someone is watching over you" :
					"you feel in touch with the universal oneness", 0);
			uncurse_all();
			break;
		case CREATE_MONSTER:
			create_monster();
			break;
		case AGGRAVATE_MONSTER:
			aggravate();
			break;
		case MAGIC_MAPPING:
			message("this scroll seems to have a map on it", 0);
			draw_magic_map();
			break;
		case CON_MON:
			con_mon = 1;
			sprintf(msg, "your hands glow %sfor a moment", get_ench_color());
			message(msg, 0);
			break;
	}
	if (id_scrolls[obj->which_kind].id_status != CALLED) {
		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
	}
	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
}
Beispiel #14
0
Datei: stop.c Projekt: dnm/l4v
/* Iterate through processes in the system. */
void
iterate_processes(char **limit, void (*proc_fn)(int, void *), void *data)
{
    /* Open /proc */
    DIR *proc_dir = opendir("/proc");
    if (proc_dir == NULL) {
        fprintf(stderr, "Could not open /proc.");
        exit(1);
    }

    /* Read through processes. */
    while (1) {
        /* Read directory. */
        struct dirent *e = readdir(proc_dir);
        if (e == NULL)
            break;

        /* Skip non-directories. */
        if ((e->d_type & DT_DIR) == 0)
            continue;

        /* Process? */
        int p = atoi(e->d_name);
        if (p == 0)
            continue;

        if (limit != NULL) {
            int skip = 1;

            /* Find the name of the process we're looking at. */
            char name[PATH_MAX];
            if (name_of(p, name, PATH_MAX) != 0)
                /* This process doesn't have a name. Poor thing. */
                continue;

            /* Determine if this process matches any of the processes we should
             * be considering.
             */
            char **l;
            for (l = limit; *l != NULL; l++) {
                if (!strcmp(name, *l)) {
                    skip = 0;
                    break;
                }
                char *last_slash = strrchr(name, '/');
                if (last_slash != NULL && !strcmp(last_slash + 1, *l)) {
                    skip = 0;
                    break;
                }
            }

            if (skip == 1)
                /* No match. */
                continue;

#if DEBUG
            printf("Considering %s...\n", name);
#endif
        }

        proc_fn(p, data);
    }

    /* Cleanup. */
    closedir(proc_dir);
}
Beispiel #15
0
void
get_desc(object *obj, char *desc, bool capitalized)
{
    char *item_name, *p;
    struct id *id_table;
    char more_info[32];
    short i;

    *desc = 0;
    if (obj->what_is == AMULET) {
	(void) strcpy(desc, mesg[27]);
	return;
    }
    item_name = name_of(obj);
    if (obj->what_is == GOLD) {
	znum(desc, obj->quantity, 0);
	strcat(desc, mesg[28]);
	return;
    }
    if (obj->what_is == WEAPON && obj->quantity > 1) {
	znum(desc, obj->quantity, 0);
	strcat(desc, mesg[29]);
    } else if (obj->what_is == FOOD) {
	znum(desc, obj->quantity, 0);
	strcat(desc, (obj->which_kind == RATION) ? mesg[30] : mesg[31]);
	(void) strcat(desc, item_name);
	goto ANA;
    } else if (obj->what_is != ARMOR && obj->quantity > 1) {
	znum(desc, obj->quantity, 0);
	strcat(desc, mesg[32]);
    }
    id_table = get_id_table(obj);

    if (wizard) {
	goto ID;
    }
    if (obj->what_is & (WEAPON | ARMOR | WAND | RING)) {
	goto CHECK;
    }

    switch (id_table[obj->which_kind].id_status) {
    case UNIDENTIFIED:
    CHECK:
	switch (obj->what_is) {
	case SCROL:
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    (void) strcat(desc, mesg[33]);
	    (void) strcat(desc, item_name);
	    break;
	case POTION:
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    (void) strcat(desc, item_name);
	    break;
	case WAND:
	case RING:
	    if (obj->identified ||
		(id_table[obj->which_kind].id_status == IDENTIFIED)) {
		goto ID;
	    }
	    if (id_table[obj->which_kind].id_status == CALLED) {
		goto CALL;
	    }
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    (void) strcat(desc, item_name);
	    break;
	case ARMOR:
	    if (obj->identified) {
		goto ID;
	    }
	    (void) strcpy(desc, id_table[obj->which_kind].title);
	    break;
	case WEAPON:
	    if (obj->identified) {
		goto ID;
	    }
	    (void) strcat(desc, name_of(obj));
	    break;
	}
	break;
    case CALLED:
    CALL:
	switch (obj->what_is) {
	case SCROL:
	case POTION:
	case WAND:
	case RING:
	    p = id_table[obj->which_kind].title;
#if defined( EUC )
	    if (*desc && *p >= ' ' && !(0x80 & *p)) {
		(void) strcat(desc, " ");
	    }
#else /* not EUC(Shift JIS) */
	    if (*desc && (*p >= ' ' && *p <= '~' || *p >= '\240' && *p < '\340')) {
		(void) strcat(desc, " ");
	    }
#endif /* not EUC */
	    (void) strcat(desc, p);
	    (void) strcat(desc, mesg[34]);
	    (void) strcat(desc, item_name);
	    break;
	}
	break;
    case IDENTIFIED:
    ID:
	switch (obj->what_is) {
	case SCROL:
	case POTION:
	    (void) strcat(desc, id_table[obj->which_kind].real);
	    (void) strcat(desc, item_name);
	    break;
	case RING:
	    (void) strcat(desc, id_table[obj->which_kind].real);
	    if (wizard || obj->identified) {
		if ((obj->which_kind == DEXTERITY) ||
		    (obj->which_kind == ADD_STRENGTH)) {
		    strcpy(more_info, "(");
		    znum(more_info, obj->class, 1);
		    strcat(more_info, ")");
		    (void) strcat(desc, more_info);
		}
	    }
	    (void) strcat(desc, item_name);
	    break;
	case WAND:
	    (void) strcat(desc, id_table[obj->which_kind].real);
	    (void) strcat(desc, item_name);
	    if (wizard || obj->identified) {
		strcpy(more_info, "[");
		znum(more_info, obj->class, 0);
		strcat(more_info, "]");
		(void) strcat(desc, more_info);
	    }
	    break;
	case ARMOR:
	    strcpy(desc, "(");
	    znum(desc, obj->d_enchant, 1);
	    strcat(desc, ")");
	    (void) strcat(desc, id_table[obj->which_kind].title);
	    strcpy(more_info, "[");
	    znum(more_info, get_armor_class(obj), 0);
	    strcat(more_info, "]");
	    (void) strcat(desc, more_info);
	    break;
	case WEAPON:
	    strcat(desc, "(");
	    znum(desc, obj->hit_enchant, 1);
	    strcat(desc, ",");
	    znum(desc, obj->d_enchant, 1);
	    strcat(desc, ")");
	    (void) strcat(desc, name_of(obj));
	    break;
	}
Beispiel #16
0
const std::string& name_of()
{
  static const std::string& name_cache =  name_of(typeid(T));
  return name_cache;
}
Beispiel #17
0
void
read_scroll(void)
{
    short ch;
    object *obj;
    char msg[ROGUE_COLUMNS];

    ch = pack_letter(mesg[245], SCROL);

    if (ch == CANCEL) {
	return;
    }
    if (!(obj = get_letter_object(ch))) {
	message(mesg[246], 0);
	return;
    }
    if (obj->what_is != SCROL) {
	message(mesg[247], 0);
	return;
    }
    switch (obj->which_kind) {
    case SCARE_MONSTER:
	message(mesg[248], 0);
	break;
    case HOLD_MONSTER:
	hold_monster();
	break;
    case ENCH_WEAPON:
	if (rogue.weapon) {
	    if (rogue.weapon->what_is == WEAPON) {
		sprintf(msg, mesg[249],
			name_of(rogue.weapon), get_ench_color());
		message(msg, 0);
		if (coin_toss()) {
		    rogue.weapon->hit_enchant++;
		} else {
		    rogue.weapon->d_enchant++;
		}
	    }
	    rogue.weapon->is_cursed = 0;
	} else {
	    message(mesg[250], 0);
	}
	break;
    case ENCH_ARMOR:
	if (rogue.armor) {
	    sprintf(msg, mesg[251], get_ench_color());
	    message(msg, 0);
	    rogue.armor->d_enchant++;
	    rogue.armor->is_cursed = 0;
	    print_stats(STAT_ARMOR);
	} else {
	    message(mesg[252], 0);
	}
	break;
    case IDENTIFY:
	message(mesg[253], 0);
	obj->identified = 1;
	id_scrolls[obj->which_kind].id_status = IDENTIFIED;
	idntfy();
	break;
    case TELEPORT:
	tele();
	break;
    case SLEEP:
	message(mesg[254], 0);
	take_a_nap();
	break;
    case PROTECT_ARMOR:
	if (rogue.armor) {
	    message(mesg[255], 0);
	    rogue.armor->is_protected = 1;
	    rogue.armor->is_cursed = 0;
	} else {
	    message(mesg[256], 0);
	}
	break;
    case REMOVE_CURSE:
	message((!halluc) ? mesg[257] : mesg[258], 0);
	uncurse_all();
	break;
    case CREATE_MONSTER:
	create_monster();
	break;
    case AGGRAVATE_MONSTER:
	aggravate();
	break;
    case MAGIC_MAPPING:
	message(mesg[259], 0);
	draw_magic_map();
	break;
    }
#if !defined( ORIGINAL )
    id_scrolls[obj->which_kind].id_status = IDENTIFIED;
#else /* ORIGINAL */
    if (id_scrolls[obj->which_kind].id_status != CALLED) {
	id_scrolls[obj->which_kind].id_status = IDENTIFIED;
    }
#endif /* ORIGINAL */
    vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
}
Beispiel #18
0
 string stem_of(string path)
 {
   string name = name_of(path);
   string::size_type p = name.rfind('.');
   return p == string::npos ? name : string(name, 0, p);
 }
Beispiel #19
0
 string suffix_of(string path)
 {
   string name = name_of(path);
   string::size_type p = name.rfind('.');
   return p == string::npos ? "" : string(name, p+1);
 }
Beispiel #20
0
void get_desc( object *obj, char *desc, boolean capitalize )
{
	char *item_name;
	struct id *id_table;
	char more_info[32];
	short i;

	if (obj->what_is == AMULET)
	{
		if( capitalize )
			(void) strcpy(desc, "The Amulet of Yendor ") ;
		else
			(void) strcpy(desc, "the Amulet of Yendor ") ;
		return;
	}
	item_name = name_of(obj);

	if (obj->what_is == GOLD)
	{
		sprintf(desc, "%d pieces of gold.", obj->quantity);
		return;
	}

	if (obj->what_is != ARMOR)
	{
		if (obj->quantity == 1)
		{
			if( capitalize )
				(void) strcpy(desc, "A ") ;
			else
				(void) strcpy(desc, "a ") ;
		}
		else
		{
			sprintf(desc, "%d ", obj->quantity);
		}
	}
	if (obj->what_is == FOOD)
	{
		if (obj->which_kind == RATION)
		{
			if (obj->quantity > 1)
			{
				sprintf( desc, "%d rations of %s", obj->quantity, item_name ) ;
			}
			else
			{
				if( capitalize )
					sprintf( desc, "A ration of %s", item_name ) ;
				else
					sprintf( desc, "a ration of %s", item_name ) ;
			}
		}
		// (zerogue 0.4.1) Add stack description for fruits.
		else
		{
			if( obj->quantity > 1 )
				sprintf( desc, "%d %s", obj->quantity, item_name ) ;
			else
			{
				if( capitalize )
					sprintf( desc, "A %s", item_name ) ;
				else
					sprintf( desc, "a %s", item_name ) ;
			}
		}
		goto ANA;
	}
	id_table = get_id_table(obj);

	if (wizard)
	{
		goto ID;
	}
	if (obj->what_is & (WEAPON | ARMOR | WAND | RING))
	{
		goto CHECK;
	}

	switch(id_table[obj->which_kind].id_status)
	{
	case UNIDENTIFIED:
CHECK:
		switch(obj->what_is)
		{
		case SCROLL:
			(void) strcat(desc, item_name);
			(void) strcat(desc, "entitled: ");
			(void) strcat(desc, id_table[obj->which_kind].title);
			break;
		case POTION:
			(void) strcat(desc, id_table[obj->which_kind].title);
			(void) strcat(desc, item_name);
			break;
		case WAND:
		case RING:
			if (obj->identified
			    || (id_table[obj->which_kind].id_status == IDENTIFIED))
			{
				goto ID;
			}
			if (id_table[obj->which_kind].id_status == CALLED)
			{
				goto CALL;
			}
			(void) strcat(desc, id_table[obj->which_kind].title);
			(void) strcat(desc, item_name);
			break;
		case ARMOR:
			if (obj->identified)
			{
				goto ID;
			}
			(void) strcpy(desc, id_table[obj->which_kind].title);
			break;
		case WEAPON:
			if (obj->identified)
			{
				goto ID;
			}
			(void) strcat(desc, name_of(obj));
			break;
		}
		break;
	case CALLED:
CALL:	switch(obj->what_is)
	{
		case SCROLL:
		case POTION:
		case WAND:
		case RING:
			(void) strcat(desc, item_name);
			(void) strcat(desc, "called ");
			(void) strcat(desc, id_table[obj->which_kind].title);
			break;
		}
		break;
	case IDENTIFIED:
ID:		switch(obj->what_is)
		{
		case SCROLL:
		case POTION:
			(void) strcat(desc, item_name);
			(void) strcat(desc, id_table[obj->which_kind].real);
			break;
		case RING:
			if (wizard || obj->identified)
			{
				if ((obj->which_kind == DEXTERITY) ||
					(obj->which_kind == ADD_STRENGTH))
				{
					sprintf(more_info, "%s%d ", ((obj->oclass > 0) ? "+" : ""),
						obj->oclass);
					(void) strcat(desc, more_info);
				}
			}
			(void) strcat(desc, item_name);
			(void) strcat(desc, id_table[obj->which_kind].real);
			break;
		case WAND:
			(void) strcat(desc, item_name);
			(void) strcat(desc, id_table[obj->which_kind].real);
			if (wizard || obj->identified)
			{
				sprintf(more_info, "[%d]", obj->oclass);
				(void) strcat(desc, more_info);
			}
			break;
		case ARMOR:
			sprintf(desc, "%s%d ", ((obj->d_enchant >= 0) ? "+" : ""),
			obj->d_enchant);
			(void) strcat(desc, id_table[obj->which_kind].title);
			sprintf( more_info, "[%d%s%s] ", get_armor_class(obj), (obj->is_protected ? "+" : ""), (obj->is_cursed ? "-" : "") ) ;
			(void) strcat(desc, more_info);
			break;
		case WEAPON:
			sprintf(desc+strlen(desc), "%s%d,%s%d ",
			((obj->hit_enchant >= 0) ? "+" : ""),
			obj->hit_enchant,
			((obj->d_enchant >= 0) ? "+" : ""),
			obj->d_enchant);
			(void) strcat(desc, name_of(obj));
			break;
		}
		break;
	}
ANA:
	if (!strncmp(desc, "a ", 2))
	{
		if (is_vowel(desc[2]))
		{
			for (i = strlen(desc) + 1; i > 1; i--)
			{
				desc[i] = desc[i-1];
			}
			desc[1] = 'n';
		}
	}
	if (obj->in_use_flags & BEING_WIELDED) {
		(void) strcat(desc, "in hand");
	} else if (obj->in_use_flags & BEING_WORN) {
		(void) strcat(desc, "being worn");
	} else if (obj->in_use_flags & ON_LEFT_HAND) {
		(void) strcat(desc, "on left hand");
	} else if (obj->in_use_flags & ON_RIGHT_HAND) {
		(void) strcat(desc, "on right hand");
	}
}
Beispiel #21
0
void read_scroll(void)
{
	short ch;
	object *obj;
	char msg[DCOLS];

	if(blind)
	{
		message("You can't see to read the scroll.",0);
		return;
	}

	ch = pack_letter("Read what?", SCROLL);

	if (ch == ROGUE_KEY_CANCEL)
	{
		return;
	}
	if (!(obj = get_letter_object(ch)))
	{
		message("No such item.", 0);
		return;
	}
	if (obj->what_is != SCROLL)
	{
		message("You can't read that!", 0);
		return;
	}
	switch(obj->which_kind)
	{
		case SCARE_MONSTER:
			message("You hear a maniacal laughter in the distance.", 0);
			break;
		case HOLD_MONSTER:
			hold_monster();
			break;
		case ENCH_WEAPON:
			if (rogue.weapon)
			{
				if (rogue.weapon->what_is == WEAPON)
				{
					sprintf(msg, "Your %sglow%s %sfor a moment.",
					name_of(rogue.weapon),
					((rogue.weapon->quantity <= 1) ? "s" : ""),
					get_ench_color());
					message(msg, 0);
					if (coin_toss())
					{
						rogue.weapon->hit_enchant++;
					}
					else
					{
						rogue.weapon->d_enchant++;
					}
				}
				rogue.weapon->is_cursed = 0;
			}
			else
			{
				message("Your hands tingle.", 0);
			}
			break;
		case ENCH_ARMOR:
			if (rogue.armor)
			{
				sprintf(msg, "Your armor glows %sfor a moment.",
				get_ench_color());
				message(msg, 0);
				rogue.armor->d_enchant++;
				rogue.armor->is_cursed = 0;
				print_stats(STAT_ARMOR);
			}
			else
			{
				message("Your skin crawls.", 0);
			}
			break;
		case IDENTIFY:
			message("This is a scroll of identify.", 0);
			obj->identified = 1;
			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
			identify_item(0) ;
			break;
		case TELEPORT:
			tele();
			/* (zerogue 0.4.0) The first time a rogue uses this scroll,
			 * he is briefly confused.
			 */
			if( ! obj->identified && id_scrolls[obj->which_kind].id_status != IDENTIFIED )
				confused += get_rand(0,5) ;
			break;
		case SLEEP:
			sleepify(obj) ;
			break ;
		case PROTECT_ARMOR:
			if (rogue.armor)
			{
				message("Your armor is covered by a shimmering gold shield.", 0);
				rogue.armor->is_protected = 1;
				rogue.armor->is_cursed = 0;
			}
			else
			{
				message("Your acne seems to have disappeared.", 0);
			}
			break;
		case REMOVE_CURSE:
				message((!halluc) ?
					"You feel as though someone is watching over you." :
					"You feel in touch with the universal oneness.", 0);
			uncurse_all();
			break;
		case CREATE_MONSTER:
			/* (zerogue 0.4.0) A summoned monster is briefly confused. */
			create_monster(1) ;
			break;
		case AGGRAVATE_MONSTER:
			aggravate();
			break;
		case MAGIC_MAPPING:
			message("This scroll seems to have a map on it.", 0);
			draw_magic_map();
			break;
	}
	if (id_scrolls[obj->which_kind].id_status != CALLED)
	{
		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
	}
	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
}