DragonflightDesign
Resource contributor
- Messages
- 1,096
- Country
I want to temporarily replace a default sound file during a check routine; specifically the autopilot disconnect sound. I have a suspicion that the default files may be locked while the sim is active because I don't seem to be able to do it. The absolute paths in the code are created at load time using GetModuleFilename to locate where the sim is running.
Yes, I am aware that this could cause a problem if there is a CTD while caapdis.wav has been replaced.
Code:
// Silence the autopilot disconnect
memset(ap_name, 0, 256);
memset(ap_replace, 0, 256);
strncpy(ap_name, globalSounds, strlen(globalSounds)); // globalSounds is the absolute path to the sim's \sound folder
strncat(ap_name, "caapdis.wav\0", 12);
strncpy(ap_replace, soundPath, strlen(soundPath)); // soundPath is the absolute path to the simobject's \sound folder
strncat(ap_replace, "caapdis_s.wav\0", 14);
if (findFile(ap_name) == TRUE) // findFile checks that the file does actually exist
{
if (findFile(ap_replace) == TRUE)
{
// Both if these return -1 (failure)
chd = remove(ap_name);
chd = rename(ap_name,ap_replace);
}
}
Yes, I am aware that this could cause a problem if there is a CTD while caapdis.wav has been replaced.