本文整理汇总了C++中Armor::load方法的典型用法代码示例。如果您正苦于以下问题:C++ Armor::load方法的具体用法?C++ Armor::load怎么用?C++ Armor::load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Armor
的用法示例。
在下文中一共展示了Armor::load方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char**argv)
{
Arguments info;
if(!parseOptions (argc, argv, info))
return 1;
ESMReader esm;
esm.setEncoding(info.encoding);
string filename = info.filename;
cout << "\nFile: " << filename << endl;
try {
if(info.raw_given)
{
cout << "RAW file listing:\n";
esm.openRaw(filename);
printRaw(esm);
return 0;
}
bool quiet = info.quiet_given;
bool loadCells = info.loadcells_given;
esm.open(filename);
cout << "Author: " << esm.getAuthor() << endl;
cout << "Description: " << esm.getDesc() << endl;
cout << "File format version: " << esm.getFVer() << endl;
cout << "Special flag: " << esm.getSpecial() << endl;
cout << "Masters:\n";
ESMReader::MasterList m = esm.getMasters();
for(unsigned int i=0;i<m.size();i++)
cout << " " << m[i].name << ", " << m[i].size << " bytes\n";
// Loop through all records
while(esm.hasMoreRecs())
{
NAME n = esm.getRecName();
esm.getRecHeader();
string id = esm.getHNOString("NAME");
if(!quiet)
cout << "\nRecord: " << n.toString()
<< " '" << id << "'\n";
switch(n.val)
{
case REC_ACTI:
{
Activator ac;
ac.load(esm);
if(quiet) break;
cout << " Name: " << ac.name << endl;
cout << " Mesh: " << ac.model << endl;
cout << " Script: " << ac.script << endl;
break;
}
case REC_ALCH:
{
Potion p;
p.load(esm);
if(quiet) break;
cout << " Name: " << p.name << endl;
break;
}
case REC_APPA:
{
Apparatus p;
p.load(esm);
if(quiet) break;
cout << " Name: " << p.name << endl;
break;
}
case REC_ARMO:
{
Armor am;
am.load(esm);
if(quiet) break;
cout << " Name: " << am.name << endl;
cout << " Mesh: " << am.model << endl;
cout << " Icon: " << am.icon << endl;
cout << " Script: " << am.script << endl;
cout << " Enchantment: " << am.enchant << endl;
cout << " Type: " << am.data.type << endl;
cout << " Weight: " << am.data.weight << endl;
break;
}
case REC_BODY:
{
BodyPart bp;
bp.load(esm);
if(quiet) break;
cout << " Name: " << bp.name << endl;
cout << " Mesh: " << bp.model << endl;
break;
}
//.........这里部分代码省略.........
示例2: loadFile
/**
* Loads a ruleset's contents from a YAML file.
* Rules that match pre-existing rules overwrite them.
* @param filename YAML filename.
*/
void Ruleset::loadFile(const std::string &filename)
{
YAML::Node doc = YAML::LoadFile(filename);
for (YAML::const_iterator i = doc["countries"].begin(); i != doc["countries"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
RuleCountry *rule;
if (_countries.find(type) != _countries.end())
{
rule = _countries[type];
}
else
{
rule = new RuleCountry(type);
_countries[type] = rule;
_countriesIndex.push_back(type);
}
rule->load(*i);
}
for (YAML::const_iterator i = doc["regions"].begin(); i != doc["regions"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
RuleRegion *rule;
if (_regions.find(type) != _regions.end())
{
rule = _regions[type];
}
else
{
rule = new RuleRegion(type);
_regions[type] = rule;
_regionsIndex.push_back(type);
}
rule->load(*i);
}
for (YAML::const_iterator i = doc["facilities"].begin(); i != doc["facilities"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
RuleBaseFacility *rule;
if (_facilities.find(type) != _facilities.end())
{
rule = _facilities[type];
}
else
{
rule = new RuleBaseFacility(type);
_facilities[type] = rule;
_facilitiesIndex.push_back(type);
}
_facilityListOrder += 100;
rule->load(*i, _modIndex, _facilityListOrder);
}
for (YAML::const_iterator i = doc["crafts"].begin(); i != doc["crafts"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
RuleCraft *rule;
if (_crafts.find(type) != _crafts.end())
{
rule = _crafts[type];
}
else
{
rule = new RuleCraft(type);
_crafts[type] = rule;
_craftsIndex.push_back(type);
}
_craftListOrder += 100;
rule->load(*i, this, _modIndex, _craftListOrder);
}
for (YAML::const_iterator i = doc["craftWeapons"].begin(); i != doc["craftWeapons"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
RuleCraftWeapon *rule;
if (_craftWeapons.find(type) != _craftWeapons.end())
{
rule = _craftWeapons[type];
}
else
{
rule = new RuleCraftWeapon(type);
_craftWeapons[type] = rule;
_craftWeaponsIndex.push_back(type);
}
rule->load(*i, _modIndex);
}
for (YAML::const_iterator i = doc["items"].begin(); i != doc["items"].end(); ++i)
{
std::string type = (*i)["type"].as<std::string>();
RuleItem *rule;
if (_items.find(type) != _items.end())
{
rule = _items[type];
}
else
//.........这里部分代码省略.........