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


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

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


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

示例1: handleCancelShutdownGalaxy

BString ObjectController::handleCancelShutdownGalaxy(BString message) const
{
    int8 replyData[128];

    if (!AdminManager::Instance()->shutdownPending())
    {
        sprintf(replyData,"No shutdown in progress");
    }
    else
    {
        sprintf(replyData,"OK");

        // We have no idea of how much white space are inserted in string...
        BString ansiData;
        int32 index = indexOfFirstField(message);
        if (index < 0)
        {
            // We may not have any "next field", it's optional here.
            index = 0;
            ansiData = "";
        }
        else
        {
            // Now we can get the broadcaste from the message.
            // Remove first field from message.
            ansiData.setLength(message.getLength());
            message.substring(ansiData, static_cast<uint16>(index), message.getLength());
        }

        // Send request to all zones, via chatserver.
        this->cancelScheduledShutdown(ansiData);
    }
    return replyData;
}
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: handleBroadcastGalaxy

BString ObjectController::handleBroadcastGalaxy(BString message) const
{
    int8* replyStr = "OK";

    int8 rawData[128];
    // We have no idea of how much white space are inserted in string...
    int32 index = indexOfFirstField(message);
    if (index >= 0)
    {
        // Now we can get the broadcast from the message.

        // Remove white space from start of message.
        BString ansiData;
        ansiData.setLength(message.getLength());
        message.substring(ansiData, static_cast<uint16>(index), message.getLength());

        // Any valid message?
        int32 elementCount = sscanf(ansiData.getAnsi(), "%80s", rawData);
        if (elementCount > 0)
        {
            this->broadcastGalaxyMessage(ansiData, -1);
        }
        else
        {
            replyStr = "No broadcast supplied";
        }
    }
    else
    {
        replyStr = "No valid broadcast supplied";
    }
    return replyStr;
}
开发者ID:,项目名称:,代码行数:33,代码来源:

示例3: sendChatRoomList

void ChatMessageLib::sendChatRoomList(DispatchClient* client, ChannelList* list) const
{
    ChannelList::iterator iter = list->begin();

    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opChatRoomlist);

    gMessageFactory->addUint32(list->size());
    while (iter != list->end())
    {
        gMessageFactory->addUint32((*iter)->getId());
        gMessageFactory->addUint32((uint32)(*iter)->isPrivate());
        gMessageFactory->addUint8((*iter)->isModerated());

        BString roomPathName = "SWG.";
        roomPathName << (*iter)->getGalaxy().getAnsi() << ".";
        roomPathName << (*iter)->getName().getAnsi();
        gMessageFactory->addString(roomPathName);

        gMessageFactory->addString(SWG);
        gMessageFactory->addString((*iter)->getGalaxy());
#ifdef DISP_REAL_FIRST_NAME
        BString* name = (ChatManager::getSingletonPtr()->getFirstName((BString &)((*iter)->getOwner()->getLoweredName())));
        if (name->getLength() == 0)
        {
            gMessageFactory->addString((*iter)->getOwner()->getLoweredName());
        }
        else
        {
            gMessageFactory->addString(*name);
        }
#else
        gMessageFactory->addString((*iter)->getOwner()->getLoweredName());
#endif

        gMessageFactory->addString(SWG);
        gMessageFactory->addString((*iter)->getGalaxy());
#ifdef DISP_REAL_FIRST_NAME
        name = (ChatManager::getSingletonPtr()->getFirstName((BString &)((*iter)->getCreator()->getLoweredName())));
        if (name->getLength() == 0)
        {
            gMessageFactory->addString((*iter)->getCreator()->getLoweredName());
        }
        else
        {
            gMessageFactory->addString(*name);
        }
#else
        gMessageFactory->addString((*iter)->getCreator()->getLoweredName());
#endif
        gMessageFactory->addString((*iter)->getTitle());

        gMessageFactory->addUint32(0);
        gMessageFactory->addUint32(0);
        ++iter;
    }
    Message* message = gMessageFactory->EndMessage();

    client->SendChannelA(message, client->getAccountId(), CR_Client, 2);
}
开发者ID:schizix,项目名称:mmoserver,代码行数:60,代码来源:ChatMessages.cpp

示例4: _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

示例5: 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

示例6: handleShutdownGalaxy

BString ObjectController::handleShutdownGalaxy(BString message) const
{
    int8 replyData[128];

    if (AdminManager::Instance()->shutdownPending())
    {
        sprintf(replyData,"Shutdown already in progress");
    }
    else
    {
        sprintf(replyData,"OK");
        // Get time for shutdown
        //
        int32 minutesToShutdown;
        int32 elementCount = sscanf(message.getAnsi(), "%3d", &minutesToShutdown);
        // string planet(rawData);
        if (elementCount > 0)
        {
            // We have no idea of how much white space are inserted in string...
            BString ansiData;
            int32 index = indexOfNextField(message);
            if (index < 0)
            {
                // We may not have any "next field", it's optional here.
                index = 0;
                ansiData = "";
            }
            else
            {
                // Now we can get the broadcaste from the message.
                // Remove first field from message.
                ansiData.setLength(message.getLength());
                message.substring(ansiData, static_cast<uint16>(index), message.getLength());
            }

            // Validate the timeout.
            if (minutesToShutdown >= 0)
            {
                // Any valid message?
                int8 rawData[128];
                elementCount = sscanf(ansiData.getAnsi(), "%80s", rawData);
                // Send request to all zones, via chatserver.
                this->scheduleShutdown(minutesToShutdown*60, ansiData);
            }
            else
            {
                sprintf(replyData,"%d is not valid shutdown time", minutesToShutdown);
            }
        }
        else
        {
            sprintf(replyData,"No shutdown time supplied");
        }
    }
    return replyData;
}
开发者ID:,项目名称:,代码行数:56,代码来源:

示例7: handleBroadcastPlanet

BString ObjectController::handleBroadcastPlanet(BString message) const
{
    // Get planet name
    int8 rawData[128];
    rawData[0] = 0;

    int32 elementCount = sscanf(message.getAnsi(), "%80s", rawData);
    BString planet(rawData);
    if (elementCount > 0)
    {
        // Yes. Validate the planet name.
        int32 planetId = gWorldManager->getPlanetIdByNameLike(planet);
        if (planetId >= 0)
        {
            // We have no idea of how much white space are inserted in string...
            int32 index = indexOfNextField(message);
            if (index > 0)
            {
                // Now we can get the broadcaste from the message.
                // Remove planet name from message.
                BString ansiData;
                ansiData.setLength(message.getLength());
                message.substring(ansiData, static_cast<uint16>(index), message.getLength());

                // Any valid message?
                elementCount = sscanf(ansiData.getAnsi(), "%80s", rawData);
                if (elementCount > 0)
                {
                    // string planetName(gWorldManager->getPlanetNameById(planetId));

                    this->broadcastGalaxyMessage(ansiData, planetId);
                    sprintf(rawData,"OK");
                }
                else
                {
                    sprintf(rawData,"No broadcast supplied");
                }
            }
            else
            {
                sprintf(rawData,"No valid broadcast supplied");
            }
        }
        else
        {
            sprintf(rawData,"%s is not valid planet name", planet.getAnsi());
        }
    }
    else
    {
        sprintf(rawData,"Missing planet name");
    }
    return rawData;
}
开发者ID:,项目名称:,代码行数:54,代码来源:

示例8: removeWhiteSpace

BString ObjectController::removeWhiteSpace(BString str) const
{
    int32 index = indexOfFirstField(str);
    if (index > 0)
    {
        // Remove white space from start of message.
        BString resultStr;
        resultStr.setLength(str.getLength());
        str.substring(resultStr, static_cast<uint16>(index), str.getLength());
        return resultStr;
    }
    // Nothing we can do about that string... good or bad.
    return str;
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例9: sendChatOnCreateRoom

void ChatMessageLib::sendChatOnCreateRoom(DispatchClient* client, Channel* channel, uint32 requestId) const
{
    gMessageFactory->StartMessage();
    gMessageFactory->addUint32(opChatOnCreateRoom);

    gMessageFactory->addUint32(0);
    gMessageFactory->addUint32(channel->getId());
    gMessageFactory->addUint32((uint32)channel->isPrivate());
    gMessageFactory->addUint8(channel->isModerated());
    gMessageFactory->addString(channel->getFullPath());

    gMessageFactory->addString(SWG);
    gMessageFactory->addString(channel->getGalaxy());
#ifdef DISP_REAL_FIRST_NAME
    BString* name = (ChatManager::getSingletonPtr()->getFirstName((BString &)(channel->getOwner()->getLoweredName())));
    if (name->getLength() == 0)
    {
        gMessageFactory->addString(channel->getOwner()->getLoweredName());
    }
    else
    {
        gMessageFactory->addString(*name);
    }
#else
    gMessageFactory->addString(channel->getOwner()->getLoweredName());
#endif
    gMessageFactory->addString(SWG);
    gMessageFactory->addString(channel->getGalaxy());
#ifdef DISP_REAL_FIRST_NAME
    name = (ChatManager::getSingletonPtr()->getFirstName((BString &)(channel->getCreator()->getLoweredName())));
    if (name->getLength() == 0)
    {
        gMessageFactory->addString(channel->getCreator()->getLoweredName());
    }
    else
    {
        gMessageFactory->addString(*name);
    }
#else
    gMessageFactory->addString(channel->getCreator()->getLoweredName());
#endif
    gMessageFactory->addString(channel->getTitle());
    gMessageFactory->addUint32(0);
    gMessageFactory->addUint32(0);
    gMessageFactory->addUint32(requestId);
    Message* message = gMessageFactory->EndMessage();

    client->SendChannelA(message, client->getAccountId(), CR_Client, 4);
}
开发者ID:schizix,项目名称:mmoserver,代码行数:49,代码来源:ChatMessages.cpp

示例10: skipToNextField

BString ObjectController::skipToNextField(BString str) const
{
    int32 index = indexOfNextField(str);
    if (index < 0)
    {
        // Not all commands have payload.
        index = str.getLength();
    }

    // Remove white space from start of message.
    BString resultStr;
    resultStr.setLength(str.getLength());
    str.substring(resultStr, static_cast<uint16>(index), str.getLength());
    return resultStr;
}
开发者ID:,项目名称:,代码行数:15,代码来源:

示例11: 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,代码来源:

示例12: sendXpUpdate

bool MessageLib::sendXpUpdate(uint32 xpType,PlayerObject* playerObject)
{
    if(!(playerObject->isConnected()))
        return(false);

    // We must be able to set the value of 0, when we use up all xp.

    BString		xpTypeName = gSkillManager->getXPTypeById(xpType);

    mMessageFactory->StartMessage();
    mMessageFactory->addUint32(opDeltasMessage);
    mMessageFactory->addUint64(playerObject->getId());
    mMessageFactory->addUint32(opPLAY);
    mMessageFactory->addUint8(8);

    mMessageFactory->addUint32(19 + xpTypeName.getLength());

    mMessageFactory->addUint16(1);
    mMessageFactory->addUint16(0);

    mMessageFactory->addUint32(1);
    mMessageFactory->addUint32(++playerObject->mXpUpdateCounter);

    mMessageFactory->addUint8(2);
    mMessageFactory->addString(xpTypeName);
    mMessageFactory->addInt32(playerObject->getXpAmount(xpType));

    (playerObject->getClient())->SendChannelA(mMessageFactory->EndMessage(),playerObject->getAccountId(),CR_Client,5);

    return(true);
}
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:31,代码来源:PlayerMessages.cpp

示例13: 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

示例14: 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,代码来源:

示例15: 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,代码来源:


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