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


C++ BString::convert方法代码示例

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


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

示例1: bankTipOnline

void TreasuryManager::bankTipOnline(int32 amount, PlayerObject* playerObject, PlayerObject* targetObject )
{
    //check if we have enough money
    int32 surcharge = (int32)((amount/100)*5);

    if((amount+surcharge) > dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getCredits())
    {
        BString s;
        s = targetObject->getFirstName();
        s.convert(BSTRType_Unicode16);
        gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_nsf_cash", L"", s.getUnicode16(), L"", amount), playerObject);
        return;
    }

    Bank* playerBank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
    Bank* targetBank = dynamic_cast<Bank*>(targetObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));

    playerBank->setCredits(playerBank->getCredits() - (amount+surcharge));
    targetBank->setCredits(targetBank->getCredits() + amount);

    saveAndUpdateBankCredits(playerObject);
    saveAndUpdateBankCredits(targetObject);

    gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_pass_self", 0, targetObject->getId(), 0, amount), playerObject);
    gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_pass_target", 0, playerObject->getId(), 0, amount), targetObject);

    gMessageLib->sendBanktipMail(playerObject,targetObject,amount);
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例2: _handleRequestWaypointAtPosition

void ObjectController::_handleRequestWaypointAtPosition(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player	= dynamic_cast<PlayerObject*>(mObject);
    Datapad* datapad			= player->getDataPad();

    //if(!datapad->getCapacity())
    //{
    //	gMessageLib->sendSystemMessage(player,L"","base_player","too_many_waypoints");
    //	return;
    //}

    BStringVector	dataElements;
    BString			dataStr;
    std::string			nameStr;

    message->getStringUnicode16(dataStr);

    // Have to convert BEFORE using split, since the conversion done there is removed It will assert().. evil grin...
    // Either do the conversion HERE, or better fix the split so it handles unicoe also.
    dataStr.convert(BSTRType_ANSI);
    uint32 elementCount = dataStr.split(dataElements,' ');

    if(elementCount < 5)
    {
        if(elementCount < 4)
        {
            return;
        }
        else
        {
            nameStr = gWorldManager->getPlanetNameThis();
            std::transform(nameStr.begin(), nameStr.end(), nameStr.begin(), &tolower);
        }
    }
    else
    {
        for(uint i = 4; i < elementCount; i++)
        {
            nameStr.append(dataElements[i].getAnsi());

            if(i + 1 < elementCount)
                nameStr.append(" ");
        }
    }

    BString	planetStr	= dataElements[0].getAnsi();
    //gLogger->log(LogManager::DEBUG,"ObjController::handleCreateWaypointAtPosition: planet %s",planetStr.getAnsi());
    float	x			= static_cast<float>(atof(dataElements[1].getAnsi()));
    float	y			= static_cast<float>(atof(dataElements[2].getAnsi()));
    float	z			= static_cast<float>(atof(dataElements[3].getAnsi()));

    int32 planetId = gWorldManager->getPlanetIdByName(planetStr);

    if(planetId == -1)
    {
        return;
    }

    datapad->requestNewWaypoint(nameStr.c_str(), glm::vec3(x,y,z),static_cast<uint16>(planetId),Waypoint_blue);
}
开发者ID:ujentus,项目名称:mmoserver,代码行数:60,代码来源:OCDatapadHandlers.cpp

示例3: handleMessage

std::string MedicManager::handleMessage(Message* message, std::string regexPattern)
{
    // Read the message out of the packet.
    BString tmp;
    message->getStringUnicode16(tmp);

    // If the string has no length the message is ill-formatted, send the
    // proper format to the client.
    if (!tmp.getLength())
        return "";

    // Convert the string to an ansi string for ease with the regex.
    tmp.convert(BSTRType_ANSI);
    std::string input_string(tmp.getAnsi());

    static const regex pattern(regexPattern);
    smatch result;

    regex_search(input_string, result, pattern);

    // Gather the results of the pattern for validation and use.
    std::string messageType(result[1]);
    if (messageType.length() > 0)
    {
        return messageType;
    }
    return "";
}
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:28,代码来源:MedicManager.cpp

示例4: bankTipOffline

void TreasuryManager::bankTipOffline(int32 amount,PlayerObject* playerObject,BString targetName)
{

    //============================================
    //check whether we have sufficient funds
    //dont forget the surcharge
    Bank* bank = dynamic_cast<Bank*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Bank));
    int32 credits = bank->getCredits();

    int32 surcharge = (int32)((amount/100)*5);

    if((amount + surcharge) > credits)
    {
        BString uniName = targetName;
        uniName.convert(BSTRType_Unicode16);

        gMessageLib->SendSystemMessage(::common::OutOfBand("base_player", "prose_tip_nsf_bank", L"", L"", uniName.getUnicode16(), amount), playerObject);
        return;
    }
    //now get the player
    int8 name[50];
    mDatabase->Escape_String(name,targetName.getAnsi(),targetName.getLength());

    int8 sql[256];
    sprintf(sql,"SELECT id FROM characters WHERE firstname like '%s'",name);

    TreasuryManagerAsyncContainer* asyncContainer;
    asyncContainer = new TreasuryManagerAsyncContainer(TREMQuery_BankTipgetId,playerObject->getClient());
    asyncContainer->amount = amount;
    asyncContainer->surcharge = surcharge;
    asyncContainer->targetName = targetName;
    asyncContainer->player = playerObject;

    mDatabase->ExecuteSqlAsync(this,asyncContainer,sql);
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例5: handleBroadcast

BString ObjectController::handleBroadcast(BString message) const
{
    int8 rawData[128];

    int8* replyStr = "OK";
    if (message.getLength())
    {
        // Any valid message?
        int32 elementCount = sscanf(message.getAnsi(), "%80s", rawData);
        if (elementCount > 0)
        {
            message.convert(BSTRType_Unicode16);

            PlayerAccMap::const_iterator it = gWorldManager->getPlayerAccMap()->begin();
            while(it != gWorldManager->getPlayerAccMap()->end())
            {
                const PlayerObject* const player = (*it).second;
                if (player->isConnected())
                {
                    gMessageLib->SendSystemMessage(message.getUnicode16(), player);
                }
                ++it;
            }
        }
        else
        {
            replyStr = "No broadcast supplied";
        }
    }
    else
    {
        replyStr = "No broadcast supplied";
    }
    return replyStr;
}
开发者ID:,项目名称:,代码行数:35,代码来源:

示例6: HandleRequestDraftslotsBatch

bool CraftingManager::HandleRequestDraftslotsBatch(Object* object,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	playerObject	= dynamic_cast<PlayerObject*>(object);
    BString			requestStr;
    BStringVector	dataElements;
    uint16			elementCount;

    message->getStringUnicode16(requestStr);
    requestStr.convert(BSTRType_ANSI);

    elementCount = requestStr.split(dataElements,' ');

    if(!elementCount)
    {
        return false;
    }

    for(uint16 i = 1; i < elementCount; i += 2)
    {
        // since we currently store everything in 1 schematic object, just look up by the crc
        // lookup of weights is done in requestresourceweightsbatch
        uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi());
        DraftSchematic* schematic = gSchematicManager->getSchematicBySlotId(static_cast<uint32>(itemId));

        if(schematic)
        {
            gMessageLib->sendDraftslotsResponse(schematic,playerObject);
        }
    }
    return true;
}
开发者ID:ANHcRush,项目名称:mmoserver,代码行数:31,代码来源:CraftingManager.cpp

示例7: HandleRequestResourceWeightsBatch

bool CraftingManager::HandleRequestResourceWeightsBatch(Object* object,Object* target,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	playerObject	= dynamic_cast<PlayerObject*>(object);
    BString			requestStr;
    BStringVector	dataElements;
    uint16			elementCount;

    message->getStringUnicode16(requestStr);
    requestStr.convert(BSTRType_ANSI);

    elementCount = requestStr.split(dataElements,' ');

    if(!elementCount)
    {
        return false;
    }

    for(uint16 i = 0; i < elementCount; i++)
    {
        uint64 itemId = boost::lexical_cast<uint64>(dataElements[i].getAnsi());
        DraftSchematic* schematic = gSchematicManager->getSchematicByWeightId(static_cast<uint32>(itemId));

        if(schematic)
        {
            gMessageLib->sendDraftWeightsResponse(schematic,playerObject);
        }
    }
    return true;
}
开发者ID:ANHcRush,项目名称:mmoserver,代码行数:29,代码来源:CraftingManager.cpp

示例8: broadcastGalaxyMessage

void ObjectController::broadcastGalaxyMessage(BString theBroadcast, int32 planetId) const
{
    if (theBroadcast.getLength())
    {
        PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
        if (player)
        {
            theBroadcast.convert(BSTRType_Unicode16);

            // let the chatserver handle this.
            Message* newMessage;
            gMessageFactory->StartMessage();
            gMessageFactory->addUint32(opIsmBroadcastGalaxy);
            gMessageFactory->addUint32(planetId);
            gMessageFactory->addString(theBroadcast);
            newMessage = gMessageFactory->EndMessage();
            player->getClient()->SendChannelA(newMessage,player->getAccountId(),CR_Chat,2);
            //this should be fastpath as not being Mission critical and we want to prevent the communication protocol overhead with Acks and resends

            // Convert since we are going to print it.
            // theBroadcast.convert(BSTRType_ANSI);
        }
    }

}
开发者ID:,项目名称:,代码行数:25,代码来源:

示例9: sendAdminFeedback

void ObjectController::sendAdminFeedback(BString reply) const
{
    PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
    if ((player) && (player->isConnected()))
    {
        if (reply.getLength())
        {
            gLogger->log(LogManager::NOTICE,"Admin (%s): %s", player->getFirstName().getAnsi(), reply.getAnsi());
            reply.convert(BSTRType_Unicode16);
            gMessageLib->SendSystemMessage(reply.getUnicode16(), player, true);
        }
        else
        {
            gLogger->log(LogManager::NOTICE,"Admin (%s):", player->getFirstName().getAnsi());
        }
    }
    else
    {
        if (reply.getDataLength())
        {
            gLogger->log(LogManager::NOTICE,"Admin (anon): %s", reply.getAnsi());
        }
        else
        {
            gLogger->log(LogManager::NOTICE,"Admin (anon):");
        }
    }
}
开发者ID:,项目名称:,代码行数:28,代码来源:

示例10: sendAdminFeedback

void ObjectController::sendAdminFeedback(BString reply) const
{
    PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
    if ((player) && (player->isConnected()))
    {
        if (reply.getLength())
        {
            reply.convert(BSTRType_Unicode16);
            gMessageLib->SendSystemMessage(reply.getUnicode16(), player, true);
        }
        else
        {
            DLOG(info) << "Admin :" << player->getFirstName().getAnsi();
        }
    }
    else
    {
        if (reply.getDataLength())
        {
            DLOG(info) << "Admin (anon): " << reply.getAnsi();
        }
        else
        {
        }
    }
}
开发者ID:schizix,项目名称:mmoserver,代码行数:26,代码来源:OCAdminHandlers.cpp

示例11: _handleSetWaypointName

void ObjectController::_handleSetWaypointName(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	player		= dynamic_cast<PlayerObject*>(mObject);
    BString			name;
    Datapad* datapad			= player->getDataPad();
    WaypointObject*	waypoint	= datapad->getWaypointById(targetId);
    int8			sql[1024],restStr[64],*sqlPointer;

    if(waypoint == NULL)
    {
        DLOG(info) << "ObjController::handlesetwaypointname: could not find waypoint "<< targetId;
        return;
    }

    message->getStringUnicode16(name);

    if(!(name.getLength()))
        return;

    waypoint->setName(name);

    name.convert(BSTRType_ANSI);

    sprintf(sql,"UPDATE %s.waypoints SET name='",mDatabase->galaxy());
    sqlPointer = sql + strlen(sql);
    sqlPointer += mDatabase->escapeString(sqlPointer,name.getAnsi(),name.getLength());
    sprintf(restStr,"' WHERE waypoint_id=%" PRIu64 "",targetId);
    strcat(sql,restStr);

    mDatabase->executeSqlAsync(NULL,NULL,sql);


    gMessageLib->sendUpdateWaypoint(waypoint,ObjectUpdateChange,player);
}
开发者ID:ujentus,项目名称:mmoserver,代码行数:34,代码来源:OCDatapadHandlers.cpp

示例12: sendGroupSystemMessage

void ChatMessageLib::sendGroupSystemMessage(BString name, BString pointer, Player* target, GroupObject* group, bool unicode) const
{
    name.convert(BSTRType_Unicode16);
    uint32	pointerLength = (uint32)ceil((double)(pointer.getLength() / 2));

    Message* newMessage;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opChatSystemMessage);
    gMessageFactory->addUint8(0);
    gMessageFactory->addUint32(0);

    gMessageFactory->addUint32(45 + pointerLength + name.getLength());
    gMessageFactory->addUint16(1);
    gMessageFactory->addUint8(1);
    gMessageFactory->addUint32(0xffffffff);
    gMessageFactory->addString(BString("group"));
    gMessageFactory->addUint32(0);
    gMessageFactory->addString(pointer);
    gMessageFactory->addUint64(0);
    gMessageFactory->addUint64(0);

    if(unicode)
    {
        gMessageFactory->addString(name);
        gMessageFactory->addUint32(0);
        gMessageFactory->addUint64(0);
        gMessageFactory->addUint32(0);
        gMessageFactory->addUint32(0);
    }
    else
    {
        gMessageFactory->addUint32(0);
        gMessageFactory->addUint32(0);
        gMessageFactory->addUint64(0);
        gMessageFactory->addUint32(0);
        gMessageFactory->addString(name);
    }

    gMessageFactory->addUint64(0);
    gMessageFactory->addUint64(0);
    gMessageFactory->addUint32(0);
    gMessageFactory->addUint32(0);
    gMessageFactory->addUint32(0);
    gMessageFactory->addUint16(0);

    newMessage = gMessageFactory->EndMessage();

    if(group == NULL)
    {
        target->getClient()->SendChannelA(newMessage, target->getClient()->getAccountId(), CR_Client, 5);
    }
    else
    {
        group->broadcastMessage(newMessage);
    }
}
开发者ID:schizix,项目名称:mmoserver,代码行数:57,代码来源:ChatMessages.cpp

示例13: sscanf

//======================================================================================================================
//
// Modifies the Admin List
//
void	ObjectController::_handleNameStructure(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)

{
    // requirement we have the structure targeted AND give the name of the recipient on the commandline
    // OR we have the recipient targeted and stand NEXT to the structure were about to transfer

    //do we have a valid donor ?
    CreatureObject* creature  = dynamic_cast<CreatureObject*>(mObject); PlayerObject* player = creature->GetGhost();

    if(!player)
    {
        return;
    }

    //do we have a valid structure ??? check our target first
    uint64 id = player->GetCreature()->getTargetId();
    Object* object = gWorldManager->getObjectById(id);
    PlayerStructure* structure = dynamic_cast<PlayerStructure*>(object);

    if(!structure)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    //is the structure in Range???
    float fTransferDistance = gWorldConfig->getConfiguration<float>("Player_Structure_Operate_Distance",(float)10.0);
    if(glm::distance(player->GetCreature()->mPosition, structure->mPosition) > fTransferDistance)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "command_no_building"), player);
        return;
    }

    //find out where our structure is
    BString dataStr;
    message->getStringUnicode16(dataStr);

    BString nameStr;

    dataStr.convert(BSTRType_ANSI);

    sscanf(dataStr.getAnsi(),"%s",nameStr.getAnsi());

    if(nameStr.getLength() > 68)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("player_structure", "not_valid_name"), player);
        return;
    }

    StructureAsyncCommand command;
    command.Command = Structure_Command_RenameStructure;
    command.PlayerId = player->getId();
    command.StructureId = structure->getId();

    gStructureManager->checkNameOnPermissionList(structure->getId(),player->getId(),player->GetCreature()->getFirstName(),"ADMIN",command);

}
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:61,代码来源:OCStructureHandlers.cpp

示例14: _handleBoardTransport

void ObjectController::_handleBoardTransport(uint64 targetId,Message* message,ObjectControllerCmdProperties* cmdProperties)
{
    PlayerObject*	playerObject	= dynamic_cast<PlayerObject*>(mObject);

    ObjectSet		inRangeObjects;
    float			boardingRange	= 25.0;

    if(playerObject->states.getPosture() == CreaturePosture_SkillAnimating)
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("error_message", "wrong_state"), playerObject);
        return;
    }

    BString str;
    message->getStringUnicode16(str);
    str.convert(BSTRType_ANSI);
    str.toLower();

    if((str.getCrc() != BString("transport").getCrc()))
    {
        gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_what_shuttle"), playerObject);
        return;
    }

    gSpatialIndexManager->getObjectsInRange(playerObject,&inRangeObjects,ObjType_Creature | ObjType_NPC, boardingRange, true);

	// iterate through the results
	ObjectSet::iterator it = inRangeObjects.begin();

	while(it != inRangeObjects.end())
	{
        if(Shuttle* shuttle = dynamic_cast<Shuttle*>(*it))
        {
            // in range check
            if(playerObject->getParentId() !=  shuttle->getParentId())
            {
                gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "boarding_too_far"), playerObject);
                return;
            }

            if (!shuttle->availableInPort())
            {
                gMessageLib->SendSystemMessage(::common::OutOfBand("travel", "shuttle_not_available"), playerObject);
                return;
            }

            shuttle->useShuttle(playerObject);

            return;
        }

        ++it;
    }

    gMessageLib->SendSystemMessage(::common::OutOfBand("structure/structure_messages", "boarding_what_shuttle"), playerObject);
}
开发者ID:schizix,项目名称:mmoserver,代码行数:56,代码来源:OCCommonHandlers.cpp

示例15: sendAttributes

void Object::sendAttributes(PlayerObject* playerObject)
{
    if(playerObject->getConnectionState() != PlayerConnState_Connected)
        return;

    if(!mAttributeMap.size() || mAttributeMap.size() != mAttributeOrderList.size())
        return;

    Message*	newMessage;
    BString		value;

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opAttributeListMessage);
    gMessageFactory->addUint64(mId);

    gMessageFactory->addUint32(mAttributeMap.size());

    AttributeMap::iterator			mapIt;
    AttributeOrderList::iterator	orderIt = mAttributeOrderList.begin();

    while(orderIt != mAttributeOrderList.end())
    {
        mapIt = mAttributeMap.find(*orderIt);
        //see if we have to format it properly

        gMessageFactory->addString(gWorldManager->getAttributeKey((*mapIt).first));
        value = (*mapIt).second.c_str();
        if(gWorldManager->getAttributeKey((*mapIt).first).getCrc() == BString("duration").getCrc())
        {
            uint32 time;
            sscanf(value.getAnsi(),"%u",&time);
            //uint32 hour = (uint32)time/3600;
            //time = time - hour*3600;
            uint32 minutes = (uint32)time/60;
            uint32 seconds = time - minutes*60;
            int8 valueInt[64];
            sprintf(valueInt,"%um %us",minutes,seconds);
            value = valueInt;

        }

        value.convert(BSTRType_Unicode16);
        gMessageFactory->addString(value);

        ++orderIt;
    }

    //these should not be necessary in precu they start appearing in cu!!!
    //gMessageFactory->addUint32(0xffffffff);

    newMessage = gMessageFactory->EndMessage();

    //must in fact be send as unreliable for attributes to show during the crafting process!!!
    (playerObject->getClient())->SendChannelAUnreliable(newMessage, playerObject->getAccountId(),CR_Client,9);
}
开发者ID:schizix,项目名称:mmoserver,代码行数:55,代码来源:Object.cpp


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