Re #307 (code cleanup) merged RmShowStandings and rmShowStandings + renamed RmShutdownLoadingScreen to RmLoadingScreenShutdown + improved ReRaceStart traces
git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@3346 30fe4595-0a0c-4342-8851-515496e4dcbd Former-commit-id: 385254c3e585723c7b322b4ce93b5045d237e4bb Former-commit-id: 8c698cc8e96e6f81b44779646119ed195baf3b58
This commit is contained in:
parent
8189054fbe
commit
543a1cf6db
5 changed files with 57 additions and 60 deletions
|
@ -24,10 +24,12 @@
|
||||||
*/
|
*/
|
||||||
#include <portability.h>
|
#include <portability.h>
|
||||||
#include <tgfclient.h>
|
#include <tgfclient.h>
|
||||||
|
|
||||||
#include <robot.h>
|
#include <robot.h>
|
||||||
#include <racescreens.h>
|
|
||||||
#include <network.h>
|
#include <network.h>
|
||||||
|
|
||||||
|
#include <racescreens.h>
|
||||||
|
|
||||||
#include "raceutil.h" // RmGetFeaturesList
|
#include "raceutil.h" // RmGetFeaturesList
|
||||||
#include "racesituation.h"
|
#include "racesituation.h"
|
||||||
#include "racecareer.h"
|
#include "racecareer.h"
|
||||||
|
@ -233,12 +235,12 @@ RePreRace(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(GfParmGetStr(params, raceName, RM_ATTR_ENABLED, RM_VAL_YES), RM_VAL_NO) == 0) {
|
if (strcmp(GfParmGetStr(params, raceName, RM_ATTR_ENABLED, RM_VAL_YES), RM_VAL_NO) == 0) {
|
||||||
printf( "||||++|||| NOT ENABLED!\n" );
|
GfLogDebug( "||||++|||| NOT ENABLED!\n" );
|
||||||
curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
|
curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
|
||||||
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
|
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
|
||||||
printf( "||||++|||| NOT LAST RACE!\n" );
|
GfLogDebug( "||||++|||| NOT LAST RACE!\n" );
|
||||||
curRaceIdx++;
|
curRaceIdx++;
|
||||||
GfOut("Race Nb %d\n", curRaceIdx);
|
GfLogTrace("Race Nb %d\n", curRaceIdx);
|
||||||
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
|
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
|
||||||
|
|
||||||
return RM_SYNC | RM_NEXT_RACE;
|
return RM_SYNC | RM_NEXT_RACE;
|
||||||
|
@ -503,30 +505,31 @@ ReRaceStart(void)
|
||||||
void *params = ReInfo->params;
|
void *params = ReInfo->params;
|
||||||
void *results = ReInfo->results;
|
void *results = ReInfo->results;
|
||||||
|
|
||||||
// Reallocate car info for the race.
|
// Reallocate and reset car info for the race.
|
||||||
FREEZ(ReInfo->_reCarInfo);
|
FREEZ(ReInfo->_reCarInfo);
|
||||||
ReInfo->_reCarInfo = (tReCarInfo*)calloc(GfParmGetEltNb(params, RM_SECT_DRIVERS), sizeof(tReCarInfo));
|
ReInfo->_reCarInfo =
|
||||||
|
(tReCarInfo*)calloc(GfParmGetEltNb(params, RM_SECT_DRIVERS), sizeof(tReCarInfo));
|
||||||
|
|
||||||
|
GfLogInfo("Starting %s %s session on %s\n", ReInfo->_reName, raceName, ReInfo->track->name);
|
||||||
|
|
||||||
// Drivers starting order
|
// Drivers starting order
|
||||||
GfParmListClean(params, RM_SECT_DRIVERS_RACING);
|
GfParmListClean(params, RM_SECT_DRIVERS_RACING);
|
||||||
if ((ReInfo->s->_raceType == RM_TYPE_QUALIF || ReInfo->s->_raceType == RM_TYPE_PRACTICE)
|
if ((ReInfo->s->_raceType == RM_TYPE_QUALIF || ReInfo->s->_raceType == RM_TYPE_PRACTICE)
|
||||||
&& ReInfo->s->_totTime < 0.0f)
|
&& ReInfo->s->_totTime < 0.0f) // <= What's this time test for ?
|
||||||
{
|
{
|
||||||
GfLogInfo("Starting %s %s session\n",
|
|
||||||
ReInfo->_reName, ReInfo->s->_raceType == RM_TYPE_PRACTICE ? "practice" : "qualification");
|
|
||||||
|
|
||||||
// Race loading screen
|
// Race loading screen
|
||||||
i = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_DRIVER, NULL, 1);
|
i = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_DRIVER, NULL, 1);
|
||||||
if (i == 1) {
|
if (i == 1) {
|
||||||
RmLoadingScreenStart(ReInfo->_reName, "data/img/splash-raceload.jpg");
|
RmLoadingScreenStart(ReInfo->_reName, "data/img/splash-raceload.jpg");
|
||||||
RmLoadingScreenSetText("Preparing Starting Grid ...");
|
RmLoadingScreenSetText("Preparing Starting Grid ...");
|
||||||
} else {
|
} else {
|
||||||
RmShutdownLoadingScreen();
|
RmLoadingScreenShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Propagate competitor drivers info to the real race starting grid
|
// Propagate competitor drivers info to the real race starting grid
|
||||||
snprintf(path, sizeof(path), "%s/%d", RM_SECT_DRIVERS, i);
|
snprintf(path, sizeof(path), "%s/%d", RM_SECT_DRIVERS, i);
|
||||||
snprintf(path2, sizeof(path2), "%s/%d", RM_SECT_DRIVERS_RACING, 1);
|
snprintf(path2, sizeof(path2), "%s/%d", RM_SECT_DRIVERS_RACING, 1);
|
||||||
|
|
||||||
GfParmSetStr(params, path2, RM_ATTR_MODULE,
|
GfParmSetStr(params, path2, RM_ATTR_MODULE,
|
||||||
GfParmGetStr(params, path, RM_ATTR_MODULE, ""));
|
GfParmGetStr(params, path, RM_ATTR_MODULE, ""));
|
||||||
GfParmSetNum(params, path2, RM_ATTR_IDX, NULL,
|
GfParmSetNum(params, path2, RM_ATTR_IDX, NULL,
|
||||||
|
@ -546,19 +549,20 @@ ReRaceStart(void)
|
||||||
|
|
||||||
gridType = GfParmGetStr(params, raceName, RM_ATTR_START_ORDER, RM_VAL_DRV_LIST_ORDER);
|
gridType = GfParmGetStr(params, raceName, RM_ATTR_START_ORDER, RM_VAL_DRV_LIST_ORDER);
|
||||||
|
|
||||||
|
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
||||||
|
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
||||||
|
nCars = MIN(nCars, maxCars);
|
||||||
|
|
||||||
// Starting grid in the arrival order of the previous race (or qualification session)
|
// Starting grid in the arrival order of the previous race (or qualification session)
|
||||||
if (!strcmp(gridType, RM_VAL_LAST_RACE_ORDER))
|
if (!strcmp(gridType, RM_VAL_LAST_RACE_ORDER))
|
||||||
{
|
{
|
||||||
GfLogInfo("Starting %s : Starting grid in the order of the last race\n",
|
GfLogTrace("Starting grid in the order of the last race\n");
|
||||||
ReInfo->_reName);
|
|
||||||
|
|
||||||
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
|
||||||
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
|
||||||
nCars = MIN(nCars, maxCars);
|
|
||||||
prevRaceName = ReGetPrevRaceName();
|
prevRaceName = ReGetPrevRaceName();
|
||||||
if (!prevRaceName) {
|
if (!prevRaceName) {
|
||||||
return RM_QUIT;
|
return RM_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < nCars + 1; i++) {
|
for (i = 1; i < nCars + 1; i++) {
|
||||||
snprintf(path, sizeof(path), "%s/%s/%s/%s/%d",
|
snprintf(path, sizeof(path), "%s/%s/%s/%s/%d",
|
||||||
ReInfo->track->name, RE_SECT_RESULTS, prevRaceName, RE_SECT_RANK, i);
|
ReInfo->track->name, RE_SECT_RESULTS, prevRaceName, RE_SECT_RANK, i);
|
||||||
|
@ -580,15 +584,13 @@ ReRaceStart(void)
|
||||||
// Starting grid in the reversed arrival order of the previous race
|
// Starting grid in the reversed arrival order of the previous race
|
||||||
else if (!strcmp(gridType, RM_VAL_LAST_RACE_RORDER))
|
else if (!strcmp(gridType, RM_VAL_LAST_RACE_RORDER))
|
||||||
{
|
{
|
||||||
GfLogInfo("Starting %s : Starting grid in the reverse order of the last race\n", ReInfo->_reName);
|
GfLogTrace("Starting grid in the reverse order of the last race\n");
|
||||||
|
|
||||||
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
|
||||||
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
|
||||||
nCars = MIN(nCars, maxCars);
|
|
||||||
prevRaceName = ReGetPrevRaceName();
|
prevRaceName = ReGetPrevRaceName();
|
||||||
if (!prevRaceName) {
|
if (!prevRaceName) {
|
||||||
return RM_QUIT;
|
return RM_QUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 1; i < nCars + 1; i++) {
|
for (i = 1; i < nCars + 1; i++) {
|
||||||
snprintf(path, sizeof(path), "%s/%s/%s/%s/%d",
|
snprintf(path, sizeof(path), "%s/%s/%s/%s/%d",
|
||||||
ReInfo->track->name, RE_SECT_RESULTS, prevRaceName, RE_SECT_RANK, nCars - i + 1);
|
ReInfo->track->name, RE_SECT_RESULTS, prevRaceName, RE_SECT_RANK, nCars - i + 1);
|
||||||
|
@ -610,11 +612,8 @@ ReRaceStart(void)
|
||||||
// Starting grid in the drivers list order
|
// Starting grid in the drivers list order
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GfLogInfo("Starting %s : Starting grid in the order of the driver list\n", ReInfo->_reName);
|
GfLogTrace("Starting grid in the order of the driver list\n");
|
||||||
|
|
||||||
nCars = GfParmGetEltNb(params, RM_SECT_DRIVERS);
|
|
||||||
maxCars = (int)GfParmGetNum(params, raceName, RM_ATTR_MAX_DRV, NULL, 100);
|
|
||||||
nCars = MIN(nCars, maxCars);
|
|
||||||
for (i = 1; i < nCars + 1; i++) {
|
for (i = 1; i < nCars + 1; i++) {
|
||||||
snprintf(path, sizeof(path), "%s/%d", RM_SECT_DRIVERS, i);
|
snprintf(path, sizeof(path), "%s/%d", RM_SECT_DRIVERS, i);
|
||||||
snprintf(path2, sizeof(path2), "%s/%d", RM_SECT_DRIVERS_RACING, i);
|
snprintf(path2, sizeof(path2), "%s/%d", RM_SECT_DRIVERS_RACING, i);
|
||||||
|
@ -636,7 +635,7 @@ ReRaceStart(void)
|
||||||
//ReTrackUpdate();
|
//ReTrackUpdate();
|
||||||
|
|
||||||
if (!strcmp(GfParmGetStr(params, ReInfo->_reRaceName, RM_ATTR_SPLASH_MENU, RM_VAL_NO), RM_VAL_YES)) {
|
if (!strcmp(GfParmGetStr(params, ReInfo->_reRaceName, RM_ATTR_SPLASH_MENU, RM_VAL_NO), RM_VAL_YES)) {
|
||||||
RmShutdownLoadingScreen();
|
RmLoadingScreenShutdown();
|
||||||
RmDisplayStartRace(ReInfo, StartRaceHookInit(), AbandonRaceHookInit());
|
RmDisplayStartRace(ReInfo, StartRaceHookInit(), AbandonRaceHookInit());
|
||||||
return RM_ASYNC | RM_NEXT_STEP;
|
return RM_ASYNC | RM_NEXT_STEP;
|
||||||
}
|
}
|
||||||
|
@ -820,7 +819,7 @@ RePostRace(void)
|
||||||
curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
|
curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
|
||||||
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
|
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
|
||||||
curRaceIdx++;
|
curRaceIdx++;
|
||||||
GfOut("Race Nb %d\n", curRaceIdx);
|
GfLogInfo("Race Nb %d\n", curRaceIdx);
|
||||||
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
|
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
|
||||||
ReUpdateStandings();
|
ReUpdateStandings();
|
||||||
return RM_SYNC | RM_NEXT_RACE;
|
return RM_SYNC | RM_NEXT_RACE;
|
||||||
|
|
|
@ -30,7 +30,9 @@
|
||||||
|
|
||||||
#include <portability.h>
|
#include <portability.h>
|
||||||
#include <tgfclient.h>
|
#include <tgfclient.h>
|
||||||
|
|
||||||
#include <racescreens.h>
|
#include <racescreens.h>
|
||||||
|
|
||||||
#include <robot.h>
|
#include <robot.h>
|
||||||
|
|
||||||
#include "racesituation.h"
|
#include "racesituation.h"
|
||||||
|
|
|
@ -26,10 +26,13 @@
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <tgfclient.h>
|
#include <tgfclient.h>
|
||||||
|
|
||||||
#include <car.h>
|
#include <car.h>
|
||||||
|
|
||||||
#include "racescreens.h"
|
#include "racescreens.h"
|
||||||
|
@ -113,7 +116,7 @@ RmLoadingScreenStart(const char *title, const char *bgimg)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
RmShutdownLoadingScreen(void)
|
RmLoadingScreenShutdown(void)
|
||||||
{
|
{
|
||||||
if (MenuHandle) {
|
if (MenuHandle) {
|
||||||
GfuiScreenRelease(MenuHandle);
|
GfuiScreenRelease(MenuHandle);
|
||||||
|
|
|
@ -94,7 +94,7 @@ RACESCREENS_API void RmPitMenuStart(tCarElt * /* car */, tfuiCallback /* callbac
|
||||||
|
|
||||||
RACESCREENS_API void RmLoadingScreenStart(const char * /* text */, const char * /* bgimg */);
|
RACESCREENS_API void RmLoadingScreenStart(const char * /* text */, const char * /* bgimg */);
|
||||||
RACESCREENS_API void RmLoadingScreenSetText(const char * /* text */);
|
RACESCREENS_API void RmLoadingScreenSetText(const char * /* text */);
|
||||||
RACESCREENS_API void RmShutdownLoadingScreen(void);
|
RACESCREENS_API void RmLoadingScreenShutdown(void);
|
||||||
|
|
||||||
RACESCREENS_API void RmShowResults(void * /* prevHdle */, tRmInfo * /* info */);
|
RACESCREENS_API void RmShowResults(void * /* prevHdle */, tRmInfo * /* info */);
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ RACESCREENS_API void RmDisplayStartRace(tRmInfo *info, void *startScr, void *abo
|
||||||
|
|
||||||
RACESCREENS_API void RmRaceParamsMenu(void *vrp);
|
RACESCREENS_API void RmRaceParamsMenu(void *vrp);
|
||||||
|
|
||||||
RACESCREENS_API void RmShowStandings(void *prevHdle, tRmInfo *info);
|
RACESCREENS_API void RmShowStandings(void *prevHdle, tRmInfo *info, int start = 0);
|
||||||
|
|
||||||
RACESCREENS_API void* RmFileSelect(void *vs);
|
RACESCREENS_API void* RmFileSelect(void *vs);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ static void *rmScrHdle = NULL;
|
||||||
static void rmPracticeResults(void *prevHdle, tRmInfo *info, int start);
|
static void rmPracticeResults(void *prevHdle, tRmInfo *info, int start);
|
||||||
static void rmRaceResults(void *prevHdle, tRmInfo *info, int start);
|
static void rmRaceResults(void *prevHdle, tRmInfo *info, int start);
|
||||||
static void rmQualifResults(void *prevHdle, tRmInfo *info, int start);
|
static void rmQualifResults(void *prevHdle, tRmInfo *info, int start);
|
||||||
static void rmShowStandings(void *prevHdle, tRmInfo *info, int start);
|
|
||||||
|
|
||||||
#define MAX_LINES 20 //Max number of result lines ona screen
|
#define MAX_LINES 20 //Max number of result lines ona screen
|
||||||
|
|
||||||
|
@ -60,7 +59,7 @@ rmSaveRes(void *vInfo)
|
||||||
{
|
{
|
||||||
tRmInfo *info = (tRmInfo *)vInfo;
|
tRmInfo *info = (tRmInfo *)vInfo;
|
||||||
|
|
||||||
GfParmWriteFile(0, info->results, (char*)"Results");
|
GfParmWriteFile(0, info->results, "Results");
|
||||||
|
|
||||||
GfuiVisibilitySet(rmScrHdle, rmSaveId, GFUI_INVISIBLE);
|
GfuiVisibilitySet(rmScrHdle, rmSaveId, GFUI_INVISIBLE);
|
||||||
}
|
}
|
||||||
|
@ -510,12 +509,12 @@ rmChgStandingScreen(void *vprc)
|
||||||
void *prevScr = rmScrHdle;
|
void *prevScr = rmScrHdle;
|
||||||
tRaceCall *prc = (tRaceCall*)vprc;
|
tRaceCall *prc = (tRaceCall*)vprc;
|
||||||
|
|
||||||
rmShowStandings(prc->prevHdle, prc->info, prc->start);
|
RmShowStandings(prc->prevHdle, prc->info, prc->start);
|
||||||
GfuiScreenRelease(prevScr);
|
GfuiScreenRelease(prevScr);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* rmShowStandings
|
* RmShowStandings
|
||||||
*
|
*
|
||||||
* Shows a results page, with optional prev/next results page buttons
|
* Shows a results page, with optional prev/next results page buttons
|
||||||
*
|
*
|
||||||
|
@ -523,8 +522,8 @@ rmChgStandingScreen(void *vprc)
|
||||||
* @param info race results information
|
* @param info race results information
|
||||||
* @param start page number
|
* @param start page number
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
RmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int y;
|
int y;
|
||||||
|
@ -627,38 +626,32 @@ rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
||||||
GfuiAddKey(rmScrHdle, GFUIK_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
|
GfuiAddKey(rmScrHdle, GFUIK_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
|
||||||
|
|
||||||
GfuiScreenActivate(rmScrHdle);
|
GfuiScreenActivate(rmScrHdle);
|
||||||
}//rmShowStandings
|
}//RmShowStandings
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
RmShowResults(void *prevHdle, tRmInfo *info)
|
RmShowResults(void *prevHdle, tRmInfo *info)
|
||||||
{
|
{
|
||||||
int nCars;
|
int nCars;
|
||||||
char buffer[512];
|
char buffer[128];
|
||||||
|
|
||||||
switch (info->s->_raceType) {
|
switch (info->s->_raceType)
|
||||||
case RM_TYPE_PRACTICE:
|
{
|
||||||
snprintf( buffer, 512, "%s/%s", info->track->name, RE_SECT_DRIVERS );
|
case RM_TYPE_PRACTICE:
|
||||||
nCars = GfParmGetEltNb( info->results, buffer );
|
snprintf( buffer, sizeof(buffer), "%s/%s", info->track->name, RE_SECT_DRIVERS );
|
||||||
if (nCars == 1)
|
nCars = GfParmGetEltNb( info->results, buffer );
|
||||||
rmPracticeResults(prevHdle, info, 0);
|
if (nCars == 1)
|
||||||
else
|
rmPracticeResults(prevHdle, info, 0);
|
||||||
rmQualifResults(prevHdle, info, 0);
|
else
|
||||||
break;
|
rmQualifResults(prevHdle, info, 0);
|
||||||
|
break;
|
||||||
|
|
||||||
case RM_TYPE_RACE:
|
case RM_TYPE_RACE:
|
||||||
rmRaceResults(prevHdle, info, 0);
|
rmRaceResults(prevHdle, info, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RM_TYPE_QUALIF:
|
case RM_TYPE_QUALIF:
|
||||||
rmQualifResults(prevHdle, info, 0);
|
rmQualifResults(prevHdle, info, 0);
|
||||||
break;
|
break;
|
||||||
}//switch raceType
|
}//switch raceType
|
||||||
}//RmShowResults
|
}//RmShowResults
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
RmShowStandings(void *prevHdle, tRmInfo *info)
|
|
||||||
{
|
|
||||||
rmShowStandings(prevHdle, info, 0);
|
|
||||||
}//RmShowStandings
|
|
||||||
|
|
Loading…
Reference in a new issue