本文整理汇总了C++中GfParmSetNum函数的典型用法代码示例。如果您正苦于以下问题:C++ GfParmSetNum函数的具体用法?C++ GfParmSetNum怎么用?C++ GfParmSetNum使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GfParmSetNum函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReInitResults
void
ReInitResults(void)
{
struct tm *stm;
time_t t;
void *results;
const int BUFSIZE = 1024;
char buf[BUFSIZE];
t = time(NULL);
stm = localtime(&t);
snprintf(buf, BUFSIZE, "%sresults/%s/results-%4d-%02d-%02d-%02d-%02d-%02d.xml",
GetLocalDir(),
ReInfo->_reFilename,
stm->tm_year+1900,
stm->tm_mon+1,
stm->tm_mday,
stm->tm_hour,
stm->tm_min,
stm->tm_sec
);
ReInfo->results = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
results = ReInfo->results;
GfParmSetNum(results, RE_SECT_HEADER, RE_ATTR_DATE, NULL, (tdble)t);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_DRIVER, NULL, 1);
}
示例2: sprintf
// Write parameter data to xml file
int TGeneticParameter::SetVal(void* SetupHandle, int Index)
{
char ParamSection[64];
if (Index > 0)
sprintf(ParamSection,"%s/%d",Section,Index);
else
sprintf(ParamSection,"%s",Section);
if (LeftRight)
{
char SideParam[64];
sprintf(SideParam,ParamSection,SECT_PH_LEFT);
GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
sprintf(SideParam,ParamSection,SECT_PH_RGHT);
if(SameSign)
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, Val, Min, Max);
else
return GfParmSetNum(SetupHandle, SideParam, Parameter, Unit, -Val, Min, Max);
}
else
return GfParmSetNum(SetupHandle, ParamSection, Parameter, Unit, Val, Min, Max);
}
示例3: saveSoundOption
// Save the choosen values in the corresponding parameter file.
static void saveSoundOption(void *)
{
// Force current edit to loose focus (if one has it) and update associated variable.
GfuiUnSelectCurrent();
char buf[1024];
sprintf(buf, "%s%s", GfLocalDir(), SND_PARAM_FILE);
void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
GfParmSetStr(paramHandle, SND_SCT_SOUND, SND_ATT_SOUND_STATE, soundOptionList[curOption]);
GfParmSetNum(paramHandle, SND_SCT_SOUND, SND_ATT_SOUND_VOLUME, "%", VolumeValue);
GfParmSetStr(paramHandle, SND_SCT_MUSIC, SND_ATT_MUSIC_STATE, musicStateList[curMusicState]);
GfParmSetNum(paramHandle, SND_SCT_MUSIC, SND_ATT_MUSIC_VOLUME, "%", MusicVolumeValue);
GfParmWriteFile(NULL, paramHandle, "sound");
GfParmReleaseHandle(paramHandle);
// Shutdown the user interface.
LegacyMenu::self().shutdown();
// Restart the game.
GfuiApp().restart();
// Return to previous screen.
GfuiScreenActivate(prevHandle);
}
示例4: RePostRace
int
RePostRace(void)
{
int curRaceIdx;
void *results = ReInfo->results;
void *params = ReInfo->params;
//ReUpdateStandings();
curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
curRaceIdx++;
GfOut("Race Nb %d\n", curRaceIdx);
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
ReUpdateStandings();
return RM_SYNC | RM_NEXT_RACE;
}
ReUpdateStandings();
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
taManager->RaceEnd(); // End of race for TA Manager
return RM_SYNC | RM_NEXT_STEP;
}
示例5: switch
void SDScreens::splitScreen(long p){
switch (p) {
case SD_SPLIT_ADD:
if (m_NbActiveScreens < SD_NB_MAX_SCREEN)
m_NbActiveScreens++;
if (m_SpanSplit)
m_NbArrangeScreens=1;
else
m_NbArrangeScreens=0;
break;
case SD_SPLIT_REM:
if (m_NbActiveScreens > 1)
m_NbActiveScreens--;
if (m_SpanSplit)
m_NbArrangeScreens=1;
else
m_NbArrangeScreens=0;
break;
case SD_SPLIT_ARR:
m_NbArrangeScreens++;
}
// Ensure current screen index stays in the righ range.
if (m_CurrentScreenIndex >= m_NbActiveScreens)
m_CurrentScreenIndex = m_NbActiveScreens - 1;
// Save nb of active screens to user settings.
GfParmSetNum(grHandle, GR_SCT_DISPMODE, GR_ATT_NB_SCREENS, NULL, m_NbActiveScreens);
GfParmSetNum(grHandle, GR_SCT_DISPMODE, GR_ATT_ARR_SCREENS, NULL, m_NbArrangeScreens);
GfParmWriteFile(NULL, grHandle, "Graph");
AdaptScreenSize();
}
示例6: GfParmGetNum
/**
* SetFuelAtRaceStart
*
* @param t the track
* @param carParmHandle handle for car parameters
* @param s current situation, provided by TORCS
* @param index index of car in the team
*/
void KStrategy::SetFuelAtRaceStart(const tTrack * const t,
void ** const carParmHandle,
const tSituation * const s,
const int index) {
// Load and set parameters.
const tdble fuel_cons_factor =
GfParmGetNum(*carParmHandle, SECT_ENGINE, PRM_FUELCONS, NULL, 1.0f);
const double fuel =
GfParmGetNum(*carParmHandle, KILO_SECT_PRIV, KILO_ATT_FUELPERLAP,
NULL, t->length * MAX_FUEL_PER_METER * fuel_cons_factor);
expected_fuel_per_lap_ = fuel;
// Pittime is pittime without refuel.
pittime_ = GfParmGetNum(*carParmHandle, KILO_SECT_PRIV,
KILO_ATT_PITTIME, NULL, 25.0);
best_lap_ = GfParmGetNum(*carParmHandle, KILO_SECT_PRIV,
KILO_ATT_BESTLAP, NULL, 87.0);
worst_lap_ = GfParmGetNum(*carParmHandle, KILO_SECT_PRIV,
KILO_ATT_WORSTLAP, NULL, 87.0);
// Fuel tank capacity
const double maxfuel = GfParmGetNum(*carParmHandle, SECT_CAR,
PRM_TANK, NULL, 100.0);
// Fuel for the whole race. A race needs one more lap - why???
const double fuelForRace = (s->_raceType == RM_TYPE_RACE)
? (s->_totLaps + 1.0) * fuel
: s->_totLaps * fuel;
// Compute race times for min to min + 9 pit stops.
ComputeBestNumberOfPits(maxfuel, fuelForRace, s->_totLaps, true);
last_fuel_ = fuel_per_stint_;
// If the setup defines initial fuel amount, use that value in races.
// Otherwise use computed amount.
const double initial_fuel = GfParmGetNum(*carParmHandle, SECT_CAR,
PRM_FUEL, NULL, 0.0);
if (s->_raceType == RM_TYPE_RACE) {
if (initial_fuel) {
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, initial_fuel);
} else {
// Add fuel dependent on index to avoid fuel stop in the same lap.
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL,
last_fuel_ + index * expected_fuel_per_lap_);
}
} else {
// Use fuel for whole 'race', ie qualy or practice N laps.
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, NULL, fuelForRace);
}
} // SetFuelAtRaceStart
示例7: saveSoundOption
// Save the choosen values in the corresponding parameter file.
static void saveSoundOption(void *)
{
const int BUFSIZE = 1024;
char buf[BUFSIZE];
snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), GR_SOUND_PARM_CFG);
void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
GfParmSetStr(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_STATE, soundOptionList[curOption]);
GfParmSetNum(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_VOLUME, "%", VolumeValue);
GfParmWriteFile(NULL, paramHandle, "sound");
GfParmReleaseHandle(paramHandle);
// Write Menu music optons
snprintf(buf, BUFSIZE, "%s%s", GetLocalDir(), MM_SOUND_PARM_CFG);
paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
GfParmSetStr(paramHandle, MM_SCT_SOUND, MM_ATT_SOUND_ENABLE, menuMusicList[curOptionMenuMusic]);
GfParmWriteFile(NULL, paramHandle, "sound");
GfParmReleaseHandle(paramHandle);
if (curOptionMenuMusic == 1) {
startMenuMusic();
} else {
stopMenuMusic();
}
// Return to previous screen.
GfuiScreenActivate(prevHandle);
return;
}
示例8: rmrpValidate
static void
rmrpValidate(void * /* dummy */)
{
if (rp->confMask & RM_CONF_RACE_LEN) {
rmrpUpdDist(0);
rmrpUpdLaps(0);
GfParmSetNum(rp->param, rp->title, RM_ATTR_DISTANCE, "km", rmrpDistance);
GfParmSetNum(rp->param, rp->title, RM_ATTR_LAPS, (char*)NULL, rmrpLaps);
}
if (rp->confMask & RM_CONF_DISP_MODE) {
GfParmSetStr(rp->param, rp->title, RM_ATTR_DISPMODE, rmCurDispModeList[rmCurDispMode]);
}
rmrpDeactivate(rp->nextScreen);
}
示例9: strrchr
/* Called for every track change or new race. */
void Driver::initTrack(tTrack* t, void *carHandle, void **carParmHandle, tSituation *s)
{
track = t;
char buffer[256];
/* get a pointer to the first char of the track filename */
char* trackname = strrchr(track->filename, '/') + 1;
switch (s->_raceType) {
case RM_TYPE_PRACTICE:
sprintf(buffer, "drivers/sparkle/%d/practice/%s", INDEX, trackname);
break;
case RM_TYPE_QUALIF:
sprintf(buffer, "drivers/sparkle/%d/qualifying/%s", INDEX, trackname);
break;
case RM_TYPE_RACE:
sprintf(buffer, "drivers/sparkle/%d/race/%s", INDEX, trackname);
break;
default:
break;
}
*carParmHandle = GfParmReadFile(buffer, GFPARM_RMODE_STD);
if (*carParmHandle == NULL) {
sprintf(buffer, "drivers/sparkle/%d/default.xml", INDEX);
*carParmHandle = GfParmReadFile(buffer, GFPARM_RMODE_STD);
}
float fuel = GfParmGetNum(*carParmHandle, BT_SECT_PRIV, BT_ATT_FUELPERLAP, (char*)NULL, 5.0);
fuel *= (s->_totLaps + 1.0);
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, (char*)NULL, MIN(fuel, 100.0));
MU_FACTOR = GfParmGetNum(*carParmHandle, BT_SECT_PRIV, BT_ATT_MUFACTOR, (char*)NULL, 0.69);
}
示例10: initTrack
/*
* Function
*
*
* Description
* search under drivers/human/tracks/<trackname>/car-<model>-<index>.xml
* drivers/human/car-<model>-<index>.xml
* drivers/human/tracks/<trackname>/car-<model>.xml
* drivers/human/car-<model>.xml
*
* Parameters
*
*
* Return
*
*
* Remarks
*
*/
static void initTrack(int index, tTrack* track, void *carHandle, void **carParmHandle, tSituation *s)
{
const char *carname;
const int BUFSIZE = 1024;
char buf[BUFSIZE];
char sstring[BUFSIZE];
tdble fuel;
int idx = index - 1;
curTrack = track;
snprintf(sstring, BUFSIZE, "Robots/index/%d", index);
snprintf(buf, BUFSIZE, "%sdrivers/human/human.xml", GetLocalDir());
void *DrvInfo = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
carname = "";
if (DrvInfo != NULL) {
carname = GfParmGetStr(DrvInfo, sstring, "car name", "");
}
*carParmHandle = NULL;
// If session type is "race" and we have a race setup use it
if (s->_raceType == RM_TYPE_RACE) {
*carParmHandle = RtParmReadSetup(RACE, "human", index, track->internalname, carname);
}
// If session type is "qualifying" and we have a qualifying setup use it, use qualifying setup as
// fallback if not race setup is available
if (s->_raceType == RM_TYPE_QUALIF || (*carParmHandle == NULL && s->_raceType == RM_TYPE_RACE)) {
*carParmHandle = RtParmReadSetup(QUALIFYING, "human", index, track->internalname, carname);
}
// If we have not yet loaded a setup we have not found a fitting one or want to use the practice setup,
// so try to load this
if (*carParmHandle == NULL) {
*carParmHandle = RtParmReadSetup(PRACTICE, "human", index, track->internalname, carname);
}
// Absolute fallback, nothing found
if (*carParmHandle == NULL) {
snprintf(sstring, BUFSIZE, "%sdrivers/human/car.xml", GetLocalDir ());
*carParmHandle = GfParmReadFile(sstring, GFPARM_RMODE_REREAD);
}
if (curTrack->pits.type != TR_PIT_NONE) {
snprintf(sstring, BUFSIZE, "%s/%s/%d", HM_SECT_PREF, HM_LIST_DRV, index);
HCtx[idx]->NbPitStopProg = (int)GfParmGetNum(PrefHdle, sstring, HM_ATT_NBPITS, (char*)NULL, 0);
GfOut("Player: index %d , Pits stops %d\n", index, HCtx[idx]->NbPitStopProg);
} else {
HCtx[idx]->NbPitStopProg = 0;
}
fuel = 0.0008 * curTrack->length * (s->_totLaps + 1) / (1.0 + ((tdble)HCtx[idx]->NbPitStopProg)) + 20.0;
if (*carParmHandle) {
GfParmSetNum(*carParmHandle, SECT_CAR, PRM_FUEL, (char*)NULL, fuel);
}
Vtarget = curTrack->pits.speedLimit;
if (DrvInfo != NULL) {
GfParmReleaseHandle(DrvInfo);
}
}
示例11: SaveGraphicOptions
static void
SaveGraphicOptions(void *prevMenu)
{
sprintf(buf, "%s%s", GetLocalDir(), GR_PARAM_FILE);
void * grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_FOVFACT, "%", FovFactorValue);
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_SMOKENB, NULL, SmokeValue);
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_MAXSTRIPBYWHEEL, NULL, SkidValue);
GfParmSetNum(grHandle, GR_SCT_GRAPHIC, GR_ATT_LODFACTOR, NULL, LodFactorValue);
GfParmWriteFile(NULL, grHandle, "graph");
GfParmReleaseHandle(grHandle);
ExitGraphicOptions(prevMenu);
}
示例12: reConfigureMenu
static void
reConfigureMenu(void * /* dummy */)
{
void *params = ReInfo->params;
/* Reset configuration automaton */
GfParmSetNum(params, RM_SECT_CONF, RM_ATTR_CUR_CONF, NULL, 1);
reConfigRunState();
}
示例13: GfParmReadFile
void RaceSet::genXML(){
std::string path = xmlFolder+"quickrace"+std::to_string(carQty)+".xml";
void *parmHandle = GfParmReadFile(path.c_str(), GFPARM_RMODE_CREAT);
int ret =mkdir(folder.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if(ret<0&&errno!=EEXIST){
std::cout<<"Race failed: Unable to access xml directory"<<std::endl;
throw 1;
}
for(int i=0;i<qty;i++){
GfParmSetNum(parmHandle, "Quick Race", "laps", NULL, races[i].laps);
GfParmSetNum(parmHandle, "Quick Race", "distance", NULL, races[i].distance);
GfParmSetStr(parmHandle, "Tracks/1", "name", races[i].track.c_str());
GfParmSetStr(parmHandle, "Tracks/1", "category", races[i].category.c_str());
GfParmWriteFile((folder+"r"+std::to_string(i)+".xml").c_str(), parmHandle, NULL);
}
}
示例14: SimAeroConfig
void
SimAeroConfig(tCar *car)
{
void *hdle = car->params;
tdble Cx, FrntArea;
Cx = GfParmGetNum(hdle, SECT_AERODYNAMICS, PRM_CX, (char*)NULL, 0.4);
FrntArea = GfParmGetNum(hdle, SECT_AERODYNAMICS, PRM_FRNTAREA, (char*)NULL, 2.5);
car->aero.Clift[0] = GfParmGetNum(hdle, SECT_AERODYNAMICS, PRM_FCL, (char*)NULL, 0.0);
car->aero.Clift[1] = GfParmGetNum(hdle, SECT_AERODYNAMICS, PRM_RCL, (char*)NULL, 0.0);
float aero_factor = car->options->aero_factor;
car->aero.SCx2 = 0.5f * AIR_DENSITY * Cx * FrntArea;
car->aero.Clift[0] *= aero_factor / 4.0f;
car->aero.Clift[1] *= aero_factor / 4.0f;
float max_lift = MaximumLiftGivenDrag (car->aero.SCx2, FrntArea);
float current_lift = 2.0f * (car->aero.Clift[0] + car->aero.Clift[1]);
if (current_lift > max_lift) {
fprintf (stderr, "Warning: car %s, driver %s: lift coefficients (%f, %f), generate a lift of %f, while maximum theoretical value is %f\n",
car->carElt->_carName,
car->carElt->_name,
car->aero.Clift[0],
car->aero.Clift[1],
current_lift,
max_lift);
}
GfParmSetNum(hdle, SECT_AERODYNAMICS, PRM_FCL, (char*)NULL, car->aero.Clift[0]);
GfParmSetNum(hdle, SECT_AERODYNAMICS, PRM_RCL, (char*)NULL, car->aero.Clift[1]);
//printf ("%f %f\n", GfParmGetNum(hdle, SECT_AERODYNAMICS, PRM_FCL, (char*)NULL, 0.0), GfParmGetNum(hdle, SECT_AERODYNAMICS, PRM_RCL, (char*)NULL, 0.0));
//printf ("cl: %f\n", car->aero.Clift[0]+car->aero.Clift[1]);
car->aero.Cd += car->aero.SCx2;
car->aero.rot_front[0] = 0.0;
car->aero.rot_front[1] = 0.0;
car->aero.rot_front[2] = 0.0;
car->aero.rot_lateral[0] = 0.0;
car->aero.rot_lateral[1] = 0.0;
car->aero.rot_lateral[2] = 0.0;
car->aero.rot_vertical[0] = 0.0;
car->aero.rot_vertical[1] = 0.0;
car->aero.rot_vertical[2] = 0.0;
}
示例15: GfParmSetStr
// Write table of content to configuration file
int TGeneticParameterTOC::Set()
{
GfParmSetStr(Handle,
SECT_TOC, PRM_AUTHOR, Author);
GfParmSetStr(Handle,
SECT_TOC, PRM_PRIVATE, Private);
GfParmSetNum(Handle,
SECT_TOC, PRM_LOOPS, 0, (float) OptimisationLoops);
GfParmSetNum(Handle,
SECT_TOC, PRM_DAMAGES, 0, (float) WeightOfDamages);
if (GetInitialVal)
GfParmSetNum(Handle,
SECT_TOC, PRM_INITIAL, 0, 1);
else
GfParmSetNum(Handle,
SECT_TOC, PRM_INITIAL, 0, 0);
return 0;
};