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 <tgfclient.h>
|
||||
|
||||
#include <robot.h>
|
||||
#include <racescreens.h>
|
||||
#include <network.h>
|
||||
|
||||
#include <racescreens.h>
|
||||
|
||||
#include "raceutil.h" // RmGetFeaturesList
|
||||
#include "racesituation.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) {
|
||||
printf( "||||++|||| NOT ENABLED!\n" );
|
||||
GfLogDebug( "||||++|||| NOT ENABLED!\n" );
|
||||
curRaceIdx = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, 1);
|
||||
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
|
||||
printf( "||||++|||| NOT LAST RACE!\n" );
|
||||
GfLogDebug( "||||++|||| NOT LAST RACE!\n" );
|
||||
curRaceIdx++;
|
||||
GfOut("Race Nb %d\n", curRaceIdx);
|
||||
GfLogTrace("Race Nb %d\n", curRaceIdx);
|
||||
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
|
||||
|
||||
return RM_SYNC | RM_NEXT_RACE;
|
||||
|
@ -503,30 +505,31 @@ ReRaceStart(void)
|
|||
void *params = ReInfo->params;
|
||||
void *results = ReInfo->results;
|
||||
|
||||
// Reallocate car info for the race.
|
||||
// Reallocate and reset car info for the race.
|
||||
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
|
||||
GfParmListClean(params, RM_SECT_DRIVERS_RACING);
|
||||
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
|
||||
i = (int)GfParmGetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_DRIVER, NULL, 1);
|
||||
if (i == 1) {
|
||||
RmLoadingScreenStart(ReInfo->_reName, "data/img/splash-raceload.jpg");
|
||||
RmLoadingScreenSetText("Preparing Starting Grid ...");
|
||||
} else {
|
||||
RmShutdownLoadingScreen();
|
||||
RmLoadingScreenShutdown();
|
||||
}
|
||||
|
||||
// Propagate competitor drivers info to the real race starting grid
|
||||
snprintf(path, sizeof(path), "%s/%d", RM_SECT_DRIVERS, i);
|
||||
snprintf(path2, sizeof(path2), "%s/%d", RM_SECT_DRIVERS_RACING, 1);
|
||||
|
||||
GfParmSetStr(params, path2, RM_ATTR_MODULE,
|
||||
GfParmGetStr(params, path, RM_ATTR_MODULE, ""));
|
||||
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);
|
||||
|
||||
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)
|
||||
if (!strcmp(gridType, RM_VAL_LAST_RACE_ORDER))
|
||||
{
|
||||
GfLogInfo("Starting %s : Starting grid in the order of the last race\n",
|
||||
ReInfo->_reName);
|
||||
GfLogTrace("Starting grid in the 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();
|
||||
if (!prevRaceName) {
|
||||
return RM_QUIT;
|
||||
}
|
||||
|
||||
for (i = 1; i < nCars + 1; i++) {
|
||||
snprintf(path, sizeof(path), "%s/%s/%s/%s/%d",
|
||||
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
|
||||
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();
|
||||
if (!prevRaceName) {
|
||||
return RM_QUIT;
|
||||
}
|
||||
|
||||
for (i = 1; i < nCars + 1; i++) {
|
||||
snprintf(path, sizeof(path), "%s/%s/%s/%s/%d",
|
||||
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
|
||||
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++) {
|
||||
snprintf(path, sizeof(path), "%s/%d", RM_SECT_DRIVERS, i);
|
||||
snprintf(path2, sizeof(path2), "%s/%d", RM_SECT_DRIVERS_RACING, i);
|
||||
|
@ -636,7 +635,7 @@ ReRaceStart(void)
|
|||
//ReTrackUpdate();
|
||||
|
||||
if (!strcmp(GfParmGetStr(params, ReInfo->_reRaceName, RM_ATTR_SPLASH_MENU, RM_VAL_NO), RM_VAL_YES)) {
|
||||
RmShutdownLoadingScreen();
|
||||
RmLoadingScreenShutdown();
|
||||
RmDisplayStartRace(ReInfo, StartRaceHookInit(), AbandonRaceHookInit());
|
||||
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);
|
||||
if (curRaceIdx < GfParmGetEltNb(params, RM_SECT_RACES)) {
|
||||
curRaceIdx++;
|
||||
GfOut("Race Nb %d\n", curRaceIdx);
|
||||
GfLogInfo("Race Nb %d\n", curRaceIdx);
|
||||
GfParmSetNum(results, RE_SECT_CURRENT, RE_ATTR_CUR_RACE, NULL, curRaceIdx);
|
||||
ReUpdateStandings();
|
||||
return RM_SYNC | RM_NEXT_RACE;
|
||||
|
|
|
@ -30,7 +30,9 @@
|
|||
|
||||
#include <portability.h>
|
||||
#include <tgfclient.h>
|
||||
|
||||
#include <racescreens.h>
|
||||
|
||||
#include <robot.h>
|
||||
|
||||
#include "racesituation.h"
|
||||
|
|
|
@ -26,10 +26,13 @@
|
|||
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#include <tgfclient.h>
|
||||
|
||||
#include <car.h>
|
||||
|
||||
#include "racescreens.h"
|
||||
|
@ -113,7 +116,7 @@ RmLoadingScreenStart(const char *title, const char *bgimg)
|
|||
}
|
||||
|
||||
void
|
||||
RmShutdownLoadingScreen(void)
|
||||
RmLoadingScreenShutdown(void)
|
||||
{
|
||||
if (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 RmLoadingScreenSetText(const char * /* text */);
|
||||
RACESCREENS_API void RmShutdownLoadingScreen(void);
|
||||
RACESCREENS_API void RmLoadingScreenShutdown(void);
|
||||
|
||||
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 RmShowStandings(void *prevHdle, tRmInfo *info);
|
||||
RACESCREENS_API void RmShowStandings(void *prevHdle, tRmInfo *info, int start = 0);
|
||||
|
||||
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 rmRaceResults(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
|
||||
|
||||
|
@ -60,7 +59,7 @@ rmSaveRes(void *vInfo)
|
|||
{
|
||||
tRmInfo *info = (tRmInfo *)vInfo;
|
||||
|
||||
GfParmWriteFile(0, info->results, (char*)"Results");
|
||||
GfParmWriteFile(0, info->results, "Results");
|
||||
|
||||
GfuiVisibilitySet(rmScrHdle, rmSaveId, GFUI_INVISIBLE);
|
||||
}
|
||||
|
@ -510,12 +509,12 @@ rmChgStandingScreen(void *vprc)
|
|||
void *prevScr = rmScrHdle;
|
||||
tRaceCall *prc = (tRaceCall*)vprc;
|
||||
|
||||
rmShowStandings(prc->prevHdle, prc->info, prc->start);
|
||||
RmShowStandings(prc->prevHdle, prc->info, prc->start);
|
||||
GfuiScreenRelease(prevScr);
|
||||
}
|
||||
|
||||
/**
|
||||
* rmShowStandings
|
||||
* RmShowStandings
|
||||
*
|
||||
* Shows a results page, with optional prev/next results page buttons
|
||||
*
|
||||
|
@ -523,8 +522,8 @@ rmChgStandingScreen(void *vprc)
|
|||
* @param info race results information
|
||||
* @param start page number
|
||||
*/
|
||||
static void
|
||||
rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
||||
void
|
||||
RmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
||||
{
|
||||
int i;
|
||||
int y;
|
||||
|
@ -627,38 +626,32 @@ rmShowStandings(void *prevHdle, tRmInfo *info, int start)
|
|||
GfuiAddKey(rmScrHdle, GFUIK_F12, "Take a Screen Shot", NULL, GfuiScreenShot, NULL);
|
||||
|
||||
GfuiScreenActivate(rmScrHdle);
|
||||
}//rmShowStandings
|
||||
}//RmShowStandings
|
||||
|
||||
|
||||
void
|
||||
RmShowResults(void *prevHdle, tRmInfo *info)
|
||||
{
|
||||
int nCars;
|
||||
char buffer[512];
|
||||
char buffer[128];
|
||||
|
||||
switch (info->s->_raceType) {
|
||||
case RM_TYPE_PRACTICE:
|
||||
snprintf( buffer, 512, "%s/%s", info->track->name, RE_SECT_DRIVERS );
|
||||
nCars = GfParmGetEltNb( info->results, buffer );
|
||||
if (nCars == 1)
|
||||
rmPracticeResults(prevHdle, info, 0);
|
||||
else
|
||||
rmQualifResults(prevHdle, info, 0);
|
||||
break;
|
||||
switch (info->s->_raceType)
|
||||
{
|
||||
case RM_TYPE_PRACTICE:
|
||||
snprintf( buffer, sizeof(buffer), "%s/%s", info->track->name, RE_SECT_DRIVERS );
|
||||
nCars = GfParmGetEltNb( info->results, buffer );
|
||||
if (nCars == 1)
|
||||
rmPracticeResults(prevHdle, info, 0);
|
||||
else
|
||||
rmQualifResults(prevHdle, info, 0);
|
||||
break;
|
||||
|
||||
case RM_TYPE_RACE:
|
||||
rmRaceResults(prevHdle, info, 0);
|
||||
break;
|
||||
|
||||
case RM_TYPE_QUALIF:
|
||||
rmQualifResults(prevHdle, info, 0);
|
||||
break;
|
||||
case RM_TYPE_RACE:
|
||||
rmRaceResults(prevHdle, info, 0);
|
||||
break;
|
||||
|
||||
case RM_TYPE_QUALIF:
|
||||
rmQualifResults(prevHdle, info, 0);
|
||||
break;
|
||||
}//switch raceType
|
||||
}//RmShowResults
|
||||
|
||||
|
||||
void
|
||||
RmShowStandings(void *prevHdle, tRmInfo *info)
|
||||
{
|
||||
rmShowStandings(prevHdle, info, 0);
|
||||
}//RmShowStandings
|
||||
|
|
Loading…
Reference in a new issue