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


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

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


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

示例1: findTicket

bool TravelMapHandler::findTicket(PlayerObject* player, BString port)
{
    uint32	zoneId = gWorldManager->getZoneId();

    ObjectIDList* invObjects = dynamic_cast<Inventory*>(player->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getObjects();
    ObjectIDList::iterator it = invObjects->begin();

    while(it != invObjects->end())
    {
        TravelTicket* ticket = dynamic_cast<TravelTicket*>(gWorldManager->getObjectById((*it)));
        if(ticket)
        {
            BString srcPoint		= (int8*)((ticket->getAttribute<std::string>("travel_departure_point")).c_str());
            uint16 srcPlanetId	= static_cast<uint16>(gWorldManager->getPlanetIdByName((int8*)((ticket->getAttribute<std::string>("travel_departure_planet")).c_str())));

            // see if we got at least 1
            if(srcPlanetId == zoneId && strcmp(srcPoint.getAnsi(),port.getAnsi()) == 0)
            {
                return false;
            }
        }
        ++it;
    }
    return true;;
}
开发者ID:gregomy,项目名称:mmoserver,代码行数:25,代码来源:TravelMapHandler.cpp

示例2: _createTicketSelectMenu

void TicketCollector::_createTicketSelectMenu(PlayerObject* playerObject)
{
    BStringVector	availableTickets;
    uint32			zoneId = gWorldManager->getZoneId();

    ObjectIDList*			invObjects	= dynamic_cast<Inventory*>(playerObject->getEquipManager()->getEquippedObject(CreatureEquipSlot_Inventory))->getObjects();
    ObjectIDList::iterator	it			= invObjects->begin();

    while(it != invObjects->end())
    {
        if(TravelTicket* ticket = dynamic_cast<TravelTicket*>(gWorldManager->getObjectById((*it))))
        {
            BString srcPoint		= (int8*)((ticket->getAttribute<std::string>("travel_departure_point")).c_str());
            uint16 srcPlanetId	= static_cast<uint16>(gWorldManager->getPlanetIdByName((int8*)((ticket->getAttribute<std::string>("travel_departure_planet")).c_str())));

            if(srcPlanetId == zoneId && strcmp(srcPoint.getAnsi(),mPortDescriptor.getAnsi()) == 0)
            {
                BString dstPoint = (int8*)((ticket->getAttribute<std::string>("travel_arrival_point")).c_str());

                availableTickets.push_back(dstPoint.getAnsi());
            }
        }
        ++it;
    }

    gUIManager->createNewListBox(this,"handleticketselect","select destination","Select destination",availableTickets,playerObject);
}
开发者ID:schizix,项目名称:mmoserver,代码行数:27,代码来源:TicketCollector.cpp

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

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

示例5: getHealWound

uint32 Medicine::getHealWound(BString attribute)
{
    //this should return us the attribute type we are trying to heal
    //TODO replace with std::string after bstring is removed...
    BString examine = "examine_heal_wound_";
    std::string tmp = examine.getAnsi();
    tmp.append(attribute.getAnsi());
    BString attr = tmp.c_str();
    return (uint32)this->getAttribute<float>(attr);
}
开发者ID:Gargash,项目名称:Unofficial_Hope,代码行数:10,代码来源:Medicine.cpp

示例6: getTicketInformation

void TravelMapHandler::getTicketInformation(BStringVector vQuery,TicketProperties* ticketProperties)
{
    ticketProperties->srcPlanetId = 0;
    while((strcmp(vQuery[0].getAnsi(),gWorldManager->getPlanetNameById(static_cast<uint8>(ticketProperties->srcPlanetId))) != 0))
        ticketProperties->srcPlanetId++;

    ticketProperties->dstPlanetId = 0;
    while((strcmp(vQuery[2].getAnsi(),gWorldManager->getPlanetNameById(static_cast<uint8>(ticketProperties->dstPlanetId))) != 0))
        ticketProperties->dstPlanetId++;

    TravelRoutes::iterator it = mTravelRoutes[ticketProperties->srcPlanetId].begin();
    while(it != mTravelRoutes[ticketProperties->srcPlanetId].end())
    {
        if((*it).first == ticketProperties->dstPlanetId)
        {
            ticketProperties->price = (*it).second;
            break;
        }
        ++it;
    }

    TravelPointList::iterator tpIt = mTravelPoints[ticketProperties->srcPlanetId].begin();
    while(tpIt != mTravelPoints[ticketProperties->srcPlanetId].end())
    {
        TravelPoint* tp = (*tpIt);
        BString desc = tp->descriptor;

        if(strcmp(strRep(std::string(vQuery[1].getAnsi()),"_"," ").c_str(),desc.getAnsi()) == 0)
        {
            ticketProperties->srcPoint = tp;
            break;
        }

        ++tpIt;
    }

    ticketProperties->dstPoint = NULL;

    tpIt = mTravelPoints[ticketProperties->dstPlanetId].begin();
    while(tpIt != mTravelPoints[ticketProperties->dstPlanetId].end())
    {
        //tp = (*tpIt);

        BString desc = (*tpIt)->descriptor;

        if(strcmp(strRep(std::string(vQuery[3].getAnsi()),"_"," ").c_str(),desc.getAnsi()) == 0)
        {
            ticketProperties->dstPoint = (*tpIt);
            ticketProperties->price += (*tpIt)->taxes;

            break;
        }
        ++tpIt;
    }
}
开发者ID:gregomy,项目名称:mmoserver,代码行数:55,代码来源:TravelMapHandler.cpp

示例7: createNewDiagnoseListBox

//======================================================================================================================
void UIManager::createNewDiagnoseListBox(UICallback* callback,PlayerObject* Medic, PlayerObject* Patient)
{
	BStringVector attributesMenu;

	BString FirstName = Patient->getFirstName(); FirstName.toUpper();
	BString LastName = Patient->getLastName(); LastName.toUpper();

	int8 title[64];
	sprintf(title,"PATIENT %s %s'S WOUNDS",FirstName.getAnsi(), LastName.getAnsi());

	int8 desc[512];
	sprintf(desc, "Below is a listing of the Wound and Battle Fatigue levels of %s %s. Wounds are healed through /tendWound or use of Wound Medpacks. High levels of Battle Fatigue can inhibit the healing process, and Battle Fatigue can only be healed by the patient choosing to watch performing entertainers",Patient->getFirstName().getAnsi(), Patient->getLastName().getAnsi());

	int8 Health[32];
	sprintf(Health,"Health -- %i",Patient->getHam()->mHealth.getWounds());
	attributesMenu.push_back(Health);

	int8 Strength[32];
	sprintf(Strength,"Strength -- %i",Patient->getHam()->mStrength.getWounds());
	attributesMenu.push_back(Strength);
	
	int8 Constitution[32];
	sprintf(Constitution,"Constitution -- %i",Patient->getHam()->mConstitution.getWounds());
	attributesMenu.push_back(Constitution);
	
	int8 Action[32];
	sprintf(Action,"Action -- %i",Patient->getHam()->mAction.getWounds());
	attributesMenu.push_back(Action);

	int8 Quickness[32];
	sprintf(Quickness,"Quickness -- %i",Patient->getHam()->mQuickness.getWounds());
	attributesMenu.push_back(Quickness);

	int8 Stamina[32];
	sprintf(Stamina,"Stamina -- %i",Patient->getHam()->mStamina.getWounds());
	attributesMenu.push_back(Stamina);

	int8 Mind[32];
	sprintf(Mind,"Mind -- %i",Patient->getHam()->mMind.getWounds());
	attributesMenu.push_back(Mind);

	int8 Focus[32];
	sprintf(Focus,"Focus -- %i",Patient->getHam()->mFocus.getWounds());
	attributesMenu.push_back(Focus);

	int8 Willpower[32];
	sprintf(Willpower,"Willpower -- %i",Patient->getHam()->mWillpower.getWounds());
	attributesMenu.push_back(Willpower);

	int8 BattleFatigue[32];
	sprintf(BattleFatigue,"Battle Fatigue -- %i",Patient->getHam()->getBattleFatigue());
	attributesMenu.push_back(BattleFatigue);

	createNewListBox(callback,"handleDiagnoseMenu",title, desc, attributesMenu, Medic, SUI_Window_ListBox,SUI_LB_OK,Patient->getId());
}
开发者ID:Arnold47525,项目名称:mmoserver,代码行数:56,代码来源:UICustomWindows.cpp

示例8: buildDistributionMap

void CurrentResource::buildDistributionMap()
{
    noise::utils::NoiseMapBuilderPlane	mapBuilder;
    noise::module::ScaleBias			flattenModule;

    flattenModule.SetSourceModule(0,mNoiseModule);
    flattenModule.SetScale(mNoiseMapScale);
    flattenModule.SetBias(mNoiseMapBias);

    _verifyNoiseSettings();

    mNoiseModule.SetPersistence(mNoiseMapPersistence);
    mNoiseModule.SetOctaveCount(mNoiseMapOctaves);
    mNoiseModule.SetFrequency(mNoiseMapFrequency);

    mapBuilder.SetSourceModule(flattenModule);
    mapBuilder.SetDestNoiseMap(mResourceDistributionMap);

    // translates to 1:32
    mapBuilder.SetDestSize(512,512);
    mapBuilder.SetBounds(mNoiseMapBoundsX1,mNoiseMapBoundsX2,mNoiseMapBoundsY1,mNoiseMapBoundsY2);

    LOG(info) << "Building DistributionMap for " << mName.getAnsi() << " " << mType->getName().getAnsi();
    mapBuilder.Build();

    if(mWriteResourceMaps)
    {
        BString fileName = (int8*)(mZoneName).c_str();
        fileName << "_" << mName.getAnsi() << ".bmp";

        LOG(info) << "Writing File " << fileName.getAnsi();

        noise::utils::RendererImage renderer;
        noise::utils::Image image;
        renderer.SetSourceNoiseMap(mResourceDistributionMap);
        renderer.SetDestImage(image);

        renderer.ClearGradient();
        renderer.AddGradientPoint(-1.0000,noise::utils::Color(0,0,0,255));
        renderer.AddGradientPoint(-0.9999,noise::utils::Color(0,0,0,255));
        renderer.AddGradientPoint(0.0000,noise::utils::Color(255,255,0,255));
        renderer.AddGradientPoint(1.0000,noise::utils::Color(255,0,0,255));

        renderer.EnableLight();
        renderer.SetLightContrast(1.5);
        renderer.SetLightBrightness(2.0);
        renderer.Render();

        noise::utils::WriterBMP writer;
        writer.SetSourceImage(image);
        writer.SetDestFilename(fileName.getAnsi());
        writer.WriteDestFile();
    }
}
开发者ID:ELMERzark,项目名称:mmoserver,代码行数:54,代码来源:CurrentResource.cpp

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

示例10: upDateFactoryVolume

//========================================================================================
//used by the factoryfactory to update hoppercontent when looking at a hopper
//
void FactoryCrate::upDateFactoryVolume(BString amount)
{
    if(!this->hasAttribute("factory_count"))
    {
        return;
    }

    std::string v = this->getAttribute<std::string>("factory_count");
    BString value = v.c_str();

    if(value.getCrc() == amount.getCrc())
    {
        return;
    }
    this->setAttribute("factory_count",amount.getAnsi());

    PlayerObjectSet*			knownPlayers	= this->getKnownPlayers();
    PlayerObjectSet::iterator	playerIt		= knownPlayers->begin();

    while(playerIt != knownPlayers->end())
    {
        PlayerObject* player = (*playerIt);
        if(player)
            gMessageLib->sendUpdateCrateContent(this,player);

        playerIt++;
    }

}
开发者ID:jason83,项目名称:mmoserver,代码行数:32,代码来源:FactoryCrate.cpp

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

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

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

示例14: addString

void MessageFactory::addString(const BString& data)
{
    // Make sure we've called StartMessage()
    assert(mCurrentMessage && "Must call StartMessage before adding data");

    // Adjust start bounds if necessary.
    _adjustHeapStartBounds(data.getDataLength());

    // Insert our data and move our end pointer.
    switch(data.getType())
    {
    case BSTRType_UTF8:
    case BSTRType_ANSI:
    {
        // First insert the string length
        *((uint16*)mCurrentMessageEnd) = data.getLength();
        mCurrentMessageEnd += 2;

        memcpy(mCurrentMessageEnd, data.getAnsi(), data.getLength());
        mCurrentMessageEnd += data.getLength();
    }
    break;

    case BSTRType_Unicode16:
    {
        // First insert the string length
        *((uint32*)mCurrentMessageEnd) = data.getLength();
        mCurrentMessageEnd += 4;

        memcpy(mCurrentMessageEnd, data.getUnicode16(), data.getLength() * 2);
        mCurrentMessageEnd += data.getLength() * 2;
    }
    break;
    }
}
开发者ID:ANHcRush,项目名称:mmoserver,代码行数:35,代码来源:MessageFactory.cpp

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


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