コード例 #1
0
ファイル: c-xtra2.c プロジェクト: jjrh/mangband
/** Open channel **/
void do_chat_open(int id, cptr name)
{
	int i, free = -1;

	/* Find free and duplicates */
	for (i = 0; i < MAX_CHANNELS; i++)
	{
		if (free == -1 && STRZERO(channels[i].name)) { free = i; continue; }
		if (!strcmp(channels[i].name, name)) return;
	}

	/* Found free slot */
	if ((i = free) != -1)
	{
		/* Copy info */
		strcpy(channels[i].name, name);
		channels[i].id = id;

		/* Highlight 
		p_ptr->on_channel[n] = TRUE; */

		/* Window fix */
		p_ptr->window |= PW_MESSAGE_CHAT;
	}
}
コード例 #2
0
ファイル: control.c プロジェクト: jjrh/mangband
/*
 * Return information about a specific player
 */
static void console_whois(connection_type* ct, char *name)
{
	int i, len;
	u16b major, minor, patch, extra;
	char brave[15]; //output[1024]; 
	player_type *p_ptr, *p_ptr_search;

	p_ptr = 0;

	/* Find this player */
	for (i = 1; i <= NumPlayers; i++)
	{
		p_ptr_search = Players[i];
		len = strlen(p_ptr_search->name);
		if (!my_strnicmp(p_ptr_search->name, name, len))
		{
			p_ptr = p_ptr_search;
		}
	}
	if (!p_ptr)
	{
		cq_printf(&ct->wbuf, "%T", "No such player\n");
		return;
	}
	
	/* Output player information */

	/* General character description */
	(p_ptr->no_ghost) ? strcpy(brave,"brave \0") : strcpy(brave,"\0"); 
	cq_printf(&ct->wbuf, "%T", format("%s is a %slevel %d %s %s at %d ft\n", 
		p_ptr->name, brave, p_ptr->lev, p_name + p_info[p_ptr->prace].name,
		c_name + c_info[p_ptr->pclass].name, p_ptr->dun_depth*50));
	
	/* Breakup the client version identifier */
	major = (p_ptr->version & 0xF000) >> 12;
	minor = (p_ptr->version & 0xF00) >> 8;
	patch = (p_ptr->version & 0xF0) >> 4;
	extra = (p_ptr->version & 0xF);

	/* Player connection info */
	cq_printf(&ct->wbuf, "%T", format("(%s@%s [%s] v%d.%d.%d.%d)\n", 
		p_ptr->realname, p_ptr->hostname, p_ptr->addr, major, minor, patch, extra));

	/* Other interesting factoids */
	if ( p_ptr->lives > 0 )
		cq_printf(&ct->wbuf, "%T", format("Has resurected %d times.\n", p_ptr->lives));
	if ( p_ptr->max_dlv == 0 )
		cq_printf(&ct->wbuf, "%T", format("Has never left the town!\n"));
	else
		cq_printf(&ct->wbuf, "%T", format("Has ventured down to %d ft\n", p_ptr->max_dlv*50));
	i = p_ptr->msg_hist_ptr-1;
	if( i >= 0 )
	{
		if (!STRZERO(p_ptr->msg_log[i]))
		{
			cq_printf(&ct->wbuf, "%T", format("Last message: %s\n", p_ptr->msg_log[i]));
		}
	}
}
コード例 #3
0
ファイル: control.c プロジェクト: jjrh/mangband
/*
 * Start listening to game server messages
 */
static void console_listen(connection_type* ct, char *channel)
{
	console_connection *cn = ct->uptr;
	int i;
	if (channel && !STRZERO(channel)) {
		for (i = 0; i < MAX_CHANNELS; i++)
		{
			if (!strcmp(channels[i].name, channel))
			{
				cn->on_channel[i] = 1; 
				break;
			}
		}
	}
	cn->listen = TRUE;
}
コード例 #4
0
ファイル: c-xtra2.c プロジェクト: jjrh/mangband
/** Close channel **/
void do_chat_close(int id)
{
	int i, j;

	for (i = 0; i < MAX_CHANNELS; i++)
	{
		if (channels[i].id == id)
		{
			if (view_channel == i)
				cmd_chat_cycle(-1);

			for (j = 0; j < message_num(); j++)
			{
				u16b type = message_type(j);
				if (type == MSG_CHAT + id)
				{
					c_message_del(j);
				}
			}

			channels[i].name[0] = '\0';
			channels[i].id = 0;

			if (p_ptr->main_channel == i)
				p_ptr->main_channel = 0;

			if (STRZERO(channels[view_channel].name))
				cmd_chat_cycle(+1);

			/* Window update */
			p_ptr->window |= PW_MESSAGE_CHAT;

			break;
		}
	}
}
コード例 #5
0
ファイル: xbexpfnc.cpp プロジェクト: utech/UtechLib
/*!
  \param String
*/
char * xbExpn::STRZERO( const char * String )
{
  return STRZERO( String, 10, 0 );
}
コード例 #6
0
ファイル: xbexpfnc.cpp プロジェクト: utech/UtechLib
/*!
  \param String
  \param length
*/
char * xbExpn::STRZERO( const char * String, xbShort length )
{
  return STRZERO( String, length, 0 );
}
コード例 #7
0
ファイル: xbexpfnc.cpp プロジェクト: utech/UtechLib
/*!
  \param d
*/
char * xbExpn::STRZERO( xbDouble d )
{
  return STRZERO( d, 10, 0 );
}
コード例 #8
0
ファイル: xbexpfnc.cpp プロジェクト: utech/UtechLib
/*!
  \param d
  \param length
*/
char * xbExpn::STRZERO( xbDouble d, xbShort length )
{
  return STRZERO( d, length, 0 );
}
コード例 #9
0
ファイル: xbexpfnc.cpp プロジェクト: utech/UtechLib
/*!
  \param Func
*/
xbShort xbExpn::ProcessFunction( char * Func )
{
/* 1 - pop function from stack
   2 - verify function name and get no of parms needed 
   3 - verify no of parms >= remainder of stack
   4 - pop parms off stack
   5 - execute function
   6 - push result back on stack
*/


  char   *buf = 0;
  xbExpNode *p1, *p2, *p3, *WorkNode, *FuncNode;
  xbShort  ParmsNeeded,len;
  char   ptype = 0;  /* process type s=string, l=logical, d=double */
  xbDouble DoubResult = 0;
  xbLong   IntResult = 0;
  FuncNode = (xbExpNode *) Pop();

  ParmsNeeded = GetFuncInfo( Func, 1 );

  if( ParmsNeeded == -1 ) {
    return XB_INVALID_FUNCTION;
  }
  else {
    ParmsNeeded = 0;
    if( FuncNode->Sibling1 ) ParmsNeeded++;
    if( FuncNode->Sibling2 ) ParmsNeeded++;
    if( FuncNode->Sibling3 ) ParmsNeeded++;
  }

  if( ParmsNeeded > GetStackDepth())
    return XB_INSUFFICIENT_PARMS;

  p1 = p2 = p3 = NULL;
  if( ParmsNeeded > 2 ) p3 = (xbExpNode *) Pop(); 
  if( ParmsNeeded > 1 ) p2 = (xbExpNode *) Pop(); 
  if( ParmsNeeded > 0 ) p1 = (xbExpNode *) Pop(); 
  memset( WorkBuf, 0x00, WorkBufMaxLen+1);

  if( strncmp( Func, "ABS", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = ABS( GetDoub( p1 ));
  }
  else if( strncmp( Func, "ASC", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = ASC( p1->StringResult );
  }
  else if( strncmp( Func, "AT", 2 ) == 0 ) {  
    ptype = 'd';
    DoubResult = AT( p1->StringResult, p2->StringResult );
  }
  else if( strncmp( Func, "CDOW", 4 ) == 0 ) {  
    ptype = 's';
    buf = CDOW( p1->StringResult );
  }
  else if( strncmp( Func, "CHR", 3 ) == 0 ) {  
    ptype = 's';
    buf = CHR( GetInt( p1 ));
  }
  else if( strncmp( Func, "CMONTH", 6 ) == 0 ) {  
    ptype = 's';
    buf = CMONTH( p1->StringResult );
  }
  else if( strncmp( Func, "CTOD", 4 ) == 0 ) {  
    ptype = 's';
    buf = CTOD( p1->StringResult );
  }
  else if( strncmp( Func, "DATE", 4 ) == 0 ) {  
    ptype = 's';
    buf = DATE();
  }
  else if( strncmp( Func, "DAY", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = DAY( p1->StringResult );
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'C' ) {  
    ptype = 's';
    buf = DESCEND( p1->StringResult.c_str() );
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'N' ) {  
    ptype = 'd';
    DoubResult = DESCEND( GetDoub( p1 ));
  }
  else if( strncmp( Func, "DESCEND", 7 ) == 0 && p1->ExpressionType == 'D' ) {  
    xbDate d( p1->StringResult );
    ptype = 'd';
    DoubResult = DESCEND( d );
  }
  else if( strncmp( Func, "DOW", 3 ) == 0 ) {
    ptype = 'd';
    DoubResult = DOW( p1->StringResult );
  }
  else if( strncmp( Func, "DTOC", 4 ) == 0 ) {  
    ptype = 's';
    buf = DTOC( p1->StringResult );
  }
  else if( strncmp( Func, "DTOS", 4 ) == 0 ) {  
    ptype = 's';
    buf = DTOS( p1->StringResult );
  }
  else if( strncmp( Func, "EXP", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = EXP( GetDoub( p1 ));
  }
  else if( strncmp( Func, "IIF", 3 ) == 0 ){
    ptype = 's';
    buf = IIF( p1->IntResult, p2->StringResult, p3->StringResult );
  }
  else if( strncmp( Func, "INT", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = INT( GetDoub( p1 ));
  }
  else if( strncmp( Func, "ISALPHA", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISALPHA( p1->StringResult );
  }
  else if( strncmp( Func, "ISLOWER", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISLOWER( p1->StringResult );
  }
  else if( strncmp( Func, "ISUPPER", 7 ) == 0 ) {  
    ptype = 'l';
    IntResult = ISUPPER( p1->StringResult );
  }
  else if( strncmp( Func, "LEN", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = LEN( p1->StringResult );
  }
  else if( strncmp( Func, "LEFT", 4 ) == 0 ) {  
    ptype = 's';
    buf = LEFT( p1->StringResult, INT( p2->DoubResult ));
  }
  else if( strncmp( Func, "LTRIM", 5 ) == 0 ) {  
    ptype = 's';
    buf = LTRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "LOG", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = LOG( GetDoub( p1 ));
  }  
  else if( strncmp( Func, "LOWER", 5 ) == 0 ) {  
    ptype = 's';
    buf = LOWER( p1->StringResult );
  }  
  else if( strncmp( Func, "MAX", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MAX( GetDoub( p1 ), GetDoub( p2 ));
  }  
  else if( strncmp( Func, "MIN", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MIN( GetDoub( p1 ), GetDoub( p2 ));
  }  
  else if( strncmp( Func, "MONTH", 5 ) == 0 ) {  
    ptype = 'd';
    DoubResult = MONTH( p1->StringResult );
  } 

  else if( strncmp( Func, "RECNO", 5 ) == 0 )
  {
    ptype = 'd';
    DoubResult = RECNO( FuncNode->dbf );
  }

  else if( strncmp( Func, "REPLICATE", 9 ) == 0 ) {
    ptype = 's';
    buf = REPLICATE( p1->StringResult, GetInt( p2 ));
  }
  else if( strncmp( Func, "RIGHT", 5 ) == 0 ) {
    ptype = 's';
    buf = RIGHT( p1->StringResult, GetInt( p2 ));
  }
  else if( strncmp( Func, "RTRIM", 5 ) == 0 ) {  
    ptype = 's';
    buf = RTRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "SPACE", 5 ) == 0 ) {  
    ptype = 's';
    buf = SPACE( INT( GetDoub( p1 )));
  }
  else if( strncmp( Func, "SQRT", 4 ) == 0 ) {  
    ptype = 'd';
    DoubResult = SQRT( GetDoub( p1 ));
  }
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 1 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult );
  }   
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 2 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult, GetInt( p2 ));
  }   
  else if( strncmp( Func, "STRZERO", 7 ) == 0 && ParmsNeeded == 3 ) {
    ptype = 's';
    buf = STRZERO( p1->StringResult, GetInt( p2 ), GetInt( p3 ));
  }   

  else if( strncmp( Func, "STR", 3 ) == 0 && p3 ) {
    ptype = 's';
    if(p1->ExpressionType == 'N')
      buf = STR( p1->DoubResult, GetInt( p2 ), GetInt( p3 ));
    else
      buf = STR( p1->StringResult, GetInt( p2 ), GetInt( p3 ));
  }   

  else if( strncmp( Func, "STR", 3 ) == 0 && p2 ) {
    ptype = 's';
    buf = STR( p1->StringResult, GetInt( p2 ));
  }

  else if( strncmp( Func, "STR", 3 ) == 0 && p1 ) {
    ptype = 's';
    buf = STR( p1->StringResult );
  }
   
  else if( strncmp( Func, "SUBSTR", 6 ) == 0 ) {
    ptype = 's';
    buf = SUBSTR( p1->StringResult, GetInt( p2 ), GetInt( p3 )); 
  }
  else if( strncmp( Func, "TRIM", 4 ) == 0 ) {  
    ptype = 's';
    buf = TRIM( p1->StringResult );
  }  
  else if( strncmp( Func, "UPPER", 5 ) == 0 ) {  
    ptype = 's';
    buf = UPPER( p1->StringResult );
  }  
  else if( strncmp( Func, "VAL", 3 ) == 0 ) {  
    ptype = 'd';
    DoubResult = VAL( p1->StringResult );
  }  
  else if( strncmp( Func, "YEAR", 4 ) == 0 ) {  
    ptype = 'd';
    DoubResult = YEAR( p1->StringResult );
  }  
  if( p1 && !p1->InTree ) delete p1;
  if( p2 && !p2->InTree ) delete p2;
  if( p3 && !p3->InTree ) delete p3;
  if( !FuncNode->InTree ) delete FuncNode;
  if( buf ){
    len = strlen( buf );
    WorkNode = new xbExpNode;
    if( !WorkNode )
      return XB_NO_MEMORY;
    WorkNode->ResultLen = len + 1;
    
  } else {    
    len = 0;
    WorkNode = new xbExpNode;
    if( !WorkNode )
      return XB_NO_MEMORY;
    WorkNode->ResultLen = 0;
  }

  switch( ptype ){
   case 's':                               /* string or char result */
    WorkNode->DataLen = len;
    WorkNode->ExpressionType = 'C';
    WorkNode->Type = 's';
    WorkNode->StringResult = buf;
    break;
   case 'd':                               /* numeric result */
    WorkNode->DataLen = 0;
    WorkNode->ExpressionType = 'N';
    WorkNode->Type = 'd';
    WorkNode->DoubResult = DoubResult;
    break;
   case 'l':                               /* logical result */
    WorkNode->DataLen = 0;
    WorkNode->ExpressionType = 'L';
    WorkNode->Type = 'l';
    WorkNode->IntResult = IntResult;
    break;
   default:
    std::cout << "\nInternal error. " << ptype;
    break;
  }
  Push(WorkNode);
  return XB_NO_ERROR;
}
コード例 #10
0
ファイル: control.c プロジェクト: jjrh/mangband
int console_read(int data1, data data2) { /* return -1 on error */
	connection_type *ct = data2;
	console_connection *cn = ct->uptr;//e_find(first_console, ct, NULL);

	int start_pos;
	int buflen;
	int i, j;

	char buf[1024];
	char *params;	

	/* Parse "read buffer" */
	while (	cq_len(&ct->rbuf) )
	{
		/* Ensure string is ready */
		start_pos = ct->rbuf.pos;
		if (cq_scanf(&ct->rbuf, "%T", buf) < 1)
		{
			/* String not ready */
			ct->rbuf.pos = start_pos;
			return 0;
		}

		/* Hijack input for login */
		if (cn->auth == FALSE)
		{
			/* Check for illegal accesses */
			if (!cfg_console_password || strcmp(buf, cfg_console_password))
			{
				/* Bail out! */
				plog(format("{CON} Authentication failure %s", ct->host_addr));				
				cq_printf(&ct->wbuf, "%T", "Invalid password\n");
				return -1;		
			}
			/* Move on */
			cn->auth = TRUE;
			cq_printf(&ct->wbuf, "%T", "Authenticated\n");
			continue;
		}

		/* Paranoia to ease ops-coder's life later */
		if (STRZERO(buf)) break;

		/* Split up command and params */
		if( (params = strstr(buf," ")) )
		{
			*params++ = '\0';
		}
		else
		{
			params = NULL;
		}

		/* Execute console command */
		buflen = strlen(buf);
		for (i = 0; i < command_len; i++) 
		{
			if (!strncmp(buf, console_commands[i].name, (j = strlen(console_commands[i].name)) ) && (buflen <= j || buf[j] == ' ')) 
			{
				(console_commands[i].call_back)(ct, params);				
				break;
			}
		}
	}

	/* Ok */
	return 0;
}
コード例 #11
0
ファイル: c-spell.c プロジェクト: mangband/mangband
/* Get spell by name */
bool get_spell_by_name(int *k, int *s, bool inven, bool equip, bool books)
{
	char buf[256];
	char *tok;
	int i, sn;
	size_t len;
	bool book_matched = FALSE;
	char *prompt = "Spell name: ";

	/* Hack -- show opening quote symbol */
	if (prompt_quote_hack) prompt = "Spell name: \"";

	buf[0] = '\0';
	if (!get_string(prompt, buf, 80))
	{
		return FALSE;
	}

	/* Hack -- remove final quote */
	len = strlen(buf);
	if (len == 0) return FALSE;
	if (buf[len-1] == '"') buf[len-1] = '\0';

	/* Split entry */
	tok = strtok(buf, "|");
	while (tok)
	{
		if (STRZERO(tok)) continue;
		/* Match against valid items */
		for (i = 0; i < INVEN_TOTAL; i++)
		for (sn = 0; sn < PY_MAX_SPELLS; sn++)
		{
			if (spell_info[i][sn][0] == '\0') break;
			if (!inven && i < INVEN_WIELD) continue;
			if (!equip && i >= INVEN_WIELD) continue;
			if (inventory[i].tval == 0) continue;

			/* Book-name match */
			if (/*get_item_okay(i) &&*/
			   books &&
			   my_stristr(inventory_name[i], tok))
			{
				(*k) = i;
				(*s) = -1;
				book_matched = TRUE;
			}

			/* Spell-name match */
			if (my_stristr(spell_info[i][sn], tok))
			{
				(*k) = i;
				(*s) = sn;
				/* Hack - also ask for projection */
				if (spell_flag[(i * SPELLS_PER_BOOK + sn)] & PY_SPELL_PROJECT)
				{
					if (get_check("Project? "))
						(*s) += SPELL_PROJECTED;
				}
				return TRUE;
			}
		}
		tok = strtok(NULL, "|");
	}
	if (books && book_matched) return TRUE;
	return FALSE;
}
コード例 #12
0
ファイル: load2.c プロジェクト: evileye-uk/mangband
 /* For wilderness levels, dun_depth has been changed from 1 to 4 bytes. */
static void rd_item(object_type *o_ptr)
{
	byte old_dd;
	byte old_ds;

	u32b f1, f2, f3;

	object_kind *k_ptr;

	char note[128];

	start_section_read("item");
	
	/* Hack -- wipe */
	WIPE(o_ptr, object_type);

	/* Skip name */
	skip_value("name");

	/* Kind */
	o_ptr->k_idx = read_int("k_idx");

	/* Location */
	o_ptr->iy = read_int("iy");
	o_ptr->ix = read_int("ix");
	
	o_ptr->dun_depth = read_int("dun_depth");

	/* Type/Subtype */
	o_ptr->tval = read_int("tval");
	o_ptr->sval = read_int("sval");

	/* Base pval */
	o_ptr->bpval = read_int("bpval");

	/* Special pval */
	o_ptr->pval = read_int("pval");


	o_ptr->discount = read_int("discount");
	o_ptr->number = read_int("number");
	o_ptr->weight = read_int("weight");

	o_ptr->name1 = read_int("name1");
	o_ptr->name2 = read_int("name2");
	o_ptr->name3 = read_int("name3");
	o_ptr->timeout = read_int("timeout");

	o_ptr->to_h = read_int("to_h");
	o_ptr->to_d = read_int("to_d");
	o_ptr->to_a = read_int("to_a");

	o_ptr->ac = read_int("ac");

	old_dd = read_int("dd");
	old_ds = read_int("ds");

	o_ptr->ident = read_int("ident");

	/* Special powers */
	o_ptr->xtra1 = read_int("xtra1");
	o_ptr->xtra2 = read_int("xtra2");

	/* Inscription */
	read_str("inscription",note); 
 
	/* Save the inscription */
	if (note[0]) o_ptr->note = quark_add(note);

	/* Owner information */
	if (value_exists("owner_name"))
	{
		/* Name */
		read_str("owner_name",note);
		/* Save */
		if (!STRZERO(note)) o_ptr->owner_name = quark_add(note); 
		/* Id */
		o_ptr->owner_id = read_int("owner_id");
	}

	/* Monster holding object */ 
   o_ptr->held_m_idx = read_int("held_m_idx");

	end_section_read("item");

	/* Mega-Hack -- handle "dungeon objects" later */
	if ((o_ptr->k_idx >= 445) && (o_ptr->k_idx <= 479)) return;


	/* Obtain the "kind" template */
	k_ptr = &k_info[o_ptr->k_idx];

	/* Obtain tval/sval from k_info */
	o_ptr->tval = k_ptr->tval;
	o_ptr->sval = k_ptr->sval;


	/* Hack -- notice "broken" items */
	if (k_ptr->cost <= 0) o_ptr->ident |= ID_BROKEN;


	/* Repair non "wearable" items */
	if (!wearable_p(o_ptr))
	{
		/* Acquire correct fields */
		o_ptr->to_h = k_ptr->to_h;
		o_ptr->to_d = k_ptr->to_d;
		o_ptr->to_a = k_ptr->to_a;

		/* Acquire correct fields */
		o_ptr->ac = k_ptr->ac;
		o_ptr->dd = k_ptr->dd;
		o_ptr->ds = k_ptr->ds;

		/* Acquire correct weight */
		o_ptr->weight = k_ptr->weight;

		/* Paranoia */
		o_ptr->name1 = o_ptr->name2 = 0;

		/* All done */
		return;
	}


	/* Extract the flags */
	object_flags(o_ptr, &f1, &f2, &f3);


	/* Paranoia */
	if (true_artifact_p(o_ptr))
	{
		artifact_type *a_ptr;

		/* Obtain the artifact info */
		a_ptr = &a_info[o_ptr->name1];

		/* Verify that artifact */
		if (!a_ptr->name) o_ptr->name1 = 0;
	}

	/* Paranoia */
	if (o_ptr->name2)
	{
		ego_item_type *e_ptr;

		/* Obtain the ego-item info */
		e_ptr = &e_info[o_ptr->name2];

		/* Verify that ego-item */
		if (!e_ptr->name) o_ptr->name2 = 0;
	}


	/* Acquire standard fields */
	o_ptr->ac = k_ptr->ac;
	o_ptr->dd = k_ptr->dd;
	o_ptr->ds = k_ptr->ds;

	/* Acquire standard weight */
	o_ptr->weight = k_ptr->weight;

	/* Hack -- extract the "broken" flag */
	if (o_ptr->pval < 0) o_ptr->ident |= ID_BROKEN;


	/* Artifacts */
	if (artifact_p(o_ptr))
	{
		artifact_type *a_ptr;

		/* Obtain the artifact info */
#if defined(RANDART)
		if (o_ptr->name1 == ART_RANDART)
		{
			a_ptr = randart_make(o_ptr);
		}
		else
		{
#endif
		a_ptr = &a_info[o_ptr->name1];
#if defined(RANDART)
		}
#endif
		/* Acquire new artifact "pval" */
		o_ptr->pval = a_ptr->pval;

		/* Acquire new artifact fields */
		o_ptr->ac = a_ptr->ac;
		o_ptr->dd = a_ptr->dd;
		o_ptr->ds = a_ptr->ds;

		/* Acquire new artifact weight */
		o_ptr->weight = a_ptr->weight;

		/* Hack -- extract the "broken" flag */
		if (!a_ptr->cost) o_ptr->ident |= ID_BROKEN;
	}

	/* Ego items */
	if (o_ptr->name2)
	{
		ego_item_type *e_ptr;

		/* Obtain the ego-item info */
		e_ptr = &e_info[o_ptr->name2];

		/* Hack -- keep some old fields */
		if ((o_ptr->dd < old_dd) && (o_ptr->ds == old_ds))
		{
			/* Keep old boosted damage dice */
			o_ptr->dd = old_dd;
		}

		/* Hack -- extract the "broken" flag */
		if (!e_ptr->cost) o_ptr->ident |= ID_BROKEN;

		/* Mega-Hack - Enforce the special broken items */
		if ((o_ptr->name2 == EGO_BLASTED) ||
			(o_ptr->name2 == EGO_SHATTERED))
		{
			/* These were set to k_info values by preceding code */
			o_ptr->ac = 0;
			o_ptr->dd = 0;
			o_ptr->ds = 0;
		}
	}
}