1 //---------------------------------------------------------------------------- 2 // EDGE Data Definition File Code (Main) 3 //---------------------------------------------------------------------------- 4 // 5 // Copyright (c) 1999-2008 The EDGE Team. 6 // 7 // This program is free software; you can redistribute it and/or 8 // modify it under the terms of the GNU General Public License 9 // as published by the Free Software Foundation; either version 2 10 // of the License, or (at your option) any later version. 11 // 12 // This program is distributed in the hope that it will be useful, 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 // GNU General Public License for more details. 16 // 17 //---------------------------------------------------------------------------- 18 19 #ifndef __DDF_SFX_H__ 20 #define __DDF_SFX_H__ 21 22 #include "epi/utility.h" 23 24 #include "types.h" 25 26 27 #define S_CLOSE_DIST 160.0f 28 #define S_CLIPPING_DIST 4000.0f 29 30 31 // ---------------------------------------------------------------- 32 // ------------------------ SOUND EFFECTS ------------------------- 33 // ---------------------------------------------------------------- 34 35 // -KM- 1998/10/29 36 typedef struct sfx_s 37 { 38 int num; 39 int sounds[1]; // -ACB- 1999/11/06 Zero based array is not ANSI compliant 40 // -AJA- I'm also relying on the [1] within sfxdef_c. 41 } 42 sfx_t; 43 44 #define sfx_None (sfx_t*) NULL 45 46 // Sound Effect Definition Class 47 class sfxdef_c 48 { 49 public: 50 sfxdef_c(); 51 ~sfxdef_c(); 52 53 public: 54 void Default(void); 55 void CopyDetail(sfxdef_c &src); 56 57 // Member vars.... 58 epi::strent_c name; 59 60 // full sound lump name (or file name) 61 lumpname_c lump_name; 62 epi::strent_c file_name; 63 64 // sfxinfo ID number 65 // -AJA- Changed to a sfx_t. It serves two purposes: (a) hold the 66 // sound ID, like before, (b) better memory usage, as we don't 67 // need to allocate a new sfx_t for non-wildcard sounds. 68 sfx_t normal; 69 70 // Sfx singularity (only one at a time), or 0 if not singular 71 int singularity; 72 73 // Sfx priority 74 int priority; 75 76 // volume adjustment (100% is normal, lower is quieter) 77 percent_t volume; 78 79 // -KM- 1998/09/01 Looping: for non NULL origins 80 bool looping; 81 82 // -AJA- 2000/04/19: Prefer to play the whole sound rather than 83 // chopping it off with a new sound. 84 bool precious; 85 86 // distance limit, if the hearer is further away than `max_distance' 87 // then the this sound won't be played at all. 88 float max_distance; 89 90 private: 91 // disable copy construct and assignment operator sfxdef_c(sfxdef_c & rhs)92 explicit sfxdef_c(sfxdef_c &rhs) { } 93 sfxdef_c& operator= (sfxdef_c &rhs) { return *this; } 94 }; 95 96 97 // Our sound effect definition container 98 class sfxdef_container_c : public epi::array_c 99 { 100 public: sfxdef_container_c()101 sfxdef_container_c() : epi::array_c(sizeof(sfxdef_c*)) 102 { } 103 ~sfxdef_container_c()104 ~sfxdef_container_c() { Clear(); } 105 106 private: 107 void CleanupObject(void *obj); 108 109 public: 110 // List management GetSize()111 int GetSize() { return array_entries; } Insert(sfxdef_c * s)112 int Insert(sfxdef_c *s) { return InsertObject((void*)&s); } 113 sfxdef_c* operator[](int idx) { return *(sfxdef_c**)FetchObject(idx); } 114 115 // Lookup functions 116 sfx_t* GetEffect(const char *name, bool error = true); 117 sfxdef_c* Lookup(const char *name); 118 }; 119 120 // ----------EXTERNALISATIONS---------- 121 122 extern sfxdef_container_c sfxdefs; // -ACB- 2004/07/25 Implemented 123 124 bool DDF_ReadSFX(void *data, int size); 125 126 #endif // __DDF_SFX_H__ 127 128 //--- editor settings --- 129 // vi:ts=4:sw=4:noexpandtab 130