// Filename:- stringed_interface.cpp // // This file contains functions that StringEd wants to call to do things like load/save, they can be modified // for use ingame, but must remain functionally the same... // // Please try and put modifications for whichever games this is used for inside #defines, so I can copy the same file // into each project. // ////////////////////////////////////////////////// // // stuff common to all qcommon files... #include "../server/server.h" #include "../game/q_shared.h" #include "qcommon.h" // ////////////////////////////////////////////////// #pragma warning ( disable : 4511 ) // copy constructor could not be generated #pragma warning ( disable : 4512 ) // assignment operator could not be generated #pragma warning ( disable : 4663 ) // C++ language change: blah blah template crap blah blah #include "stringed_interface.h" #include "stringed_ingame.h" #include using namespace std; #ifdef _STRINGED #include #include #include "generic.h" #endif // this just gets the binary of the file into memory, so I can parse it. Called by main SGE loader // // returns either char * of loaded file, else NULL for failed-to-open... // unsigned char *SE_LoadFileData( const char *psFileName, int *piLoadedLength /* = 0 */) { unsigned char *psReturn = NULL; if ( piLoadedLength ) { *piLoadedLength = 0; } #ifdef _STRINGED if (psFileName[1] == ':') { // full-path filename... // FILE *fh = fopen( psFileName, "rb" ); if (fh) { long lLength = filesize(fh); if (lLength > 0) { psReturn = (unsigned char *) malloc( lLength + 1); if (psReturn) { int iBytesRead = fread( psReturn, 1, lLength, fh ); if (iBytesRead != lLength) { // error reading file!!!... // free(psReturn); psReturn = NULL; } else { psReturn[ lLength ] = '\0'; if ( piLoadedLength ) { *piLoadedLength = iBytesRead; } } fclose(fh); } } } } else #endif { // local filename, so prepend the base dir etc according to game and load it however (from PAK?) // unsigned char *pvLoadedData; int iLen = FS_ReadFile( psFileName, (void **)&pvLoadedData ); if (iLen>0) { psReturn = pvLoadedData; if ( piLoadedLength ) { *piLoadedLength = iLen; } } } return psReturn; } // called by main SGE code after loaded data has been parsedinto internal structures... // void SE_FreeFileDataAfterLoad( unsigned char *psLoadedFile ) { #ifdef _STRINGED if ( psLoadedFile ) { free( psLoadedFile ); } #else if ( psLoadedFile ) { FS_FreeFile( psLoadedFile ); } #endif } #ifndef _STRINGED // quake-style method of doing things since their file-list code doesn't have a 'recursive' flag... // int giFilesFound; static void SE_R_ListFiles( const char *psExtension, const char *psDir, string &strResults ) { // Com_Printf(va("Scanning Dir: %s\n",psDir)); char **sysFiles, **dirFiles; int numSysFiles, i, numdirs; dirFiles = FS_ListFiles( psDir, "/", &numdirs); for (i=0;i