Sound source full_range and fade_range are now allowed to be 0. When fade_range=0 division by zero prevented.
This commit is contained in:
parent
b5e500cfda
commit
44bb36d411
1 changed files with 8 additions and 4 deletions
|
@ -120,8 +120,8 @@ positional_source::positional_source(const sourcespec &spec) :
|
|||
files_(spec.files()),
|
||||
locations_(spec.get_locations())
|
||||
{
|
||||
assert(range_ > 0);
|
||||
assert(faderange_ > 0);
|
||||
assert(range_ >= 0);
|
||||
assert(faderange_ >= 0);
|
||||
}
|
||||
|
||||
positional_source::~positional_source()
|
||||
|
@ -189,8 +189,8 @@ void positional_source::update_positions(unsigned int time, const display &disp)
|
|||
|
||||
int positional_source::calculate_volume(const map_location &loc, const display &disp)
|
||||
{
|
||||
assert(range_ > 0);
|
||||
assert(faderange_ > 0);
|
||||
assert(range_ >= 0);
|
||||
assert(faderange_ >= 0);
|
||||
|
||||
if((check_shrouded_ && disp.shrouded(loc)) || (check_fogged_ && disp.fogged(loc)))
|
||||
return DISTANCE_SILENT;
|
||||
|
@ -203,6 +203,10 @@ int positional_source::calculate_volume(const map_location &loc, const display &
|
|||
return 0;
|
||||
}
|
||||
|
||||
if(faderange_ == 0) {
|
||||
return DISTANCE_SILENT;
|
||||
}
|
||||
|
||||
return static_cast<int>((((distance - range_)
|
||||
/ static_cast<double>(faderange_)) * DISTANCE_SILENT));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue