_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sound.h
Go to the documentation of this file.
1 // _________ __ __
2 // / _____// |_____________ _/ |______ ____ __ __ ______
3 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/
4 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ |
5 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ >
6 // \/ \/ \//_____/ \/
7 // ______________________ ______________________
8 // T H E W A R B E G I N S
9 // Stratagus - A free fantasy real time strategy game engine
10 //
12 //
13 // (c) Copyright 1998-2007 by Lutz Sammer, Fabrice Rossi, and Jimmy Salmon
14 //
15 // This program is free software; you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation; only version 2 of the License.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 // 02111-1307, USA.
28 //
29 
30 #ifndef __SOUND_H__
31 #define __SOUND_H__
32 
34 
35 /*----------------------------------------------------------------------------
36 -- Includes
37 ----------------------------------------------------------------------------*/
38 
39 #include "unitsound.h"
40 
41 /*----------------------------------------------------------------------------
42 -- Declarations
43 ----------------------------------------------------------------------------*/
44 
45 class CUnit;
46 class Missile;
47 class CSample;
48 class LuaActionListener;
49 
50 /*----------------------------------------------------------------------------
51 -- Definitons
52 ----------------------------------------------------------------------------*/
53 
54 #define MaxSampleVolume 255
55 #define NO_SOUND 0
56 
57 
73 };
74 
75 
79 class GameSound
80 {
81 public:
93 };
94 
98 class CSound
99 {
100 public:
101  CSound() : Mapref(0), Range(0), Number(0)
102  {
103  memset(&Sound, 0, sizeof(Sound));
104  }
105  ~CSound();
106  unsigned int Mapref;
111  unsigned char Range;
112  unsigned char Number;
113  union {
116  struct {
119  } TwoGroups;
120  } Sound;
121 };
122 
126 #define ONE_SOUND 0
127 
131 #define TWO_GROUPS 1
132 
136 #define INFINITE_SOUND_RANGE 255
137 
140 #define MAX_SOUND_RANGE 254
141 
145 struct Origin {
146  const void *Base;
147  unsigned Id;
148 };
149 
150 
151 /*----------------------------------------------------------------------------
152 -- Variables
153 ----------------------------------------------------------------------------*/
154 
155 extern GameSound GameSounds;
156 
157 extern bool CallbackMusic;
158 
160 extern int DistanceSilent;
161 
162 /*----------------------------------------------------------------------------
163 -- Functions
164 ----------------------------------------------------------------------------*/
165 
167 extern unsigned char CalculateVolume(bool isVolume, int power, unsigned char range);
169 extern void PlayUnitSound(const CUnit &unit, UnitVoiceGroup unit_voice_group);
171 extern void PlayUnitSound(const CUnit &unit, CSound *sound);
173 extern void PlayMissileSound(const Missile &missile, CSound *sound);
175 extern void PlayGameSound(CSound *sound, unsigned char volume, bool always = false);
176 
178 extern int PlayFile(const std::string &name, LuaActionListener *listener = NULL);
179 
181 extern void SetSoundRange(CSound *sound, unsigned char range);
182 
184 extern CSound *RegisterSound(const std::vector<std::string> &files);
185 
187 extern CSound *RegisterTwoGroups(CSound *first, CSound *second);
188 
190 extern void InitSoundClient();
191 
192 
193 // music.cpp
194 
196 extern void CheckMusicFinished(bool force = false);
197 
199 extern void InitMusic();
200 
202 #define CallbackMusicOn() \
203  CallbackMusic = true;
204 #define CallbackMusicOff() \
206  CallbackMusic = false;
207 
208 
209 // sound_id.cpp
210 
212 extern void MapSound(const std::string &sound_name, CSound *id);
214 extern CSound *SoundForName(const std::string &sound_name);
216 extern CSound *MakeSound(const std::string &sound_name, const std::vector<std::string> &files);
218 extern CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second);
219 
220 extern void FreeSounds();
221 
222 // script_sound.cpp
223 
225 extern void SoundCclRegister();
226 
227 
229 
230 #endif // !__SOUND_H__
SoundConfig BuildingConstruction[MAX_RACES]
ship reaches coast
Definition: sound.h:86
Attack command.
Definition: sound.h:72
void CheckMusicFinished(bool force=false)
Check if music is finished and play the next song.
Definition: music.cpp:77
only for building under construction
Definition: sound.h:68
CSound * Second
first group: selected sound
Definition: sound.h:118
int PlayFile(const std::string &name, LuaActionListener *listener=NULL)
Play a sound file.
Definition: sound.cpp:403
CSound * SoundForName(const std::string &sound_name)
Get the sound id bound to an identifier.
Definition: sound_id.cpp:88
SoundConfig Rescue[MAX_RACES]
building ready
Definition: sound.h:88
Definition: sound.h:145
SoundConfig Docking
used by ui
Definition: sound.h:85
CSound()
Definition: sound.h:101
struct CSound::@34::@35 TwoGroups
when it's a simple group
int DistanceSilent
flag true callback ccl if stops
Definition: sound.cpp:72
Missile on the map.
Definition: missile.h:413
#define MAX_RACES
Definition: stratagus.h:160
resource 6
Definition: upgrade_structs.h:70
unsigned char CalculateVolume(bool isVolume, int power, unsigned char range)
Calculates volume level.
Definition: sound.cpp:245
Definition: sound.h:79
void SoundCclRegister()
register ccl features
Definition: script_sound.cpp:352
SoundConfig NotEnoughFood[MAX_RACES]
not enough resources message
Definition: sound.h:92
only worker, work completed
Definition: sound.h:67
The big unit structure.
Definition: unit.h:119
CSound * MakeSoundGroup(const std::string &name, CSound *first, CSound *second)
Make a sound group bound to identifier.
Definition: sound_id.cpp:140
void InitSoundClient()
Initialize client side of the sound layer.
Definition: sound.cpp:498
SoundConfig WorkComplete[MAX_RACES]
building under construction
Definition: sound.h:87
Definition: unitsound.h:54
Definition: sound.h:98
UnitVoiceGroup
Definition: sound.h:60
unsigned char Number
Range is a multiplier for DistanceSilent.
Definition: sound.h:112
Acknowledge command.
Definition: sound.h:63
Definition: widgets.h:46
SoundConfig ResearchComplete[MAX_RACES]
chat message
Definition: sound.h:90
void InitMusic()
Initialize music.
Definition: music.cpp:100
bool CallbackMusic
Game sound configuration.
Definition: music.cpp:57
GameSound GameSounds
Definition: sound.cpp:57
only for transport reaching coast
Definition: sound.h:69
unsigned char Range
Definition: sound.h:111
const void * Base
Definition: sound.h:146
~CSound()
Definition: sound.cpp:566
If killed.
Definition: sound.h:66
SoundConfig PlacementError[MAX_RACES]
Definition: sound.h:82
Definition: sound.h:61
harvesting
Definition: sound.h:71
void SetSoundRange(CSound *sound, unsigned char range)
Modify the range of a given sound.
Definition: sound.cpp:425
SoundConfig Click
used by ui
Definition: sound.h:84
CSound * RegisterTwoGroups(CSound *first, CSound *second)
Create a special sound group with two sounds.
Definition: sound.cpp:481
CSample * OneSound
Definition: sound.h:114
CSound * First
Definition: sound.h:117
CSound * RegisterSound(const std::vector< std::string > &files)
Register a sound (can be a simple sound or a group)
Definition: sound.cpp:444
CSound * MakeSound(const std::string &sound_name, const std::vector< std::string > &files)
Make a sound bound to identifier.
Definition: sound_id.cpp:111
If selected.
Definition: sound.h:62
SoundConfig NotEnoughRes[MAX_RACES][MaxCosts]
research complete message
Definition: sound.h:91
SoundConfig PlacementSuccess[MAX_RACES]
used by ui
Definition: sound.h:83
void PlayMissileSound(const Missile &missile, CSound *sound)
Play a missile sound.
Definition: sound.cpp:330
void PlayGameSound(CSound *sound, unsigned char volume, bool always=false)
Play a game sound.
Definition: sound.cpp:360
unsigned Id
pointer on a Unit
Definition: sound.h:147
unsigned int Mapref
Definition: sound.h:106
Definition: sound_server.h:52
SoundConfig ChatMessage
rescue units
Definition: sound.h:89
void PlayUnitSound(const CUnit &unit, UnitVoiceGroup unit_voice_group)
Play a unit sound.
Definition: sound.cpp:275
void FreeSounds()
Definition: sound_id.cpp:156
CSample ** OneGroup
if it's only a simple sound
Definition: sound.h:115
union CSound::@34 Sound
single, group, or table of sounds.
If attacked.
Definition: sound.h:65
repairing
Definition: sound.h:70
Command completed.
Definition: sound.h:64
void MapSound(const std::string &sound_name, CSound *id)
Map sound to identifier.
Definition: sound_id.cpp:71
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.