本文整理汇总了C++中TdfParser::LoadFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TdfParser::LoadFile方法的具体用法?C++ TdfParser::LoadFile怎么用?C++ TdfParser::LoadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TdfParser
的用法示例。
在下文中一共展示了TdfParser::LoadFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenTDF
void CReadMap::OpenTDF (const std::string& mapname, TdfParser& parser)
{
string extension = mapname.substr(mapname.length()-3);
if (extension == "smf")
parser.LoadFile (string("maps/")+mapname.substr(0,mapname.find_last_of('.'))+".smd");
else if(extension == "sm3")
parser.LoadFile (string("maps/")+mapname);
}
示例2: catch
CWeaponDefHandler::CWeaponDefHandler()
{
std::vector<std::string> tafiles = CFileHandler::FindFiles("weapons/", "*.tdf");
//std::cout << " getting files from weapons/*.tdf ... " << std::endl;
TdfParser tasunparser;
for(unsigned int i=0; i<tafiles.size(); i++)
{
try {
tasunparser.LoadFile(tafiles[i]);
}catch( TdfParser::parse_error const& e) {
std::cout << "Exception:" << e.what() << std::endl;
} catch(...) {
std::cout << "Unknown exception in parse process of " << tafiles[i] <<" caught." << std::endl;
}
}
std::vector<std::string> weaponlist = tasunparser.GetSectionList("");
weaponDefs = SAFE_NEW WeaponDef[weaponlist.size()+1];
for(std::size_t taid=0; taid<weaponlist.size(); taid++)
{
ParseTAWeapon(&tasunparser, weaponlist[taid], taid);
}
}
示例3: content_error
CSensorHandler::CSensorHandler()
{
TdfParser tdfparser;
try {
tdfparser.LoadFile("gamedata/sensors.tdf");
} catch (content_error) {
// No need to do anything here, we just continue
// getting default values from the empty tdfparser.
}
tdfparser.GetDef(losMipLevel, "1", "Sensors\\Los\\LosMipLevel");
//loshandler->losMipLevel = losMipLevel;
tdfparser.GetDef(airMipLevel, "2", "Sensors\\Los\\AirLosMipLevel");
//loshandler->airLosMipLevel = airLosMipLevel;
// losMipLevel is used as index to readmap->mipHeightmap,
// so the max value is CReadMap::numHeightMipMaps - 1
if (losMipLevel < 0 || losMipLevel >= 7)
throw content_error("Sensors\\Los\\LosMipLevel out of bounds. "
"The minimum value is 0. The maximum value is 6.");
// airLosMipLevel doesn't have such restrictions, it's just used in various
// bitshifts with signed integers
if (airMipLevel < 0 || airMipLevel > 30)
throw content_error("Sensors\\Los\\AirLosMipLevel out of bounds. "
"The minimum value is 0. The maximum value is 30.");
tdfparser.GetDef(losMul, "1", "Sensors\\Los\\LosMul");
tdfparser.GetDef(airLosMul, "1", "Sensors\\Los\\AirLosMul");
}
示例4: ParseUnit
void CSyncer::ParseUnit(const string& fileName)
{
TdfParser *p = new TdfParser();
p->LoadFile(fileName);
delete p;
}
示例5: ProcessUnits
int CSyncer::ProcessUnits(bool checksum)
{
if (!populated) {
//Populate the list of unit files to consider
files = CFileHandler::FindFiles("units/*.fbi");
populated = true;
}
if (files.size() == 0) {
return 0;
}
string curFile = files.back();
files.pop_back();
size_t len = curFile.find_last_of("/")+1;
string unitName = curFile.substr(len, curFile.size() - 4 - len);
transform(unitName.begin(), unitName.end(), unitName.begin(), (int (*)(int))tolower);
string perror("");
TdfParser *parser = new TdfParser();
try {
parser->LoadFile("units/" + unitName + ".fbi");
} catch (TdfParser::parse_error& pe) {
perror = unitName + " (" + string(pe.what()) + ")";
}
Unit u;
if (checksum) {
u.fbi = CalculateCRC("units/" + unitName + ".fbi");
u.cob = CalculateCRC("scripts/" + unitName + ".cob");
//The model filenames has to be figured out from the fbi file
string modelName = parser->SGetValueDef(unitName, "unitinfo\\Objectname");
string deadName = parser->SGetValueDef(unitName + "_dead", "unitinfo\\Corpse");
u.model = CalculateCRC("objects3d/" + modelName + ".3do");
u.model += CalculateCRC("objects3d/" + deadName + ".3do");
}
u.fullName = parser->SGetValueDef("unknown", "unitinfo\\Name");
if (perror.length() > 0)
u.fullName = perror;
units[unitName] = u;
delete parser;
//If we are done, map id numbers to names
if (files.size() == 0) {
MapUnitIds();
}
return (int)files.size();
}
示例6: catch
CSensorHandler::CSensorHandler(void)
{
TdfParser tdfparser;
try {
tdfparser.LoadFile("gamedata/sensors.tdf");
} catch (content_error) {
// No need to do anything here, we just continue
// getting the values from the empty tdfparser.
}
tdfparser.GetDef(losMipLevel, "1", "Sensors\\Los\\LosMipLevel");
//loshandler->losMipLevel = losMipLevel;
tdfparser.GetDef(airMipLevel, "2", "Sensors\\Los\\AirLosMipLevel");
//loshandler->airLosMipLevel = airLosMipLevel;
tdfparser.GetDef(losMul, "1", "Sensors\\Los\\LosMul");
tdfparser.GetDef(airLosMul, "1", "Sensors\\Los\\AirLosMul");
}
示例7: FindTABuildOpt
void CUnitDefHandler::FindTABuildOpt()
{
TdfParser tdfparser;
tdfparser.LoadFile("gamedata/SIDEDATA.TDF");
std::vector<std::string> sideunits = tdfparser.GetSectionList("CANBUILD");
for(unsigned int i=0; i<sideunits.size(); i++)
{
std::map<std::string, std::string>::iterator it;
UnitDef *builder=NULL;
std::transform(sideunits[i].begin(), sideunits[i].end(), sideunits[i].begin(), (int (*)(int))std::tolower);
std::map<std::string, int>::iterator it1 = unitID.find(sideunits[i]);
if(it1!= unitID.end())
builder = &unitDefs[it1->second];
if(builder)
{
std::map<std::string, std::string> buildoptlist = tdfparser.GetAllValues("CANBUILD\\" + sideunits[i]);
for(it=buildoptlist.begin(); it!=buildoptlist.end(); it++)
{
UnitDef *buildopt=0;
std::transform(it->second.begin(),it->second.end(), it->second.begin(), (int (*)(int))std::tolower);
if(unitID.find(it->second)!= unitID.end()){
int num=atoi(it->first.substr(8).c_str());
builder->buildOptions[num]=it->second;
}
}
}
}
std::vector<std::string> files = CFileHandler::FindFiles("download/*.tdf");
for(unsigned int i=0; i<files.size(); i++)
{
TdfParser dparser(files[i]);
std::vector<std::string> sectionlist = dparser.GetSectionList("");
for(unsigned int j=0; j<sectionlist.size(); j++)
{
UnitDef *builder=NULL;
std::string un1 = dparser.SGetValueDef("", sectionlist[j] + "\\UNITMENU");
std::transform(un1.begin(), un1.end(), un1.begin(), (int (*)(int))std::tolower);
std::map<std::string, int>::iterator it1 = unitID.find(un1);
if(it1!= unitID.end())
builder = &unitDefs[it1->second];
if(builder)
{
UnitDef *buildopt=NULL;
string un2 = dparser.SGetValueDef("", sectionlist[j] + "\\UNITNAME");
std::transform(un2.begin(), un2.end(), un2.begin(), (int (*)(int))std::tolower);
if(unitID.find(un2)!= unitID.end()){
int menu=atoi(dparser.SGetValueDef("", sectionlist[j] + "\\MENU").c_str());
int button=atoi(dparser.SGetValueDef("", sectionlist[j] + "\\BUTTON").c_str());
int num=(menu-2)*6+button+1;
builder->buildOptions[num]=un2;
} else {
info->AddLine("couldnt find unit %s",un2.c_str());
}
}
}
}
}