Beispiel #1
0
int main()
{
	FILE *pcm = fopen(FILE_NAME_IN, "r" );
	if (pcm == 0) {
		fprintf(stderr, "Failed to open file: %s\n", FILE_NAME_IN);
		exit(ERR_OPEN);
	}

	int r = fread((void *)pcm_buf, sizeof(int), BUF_SIZE, pcm);
	if (r != BUF_SIZE) {
		fprintf(stderr, "Error: read %d samples\n", r);
		exit(ERR_READ);
	}

	struct audio_fader af;
	init_af(&af);
	start_fade(&af, FADE_OUT, 100, 0);
	process(&af, (const short *)pcm_buf, (short *)pcm_buf, BUF_SIZE);

	FILE *output = fopen(FILE_NAME_OUT, "w");
	if (output == 0) {
		fprintf(stderr, "Failed to open file: %s\n", FILE_NAME_OUT);
		exit(ERR_OPEN);
	}

	int w = fwrite((const void *)pcm_buf, sizeof(int), BUF_SIZE, output);
	if (w != BUF_SIZE) {
		fprintf(stderr, "Error: write %d samples\n", w);
		exit(ERR_WRITE);
	}

	fclose(pcm);
	fclose(output);

	exit(0);
}
Beispiel #2
0
bool try_and_add_player_item(short player_index, short type) 
{
	item_definition *definition = get_item_definition(type);
	// LP change: added idiot-proofing
	if (!definition) 
		return false;
	
	player_data *player = get_player_data(player_index);
	short grabbed_sound_index = NONE;
	bool success = false;

	switch (definition->item_kind)
	{
		case _powerup: /* powerups donÕt get added to your inventory */
			if (legal_player_powerup(player_index, type))
			{
				process_player_powerup(player_index, type);
				object_was_just_destroyed(_object_is_item, type);
				grabbed_sound_index= Sound_GotPowerup();
				success= true;
			}
			break;
		
		case _ball:
			// START Benad
			/* Note that you can only carry ONE ball (ever) */
			if(find_player_ball_color(player_index)==NONE)
			{
				player_data *player= get_player_data(player_index);
				
				// When taking ball of your own team, it returns to its original
				// position on the map, unless it's already in our base (or hill).
				if ( (GET_GAME_TYPE() == _game_of_capture_the_flag) &&
					 (type - BALL_ITEM_BASE == player->team)  )
				{
					// START Benad modified oct. 1st
					polygon_data *polygon= get_polygon_data(player->supporting_polygon_index);
					if (polygon->type!=_polygon_is_base)
					{
						object_was_just_destroyed(_object_is_item, type);
						grabbed_sound_index= Sound_GotItem();
						success= true;
						goto DONE;
					}
					else // _polygon_is_base and base == player->team
						 // base != player->team taken care of in update_net_game
						 // (your ball should NEVER get there)
					{
						success= false;
						goto DONE;
					}
					// END Benad modified oct. 1st
				}
				else if (GET_GAME_TYPE() == _game_of_rugby)
				{
					// ghs: work around for SF 2894880

					// if you're in an enemy base
					// and pick up the ball, you
					// score
					polygon_data* polygon = get_polygon_data(player->supporting_polygon_index);
					if (polygon->type == _polygon_is_base && polygon->permutation != player->team)
					{
						/* Goal! */

						// defined in network_games.cpp
						const int _points_scored = 0;
						player->netgame_parameters[_points_scored]++;
						team_netgame_parameters[player->team][_points_scored]++;
						object_was_just_destroyed(_object_is_item, type);
						grabbed_sound_index = Sound_GotItem();
						success = true;
						goto DONE;
					}
				}
				
				player->items[type]= 1;

				// OK, since only for loading weapon. Ignores item_type, cares
				// only about item_kind (here, _ball).
				/* Load the ball weapon.. */
				process_new_item_for_reloading(player_index, _i_red_ball);
				
				/* Tell the interface to redraw next time it has to */
				mark_player_inventory_as_dirty(player_index, type);
				
				success= true;
			}
			grabbed_sound_index= NONE;
			break;
			// END Benad
					
		case _weapon:
		case _ammunition:
		case _item:
			/* Increment the count */	
			assert(type>=0 && type<NUMBER_OF_ITEMS);
			if(player->items[type]==NONE)
			{
				/* just got the first one.. */
				player->items[type]= 1;
				success= true;
			} 
			else if(player->items[type]+1<=definition->maximum_count_per_player ||
				(dynamic_world->game_information.difficulty_level==_total_carnage_level && ((static_world->environment_flags & _environment_m1_weapon_pickups) || definition->item_kind==_ammunition)))
			{
				/* Increment your count.. */
				player->items[type]++;
				success= true;
			} else {
				/* You have exceeded the count of these items */
			}

			grabbed_sound_index= Sound_GotItem();

			if(success)
			{
				/* Reload or whatever.. */
				process_new_item_for_reloading(player_index, type);
					
				/* Tell the interface to redraw next time it has to */
				mark_player_inventory_as_dirty(player_index, type);
			}
			break;
		
		default:
			assert(false);
			break;
	}
	// Benad. Burk.
	DONE:
	
	//CP Addition: call any script traps available
	// jkvw: but only if we actually got the item
	if (success)
	{
		//MH: Call Lua script hook
		L_Call_Got_Item(type, player_index);
	}

	/* Play the pickup sound */
	if (success && player_index==current_player_index)
	{
		SoundManager::instance()->PlayLocalSound(grabbed_sound_index);
	
		/* Flash screen */
		start_fade(_fade_bonus);
	}

	return success;
}