Redline/source/config.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

#include "fileio.h"
#include "config.h"
#include "gamemem.h"
#include "parser.h"
#include "gameinitexit.h"
#include "carselection.h"
#include "screen.h"
#include <string.h>
tSysConfig *gConfig;
void ConfigInit()
{
gConfig=(tSysConfig*)FileGetParsedDataPtr(FileGetReference(kConfigFileName),kParserTypeConfigDesc,sizeof(tSysConfig));
if(strlen(gConfig->playerName)==0)
CFStringGetCString(CSCopyUserName(false),gConfig->playerName,256,0);
if(strlen(gConfig->gameName)==0)
CFStringGetCString(CSCopyMachineName(),gConfig->gameName,256,0);
if(strlen(gConfig->playerName)>=kMaxNameLength)
gConfig->playerName[kMaxNameLength-1]='\0';
if((gConfig->dbIndex^gConfig->challengeData)!=0xdeadbeef)
{
gConfig->dbIndex=0xdeadbeef;
gConfig->challengeData=0;
}
int availableCars[kMaxCars];
int carCount;
GetAvailableCars(availableCars,&carCount,false,false);
for(int i=0;i<11;i++)
{
int ok=false;
for(int j=0;j<carCount;j++)
if(availableCars[j]==gConfig->opponentCars[i])
ok=true;
if(!ok)
gConfig->opponentCars[i]=availableCars[0];
}
if(ScreenNoWindow())
gConfig->fullscreen=true;
}