soundinit.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "pch.h"
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Sound Initialization
  5. //
  6. //////////////////////////////////////////////////////////////////////////////
  7. namespace SoundInit {
  8. void InitializeSoundTemplates(
  9. Modeler* pmodeler,
  10. TVector<TRef<ISoundTemplate> >& vSoundMap
  11. ) {
  12. DWORD dwStartTime = timeGetTime();
  13. // load the training sound definitions
  14. TRef<ZFile> pFile = pmodeler->LoadFile ("trainingsounddef", "mdl", false);
  15. TRef<INameSpace> pnsTrainingSoundDef;
  16. if (pFile == NULL)
  17. {
  18. // here we substitute a namespace that we will use
  19. pnsTrainingSoundDef = pmodeler->CreateNameSpace("trainingsounddef", pmodeler->GetNameSpace("notrainingsounddef"));
  20. }
  21. // load the general-purpose sound templates
  22. TRef<INameSpace> pnsSoundDefs = pmodeler->GetNameSpace("sounddef");
  23. TRef<IObjectList> plist; CastTo(plist, pnsSoundDefs->FindMember("soundList"));
  24. TLookup<ISoundTemplate>::Parse(plist, 0, vSoundMap);
  25. // unload the training sound namespace
  26. pmodeler->UnloadNameSpace ("trainingsounddef");
  27. // make sure all of the IGC sounds were defined
  28. #define DEFSOUND(id) ZAssert(vSoundMap[id##Sound] != NULL);
  29. #include "sounds.h"
  30. #undef DEFSOUND
  31. debugf("Time reading sounds: %d ms\n", timeGetTime() - dwStartTime);
  32. }
  33. void AddMembers(INameSpace* pns)
  34. {
  35. #define DEFSOUND(id) pns->AddMember(#id "SoundId", new Number((float)id##Sound));
  36. #include "sounds.h"
  37. #undef DEFSOUND
  38. }
  39. }