void CWeaponDefHandler::LoadSound(const LuaTable& wdTable, GuiSoundSet& gsound, const string& soundCat) { string name = ""; float volume = -1.0f; if (soundCat == "start") { name = wdTable.GetString("soundStart", ""); volume = wdTable.GetFloat("soundStartVolume", -1.0f); } else if (soundCat == "hit") { name = wdTable.GetString("soundHit", ""); volume = wdTable.GetFloat("soundHitVolume", -1.0f); } if (name != "") { const int id = LoadSoundFile(name); if (id > 0) { GuiSoundSet::Data soundData(name, 0, volume); gsound.sounds.push_back(soundData); gsound.setID(0, id); } } }
void CWeaponDefHandler::LoadSound(const LuaTable& wdTable, GuiSoundSet& gsound, const string& soundCat) { string name = ""; float volume = -1.0f; if (soundCat == "start") { name = wdTable.GetString("soundStart", ""); volume = wdTable.GetFloat("soundStartVolume", -1.0f); } else if (soundCat == "hit") { name = wdTable.GetString("soundHit", ""); volume = wdTable.GetFloat("soundHitVolume", -1.0f); } if (name != "") { if (!sound->HasSoundItem(name)) { if (name.find(".wav") == string::npos) { // .wav extension missing, add it name += ".wav"; } const string soundPath = "sounds/" + name; CFileHandler sfile(soundPath); if (sfile.FileExists()) { // only push data if we extracted a valid name GuiSoundSet::Data soundData(name, 0, volume); gsound.sounds.push_back(soundData); int id = sound->GetSoundId(soundPath); gsound.setID(0, id); } } else { GuiSoundSet::Data soundData(name, 0, volume); gsound.sounds.push_back(soundData); int id = sound->GetSoundId(name); gsound.setID(0, id); } } }