/** ** Glue between c and scheme. Ask to the sound system to remap a sound id ** to a given name. ** ** @param l Lua state. ** ** @return the sound object */ static int CclMapSound(lua_State *l) { const char *sound_name; LuaCheckArgs(l, 2); sound_name = LuaToString(l, 1); MapSound(sound_name, CclGetSound(l)); lua_pushvalue(l, 2); return 1; }
/** ** Ask the sound server to build a special sound group. ** ** Register two sound groups together to make a special sound (for ** selection). Return the corresponding id after registering it under a ** given name. ** ** @param name the name of the group (handled by caller). ** @param first id of the first group ** @param second id of the second group ** ** @return Registered sound identifier. */ CSound *MakeSoundGroup(const std::string &name, CSound *first, CSound *second) { CSound *sound; if ((sound = FindSound(name))) { DebugPrint("re-register sound `%s'\n" _C_ name.c_str()); return sound; } sound = RegisterTwoGroups(first, second); if(sound != NO_SOUND) MapSound(name, sound); return sound; }
/** ** Ask the sound server to register a sound and store the mapping ** between its name and its id. ** Register a sound group (or an unique sound if nb==1) and get the ** corresponding sound id. ** ** @param name name of this sound group (Freed by caller). ** @param file list of sound file names ** @param nb number of sounds ** ** @return the sound id of the created group */ CSound *MakeSound(const std::string &name, const char *file[], int nb) { CSound *sound; Assert(nb <= 255); if ((sound = FindSound(name))) { DebugPrint("re-register sound `%s'\n" _C_ name.c_str()); return sound; } sound = RegisterSound(file, nb); if(sound != NO_SOUND) MapSound(name, sound); return sound; }
/** Performs remaping listed in the Remaps array. Maps also critter sounds to ** their correct values. */ local void RemapSounds(void) { int i; int nb; nb=sizeof(Remaps)/sizeof(*Remaps); for(i=0;i<nb;i++) { //FIXME: should be more efficient MapSound(Remaps[i].NewName,SoundIdForName(Remaps[i].BaseName)); } // critter mapping switch( TheMap.Terrain ) { case TilesetSummer: MakeSoundGroup("critter-selected", SoundIdForName("sheep selected"), SoundIdForName("sheep annoyed")); break; case TilesetWinter: MakeSoundGroup("critter-selected", SoundIdForName("seal selected"), SoundIdForName("seal annoyed")); break; case TilesetWasteland: MakeSoundGroup("critter-selected", SoundIdForName("pig selected"), SoundIdForName("pig annoyed")); break; case TilesetSwamp: MakeSoundGroup("critter-selected", SoundIdForName("warthog selected"), SoundIdForName("warthog annoyed")); break; default: DebugLevel2("Unknown Terrain %d\n",TheMap.Terrain); } }