void CGhostPlayer::loadGhostFile(const c8 *sFile) { if (m_pReplayLap!=NULL) delete m_pReplayLap; m_pReplayLap=new CGhostLaps(0); u32 iSize=0,iSteps=0; c8 sBuffer[0xFF]; CSerializer cData; printf("open %s\n",sFile); IFileSystem *pFs=m_pDevice->getFileSystem(); IReadFile *f=pFs->createAndOpenFile(path(sFile)); f->read(&iSize,sizeof(u32)); f->read(sBuffer,iSize); cData.setBuffer(sBuffer,iSize); CGhostHeader cHead(&cData); printf("\t\t--> %s\n\t\t--> %s\n\t\t--> %s\n",cHead.getPlayer(),cHead.getLevel(),cHead.getIdent()); while (f->getPos()<f->getSize()) { f->read(&iSize,sizeof(u32)); f->read(sBuffer,iSize); cData.setBuffer(sBuffer,iSize); CGhostState *pState=new CGhostState(&cData); m_pReplayLap->m_lStates.push_back(pState); iSteps++; } printf("%i steps\n",iSteps); m_it=m_pReplayLap->m_lStates.end(); f->drop(); }
bool CGhostPlayer::validateGhostFile(const c8 *sFile, c8 *sPlayer, c8 *sLevel, u32 *iSteps) { bool bRet=true; u32 iSize=0; c8 sBuffer[0xFF]; CSerializer cData; *iSteps=0; printf("open %s\n",sFile); IFileSystem *pFs=m_pDevice->getFileSystem(); IReadFile *f=pFs->createAndOpenFile(path(sFile)); f->read(&iSize,sizeof(u32)); f->read(sBuffer,iSize); cData.setBuffer(sBuffer,iSize); CGhostHeader cHead(&cData); if (!strcmp(cHead.getIdent(),"StuntMarbleRacersGhostFile")) { strcpy(sPlayer,cHead.getPlayer()); strcpy(sLevel ,cHead.getLevel ()); while (f->getPos()<f->getSize()) { f->read(&iSize,sizeof(u32)); bRet=bRet && iSize==24; f->read(sBuffer,iSize); cData.setBuffer(sBuffer,iSize); CGhostState cState(&cData); (*iSteps)++; } } f->drop(); return bRet && !strcmp(cHead.getIdent(),"StuntMarbleRacersGhostFile"); }