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


C++ ObjectList::addLast方法代码示例

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


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

示例1: autoStartGame

// -----------------------------------------------------------------
// Name : autoStartGame
// -----------------------------------------------------------------
void DebugManager::autoStartGame()
{
    // Build client data
    int nbClients = 1;
    ClientData * clients = new ClientData[nbClients];
    int iClient = 0;
    clients[iClient].bLocal = true;

    // Re-init map data
    MapReader * pMapReader = new MapReader(m_pLocalClient);
    pMapReader->init("standard.lua");
    ObjectList * pMapParameters = new ObjectList(true);
    pMapReader->getMapParameters(pMapParameters, LABEL_MAX_CHARS);

    int * pCustomParams = NULL;
    if (pMapParameters->size > 0)
        pCustomParams = new int[pMapParameters->size];

    // Map custom parameters
    int i = 0;
    MapReader::MapParameters * pParam = (MapReader::MapParameters*) pMapParameters->getFirst(0);
    while (pParam != NULL)
    {
        pCustomParams[i++] = pParam->defaultValueIndex;
        pParam = (MapReader::MapParameters*) pMapParameters->getNext(0);
    }

    // Init map generator (we will not delete it here, as the pointer now belong to Server object)
    pMapReader->setMapParameters(pCustomParams, pMapParameters->size, 2);
    delete[] pCustomParams;
    MapReader::deleteMapParameters(pMapParameters);
    delete pMapParameters;

    // Init server
    Server * pServer = m_pLocalClient->initServer("", 1, clients, pMapReader, -1, -1);
    delete[] clients;
    if (pServer == NULL)
    {
        notifyErrorMessage("Error: server could not be initialized.");
        return;
    }

    // Build players data
    ObjectList * pServerPlayers = pServer->getSolver()->getPlayersList();
    // Create neutral player
    char sName[NAME_MAX_CHARS];
    i18n->getText("NEUTRA", sName, NAME_MAX_CHARS);
    Player * pPlayer = new Player(0, 0, pServer->getSolver()->getGlobalSpellsPtr());
    wsafecpy(pPlayer->m_sProfileName, NAME_MAX_CHARS, sName);
    pPlayer->m_Color = rgb(0.5, 0.5, 0.5);
    wsafecpy(pPlayer->m_sBanner, 64, "blason1");
    pServer->getSolver()->setNeutralPlayer(pPlayer);
    // Human players
    int playerId = 1;
    for (int fdfdf = 0; fdfdf < 2; fdfdf++)
    {
        // Create player object
        pPlayer = new Player(playerId, 0, pServer->getSolver()->getGlobalSpellsPtr());
        snprintf(pPlayer->m_sProfileName, NAME_MAX_CHARS, "test%d", playerId);
        Profile * pProfile = m_pLocalClient->getDataFactory()->findProfile(pPlayer->m_sProfileName);
        AvatarData * pAvatar = (AvatarData*) pProfile->getAvatarsList()->getFirst(0);
        pPlayer->m_Color = rgb(1, 1, 1);
        pAvatar->getBanner(pPlayer->m_sBanner, 64);
        pServerPlayers->addLast(pPlayer);
        // Set Avatar
        CoordsMap pos = pMapReader->getPlayerPosition(playerId-1);
        pServer->getSolver()->setInitialAvatar(pAvatar->clone(m_pLocalClient), pPlayer, pos);
        // Add spells that are equipped
        Profile::SpellData * pSpellDesc = (Profile::SpellData*) pProfile->getSpellsList()->getFirst(0);
        while (pSpellDesc != NULL)
        {
            AvatarData * pOwner = pSpellDesc->m_pOwner;
            if (pOwner != NULL && strcmp(pAvatar->m_sEdition, pOwner->m_sEdition) == 0
                    && strcmp(pAvatar->m_sObjectId, pOwner->m_sObjectId) == 0)
                pServer->getSolver()->addInitialPlayerSpell(pPlayer, pSpellDesc->m_sEdition, pSpellDesc->m_sName);
            pSpellDesc = (Profile::SpellData*) pProfile->getSpellsList()->getNext(0);
        }
        // Add equipped artifacts
        Artifact * pArtifact = (Artifact*) pProfile->getArtifactsList()->getFirst(0);
        while (pArtifact != NULL)
        {
            AvatarData * pOwner = pArtifact->m_pOwner;
            if (pOwner != NULL && strcmp(pAvatar->m_sEdition, pOwner->m_sEdition) == 0
                    && strcmp(pAvatar->m_sObjectId, pOwner->m_sObjectId) == 0)
            {
                Unit * pAvatarInGame = pPlayer->getAvatar();
                assert(pAvatarInGame != NULL);
                ArtifactEffect * pEffect = (ArtifactEffect*) pArtifact->getArtifactEffects()->getFirst(0);
                while (pEffect != NULL)
                {
                    switch (pEffect->getType())
                    {
                    case ARTIFACT_EFFECT_CHARAC:
                    {
                        bool bFound = true;
                        long val = pAvatarInGame->getValue(((ArtifactEffect_Charac*)pEffect)->m_sKey, false, &bFound);
                        if (bFound)
//.........这里部分代码省略.........
开发者ID:jotak,项目名称:shahnarman,代码行数:101,代码来源:DebugManager.cpp


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