void MPLoadMap::seedFromFile( const char* pFileName ) { FullPathFileName path; path.init( missionPath, pFileName, ".csv" ); CSVFile file; if ( NO_ERR != file.open( path ) ) { Assert( 0, 0, "couldn't open multiplayer mission .csv file" ); return; } int i = 1; char fileName[255]; while( true ) { if ( NO_ERR != file.readString( i, 1, fileName, 255 ) ) break; path.init( missionPath, fileName, ".fit" ); if ( fileExists( path ) ) { addFile( fileName, false ); } i++; } }
//--------------------------------------------------------------------------------- void WeaponEffects::init (char *effectCSVFileName) { FullPathFileName effectsName; effectsName.init(objectPath,effectCSVFileName,".csv"); CSVFile effectFile; long result = effectFile.open(effectsName); if (result != NO_ERR) STOP(("Unable to open Effects File %s",effectsName)); numEffects = effectFile.getNumLines() - 1; //Always subtract one for the column headers effects = (EffectData *)systemHeap->Malloc(sizeof(EffectData) * numEffects); gosASSERT(effects != NULL); for (long i=0;i<numEffects;i++) { effectFile.readString(i+2,2,effects[i].effectName,49); effectFile.readString(i+2,3,effects[i].muzzleFlashName,49); effectFile.readString(i+2,4,effects[i].hitEffectName,49); effectFile.readString(i+2,6,effects[i].missEffectName,49); effectFile.readLong(i+2,5,effects[i].effectObjNum); } }
void Pilot::initPilots() { CSVFile file; char path[256]; strcpy( path, objectPath ); strcat( path, "pilots.csv" ); if ( NO_ERR != file.open( path ) ) { STOP(( "couldn't find pilots.csv file" )); return; } char pilotFileName[256]; strcpy(pilotFileName, ""); PilotInfo* infos = s_GoodPilots; long* counter = &goodCount; for ( int i = 0; i < 2; i++ ) { while( true ) { int bytesRead = file.readLine( (BYTE*)pilotFileName, 256 ); if ( bytesRead < 2 ) break; CString postFix; if (0 == i) { if ((strlen(pilotFileName) > strlen("pmw")) && (0 == strnicmp(pilotFileName, "pmw", strlen("pmw")))) { /*Good pilots that start with "pmw" are single-player pilots.*/ CString tmpStr; tmpStr.LoadString(IDS_PILOT_SINGLE_PLAYER_VERSION); postFix = tmpStr.GetBuffer(0); } else if ((strlen(pilotFileName) > strlen("pmp_")) && (0 == strnicmp(pilotFileName, "pmp_", strlen("pmp_")))) { /*Good pilots that start with "pmp_" are multi-player pilots.*/ CString tmpStr; tmpStr.LoadString(IDS_PILOT_MULTIPLAYER_VERSION); postFix = tmpStr.GetBuffer(0); } } FitIniFile pilotFile; FullPathFileName tmpPath; tmpPath.init(warriorPath,pilotFileName,".fit"); if ( NO_ERR != pilotFile.open( tmpPath ) ) { char errorString[256]; sprintf( errorString, "Couldn't open file %s", tmpPath); Assert( 0, 0, errorString ); return; } infos[*counter].fileName = new char[strlen( pilotFileName ) + 1]; strcpy( infos[*counter].fileName, pilotFileName ); // if we got this far we have a file, make a pilot int result = pilotFile.seekBlock( "General" ); gosASSERT( result == 0 ); long tmp; result = pilotFile.readIdLong( "descIndex", tmp ); gosASSERT( result == NO_ERR ); cLoadString( tmp, pilotFileName, 64); strcat(pilotFileName, " "); strncat(pilotFileName, postFix.GetBuffer(0), 64); infos[*counter].name = new char[strlen( pilotFileName ) +1]; strcpy( infos[*counter].name, pilotFileName ); (*counter)++; if ( goodCount > MAX_PILOT ) return; } file.close(); FullPathFileName path; path.init(objectPath,"BadPilots",".csv"); if ( NO_ERR != file.open( path ) ) { STOP(( "couldn't find BadPilots.csv file" )); return; } infos = s_BadPilots; counter = &badCount; } }