! Load a 2D sound @param sSound filename of the sound @return nil or sound ID in case of success */
| 145 | @return nil or sound ID in case of success |
| 146 | */ |
| 147 | int CScriptObjectSound::LoadSound(IFunctionHandler *pH) |
| 148 | { |
| 149 | float fVolume=255.0f; |
| 150 | |
| 151 | if (pH->GetParamCount()<1 || pH->GetParamCount()>3) |
| 152 | { |
| 153 | m_pScriptSystem->RaiseError("Sound.LoadSound wrong number of arguments"); |
| 154 | return pH->EndFunctionNull(); |
| 155 | }; |
| 156 | |
| 157 | const char *sSound; |
| 158 | ISound *pSound; |
| 159 | int nFlags=0; |
| 160 | int pcount=pH->GetParamCount(); |
| 161 | // int iLocalized; |
| 162 | pH->GetParam(1,sSound); |
| 163 | |
| 164 | if (pcount>1) |
| 165 | pH->GetParam(2, nFlags); |
| 166 | |
| 167 | if (pcount>2) |
| 168 | pH->GetParam(3, fVolume); |
| 169 | |
| 170 | if (m_pSoundSystem) |
| 171 | { |
| 172 | pSound=m_pSoundSystem->LoadSound(sSound,nFlags); |
| 173 | if(pSound) |
| 174 | { |
| 175 | pSound->SetVolume((int)(fVolume)); |
| 176 | |
| 177 | pSound->AddRef(); |
| 178 | USER_DATA ud=m_pScriptSystem->CreateUserData((INT_PTR)pSound,USER_DATA_SOUND); //AMD Port |
| 179 | return pH->EndFunction(ud); |
| 180 | } |
| 181 | else{ |
| 182 | m_pScriptSystem->RaiseError("Sound.LoadSound error loading %s",sSound); |
| 183 | } |
| 184 | } |
| 185 | return pH->EndFunctionNull(); |
| 186 | } |
| 187 | |
| 188 | |
| 189 |
no test coverage detected