Writes data from the ambient sound data file
| 289 | |
| 290 | // Writes data from the ambient sound data file |
| 291 | void WriteAmbientData() { |
| 292 | char filename[_MAX_PATH]; |
| 293 | CFILE *ofile; |
| 294 | |
| 295 | #ifndef NEWEDITOR |
| 296 | ddio_MakePath(filename, Base_directory, "data", "misc", AMBIENT_FILE_NAME, NULL); |
| 297 | #else |
| 298 | ddio_MakePath(filename, D3HogDir, "data", "misc", AMBIENT_FILE_NAME, NULL); |
| 299 | #endif |
| 300 | ofile = cfopen(filename, "wb"); |
| 301 | |
| 302 | if (!ofile) { |
| 303 | Int3(); |
| 304 | return; |
| 305 | } |
| 306 | |
| 307 | // Write file ID & version |
| 308 | cf_WriteBytes((uint8_t *)AMBIENT_FILE_ID, strlen(AMBIENT_FILE_ID), ofile); |
| 309 | cf_WriteInt(ofile, AMBIENT_FILE_VERSION); |
| 310 | |
| 311 | // Write the number of patterns |
| 312 | cf_WriteInt(ofile, Num_ambient_sound_patterns); |
| 313 | |
| 314 | // Read the patterns |
| 315 | for (int p = 0; p < Num_ambient_sound_patterns; p++) { |
| 316 | |
| 317 | asp *asp = &Ambient_sound_patterns[p]; |
| 318 | |
| 319 | cf_WriteString(ofile, asp->name); |
| 320 | |
| 321 | cf_WriteFloat(ofile, asp->min_delay); |
| 322 | cf_WriteFloat(ofile, asp->max_delay); |
| 323 | |
| 324 | cf_WriteInt(ofile, asp->num_sounds); |
| 325 | |
| 326 | for (int s = 0; s < asp->num_sounds; s++) { |
| 327 | cf_WriteString(ofile, Sounds[asp->sounds[s].handle].name); |
| 328 | |
| 329 | cf_WriteFloat(ofile, asp->sounds[s].min_volume); |
| 330 | cf_WriteFloat(ofile, asp->sounds[s].max_volume); |
| 331 | cf_WriteInt(ofile, asp->sounds[s].probability); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | cfclose(ofile); |
| 336 | } |
no test coverage detected