当前位置: 首页>>代码示例>>C++>>正文


C++ Seperator::argCount方法代码示例

本文整理汇总了C++中Seperator::argCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Seperator::argCount方法的具体用法?C++ Seperator::argCount怎么用?C++ Seperator::argCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Seperator的用法示例。


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

示例1: PrintHelp

void PrintHelp( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 1 == cmd.argCount() )
    {
        sLog.Log( cmdName, "Available commands:" );

        for( size_t i = 0; i < EVETOOL_COMMAND_COUNT; ++i )
        {
            const EVEToolCommand* c = &EVETOOL_COMMANDS[i];

            sLog.Log( cmdName, "%s", c->name );
        }

        sLog.Log( cmdName, "You can get detailed help by typing '%s <command> [<command>] ...'.", cmdName );
    }
    else
    {
        for( size_t i = 1; i < cmd.argCount(); ++i )
        {
            const std::string& cmdStr = cmd.arg( i );
            const EVEToolCommand* c = FindCommand( cmdStr );

            if( NULL == c )
                sLog.Error( cmdName, "Unknown command '%s'.", cmdStr.c_str() );
            else
                sLog.Log( cmdName, "%s: %s", c->name, c->description );
        }
    }
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:31,代码来源:Commands.cpp

示例2: Command_heal

PyResult Command_heal( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount()== 1 )
	{
		/*who->GetShip()->Set_armorDamage(0);
		who->GetShip()->Set_damage(0);
		who->GetShip()->Set_shieldCharge(who->GetShip()->shieldCapacity());*/

        who->GetShip()->SetAttribute(AttrArmorDamage, 0);
        who->GetShip()->SetAttribute(AttrDamage, 0);
    	EvilNumber shield_charge = who->GetShip()->GetAttribute(AttrShieldCapacity);
        who->GetShip()->SetAttribute(AttrShieldCharge, shield_charge);
	}
	if( args.argCount() == 2 )
	{
		if( !args.isNumber( 1 ) )
			{
				throw PyException( MakeCustomError( "Argument 1 should be a character ID" ) );
			}
		uint32 entity = atoi( args.arg( 1 ).c_str() );

		Client *target = services->entity_list.FindCharacter( entity );
		if(target == NULL)
			throw PyException( MakeCustomError( "Cannot find Character by the entity %d", entity ) );
		
        who->GetShip()->SetAttribute(AttrArmorDamage, 0);
        who->GetShip()->SetAttribute(AttrDamage, 0);
    	EvilNumber shield_charge = who->GetShip()->GetAttribute(AttrShieldCapacity);
        who->GetShip()->SetAttribute(AttrShieldCharge, shield_charge);
	}

	return(new PyString("Heal successful!"));
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:33,代码来源:GMCommands.cpp

示例3: UnmarshalLogText

void UnmarshalLogText( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 1 == cmd.argCount() )
    {
        sLog.Error( cmdName, "Usage: %s marshal-binary [marshal-binary] ...", cmdName );
        return;
    }

    for( size_t i = 1; i < cmd.argCount(); ++i )
    {
        const std::string& marshalBinaryStr = cmd.arg( i );

        Buffer marshalBinary;
        if( !PyDecodeEscape( marshalBinaryStr.c_str(), marshalBinary ) )
        {
            sLog.Error( cmdName, "Failed to decode string into binary." );
            continue;
        }

        PyRep* r = InflateUnmarshal( marshalBinary );
        if( NULL == r )
            sLog.Error( cmdName, "Failed to unmarshal binary." );
        else
        {
            sLog.Success( cmdName, "Result:" );
            r->Dump( stdout, "    " );

            PyDecRef( r );
        }
    }
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:33,代码来源:Commands.cpp

示例4: Command_unban

PyResult Command_unban( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount() == 2 ) 
	{

		if( !args.isNumber( 1 ) )
		{
			const char *name = args.arg( 1 ).c_str();
			services->serviceDB().SetAccountBanStatus(db->GetAccountID(name),false);
		}
		else
			throw PyException( MakeCustomError("Correct Usage: /ban [Character Name]") );
	} 
	//support for characters with first and last names
	else if( args.argCount() == 3 )
	{
		if( args.isHexNumber( 1 ) )
			throw PyException( MakeCustomError("Unknown arguments") );

		std::string name = args.arg( 1 ) + " " + args.arg( 2 );
		services->serviceDB().SetAccountBanStatus(db->GetAccountID(name),false);
	} 
	else
		throw PyException( MakeCustomError("Correct Usage: /unban [Character Name / Character ID]") );

	return NULL;
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:27,代码来源:GMCommands.cpp

示例5: Command_ban

PyResult Command_ban( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	Client *target;

	if( args.argCount() == 2 ) 
	{

		if( !args.isNumber( 1 ) )
		{
			const char *name = args.arg( 1 ).c_str();
			target = services->entity_list.FindCharacter( name );
		}
		else
			throw PyException( MakeCustomError("Correct Usage: /ban [Character Name]") );
	} 
	//support for characters with first and last names
	else if( args.argCount() == 3 )
	{
		if( args.isHexNumber( 1 ) )
			throw PyException( MakeCustomError("Unknown arguments") );

		std::string name = args.arg( 1 ) + " " + args.arg( 2 );
		target = services->entity_list.FindCharacter( name.c_str() ) ;
	} 
	else
		throw PyException( MakeCustomError("Correct Usage: /ban [Character Name]") );

	//ban client
	target->BanClient();

	//disconnect client
	target->DisconnectClient();

	return NULL;
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:35,代码来源:GMCommands.cpp

示例6: Command_createitem

PyResult Command_createitem( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount() < 2 ) {
		throw PyException( MakeCustomError("Correct Usage: /create [typeID]") );
	}
	
	//basically, a copy/paste from Command_create. The client seems to call this multiple times, 
	//each time it creates an item
	if( !args.isNumber( 1 ) )
		throw PyException( MakeCustomError( "Argument 1 must be type ID." ) );
    const uint32 typeID = atoi( args.arg( 1 ).c_str() );
 
	uint32 qty = 1;
    if( 2 < args.argCount() )
    {
	    if( args.isNumber( 2 ) )
		    qty = atoi( args.arg( 2 ).c_str() );
    }

    sLog.Log("command message", "Create %s %u times", args.arg( 1 ).c_str(), qty );

	//create into their cargo hold unless they are docked in a station,
	//then stick it in their hangar instead.
	uint32 locationID;
	EVEItemFlags flag;
	if( who->IsInSpace() )
    {
		locationID = who->GetShipID();
		flag = flagCargoHold;
	}
    else
    {
		locationID = who->GetStationID();
		flag = flagHangar;
	}
	
	ItemData idata(
		typeID,
		who->GetCharacterID(),
		0, //temp location
		flag,
		qty
	);

	InventoryItemRef i = services->item_factory.SpawnItem( idata );
	if( !i )
		throw PyException( MakeCustomError( "Unable to create item of type %s.", args.arg( 1 ).c_str() ) );

	//Move to location
	i->Move( locationID, flag, true );

	return new PyString( "Creation successful." );
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:53,代码来源:GMCommands.cpp

示例7: LoadScript

void LoadScript( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 1 == cmd.argCount() )
    {
        sLog.Error( cmdName, "Usage: %s file [file] ...", cmdName );
        return;
    }

    for( size_t i = 1; i < cmd.argCount(); ++i )
        ProcessFile( cmd.arg( i ) );
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:13,代码来源:Commands.cpp

示例8: Command_giveisk

PyResult Command_giveisk( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{

	if( args.argCount() < 3 ) {
		throw PyException( MakeCustomError("Correct Usage: /giveisk [entityID (0=self)] [amount]") );
	}

	if( !args.isNumber( 1 ) )
		throw PyException( MakeCustomError( "Argument 1 should be an entity ID (0=self)" ) );
	uint32 entity = atoi( args.arg( 1 ).c_str() );

	if( !args.isNumber( 2 ) )
		throw PyException( MakeCustomError( "Argument 2 should be an amount of ISK" ) );
	double amount = strtod( args.arg( 2 ).c_str(), NULL );
	
	Client* tgt;
	if( 0 == entity )
		tgt = who;
	else
    {
		tgt = services->entity_list.FindCharacter( entity );
		if( NULL == tgt )
			throw PyException( MakeCustomError( "Unable to find character %u", entity ) );
	}
	
	tgt->AddBalance( amount );
	return new PyString( "Operation successful." );
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:28,代码来源:GMCommands.cpp

示例9: Command_tr

PyResult Command_tr( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount() < 3 ) {
		throw PyException( MakeCustomError("Correct Usage: /tr [entityID]") );
	}

	const std::string& name = args.arg( 1 );
	if( "me" != name )
		throw PyException( MakeCustomError( "Translocate (/TR) to non-me who '%s' is not supported yet.", name.c_str() ) );
	
	if( !args.isNumber( 2 ) )
		throw PyException( MakeCustomError( "Argument 1 should be an entity ID" ) );
    uint32 loc = atoi( args.arg( 2 ).c_str() );

    sLog.Log( "Command", "Translocate to %u.", loc );

	GPoint p( 0.0f, 1000000.0f, 0.0f ); //when going to a system, who knows where to stick them... could find a stargate and stick them near it I guess...

		
	if( !IsStation( loc ) && !IsSolarSystem( loc ) )
    {
		Client* target = services->entity_list.FindCharacter( loc );
		if( NULL == target )
			target = services->entity_list.FindByShip( loc );
		if( NULL == target )
			throw PyException( MakeCustomError( "Unable to find location %u.", loc ) );

		loc = target->GetLocationID();
		p = target->GetPosition();
	}

	who->MoveToLocation( loc , p );
	return new PyString( "Translocation successful." );
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:34,代码来源:GMCommands.cpp

示例10: Command_online

PyResult Command_online(Client *who, CommandDB *db, PyServiceMgr *services, const Seperator &args) {
	
	if( args.argCount() == 2 )
	{ 
		if( strcmp("me", args.arg( 1 ).c_str())!=0 )
			if( !args.isNumber( 1 ) )
				throw PyException( MakeCustomError( "Argument 1 should be an entity ID or me (me=self)" ) );
			uint32 entity = atoi( args.arg( 1 ).c_str() );
	
		Client* tgt;
		if( strcmp("me", args.arg( 1 ).c_str())==0 )
			tgt = who;
		else
		{
			tgt = services->entity_list.FindCharacter( entity );
			if( NULL == tgt )
				throw PyException( MakeCustomError( "Unable to find character %u", entity ) );
		}

		if( !tgt->InPod() )
			tgt->GetShip()->OnlineAll();
		else
			throw PyException( MakeCustomError( "Command failed: You can't activate mModulesMgr while in pod"));

		return(new PyString("All mModulesMgr have been put Online"));
	}
	else
		throw PyException( MakeCustomError( "Command failed: You got the arguments all wrong!"));
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:29,代码来源:GMCommands.cpp

示例11: Command_dogma

PyResult Command_dogma( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	//"dogma" "140019878" "agility" "=" "0.2"

	if( !(args.argCount() == 5) ) {
		throw PyException( MakeCustomError("Correct Usage: /dogma [itemID] [attributeName] = [value]") );
	}

	if( !args.isNumber( 1 ) ){
		throw PyException( MakeCustomError("Invalid itemID. \n Correct Usage: /dogma [itemID] [attributeName] = [value]") );
	}
	uint32 itemID = atoi( args.arg( 1 ).c_str() );

	if( args.isNumber( 2 ) ) {
		throw PyException( MakeCustomError("Invalid attributeName. \n Correct Usage: /dogma [itemID] [attributeName] = [value]") );
	}
	const char *attributeName = args.arg( 2 ).c_str();

	if( !args.isNumber( 4 ) ){
		throw PyException( MakeCustomError("Invalid attribute value. \n Correct Usage: /dogma [itemID] [attributeName] = [value]") );
	}
	double attributeValue = atof( args.arg( 4 ).c_str() );

	//get item
	InventoryItemRef item = services->item_factory.GetItem( itemID );

	//get attributeID
	uint32 attributeID = db->GetAttributeID( attributeName );

    sLog.Warning( "GMCommands: Command_dogma()", "This command will modify attribute and send change to client, but change does not take effect in client for some reason." );
    item->SetAttribute( attributeID, attributeValue );

	return NULL;
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:34,代码来源:GMCommands.cpp

示例12: Command_setattr

PyResult Command_setattr( Client* who, CommandDB* db, PyServiceMgr* services, const Seperator& args )
{
	if( args.argCount() < 4 ) {
		throw PyException( MakeCustomError("Correct Usage: /setattr [itemID] [attributeID] [value]") );
	}

	if( !args.isNumber( 1 ) )
		throw PyException( MakeCustomError( "1st argument must be itemID (got %s).", args.arg( 1 ).c_str() ) );
    const uint32 itemID = atoi( args.arg( 1 ).c_str() );

	if( !args.isNumber( 2 ) )
		throw PyException( MakeCustomError( "2nd argument must be attributeID (got %s).", args.arg( 2 ).c_str() ) );
    const ItemAttributeMgr::Attr attribute = (ItemAttributeMgr::Attr)atoi( args.arg( 2 ).c_str() );

	if( !args.isNumber( 3 ) )
		throw PyException( MakeCustomError( "3rd argument must be value (got %s).", args.arg( 3 ).c_str() ) );
    const double value = atof( args.arg( 3 ).c_str() );

	InventoryItemRef item = services->item_factory.GetItem( itemID );
	if( !item )
		throw PyException( MakeCustomError( "Failed to load item %u.", itemID ) );

	//item->attributes.SetReal( attribute, value );
    sLog.Warning( "GMCommands: Command_dogma()", "This command will modify attribute and send change to client, but change does not take effect in client for some reason." );
    item->SetAttribute(attribute, (float)value);

	return new PyString( "Operation successful." );
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:28,代码来源:GMCommands.cpp

示例13: TriToOBJ

void TriToOBJ( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 4 != cmd.argCount() )
    {
        sLog.Error( cmdName, "Usage: %s [trifile] [objout] [mtlout]", cmdName );
        return;
    }
    const std::string& trifile = cmd.arg( 1 );
    const std::string& objout = cmd.arg( 2 );
    const std::string& mtlout = cmd.arg( 3 );

    TriExporter::TriFile f;
    if( !f.LoadFile( trifile.c_str() ) )
    {
        sLog.Error( cmdName, "Failed to load trifile '%s'.", trifile.c_str() );
        return;
    }

    f.DumpHeaders();
    f.ExportObj( objout.c_str(), mtlout.c_str() );

    sLog.Success( cmdName, "%s - %s - written.", objout.c_str(), mtlout.c_str() );
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:25,代码来源:Commands.cpp

示例14: Command_unload

PyResult Command_unload(Client *who, CommandDB *db, PyServiceMgr *services, const Seperator &args) {
	
	if( args.argCount() >= 2 && args.argCount() <= 3 )
	{ 
		uint32 item=0,entity=0;

		if( strcmp("me", args.arg( 1 ).c_str())!=0 )
			if( !args.isNumber( 1 ) )
			{
				throw PyException( MakeCustomError( "Argument 1 should be an entity ID or me (me=self)" ) );
			}
			entity = atoi( args.arg( 1 ).c_str() );

		if( args.argCount() ==3 )
		{
			if( strcmp("all", args.arg( 2 ).c_str())!=0 )
				if( !args.isNumber( 2 ) )
					throw PyException( MakeCustomError( "Argument 2 should be an item ID or all" ) );
				item = atoi( args.arg( 2 ).c_str() );
		}
	
		//select character
		Client* tgt;
		if( strcmp("me", args.arg( 1 ).c_str())==0 )
			tgt = who;
		else
		{
			tgt = services->entity_list.FindCharacter( entity );

			if( NULL == tgt )
				throw PyException( MakeCustomError( "Unable to find character %u", entity ) );
		}

		if( tgt->IsInSpace() )
			throw PyException( MakeCustomError( "Character needs to be docked!" ) );

		if( args.argCount() == 3 && strcmp("all", args.arg( 2 ).c_str())!=0)
			tgt->GetShip()->UnloadModule(item);

		if( args.argCount() == 3 && strcmp("all", args.arg( 2 ).c_str())==0)
			tgt->GetShip()->UnloadAllModules();

		return(new PyString("All mModulesMgr have been unloaded"));
	}
	else
		throw PyException( MakeCustomError( "Command failed: You got the arguments all wrong!"));
}
开发者ID:Almamu,项目名称:evemu_incursion,代码行数:47,代码来源:GMCommands.cpp

示例15: ObjectToSQL

void ObjectToSQL( const Seperator& cmd )
{
    const char* cmdName = cmd.arg( 0 ).c_str();

    if( 5 != cmd.argCount() )
    {
        sLog.Error( cmdName, "Usage: %s [cache_file] [table_name] [key_field] [file_name]", cmdName );
        return;
    }
    const std::string& cacheFile = cmd.arg( 1 );
    const std::string& tableName = cmd.arg( 2 );
    const std::string& keyField = cmd.arg( 3 );
    const std::string& fileName = cmd.arg( 4 );

    std::string abs_fname( "../data/cache/" );
    abs_fname += cacheFile;
    abs_fname += ".cache";

    sLog.Log( cmdName, "Converting cached object %s:\n", abs_fname.c_str() );

    CachedObjectMgr mgr;
    PyCachedObjectDecoder* obj = mgr.LoadCachedObject( abs_fname.c_str(), cacheFile.c_str() );
    if( obj == NULL )
    {
        sLog.Error( cmdName, "Unable to load or decode '%s'!", abs_fname.c_str() );
        return;
    }

    obj->cache->DecodeData();
    if( obj->cache->decoded() == NULL )
    {
        sLog.Error( cmdName, "Unable to load or decode body of '%s'!", abs_fname.c_str() );

        SafeDelete( obj );
        return;
    }

    FILE* out = fopen( fileName.c_str(), "w" );
    if( out == NULL )
    {
        sLog.Error( cmdName, "Unable to open output file '%s'", fileName.c_str() );

        SafeDelete( obj );
        return;
    }

    SetSQLDumper dumper( tableName.c_str(), keyField.c_str(), out );
    if( obj->cache->decoded()->visit( dumper ) )
        sLog.Success( cmdName, "Dumping of %s succeeded.", tableName.c_str() );
    else
        sLog.Error( cmdName, "Dumping of %s failed.", tableName.c_str() );

    fclose( out );
    SafeDelete( obj );
}
开发者ID:AlTahir,项目名称:Apocrypha_combo,代码行数:55,代码来源:Commands.cpp


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