您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ str_cmp函数代码示例

51自学网 2021-06-03 08:25:46
  C++
这篇教程C++ str_cmp函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中str_cmp函数的典型用法代码示例。如果您正苦于以下问题:C++ str_cmp函数的具体用法?C++ str_cmp怎么用?C++ str_cmp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了str_cmp函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: do_play

void do_play(CHAR_DATA *ch, char *argument){    OBJ_DATA *juke;    char *str,arg[MAX_INPUT_LENGTH];    int song,i;    bool global = FALSE;    str = one_argument(argument,arg);    for (juke = ch->in_room->contents; juke != NULL; juke = juke->next_content)	if (juke->item_type == ITEM_JUKEBOX && can_see_obj(ch,juke))	    break;    if (argument[0] == '/0')    {	send_to_char("Play what?/n/r",ch);	return;    }    if (juke == NULL)    {	send_to_char("You see nothing to play./n/r",ch);	return;    }    if (!str_cmp(arg,"list"))    {	BUFFER *buffer;  	char buf[MAX_STRING_LENGTH];	int col = 0;	bool artist = FALSE, match = FALSE;	buffer = new_buf();	argument = str;	argument = one_argument(argument,arg);	if (!str_cmp(arg,"artist"))	    artist = TRUE;	if (argument[0] != '/0')	    match = TRUE;	sprintf(buf,"%s has the following songs available:/n/r",	    juke->short_descr);	add_buf(buffer,capitalize(buf));	for (i = 0; i < MAX_SONGS; i++)	{	    if (song_table[i].name == NULL)		break;	    if (artist && (!match 	    || 		   !str_prefix(argument,song_table[i].group)))		sprintf(buf,"%-39s %-39s/n/r",		    song_table[i].group,song_table[i].name);	    else if (!artist && (!match 	    || 	 		 !str_prefix(argument,song_table[i].name)))	    	sprintf(buf,"%-35s ",song_table[i].name);	    else		continue;	    add_buf(buffer,buf);	    if (!artist && ++col % 2 == 0)		add_buf(buffer,"/n/r");        }        if (!artist && col % 2 != 0)	    add_buf(buffer,"/n/r");	page_to_char(buf_string(buffer),ch);	free_buf(buffer);	return;    }    if (!str_cmp(arg,"loud"))    {        argument = str;        global = TRUE;    }    if (argument[0] == '/0')    {        send_to_char("Play what?/n/r",ch);        return;    }    if ((global && channel_songs[MAX_GLOBAL] > -1)     ||  (!global && juke->value[4] > -1))    {        send_to_char("The jukebox is full up right now./n/r",ch);        return;    }    for (song = 0; song < MAX_SONGS; song++)    {	if (song_table[song].name == NULL)	{	    send_to_char("That song isn't available./n/r",ch);	    return;	}	if (!str_prefix(argument,song_table[song].name))	    break;//.........这里部分代码省略.........
开发者ID:Geadin,项目名称:balrog,代码行数:101,


示例2: make_adminlist

void make_adminlist(){    DIR *dp;    struct dirent *dentry;    char *word;    FILE *gfp, *wfp;    int ilevel;    COUNCIL_DATA *council;    ADMINENT *admin, *adminnext;    char buf[MAX_STRING_LENGTH];    char arg[MAX_STRING_LENGTH];    char *arg2 = NULL;    first_admin = NULL;    last_admin = NULL;        if ( (dp = opendir( GOD_DIR )) == NULL )    {    	bug("Error opening the god directory", 0 );	return;    }    ilevel = 0;    dentry = readdir( dp );    while( dentry )    {        if ( dentry->d_name[0] != '.' )        {                    sprintf (buf, "%s%s", GOD_DIR, dentry->d_name);            gfp = fopen (buf, "r" );            if (gfp)            {                 word = feof( gfp ) ? "End" : fread_word( gfp );    	         ilevel = fread_number( gfp );                 fread_to_eol( gfp );         	 word = feof( gfp ) ? "End" : fread_word( gfp );		 add_to_adminlist( dentry->d_name, ilevel );                 fclose(gfp);              }          }         dentry = readdir( dp );    }     closedir( dp );    unlink( ADMINLIST_FILE );    if ( (wfp = fopen( ADMINLIST_FILE, "a" )) == NULL )    {    	bug("Error opening the Adminlist file", 0 );	return;    }    sprintf(buf, "%s Administrative Council List", sysdata.mud_name);    toadminfile(buf, wfp);        toadminfile(" ", wfp);    for ( admin = first_admin; admin; admin = admin->next )    {        sprintf (buf, "%s%c/%s", PLAYER_DIR, tolower(admin->name[0]), admin->name);        gfp = fopen (buf, "r" );        if (gfp)        { 	    arg2 = NULL;            do            {                    fgets( buf, MAX_STRING_LENGTH, gfp);                arg2 = one_argument(buf, arg);            }while ( str_cmp(arg,"Council") && !feof(gfp));        }            if (!str_cmp(arg, "Council") )	{	     remove_tilde(arg2);             admin->council = str_dup (arg2);	}	fclose( gfp );    }    sort_adminlist();    for (council = first_council; council; council = council->next)    {       sprintf( buf, "%s", council->name);       sprintf( arg, "%c", ' ' );       toadminfile(buf, wfp);       for ( admin = first_admin; admin; admin = admin->next )       {           if(!str_cmp(admin->council, council->name) )           {	      if ( !str_cmp( admin->name, council->head) || ( council->head2 &&	           !str_cmp( admin->name, council->head2) ) )              	sprintf(buf, "*%s* ", admin->name);	      else              	sprintf(buf, "%s ", admin->name);              if ((strlen (arg) + strlen (buf)) > 76 )	      {                 toadminfile(arg, wfp);		 sprintf( arg, "%c", ' ');	      }              strcat(arg, buf);           }//.........这里部分代码省略.........
开发者ID:bkero,项目名称:Smaug,代码行数:101,


示例3: snprintf

char *display_clan_ranks (CHAR_DATA *ch, CHAR_DATA *observer){	CLAN_DATA	*clan = NULL;	static char	buf [MAX_STRING_LENGTH] = { '/0' };	char		*argument = NULL, *argument2 = NULL;	char		ranks_list [MAX_STRING_LENGTH] = { '/0' };	char		clan_name [MAX_STRING_LENGTH] = { '/0' };	char		clan_name2 [MAX_STRING_LENGTH] = { '/0' };	char		name [MAX_STRING_LENGTH] = { '/0' };	int			flags = 0, flags2 = 0, clans = 0;	bool		first = TRUE;	char		*temp_arg = NULL;		argument = observer->clans;	*ranks_list = '/0';	snprintf (buf, MAX_STRING_LENGTH,  "You recognize that %s carries the rank of", HSSH(ch));    while ( get_next_clan (&argument, clan_name, &flags) ) {    	argument2 = ch->clans;                while ( get_next_clan (&argument2, clan_name2, &flags2) ) {        	        	if ( !str_cmp (clan_name, "osgi_citizens") ||            	 !str_cmp (clan_name, "mm_denizens") )                continue;						clan = get_clandef (clan_name);						if ( !clan )				continue;                        if ( !str_cmp (clan_name, clan_name2) ) {				if ( *ranks_list ) {					strcat (buf, ranks_list);								if ( !first )						strcat (buf, ",");									*ranks_list = '/0';				}										snprintf (name, MAX_STRING_LENGTH, "%s", clan->literal);								if ( !cmp_strn (clan->literal, "The ", 4) )					*name = tolower(*name);								if ( cmp_strn (clan->literal, "the ", 4) ){					temp_arg = get_clan_rank_name (flags2);					snprintf (name, MAX_STRING_LENGTH, "the %s", clan->literal);					snprintf (ranks_list + strlen(ranks_list), MAX_STRING_LENGTH, " %s in %s", temp_arg, name); 				}										first = FALSE;				clans++;            }        }    }	if ( *ranks_list ) {		if ( clans > 1 )			strcat (buf, " and");			strcat (buf, ranks_list);	} 	strcat (buf, ".");	if (clan)		free(clan);  /* clan = get_clandef (clan_name); */			if ( clans )		return buf;	else		return NULL;		}
开发者ID:MUDOmnibus,项目名称:Argila2,代码行数:78,


示例4: parse_attribute_candidate

static int parse_attribute_candidate(struct sdp_attribute *output) {	PARSE_DECL;	char *ep;	struct attribute_candidate *c;	output->attr = ATTR_CANDIDATE;	c = &output->u.candidate;	PARSE_INIT;	EXTRACT_TOKEN(u.candidate.cand_parsed.foundation);	EXTRACT_TOKEN(u.candidate.component_str);	EXTRACT_TOKEN(u.candidate.transport_str);	EXTRACT_TOKEN(u.candidate.priority_str);	EXTRACT_TOKEN(u.candidate.address_str);	EXTRACT_TOKEN(u.candidate.port_str);	EXTRACT_TOKEN(u.candidate.typ_str);	EXTRACT_TOKEN(u.candidate.type_str);	c->cand_parsed.component_id = strtoul(c->component_str.s, &ep, 10);	if (ep == c->component_str.s)		return -1;	c->cand_parsed.transport = ice_transport(&c->transport_str);	if (!c->cand_parsed.transport)		return 0;	c->cand_parsed.priority = strtoul(c->priority_str.s, &ep, 10);	if (ep == c->priority_str.s)		return -1;	if (__parse_address(&c->cand_parsed.endpoint.ip46, NULL, NULL, &c->address_str))		return 0;	c->cand_parsed.endpoint.port = strtoul(c->port_str.s, &ep, 10);	if (ep == c->port_str.s)		return -1;	if (str_cmp(&c->typ_str, "typ"))		return -1;	c->cand_parsed.type = ice_candidate_type(&c->type_str);	if (!c->cand_parsed.type)		return 0;	if (!ice_has_related(c->cand_parsed.type))		goto done;	EXTRACT_TOKEN(u.candidate.raddr_str);	EXTRACT_TOKEN(u.candidate.related_address_str);	EXTRACT_TOKEN(u.candidate.rport_str);	EXTRACT_TOKEN(u.candidate.related_port_str);	if (str_cmp(&c->raddr_str, "raddr"))		return -1;	if (str_cmp(&c->rport_str, "rport"))		return -1;	if (__parse_address(&c->cand_parsed.related_address, NULL, NULL, &c->related_address_str))		return 0;	c->cand_parsed.related_port = strtoul(c->related_port_str.s, &ep, 10);	if (ep == c->related_port_str.s)		return -1;done:	c->parsed = 1;	return 0;}
开发者ID:jungle0755,项目名称:rtpengine,代码行数:68,


示例5: setVTblPtr

// ---------------------------------------------------------------------// Driver for Unpacking//// In a nutshell, unpacking consists of the following major steps://// 1. fix the endianness of the version header (members of this class)// 2. fix up the virtual table function pointer for the object// 3. migrate an object of a previous version to the current version// 4. fix the endianness of all other members in the subclasses// 5. convert pointers in this object from offsets back to addresses// 5. initiate unpacking for other objects referenced by this object// 6. initialize new members added in the new version//// Parameters:// base             is the base address (added to offset to get pointer)// vtblPtr          (first form) is the pointer to the virtual function table//                  of the class// ptrToAnchorClass (second form, see below) is a pointer to an object//                  that has the desired virtual function pointer// ---------------------------------------------------------------------NA_EIDPROC NAVersionedObject *NAVersionedObject::driveUnpack(                                    void *base,				    char *vtblPtr,				    void * reallocator)  {    // -----------------------------------------------------------------    // Make sure we are really dealing with a NAVersionedObject by    // examining its eyeCatcher_.    // -----------------------------------------------------------------    if (str_cmp(eyeCatcher_,VOBJ_EYE_CATCHER,VOBJ_EYE_CATCHER_SIZE))      return NULL;    // -----------------------------------------------------------------    // If object has already been unpacked, just return either its own    // address or the reallocated address if the object was reallocated    // to somewhere else.    // -----------------------------------------------------------------    if (!isPacked())    {      if (reallocatedAddress_.isNull())        return this;      else        return reallocatedAddress_.getPointer();    }#ifdef NA_64BIT    // dg64 - the 32-bit module files have junk in them, so let's try zero    //        at least in the high-order 32-bits    else      reallocatedAddress_ = (NAVersionedObjectPtr) NULL ;#endif    // -----------------------------------------------------------------    // Fix the Version Header to the endianness of the local platform    // if necessary. Correct classID_ field is necessary to determine    // the right subclass the object belongs.    //    // *** DON'T DO THIS JUST YET: PLAN IS TO SUPPORT THIS ONLY FROM    // *** SECOND RELEASE.    // -----------------------------------------------------------------#ifndef NA_LITTLE_ENDIAN    // toggleEndiannessOfVersionHeader();#endif    // -----------------------------------------------------------------    // The method findVTblPtr() was called on an object of the Anthor    // Class T to find out what subclass of the Anchor Class this object    // belongs based on its classID_. Now, the virtual function table    // pointer is used to fix up this object.    // -----------------------------------------------------------------    if (vtblPtr == NULL)      return NULL;                                // unknown class ID //    else      setVTblPtr(vtblPtr);    // -----------------------------------------------------------------    // Call the virtual method migrateToNewVersion() so that older    // objects can be migrated to fit in the new class template.    // -----------------------------------------------------------------    NAVersionedObject *objPtr = NULL;    // -----------------------------------------------------------------    // migrateToNewVersion() should either set objPtr to this or to an    // reallocated image.    // -----------------------------------------------------------------    if (migrateToNewVersion(objPtr))      return NULL;                           // version not supported //    // -----------------------------------------------------------------    // Convert members of this object from reference platform to local    // platform.    //    // *** DON'T DO THIS JUST YET: PLAN IS TO SUPPORT THIS ONLY FROM    // *** SECOND RELEASE.    // -----------------------------------------------------------------    // objPtr->convertToLocalPlatform();    // -----------------------------------------------------------------    // Mark object as not packed, despite it is not completely unpacked    // yet. This is needed because the call that follows to the virtual    // method unpack() drives the unpacking of all objects referenced by//.........这里部分代码省略.........
开发者ID:RuoYuHP,项目名称:incubator-trafodion,代码行数:101,


示例6: note_remove

void note_remove( CHAR_DATA *ch, NOTE_DATA *pnote ){    FILE      *fp;    NOTE_DATA *prev;    char      *to_list;    char       to_new [ MAX_INPUT_LENGTH ];    char       to_one [ MAX_INPUT_LENGTH ];    /*     * Build a new to_list.     * Strip out this recipient.     */    to_new[0]	= '/0';    to_list	= pnote->to_list;    while ( *to_list != '/0' )    {	to_list	= one_argument( to_list, to_one );	if ( to_one[0] != '/0' && str_cmp( ch->name, to_one ) )	{	    strcat( to_new, " "    );	    strcat( to_new, to_one );	}    }    /*     * Just a simple recipient removal?     */    if ( str_cmp( ch->name, pnote->sender ) && to_new[0] != '/0' )    {	free_string( pnote->to_list );	pnote->to_list = str_dup( to_new + 1 );	return;    }    /*     * Remove note from linked list.     */    if ( pnote == note_list )    {	note_list = pnote->next;    }    else    {	for ( prev = note_list; prev; prev = prev->next )	{	    if ( prev->next == pnote )		break;	}	if ( !prev )	{	    bug( "Note_remove: pnote not found.", 0 );	    return;	}	prev->next = pnote->next;    }    free_string( pnote->text    );    free_string( pnote->subject );    free_string( pnote->to_list );    free_string( pnote->date    );    free_string( pnote->sender  );    pnote->next	= note_free;    note_free	= pnote;    /*     * Rewrite entire list.     */    fclose( fpReserve );    if ( !( fp = fopen( NOTE_FILE, "w" ) ) )    {	perror( NOTE_FILE );    }    else    {	for ( pnote = note_list; pnote; pnote = pnote->next )	{	    fprintf( fp, "Sender  %s~/n", pnote->sender     );	    fprintf( fp, "Date    %s~/n", pnote->date       );	    fprintf( fp, "Stamp   %ld/n", (unsigned long)pnote->date_stamp );	    fprintf( fp, "To      %s~/n", pnote->to_list    );	    fprintf( fp, "Subject %s~/n", pnote->subject    );	    fprintf( fp, "Text/n%s~/n/n", pnote->text       );	}	fclose( fp );    }    fpReserve = fopen( NULL_FILE, "r" );    return;}
开发者ID:lolindrath,项目名称:EnvyMUD,代码行数:90,


示例7: do_finger

void do_finger( CHAR_DATA *ch, char *argument ){    char arg[MAX_INPUT_LENGTH];    char buf[MAX_STRING_LENGTH];    CHAR_DATA *victim;    FILE *fp;    bool fOld;    one_argument( argument, arg );    if ( arg[0] == '/0' )    {	send_to_char( "Finger whom?/n/r", ch );	return;    }    if ( ( victim = get_char_world( ch, arg ) ) != NULL)    {	if (!IS_NPC(victim))	{	    act( "$N is on right now!", ch, NULL, victim, TO_CHAR );	    return;	}    }    victim = new_char();    victim->pcdata = new_pcdata();    fOld = FALSE;        sprintf( buf, "%s%s", PLAYER_DIR, capitalize( arg ) );    if ( ( fp = fopen( buf, "r" ) ) != NULL )    {	int iNest;	for ( iNest = 0; iNest < MAX_NEST; iNest++ )	    rgObjNest[iNest] = NULL;	fOld = TRUE;	for ( ; ; )	{	    char letter;	    char *word;	    letter = fread_letter( fp );	    if ( letter == '*' )	    {		fread_to_eol( fp );		continue;	    }	    if ( letter != '#' )	    {		bug( "Load_char_obj: # not found.", 0 );		break;	    }	    word = fread_word( fp );	    if      ( !str_cmp( word, "PLAYER" ) ) fread_char( victim, fp );	    else if ( !str_cmp( word, "OBJECT" ) ) break;	    else if ( !str_cmp( word, "O"      ) ) break;	    else if ( !str_cmp( word, "PET"    ) ) break;	    else if ( !str_cmp( word, "END"    ) ) break;	    else	    {		bug( "Load_char_obj: bad section.", 0 );		break;	    }	}	fclose( fp );    }    if ( !fOld )    {	send_to_char("No player by that name exists./n/r",ch);	free_pcdata(victim->pcdata);	free_char(victim);	return;    }    if ( (victim->level > LEVEL_HERO) && (victim->level > ch->level) )    {	send_to_char("The gods wouldn't like that./n/r",ch);	free_pcdata(victim->pcdata);	free_char(victim);	return;    }    sprintf(buf,"%s last logged off on %s",	victim->name, (char *) ctime(&victim->llogoff));    send_to_char(buf,ch);    free_pcdata(victim->pcdata);    free_char(victim);    return;}
开发者ID:MUDOmnibus,项目名称:Rot14,代码行数:91,


示例8: list_apply_handler

static bool list_apply_handler(struct le *le, void *arg){    struct vidisp_st *st = le->data;    return 0 == str_cmp(st->device, arg);}
开发者ID:AmesianX,项目名称:baresip,代码行数:6,


示例9: skill_ethereal_snake

int skill_ethereal_snake( int sn, int level, CHAR_DATA *ch, void *vo ){    AFFECT_DATA af;    CHAR_DATA *victim;   /*    if ( !IS_NPC( ch )        && ( ( ch->level < skill_table[sn].skill_level[ch->class] )        && (ch->level < skill_table[sn].skill_level[ch->multied])))    {        send_to_char(C_DEFAULT, "You can not perform that skill./n/r", ch );        return SKPELL_MISSED;    }*/    // modified check so if NPCs have spell on already    // they can use bite/devour/etc - Ahsile    if ( IS_NPC(ch) || number_percent( ) > ( ch->pcdata->learned[sn] / 10 ) )    {	if (IS_NPC(ch))	{		if (!IS_AFFECTED4(ch, AFF_ETHEREAL_SNAKE))		{				send_to_char( C_DEFAULT, "You failed./n/r", ch );			return SKPELL_MISSED;		}	} else	{			send_to_char( C_DEFAULT, "You failed./n/r", ch );			return SKPELL_MISSED;	}    }       if ( !ch->fighting )    {	if ( IS_AFFECTED4( ch, AFF_ETHEREAL_SNAKE ) )	{	    send_to_char( AT_DGREY, "You replace your ethereal snake with a new one./n/r", ch );	    return SKPELL_NO_DAMAGE;	}	/* TO DO: Mana costs */   	af.type = sn;	af.level = ch->level;	af.duration = ch->level;	af.location = APPLY_NONE;	af.modifier = 0;	af.bitvector = AFF_ETHEREAL_SNAKE;	affect_to_char4(ch, &af);	act( AT_DGREY, "$n summons an ethereal snake!", ch, NULL, NULL, TO_ROOM );	send_to_char( AT_DGREY, "You have summoned an ethereal snake to assist you./n/r", ch );	WAIT_STATE( ch, skill_table[sn].beats );	return SKPELL_NO_DAMAGE;    }    /* Snake commands will go here */    victim = ch->fighting;    if (target_name[0] == '/0')    {	send_to_char( AT_DGREY, "You get the attention of your snake./n/r", ch );	act( AT_DGREY, "$n gets the attention of $m snake.", ch, NULL, NULL, TO_ROOM );	return SKPELL_NO_DAMAGE;    }    if ( !str_cmp( target_name, "bite" ) )    {	send_to_char( AT_DGREY, "You order your snake to bite!/n/r", ch );	act( AT_DGREY, "$n orders $m ethereal snake to bite!", ch, NULL, NULL, TO_ROOM );	WAIT_STATE( ch, skill_table[skill_lookup("ethereal snake bite")].beats );		return spell_ethereal_snake_bite ( skill_lookup("ethereal snake bite"), ch->level, ch, victim );    }    if ( !str_cmp( target_name, "strike" ) )    {	send_to_char( AT_DGREY, "You order your snake to strike!/n/r", ch );	act( AT_DGREY, "$n orders $m ethereal snake to strike!", ch, NULL, NULL, TO_ROOM );	WAIT_STATE( ch, skill_table[skill_lookup("ethereal snake strike")].beats );	return spell_ethereal_snake_strike ( skill_lookup("ethereal snake strike"), ch->level, ch, victim );    }    if ( !str_cmp( target_name, "devour" ) )    {	send_to_char( AT_DGREY, "You order your snake to devour!/n/r", ch );	act( AT_DGREY, "$n orders $m ethereal snake to devour its target whole!", ch, NULL, NULL, TO_ROOM );	WAIT_STATE( ch, skill_table[skill_lookup("ethereal snake devour")].beats);		return spell_ethereal_snake_devour ( skill_lookup("ethereal snake devour"), ch->level, ch, victim );    }    send_to_char ( AT_DGREY, "You may only order your snake to BITE, STRIKE or DEVOUR./n/r", ch );//.........这里部分代码省略.........
开发者ID:rayhe,项目名称:stormgate,代码行数:101,


示例10: do_buy

void do_buy( CHAR_DATA *ch, char *argument ){    char arg[MAX_INPUT_LENGTH];    int maxgold;    bool debit;    OBJ_DATA *obj;        argument = one_argument( argument, arg );    if ( arg[0] == '/0' )    {	send_to_char( "Buy what?/n/r", ch );	return;    }    if ( IS_SET(ch->in_room->room_flags, ROOM_PET_SHOP) )    {	char buf[MAX_STRING_LENGTH];	CHAR_DATA *pet;	ROOM_INDEX_DATA *pRoomIndexNext;	ROOM_INDEX_DATA *in_room;   if ( argument[0] == '/0' )      debit = FALSE;   else if ( !str_cmp( "atm", argument ) || !str_cmp( "debit", argument ) )   {      bool has_card = FALSE;            for ( obj = ch->last_carrying; obj; obj = obj->prev_content )              {          if ( obj->item_type == ITEM_DEBIT_CARD )            has_card = TRUE;      }              if ( has_card == TRUE )      debit = TRUE;     else     {       send_to_char( "You don't even have your card with you!/n/r", ch );       return;         }        }	if ( IS_NPC(ch) )	    return;	pRoomIndexNext = get_room_index( ch->in_room->vnum + 1 );	if ( !pRoomIndexNext )	{	    bug( "Do_buy: bad pet shop at vnum %d.", ch->in_room->vnum );	    send_to_char( "Sorry, you can't buy that here./n/r", ch );	    return;	}	in_room     = ch->in_room;	ch->in_room = pRoomIndexNext;	pet         = get_char_room( ch, arg );	ch->in_room = in_room;	if ( pet == NULL || !IS_NPC( pet ) || !IS_SET(pet->act, ACT_PET) )	{	    send_to_char( "Sorry, you can't buy that here./n/r", ch );	    return;	}	if (( ch->gold < 10 * pet->top_level * pet->top_level ) && debit == FALSE)	{	    send_to_char( "You can't afford it./n/r", ch );	    return;	}	else if ( (ch->pcdata->bank < 10 * pet->top_level * pet->top_level) && debit == TRUE )	{	  send_to_char( "You dont have enough money in your bank account for it./n/r", ch );          return;            } 	maxgold = 10 * pet->top_level * pet->top_level;        if ( debit == FALSE )	  ch->gold	-= maxgold; /* this was already here, btw */	else	  ch->pcdata->bank  -= maxgold;	boost_economy( ch->in_room->area, maxgold );	pet		= create_mobile( pet->pIndexData );	SET_BIT(pet->act, ACT_PET);	SET_BIT(pet->affected_by, AFF_CHARM);	argument = one_argument( argument, arg );	if ( arg[0] != '/0' )	{	    sprintf( buf, "%s %s", pet->name, arg );	    STRFREE( pet->name );	    pet->name = STRALLOC( buf );	}	sprintf( buf, "%sA neck tag says 'I belong to %s'./n/r",	    pet->description, ch->name );	STRFREE( pet->description );	pet->description = STRALLOC( buf );//.........这里部分代码省略.........
开发者ID:smthbh,项目名称:SWFotE-Mud,代码行数:101,


示例11: quest_stat

void quest_stat(struct char_data *ch, char argument[MAX_STRING_LENGTH]){  qst_rnum rnum;  mob_rnum qmrnum;  char buf[MAX_STRING_LENGTH];  char targetname[MAX_STRING_LENGTH];  if (GET_ADMLEVEL(ch) < ADMLVL_IMMORT)    send_to_char(ch, "Huh!?!/r/n");  else if (!*argument)    send_to_char(ch, "%s/r/n", quest_imm_usage);  else if ((rnum = real_quest(atoi(argument))) == NOTHING )    send_to_char(ch, "That quest does not exist./r/n");  else {    sprintbit(QST_FLAGS(rnum), aq_flags, buf, sizeof(buf));    switch (QST_TYPE(rnum)) {      case AQ_OBJ_FIND:      case AQ_OBJ_RETURN:        snprintf(targetname, sizeof(targetname), "%s",                 real_object(QST_TARGET(rnum)) == NOTHING ?                 "An unknown object" :    obj_proto[real_object(QST_TARGET(rnum))].short_description); break;      case AQ_ROOM_FIND:      case AQ_ROOM_CLEAR:        snprintf(targetname, sizeof(targetname), "%s",          real_room(QST_TARGET(rnum)) == NOWHERE ?                 "An unknown room" :    world[real_room(QST_TARGET(rnum))].name);        break;      case AQ_MOB_FIND:      case AQ_MOB_KILL:      case AQ_MOB_SAVE: snprintf(targetname, sizeof(targetname), "%s",                 real_mobile(QST_TARGET(rnum)) == NOBODY ?    "An unknown mobile" :    GET_NAME(&mob_proto[real_mobile(QST_TARGET(rnum))])); break;      default: snprintf(targetname, sizeof(targetname), "Unknown"); break;    }    qmrnum = real_mobile(QST_MASTER(rnum));    send_to_char(ch,        "VNum  : [/ty%5d/tn], RNum: [/ty%5d/tn] -- Questmaster: [/ty%5d/tn] /ty%s/tn/r/n"        "Name  : /ty%s/tn/r/n" "Desc  : /ty%s/tn/r/n" "Accept Message:/r/n/tc%s/tn" "Completion Message:/r/n/tc%s/tn" "Quit Message:/r/n/tc%s/tn" "Type  : /ty%s/tn/r/n"        "Target: /ty%d/tn /ty%s/tn, Quantity: /ty%d/tn/r/n" "Value : /ty%d/tn, Penalty: /ty%d/tn, Min Level: /ty%2d/tn, Max Level: /ty%2d/tn/r/n" "Flags : /tc%s/tn/r/n",     QST_NUM(rnum), rnum, QST_MASTER(rnum) == NOBODY ? -1 : QST_MASTER(rnum), (qmrnum == NOBODY) ? "(Invalid vnum)" : GET_NAME(&mob_proto[(qmrnum)]),        QST_NAME(rnum), QST_DESC(rnum),        QST_INFO(rnum), QST_DONE(rnum), (QST_QUIT(rnum) &&  (str_cmp(QST_QUIT(rnum), "undefined") != 0)          ? QST_QUIT(rnum) : "Nothing/r/n"),     quest_types[QST_TYPE(rnum)], QST_TARGET(rnum) == NOBODY ? -1 : QST_TARGET(rnum), targetname, QST_QUANTITY(rnum),     QST_POINTS(rnum), QST_PENALTY(rnum), QST_MINLEVEL(rnum), QST_MAXLEVEL(rnum), buf);    if (QST_PREREQ(rnum) != NOTHING)      send_to_char(ch, "Preq  : [/ty%5d/tn] /ty%s/tn/r/n",        QST_PREREQ(rnum) == NOTHING ? -1 : QST_PREREQ(rnum),        QST_PREREQ(rnum) == NOTHING ? "" :   real_object(QST_PREREQ(rnum)) == NOTHING ? "an unknown object" :       obj_proto[real_object(QST_PREREQ(rnum))].short_description);    if (QST_TYPE(rnum) == AQ_OBJ_RETURN)      send_to_char(ch, "Mob   : [/ty%5d/tn] /ty%s/tn/r/n",        QST_RETURNMOB(rnum), real_mobile(QST_RETURNMOB(rnum)) == NOBODY ? "an unknown mob" :           mob_proto[real_mobile(QST_RETURNMOB(rnum))].player.short_descr);    if (QST_TIME(rnum) != -1)      send_to_char(ch, "Limit : There is a time limit of %d turn%s to complete./r/n",   QST_TIME(rnum),   QST_TIME(rnum) == 1 ? "" : "s");    else      send_to_char(ch, "Limit : There is no time limit on this quest./r/n");    send_to_char(ch, "Prior :");    if (QST_PREV(rnum) == NOTHING)      send_to_char(ch, " /tyNone./tn/r/n");    else      send_to_char(ch, " [/ty%5d/tn] /tc%s/tn/r/n",        QST_PREV(rnum), QST_DESC(real_quest(QST_PREV(rnum))));    send_to_char(ch, "Next  :");    if (QST_NEXT(rnum) == NOTHING)      send_to_char(ch, " /tyNone./tn/r/n");    else      send_to_char(ch, " [/ty%5d/tn] /tc%s/tn/r/n",        QST_NEXT(rnum), QST_DESC(real_quest(QST_NEXT(rnum))));  }}
开发者ID:mystickdreamer,项目名称:tba365,代码行数:99,


示例12: do_repairset

void do_repairset( CHAR_DATA *ch, char *argument ){    REPAIR_DATA *repair;    MOB_INDEX_DATA *mob, *mob2;    char arg1[MAX_INPUT_LENGTH];    char arg2[MAX_INPUT_LENGTH];    int vnum;    int value;        argument = one_argument( argument, arg1 );    argument = one_argument( argument, arg2 );    if ( arg1[0] == '/0' || arg2[0] == '/0' )    {	send_to_char( "Usage: repairset <mob vnum> <field> value/n/r", ch );	send_to_char( "/n/rField being one of:/n/r", ch );	send_to_char( "  fix0 fix1 fix2 profit type open close keeper/n/r", ch );	return;    }    vnum = atoi( arg1 );    if ( (mob = get_mob_index(vnum)) == NULL )    {	send_to_char( "Mobile not found./n/r", ch );	return;    }    if ( !can_medit(ch, mob) )      return;    if ( !mob->rShop )    {	send_to_char( "This mobile doesn't keep a repair shop./n/r", ch );	return;    }    repair = mob->rShop;    value = atoi( argument );    if ( !str_cmp( arg2, "fix0" ) )    {	if ( !is_number(argument) )	  value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	repair->fix_type[0] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "fix1" ) )    {	if ( !is_number(argument) )	  value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	repair->fix_type[1] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "fix2" ) )    {	if ( !is_number(argument) )	  value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	repair->fix_type[2] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "profit" ) )    {	if ( value < 1 || value > 1000 )	{	    send_to_char( "Out of range./n/r", ch );	    return;	}	repair->profit_fix = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "type" ) )    {	if ( value < 1 || value > 2 )	{	    send_to_char( "Out of range./n/r", ch );	    return;	}//.........这里部分代码省略.........
开发者ID:smthbh,项目名称:SWFotE-Mud,代码行数:101,


示例13: do_shopset

void do_shopset( CHAR_DATA *ch, char *argument ){    SHOP_DATA *shop;    MOB_INDEX_DATA *mob, *mob2;    char arg1[MAX_INPUT_LENGTH];    char arg2[MAX_INPUT_LENGTH];    int vnum;    int value;        argument = one_argument( argument, arg1 );    argument = one_argument( argument, arg2 );    if ( arg1[0] == '/0' || arg2[0] == '/0' )    {	send_to_char( "Usage: shopset <mob vnum> <field> value/n/r", ch );	send_to_char( "/n/rField being one of:/n/r", ch );	send_to_char( "  buy0 buy1 buy2 buy3 buy4 buy sell open close keeper/n/r", ch );	return;    }    vnum = atoi( arg1 );    if ( (mob = get_mob_index(vnum)) == NULL )    {	send_to_char( "Mobile not found./n/r", ch );	return;    }    if ( !can_medit(ch, mob) )      return;    if ( !mob->pShop )    {	send_to_char( "This mobile doesn't keep a shop./n/r", ch );	return;    }    shop = mob->pShop;    value = atoi( argument );    if ( !str_cmp( arg2, "buy0" ) )    {	if ( !is_number(argument) )	    value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	shop->buy_type[0] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "buy1" ) )    {	if ( !is_number(argument) )	    value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	shop->buy_type[1] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "buy2" ) )    {	if ( !is_number(argument) )	  value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	shop->buy_type[2] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "buy3" ) )    {	if ( !is_number(argument) )	  value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )	{	    send_to_char( "Invalid item type!/n/r", ch );	    return;	}	shop->buy_type[3] = value;	send_to_char( "Done./n/r", ch );	return;    }    if ( !str_cmp( arg2, "buy4" ) )    {	if ( !is_number(argument) )	  value = get_otype(argument);	if ( value < 0 || value > MAX_ITEM_TYPE )//.........这里部分代码省略.........
开发者ID:smthbh,项目名称:SWFotE-Mud,代码行数:101,


示例14: load_char_objs

void load_char_objs(struct char_data *ch){  FILE *fl;  bool found = FALSE;  float timegold;  struct obj_file_u st;  char buf[200];/*  load in aliases and poofs first*/  load_char_extra(ch);    sprintf(buf, "rent/%s", lower(ch->player.name));    /* r+b is for Binary Reading/Writing */  if (!(fl = fopen(buf, "r+b")))  {    log_msg("Char has no equipment");    return;  }  rewind(fl);  if (!ReadObjs(fl, &st)) {    log_msg("No objects found");    fclose(fl);    return;  }  if (str_cmp(st.owner, GET_NAME(ch)) != 0) {    log_msg("Hmm.. bad item-file write. someone is losing thier objects");    fclose(fl);    return;  }/*  if the character has been out for 12 real hours, they are fully healed  upon re-entry.  if they stay out for 24 full hours, all affects are  removed, including bad ones.*/    if (st.last_update + 12*SECS_PER_REAL_HOUR < time(0))      RestoreChar(ch);    if (st.last_update + 24*SECS_PER_REAL_HOUR < time(0))      RemAllAffects(ch);        if (ch->in_room == NOWHERE &&	st.last_update + 1*SECS_PER_REAL_HOUR > time(0)) {	/* you made it back from the crash in time, 1 hour grace period. */      log_msg("Character reconnecting.");      found = TRUE;    } else {      char	buf[MAX_STRING_LENGTH];      if (ch->in_room == NOWHERE)	log_msg("Char reconnecting after autorent");#if NEW_RENT      timegold = (int) ((100*((float)time(0) - st.last_update)) / 			(SECS_PER_REAL_DAY));#else      timegold = (int) ((st.total_cost*((float)time(0) - st.last_update)) / 			(SECS_PER_REAL_DAY));#endif      sprintf(buf, "Char ran up charges of %g gold in rent", timegold);      log_msg(buf);      sprintf(buf, "You ran up charges of %g gold in rent./n/r", timegold);      send_to_char(buf, ch);      GET_GOLD(ch) -= timegold;      found = TRUE;          if (GET_GOLD(ch) < 0) {	log_msg("Char ran out of money in rent");        send_to_char("You ran out of money, you deadbeat./n/r", ch);	GET_GOLD(ch) = 0;	found = FALSE;      }    }  fclose(fl);  if (found)      obj_store_to_char(ch, &st);  else {    ZeroRent(GET_NAME(ch));  }    /* Save char, to avoid strange data if crashing */  save_char(ch, AUTO_RENT);  }
开发者ID:lolindrath,项目名称:SillyMUD,代码行数:95,


示例15: main

int main(int argc, char **argv){	int rc;	umseconds_t milliseconds_taken;	char *path = NULL;	measure_func_t fn = NULL;	int iteration;	int iterations;	char *log_str = NULL;	char *test_type = NULL;	char *endptr;		if (argc < 5) {		fprintf(stderr, NAME ": Error, argument missing./n");		syntax_print();		return 1;	}		if (argc > 5) {		fprintf(stderr, NAME ": Error, too many arguments./n");		syntax_print();		return 1;	}		// Skip program name	--argc; ++argv;	iterations = strtol(*argv, &endptr, 10);	if (*endptr != '/0') {		printf(NAME ": Error, invalid argument (iterations)./n");		syntax_print();		return 1;	}		--argc; ++argv;	test_type = *argv;	--argc; ++argv;	log_str = *argv;	--argc; ++argv;	path = *argv;		if (str_cmp(test_type, "sequential-file-read") == 0) {		fn = sequential_read_file;	}	else if (str_cmp(test_type, "sequential-dir-read") == 0) {		fn = sequential_read_dir;	}	else {		fprintf(stderr, "Error, unknown test type/n");		syntax_print();		return 1;	}	for (iteration = 0; iteration < iterations; iteration++) {		rc = measure(fn, path, &milliseconds_taken);		if (rc != EOK) {			fprintf(stderr, "Error %d/n", rc);			return 1;		}			printf("%s;%s;%s;%lu;ms/n", test_type, path, log_str, milliseconds_taken);	}	return 0;}
开发者ID:fhector,项目名称:helenOS-0.5-Hector,代码行数:67,


示例16: skill_ethereal_wolf

int skill_ethereal_wolf( int sn, int level, CHAR_DATA *ch, void *vo ){    AFFECT_DATA af;    char arg [ MAX_INPUT_LENGTH ];    CHAR_DATA *victim;   /*    if ( !IS_NPC( ch )        && ( ( ch->level < skill_table[sn].skill_level[ch->class] )        && (ch->level < skill_table[sn].skill_level[ch->multied])))    {        send_to_char(C_DEFAULT, "You can not perform that skill./n/r", ch );        return SKPELL_MISSED;    }*/    // modified check so if NPCs have spell on already    // they can use bite/howl/etc - Ahsile    if ( IS_NPC(ch) || number_percent( ) > ( ch->pcdata->learned[sn] / 10 )  )    {	if (IS_NPC(ch))	{		if (!IS_AFFECTED4(ch, AFF_ETHEREAL_WOLF))		{				send_to_char( C_DEFAULT, "You failed./n/r", ch );			return SKPELL_MISSED;		}	} else	{			send_to_char( C_DEFAULT, "You failed./n/r", ch );			return SKPELL_MISSED;	}    }           if ( !ch->fighting )    {	if ( IS_AFFECTED4( ch, AFF_ETHEREAL_WOLF ) )	{	    send_to_char( AT_DGREY, "You replace your ethereal wolf with a new one./n/r", ch );	    return SKPELL_NO_DAMAGE;	}	/* TO DO: Mana costs */   	af.type = sn;	af.level = ch->level;	af.duration = ch->level;	af.location = APPLY_NONE;	af.modifier = 0;	af.bitvector = AFF_ETHEREAL_WOLF;	affect_to_char4(ch, &af);	act( AT_DGREY, "$n summons an ethereal wolf!", ch, NULL, NULL, TO_ROOM );	send_to_char( AT_DGREY, "You have summoned an ethereal wolf to assist you./n/r", ch );	WAIT_STATE( ch, skill_table[sn].beats );	return SKPELL_NO_DAMAGE;    }    /* Wolf commands will go here */    victim = ch->fighting;    if (target_name[0] == '/0')    {	send_to_char( AT_DGREY, "You get the attention of your wolf./n/r", ch );	act( AT_DGREY, "$n gets the attention of $m wolf.", ch, NULL, NULL, TO_ROOM );	return SKPELL_NO_DAMAGE;    }    if ( !str_cmp( target_name, "bite" ) )    {	send_to_char( AT_DGREY, "You order your wolf to bite!/n/r", ch );	act( AT_DGREY, "$n orders $m ethereal wolf to bite!", ch, NULL, NULL, TO_ROOM );	WAIT_STATE( ch, skill_table[skill_lookup("ethereal wolf bite")].beats );	return spell_ethereal_wolf_bite ( skill_lookup("ethereal wolf bite"), ch->level, ch, victim );	    }    if ( !str_cmp( arg, "claw" ) )    {	send_to_char( AT_DGREY, "You order your wolf to claw!/n/r", ch );	act( AT_DGREY, "$n orders $m ethereal wolf to claw!", ch, NULL, NULL, TO_ROOM );	WAIT_STATE( ch, skill_table[skill_lookup("ethereal wolf claw")].beats );	return spell_ethereal_wolf_claw ( skill_lookup("ethereal wolf claw"), ch->level, ch, victim );    }    if ( !str_cmp( arg, "howl" ) )    {	send_to_char( AT_DGREY, "You order your wolf to howl!/n/r", ch );	act( AT_DGREY, "$n orders $m ethereal wolf to howl!", ch, NULL, NULL, TO_ROOM );	spell_ethereal_wolf_howl ( skill_lookup("ethereal wolf howl"), ch->level, ch, victim );    	WAIT_STATE( ch, skill_table[skill_lookup("ethereal wolf howl")].beats / 2);	send_to_char( AT_DGREY, "You are terrified!/n/r", victim );	if( !saves_spell( ch->level, victim ) )	{	    WAIT_STATE( victim, skill_table[skill_lookup("ethereal wolf howl")].beats );	}    //.........这里部分代码省略.........
开发者ID:rayhe,项目名称:stormgate,代码行数:101,


示例17: do_note

/* Date stamp idea comes from Alander of ROM */void do_note( CHAR_DATA *ch, const char *argument ){    NOTE_DATA *pnote;    char       buf  [ MAX_STRING_LENGTH   ];    char       buf1 [ MAX_STRING_LENGTH*7 ];    char       arg  [ MAX_INPUT_LENGTH    ];    int        vnum;    int        anum;    if ( IS_NPC( ch ) )	return;    argument = one_argument( argument, arg );    smash_tilde( argument );    if ( arg[0] == '/0' )    {	do_note( ch, "read" );	return;    }    if ( !str_cmp( arg, "list" ) )    {	vnum    = 0;	buf1[0] = '/0';	for ( pnote = note_list; pnote; pnote = pnote->next )	{	    if ( is_note_to( ch, pnote ) )	    {		sprintf( buf, "[%3d%s] %s: %s/n/r",			vnum,			( pnote->date_stamp > ch->last_note			 && str_cmp( pnote->sender, ch->name ) ) ? "N" : " ",			pnote->sender, pnote->subject );		strcat( buf1, buf );		vnum++;	    }	}	send_to_char( buf1, ch );	return;    }    if ( !str_cmp( arg, "read" ) )    {	bool fAll;	if ( !str_cmp( argument, "all" ) )	{	    fAll = TRUE;	    anum = 0;	}	else if ( argument[0] == '/0' || !str_prefix( argument, "next" ) )	  /* read next unread note */	{	    vnum    = 0;	    buf1[0] = '/0';	    for ( pnote = note_list; pnote; pnote = pnote->next )	    {		if ( is_note_to( ch, pnote )		    && str_cmp( ch->name, pnote->sender )		    && ch->last_note < pnote->date_stamp )		{		    break;		}		else		{		    if ( is_note_to( ch, pnote ) )		        vnum++;		}	    }	    if ( pnote )	    {		sprintf( buf, "[%3d] %s: %s/n/r%s/n/rTo: %s/n/r",			vnum,			pnote->sender,			pnote->subject,			pnote->date,			pnote->to_list );		strcat( buf1, buf );		strcat( buf1, pnote->text );		ch->last_note = UMAX( ch->last_note, pnote->date_stamp );		send_to_char( buf1, ch );		return;	    }	    send_to_char( "You have no unread notes./n/r", ch );	    return;	}	else if ( is_number( argument ) )	{	    fAll = FALSE;	    anum = atoi( argument );	}	else	{	    send_to_char( "Note read which number?/n/r", ch );	    return;	}	vnum    = 0;//.........这里部分代码省略.........
开发者ID:lolindrath,项目名称:EnvyMUD,代码行数:101,


示例18: print_comparison

void print_comparison(char *a, char *b){  int result = str_cmp(a, b);  printf("%s == %s? %d:(%d)/n", a, b, (result == 0), result);}
开发者ID:Blaise2016,项目名称:c-programming,代码行数:5,


示例19: load_bits

/* Load the abits and qbits */void load_bits( void ){   char buf[MAX_STRING_LENGTH];   char *word;   bool fMatch;   int mode = 0;   BIT_DATA *bit = NULL;   FILE *fp;   sprintf( buf, "%sabit.lst", SYSTEM_DIR );   if( ( fp = fopen( buf, "r" ) ) == NULL )   {      perror( buf );      return;   }   for( ;; )   {      word = feof( fp ) ? "End" : fread_word( fp );      fMatch = FALSE;      switch ( UPPER( word[0] ) )      {         case '*':            fMatch = TRUE;            fread_to_eol( fp );            break;         case '#':            if( !str_cmp( word, "#END" ) )            {               fclose( fp );               if( mode == 0 )               {                  mode = 1;   /* We have two files to read, I reused the same code to read both */                  sprintf( buf, "%sqbit.lst", SYSTEM_DIR );                  if( ( fp = fopen( buf, "r" ) ) == NULL )                  {                     perror( buf );                     return;                  }               }               else                  return;               fMatch = TRUE;            }            break;         case 'D':            if( !str_cmp( word, "Desc" ) )            {               fMatch = TRUE;               strcpy( bit->desc, fread_string( fp ) );            }            break;         case 'E':            if( !strcmp( word, "End" ) )            {               if( mode == 0 )                  LINK( bit, first_abit, last_abit, next, prev );               else                  LINK( bit, first_qbit, last_qbit, next, prev );               bit = NULL;               fMatch = TRUE;            }            break;         case 'N':            if( !strcmp( word, "Number" ) )            {               CREATE( bit, BIT_DATA, 1 );               bit->number = fread_number( fp );               fMatch = TRUE;            }            break;      }      if( !fMatch )      {         sprintf( buf, "load_bits: no match: %s", word );         bug( buf, 0 );      }   }}
开发者ID:jmdjr,项目名称:sdf-mud,代码行数:86,


示例20: do_plantbug

void do_plantbug( CHAR_DATA * ch, char *argument ){   CHAR_DATA *victim;   BUG_DATA *pbug;   BUG_DATA *cbug;   OBJ_DATA *obj;   bool checkbug = FALSE;   int schance;   if( IS_NPC( ch ) )      return;   if( ( victim = get_char_room( ch, argument ) ) == NULL )   {      send_to_char( "They aren't here./n/r", ch );      return;   }   if( IS_NPC( victim ) )   {      send_to_char( "You can't bug NPC's!/n/r", ch );      return;   }   if( IS_IMMORTAL( victim ) )   {      send_to_char( "Don't try to plant bugs on immortals./n/r", ch );      return;   }   if( in_arena( ch ) )   {      send_to_char( "You're here to FIGHT, not spy./n/r", ch );      return;   }   if( ch == victim )   {      send_to_char( "You can't bug yourself!/n/r", ch );      return;   }   for( obj = ch->last_carrying; obj; obj = obj->prev_content )      if( obj->item_type == ITEM_BUG )         checkbug = TRUE;   if( checkbug == FALSE )   {      send_to_char( "You don't have any bugs to plant./n/r", ch );      return;   }   for( cbug = victim->first_bug; cbug; cbug = cbug->next_in_bug )      if( !str_cmp( ch->name, cbug->name ) )      {         send_to_char( "You have already planted a bug on this person./n/r", ch );         return;      }   schance = number_percent(  ) - UMIN( 0, ( get_curr_lck( ch ) - 14 ) ) + UMIN( 0, ( get_curr_lck( victim ) - 13 ) );   if( schance < ch->pcdata->learned[gsn_plantbug] )   {      act( AT_WHITE, "You carefully reach into $N's pocket and place a bug.", ch, NULL, victim, TO_CHAR );      CREATE( pbug, BUG_DATA, 1 );      pbug->name = ch->name;      LINK( pbug, victim->first_bug, victim->last_bug, next_in_bug, prev_in_bug );      learn_from_success( ch, gsn_plantbug );      for( obj = ch->last_carrying; obj; obj = obj->prev_content )      {         if( obj->item_type == ITEM_BUG )         {            separate_obj( obj );            obj_from_char( obj );            extract_obj( obj );            break;         }      }      return;   }   else   {      send_to_char( "&RYou try to find a pocket to plant the bug in but fail!/n/r", ch );      learn_from_failure( ch, gsn_plantbug );      if( number_bits( 0 ) == 0 )         ch_printf( victim, "You feel a slight brush against your pocket to find %s's hand there./n/r", PERS( ch, victim ) );      return;   }}
开发者ID:ccubed,项目名称:SWFoteCustom,代码行数:90,


示例21: parse_attribute_crypto

//.........这里部分代码省略.........	err = "unknown crypto suite";	if (!c->crypto_suite)		goto error;	salt_key_len = c->crypto_suite->master_key_len			+ c->crypto_suite->master_salt_len;	enc_salt_key_len = ceil((double) salt_key_len * 4.0/3.0);	err = "invalid key parameter length";	if (c->key_params_str.len < 7 + enc_salt_key_len)		goto error;	err = "unknown key method";	if (strncasecmp(c->key_params_str.s, "inline:", 7))		goto error;	c->key_base64_str = c->key_params_str;	str_shift(&c->key_base64_str, 7);	ret = g_base64_decode_step(c->key_base64_str.s, enc_salt_key_len,			(guchar *) c->key_salt_buf, &b64_state, &b64_save);	err = "invalid base64 encoding";	if (ret != salt_key_len)		goto error;	c->master_key.s = c->key_salt_buf;	c->master_key.len = c->crypto_suite->master_key_len;	c->salt.s = c->master_key.s + c->master_key.len;	c->salt.len = c->crypto_suite->master_salt_len;	c->lifetime_str = c->key_params_str;	str_shift(&c->lifetime_str, 7 + enc_salt_key_len);	if (c->lifetime_str.len >= 2) {		err = "invalid key parameter syntax";		if (c->lifetime_str.s[0] != '|')			goto error;		str_shift(&c->lifetime_str, 1);		str_chr_str(&c->mki_str, &c->lifetime_str, '|');		if (!c->mki_str.s) {			if (str_chr(&c->lifetime_str, ':')) {				c->mki_str = c->lifetime_str;				c->lifetime_str = STR_NULL;			}		}		else {			c->lifetime_str.len = c->mki_str.s - c->lifetime_str.s;			str_shift(&c->mki_str, 1);		}	}	else		c->lifetime_str = STR_NULL;	if (c->lifetime_str.s) {		if (c->lifetime_str.len >= 3 && !memcmp(c->lifetime_str.s, "2^", 2)) {			c->lifetime = strtoull(c->lifetime_str.s + 2, NULL, 10);			err = "invalid key lifetime";			if (!c->lifetime || c->lifetime > 64)				goto error;			c->lifetime = 1ULL << c->lifetime;		}		else			c->lifetime = strtoull(c->lifetime_str.s, NULL, 10);		err = "invalid key lifetime";		if (!c->lifetime || c->lifetime > c->crypto_suite->srtp_lifetime#ifdef STRICT_SDES_KEY_LIFETIME				|| c->lifetime > c->crypto_suite->srtcp_lifetime#endif				)			goto error;	}	if (c->mki_str.s) {		str_chr_str(&s, &c->mki_str, ':');		err = "invalid MKI specification";		if (!s.s)			goto error;		u32 = htonl(strtoul(c->mki_str.s, NULL, 10));		c->mki_len = strtoul(s.s + 1, NULL, 10);		err = "MKI too long";		if (c->mki_len > sizeof(c->mki))			goto error;		memset(c->mki, 0, c->mki_len);		if (sizeof(u32) >= c->mki_len)			memcpy(c->mki, ((void *) &u32) + (sizeof(u32) - c->mki_len), c->mki_len);		else			memcpy(c->mki + (c->mki_len - sizeof(u32)), &u32, sizeof(u32));	}	while (extract_token(&start, end, &s) == 0) {		if (!str_cmp(&s, "UNENCRYPTED_SRTCP"))			c->unencrypted_srtcp = 1;		else if (!str_cmp(&s, "UNENCRYPTED_SRTP"))			c->unencrypted_srtp = 1;		else if (!str_cmp(&s, "UNAUTHENTICATED_SRTP"))			c->unauthenticated_srtp = 1;	}	return 0;error:	ilog(LOG_ERROR, "Failed to parse a=crypto attribute: %s", err);	return -1;}
开发者ID:jungle0755,项目名称:rtpengine,代码行数:101,


示例22: do_contract

//Contract System by Tawnos.void do_contract( CHAR_DATA * ch, char *argument ){   CHAR_DATA *victim;   CHAR_DATA *target;   char arg1[MAX_INPUT_LENGTH];   char arg2[MAX_INPUT_LENGTH];   char arg3[MAX_INPUT_LENGTH];   long amount = 0;   CONTRACT_DATA *ccontract;   CONTRACT_DATA *contract;   argument = one_argument( argument, arg1 );   argument = one_argument( argument, arg2 );   argument = one_argument( argument, arg3 );   if( IS_NPC( ch ) )      return;   if( arg1[0] == '/0' || arg2[0] == '/0' || arg3[0] == '/0' )   {      send_to_char( "&RSyntax: contract <person> <target> <amount>/n/r", ch );      return;   }   if( ( victim = get_char_room( ch, arg1 ) ) == NULL )   {      send_to_char( "They aren't here./n/r", ch );      return;   }   if( ( target = get_char_world_ooc( ch, arg2 ) ) == NULL )   {      send_to_char( "Your target is currently not online./n/r", ch );      return;   }   if( ch == victim )   {      send_to_char( "You can't contract yourself!/n/r", ch );      return;   }   if( IS_NPC( victim ) || IS_NPC( target ) )   {      send_to_char( "You can't contract NPC's./n/r", ch );      return;   }   if( ch == target )   {      send_to_char( "You can't contract against yourself!/n/r", ch );      return;   }   if( target == victim )   {      send_to_char( "You can't contract them to kill themself!/n/r", ch );      return;   }   amount = atoi( arg3 );   if( amount < 5000 )   {      send_to_char( "&RYour contract must be for at least 5000 credits./n/r", ch );      return;   }   if( ch->gold < amount )   {      send_to_char( "&RYou don't have enough credits!/n/r", ch );      return;   }   for( ccontract = victim->first_contract; ccontract; ccontract = ccontract->next_in_contract )   {      if( !str_cmp( ccontract->target, target->name ) )      {         ch->gold -= amount;         ccontract->amount += amount;         ch_printf( ch, "&GYou have contracted %s to kill %s for an amount of %d credits./n/r", PERS( victim, ch ),                    target->name, amount );         ch_printf( victim, "&G%s has contracted you to kill %s, raising your contract reward by %d credits./n/r",                    PERS( ch, victim ), target->name, amount );         return;      }   }   CREATE( contract, CONTRACT_DATA, 1 );   contract->target = target->name;   contract->amount = amount;   LINK( contract, victim->first_contract, victim->last_contract, next_in_contract, prev_in_contract );   ch->gold -= amount;   ch_printf( ch, "&GYou have contracted %s to kill %s for an amount of %d credits./n/r", PERS( victim, ch ), target->name,              amount );   ch_printf( victim, "&G%s has contracted you to kill %s for an amount of %d credits./n/r", PERS( ch, victim ),              target->name, amount );//.........这里部分代码省略.........
开发者ID:ccubed,项目名称:SWFoteCustom,代码行数:101,


示例23: parse_attribute

static int parse_attribute(struct sdp_attribute *a) {	int ret;	a->name = a->line_value;	str_chr_str(&a->value, &a->name, ':');	if (a->value.s) {		a->name.len -= a->value.len;		a->value.s++;		a->value.len--;		a->key = a->name;		str_chr_str(&a->param, &a->value, ' ');		if (a->param.s) {			a->key.len += 1 +				(a->value.len - a->param.len);			a->param.s++;			a->param.len--;			if (!a->param.len)				a->param.s = NULL;		}		else			a->key.len += 1 + a->value.len;	}	ret = 0;	switch (a->name.len) {		case 3:			if (!str_cmp(&a->name, "mid"))				a->attr = ATTR_MID;			break;		case 4:			if (!str_cmp(&a->name, "rtcp"))				ret = parse_attribute_rtcp(a);			else if (!str_cmp(&a->name, "ssrc"))				ret = parse_attribute_ssrc(a);			break;		case 5:			if (!str_cmp(&a->name, "group"))				ret = parse_attribute_group(a);			else if (!str_cmp(&a->name, "setup"))				ret = parse_attribute_setup(a);			break;		case 6:			if (!str_cmp(&a->name, "crypto"))				ret = parse_attribute_crypto(a);			else if (!str_cmp(&a->name, "extmap"))				a->attr = ATTR_EXTMAP;			else if (!str_cmp(&a->name, "rtpmap"))				ret = parse_attribute_rtpmap(a);			break;		case 7:			if (!str_cmp(&a->name, "ice-pwd"))				a->attr = ATTR_ICE_PWD;			break;		case 8:			switch (a->name.s[0]) {				case 'i':					if (!str_cmp(&a->name, "ice-lite"))						a->attr = ATTR_ICE_LITE;					else if (!str_cmp(&a->name, "inactive"))						a->attr = ATTR_INACTIVE;					break;				case 's':					if (!str_cmp(&a->name, "sendrecv"))						a->attr = ATTR_SENDRECV;					else if (!str_cmp(&a->name, "sendonly"))						a->attr = ATTR_SENDONLY;					break;				case 'r':					if (!str_cmp(&a->name, "recvonly"))						a->attr = ATTR_RECVONLY;					if (!str_cmp(&a->name, "rtcp-mux"))						a->attr = ATTR_RTCP_MUX;					break;			}			break;		case 9:			if (!str_cmp(&a->name, "candidate"))				ret = parse_attribute_candidate(a);			else if (!str_cmp(&a->name, "ice-ufrag"))				a->attr = ATTR_ICE_UFRAG;			break;		case 11:			if (!str_cmp(&a->name, "ice-options"))				a->attr = ATTR_ICE_OPTIONS;			else if (!str_cmp(&a->name, "fingerprint"))				ret = parse_attribute_fingerprint(a);			break;		case 12:			if (!str_cmp(&a->name, "ice-mismatch"))				a->attr = ATTR_ICE;			break;		case 17:			if (!str_cmp(&a->name, "remote-candidates"))				a->attr = ATTR_ICE;			break;	}//.........这里部分代码省略.........
开发者ID:jungle0755,项目名称:rtpengine,代码行数:101,


示例24: do_order

void do_order( CHAR_DATA * ch, char * argument ) {  CHAR_DATA * victim;  CHAR_DATA * och;  CHAR_DATA * och_next;  char        arg[ MAX_INPUT_LENGTH ];  bool        found;  bool        fAll;  argument = one_argument( argument, arg );  if ( arg[ 0 ] == '/0' || argument[ 0 ] == '/0' ) {    send_to_char( AT_GREY, "Order whom to do what?/n/r", ch );    return;  }  if ( IS_AFFECTED( ch, AFF_CHARM ) ) {    send_to_char( AT_GREY, "You feel like taking, not giving, orders./n/r", ch );    return;  }  if ( !str_cmp( arg, "all" ) ) {    fAll   = TRUE;    victim = NULL;  } else {    fAll = FALSE;    if ( !( victim = get_char_room( ch, arg ) ) ) {      send_to_char( AT_GREY, "They aren't here./n/r", ch );      return;    }    if ( victim == ch ) {      send_to_char( AT_GREY, "Aye aye, right away!/n/r", ch );      return;    }    if ( !IS_AFFECTED( victim, AFF_CHARM ) || victim->master != ch ) {      send_to_char( AT_GREY, "Do it yourself!/n/r", ch );      return;    }  }  found = FALSE;  for ( och = ch->in_room->people; och; och = och_next ) {    och_next = och->next_in_room;    if ( och->deleted ) {      continue;    }    /* You cannot order a newbie helper around period. Angi */    if ( IS_NPC( och ) ) {      if ( CHECK_BIT( och->act, ACT_NEWBIE ) ) {        continue;      }    }    if ( IS_AFFECTED( och, AFF_CHARM )         && och->master == ch         && ( fAll || och == victim ) ) {      found = TRUE;      act( AT_GREY, "$n orders you to '$t'.", ch, argument, och, TO_VICT );      interpret( och, argument );    }  }  if ( found ) {    send_to_char( AT_GREY, "Ok./n/r", ch );  } else {    send_to_char( AT_GREY, "You have no followers here./n/r", ch );  }  return;}
开发者ID:zachflower,项目名称:oasis-mud,代码行数:75,


示例25: sort_adminlist

void sort_adminlist( ){  ADMINENT *admin, *tmp, *next;  COUNCIL_DATA *council;  bool run = TRUE, head = FALSE, thead = FALSE;  while ( run )  {    run = FALSE;    for ( admin = first_admin; admin; admin = admin->next )    {  	tmp = admin->next;	if ( tmp )	{	   if ( strcmp( admin->name, tmp->name)>0)	   {	     if ( tmp->next )	     	tmp->next->last = admin;	     if ( admin->last )	        admin->last->next = tmp;	     next = tmp->next;	     tmp->next = admin;	     tmp->last = admin->last;	     admin->next = next;	     admin->last = tmp;	     if ( last_admin == tmp )	     	last_admin = admin;	     if ( first_admin == admin )	        first_admin = tmp;	     run = TRUE;	   }	}    }  }  run = TRUE;  while ( run )  {    run = FALSE;    for ( admin = first_admin; admin; admin = admin->next )    {  	tmp = admin->next;	if ( tmp )	{	   if ( tmp->level > admin->level )	   {	     if ( tmp->next )	     	tmp->next->last = admin;	     if ( admin->last )	        admin->last->next = tmp;	     next = tmp->next;	     tmp->next = admin;	     tmp->last = admin->last;	     admin->next = next;	     admin->last = tmp;	     if ( last_admin == tmp )	     	last_admin = admin;	     if ( first_admin == admin )	        first_admin = tmp;	     run = TRUE;	   }	}    }  }  run = TRUE;  while ( run )  {    run = FALSE;    for ( admin = first_admin; admin; admin = admin->next )    {      head = FALSE;      thead = FALSE;      tmp = admin->next;      if ( tmp )      {        for ( council = first_council; council; council = council->next )        {      	   if ( !str_cmp( council->head, admin->name) || ( council->head2 &&	 	!str_cmp( council->head2, admin->name) ) )		  head = TRUE;      	   if ( !str_cmp( council->head, tmp->name) || ( council->head2 &&	 	!str_cmp( council->head2, tmp->name) ) )		  thead = TRUE;        }	   if ( thead && !head )	   {	     if ( tmp->next )	     	tmp->next->last = admin;	     if ( admin->last )	        admin->last->next = tmp;	     next = tmp->next;	     tmp->next = admin;	     tmp->last = admin->last;	     admin->next = next;	     admin->last = tmp;	     if ( last_admin == tmp )	     	last_admin = admin;	     if ( first_admin == admin )	        first_admin = tmp;//.........这里部分代码省略.........
开发者ID:bkero,项目名称:Smaug,代码行数:101,


示例26: do_split

/* * 'Split' originally by Gnort, God of Chaos. */void do_split( CHAR_DATA * ch, char * argument ) {  CHAR_DATA * gch;  char        buf[ MAX_STRING_LENGTH ];  char        arg[ MAX_INPUT_LENGTH  ];  int         members;  int         amount = 0;  int         share  = 0;  int         extra  = 0;  MONEY_DATA  amt;  char        arg2[ MAX_STRING_LENGTH ];  argument = one_argument( argument, arg );  argument = one_argument( argument, arg2 );  if ( arg[ 0 ] == '/0' ) {    send_to_char( AT_YELLOW, "Split how much?/n/r", ch );    return;  }  /* split 5 copper,gold,silver */  amount   = is_number( arg ) ? atoi( arg ) : 0;  amt.gold = amt.silver = amt.copper = 0;  if ( !str_cmp( arg2, "gold" ) ) {    amt.gold = amount;  } else if ( !str_cmp( arg2, "silver" ) ) {    amt.silver = amount;  } else if ( !str_cmp( arg2, "copper" ) ) {    amt.copper = amount;  } else {    send_to_char( AT_WHITE, "&WSyntax: &Rsplit <amount> <currency type>/n/r",                  ch );    return;  }  if ( ( amt.gold < 0 ) || ( amt.silver < 0 )       || ( amt.copper < 0 ) ) {    send_to_char( AT_YELLOW, "Your group wouldn't like that./n/r", ch );    return;  }  if ( ( amt.gold == 0 ) && ( amt.silver == 0 )       && ( amt.copper == 0 ) ) {    send_to_char( AT_YELLOW, "You hand out zero coins, but no one notices./n/r",                  ch );    return;  }  if ( ( ch->money.gold < amt.gold ) || ( ch->money.silver < amt.silver )       || ( ch->money.copper < amt.copper ) ) {    sprintf( buf, "You don't have that many %s coins./n/r", arg2 );    send_to_char( AT_YELLOW, buf, ch );    return;  }  members = 0;  for ( gch = ch->in_room->people; gch; gch = gch->next_in_room ) {    if ( gch->deleted ) {      continue;    }    if ( is_same_group( gch, ch ) ) {      members++;    }  }  if ( members < 2 ) {    return;  }  share = amount / members;  extra = amount % members;  if ( share == 0 ) {    send_to_char( AT_YELLOW, "Don't even bother, cheapskate./n/r", ch );    return;  }  if ( !str_cmp( arg2, "gold" ) ) {    ch->money.gold -= amount;    ch->money.gold += share + extra;  } else if ( !str_cmp( arg2, "silver" ) ) {    ch->money.silver -= amount;    ch->money.silver += share + extra;  } else if ( !str_cmp( arg2, "copper" ) ) {    ch->money.copper -= amount;    ch->money.silver += share + extra;  }  sprintf( buf,           "You split %s  Your share is %d %s coins./n/r",           money_string( &amt ), share + extra, arg2 );  send_to_char( AT_YELLOW, buf, ch );  sprintf( buf, "$n splits %s  Your share is %d %s coins.",//.........这里部分代码省略.........
开发者ID:zachflower,项目名称:oasis-mud,代码行数:101,


示例27: index_querybuild

//.........这里部分代码省略.........                        state = CONJUNCT_TYPE_WORD;   /* stop AND condition */                        maxterms += current->terms - 1;                        query->terms--;                    }                } else if (current && (state == CONJUNCT_TYPE_PHRASE)) {                    /* same, except phrase continues until end-phrase */                    if (current->f_qt > 1) {                        current->f_qt--;                    } else {                        maxterms += current->terms - 1;                        query->terms--;                    }                }                current = NULL;            } else if (state == CONJUNCT_TYPE_PHRASE) {                /* OPTIMIZE: check word against excluded terms */                struct term *currterm;                /* processing a phrase */                if (!currmatch) {                    /* first word in phrase, match or add a conjunction */                    current = conjunct_add(query, &entry,                      /* ve, veclen,  */                      word, wordlen,                       CONJUNCT_TYPE_PHRASE, &maxterms);                    currmatch = 1;                } else if (current && (current->f_qt > 1)) {                    /* we're matching an existing phrase */                     /* iterate to next term we need to match */                    for (i = 0, currterm = &current->term; i < currmatch;                       i++, currterm = currterm->next) ;                    if (currterm && !str_cmp(currterm->term, word)) {                        /* matched */                        currmatch++;                    } else {                        /* didn't match, copy non-matching phrase */                        current->f_qt--;                        current = conjunct_copy(query, current, currmatch,                           &entry, word, wordlen, &maxterms);                        currmatch++;                    }                } else if (current) {                    /* we're building a new phrase, add next word on */                    conjunct_append(query, current,                       &entry,                     /* ve, veclen, */                      word, wordlen,                       &maxterms);                    currmatch++;                }                /* otherwise we're ignoring this phrase (because it contains a                 * word thats not in the vocab) */            } else if (state == CONJUNCT_TYPE_AND) {                /* we are constructing an AND conjunction */                /* FIXME: stop word                 stopped = 1;                current = NULL; */                /* OPTIMIZE: check word against excluded terms */                if (current) {                    if ((current->type == CONJUNCT_TYPE_AND) 
开发者ID:eckucukoglu,项目名称:zettair,代码行数:67,


示例28: mpedit

void mpedit( CHAR_DATA *ch, char *argument ){    PROG_CODE * pMcode;    char arg[ MAX_INPUT_LENGTH ];    char command[ MAX_INPUT_LENGTH ];    char log_buf[ MAX_STRING_LENGTH ];    int cmd;    AREA_DATA *ad;    smash_tilde( argument );    strcpy( arg, argument );    argument = one_argument( argument, command );    EDIT_MPCODE( ch, pMcode );    if ( pMcode )    {        ad = pMcode->area;        if ( ad == NULL )  /* ? */        {            edit_done( ch );            return ;        }        if ( !IS_BUILDER( ch, ad ) )        {            send_to_char( "MPEdit: Insufficient security to modify code./n/r", ch );            edit_done( ch );            return ;        }    }    if ( command[ 0 ] == '/0' )    {        mpedit_show( ch, argument );        return ;    }    if ( !str_cmp( command, "done" ) )    {        edit_done( ch );        return ;    }    for ( cmd = 0; mpedit_table[ cmd ].name != NULL; cmd++ )    {        if ( !str_prefix( command, mpedit_table[ cmd ].name ) )        {            if ( ( *mpedit_table[ cmd ].olc_fun ) ( ch, argument ) && pMcode )            {                if ( ( ad = pMcode->area ) != NULL )                {                    SET_BIT( ad->area_flags, AREA_CHANGED );                }                append_file_format_daily( ch, BUILD_LOG_FILE, "-> mpedit %s: %s", pMcode ? pMcode->name: "0", arg );            }            return ;        }    }    interpret( ch, arg );    return ;}
开发者ID:KillerMud,项目名称:Source,代码行数:65,


示例29: do_recruit

void do_recruit (CHAR_DATA *ch, char *argument, int cmd){	CHAR_DATA	*pal = NULL;	char		buf [MAX_STRING_LENGTH];	argument = one_argument (argument, buf);	if ( !*buf ) {		for ( pal = ch->room->people; pal; pal = pal->next_in_room ) {			if ( IS_NPC (pal) &&				 pal->following != ch &&				 is_leader (ch, pal) )				break;		}		if ( !pal ) {			send_to_char ("Nobody else here will follow you./n/r", ch);			return;		}		pal->following = ch;		act ("$N nods to you to follow.", FALSE, pal, 0, ch, TO_CHAR | TO_ACT_FORMAT);		act ("$N motions to $S clanmates.", FALSE, pal, 0, ch, TO_NOTVICT | TO_ACT_FORMAT);		act ("$n falls in.", FALSE, pal, 0, ch, TO_ROOM | TO_ACT_FORMAT);		return;	}	if ( !str_cmp (buf, "all") ) {		act ("$n motions to $s clanmates.", FALSE, ch, 0, 0, TO_ROOM | TO_ACT_FORMAT);		for ( pal = ch->room->people; pal; pal = pal->next_in_room ) {			if ( IS_NPC (pal) &&				 pal->following != ch &&				 is_leader (ch, pal) ) {				pal->following = ch;				act ("$N nods to you to follow.", FALSE, pal, 0, ch, TO_CHAR | TO_ACT_FORMAT);				act ("$n falls in.", FALSE, pal, 0, ch, TO_ROOM | TO_ACT_FORMAT);			}		}		if ( !pal ) {			send_to_char ("Nobody else here will follow you./n/r", ch);			return;		}		return;	}	if ( !(pal = get_char_room_vis (ch, buf)) ) {		send_to_char ("Nobody is here by that name./n/r", ch);		return;	}	if ( pal == ch ) {		send_to_char ("Not yourself./n/r", ch);		return;	}	if ( !is_leader (ch, pal) ) {		act ("You don't have the authority to recruit $N.", FALSE, ch, 0, pal, TO_CHAR);		return;	}	if ( pal->following == ch ) {		act ("$N is already following you.", FALSE, ch, 0, pal, TO_CHAR);		return;	}	pal->following = ch;	act ("$N motions to $S clanmates.", FALSE, pal, 0, ch, TO_NOTVICT | TO_ACT_FORMAT);	act ("$n falls in.", FALSE, pal, 0, ch, TO_VICT | TO_ACT_FORMAT);	act ("$N nods to you to follow.", FALSE, pal, 0, ch, TO_CHAR);	return;}
开发者ID:MUDOmnibus,项目名称:Argila2,代码行数:75,


示例30: snprintf

SOCIAL_DATA *load_social( const char *social ){    SOCIAL_DATA *ret;    list<SOCIAL_DATA *>::iterator li;    FILE *fp;    char tmp[MSL] = {'/0'};    char search[MSL] = {'0'};    const char *word;    bool fMatch = false;        /* Check the cache list before trying to load from file --Kline */    for( li = social_list.begin(); li != social_list.end(); li++ )    {        ret = *li;        if( ret->name.find(social) != string::npos )        {            snprintf( log_buf, MIL, "load_social: using cached copy of (%s) which expires in (%d)", ret->name.c_str(), ret->cache_time );            monitor_chan( log_buf, MONITOR_DEBUG );            ret->cache_time = sysdata.pulse_cache;            return ret;        }    }        ret = new SOCIAL_DATA;        snprintf( search, MSL, "find %s%s/ -iname %s//*.%s -printf '%%p'", SOCIAL_DIR, initial(social), social, SOCIAL_EXT );    snprintf( tmp, MSL, "%s", _popen(search) );    fp = file_open( tmp, "r" );        snprintf( tmp, MSL, "ls -1 %s%s/%s*.%s | cut -d/ -f4 | cut -d. -f1", SOCIAL_DIR, initial(social), social, SOCIAL_EXT );    ret->name = _popen(tmp);    ret->name.resize(ret->name.length()-1); /* Strip off the appended /n --Kline */    for ( ;; )    {        word = feof(fp) ? "End" : fread_word(fp);        fMatch = false;        switch ( UPPER(word[0]) )        {            case '*':                fMatch = true;                fread_to_eol(fp);                break;            case 'C':                KEY("CharAuto", ret->char_auto, fread_string( fp ) );                KEY("CharFound", ret->char_found, fread_string( fp ) );                KEY("CharNoArg", ret->char_no_arg, fread_string( fp ) );                break;            case 'E':                if ( !str_cmp(word, "End") )                {                    file_close(fp);                    return ret;                }                break;            case 'O':                KEY("OtherAuto", ret->other_auto, fread_string( fp ) );                KEY("OtherFound", ret->other_found, fread_string( fp ) );                KEY("OtherNoArg", ret->other_no_arg, fread_string( fp ) );                break;            case 'V':                KEY("VictFound", ret->vict_found, fread_string( fp ) );                break;        }    }    if ( !fMatch )    {        snprintf( log_buf, (2 * MIL), "Loading in social :%s, no match for ( %s ).", social, word );        monitor_chan( log_buf, MONITOR_BAD );        fread_to_eol( fp );    }    file_close(fp);    return ret;}
开发者ID:Catcheeto,项目名称:ackfuss,代码行数:82,



注:本文中的str_cmp函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ str_comp函数代码示例
C++ str_cli函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。