Exemple #1
0
//==========================================================================*
// Module entry point (Torcs backward compatibility scheme).
//--------------------------------------------------------------------------*
int simplixEntryPoint(tModInfo *ModInfo, void *RobotSettings)
{
    LogSimplix.debug("\n#Torcs backward compatibility scheme used\n");
    NBBOTS = MIN(10,NBBOTS);

    memset(ModInfo, 0, NBBOTS*sizeof(tModInfo));
	DriverNames = (char *) calloc(10,DRIVERLEN);
	DriverDescs = (char *) calloc(10,DESCRPLEN);
    memset(DriverNames, 0, 10*DRIVERLEN);
    memset(DriverDescs, 0, 10*DESCRPLEN);

    char SectionBuf[BUFSIZE];
	char *Section = SectionBuf;

	snprintf( SectionBuf, BUFSIZE, "%s/%s/%d", 
		ROB_SECT_ROBOTS, ROB_LIST_INDEX, 0);

    int I;
    for (I = 0; I < NBBOTS; I++) 
    {
	  snprintf( SectionBuf, BUFSIZE, "%s/%s/%d", 
		  ROB_SECT_ROBOTS, ROB_LIST_INDEX, I + IndexOffset );
	  const char *DriverName = GfParmGetStr( RobotSettings, 
		  Section, (char *) ROB_ATTR_NAME, defaultBotName[I]);
	  strncpy(&DriverNames[I*DRIVERLEN], DriverName, DRIVERLEN-1);
      const char *DriverDesc = GfParmGetStr( RobotSettings, 
		  Section, (char *) ROB_ATTR_DESC, defaultBotDesc[I]);
	  strncpy(&DriverDescs[I*DESCRPLEN], DriverDesc, DESCRPLEN-1);
    }

    return moduleInitialize(ModInfo);
}
Exemple #2
0
// Module entry point (Torcs backward compatibility scheme).
extern "C" int usr(tModInfo *modInfo)
{
  NBBOTS = 10;
  memset(DriverNames, 0, NBBOTS * DRIVERLEN);
  memset(DriverDescs, 0, NBBOTS * DRIVERLEN);

  // Filehandle for robot's xml-file
  void *robot_settings = getFileHandle();

  // Let's look what we have to provide here
  if (robot_settings)
  {
    char SectionBuf[BUFSIZE];
    char *Section = SectionBuf;

    snprintf(SectionBuf, BUFSIZE, "%s/%s/%d",
              ROB_SECT_ROBOTS, ROB_LIST_INDEX, 0);

    for (int i = 0; i < NBBOTS; ++i)
    {
      const char *DriverName = GfParmGetStr(robot_settings, Section,
                              ROB_ATTR_NAME, defaultBotName[i]);
      strncpy(&DriverNames[i * DRIVERLEN], DriverName, DRIVERLEN - 1);
      const char *DriverDesc = GfParmGetStr(robot_settings, Section,
                              ROB_ATTR_DESC, defaultBotDesc[i]);
      strncpy(&DriverDescs[i * DRIVERLEN], DriverDesc, DRIVERLEN - 1);
    }
  }
  return moduleInitialize(modInfo);
}
Exemple #3
0
/** Initialize the track for a race manager.
    @return <tt>0 ... </tt>Ok<br>
    <tt>-1 .. </tt>Error
*/
int
ReTrackInit(void)
{
	char buf[256];
	
	const char  *trackName;
	const char  *catName;

	const int curTrkIdx =
		(int)GfParmGetNum(ReInfo->results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1);
	snprintf(buf, sizeof(buf), "%s/%d", RM_SECT_TRACKS, curTrkIdx);
	trackName = GfParmGetStr(ReInfo->params, buf, RM_ATTR_NAME, 0);
	if (!trackName)
		return -1;

	catName = GfParmGetStr(ReInfo->params, buf, RM_ATTR_CATEGORY, 0);
	if (!catName) 
		return -1;

	snprintf(buf, sizeof(buf), "tracks/%s/%s/%s.%s", catName, trackName, trackName, TRKEXT);
	ReInfo->track = ReTrackLoader().load(buf);

	snprintf(buf, sizeof(buf), "Loading %s track", ReInfo->track->name);
	ReUI().addLoadingMessage(buf);

	reTrackInitTimeOfDay();
	reTrackInitWeather();

	reTrackDump(ReInfo->track, 0);

	return 0;
}//ReTrackInit
Exemple #4
0
static int 
createStaticImage(void* hscr, void* hparm, const char* pszName)
{
	const char* pszImage = GfParmGetStr(hparm, pszName, GFMNU_ATTR_IMAGE, "");

	const int x = (int)GfParmGetNum(hparm, pszName, GFMNU_ATTR_X, NULL, 0.0);
	const int y = (int)GfParmGetNum(hparm, pszName, GFMNU_ATTR_Y, NULL, 0.0);
	const int w = (int)GfParmGetNum(hparm, pszName, GFMNU_ATTR_WIDTH, NULL, 100.0);
	const int h = (int)GfParmGetNum(hparm, pszName, GFMNU_ATTR_HEIGHT, NULL, 100.0);

	const bool canDeform = getControlBoolean(hparm, pszName, GFMNU_ATTR_CAN_DEFORM, true);

	int id = GfuiStaticImageCreate(hscr, x, y, w, h, pszImage, canDeform);

	char pszImageFieldName[32];
	for (int i = 1; i < GFUI_MAXSTATICIMAGES;i++)
	{
		sprintf(pszImageFieldName, GFMNU_ATTR_IMAGE" %d", i);
		const char* pszFileName = GfParmGetStr(hparm, pszName, pszImageFieldName, 0);
		if (pszFileName)
			GfuiStaticImageSet(hscr, id, pszFileName, i);
		else
			break; // Assumes an indexed image list, with no hole inside.
	}

	return id;
}
Exemple #5
0
// Read table of content from configuration file 
int TGeneticParameterTOC::Get() 
{
	char* Value = (char*) GfParmGetStr(Handle, 
		SECT_TOC, PRM_AUTHOR, "Wolf-Dieter Beelitz");
	if (Author)
		free(Author);
	if (Value)
		Author = strdup(Value);
	else
		Author = NULL;

	Value = (char*) GfParmGetStr(Handle, 
		SECT_TOC, PRM_PRIVATE, "simplix private");
	if (Private)
		free(Private);
	if (Value)
		Private = strdup(Value);
	else
		Private = NULL;

	OptimisationLoops = (int) GfParmGetNum(Handle, 
		SECT_TOC, PRM_LOOPS, 0, (float) OptimisationLoops);
	WeightOfDamages = GfParmGetNum(Handle, 
		SECT_TOC, PRM_DAMAGES, 0, (float) WeightOfDamages);
	GetInitialVal = 0 < GfParmGetNum(Handle, 
		SECT_TOC, PRM_INITIAL, 0, 1);

	return 0;
}; 
Exemple #6
0
void gfuiLoadFonts(void)
{
	void *param;
	int	size;
	int	i;
	int nFontId;

	snprintf(buf, sizeof(buf), "%s%s", GfLocalDir(), GFSCR_CONF_FILE);
	param = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_CREAT);

	snprintf(buf, sizeof(buf), "%sdata/fonts/%s", GfDataDir(),
			 GfParmGetStr(param, "Menu Font", "name", "b5.glf"));
	GfLogTrace("Loading font 'Menu Font' from %s : Sizes", buf);
	nFontId = GFUI_FONT_BIG;
	for(i = 0; i < 4; i++, nFontId++) {
		size = (int)GfParmGetNum(param, "Menu Font", keySize[i], (char*)NULL, 10.0);
		GfLogTrace(" %d,", size);
		gfuiFont[nFontId] = new GfuiFontClass(buf);
		gfuiFont[nFontId]->create(size);
	}
	GfLogTrace("\n");

	snprintf(buf, sizeof(buf), "%sdata/fonts/%s", GfDataDir(),
			 GfParmGetStr(param, "Console Font", "name", "b7.glf"));
	GfLogTrace("Loading font 'Console Font' from %s : Sizes", buf);
	nFontId = GFUI_FONT_BIG_C;
	for(i = 0; i < 4; i++, nFontId++) {
		size = (int)GfParmGetNum(param, "Console Font", keySize[i], (char*)NULL, 10.0);
		GfLogTrace(" %d,", size);
		gfuiFont[nFontId] = new GfuiFontClass(buf);
		gfuiFont[nFontId]->create(size);
	}
	GfLogTrace("\n");

	snprintf(buf, sizeof(buf), "%sdata/fonts/%s", GfDataDir(),
			 GfParmGetStr(param, "Text Font", "name", "b6.glf"));
	GfLogTrace("Loading font 'Text Font' from %s : Sizes", buf);
	nFontId = GFUI_FONT_BIG_T;
	for(i = 0; i < 4; i++, nFontId++) {
		size = (int)GfParmGetNum(param, "Text Font", keySize[i], (char*)NULL, 10.0);
		GfLogTrace(" %d,", size);
		gfuiFont[nFontId] = new GfuiFontClass(buf);
		gfuiFont[nFontId]->create(size);
	}
	GfLogTrace("\n");

	snprintf(buf, sizeof(buf), "%sdata/fonts/%s", GfDataDir(),
			 GfParmGetStr(param, "Digital Font", "name", "digital.glf"));
	GfLogTrace("Loading font 'Digital Font' from %s : Sizes", buf);
	nFontId = GFUI_FONT_DIGIT;
	size = (int)GfParmGetNum(param, "Digital Font", keySize[0], (char*)NULL, 8.0);
	GfLogTrace(" %d\n", size);
	gfuiFont[nFontId] = new GfuiFontClass(buf);
	gfuiFont[nFontId]->create(size);

	GfParmReleaseHandle(param);
}
// Read sound configuration.
static void readSoundCfg(void)
{
	const char *optionName;
	int	i;
	char buf[1024];

	// Sound interface.
	sprintf(buf, "%s%s", GfLocalDir(), SND_PARAM_FILE);
	void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
	optionName = GfParmGetStr(paramHandle, SND_SCT_SOUND, SND_ATT_SOUND_STATE, soundOptionList[0]);

	for (i = 0; i < nbOptions; i++) {
		if (strcmp(optionName, soundOptionList[i]) == 0) {
			curOption = i;
			break;
		}
	}

	GfuiLabelSetText(scrHandle, SoundOptionId, soundOptionList[curOption]);

	// Sound volume.
	VolumeValue = GfParmGetNum(paramHandle, SND_SCT_SOUND, SND_ATT_SOUND_VOLUME, "%", 100.0f);
	if (VolumeValue>100.0f) {
		VolumeValue = 100.0f;
	} 
	else if (VolumeValue < 0.0f) {
		VolumeValue = 0.0f;
	}

	sprintf(buf, "%g", VolumeValue);
	GfuiEditboxSetString(scrHandle, VolumeValueId, buf);

	optionName = GfParmGetStr(paramHandle, SND_SCT_MUSIC, SND_ATT_MUSIC_STATE, musicStateList[0]);

	for (i = 0; i < nbMusicStates; i++) {
		if (strcmp(optionName, musicStateList[i]) == 0) {
			curMusicState = i;
			break;
		}
	}

	GfuiLabelSetText(scrHandle, MusicStateId, musicStateList[curMusicState]);

	// Music volume.
	MusicVolumeValue = GfParmGetNum(paramHandle, SND_SCT_MUSIC, SND_ATT_MUSIC_VOLUME, "%", 100.0f);
	if (MusicVolumeValue>100.0f) {
		MusicVolumeValue = 100.0f;
	} 
	else if (MusicVolumeValue < 0.0f) {
		MusicVolumeValue = 0.0f;
	}

		sprintf(buf, "%g", MusicVolumeValue);
	GfuiEditboxSetString(scrHandle, MusicVolumeValueId, buf);

	GfParmReleaseHandle(paramHandle);
}
Exemple #8
0
int 
GfuiMenuCreateEditControl(void* hscr, void* hparm, const char* pszName,
						  void* userDataOnFocus, tfuiCallback onFocus, tfuiCallback onFocusLost)
{
	std::string strControlPath(GFMNU_SECT_DYNAMIC_CONTROLS"/");
	strControlPath += pszName;

	const char* pszType = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TYPE, "");
	if (strcmp(pszType, GFMNU_TYPE_EDIT_BOX))
	{
		GfLogError("Failed to create control '%s' : section not found or not an '%s' \n",
				   pszName, GFMNU_TYPE_EDIT_BOX);
		return -1;
	}

	// TODO : Add real support for tips (the onFocus/onFocusLost system is already used
	//        for user input management)
	//         const char* pszTip = GfParmGetStr(hparm, pszName, GFMNU_ATTR_TIP, "");
	//         if (strlen(pszTip) > 0)
	//         {
	//                 tMenuCallbackInfo * cbinfo = (tMenuCallbackInfo*)calloc(1, sizeof(tMenuCallbackInfo));
	//                 cbinfo->screen = hscr;
	//                 cbinfo->labelId = GfuiTipCreate(hscr, pszTip, strlen(pszTip));
	//                 GfuiVisibilitySet(hscr, cbinfo->labelId, GFUI_INVISIBLE);
	//
	//                 // TODO: In this case, we simply ignore onFocus/onFocusLost !
	//                 userDataOnFocus = (void*)cbinfo;
	//                 onFocus = onFocusShowTip;
	//                 onFocusLost = onFocusLostHideTip;
	//         }

	const char* pszText = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TEXT, "");
	const int x = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_X, NULL, 0.0);
	const int y = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_Y, NULL, 0.0);
	const char* pszFontName = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_FONT, "");
	const int font = gfuiMenuGetFontId(pszFontName);
	const int width = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_WIDTH, NULL, 0.0);
	const int maxlen = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_MAX_LEN, NULL, 0.0);
	const char* pszAlignH = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_H_ALIGN, "");
	const int align = gfuiMenuGetAlignment(pszAlignH);

	const GfuiColor c = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR);
	const GfuiColor fc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR_FOCUSED);
	const GfuiColor dc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR_DISABLED);
	const GfuiColor bc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_COLOR);
	const GfuiColor bfc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_COLOR_FOCUSED);
	const GfuiColor bdc = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_COLOR_DISABLED);

	int id = GfuiEditboxCreate(hscr, pszText, font, x, y, width, maxlen, align,
							   userDataOnFocus, onFocus, onFocusLost);

	GfuiEditboxSetColors(hscr, id, c, fc, dc);
	GfuiEditboxSetBGColors(hscr, id, bc, bfc, bdc);

	return id;
}
Exemple #9
0
int 
GfuiMenuCreateProgressbarControl(void* hscr, void* hparm, const char* pszName)
{
	std::string strControlPath(GFMNU_SECT_DYNAMIC_CONTROLS"/");
	strControlPath += pszName;
	
	const std::string strType = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TYPE, "");
	if (strType != GFMNU_TYPE_PROGRESS_BAR)
	{
		GfLogError("Failed to create control '%s' : section not found or not an '%s' \n",
				   pszName, GFMNU_TYPE_PROGRESS_BAR);
		return -1;
	}
	
	const char* pszImage =
		GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_IMAGE, "data/img/progressbar.png");
	const char* pszBgImage =
		GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_BG_IMAGE, "data/img/progressbar-bg.png");
	
	const float* aOutlineColor = 0;
	const GfuiColor color = getControlColor(hparm, strControlPath.c_str(), GFMNU_ATTR_COLOR);
	if (color.alpha)
		aOutlineColor = color.toFloatRGBA();

	const int x = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_X, NULL, 0.0);
	const int y = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_Y, NULL, 0.0);
	const int w = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_WIDTH, NULL, 100.0);
	const int h = (int)GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_HEIGHT, NULL, 20.0);
	
	const float min = GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_MIN, NULL, 0.0);
	const float max = GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_MAX, NULL, 100.0);
	const float value = GfParmGetNum(hparm, strControlPath.c_str(), GFMNU_ATTR_VALUE, NULL, 50.0);
	
	const char* pszTip = GfParmGetStr(hparm, strControlPath.c_str(), GFMNU_ATTR_TIP, "");
	
	void* userDataOnFocus = 0;
	tfuiCallback onFocus = 0;
	tfuiCallback onFocusLost = 0;
	if (strlen(pszTip) > 0)
	{
		tMenuCallbackInfo * cbinfo = (tMenuCallbackInfo*)calloc(1, sizeof(tMenuCallbackInfo));
		cbinfo->screen = hscr;
		cbinfo->labelId = GfuiTipCreate(hscr, pszTip, strlen(pszTip));
		GfuiVisibilitySet(hscr, cbinfo->labelId, GFUI_INVISIBLE);
		
		userDataOnFocus = (void*)cbinfo;
		onFocus = onFocusShowTip;
		onFocusLost = onFocusLostHideTip;
	}

	int id = GfuiProgressbarCreate(hscr, x, y, w, h, pszBgImage, pszImage, aOutlineColor,
								   min, max, value, userDataOnFocus, onFocus, onFocusLost);
	
	return id;
}
Exemple #10
0
static void loadSimuCfg(void)
{
	const char *simuVersionName;
	const char *multiThreadSchemeName;
	const char *threadAffinitySchemeName;
	int i;

	char buf[1024];
	snprintf(buf, sizeof(buf), "%s%s", GfLocalDir(), RACE_ENG_CFG);

	void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);

	// Simulation engine name.
	simuVersionName = GfParmGetStr(paramHandle, RM_SECT_MODULES, RM_ATTR_MOD_SIMU, SimuVersionList[DefaultSimuVersion]);
	for (i = 0; i < NbSimuVersions; i++) {
		if (strcmp(simuVersionName, SimuVersionList[i]) == 0) {
			CurSimuVersion = i;
			break;
		}
	}

	// Check if the selected simulation module is there, and fall back to the default one if not.
	snprintf(buf, sizeof(buf), "%smodules/simu/%s.%s", GfLibDir(), SimuVersionList[CurSimuVersion], DLLEXT);
	if (!GfFileExists(buf))
	{
		GfLogWarning("User settings %s physics engine module not found ; falling back to %s\n",
					 SimuVersionList[CurSimuVersion], SimuVersionList[DefaultSimuVersion]);
		CurSimuVersion = DefaultSimuVersion;
	}

	// Multi-threading.
	multiThreadSchemeName = GfParmGetStr(paramHandle, RM_SECT_RACE_ENGINE, RM_ATTR_MULTI_THREADING, MultiThreadSchemeList[0]);
	for (i = 0; i < NbMultiThreadSchemes; i++) {
		if (strcmp(multiThreadSchemeName, MultiThreadSchemeList[i]) == 0) {
			CurMultiThreadScheme = i;
			break;
		}
	}

	// Thread affinity.
	threadAffinitySchemeName = GfParmGetStr(paramHandle, RM_SECT_RACE_ENGINE, RM_ATTR_THREAD_AFFINITY, ThreadAffinitySchemeList[0]);
	for (i = 0; i < NbThreadAffinitySchemes; i++) {
		if (strcmp(threadAffinitySchemeName, ThreadAffinitySchemeList[i]) == 0) {
			CurThreadAffinityScheme = i;
			break;
		}
	}

	GfParmReleaseHandle(paramHandle);

	GfuiLabelSetText(ScrHandle, SimuVersionId, SimuVersionDispNameList[CurSimuVersion]);
	GfuiLabelSetText(ScrHandle, MultiThreadSchemeId, MultiThreadSchemeList[CurMultiThreadScheme]);
	GfuiLabelSetText(ScrHandle, ThreadAffinitySchemeId, ThreadAffinitySchemeList[CurThreadAffinityScheme]);
}
Exemple #11
0
int
ReRaceEventInit(void)
{
	void *mainParams = ReInfo->mainParams;
	void *params = ReInfo->params;

	const bool careerMode = strcmp(GfParmGetStr(ReInfo->mainParams, RM_SECT_SUBFILES, RM_ATTR_HASSUBFILES, RM_VAL_NO), RM_VAL_YES) == 0;
	
	/* Career mode : Look if it is necessary to open another file */
	if (strcmp(GfParmGetStr(mainParams, RM_SECT_SUBFILES, RM_ATTR_HASSUBFILES, RM_VAL_NO), RM_VAL_YES) == 0)
	{
		/* Close previous params */
		if (params != mainParams)
			GfParmReleaseHandle(params);

		/* Read the new params */
		ReInfo->params = GfParmReadFile( GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, "" ), GFPARM_RMODE_STD );
		GfLogTrace("Career : New params file is %s (from main results file)\n",
				   GfParmGetStr( ReInfo->mainResults, RE_SECT_CURRENT, RE_ATTR_CUR_FILE, ""));
		if (!ReInfo->params)
			GfLogWarning( "Career : MainResults params weren't read correctly\n" );

		/* Close previous results */
		if (ReInfo->results != ReInfo->mainResults)
		{
			GfParmWriteFile(NULL, ReInfo->results, NULL);
			GfParmReleaseHandle(ReInfo->results);
		}

		/* Read the new results */
		ReInfo->results = GfParmReadFile( GfParmGetStr( ReInfo->params, RM_SECT_SUBFILES, RM_ATTR_RESULTSUBFILE, ""), GFPARM_RMODE_STD );
		if (!ReInfo->results)
			GfLogWarning( "Career : New results weren't read correctly\n" );
	}

	// Initialize the race session name.
	ReInfo->_reRaceName = ReGetCurrentRaceName();
	GfLogInfo("Starting new event (%s session)\n", ReInfo->_reRaceName);

	ReUI().onRaceEventInitializing();
	
	ReInfo->s->_features = RmGetFeaturesList(ReInfo->params);

	ReTrackInit();
	
	ReEventInitResults();

	NoCleanupNeeded = false;

	const bool bGoOnLooping = ReUI().onRaceEventStarting(careerMode && !ReHumanInGroup());

	return (bGoOnLooping ? RM_SYNC : RM_ASYNC) | RM_NEXT_STEP;
}
int
ReRacemanMenu(void)
{
    char	*str;
    void	*params = ReInfo->params;

    if (racemanMenuHdle) {
        GfuiScreenRelease(racemanMenuHdle);
    }
    racemanMenuHdle = GfuiScreenCreateEx(NULL,
                                         NULL, (tfuiCallback)NULL,
                                         NULL, (tfuiCallback)NULL,
                                         1);

    str = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_BGIMG, 0);
    if (str) {
        GfuiScreenAddBgImg(racemanMenuHdle, str);
    }

    GfuiMenuDefaultKeysAdd(racemanMenuHdle);

    str = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_NAME, 0);
    if (str) {
        GfuiTitleCreate(racemanMenuHdle, str, strlen(str));
    }


    GfuiMenuButtonCreate(racemanMenuHdle,
                         "New Race", "Start a New Race",
                         NULL, ReStartNewRace);

    GfuiMenuButtonCreate(racemanMenuHdle,
                         "Configure Race", "Configure The Race",
                         NULL, reConfigureMenu);

    /*     GfuiMenuButtonCreate(racemanMenuHdle, */
    /* 			 "Configure Players", "Players configuration menu", */
    /* 			 TorcsDriverMenuInit(racemanMenuHdle), GfuiScreenActivate); */

    if (GfParmGetEltNb(params, RM_SECT_TRACKS) > 1) {
        GfuiMenuButtonCreate(racemanMenuHdle,
                             "Load", "Load a Previously Saved Game",
                             racemanMenuHdle, reLoadMenu);
    }

    GfuiMenuBackQuitButtonCreate(racemanMenuHdle,
                                 "Back to Main", "Return to previous Menu",
                                 ReInfo->_reMenuScreen, GfuiScreenActivate);

    GfuiScreenActivate(racemanMenuHdle);

    return RM_ASYNC | RM_NEXT_STEP;
}
Exemple #13
0
void
RmStopRaceMenu()
{
	void* params = LmRaceEngine().outData()->params;
	const char* pszRaceName = LmRaceEngine().outData()->_reRaceName;

	// Mute sound.
	if (LegacyMenu::self().soundEngine())
		LegacyMenu::self().soundEngine()->mute();

	if (!strcmp(GfParmGetStr(params, pszRaceName, RM_ATTR_ALLOW_RESTART, RM_VAL_NO), RM_VAL_NO)) 
	{
		if (strcmp(GfParmGetStr(params, pszRaceName, RM_ATTR_MUST_COMPLETE, RM_VAL_YES), RM_VAL_YES)) 
		{
			rmStopScrHandle =
				rmStopRaceMenu
				    ("resume", RmBackToRaceHookInit(),
					 "skip", rmSkipSessionHookInit(),
					 "abort", rmAbortRaceHookInit(),
					 "quit", rmQuitHookInit());
		}
		else 
		{
			rmStopScrHandle =
				rmStopRaceMenu
				    ("resume", RmBackToRaceHookInit(),
					 "abort", rmAbortRaceHookInit(),
					 "quit", rmQuitHookInit());
		}
	}
	else 
	{
		if (strcmp(GfParmGetStr(params, pszRaceName, RM_ATTR_MUST_COMPLETE, RM_VAL_YES), RM_VAL_YES)) 
		{
			rmStopScrHandle =
				rmStopRaceMenu
				    ("resume", RmBackToRaceHookInit(),
					 "skip", rmSkipSessionHookInit(),
					 "restart", rmRestartRaceHookInit(),
					 "abort", rmAbortRaceHookInit(),
					 "quit", rmQuitHookInit());
		}
		else 
		{
			rmStopScrHandle =
				rmStopRaceMenu
				    ("resume", RmBackToRaceHookInit(),
					 "restart", rmRestartRaceHookInit(),
					 "abort", rmAbortRaceHookInit(),
					 "quit", rmQuitHookInit());
		}
	}
}
int
ReNewTrackMenu(void)
{
	void	*params = ReInfo->params;
	void	*results = ReInfo->results;
	
	if (newTrackMenuHdle) {
		GfuiScreenRelease(newTrackMenuHdle);
	}

	newTrackMenuHdle = GfuiScreenCreateEx(NULL, 
						NULL, (tfuiCallback)NULL, 
						NULL, (tfuiCallback)NULL, 
						1);
	
	const char* str = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_BGIMG, 0);
	if (str) {
		GfuiScreenAddBgImg(newTrackMenuHdle, str);
	}

	str = GfParmGetStr(params, RM_SECT_HEADER, RM_ATTR_NAME, "");
	GfuiTitleCreate(newTrackMenuHdle, str, strlen(str));
	
	GfuiMenuDefaultKeysAdd(newTrackMenuHdle);
	
	sprintf(buf, "Race Day #%d/%d on %s",
		(int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_TRACK, NULL, 1),
		GfParmGetEltNb(params, RM_SECT_TRACKS),
		ReInfo->track->name);
	
	GfuiLabelCreateEx(newTrackMenuHdle,
				buf,
				red,
				GFUI_FONT_MEDIUM_C,
				320, 420,
				GFUI_ALIGN_HC_VB, 50);
	
	GfuiMenuButtonCreate(newTrackMenuHdle,
				"Start Event", "Start The Current Race",
				NULL, reStateManage);
	
	
	GfuiMenuButtonCreate(newTrackMenuHdle, 
				"Abandon", "Abandon The Race",
				ReInfo->_reMenuScreen, GfuiScreenActivate);
	
	GfuiAddKey(newTrackMenuHdle, 27,  "Abandon", ReInfo->_reMenuScreen, GfuiScreenActivate, NULL);
	
	GfuiScreenActivate(newTrackMenuHdle);
	
	return RM_ASYNC | RM_NEXT_STEP;
}
Exemple #15
0
void GfDriver::load(void* hparmRobot)
{
	std::ostringstream ossDrvSecPath;
	ossDrvSecPath << ROB_SECT_ROBOTS << '/' << ROB_LIST_INDEX << '/' << _nItfIndex;

	// Humanity.
	_bIsHuman =
		strcmp(GfParmGetStr(hparmRobot, ossDrvSecPath.str().c_str(), ROB_ATTR_TYPE, ROB_VAL_ROBOT),
			   ROB_VAL_ROBOT) != 0;

	// Skill level.
    const char* pszKillLevel =
		GfParmGetStr(hparmRobot, ossDrvSecPath.str().c_str(), ROB_ATTR_LEVEL, ROB_VAL_SEMI_PRO);
    for(int nLevelInd = 0; nLevelInd < NbSkillLevels; nLevelInd++)
	{
		if (!strcmp(ASkillLevelStrings[nLevelInd], pszKillLevel))
		{
			_fSkillLevel = ASkillLevelValues[nLevelInd];
			break;
		}
    }

	// Supported features.
	if (_bIsHuman)
	{
		_nFeatures = RM_FEATURE_TIMEDSESSION | RM_FEATURE_WETTRACK;
		if (_fSkillLevel <= ASkillLevelValues[3]) // Pro (TODO: Create enum for that !)
			_nFeatures |= RM_FEATURE_PENALTIES;
	}
	else
	{
		_nFeatures = 0;
		char* pszDrvFeatures =
			strdup(GfParmGetStr(hparmRobot, ossDrvSecPath.str().c_str(), ROB_ATTR_FEATURES, ""));
		for (char* pszFeature = strtok(pszDrvFeatures, ";");
			 pszFeature != 0; pszFeature = strtok(NULL, ";"))
		{
			for (int nFeatInd = 0; nFeatInd < NRobotFeatures; nFeatInd++)
				if (!strcmp(pszFeature, RobotFeatures[nFeatInd].pszName))
				{
					_nFeatures |= RobotFeatures[nFeatInd].nValue;
					break;
				}
		}
		free(pszDrvFeatures);
	}

	// Driven car.
	const char* pszCarId = GfParmGetStr(hparmRobot, ossDrvSecPath.str().c_str(), ROB_ATTR_CAR, "");
	_pCar = GfCars::self()->getCar(pszCarId);
}
Exemple #16
0
void
ReUpdateQualifCurRes(tCarElt *car)
{
	int i;
	int nCars;
	int printed;
	int maxLines;
	void *carparam;
	char *carName;
	const char *race = ReInfo->_reRaceName;
	void *results = ReInfo->results;
	const int BUFSIZE = 1024;
	char buf[BUFSIZE], path[BUFSIZE];

	ReResEraseScreen();
	maxLines = ReResGetLines();
	
	snprintf(buf, BUFSIZE, "%s on %s - Lap %d", car->_name, ReInfo->track->name, car->_laps);
	ReResScreenSetTitle(buf);
	
	snprintf(buf, BUFSIZE, "cars/%s/%s.xml", car->_carName, car->_carName);
	carparam = GfParmReadFile(buf, GFPARM_RMODE_STD);
	carName = GfParmGetName(carparam);
	
	printed = 0;
	snprintf(path, BUFSIZE, "%s/%s/%s/%s", ReInfo->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK);
	nCars = GfParmGetEltNb(results, path);
	nCars = MIN(nCars + 1, maxLines);
	for (i = 1; i < nCars; i++) {
		snprintf(path, BUFSIZE, "%s/%s/%s/%s/%d", ReInfo->track->name, RE_SECT_RESULTS, race, RE_SECT_RANK, i);
		if (!printed) {
			if ((car->_bestLapTime != 0.0) && (car->_bestLapTime < GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0))) {
				snprintf(buf, BUFSIZE, "%d - %s - %s (%s)", i, GfTime2Str(car->_bestLapTime, 0), car->_name, carName);
				ReResScreenSetText(buf, i - 1, 1);
				printed = 1;
			}
		}
		snprintf(buf, BUFSIZE, "%d - %s - %s (%s)", i + printed, GfTime2Str(GfParmGetNum(results, path, RE_ATTR_BEST_LAP_TIME, NULL, 0), 0),
		GfParmGetStr(results, path, RE_ATTR_NAME, ""), GfParmGetStr(results, path, RE_ATTR_CAR, ""));
		ReResScreenSetText(buf, i - 1 + printed, 0);
	}

	if (!printed) {
		snprintf(buf, BUFSIZE, "%d - %s - %s (%s)", i, GfTime2Str(car->_bestLapTime, 0), car->_name, carName);
		ReResScreenSetText(buf, i - 1, 1);
	}

	GfParmReleaseHandle(carparam);
	ReInfo->_refreshDisplay = 1;
}
Exemple #17
0
void RaceSet::readConfig(std::string configXML){
	
	
	void *parmHandle = GfParmReadFile(configXML.c_str(), GFPARM_RMODE_STD);

	std::string id=GfParmGetStr(parmHandle, "Header", "id", "default");
	folder=xmlOut+id+"/";

	md=GfParmGetNum(parmHandle, "Header", "mindist", NULL, 0);
	mt=GfParmGetNum(parmHandle, "Header", "maxticks", NULL, 0);


	Race r;
	std::string path;

	std::string track = GfParmGetStr(parmHandle, "Races/1", "track", "not found");

	


	path="Races/"+std::to_string(1);
	

	int i;
	for(i=1;track!="not found";i++){
		r.track=track;
		
		r.distance=GfParmGetNum(parmHandle, path.c_str(), "distance", NULL, 0);
		r.laps=GfParmGetNum(parmHandle, path.c_str(), "laps", NULL, 0);
		r.category= GfParmGetStr(parmHandle, path.c_str(), "category", "road");
		if(r.distance<=0&&r.laps<=0){
			std::cout<<"RaceSet construction failed: invalid race length for race #"<<i<<std::endl;
			throw 1;
		}

		races.push_back(r);

		path="Races/"+std::to_string(i+1);

		track = GfParmGetStr(parmHandle, path.c_str(), "track", "not found");
	}


	if(i==1){
		std::cout<<"RaceSet construction failed: empty set of races"<<std::endl;
		throw 1;
	}
	
	
}
Exemple #18
0
bool LegacyMenu::onRaceFinished(bool bEndOfSession)
{
    tRmInfo* pReInfo = _piRaceEngine->inData();

    // Display the results of the session for all the competitors
    // only if this is the end of a session (for all competitors),
    // and if specified by the race mode or if the display mode is "normal".
    if (bEndOfSession
		&& (!strcmp(GfParmGetStr(pReInfo->params, pReInfo->_reRaceName, RM_ATTR_DISPRES, RM_VAL_YES), RM_VAL_YES)
            || pReInfo->_displayMode == RM_DISP_MODE_NORMAL))
	{
        // Create the "Race Engine update state" hook if not already done.
        if (!_hscrReUpdateStateHook)
            _hscrReUpdateStateHook = ::RmInitReUpdateStateHook();

        // This is now the "game" screen.
        _hscrGame = _hscrReUpdateStateHook;

        // Display the results menu (will activate the game screen on exit).
        ::RmShowResults(_hscrGame, _piRaceEngine->inData());

        // Tell the race engine state automaton to stop looping (enter the menu).
        return false;
    }

    GfLogInfo("Not starting Results menu (not end of session, or specified not to, or blind mode).\n");

    return true;
}
// Implementation of IRaceEngine.
void StandardGame::reset(void)
{
	GfLogInfo("Resetting StandardGame race engine.\n");

	// Cleanup everything in case no yet done.
	cleanup();
	
	// Internal init.
	::ReReset();

	// Load and initialize the track loader module.
	const char* pszModName =
		GfParmGetStr(ReSituation::self().data()->_reParam, "Modules", "track", "track");
	GfLogInfo("Loading '%s' track loader ...\n", pszModName);
	GfModule* pmodTrkLoader = GfModule::load("modules/track", pszModName);

	// Check that it implements ITrackLoader.
	if (pmodTrkLoader)
		_piTrkLoader = pmodTrkLoader->getInterface<ITrackLoader>();
	if (pmodTrkLoader && !_piTrkLoader)
	{
		GfModule::unload(pmodTrkLoader);
		return;
	}

	// Initialize GfTracks' track module interface (needed for some track infos).
	GfTracks::self()->setTrackLoader(_piTrkLoader);
}
Exemple #20
0
static void
rmdsClickOnDriver(void * /* dummy */)
{
    char	*name;
    tDrvElt	*curDrv;
    void	*robhdle;

    name = GfuiScrollListGetSelectedElement(scrHandle, selectedScrollList, (void**)&curDrv);
    if (!name) {
	name = GfuiScrollListGetSelectedElement(scrHandle, unselectedScrollList, (void**)&curDrv);
    }
    
    if (name) {
	GfuiLabelSetText(scrHandle, PickDrvNameLabelId, curDrv->name);
	/* search driver infos */
	sprintf(buf, "%sdrivers/%s/%s.xml", GetLocalDir(), curDrv->dname, curDrv->dname);
	robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
	if (!robhdle) {
	    sprintf(buf, "drivers/%s/%s.xml", curDrv->dname, curDrv->dname);
	    robhdle = GfParmReadFile(buf, GFPARM_RMODE_STD);
	}
	if (robhdle != NULL) {
	    sprintf(buf, "%s/%s/%d", ROB_SECT_ROBOTS, ROB_LIST_INDEX, curDrv->index);
	    GfuiLabelSetText(scrHandle, PickDrvCarLabelId, GfParmGetName(curDrv->car));
	    GfuiLabelSetText(scrHandle, PickDrvCategoryLabelId, GfParmGetStr(curDrv->car, SECT_CAR, PRM_CATEGORY, ""));
	    GfParmReleaseHandle(robhdle);
	}
    }
}
Exemple #21
0
/*
 * 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);
	}
}
Exemple #22
0
extern "C" int
human(tModInfo *modInfo)
{
	int i;
	const char *driver;
	const int BUFSIZE = 1024;
	char buf[BUFSIZE];
	char sstring[BUFSIZE];

	memset(modInfo, 0, 10*sizeof(tModInfo));

	snprintf(buf, BUFSIZE, "%sdrivers/human/human.xml", GetLocalDir());
	void *DrvInfo = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);

	if (DrvInfo != NULL) {
		for (i = 0; i < 10; i++) {
			snprintf(sstring, BUFSIZE, "Robots/index/%d", i+1);
			driver = GfParmGetStr(DrvInfo, sstring, "name", "");
			if (strlen(driver) == 0) {
				break;
			}

			modInfo->name    = strdup(driver);	/* name of the module (short) */
			modInfo->desc    = strdup("Joystick controlable driver");	/* description of the module (can be long) */
			modInfo->fctInit = InitFuncPt;	/* init function */
			modInfo->gfId    = ROB_IDENT;	/* supported framework version */
			modInfo->index   = i+1;
			modInfo++;
		}
		// Just release in case we got it.
		GfParmReleaseHandle(DrvInfo);
	}

	return 0;
}
Exemple #23
0
static int 
createBackgroundImage(void* hscr, void* hparm, const char* pszName)
{
	const char* pszImage = GfParmGetStr(hparm, pszName, GFMNU_ATTR_IMAGE, "");
	GfuiScreenAddBgImg(hscr, pszImage);
	return 1;
}
static void
rmCarSettingsMenu(void *pMenu)
{
	int nDriverIdx = NetGetNetwork()->GetDriverIdx();

	if (nDriverIdx > -1) {
		NetDriver driver;
		// char newName[64]; Never used
		char dname[256];

		// check for car change
		GfLogInfo("Car %d changed \n", nDriverIdx);

		tRmInfo* reInfo = LmRaceEngine().inData();
		reInfo->params = GfParmReadFileLocal("config/raceman/networkrace.xml",GFPARM_RMODE_REREAD);
		reInfo->_reName = GfParmGetStr(reInfo->params, RM_SECT_HEADER, RM_ATTR_NAME, "");

		sprintf(dname, "%s/%d", RM_SECT_DRIVERS, nDriverIdx);
		int idx = GfParmGetNum(reInfo->params, dname, RM_ATTR_IDX, "",0);

		// Garage menu to change clients car
		GfDriver* PCurrentDriver = GfDrivers::self()->getDriver(NETWORKROBOT, idx);

		GarageMenu.setPreviousMenuHandle(racemanMenuHdle);
		GarageMenu.runMenu(LmRaceEngine().race(), PCurrentDriver);
		bGarage = true;
	}
}
Exemple #25
0
void 
SimDifferentialConfig(GfParmHandle *hdle, char *section, tDifferential *differential)
{
    char *type;

    differential->I		= GfParmGetNum(hdle, section, PRM_INERTIA, (char*)NULL, 0.1f);
    differential->efficiency	= GfParmGetNum(hdle, section, PRM_EFFICIENCY, (char*)NULL, 1.0f);
    differential->ratio		= GfParmGetNum(hdle, section, PRM_RATIO, (char*)NULL, 1.0f);
    differential->bias		= GfParmGetNum(hdle, section, PRM_BIAS, (char*)NULL, 0.1f);
    differential->dTqMin	= GfParmGetNum(hdle, section, PRM_MIN_TQ_BIAS, (char*)NULL, 0.05f);
    differential->dTqMax	= GfParmGetNum(hdle, section, PRM_MAX_TQ_BIAS, (char*)NULL, 0.80f) - differential->dTqMin;
    differential->dSlipMax	= GfParmGetNum(hdle, section, PRM_MAX_SLIP_BIAS, (char*)NULL, 0.2f);
    differential->lockInputTq	= GfParmGetNum(hdle, section, PRM_LOCKING_TQ, (char*)NULL, 300.0f);
    differential->viscosity	= GfParmGetNum(hdle, section, PRM_VISCOSITY_FACTOR, (char*)NULL, 2.0f);
    differential->viscomax	= 1 - exp(-differential->viscosity);

    type = GfParmGetStr(hdle, section, PRM_TYPE, VAL_DIFF_NONE);
    if (strcmp(type, VAL_DIFF_LIMITED_SLIP) == 0) {
	differential->type = DIFF_LIMITED_SLIP; 
    } else if (strcmp(type, VAL_DIFF_VISCOUS_COUPLER) == 0) {
	differential->type = DIFF_VISCOUS_COUPLER;
    } else if (strcmp(type, VAL_DIFF_SPOOL) == 0) {
	differential->type = DIFF_SPOOL;
    }  else if (strcmp(type, VAL_DIFF_FREE) == 0) {
	differential->type = DIFF_FREE;
    } else {
	differential->type = DIFF_NONE; 
    }

    
    differential->feedBack.I = differential->I * differential->ratio * differential->ratio +
	(differential->inAxis[0]->I + differential->inAxis[1]->I) / differential->efficiency;
}
/* Register a race manager */
static void
reRegisterRaceman(tFList *racemanCur)
{
	sprintf(buf, "%sconfig/raceman/%s", GetLocalDir(), racemanCur->name);
	racemanCur->userData = GfParmReadFile(buf, GFPARM_RMODE_STD);
	racemanCur->dispName = GfParmGetStr(racemanCur->userData, RM_SECT_HEADER, RM_ATTR_NAME, 0);
}
// Read sound configuration.
static void readSoundCfg(void)
{
	const char *optionName;
	int	i;
	char buf[1024];

	sprintf(buf, "%s%s", GetLocalDir(), GR_SOUND_PARM_CFG);
	void *paramHandle = GfParmReadFile(buf, GFPARM_RMODE_REREAD | GFPARM_RMODE_CREAT);
	optionName = GfParmGetStr(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_STATE, soundOptionList[0]);

	for (i = 0; i < nbOptions; i++) {
		if (strcmp(optionName, soundOptionList[i]) == 0) {
			curOption = i;
			break;
		}
	}

    VolumeValue = GfParmGetNum(paramHandle, GR_SCT_SOUND, GR_ATT_SOUND_VOLUME, "%", 100.0f);
	if (VolumeValue>100.0f) {
		VolumeValue = 100.0f;
	} 
	if (VolumeValue < 0.0f) {
		VolumeValue = 0.0f;
	}

	GfParmReleaseHandle(paramHandle);

	GfuiLabelSetText(scrHandle, SoundOptionId, soundOptionList[curOption]);
}
static void
InitSides(void *TrackHandle, char *section)
{
    int side;
    
    for (side = 0; side < 2; side++) {
	sideMaterial[side]  = GfParmGetStr(TrackHandle, section, KeySideSurface[side], TRK_VAL_GRASS);
	sideEndWidth[side] = GfParmGetNum(TrackHandle, section, KeySideWidth[side], (char*)NULL, 0.0);
	/* banking of borders */
	if (strcmp(TRK_VAL_LEVEL, GfParmGetStr(TrackHandle, section, KeySideBankType[side], TRK_VAL_LEVEL)) == 0) {
	    sideBankType[side] = 0;
	} else {
	    sideBankType[side] = 1;
	}
    }
}
static void onHostPlayerReady(tCheckBoxInfo* pInfo)
{
	tRmInfo* reInfo = LmRaceEngine().inData();
	char dname[256];

	int nCars = GfParmGetEltNb(reInfo->params, RM_SECT_DRIVERS);

	NetServerMutexData *pSData = NetGetServer()->LockServerData();
	for (int i=1; i <= nCars; i++) {
		sprintf(dname, "%s/%d", RM_SECT_DRIVERS, i);

		GfLogInfo("Setting driver %d to %d\n", i, pInfo->bChecked);
		if(strcmp(NETWORKROBOT, GfParmGetStr(reInfo->params, dname, RM_ATTR_MODULE, "")) == 0) {
			// Human drive, check if local
			int index = GfParmGetNum(reInfo->params, dname, RM_ATTR_IDX, NULL, 1.0) - 1;

			GfLogInfo("Index %d\n", index);
			if (pSData->m_vecNetworkPlayers[index].client == false)
				NetGetServer()->OverrideDriverReady(i, pInfo->bChecked);
		} else {
			// Robot driver, all are local
			NetGetServer()->OverrideDriverReady(i, pInfo->bChecked);
		}

		bRobotsReady = pInfo->bChecked;
	}
	NetGetServer()->UnlockServerData();

	EnableMenuHostButtons(pInfo->bChecked);
	GfLogInfo("menu ready\n");
}
Exemple #30
0
static int 
createMusic(void* hscr, void* hparm)
{
	const char* pszMusic = GfParmGetStr(hparm, GFMNU_SECT_MUSIC, GFMNU_ATTR_MUSIC_FILE, 0);
	GfuiScreenAddMusic(hscr, pszMusic);
	return 1;
}