/* =============== VM_LoadSymbols =============== */ void VM_LoadSymbols( vm_t *vm ) { int len; char *mapfile, *text_p, *token; char name[MAX_QPATH]; char symbols[MAX_QPATH]; vmSymbol_t **prev, *sym; int count; int value; int chars; int segment; int numInstructions; // don't load symbols if not developer if ( !com_developer->integer ) { return; } COM_StripExtension2( vm->name, name, sizeof( name ) ); Com_sprintf( symbols, sizeof( symbols ), "vm/%s.map", name ); len = FS_ReadFile( symbols, (void **)&mapfile ); if ( !mapfile ) { Com_Printf( "Couldn't load symbol file: %s\n", symbols ); return; } numInstructions = vm->instructionPointersLength >> 2; // parse the symbols text_p = mapfile; prev = &vm->symbols; count = 0; while ( 1 ) { token = COM_Parse( &text_p ); if ( !token[0] ) { break; } segment = ParseHex( token ); if ( segment ) { COM_Parse( &text_p ); COM_Parse( &text_p ); continue; // only load code segment values } token = COM_Parse( &text_p ); if ( !token[0] ) { Com_Printf( "WARNING: incomplete line at end of file\n" ); break; } value = ParseHex( token ); token = COM_Parse( &text_p ); if ( !token[0] ) { Com_Printf( "WARNING: incomplete line at end of file\n" ); break; } chars = strlen( token ); sym = Hunk_Alloc( sizeof( *sym ) + chars, h_high ); *prev = sym; prev = &sym->next; sym->next = NULL; // convert value from an instruction number to a code offset if ( value >= 0 && value < numInstructions ) { value = vm->instructionPointers[value]; } sym->symValue = value; Q_strncpyz( sym->symName, token, chars + 1 ); count++; } vm->numSymbols = count; Com_Printf( "%i symbols parsed from %s\n", count, symbols ); FS_FreeFile( mapfile ); }
/* ================= S_CodecGetSound Opens/loads a sound, tries codec based on the sound's file extension then tries all supported codecs. ================= */ static void *S_CodecGetSound( const char *filename, snd_info_t *info ) { snd_codec_t *codec; snd_codec_t *orgCodec = NULL; qboolean orgNameFailed = qfalse; char localName[ MAX_QPATH ]; const char *ext; char altName[ MAX_QPATH ]; void *rtn = NULL; Q_strncpyz( localName, filename, MAX_QPATH ); ext = COM_GetExtension( localName ); if ( *ext ) { // Look for the correct loader and use it for ( codec = codecs; codec; codec = codec->next ) { if ( !Q_stricmp( ext, codec->ext ) ) { // Load if ( info ) rtn = codec->load( localName, info ); else rtn = codec->open( localName ); break; } } // A loader was found if ( codec ) { if ( !rtn ) { // Loader failed, most likely because the file isn't there; // try again without the extension orgNameFailed = qtrue; orgCodec = codec; COM_StripExtension2( filename, localName, MAX_QPATH ); } else { // Something loaded return rtn; } } } // Try and find a suitable match using all // the sound codecs supported for ( codec = codecs; codec; codec = codec->next ) { if ( codec == orgCodec ) continue; Com_sprintf( altName, sizeof( altName ), "%s.%s", localName, codec->ext ); // Load if ( info ) rtn = codec->load( altName, info ); else rtn = codec->open( altName ); if ( rtn ) { if ( orgNameFailed ) { Com_DPrintf( S_COLOR_YELLOW "WARNING: %s not present, using %s instead\n", filename, altName ); } return rtn; } } Com_Printf( S_COLOR_YELLOW "WARNING: Failed to %s sound %s!\n", info ? "load" : "open", filename ); return NULL; }