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


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

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


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

示例1: GenerateScriptXML

csString LootRandomizer::GenerateScriptXML(csString &name, csString &equip_script, csArray<ValueModifier> &values)
{
    csString scriptXML;
    csHash<float, csString> results;

    //prepare the heading of the apply script
    scriptXML.Format("<apply aim=\"Actor\" name=\"%s\" type=\"buff\">", name.GetData());

    //parse the values and try to find the default values for all variables
    //and put them in the hash in order to simplify access.
    for(size_t i = 0; i < values.GetSize(); ++i)
    {
        //Do it only for the VAL references which identify a default value.
        if(values[i].op.CompareNoCase("VAL"))
        {
            results.PutUnique(values[i].name, values[i].value);
            //delete the entry as we don't need it anymore, in order to reduce the
            //amount of items to check later
            values.DeleteIndex(i);
            //reduce the index as we have removed an item
            i--;
        }
    }
    //then do all the others operation entries, in order of definition.
    for(size_t i = 0; i < values.GetSize(); ++i)
    {
        //first of all check if the item is available in its default value
        //if it's not we are ignoring the operation as the variable is not
        //defined.
        if(results.Contains(values[i].name))
        {
            //we don't check for null as at this point it's safe the presence
            //of the variable in the hash (due to the check of contains).
            float* value[1] = {results.GetElementPointer(values[i].name)};
            SetAttributeApplyOP(value, values[i].value, 1, values[i].op);
        }
        else
        {
            Error2("Unable to find base value for variable %s", values[i].name.GetData());
        }
    }

    // If we have any variables defined, we add their definitions
    // on top of the script.
    if(!results.IsEmpty())
    {
        scriptXML.AppendFmt("<let vars=\"");
        csHash<float, csString>::GlobalIterator it = results.GetIterator();
        while(it.HasNext())
        {
            csTuple2<float, csString> entry = it.NextTuple();
            scriptXML.AppendFmt("%s = %f;", entry.second.GetData(), entry.first);
        }
        scriptXML.AppendFmt("\">%s</let></apply>", equip_script.GetData());
    }
    else
    {
        scriptXML.AppendFmt("%s</apply>", equip_script.GetData());
    }

    return scriptXML;
}
开发者ID:huigou,项目名称:planeshift,代码行数:62,代码来源:lootrandomizer.cpp


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