//--------------------------------------------------------------------- void CameraMatrixFile::loadImpl() { CameraMatrixFileSerializer serializer; Ogre::DataStreamPtr stream( openResource() ); serializer.importCameraMatrixFile( stream, this ); }
//------------------------------------------------------------------------- void AFile::loadImpl() { AFileSerializer serializer; Ogre::DataStreamPtr stream( openResource() ); serializer.importAFile( stream, this ); }
int loadResource(const char *fileName, short int arg_4, unsigned char** ptr) { FILE* resourceFile; int headerSize; int offToData; int dataSize; int compressedSize; short int mode; unsigned char *temp; resourceFile=openResource(fileName); if(!resourceFile) return (-1); readResource(resourceFile,(char*)&headerSize,4); if(arg_4>=headerSize/4) { closeResource(resourceFile); return (-1); } fseek(resourceFile,arg_4*4,SEEK_SET); readResource(resourceFile,(char*)&offToData,4); fseek(resourceFile,offToData,SEEK_SET); readResource(resourceFile,(char*)&dataSize,4); readResource(resourceFile,(char*)&compressedSize,4); readResource(resourceFile,(char*)&mode,2); *ptr=(unsigned char*)malloc(dataSize); if(!(*ptr)) return (-1); if(mode<=0) // uncompressed { readResource(resourceFile,(char*)*ptr,dataSize); } else // compressed: both modes (1 & 2) { temp=(unsigned char*)malloc(compressedSize); readResource(resourceFile,(char*)temp,compressedSize); decompResource(dataSize,*ptr,temp,(unsigned char)mode); free(temp); } closeResource(resourceFile); return dataSize; }
void ArchiveReader::dump(uint resIndex) { int32 resourceSize = getResourceSize(resIndex); byte *data = new byte[resourceSize]; Common::String fn = Common::String::format("toltecs_res.%03d", resIndex); openResource(resIndex); read(data, resourceSize); closeResource(); Common::DumpFile o; o.open(fn); o.write(data, resourceSize); o.finalize(); o.close(); delete[] data; }
//-------------------------------------------------------------------------- void FLevelFile::loadImpl() { FLevelFileSerializer serializer; Ogre::DataStreamPtr stream( openResource() ); serializer.importFLevelFile( stream, this ); String background_texture_name( getBackgroundTextureName() ); if( m_background_texture_loader == NULL ) { m_background_texture_loader = new FLevelTextureLoader( *this ); m_background_texture = Ogre::TextureManager::getSingleton().create( background_texture_name, mGroup, true, m_background_texture_loader ); } String background_2d_name( getBackground2DName() ); if( m_background_2d_loader == NULL ) { m_background_2d_loader = new FLevelBackground2DLoader( *this ); m_background_2d = Background2DFileManager::getSingleton().create( background_2d_name, mGroup, true, m_background_2d_loader ); } }
void ArchiveReader::dump(uint resIndex, const char *prefix) { int32 resourceSize = getResourceSize(resIndex); byte *data = new byte[resourceSize]; Common::String fn; if (prefix) fn = Common::String::format("%s_%04X.0", prefix, resIndex); else fn = Common::String::format("%04X.0", resIndex); openResource(resIndex); read(data, resourceSize); closeResource(); Common::DumpFile o; o.open(fn); o.write(data, resourceSize); o.finalize(); o.close(); delete[] data; }
void ResourceManager::askForCD(int cd) { byte *textRes; // Stop any music from playing - so the system no longer needs the // current CD - otherwise when we take out the CD, Windows will // complain! _vm->_sound->stopMusic(true); textRes = openResource(2283); _vm->_screen->displayMsg(_vm->fetchTextLine(textRes, 5 + cd) + 2, 0); closeResource(2283); // The original code probably determined automagically when the correct // CD had been inserted, but our backend doesn't support that, and // anyway I don't know if all systems allow that sort of thing. So we // wait for the user to press any key instead, or click the mouse. // // But just in case we ever try to identify the CDs by their labels, // they should be: // // CD1: "RBSII1" (or "PCF76" for the PCF76 version, whatever that is) // CD2: "RBSII2" }
int streamFile(shout_t *shout, const char *fileName) { FILE *filepstream = NULL; int popenFlag = 0; char *songLenStr = NULL; int isStdin = 0; int ret, retval = 0; long songLen; metadata_t *mdata; struct timeval startTime; if ((filepstream = openResource(shout, fileName, &popenFlag, &mdata, &isStdin, &songLen)) == NULL) { if (++resource_errors > 100) { printf("%s: Too many errors -- giving up.\n", __progname); return (0); } /* Continue with next resource on failure: */ return (1); } resource_errors = 0; if (mdata != NULL) { char *tmp, *metaData; tmp = metadata_assemble_string(mdata); if ((metaData = UTF8toCHAR(tmp, ICONV_REPLACE)) == NULL) metaData = xstrdup("(unknown title)"); xfree(tmp); printf("%s: Streaming ``%s''", __progname, metaData); if (vFlag) printf(" (file: %s)\n", fileName); else printf("\n"); xfree(metaData); /* MP3 streams are special, so set the metadata explicitly: */ if (strcmp(pezConfig->format, MP3_FORMAT) == 0) setMetadata(shout, mdata, NULL); metadata_free(&mdata); } else if (isStdin) printf("%s: Streaming from standard input\n", __progname); if (songLen > 0) songLenStr = xstrdup(getTimeString(songLen)); ez_gettimeofday((void *)&startTime); do { ret = sendStream(shout, filepstream, fileName, isStdin, songLenStr, &startTime); if (quit) break; if (ret != STREAM_DONE) { if ((skipTrack && rereadPlaylist) || (skipTrack && queryMetadata)) { skipTrack = 0; ret = STREAM_CONT; } if (queryMetadata && rereadPlaylist) { queryMetadata = 0; ret = STREAM_CONT; } if (ret == STREAM_SKIP || skipTrack) { skipTrack = 0; if (!isStdin && vFlag) printf("%s: SIGUSR1 signal received, skipping current track\n", __progname); retval = 1; ret = STREAM_DONE; } if (ret == STREAM_UPDMDATA || queryMetadata) { queryMetadata = 0; if (mFlag) continue; if (metadataFromProgram) { char *mdataStr = NULL; metadata_t *prog_mdata; if (vFlag > 1) printf("%s: Querying '%s' for fresh metadata\n", __progname, pezConfig->metadataProgram); if ((prog_mdata = getMetadata(pezConfig->metadataProgram)) == NULL) { retval = 0; ret = STREAM_DONE; continue; } if (setMetadata(shout, prog_mdata, &mdataStr) != SHOUTERR_SUCCESS) { retval = 0; ret = STREAM_DONE; continue; } metadata_free(&prog_mdata); if (vFlag > 1) printf("%s: New metadata: ``%s''\n", __progname, mdataStr); xfree(mdataStr); } } if (ret == STREAM_SERVERR) { retval = 0; ret = STREAM_DONE; } } else retval = 1; } while (ret != STREAM_DONE); if (popenFlag) pclose(filepstream); else if (!isStdin) fclose(filepstream); if (songLenStr != NULL) xfree(songLenStr); return (retval); }