grsound.cpp: Use GfFileExists instead of fopen(3)
Opening a file only to check whether it exists is resource-consuming for no reason, since GfFileExists can achieve the same effect without requiring to open a file.
This commit is contained in:
parent
36d5490d1a
commit
ed97add0a0
1 changed files with 1 additions and 7 deletions
|
@ -93,7 +93,6 @@ void grInitSound(tSituation* s, int ncars)
|
|||
tCarElt *car = s->cars[i];
|
||||
const char* param;
|
||||
char filename[512];
|
||||
FILE *file = NULL;
|
||||
|
||||
// ENGINE PARAMS
|
||||
tdble rpm_scale;
|
||||
|
@ -103,17 +102,12 @@ void grInitSound(tSituation* s, int ncars)
|
|||
car->_carName,
|
||||
(int)(sizeof(filename) - strlen(car->_carName) - strlen("cars/models//")),
|
||||
param);
|
||||
file = fopen(filename, "r");
|
||||
if (!file)
|
||||
if (!GfFileExists(filename))
|
||||
{
|
||||
sprintf(filename, "data/sound/%.*s",
|
||||
(int)(sizeof(filename) - strlen(car->_carName) - strlen("data/sound/")),
|
||||
param);
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
car_sound_data[car->index] = new CarSoundData (car->index, sound_interface);
|
||||
Sound* engine_sound = sound_interface->addSample(filename, ACTIVE_VOLUME | ACTIVE_PITCH | ACTIVE_LP_FILTER, true, false);
|
||||
|
|
Loading…
Reference in a new issue