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


C++ csArray::Push方法代码示例

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


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

示例1: GetAllGMEventsForPlayer

int GMEventManager::GetAllGMEventsForPlayer (PID playerID,
                                             csArray<int>& completedEvents,
                                             int& runningEventAsGM,
                                             csArray<int>& completedEventsAsGM)
{
    int runningEvent = -1, id, index=0;
    GMEvent* gmEvent;

    completedEvents.DeleteAll();
    completedEventsAsGM.DeleteAll();

    if ((gmEvent = GetGMEventByGM(playerID, RUNNING, index)))
    {
        runningEventAsGM = gmEvent->id;
    }
    else
    {
        runningEventAsGM = -1;
    }

    index = 0;
    do
    {
        gmEvent = GetGMEventByGM(playerID, COMPLETED, index);
        if (gmEvent)
        {
            id = gmEvent->id;
            completedEventsAsGM.Push(id);
        }
    }
    while (gmEvent);

    index = 0;
    gmEvent = GetGMEventByPlayer(playerID, RUNNING, index);
    if (gmEvent)
        runningEvent = gmEvent->id;

    index = 0;
    do
    {
        gmEvent = GetGMEventByPlayer(playerID, COMPLETED, index);
        if (gmEvent)
        {
            id = gmEvent->id;
            completedEvents.Push(id);
        }
    }
    while (gmEvent);

    return (runningEvent);
}
开发者ID:garinh,项目名称:planeshift,代码行数:51,代码来源:gmeventmanager.cpp

示例2: CalculatePointSegment

bool csBox3::ProjectOutline (const csVector3& origin,
                             int axis, float where, csArray<csVector2>& poly) const
{
    int idx = CalculatePointSegment (origin);
    const Outline &ol = outlines[idx];
    int num_array = MIN (ol.num, 6);

    int i;
    for (i = 0 ; i < num_array ; i++)
    {
        csVector3 isect;
        if (!csIntersect3::SegmentAxisPlane (origin, GetCorner (ol.vertices[i]),
                                             axis, where, isect))
            return false;
        csVector2 v;
        switch (axis)
        {
        case CS_AXIS_X:
            v.x = isect.y;
            v.y = isect.z;
            break;
        case CS_AXIS_Y:
            v.x = isect.x;
            v.y = isect.z;
            break;
        case CS_AXIS_Z:
            v.x = isect.x;
            v.y = isect.y;
            break;
        }
        poly.Push (v);
    }
    return true;
}
开发者ID:garinh,项目名称:cs,代码行数:34,代码来源:box.cpp

示例3: LoadChildWidgets

bool PawsManager::LoadChildWidgets( const char* widgetFile, csArray<pawsWidget *> &loadedWidgets )
{
    bool errors=false;
    loadedWidgets.DeleteAll();
    csString fullPath = localization->FindLocalizedFile(widgetFile);

    csRef<iDocumentNode> topNode = ParseWidgetFile( fullPath );
    if (!topNode) return false;
    csRef<iDocumentNodeIterator> iter = topNode->GetNodes();

    while ( iter->HasNext() )
    {
        csRef<iDocumentNode> node = iter->Next();

        if ( node->GetType() != CS_NODE_ELEMENT )
            continue;

        // This is a widget so read it's factory to create it.
        pawsWidget * widget = LoadWidget(node);
        if (widget)
            loadedWidgets.Push(widget);
        else
            errors = true;
    }
    return (!errors);
}
开发者ID:garinh,项目名称:planeshift,代码行数:26,代码来源:pawsmanager.cpp

示例4: ParseMaterialPalette

bool csTerrainObjectLoader::ParseMaterialPalette (iDocumentNode *node,
       iLoaderContext *ldr_context, csArray<iMaterialWrapper*>& palette)
{
  csRef<iDocumentNodeIterator> it = node->GetNodes ();
  while (it->HasNext ())
  {
    csRef<iDocumentNode> child = it->Next ();
    if (child->GetType () != CS_NODE_ELEMENT) continue;
    const char *value = child->GetValue ();
    csStringID id = xmltokens.Request (value);
    switch (id)
    {
      case XMLTOKEN_MATERIAL:
      {
        const char* matname = child->GetContentsValue ();
        csRef<iMaterialWrapper> mat = ldr_context->FindMaterial (matname);
        if (!mat)
        {
          synldr->ReportError (
            "crystalspace.terrain.object.loader.materialpalette",
            child, "Couldn't find material '%s'!", matname);
          return false;
        }
        palette.Push (mat);
        break;
      }
      default:
        synldr->ReportError (
          "crystalspace.terrain.object.loader.materialpalette",
          child, "Unknown token in materials list!");
    }
  }
  return true;
}
开发者ID:garinh,项目名称:cs,代码行数:34,代码来源:terrainldr.cpp

示例5: AddEnoughRecords

void psNetMsgProfiles::AddEnoughRecords(csArray<psOperProfile*> & arr, int neededIndex, const char * desc)
{
    while (neededIndex >= (int)arr.GetSize())
    {
        csStringFast<100> fullDesc = GetMsgTypeName((int)arr.GetSize()) + "-" + csStringFast<100>(desc);
        psOperProfile * newProf = new psOperProfile(fullDesc);
        arr.Push(newProf);
        profs.Push(newProf);
    }
}
开发者ID:diana-coman,项目名称:Eulora-client,代码行数:10,代码来源:netprofile.cpp

示例6: GetModifiers

bool LootRandomizer::GetModifiers(uint32_t itemID,
                                  csArray<psGMSpawnMods::ItemModifier>& mods)
{
    csHash<LootModifier*, uint32_t>::GlobalIterator it =
        LootModifiersById.GetIterator();
    while(it.HasNext())
    {
        LootModifier* lootModifier = it.Next();
        if(!lootModifier->IsAllowed(itemID))
        {
            continue;
        }

        psGMSpawnMods::ItemModifier mod;
        mod.name = lootModifier->name;
        mod.id = lootModifier->id;
        mod.type = lootModifier->mod_id;
        mods.Push(mod);
    }

    return mods.GetSize() != 0;
}
开发者ID:huigou,项目名称:planeshift,代码行数:22,代码来源:lootrandomizer.cpp

示例7: strlen

      void CanvasCommonBase::csGLPixelFormatPicker::ReadPickerValue (
        const char* valuesStr, csArray<int>& values)
      {
        if ((valuesStr != 0) && (*valuesStr != 0))
        {
          CS_ALLOC_STACK_ARRAY(char, myValues, strlen (valuesStr) + 1);
          strcpy (myValues, valuesStr);

          char* currentVal = myValues;
          while ((currentVal != 0) && (*currentVal != 0))
          {
            char* comma = strchr (currentVal, ',');
            if (comma != 0) *comma = 0;

            char dummy;
            int val;
            if (sscanf (currentVal, "%d%c", &val, &dummy) == 1)
            {
                values.Push (val);
            }
            currentVal = comma ? comma + 1 : 0;
          }
        }
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:23,代码来源:glcanvascommon.cpp

示例8: SetText

bool psEffectObjLabel::SetText(int rows, ...)
{
    size_t lettercount = 0;

    static csArray<psEffectTextElement> elemBuffer;
    psEffectTextElement newElem;
    psEffectTextRow * row = 0;
    int y = 0;

    // calculate dimensions of text area
    int maxWidth = 0;
    int maxHeight = 0;

    elemBuffer.Empty();

    va_list arg;
    va_start(arg, rows);

    // Loop through all rows
    for (int a=0; a<rows; a++)
    {
        row = va_arg(arg, psEffectTextRow *);

        // Text and Formatting
        newElem.colour = row->colour;
        newElem.hasOutline = row->hasOutline;
        newElem.hasShadow = row->hasShadow;
        newElem.shadowColour = row->shadowColour;
        newElem.outlineColour = row->outlineColour;
        newElem.text = row->text;
        newElem.align = row->align;
        newElem.width = 0;
        newElem.height = 0;
        for(uint b=0; b<newElem.text.Length(); b++)
        {
            newElem.width += width[newElem.text[b]];
            if( newElem.height < height[newElem.text[b]] )
            {
                newElem.height = height[newElem.text[b]];
            }
        }
        newElem.x = 0;
        newElem.y = y;
        elemBuffer.Push(newElem);
        y += newElem.height;
        lettercount += newElem.text.Length();

        int right = newElem.x + newElem.width;
        int bottom = newElem.y + newElem.height;

        if (right > maxWidth)
            maxWidth = right;
        if (bottom > maxHeight)
            maxHeight = bottom;
    }
    va_end(arg);

    CS_ASSERT(facState!=0);
    iMeshObjectFactory * fact = meshFact->GetMeshObjectFactory();
    int mw,mh;
    fact->GetMaterialWrapper()->GetMaterial()->GetTexture()->GetOriginalDimensions(mw, mh);

    facState->SetVertexCount( (int)lettercount * 4 );
    facState->SetTriangleCount( (int)lettercount * 2 );

    size_t elementCount = elemBuffer.GetSize();
    int cp = 0;

    for(size_t i=0; i<elementCount; i++)
    {
        int x = elemBuffer[i].width;
        
        switch (elemBuffer[i].align)
        {
            case ETA_LEFT:
                x = maxWidth;
                break;
            case ETA_CENTER:
                x = (maxWidth-x)/2;
                break;
            case ETA_RIGHT:
                x = maxWidth-x;
                break;
        }
        int y = elemBuffer[i].y;
        csString text = elemBuffer[i].text;
        float scalefactor = labelwidth / (float)maxWidth;
        for(size_t j=0; j<text.Length(); j++)
        {
            uint c = text.GetAt(j);
            float fx1, fy1, fx2, fy2;

            fx1 = (float)x * scalefactor - labelwidth/2.0;
            fy1 = (float)(maxHeight/2 - y) * scalefactor;
            fx2 = (float)(x+width[c]) * scalefactor - labelwidth/2.0;
            fy2 = (float)(maxHeight/2 - y + height[c]) * scalefactor;
            //printf("rendering char %d pos %d,%d w/h %d,%d xp/yp %d,%d - %f %f %f %f\n", cp/4, x, y, width[c], height[c], xpos[c], ypos[c], fx1, fy1, fx2, fy2);
            facState->GetVertices()[cp  ].Set(fx2,0,fy1); 
            facState->GetVertices()[cp+1].Set(fx1,0,fy1); 
            facState->GetVertices()[cp+2].Set(fx1,0,fy2); 
//.........这里部分代码省略.........
开发者ID:Chettie,项目名称:Eulora-client,代码行数:101,代码来源:pseffectobjlabel.cpp

示例9: SetAttribute

bool LootRandomizer::SetAttribute(const csString &op, const csString &attrName, float modifier, RandomizedOverlay* overlay, psItemStats* baseItem, csArray<ValueModifier> &values)
{
    float* value[3] = { NULL, NULL, NULL };
    // Attribute Names:
    // item
    //        weight
    //        damage
    //            slash
    //            pierce
    //            blunt
    //            ...
    //        protection
    //            slash
    //            pierce
    //            blunt
    //            ...
    //        speed

    csString AttributeName(attrName);
    AttributeName.Downcase();
    if(AttributeName.StartsWith("var."))
    {
        //if var. was found we have a script variable
        //parse it and place it in the array which will be used later
        //to handle those variables.
        ValueModifier val;

        //start the name of the variable after var.
        val.name = attrName.Slice(4);
        val.value = modifier;
        val.op = op;

        //add the variable to the array
        values.Push(val);
        return true;
    }
    if(AttributeName.Compare("item.weight"))
    {
        // Initialize the value if needed
        if(CS::IsNaN(overlay->weight))
        {
            overlay->weight = baseItem->GetWeight();
        }

        value[0] = &overlay->weight;
    }
    else if(AttributeName.Compare("item.speed"))
    {
        // Initialize the value if needed
        if(CS::IsNaN(overlay->latency))
        {
            overlay->latency = baseItem->Weapon().Latency();
        }

        value[0] = &overlay->latency;
    }
    else if(AttributeName.Compare("item.damage"))
    {
        for(int i = 0; i < 3; i++)
        {
            // Initialize the value if needed
            if(CS::IsNaN(overlay->damageStats[i]))
            {
                overlay->damageStats[i] = baseItem->Weapon().Damage((PSITEMSTATS_DAMAGETYPE)i);
            }
        }

        value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH];
        value[1] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT];
        value[2] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE];
    }
    else if(AttributeName.Compare("item.damage.slash"))
    {
        // Initialize the value if needed
        if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH]))
        {
            overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH] = baseItem->Weapon().Damage(PSITEMSTATS_DAMAGETYPE_SLASH);
        }

        value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_SLASH];
    }
    else if(AttributeName.Compare("item.damage.pierce"))
    {
        // Initialize the value if needed
        if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE]))
        {
            overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE] = baseItem->Weapon().Damage(PSITEMSTATS_DAMAGETYPE_PIERCE);
        }

        value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_PIERCE];
    }
    else if(AttributeName.Compare("item.damage.blunt"))
    {
        // Initialize the value if needed
        if(CS::IsNaN(overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT]))
        {
            overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT] = baseItem->Weapon().Damage(PSITEMSTATS_DAMAGETYPE_BLUNT);
        }

        value[0] = &overlay->damageStats[PSITEMSTATS_DAMAGETYPE_BLUNT];
//.........这里部分代码省略.........
开发者ID:huigou,项目名称:planeshift,代码行数:101,代码来源:lootrandomizer.cpp

示例10: proc_arg

int proc_arg(int argc, char *argv[], int which)
{
    static Animation *last_anim;

    if (!strncmp(argv[which],"-a",2)) // build list of animations with frames
    {
    	int i;
        for (i = which+1; i < argc-1 && argv[i][0]!='-'; i+=3)
        {
            Animation *anim = new Animation;
            anim->name = argv[i];
            anim->startframe = atoi(argv[i+1]);
	    anim->duration   = atoi(argv[i+2]);

            anims.Push(anim);

	    csPrintf("Defined Animation: %s starting with frame %d.\n",
		   (const char *)anim->name, anim->startframe);

	    last_anim = anim;
        }
	return i;
    }
    else if (!strncmp(argv[which],"-s",2)) // build list of sockets and tri #'s.
    {
    	int i;
        for (i = which+1; i < argc-1 && argv[i][0]!='-'; i+=2)
        {
            Animation *socket = new Animation;
            socket->name = argv[i];
            socket->startframe = atoi(argv[i+1]);
            sockets.Push(socket);

	    csPrintf("Defined Socket: %s at polygon %d.\n",
		   (const char *)socket->name,socket->startframe);
        }
	return i;
    }
    else if (!strncmp(argv[which],"-dg",3)) // specify displacement frames
    {
    	int i;
        for (i = which+1; i < argc-1 && argv[i][0]!='-'; i+=3)
        {
            DisplacementGroup df;
            df.vertex = atoi(argv[i]);
            df.startframe = atoi(argv[i+1]);
            df.stopframe = atoi(argv[i+2]);

            last_anim->displacements.Push(df);

	    csPrintf("Defined displacement group: Frames %d thru %d, using vertex %d\n",
		   df.startframe, df.stopframe, df.vertex);
        }
	return i;
    }
    else
    {
       csPrintf("Illegal parameter %d (%s).  Please try again.\n",
	      which,argv[which]);
       return 0; // error
    }
}
开发者ID:GameLemur,项目名称:Crystal-Space,代码行数:62,代码来源:maya2spr.cpp


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