本文整理汇总了C++中CONFIGFILE类的典型用法代码示例。如果您正苦于以下问题:C++ CONFIGFILE类的具体用法?C++ CONFIGFILE怎么用?C++ CONFIGFILE使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CONFIGFILE类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Save
void SETTINGS::Save(std::string sfile)
{
if (net_local_plr > 0) // save only for host for many local games
return;
CONFIGFILE c; c.Load(sfile); version = SET_VER;
Serialize(true, c); c.Write();
}
示例2: LoadStartPos
// old
bool Scene::LoadStartPos(Ogre::String file)
{
CONFIGFILE param;
if (!param.Load(file))
return false;
float f3[3], f1;
QUATERNION <float> fixer; fixer.Rotate(3.141593, 0,0,1);
param.GetParam("start position 0", f3);
MATHVECTOR <float, 3> pos(f3[2], f3[0], f3[1]);
if (!param.GetParam("start orientation-xyz 0", f3))
return false;
if (!param.GetParam("start orientation-w 0", f1))
return false;
QUATERNION <float> rot(f3[2], f3[0], f3[1], f1);
rot = fixer * rot;
startPos = pos;
startRot = rot;
return true;
}
示例3: LoadSaveOptions
void GAME::LoadSaveOptions(OPTION_ACTION action, std::map<string, string> & options)
{
if (action == LOAD) //load from the settings class to the options map
{
CONFIGFILE tempconfig;
settings->Serialize(true, tempconfig);
std::list <string> paramlistoutput;
tempconfig.GetParamList(paramlistoutput);
for (std::list <string>::iterator i = paramlistoutput.begin(); i != paramlistoutput.end(); ++i)
{
string val;
tempconfig.GetParam(*i, val);
options[*i] = val;
//std::cout << "LOAD - PARAM: " << *i << " = " << val << endl;
}
}
else //save from the options map to the settings class
{
CONFIGFILE tempconfig;
for (std::map<string, string>::iterator i = options.begin(); i != options.end(); ++i)
{
tempconfig.SetParam(i->first, i->second);
//std::cout << "SAVE - PARAM: " << i->first << " = " << i->second << endl;
}
settings->Serialize(false, tempconfig);
//account for new settings
ProcessNewSettings();
}
}
示例4: LoadAllSurfaces
/// Surfaces all in data/cars/surfaces.cfg
//------------------------------------------------------------------------------------------------------------------------------
bool App::LoadAllSurfaces()
{
surfaces.clear();
surf_map.clear();
std::string path = PATHMANAGER::CarSim() + "/normal/surfaces.cfg";
CONFIGFILE param;
if (!param.Load(path))
{
LogO("Can't find surfaces configfile: " + path);
return false;
}
std::list <std::string> sectionlist;
param.GetSectionList(sectionlist);
for (std::list<std::string>::const_iterator section = sectionlist.begin(); section != sectionlist.end(); ++section)
{
TRACKSURFACE surf;
surf.name = *section;
int id;
param.GetParam(*section + ".ID", id); // for sound..
//-assert(indexnum >= 0 && indexnum < (int)tracksurfaces.size());
surf.setType(id);
float temp = 0.0;
param.GetParam(*section + ".BumpWaveLength", temp);
surf.bumpWaveLength = temp;
param.GetParam(*section + ".BumpAmplitude", temp);
surf.bumpAmplitude = temp;
//frictionX, frictionY, bumpWaveLength2, bumpAmplitude2, not shown ..
param.GetParam(*section + ".FrictionTread", temp);
surf.friction = temp;
if (param.GetParam(*section + ".RollResistance", temp)) surf.rollingResist = temp;
param.GetParam(*section + ".RollingDrag", temp);
surf.rollingDrag = temp;
///--- Tire ---
std::string tireFile;
if (!param.GetParam(*section + "." + "Tire", tireFile))
tireFile = "Default"; // default surface if not found
surf.tireName = tireFile;
///---
surfaces.push_back(surf);
surf_map[surf.name] = (int)surfaces.size(); //+1, 0 = not found
}
return true;
}
示例5: LoadCar
/// add a car, optionally controlled by the local player
CAR* GAME::LoadCar(const string & carname, const MATHVECTOR <float, 3> & start_position,
const QUATERNION <float> & start_orientation, bool islocal, bool isai, bool isRemote,
int idCar, bool asphalt)
{
CONFIGFILE carconf;
if (!carconf.Load(PATHMANAGER::GetCarPath()+"/"+carname+"/"+carname + (asphalt ? "_a":"") + ".car"))
return NULL;
cars.push_back(CAR());
if (!cars.back().Load(pOgreGame, settings,
carconf, PATHMANAGER::GetCarPath(),
PATHMANAGER::GetDriverPath()+"/driver2",
carname,
start_position, start_orientation,
collision,
sound.Enabled(),
sound.GetDeviceInfo(),
generic_sounds,
settings->abs || isai,
settings->tcs || isai,
isRemote,
idCar,
debugmode, info_output, error_output))
{
error_output << "Error loading car: " << carname << endl;
cars.pop_back();
return NULL;
}
else
{
info_output << "Car loading was successful: " << carname << endl;
if (islocal)
{
//load local controls
carcontrols_local.first = &cars.back();
//setup auto clutch and auto shift
ProcessNewSettings();
// shift into first gear if autoshift enabled
if (carcontrols_local.first && settings->autoshift)
carcontrols_local.first->SetGear(1);
}
}
return &cars.back();
}
示例6: Load
void SETTINGS::Load(std::string sfile)
{
CONFIGFILE c; c.Load(sfile);
Serialize(false, c);
}
示例7: Load
//----------------------------------------------------------------------------------------------------------------------------------
/// Load (.car file)
//----------------------------------------------------------------------------------------------------------------------------------
bool CARDYNAMICS::Load(GAME* pGame, CONFIGFILE & c, ostream & error_output)
{
QTimer ti; ti.update(); /// time
//bTerrain = false;
string drive = "RWD";
int version(1);
c.GetParam("version", version);
if (version > 2)
{
error_output << "Unsupported car version: " << version << endl;
return false;
}
float temp_vec3[3];
//load the engine
{
float mass, rpm_limit, inertia, friction,
start_rpm, stall_rpm, fuel_consumption;
MATHVECTOR<double,3> position;
if (!c.GetParam("engine.rpm-limit", rpm_limit, error_output)) return false;
engine.SetRpmMax(rpm_limit);
if (!c.GetParam("engine.inertia", inertia, error_output)) return false;
engine.SetInertia(inertia);
if (!c.GetParam("engine.friction", friction, error_output)) return false;
engine.SetFrictionB(friction);
if (!c.GetParam("engine.start-rpm", start_rpm, error_output)) return false;
engine.SetStartRPM(start_rpm);
if (!c.GetParam("engine.stall-rpm", stall_rpm, error_output)) return false;
engine.SetStallRPM(stall_rpm);
if (!c.GetParam("engine.fuel-consumption", fuel_consumption, error_output)) return false;
engine.SetFuelConsumption(fuel_consumption);
if (!c.GetParam("engine.mass", mass, error_output)) return false;
if (!c.GetParam("engine.position", temp_vec3, error_output)) return false;
if (version == 2) ConvertV2to1(temp_vec3[0],temp_vec3[1],temp_vec3[2]);
position.Set(temp_vec3[0],temp_vec3[1],temp_vec3[2]);
engine.SetMass(mass);
engine.SetPosition(position);
AddMassParticle(mass, position);
float mul = 1.f, max_torque = 0;
c.GetParam("engine.torque-val-mul", mul);
float torque_point[3];
string torque_str("engine.torque-curve-00");
vector <pair <double, double> > torques;
int curve_num = 0;
while (c.GetParam(torque_str, torque_point))
{
max_torque = max(max_torque, torque_point[1] * mul);
torques.push_back(pair <float, float> (torque_point[0], torque_point[1] * mul));
curve_num++;
stringstream str;
str << "engine.torque-curve-"; str.width(2); str.fill('0');
str << curve_num;
torque_str = str.str();
}
if (torques.size() <= 1)
{
error_output << "You must define at least 2 torque curve points." << endl;
return false;
}
engine.SetTorqueCurve(rpm_limit, torques);
//load the clutch
{
float mul; //max_torque = sliding * radius * area * max_pressure;
//if (!c.GetParam("clutch.max-torque", max_torque, error_output)) return false;
if (!c.GetParam("clutch.max-torque-mul", mul, error_output)) return false;
clutch.SetMaxTorque(max_torque * mul);
}
// factor for stats -
mul = 1.f;
if (c.GetParam("engine.real-pow-tq-mul", mul))
engine.real_pow_tq_mul = mul;
mul = 1.f;
if (c.GetParam("engine.sound-vol-mul", mul))
engine_vol_mul = mul;
}
//load the transmission
{
float time = 0;
float ratio;
int gears;
c.GetParam("transmission.shift-delay", time);
//.........这里部分代码省略.........
示例8: LoadSounds
//--------------------------------------------------------------------------------------------------------------------------
bool CAR::LoadSounds(
const std::string & carpath,
const std::string & carname,
const SOUNDINFO & sound_device_info,
const SOUNDBUFFERLIBRARY & sndLib,
std::ostream & info_output,
std::ostream & errOut)
{
//check for sound specification file
CONFIGFILE aud;
if (aud.Load(carpath+"/"+carname+"/"+carname+".aud")) // ?
{
std::list <std::string> sections;
aud.GetSectionList(sections);
for (std::list <std::string>::iterator i = sections.begin(); i != sections.end(); ++i)
{
//load the buffer
std::string filename;
if (!aud.GetParam(*i+".filename", filename, errOut)) return false;
if (!soundbuffers[filename].GetLoaded())
if (!soundbuffers[filename].Load(carpath+"/"+carname+"/"+filename, sound_device_info, errOut))
{
errOut << "Error loading sound: " << carpath+"/"+carname+"/"+filename << std::endl;
return false;
}
enginesounds.push_back(std::pair <ENGINESOUNDINFO, SOUNDSOURCE> ());
ENGINESOUNDINFO & info = enginesounds.back().first;
SOUNDSOURCE & sound = enginesounds.back().second;
if (!aud.GetParam(*i+".MinimumRPM", info.minrpm, errOut)) return false;
if (!aud.GetParam(*i+".MaximumRPM", info.maxrpm, errOut)) return false;
if (!aud.GetParam(*i+".NaturalRPM", info.naturalrpm, errOut)) return false;
std::string powersetting;
if (!aud.GetParam(*i+".power", powersetting, errOut)) return false;
if (powersetting == "on")
info.power = ENGINESOUNDINFO::POWERON;
else if (powersetting == "off")
info.power = ENGINESOUNDINFO::POWEROFF;
else //assume it's used in both ways
info.power = ENGINESOUNDINFO::BOTH;
sound.Setup(soundbuffers[filename], true, true, 0.f);
sound.Play();
}
//set blend start and end locations -- requires multiple passes
std::map <ENGINESOUNDINFO *, ENGINESOUNDINFO *> temporary_to_actual_map;
std::list <ENGINESOUNDINFO> poweron_sounds;
std::list <ENGINESOUNDINFO> poweroff_sounds;
for (std::list <std::pair <ENGINESOUNDINFO, SOUNDSOURCE> >::iterator i = enginesounds.begin(); i != enginesounds.end(); ++i)
{
ENGINESOUNDINFO & info = i->first;
if (info.power == ENGINESOUNDINFO::POWERON)
{
poweron_sounds.push_back(info);
temporary_to_actual_map[&poweron_sounds.back()] = &info;
}
else if (info.power == ENGINESOUNDINFO::POWEROFF)
{
poweroff_sounds.push_back(info);
temporary_to_actual_map[&poweroff_sounds.back()] = &info;
}
}
poweron_sounds.sort();
poweroff_sounds.sort();
//we only support 2 overlapping sounds at once each for poweron and poweroff; this
// algorithm fails for other cases (undefined behavior)
std::list <ENGINESOUNDINFO> * cursounds = &poweron_sounds;
for (int n = 0; n < 2; n++)
{
if (n == 1)
cursounds = &poweroff_sounds;
for (std::list <ENGINESOUNDINFO>::iterator i = (*cursounds).begin(); i != (*cursounds).end(); ++i)
{
//set start blend
if (i == (*cursounds).begin())
i->fullgainrpmstart = i->minrpm;
//else, the blend start has been set already by the previous iteration
//set end blend
std::list <ENGINESOUNDINFO>::iterator inext = i;
++inext;
if (inext == (*cursounds).end())
i->fullgainrpmend = i->maxrpm;
else
{
i->fullgainrpmend = inext->minrpm;
inext->fullgainrpmstart = i->maxrpm;
}
}
//now assign back to the actual infos
for (std::list <ENGINESOUNDINFO>::iterator i = (*cursounds).begin(); i != (*cursounds).end(); ++i)
{
//.........这里部分代码省略.........
示例9: Defaults
void CarModel::LoadConfig(const std::string & pathCar)
{
Defaults();
/// load -----
CONFIGFILE cf;
if (!cf.Load(pathCar))
{ LogO("!! CarModel: Can't load .car "+pathCar); return; }
//- custom interior model offset
cf.GetParam("model_ofs.interior-x", interiorOffset[0]);
cf.GetParam("model_ofs.interior-y", interiorOffset[1]);
cf.GetParam("model_ofs.interior-z", interiorOffset[2]);
cf.GetParam("model_ofs.rot_fix", bRotFix);
//~ boost offset
cf.GetParam("model_ofs.boost-x", boostOffset[0]);
cf.GetParam("model_ofs.boost-y", boostOffset[1]);
cf.GetParam("model_ofs.boost-z", boostOffset[2]);
cf.GetParam("model_ofs.boost-size-z", boostSizeZ);
cf.GetParam("model_ofs.boost-name", sBoostParName);
// thruster spaceship hover
cf.GetParam("model_ofs.thrust-x", thrusterOfs[0]);
cf.GetParam("model_ofs.thrust-y", thrusterOfs[1]);
cf.GetParam("model_ofs.thrust-z", thrusterOfs[2]);
cf.GetParam("model_ofs.thrust-size-z", thrusterSizeZ);
cf.GetParam("model_ofs.thrust-name", sThrusterPar);
//~ brake flares
float pos[3]; bool ok=true; int i=0;
while (ok)
{ ok = cf.GetParam("flares.brake-pos"+toStr(i), pos); ++i;
if (ok) brakePos.push_back(bRotFix ? Vector3(-pos[0],pos[2],pos[1]) : Vector3(-pos[1],-pos[2],pos[0]));
}
cf.GetParam("flares.brake-color", pos);
brakeClr = ColourValue(pos[0],pos[1],pos[2]);
cf.GetParam("flares.brake-size", brakeSize);
//- custom exhaust pos for boost particles
if (cf.GetParam("model_ofs.exhaust-x", exhaustPos[0]))
{
manualExhaustPos = true;
cf.GetParam("model_ofs.exhaust-y", exhaustPos[1]);
cf.GetParam("model_ofs.exhaust-z", exhaustPos[2]);
}else
manualExhaustPos = false;
if (!cf.GetParam("model_ofs.exhaust-mirror-second", has2exhausts))
has2exhausts = false;
//- load cameras pos
cf.GetParam("driver.view-position", pos, pGame->error_output);
driver_view[0]=pos[1]; driver_view[1]=-pos[0]; driver_view[2]=pos[2];
cf.GetParam("driver.hood-position", pos, pGame->error_output);
hood_view[0]=pos[1]; hood_view[1]=-pos[0]; hood_view[2]=pos[2];
// tire params
WHEEL_POSITION leftside = FRONT_LEFT, rightside = FRONT_RIGHT;
float value;
bool both = cf.GetParam("tire-both.radius", value);
std::string posstr = both ? "both" : "front";
for (int p = 0; p < 2; ++p)
{
if (p == 1)
{
leftside = REAR_LEFT;
rightside = REAR_RIGHT;
if (!both) posstr = "rear";
}
float radius;
cf.GetParam("tire-"+posstr+".radius", radius, pGame->error_output);
whRadius[leftside] = radius;
whRadius[rightside] = radius;
float width = 0.2f;
cf.GetParam("tire-"+posstr+".width-trail", width);
whWidth[leftside] = width;
whWidth[rightside] = width;
}
// wheel pos
// for track's ghost or garage view
int version(1);
cf.GetParam("version", version);
for (int i = 0; i < 4; ++i)
{
std::string sPos;
if (i == 0) sPos = "FL";
else if (i == 1) sPos = "FR";
else if (i == 2) sPos = "RL";
else sPos = "RR";
float pos[3];
//.........这里部分代码省略.........
示例10: LoadWorld
bool LoadWorld()
{
UnloadWorld();
editordata.helppage = 0;
editordata.numbezinput = 0;
editordata.mousebounce[1] = false;
//teststrip = track.AddNewRoad();
//begin loading world
LoadingScreen("Loading...\nConfiguration files");
CONFIGFILE setupfile;
setupfile.Load(settings.GetDataDir() + "/tracks/editor.config");
setupfile.GetParam("active track", editordata.activetrack);
if (editordata.activetrack == "")
editordata.activetrack = "default";
objects.LoadObjectsFromFolder(settings.GetDataDir() + "/tracks/" +
editordata.activetrack + "/objects/");
track.Load(editordata.activetrack);
//float aangle[] = {0, 1, 0, 0};
//track.GetStartOrientation(0).GetAxisAngle(aangle);
//cam.Rotate(aangle[0], aangle[1], aangle[2], aangle[3]);
VERTEX start = track.GetStart(0);
cam.Move(-start.x, -start.y, -start.z);
cam.Update();
cam.LoadVelocityIdentity();
//car_file = "s2000";
//ifstream csfile;
//car_file = "";
//csfile.open((settings.GetSettingsDir() + "/selected_car").c_str());
//car_paint = 0;
/* if (csfile)
{
state.SetCarName(0, utility.sGetLine(csfile));
state.SetCarPaint(0, utility.iGetParam(csfile));
csfile.close();
}
*/
//LoadingScreen("Loading...\nLoading scenery objects");
//objects.LoadObjectsFromFolder(settings.GetDataDir() + "/tracks/" + state.GetTrackName() + "/objects");
/*trees.DeleteAll();
int numtrees = 200;
for (i = 0; i < numtrees/2; i++)
{
VERTEX tp;
tp.x = ((float) rand()/RAND_MAX)*(param[0]/2.0)+param[0]/4.0;
tp.z = ((float) rand()/RAND_MAX)*(param[2]/2.0)+param[2]/4.0;
tp.x += param[3];
tp.z += param[4];
tp.y = terrain.GetHeight(tp.x, tp.z);
trees.Add(tp, 40.0, 0, 5);
}
for (i = 0; i < numtrees/2; i++)
{
VERTEX tp;
tp.x = ((float) rand()/RAND_MAX)*(param[0]/2.0)+param[0]/4.0;
tp.z = ((float) rand()/RAND_MAX)*(param[2]/2.0)+param[2]/4.0;
tp.x += param[3];
tp.z += param[4];
tp.y = terrain.GetHeight(tp.x, tp.z);
trees.Add(tp, 60.0, 1, 5);
}*/
LoadingScreen("Loading...\nDone");
mq1.AddMessage("Editor started, press H for help");
return true;
}