betterer ambient sounds

This commit is contained in:
darkrose 2015-04-11 23:41:00 +10:00
parent 3d7bc18030
commit 74406aacdd
3 changed files with 28 additions and 8 deletions

View File

@ -497,6 +497,29 @@ void mapblock_mesh_generate_special(MeshMakeData *data,
g_sound->stopSound(i->second.id);
}
}
if (add_sound && content_features(n).liquid_type != LIQUID_NONE) {
if (data->m_vmanip.getNodeRO(blockpos_nodes+p+v3s16(0,1,0)).getContent() != CONTENT_AIR) {
add_sound = false;
}else if (content_features(n).param2_type != CPT_LIQUID || n.param2 < 4 || n.param2 > 7) {
add_sound = false;
}else{
int adj = 0;
for (s16 x=-1; x<2; x++) {
for (s16 z=-1; z<2; z++) {
if (!x && !z)
continue;
content_t ac = data->m_vmanip.getNodeRO(blockpos_nodes+p+v3s16(x,0,z)).getContent();
if (
ac == content_features(n).liquid_alternative_flowing
|| ac == content_features(n).liquid_alternative_source
)
adj++;
}
}
if (adj > 3)
add_sound = false;
}
}
if (add_sound) {
v3f pf = intToFloat(p+blockpos_nodes,BS);
MapBlockSound bsnd;

View File

@ -101,8 +101,8 @@ void init_sounds(ISoundManager *sound)
sound->loadSound("env-dooropen","env_dooropen.ogg");
sound->loadSound("env-doorclose","env_doorclose.ogg");
sound->loadSound("env-fire","env_fire.ogg");
sound->loadSound("env-lava","env_lava.ogg",0.2);
sound->loadSound("env-water","env_water.ogg",0.2);
sound->loadSound("env-lava","env_lava.ogg",0.5);
sound->loadSound("env-water","env_water.ogg",0.5);
sound->loadSound("env-steam","env_steam.ogg");
sound->loadSound("env-tnt","env_tnt.ogg");
sound->loadSound("env-teleport","env_teleport.ogg");

View File

@ -359,7 +359,7 @@ public:
PlayingSound *sound = new PlayingSound;
assert(sound);
float distance = m_listener_pos.getDistanceFrom(pos);
if (!queue && (!loop || distance < 240.0)) {
if (!queue && (!loop || distance < 160.0)) {
alGenSources(1, &sound->source_id);
alSourcei(sound->source_id, AL_BUFFER, buf->buffer_id);
alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false);
@ -443,19 +443,16 @@ public:
<<m_sounds_playing.size()<<" playing sounds, "
<<m_buffers.size()<<" sound names loaded"<<std::endl;
std::set<int> del_list;
bool did_start = false;
for (std::map<int, PlayingSound*>::iterator i = m_sounds_playing.begin(); i != m_sounds_playing.end(); i++) {
int id = i->first;
PlayingSound *sound = i->second;
if (sound->has_position && sound->loop && !sound->should_delete) {
float distance = m_listener_pos.getDistanceFrom(sound->pos);
if (distance > 320.0 && !sound->disabled && !did_start) {
alSourceStop(sound->source_id);
if (distance > 320.0 && !sound->disabled) {
alDeleteSources(1, &sound->source_id);
sound->disabled = true;
sound->source_id = 0;
}else if (distance < 240.0 && sound->disabled) {
did_start = true;
}else if (distance < 160.0 && sound->disabled) {
alGenSources(1, &sound->source_id);
alSourcei(sound->source_id, AL_BUFFER, sound->buf->buffer_id);
alSourcei(sound->source_id, AL_SOURCE_RELATIVE, false);