BOOL KTrackList::Load() { BOOL bResult = false; int nRetCode = 0; ITabFile* piTabFile = NULL; int nTabHeight = 0; char szFileName[MAX_PATH]; snprintf(szFileName, sizeof(szFileName), "%s/%s/track.tab", SETTING_DIR, TRACK_DIR); szFileName[sizeof(szFileName) - 1] = '\0'; piTabFile = g_OpenTabFile(szFileName); KGLOG_PROCESS_ERROR(piTabFile); nTabHeight = piTabFile->GetHeight(); KGLOG_PROCESS_ERROR(nTabHeight >= 2); for (int nLine = 2; nLine <= nTabHeight; nLine++) { DWORD dwID = 0; KTRACK* pTrack = NULL; KTRACK_INFO TrackInfo; pair<KTRACK_TABLE::iterator, bool> IntResult; nRetCode = piTabFile->GetInteger(nLine, COL_ID, 0, (int*)&dwID); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = piTabFile->GetInteger(nLine, COL_MAP, 0, (int*)&TrackInfo.dwMapID); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = piTabFile->GetString(nLine, COL_DESC, "?", TrackInfo.szDesc, sizeof(TrackInfo.szDesc)); KGLOG_PROCESS_ERROR(nRetCode); IntResult = m_TrackTable.insert(KTRACK_TABLE::value_type(dwID, TrackInfo)); KGLOG_PROCESS_ERROR(IntResult.second); pTrack = &IntResult.first->second.Track; nRetCode = LoadTrack(dwID, pTrack); KGLOG_PROCESS_ERROR(nRetCode); nRetCode = CalculateCriticalFrame(pTrack); KGLOG_PROCESS_ERROR(nRetCode); } bResult = true; Exit0: if (!bResult) { m_TrackTable.clear(); } KG_COM_RELEASE(piTabFile); return bResult; }
void _LOAD( astr A_S, astr B_S, astr NAPI_S, aint TRYB) { // Procedure _LOAD[A$,B$,NAPI$,TRYB] // If Exist(A$) // Goto ODCZYT // Else // A$=B$ // REQUEST[A$,NAPI$] // End If if( Exists(A_S) ) { goto ODCZYT; } else { A_S = B_S; //requesta nie robimy } ODCZYT: // ODCZYT: // On Error Proc BLAD // If TRYB=0 : Load A$ : End If // If TRYB=1 : Load A$,1 : End If // If TRYB=2 : Load Iff A$ : End If // If TRYB=3 : Load Iff A$,0 : End If // If TRYB=4 : Load Iff A$,1 : End If // If TRYB=5 : Load Iff A$,2 : End If // If TRYB=6 : Track Load A$,3 : End If // If TRYB=7 : Load A$,3 : End If // If TRYB=8 : Load A$,4 : End If // If TRYB=9 : Load A$,5 : End If // int ret; switch( TRYB ) { case 0: ret = LoadAbkSp(A_S,-1); break; case 1: ret = LoadAbkSp(A_S,1); break; case 2: ret = LoadIff(A_S,-1); break; case 3: ret = LoadIff(A_S,0); break; case 4: ret = LoadIff(A_S,1); break; case 5: ret = LoadIff(A_S,2); break; case 6: ret = LoadTrack(A_S,3); break; case 7: ret = LoadAbkMus(A_S,3); break; case 8: ret = LoadAbkSnd(A_S,4); break; case 9: ret = LoadAbkSnd(A_S,5); break; default: ret=-1; } if( ret < 0 ) { ERROR("B³¹d ³adowania pliku danych: " + A_S + ": " + toString(ret)); BLAD(); } else { INFO("Pomyœlnie za³adowano plik danych: " + A_S); } // End Proc }
// allocate and decode track int CDiskImage::AllocTrack(PDISKTRACKINFO pti, UDWORD flag) { // cancel if bad track if (!pti) return imgeGeneric; // track type support switch (pti->type) { // load known formats case dtitCapsDump: case dtitCapsImage: return LoadTrack(pti, flag); // plain format is generic case dtitPlain: return LoadPlain(pti); // any other state is undefined default: return imgeGeneric; } }
void MIDI::Load( const IDataStream& Stream ) { m_Tracks.Clear(); Stream.Read( 14, &m_Header ); // sizeof( SMIDIFileHeader ) is rounded to word size, so we can't use that Endian::SwapInPlace( m_Header.m_Header.m_ChunkID ); Endian::SwapInPlace( m_Header.m_Header.m_ChunkSize ); Endian::SwapInPlace( m_Header.m_FormatType ); Endian::SwapInPlace( m_Header.m_NumTracks ); Endian::SwapInPlace( m_Header.m_TimeDivision ); ASSERT( m_Header.m_Header.m_ChunkID == 'MThd' ); ASSERT( m_Header.m_Header.m_ChunkSize == 6 ); ASSERT( m_Header.m_FormatType <= 2 ); for( uint TrackIndex = 0; TrackIndex < m_Header.m_NumTracks; ++TrackIndex ) { //PRINTF( "======== Loading track %d ========\n", TrackIndex ); m_Tracks.PushBack( SMIDITrack() ); LoadTrack( Stream, m_Tracks[ TrackIndex ] ); } }
void SDScenery::LoadScene(tTrack *track) { void *hndl = grTrackHandle; const char *acname; char buf[256]; GfOut("Initialisation class SDScenery\n"); m_background = new SDBackground; //m_pit = new SDPit; _scenery = new osg::Group; SDTrack = track; // Load graphics options. LoadGraphicsOptions(); if(grHandle == NULL) { snprintf(buf, 256, "%s%s", GetLocalDir(), GR_PARAM_FILE); grHandle = GfParmReadFile(buf, GFPARM_RMODE_STD | GFPARM_RMODE_REREAD); }//if grHandle /* Determine the world limits */ grWrldX = (int)(SDTrack->max.x - SDTrack->min.x + 1); grWrldY = (int)(SDTrack->max.y - SDTrack->min.y + 1); grWrldZ = (int)(SDTrack->max.z - SDTrack->min.z + 1); grWrldMaxSize = (int)(MAX(MAX(grWrldX, grWrldY), grWrldZ)); if (strcmp(SDTrack->category, "speedway") == 0) { _speedWay = true; if (strcmp(SDTrack->subcategory, "long") == 0) _speedWayLong = true; else _speedWayLong = false; } else _speedWay = false; GfOut("SpeedWay = %d - SubCategorie = %d\n", _speedWay, _speedWayLong); acname = GfParmGetStr(hndl, TRK_SECT_GRAPH, TRK_ATT_3DDESC, "track.ac"); GfOut("ACname = %s\n", acname); if (strlen(acname) == 0) { GfLogError("No specified track 3D model file\n"); } std::string PathTmp = GetDataDir(); _bgsky = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKY, GR_ATT_BGSKY_DISABLED), GR_ATT_BGSKY_ENABLED) == 0; if (_bgsky) { _bgtype = strcmp(GfParmGetStr(grHandle, GR_SCT_GRAPHIC, GR_ATT_BGSKYTYPE, GR_ATT_BGSKY_RING), GR_ATT_BGSKY_LAND) == 0; std::string strPath = PathTmp; snprintf(buf, 256, "tracks/%s/%s/", SDTrack->category, SDTrack->internalname); strPath += buf; m_background->build(_bgtype, grWrldX, grWrldY, grWrldZ, strPath); GfOut("Background loaded\n"); } std::string strPath = GetDataDir(); snprintf(buf, 256, "tracks/%s/%s/", SDTrack->category, SDTrack->internalname); std::string ext = osgDB::getFileExtension(acname); if (ext == "acc") { GfOut("Load 3D Model Scene ACC\n"); strPath+=buf; _strTexturePath = strPath; strPath+=acname; LoadTrack(strPath); } else { strPath+=buf; std::string strTPath = GetDataDir(); snprintf(buf, 256, "data/textures/"); strTPath += buf; osgDB::FilePathList pathList = osgDB::Registry::instance()->getDataFilePathList(); pathList.push_back(strPath); pathList.push_back(strTPath+"data/objects/"); pathList.push_back(strTPath+"data/textures/"); osgDB::Registry::instance()->setDataFilePathList(pathList); osg::ref_ptr<osg::Node> pTrack = osgDB::readNodeFile(acname); if (ext =="ac") { osg::ref_ptr<osg::MatrixTransform> rot = new osg::MatrixTransform; osg::Matrix mat( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); rot->setMatrix(mat); rot->addChild(pTrack); _scenery->addChild(rot.get()); } else { _scenery->addChild(pTrack.get()); } } osgDB::Registry::instance()->clearObjectCache(); }