____ _ __
/ __ )____ _____ | | / /___ ___________
/ __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/
/ /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ )
/_____/\____/____/ |__/|__/\__,_/_/ /____/
A futuristic real-time strategy game.
This file is part of Bos Wars.
(C) Copyright 2001-2007 by the Bos Wars and Stratagus Project.
Distributed under the "GNU General Public License"00001 // ____ _ __ 00002 // / __ )____ _____ | | / /___ ___________ 00003 // / __ / __ \/ ___/ | | /| / / __ `/ ___/ ___/ 00004 // / /_/ / /_/ (__ ) | |/ |/ / /_/ / / (__ ) 00005 // /_____/\____/____/ |__/|__/\__,_/_/ /____/ 00006 // 00007 // A futuristic real-time strategy game. 00008 // This file is part of Bos Wars. 00009 // 00011 // 00012 // (c) Copyright 1998-2007 by Lutz Sammer and Fabrice Rossi 00013 // 00014 // This program is free software; you can redistribute it and/or modify 00015 // it under the terms of the GNU General Public License as published by 00016 // the Free Software Foundation; only version 2 of the License. 00017 // 00018 // This program is distributed in the hope that it will be useful, 00019 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 // GNU General Public License for more details. 00022 // 00023 // You should have received a copy of the GNU General Public License 00024 // along with this program; if not, write to the Free Software 00025 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00026 // 02111-1307, USA. 00027 // 00028 00030 00031 /*---------------------------------------------------------------------------- 00032 -- Includes 00033 ----------------------------------------------------------------------------*/ 00034 00035 #include <stdio.h> 00036 #include <stdlib.h> 00037 #include <string.h> 00038 00039 #include "stratagus.h" 00040 00041 #include <string> 00042 #include <map> 00043 00044 #include "sound.h" 00045 #include "sound_server.h" 00046 00047 /*---------------------------------------------------------------------------- 00048 -- Variables 00049 ----------------------------------------------------------------------------*/ 00050 00051 static std::map<std::string, CSound *> SoundMap; 00052 00053 /*---------------------------------------------------------------------------- 00054 -- Functions 00055 ----------------------------------------------------------------------------*/ 00056 00064 void MapSound(const std::string &name, CSound *id) 00065 { 00066 SoundMap[name] = id; 00067 } 00068 00076 CSound *SoundForName(const std::string &name) 00077 { 00078 Assert(!name.empty()); 00079 00080 CSound *result = SoundMap[name]; 00081 if (!result) { 00082 DebugPrint("Can't find sound `%s' in sound table\n" _C_ name.c_str()); 00083 } 00084 return result; 00085 } 00086 00099 CSound *MakeSound(const std::string &name, const char *file[], int nb) 00100 { 00101 CSound *sound; 00102 00103 Assert(nb <= 255); 00104 00105 if ((sound = SoundMap[name])) { 00106 DebugPrint("re-register sound `%s'\n" _C_ name.c_str()); 00107 return sound; 00108 } 00109 00110 sound = RegisterSound(file, nb); 00111 MapSound(name, sound); 00112 00113 return sound; 00114 } 00115 00129 CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second) 00130 { 00131 CSound *sound; 00132 00133 if ((sound = SoundMap[name])) { 00134 DebugPrint("re-register sound `%s'\n" _C_ name.c_str()); 00135 return sound; 00136 } 00137 00138 sound = RegisterTwoGroups(first, second); 00139 MapSound(name, sound); 00140 00141 return sound; 00142 } 00143 00144 #ifdef DEBUG 00145 void FreeSounds() 00146 { 00147 std::map<std::string, CSound *>::iterator i; 00148 for (i = SoundMap.begin(); i != SoundMap.end(); ++i) { 00149 delete (*i).second; 00150 } 00151 } 00152 #endif 00153
1.5.6