From 5174e155217349d0513abcbda6d696f5aeaca38f Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Wed, 23 May 2012 22:27:39 +0200 Subject: [PATCH 01/39] Changed: #1469 StringId conversion to SheetId for sound (DOES NOT COMPILE YET) --HG-- branch : gsoc2012-fabien --- code/nel/include/nel/3d/cluster.h | 7 ++--- code/nel/include/nel/3d/ps_sound.h | 7 ++--- code/nel/include/nel/3d/u_ps_sound_impl.h | 2 +- .../nel/include/nel/3d/u_ps_sound_interface.h | 3 ++- code/nel/include/nel/sound/audio_mixer_user.h | 27 ++++++++++--------- code/nel/include/nel/sound/background_sound.h | 6 ++--- .../nel/sound/background_sound_manager.h | 6 ++--- code/nel/include/nel/sound/clustered_sound.h | 4 +-- code/nel/include/nel/sound/complex_sound.h | 6 ++--- code/nel/include/nel/sound/context_sound.h | 16 +++++------ code/nel/include/nel/sound/sound.h | 14 +++++----- .../nel/include/nel/sound/sound_anim_marker.h | 9 ++++--- code/nel/include/nel/sound/sound_bank.h | 11 ++++---- code/nel/include/nel/sound/source_common.h | 3 ++- code/nel/include/nel/sound/u_audio_mixer.h | 11 ++++---- code/nel/src/3d/cluster.cpp | 20 +++++++++----- code/nel/src/3d/ps_sound.cpp | 6 ++--- code/nel/src/sound/audio_mixer_user.cpp | 19 ++++++------- code/nel/src/sound/background_sound.cpp | 4 +-- .../src/sound/background_sound_manager.cpp | 16 +++++------ code/nel/src/sound/clustered_sound.cpp | 6 ++--- code/nel/src/sound/complex_sound.cpp | 15 ++++++----- code/nel/src/sound/complex_source.cpp | 6 ++--- code/nel/src/sound/context_sound.cpp | 16 +++++------ code/nel/src/sound/sound.cpp | 8 +++--- code/nel/src/sound/sound_anim_marker.cpp | 12 ++++----- code/nel/src/sound/sound_animation.cpp | 8 +++--- code/nel/src/sound/sound_bank.cpp | 12 +++++---- code/nel/src/sound/source_common.cpp | 4 +-- code/nel/src/sound/stream_file_sound.cpp | 6 +++-- 30 files changed, 156 insertions(+), 134 deletions(-) diff --git a/code/nel/include/nel/3d/cluster.h b/code/nel/include/nel/3d/cluster.h index 07ccc7d7e..e8364ccb0 100644 --- a/code/nel/include/nel/3d/cluster.h +++ b/code/nel/include/nel/3d/cluster.h @@ -21,6 +21,7 @@ #include "nel/misc/string_mapper.h" #include "nel/misc/plane.h" #include "nel/misc/aabbox.h" +#include "nel/misc/sheet_id.h" #include "nel/3d/transform.h" @@ -125,9 +126,9 @@ public: //\name Sound related. //@{ void setSoundGroup(const std::string &soundGroup); - void setSoundGroup(const NLMISC::TStringId &soundGroupId); + void setSoundGroup(const NLMISC::CSheetId &soundGroupId); const std::string &getSoundGroup(); - NLMISC::TStringId getSoundGroupId(); + NLMISC::CSheetId getSoundGroupId(); void setEnvironmentFx(const std::string &environmentFx); void setEnvironmentFx(const NLMISC::TStringId &environmentFxId); const std::string &getEnvironmentFx(); @@ -188,7 +189,7 @@ private: std::vector _Volume; /// Sound group name id - NLMISC::TStringId _SoundGroupId; + NLMISC::CSheetId _SoundGroupId; /// Environement Fx name Id (using CStringMapper) NLMISC::TStringId _EnvironmentFxId; diff --git a/code/nel/include/nel/3d/ps_sound.h b/code/nel/include/nel/3d/ps_sound.h index fe15eb302..c1d6583b8 100644 --- a/code/nel/include/nel/3d/ps_sound.h +++ b/code/nel/include/nel/3d/ps_sound.h @@ -21,6 +21,7 @@ #include "nel/misc/string_mapper.h" #include "nel/3d/ps_located.h" #include "nel/3d/ps_attrib.h" +#include "nel/misc/sheet_id.h" @@ -63,13 +64,13 @@ public: virtual void step(TPSProcessPass pass); /// set the name of the sound - void setSoundName(const NLMISC::TStringId &soundName) + void setSoundName(const NLMISC::CSheetId &soundName) { _SoundName = soundName; } /// get the name of the sound - const NLMISC::TStringId &getSoundName(void) const + const NLMISC::CSheetId &getSoundName(void) const { return _SoundName; } @@ -161,7 +162,7 @@ protected: void removeAllSources(); CPSAttrib _Sounds; - NLMISC::TStringId _SoundName; + NLMISC::CSheetId _SoundName; float _Gain; CPSAttribMaker * _GainScheme; float _Pitch; diff --git a/code/nel/include/nel/3d/u_ps_sound_impl.h b/code/nel/include/nel/3d/u_ps_sound_impl.h index 469bc913a..4e3a3571b 100644 --- a/code/nel/include/nel/3d/u_ps_sound_impl.h +++ b/code/nel/include/nel/3d/u_ps_sound_impl.h @@ -162,7 +162,7 @@ public: /// inherited from IPSSoundServer - UPSSoundInstance *createSound(const NLMISC::TStringId &soundName, bool spawned = true) + UPSSoundInstance *createSound(const NLMISC::CSheetId &soundName, bool spawned = true) { if (!_AudioMixer) return NULL; diff --git a/code/nel/include/nel/3d/u_ps_sound_interface.h b/code/nel/include/nel/3d/u_ps_sound_interface.h index 5c40d8727..693350f78 100644 --- a/code/nel/include/nel/3d/u_ps_sound_interface.h +++ b/code/nel/include/nel/3d/u_ps_sound_interface.h @@ -19,6 +19,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" +#include "nel/misc/sheet_id.h" #include namespace NLMISC @@ -50,7 +51,7 @@ struct UPSSoundServer * \param spawn true if the sound must be spawned e.g it continues after this interface is removed * \param cb useful only for spawned sound, it tells when a spawned sound has been removed */ - virtual UPSSoundInstance *createSound(const NLMISC::TStringId &soundName, bool spawn = false) = 0; + virtual UPSSoundInstance *createSound(const NLMISC::CSheetId &soundName, bool spawn = false) = 0; }; diff --git a/code/nel/include/nel/sound/audio_mixer_user.h b/code/nel/include/nel/sound/audio_mixer_user.h index 9c9fd5c86..48f07d8e2 100644 --- a/code/nel/include/nel/sound/audio_mixer_user.h +++ b/code/nel/include/nel/sound/audio_mixer_user.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -92,9 +93,9 @@ public: //@{ /// @name IStringMapperProvider implementation /// map a string - NLMISC::TStringId map(const std::string &str) { return NLMISC::CStringMapper::map(str);} + NLMISC::CSheetId map(const std::string &str) { return NLMISC::CSheetId(str);/*NLMISC::CStringMapper::map(str);*/} /// unmap a string - const std::string &unmap(const NLMISC::TStringId &stringId) { return NLMISC::CStringMapper::unmap(stringId);} + const std::string &unmap(const NLMISC::CSheetId &stringId) { return stringId.toString();/*NLMISC::CStringMapper::unmap(stringId);*/} //@} @@ -180,7 +181,7 @@ public: // Load environment sounds ; treeRoot can be null if you don't want an access to the envsounds // virtual void loadEnvSounds( const char *filename, UEnvSound **treeRoot=NULL ); /// Get a TSoundId from a name (returns NULL if not found) - virtual TSoundId getSoundId( const NLMISC::TStringId &name ); + virtual TSoundId getSoundId( const NLMISC::CSheetId &name ); /// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created. /// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera @@ -192,7 +193,7 @@ public: * pass a callback function that will be called (if not NULL) just before deleting the spawned * source. */ - virtual USource *createSource( const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); + virtual USource *createSource( const NLMISC::CSheetId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); /// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*) virtual USource *createSource( TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *cbUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL); /// Add a source which was created by an EnvSound @@ -223,7 +224,7 @@ public: /// Return the names of the sounds (call this method after loadSounds()) - virtual void getSoundNames( std::vector &names ) const; + virtual void getSoundNames( std::vector &names ) const; /// Return the number of mixing tracks (voices) virtual uint getPolyphony() const { return (uint)_Tracks.size(); } /// Return the number of sources instance. @@ -320,8 +321,8 @@ public: void incPlayingSourceMuted() { ++_PlayingSourcesMuted; }; void decPlayingSourceMuted() { --_PlayingSourcesMuted; }; - void setUserVar(NLMISC::TStringId varName, float value); - float getUserVar(NLMISC::TStringId varName); + void setUserVar(NLMISC::CSheetId varName, float value); + float getUserVar(NLMISC::CSheetId varName); // music virtual bool playMusic(const std::string &fileName, uint xFadeTime= 0, bool async= true, bool loop=true); @@ -351,7 +352,7 @@ public: /// Add a reverb environment. void addEnvironment(const std::string &name, const IReverbEffect::CEnvironment &environment); /// Set the current reverb environment. - void setEnvironment(NLMISC::TStringId environmentName, float roomSize); + void setEnvironment(NLMISC::CSheetId environmentName, float roomSize); /// Set the current reverb environment. inline void setEnvironment(const std::string &environmentName, float roomSize) { setEnvironment(NLMISC::CStringMapper::map(environmentName), roomSize); } /// Get a reverb environment @@ -409,8 +410,8 @@ public: /// Read all user controled var sheets void initUserVar(); - void addUserControledSource(CSourceCommon *source, NLMISC::TStringId varName); - void removeUserControledSource(CSourceCommon *source, NLMISC::TStringId varName); + void addUserControledSource(CSourceCommon *source, NLMISC::CSheetId varName); + void removeUserControledSource(CSourceCommon *source, NLMISC::CSheetId varName); virtual void startDriverBench(); @@ -440,11 +441,11 @@ private: struct CControledSources { /// The user var name - NLMISC::TStringId Name; + NLMISC::CSheetId Name; /// Witch parameter to control TControledParamId ParamId; /// The controled sounds names. - std::vector SoundNames; + std::vector SoundNames; /// Current parameter value float Value; /// All the sources controled by this variable @@ -472,7 +473,7 @@ protected: /// Fill a vector of position and mute flag for all playing sound source. virtual void getPlayingSoundsPos(bool virtualPos, std::vector > &pos); - typedef CHashMap TUserVarControlsContainer; + typedef CHashMap TUserVarControlsContainer; /// Container for all user controler and currently controled playing source TUserVarControlsContainer _UserVarControls; diff --git a/code/nel/include/nel/sound/background_sound.h b/code/nel/include/nel/sound/background_sound.h index c8e4cc147..24b1c079b 100644 --- a/code/nel/include/nel/sound/background_sound.h +++ b/code/nel/include/nel/sound/background_sound.h @@ -64,7 +64,7 @@ public: /// Associtation clas for storage of sound / filter. struct TSoundInfo { - NLMISC::TStringId SoundName; + NLMISC::CSheetId SoundName; UAudioMixer::TBackgroundFlags Filter; void serial(NLMISC::IStream &s) @@ -73,11 +73,11 @@ public: if (s.isReading()) { s.serial(soundName); - SoundName = NLMISC::CStringMapper::map(soundName); + SoundName = NLMISC::CSheetId(soundName);/*NLMISC::CStringMapper::map(soundName)*/; } else { - soundName = NLMISC::CStringMapper::unmap(SoundName); + soundName = SoundName.toString();/* NLMISC::CStringMapper::unmap(SoundName)*/; s.serial(soundName); } s.serial(Filter); diff --git a/code/nel/include/nel/sound/background_sound_manager.h b/code/nel/include/nel/sound/background_sound_manager.h index 5281e980b..d06533475 100644 --- a/code/nel/include/nel/sound/background_sound_manager.h +++ b/code/nel/include/nel/sound/background_sound_manager.h @@ -229,7 +229,7 @@ private: struct TSoundData { /// The name of the sound. - NLMISC::TStringId SoundName; + NLMISC::CSheetId SoundName; /// The reference to the sound. CSound *Sound; /// A source instance of the sound (may be NULL). @@ -282,7 +282,7 @@ private: struct TFxZone { /// Name of the env fx - NLMISC::TStringId FxName; + NLMISC::CSheetId FxName; /// The vector of points compositing the primitive std::vector Points; /// The min vector of the bounding box @@ -295,7 +295,7 @@ private: /// Container for the fx primitive. std::vector _FxZones; /// Last setted env fx. Used when clustered sound is not active - NLMISC::TStringId _LastEnv; + NLMISC::CSheetId _LastEnv; //@} }; diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index 6a750a724..f29a850d0 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -249,11 +249,11 @@ private: /// The segment of all the audio path. std::vector > _AudioPath; - typedef CHashMap TClusterSoundCont; + typedef CHashMap TClusterSoundCont; /// The current cluster playing source indexed with sound group id TClusterSoundCont _Sources; - typedef CHashMap TStringStringMap; + typedef CHashMap TStringStringMap; /// The sound_group to sound assoc TStringStringMap _SoundGroupToSound; }; diff --git a/code/nel/include/nel/sound/complex_sound.h b/code/nel/include/nel/sound/complex_sound.h index 6b15b7200..55552259a 100644 --- a/code/nel/include/nel/sound/complex_sound.h +++ b/code/nel/include/nel/sound/complex_sound.h @@ -52,8 +52,8 @@ public: const std::vector &getSoundSeq() const { return _SoundSeq;} const std::vector &getDelaySeq() const { return _DelaySeq;} - NLMISC::TStringId getSound(uint index) const { return !_Sounds.empty() ? _Sounds[index%_Sounds.size()]:0;} - const std::vector &getSounds() const { return _Sounds;} + NLMISC::CSheetId getSound(uint index) const { return !_Sounds.empty() ? _Sounds[index%_Sounds.size()]:NLMISC::CSheetId::Unknown;} + const std::vector &getSounds() const { return _Sounds;} uint32 getFadeLength() const { return _XFadeLength;} @@ -87,7 +87,7 @@ private: virtual float getMaxDistance() const; TPATTERN_MODE _PatternMode; - std::vector _Sounds; + std::vector _Sounds; float _TicksPerSeconds; std::vector _SoundSeq; /// Sequence of delay in millisec. diff --git a/code/nel/include/nel/sound/context_sound.h b/code/nel/include/nel/sound/context_sound.h index 09932ca66..aed2fd2f5 100644 --- a/code/nel/include/nel/sound/context_sound.h +++ b/code/nel/include/nel/sound/context_sound.h @@ -133,7 +133,7 @@ class CContextSoundContainer : public IContextSoundContainer virtual void addSound(CSound *sound, const std::string &baseName) { - const std::string &patternName = NLMISC::CStringMapper::unmap(sound->getName()); + const std::string &patternName = sound->getName().toString(); /*NLMISC::CStringMapper::unmap(sound->getName())*/; nlassert(patternName.size() >= baseName.size()); std::string arg; @@ -172,7 +172,7 @@ class CContextSoundContainer : public IContextSoundContainer if (i != NbJoker) return; - nlassertex(i==NbJoker, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); + nlassertex(i==NbJoker, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); sint randomValue = 0; if (UseRandom) @@ -187,7 +187,7 @@ class CContextSoundContainer : public IContextSoundContainer } else if (!arg.empty()) { - nlassertex (!ok, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); + nlassertex (!ok, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); // end of the argument. NLMISC::fromString(arg, randomValue); arg.clear(); @@ -199,13 +199,13 @@ class CContextSoundContainer : public IContextSoundContainer // read the potential last arg. if (!arg.empty()) { - nlassertex (!ok, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); + nlassertex (!ok, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); // end of the argument. NLMISC::fromString(arg, randomValue); arg.clear(); ok = true; } - nlassertex (ok, ("Error while adding sound '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); + nlassertex (ok, ("Error while adding sound '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); } else @@ -221,9 +221,9 @@ class CContextSoundContainer : public IContextSoundContainer if (!ret.second) { typename THashContextSound::iterator it = _ContextSounds.find(cm); - nlassertex(it != _ContextSounds.end(), ("Error wile adding soudn '%s' into context sound container", NLMISC::CStringMapper::unmap(sound->getName()).c_str())); + nlassertex(it != _ContextSounds.end(), ("Error wile adding soudn '%s' into context sound container", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/)); - nlwarning("Sound %s has the same context matcher as the sound %s", NLMISC::CStringMapper::unmap(sound->getName()).c_str(), NLMISC::CStringMapper::unmap(it->second->getName()).c_str()); + nlwarning("Sound %s has the same context matcher as the sound %s", sound->getName().toString().c_str()/*NLMISC::CStringMapper::unmap(sound->getName()).c_str()*/, it->second->getName().toString().c_str() /*NLMISC::CStringMapper::unmap(it->second->getName()).c_str()*/); } } @@ -249,7 +249,7 @@ class CContextSoundContainer : public IContextSoundContainer typename THashContextSound::const_iterator first(_ContextSounds.begin()), last(_ContextSounds.end()); for (; first != last; ++first) { - subsounds.push_back(std::make_pair(NLMISC::CStringMapper::unmap(first->second->getName()), first->second)); + subsounds.push_back(std::make_pair(first->second->getName().toString()/*NLMISC::CStringMapper::unmap(first->second->getName())*/, first->second)); } } diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index e9d4f755c..04b89ee67 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -22,6 +22,7 @@ #include "nel/misc/string_mapper.h" #include "nel/sound/u_source.h" #include "nel/georges/u_form_elm.h" +#include "nel/misc/sheet_id.h" #include namespace NLSOUND { @@ -35,7 +36,7 @@ class CGroupController; /// Sound names hash map //typedef std::hash_map TSoundMap; -typedef CHashMap TSoundMap; +typedef CHashMap TSoundMap; /// Sound names set (for ambiant sounds) typedef std::set TSoundSet; @@ -99,7 +100,7 @@ public: /// Return the length of the sound in ms virtual uint32 getDuration() = 0; /// Return the name (must be unique) - const NLMISC::TStringId& getName() const { return _Name; } + const NLMISC::CSheetId& getName() const { return _Name; } /// Return the min distance (if detailed()) (default 1.0f if not implemented by sound type) virtual float getMinDistance() const { return _MinDist; } @@ -117,11 +118,12 @@ public: virtual void serial(NLMISC::IStream &s); - NLMISC::TStringId getUserVarControler() { return _UserVarControler; } + NLMISC::CSheetId getUserVarControler() { return _UserVarControler; } bool operator<( const CSound& otherSound ) const { - return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name); + //return NLMISC::CStringMapper::unmap(_Name) < NLMISC::CStringMapper::unmap(otherSound._Name); + return _Name.toString() < otherSound._Name.toString(); } protected: @@ -142,9 +144,9 @@ protected: float _MaxDist; // Sound name. - NLMISC::TStringId _Name; + NLMISC::CSheetId _Name; /// An optional user var controler. - NLMISC::TStringId _UserVarControler; + NLMISC::CSheetId _UserVarControler; /// The group controller, always exists, owned by the audio mixer CGroupController *_GroupController; diff --git a/code/nel/include/nel/sound/sound_anim_marker.h b/code/nel/include/nel/sound/sound_anim_marker.h index 53ebd3fa0..12c841df0 100644 --- a/code/nel/include/nel/sound/sound_anim_marker.h +++ b/code/nel/include/nel/sound/sound_anim_marker.h @@ -20,6 +20,7 @@ #include "nel/misc/string_mapper.h" #include "nel/3d/cluster.h" #include "nel/sound/u_source.h" +#include "nel/misc/sheet_id.h" namespace NLMISC @@ -31,7 +32,7 @@ namespace NLMISC namespace NLSOUND { -typedef std::set TMarkerSoundSet; +typedef std::set TMarkerSoundSet; class UAudioMixer; @@ -50,13 +51,13 @@ public: virtual float getTime() const { return _Time; } /** Add a new sound in the set of to-be-played sounds for this marker */ - virtual void addSound(const NLMISC::TStringId &soundName); + virtual void addSound(const NLMISC::CSheetId &soundName); /** Remove a sound */ - virtual void removeSound(const NLMISC::TStringId &soundName); + virtual void removeSound(const NLMISC::CSheetId &soundName); /** Return the set of sounds of this marker */ - virtual void getSounds(std::vector &sounds); + virtual void getSounds(std::vector &sounds); /** Play all the sounds of this marker */ virtual void play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundContext &context); diff --git a/code/nel/include/nel/sound/sound_bank.h b/code/nel/include/nel/sound/sound_bank.h index 9e28d3adc..2d72f9935 100644 --- a/code/nel/include/nel/sound/sound_bank.h +++ b/code/nel/include/nel/sound/sound_bank.h @@ -20,6 +20,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" #include "nel/sound/audio_mixer_user.h" +#include "nel/misc/sheet_id.h" #include namespace NLSOUND { @@ -67,16 +68,16 @@ public: bool isLoaded(); /// Return a sound corresponding to a name. - CSound *getSound(const NLMISC::TStringId &name); + CSound *getSound(const NLMISC::CSheetId &name); /// Return the names of the sounds - void getNames( std::vector &names ); + void getNames( std::vector &names ); /// Return the number of sounds in this bank. uint countSounds(); void addSound(CSound *sound); - void removeSound(const NLMISC::TStringId &name); + void removeSound(const NLMISC::CSheetId &name); private: @@ -85,10 +86,10 @@ private: typedef CHashSet > TSimpleSoundContainer; // typedef std::hash_map TBufferAssocContainer; - typedef CHashMap TBufferAssocContainer; + typedef CHashMap TBufferAssocContainer; /// Sound names hash map // typedef std::hash_map TSoundTable; - typedef CHashMap TSoundTable; + typedef CHashMap TSoundTable; /// Assoc from buffer to sound. Used for sound unloading. TBufferAssocContainer _BufferAssoc; diff --git a/code/nel/include/nel/sound/source_common.h b/code/nel/include/nel/sound/source_common.h index 1180fd68e..12c781ff6 100644 --- a/code/nel/include/nel/sound/source_common.h +++ b/code/nel/include/nel/sound/source_common.h @@ -23,6 +23,7 @@ #include "nel/3d/cluster.h" #include "nel/sound/sound.h" #include "nel/sound/group_controller.h" +#include "nel/misc/sheet_id.h" namespace NLSOUND { @@ -149,7 +150,7 @@ protected: NL3D::CCluster *_Cluster; /// An optional user var controler. - NLMISC::TStringId _UserVarControler; + NLMISC::CSheetId _UserVarControler; /// Group controller for gain CGroupController *_GroupController; diff --git a/code/nel/include/nel/sound/u_audio_mixer.h b/code/nel/include/nel/sound/u_audio_mixer.h index c4702c3f8..fbac4a878 100644 --- a/code/nel/include/nel/sound/u_audio_mixer.h +++ b/code/nel/include/nel/sound/u_audio_mixer.h @@ -19,6 +19,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" +#include "nel/misc/sheet_id.h" #include "nel/sound/u_source.h" #include "nel/sound/u_group_controller.h" #include "nel/ligo/primitive.h" @@ -284,7 +285,7 @@ public: //@} /// Get a TSoundId from a name (returns NULL if not found) - virtual TSoundId getSoundId( const NLMISC::TStringId &name ) = 0; + virtual TSoundId getSoundId( const NLMISC::CSheetId &name ) = 0; /// Gets the group controller for the given group tree path with separator '/', if it doesn't exist yet it will be created. /// Examples: "music", "effects", "dialog", "music/background", "music/loading", "music/player", etcetera @@ -296,7 +297,7 @@ public: * pass a callback function that will be called (if not NULL) just before deleting the spawned * source. */ - virtual USource *createSource(const NLMISC::TStringId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; + virtual USource *createSource(const NLMISC::CSheetId &name, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; /// Add a logical sound source (by sound id). To remove a source, just delete it. See createSource(const char*) virtual USource *createSource(TSoundId id, bool spawn=false, TSpawnEndCallback cb=NULL, void *callbackUserParam = NULL, NL3D::CCluster *cluster = 0, CSoundContext *context = 0, UGroupController *groupController = NULL) = 0; @@ -320,7 +321,7 @@ public: //@{ //@name Statistic and utility methods /// Fill a vector with the names of all loaded sounds. - virtual void getSoundNames( std::vector &names ) const = 0; + virtual void getSoundNames( std::vector &names ) const = 0; /// Return the number of mixing tracks (voices) virtual uint getPolyphony() const = 0; /// Return the number of sources @@ -381,9 +382,9 @@ public: * Binding from user var to sound parameter is done in * one or more georges sheet .user_var_binding. */ - virtual void setUserVar(NLMISC::TStringId varName, float value) =0; + virtual void setUserVar(NLMISC::CSheetId varName, float value) =0; /// Return the current value of a user var. - virtual float getUserVar(NLMISC::TStringId varName) =0; + virtual float getUserVar(NLMISC::CSheetId varName) =0; //@} //@{ diff --git a/code/nel/src/3d/cluster.cpp b/code/nel/src/3d/cluster.cpp index 823b592ac..1b7ab08d7 100644 --- a/code/nel/src/3d/cluster.cpp +++ b/code/nel/src/3d/cluster.cpp @@ -51,7 +51,9 @@ CCluster::CCluster () // map a no fx string _EnvironmentFxId = CStringMapper::map("no fx"); // map a no soundgroup string - _SoundGroupId = CStringMapper::map(""); + _SoundGroupId = NLMISC::CSheetId::Unknown; /*CStringMapper::map("")*/; + nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); + // I am a transform cluster CTransform::setIsCluster(true); @@ -76,18 +78,21 @@ CCluster::~CCluster() void CCluster::setSoundGroup(const std::string &soundGroup) { - _SoundGroupId = CStringMapper::map(soundGroup); + _SoundGroupId = NLMISC::CSheetId(soundGroup);/*CStringMapper::map(soundGroup);*/ + nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); + } -void CCluster::setSoundGroup(const NLMISC::TStringId &soundGroupId) +void CCluster::setSoundGroup(const NLMISC::CSheetId &soundGroupId) { _SoundGroupId = soundGroupId; + nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); } const std::string &CCluster::getSoundGroup() { - return CStringMapper::unmap(_SoundGroupId); + return _SoundGroupId.toString();/*CStringMapper::unmap(_SoundGroupId)*/; } -NLMISC::TStringId CCluster::getSoundGroupId() +NLMISC::CSheetId CCluster::getSoundGroupId() { return _SoundGroupId; } @@ -304,7 +309,8 @@ void CCluster::serial (NLMISC::IStream&f) std::string envFxName; f.serial(soundGroup); - _SoundGroupId = CStringMapper::map(soundGroup); + _SoundGroupId = NLMISC::CSheetId(soundGroup); /*CStringMapper::map(soundGroup)*/; + nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); f.serial(envFxName); if (envFxName == "") @@ -314,7 +320,7 @@ void CCluster::serial (NLMISC::IStream&f) else { // write the sound group - std::string soundGroup = CStringMapper::unmap(_SoundGroupId); + std::string soundGroup = _SoundGroupId.toString();/*CStringMapper::unmap(_SoundGroupId)*/; f.serial(soundGroup); // write the env fx name std::string envFxName = CStringMapper::unmap(_EnvironmentFxId); diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index e2366708a..d53e1d59f 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -43,7 +43,7 @@ CPSSound::CPSSound() : _Gain(1.f), { NL_PS_FUNC(CPSSound_CPSSound) if (CParticleSystem::getSerializeIdentifierFlag()) _Name = std::string("sound"); - _SoundName = NLMISC::CStringMapper::emptyId(); + _SoundName = NLMISC::CSheetId::Unknown /*NLMISC::CStringMapper::emptyId()*/; } // *************************************************************************************************** @@ -265,11 +265,11 @@ void CPSSound::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { std::string soundName; f.serial(soundName); - _SoundName = NLMISC::CStringMapper::map(soundName); + _SoundName = NLMISC::CSheetId(soundName)/*NLMISC::CStringMapper::map(soundName)*/; } else { - std::string soundName = NLMISC::CStringMapper::unmap(_SoundName); + std::string soundName = _SoundName.toString()/*NLMISC::CStringMapper::unmap(_SoundName)*/; f.serial(soundName); } diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 1a6c2d322..a348e57d3 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -23,6 +23,7 @@ #include "nel/misc/command.h" #include "nel/misc/file.h" #include "nel/misc/path.h" +#include "nel/misc/sheet_id.h" #include "nel/georges/u_form_loader.h" #include "nel/georges/u_form_elm.h" @@ -1157,7 +1158,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s) // ****************************************************************** -void CAudioMixerUser::setUserVar(NLMISC::TStringId varName, float value) +void CAudioMixerUser::setUserVar(NLMISC::CSheetId varName, float value) { TUserVarControlsContainer::iterator it(_UserVarControls.find(varName)); if (it != _UserVarControls.end()) @@ -1190,7 +1191,7 @@ void CAudioMixerUser::setUserVar(NLMISC::TStringId varName, float value) // ****************************************************************** -float CAudioMixerUser::getUserVar(NLMISC::TStringId varName) +float CAudioMixerUser::getUserVar(NLMISC::CSheetId varName) { TUserVarControlsContainer::iterator it(_UserVarControls.find(varName)); if (it != _UserVarControls.end()) @@ -1203,7 +1204,7 @@ float CAudioMixerUser::getUserVar(NLMISC::TStringId varName) // ****************************************************************** -void CAudioMixerUser::addUserControledSource(CSourceCommon *source, NLMISC::TStringId varName) +void CAudioMixerUser::addUserControledSource(CSourceCommon *source, NLMISC::CSheetId varName) { TUserVarControlsContainer::iterator it(_UserVarControls.find(varName)); if (it != _UserVarControls.end()) @@ -1227,7 +1228,7 @@ void CAudioMixerUser::addUserControledSource(CSourceCommon *source, NLMISC::TStr // ****************************************************************** -void CAudioMixerUser::removeUserControledSource(CSourceCommon *source, NLMISC::TStringId varName) +void CAudioMixerUser::removeUserControledSource(CSourceCommon *source, NLMISC::CSheetId varName) { TUserVarControlsContainer::iterator it(_UserVarControls.find(varName)); if (it != _UserVarControls.end()) @@ -1780,7 +1781,7 @@ void CAudioMixerUser::update() // ****************************************************************** -TSoundId CAudioMixerUser::getSoundId( const NLMISC::TStringId &name ) +TSoundId CAudioMixerUser::getSoundId( const NLMISC::CSheetId &name ) { return _SoundBank->getSound(name); } @@ -2035,7 +2036,7 @@ retrySound: // ****************************************************************** -USource *CAudioMixerUser::createSource( const NLMISC::TStringId &name, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context, UGroupController *groupController) +USource *CAudioMixerUser::createSource( const NLMISC::CSheetId &name, bool spawn, TSpawnEndCallback cb, void *userParam, NL3D::CCluster *cluster, CSoundContext *context, UGroupController *groupController) { return createSource( getSoundId( name ), spawn, cb, userParam, cluster, context, groupController); } @@ -2162,7 +2163,7 @@ bool CAudioMixerUser::unloadSampleBank(const std::string &name) // ****************************************************************** -void CAudioMixerUser::getSoundNames( std::vector &names ) const +void CAudioMixerUser::getSoundNames( std::vector &names ) const { _SoundBank->getNames(names); } @@ -2767,7 +2768,7 @@ void CAudioMixerUser::addEnvironment(const std::string &environmentName, const I } /// Set the current reverb environment -void CAudioMixerUser::setEnvironment(NLMISC::TStringId environmentName, float roomSize) +void CAudioMixerUser::setEnvironment(NLMISC::CSheetId environmentName, float roomSize) { if (_ReverbEffect) { @@ -2776,7 +2777,7 @@ void CAudioMixerUser::setEnvironment(NLMISC::TStringId environmentName, float ro } /// Get a reverb environment -const IReverbEffect::CEnvironment &CAudioMixerUser::getEnvironment(NLMISC::TStringId environmentName) +const IReverbEffect::CEnvironment &CAudioMixerUser::getEnvironment(NLMISC::CSheetId environmentName) { TEnvironments::iterator it(_Environments.find(environmentName)); if (it == _Environments.end()) diff --git a/code/nel/src/sound/background_sound.cpp b/code/nel/src/sound/background_sound.cpp index 294a18c3f..24f94759f 100644 --- a/code/nel/src/sound/background_sound.cpp +++ b/code/nel/src/sound/background_sound.cpp @@ -84,7 +84,7 @@ void CBackgroundSound::importForm(const std::string& filename, NLGEORGES::UFormE // Read the sound name. std::string soundName; psoundItem->getValueByName(soundName, "Sound"); - sound.SoundName = CStringMapper::map(CFile::getFilenameWithoutExtension(soundName)); + sound.SoundName = NLMISC::CSheetId(CFile::getFilenameWithoutExtension(soundName));/*CStringMapper::map(CFile::getFilenameWithoutExtension(soundName))*/; // Read the environnement flag. @@ -133,7 +133,7 @@ void CBackgroundSound::getSubSoundList(std::vectorgetSoundId(first->SoundName); - subsounds.push_back(make_pair(CStringMapper::unmap(first->SoundName), sound)); + subsounds.push_back(make_pair(first->SoundName.toString()/*CStringMapper::unmap(first->SoundName)*/, sound)); } } diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index b40fff40b..ec4c56b70 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -86,7 +86,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI CAudioMixerUser *mixer = CAudioMixerUser::instance(); TSoundData sd; - sd.SoundName = CStringMapper::map(soundName); + sd.SoundName = /*CStringMapper::map(soundName)*/ NLMISC::CSheetId(soundName); sd.Sound = mixer->getSoundId(sd.SoundName); sd.Source = 0; @@ -133,7 +133,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI } else { - nlwarning ("The sound '%s' can't be loaded", CStringMapper::unmap(sd.SoundName).c_str()); + nlwarning ("The sound '%s' can't be loaded", sd.SoundName.toString().c_str()/*CStringMapper::unmap(sd.SoundName).c_str()*/); } } @@ -465,7 +465,7 @@ void CBackgroundSoundManager::addFxZone(const std::string &fxName, const std::ve { TFxZone fxZone; - fxZone.FxName = CStringMapper::map(fxName); + fxZone.FxName = /*CStringMapper::map(fxName)*/ NLMISC::CSheetId(fxName); fxZone.Points.resize (points.size()); for (uint j=0; jsetEnvironmentFx(first->FxName); + rootCluster->setEnvironmentFx(first->FxName.toString()); } else { @@ -1437,14 +1437,14 @@ void CBackgroundSoundManager::TSoundData::serial(NLMISC::IStream &s) { CAudioMixerUser *mixer = CAudioMixerUser::instance(); s.serial(str); - SoundName = NLMISC::CStringMapper::map(str); + SoundName = /*NLMISC::CStringMapper::map(str)*/ NLMISC::CSheetId(str); Sound = mixer->getSoundId(SoundName); Source = NULL; Selected = false; } else { - s.serial(const_cast(NLMISC::CStringMapper::unmap(SoundName))); + s.serial(const_cast(SoundName.toString()/*NLMISC::CStringMapper::unmap(SoundName)*/)); } s.serial(MinBox); s.serial(MaxBox); @@ -1461,11 +1461,11 @@ void CBackgroundSoundManager::TFxZone::serial(NLMISC::IStream &s) if (s.isReading()) { s.serial(str); - FxName= NLMISC::CStringMapper::map(str); + FxName= NLMISC::CSheetId(str);/*NLMISC::CStringMapper::map(str)*/; } else { - s.serial(const_cast(NLMISC::CStringMapper::unmap(FxName))); + s.serial(const_cast(FxName.toString()/*NLMISC::CStringMapper::unmap(FxName)*/)); } s.serialCont(Points); diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index 3a75ee4f4..20693a277 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -254,10 +254,10 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view TClusterStatusMap::const_iterator first(_AudibleClusters.begin()), last(_AudibleClusters.end()); for (; first != last; ++first ) { - static NLMISC::TStringId NO_SOUND_GROUP = CStringMapper::emptyId(); + static NLMISC::CSheetId NO_SOUND_GROUP = /*CStringMapper::emptyId()*/NLMISC::CSheetId::Unknown; const CClusterSoundStatus &css = first->second; CCluster *cluster = first->first; - NLMISC::TStringId soundGroup; + NLMISC::CSheetId soundGroup; soundGroup = cluster->getSoundGroupId(); @@ -292,7 +292,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view TStringStringMap::iterator it2(_SoundGroupToSound.find(soundGroup)); if (it2 != _SoundGroupToSound.end()) { - NLMISC::TStringId soundName = it2->second; + NLMISC::CSheetId soundName = it2->second; CClusterSound cs; // nldebug("Found the sound [%s] for sound group [%s]", CStringMapper::unmap(soundName).c_str(), CStringMapper::unmap(soundGroup).c_str()); diff --git a/code/nel/src/sound/complex_sound.cpp b/code/nel/src/sound/complex_sound.cpp index fbecbbcf2..292b36f25 100644 --- a/code/nel/src/sound/complex_sound.cpp +++ b/code/nel/src/sound/complex_sound.cpp @@ -19,6 +19,7 @@ #include "nel/misc/path.h" #include "nel/misc/common.h" #include "nel/sound/audio_mixer_user.h" +#include "nel/misc/sheet_id.h" using namespace std; using namespace NLMISC; @@ -63,11 +64,11 @@ void CComplexSound::parseSequence(const std::string &str, std::vector &s void CComplexSound::getSubSoundList(std::vector > &subsounds) const { CAudioMixerUser *mixer = CAudioMixerUser::instance(); - std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); + std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(*first); - subsounds.push_back(make_pair(CStringMapper::unmap(*first), sound)); + subsounds.push_back(make_pair((*first).toString()/*CStringMapper::unmap(*first)*/, sound)); } } @@ -83,7 +84,7 @@ uint32 CComplexSound::getDuration() CAudioMixerUser *mixer = CAudioMixerUser::instance(); vector durations; - std::vector::iterator first(_Sounds.begin()), last(_Sounds.end()); + std::vector::iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { CSound *sound = mixer->getSoundId(*first); @@ -204,7 +205,7 @@ float CComplexSound::getMaxDistance() const CComplexSound *This = const_cast(this); This->_MaxDist = 0.0f; - std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); + std::vector::const_iterator first(_Sounds.begin()), last(_Sounds.end()); for (; first != last; ++first) { @@ -236,7 +237,7 @@ void CComplexSound::serial(NLMISC::IStream &s) { std::string name; s.serial(name); - _Sounds.push_back(CStringMapper::map(name)); + _Sounds.push_back(/*CStringMapper::map(name)*/NLMISC::CSheetId(name)); } } else @@ -245,7 +246,7 @@ void CComplexSound::serial(NLMISC::IStream &s) s.serial(nb); for (uint i=0; igetArrayValue(soundname, i)) { soundname = CFile::getFilenameWithoutExtension(soundname); - _Sounds.push_back(CStringMapper::map(soundname)); + _Sounds.push_back(NLMISC::CSheetId(soundname)/*CStringMapper::map(soundname)*/); } } } diff --git a/code/nel/src/sound/complex_source.cpp b/code/nel/src/sound/complex_source.cpp index 8fad61a53..acaf30f8a 100644 --- a/code/nel/src/sound/complex_source.cpp +++ b/code/nel/src/sound/complex_source.cpp @@ -190,9 +190,9 @@ void CComplexSource::playStuf() case CComplexSound::MODE_ALL_IN_ONE: { // just spanw all the listed source. - const std::vector &sounds = _PatternSound->getSounds(); + const std::vector &sounds = _PatternSound->getSounds(); - std::vector::const_iterator first(sounds.begin()), last(sounds.end()); + std::vector::const_iterator first(sounds.begin()), last(sounds.end()); if (_AllSources.empty()) { @@ -524,7 +524,7 @@ void CComplexSource::onUpdate() else { // no sound after, just set an event at end of current sound to stop the complex sound. - nldebug("Setting last event for sound %s in %u millisec.", CStringMapper::unmap(_Source1->getSound()->getName()).c_str(), _Source1->getSound()->getDuration()); + nldebug("Setting last event for sound %s in %u millisec.", _Source1->getSound()->getName().toString().c_str()/*CStringMapper::unmap(_Source1->getSound()->getName()).c_str()*/, _Source1->getSound()->getDuration()); if (_PatternSound->doFadeOut()) { // set the event to begin fade out. diff --git a/code/nel/src/sound/context_sound.cpp b/code/nel/src/sound/context_sound.cpp index f18ecbed7..a7772276a 100644 --- a/code/nel/src/sound/context_sound.cpp +++ b/code/nel/src/sound/context_sound.cpp @@ -187,7 +187,7 @@ void CContextSound::init() } else { - nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); + nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); fromString(index, contextArgIndex[nbJoker++]); parseArg = false; index = ""; @@ -195,13 +195,13 @@ void CContextSound::init() } else if (*first == 'r') { - nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); + nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); useRandom = true; } } else if (*first == '%') { - nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); + nlassertex(useRandom == false, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); parseArg = true; } } @@ -215,7 +215,7 @@ void CContextSound::init() } else { - nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", CStringMapper::unmap(_Name).c_str())); + nlassertex(nbJoker < SoundContextNbArgs, ("Error will trying to play ContextSound '%s'", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/)); fromString(index, contextArgIndex[nbJoker++]); parseArg = false; } @@ -247,7 +247,7 @@ void CContextSound::init() LM_CASE_CONTAINER_CREATOR(9) LM_CASE_CONTAINER_CREATOR(10) default: - nlwarning("Unsuported number of context argument in context sound '%s'!", CStringMapper::unmap(_Name).c_str()); + nlwarning("Unsuported number of context argument in context sound '%s'!", _Name.toString().c_str()/*CStringMapper::unmap(_Name).c_str()*/); return; } // cleanup macro @@ -257,14 +257,14 @@ void CContextSound::init() // ok, we have the container, now fill it with the sound { - std::vector allSounds; + std::vector allSounds; // CSoundBank::getSoundNames(allSounds); CAudioMixerUser::instance()->getSoundNames(allSounds); - std::vector::iterator first(allSounds.begin()), last(allSounds.end()); + std::vector::iterator first(allSounds.begin()), last(allSounds.end()); for (; first != last; ++first) { - const std::string &soundName = CStringMapper::unmap(*first); + const std::string &soundName = first->toString()/*CStringMapper::unmap(*first)*/; if (soundName.size() > _BaseName.size()) { uint i; diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index b1b644ed2..06bfc2c8a 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -115,7 +115,7 @@ CSound::CSound() : _Looping(false), _MinDist(1.0f), _MaxDist(1000000.0f), - _UserVarControler(CStringMapper::emptyId()), + _UserVarControler(NLMISC::CSheetId::Unknown), _GroupController(NULL) { } @@ -137,11 +137,11 @@ void CSound::serial(NLMISC::IStream &s) { std::string name; s.serial(name); - _Name = CStringMapper::map(name); + _Name = NLMISC::CSheetId(name);//CStringMapper::map(name); } else { - std::string name = CStringMapper::unmap(_Name); + std::string name = _Name.toString();//CStringMapper::unmap(_Name); s.serial(name); } @@ -170,7 +170,7 @@ void CSound::serial(NLMISC::IStream &s) void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root) { // Name - _Name = CStringMapper::map(CFile::getFilenameWithoutExtension(filename)); + _Name = NLMISC::CSheetId(CFile::getFilenameWithoutExtension(filename));//CStringMapper::map(CFile::getFilenameWithoutExtension(filename)); // InternalConeAngle uint32 inner; diff --git a/code/nel/src/sound/sound_anim_marker.cpp b/code/nel/src/sound/sound_anim_marker.cpp index 76d08a1db..e4e2cac1f 100644 --- a/code/nel/src/sound/sound_anim_marker.cpp +++ b/code/nel/src/sound/sound_anim_marker.cpp @@ -41,7 +41,7 @@ void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundC for (; first != last; ++first) { - USource* source = mixer->createSource((*first), true, NULL, NULL, cluster, &context); + USource* source = mixer->createSource(NLMISC::CSheetId(*first), true, NULL, NULL, cluster, &context); if (source != NULL) { source->setRelativeGain(context.RelativeGain); @@ -53,19 +53,19 @@ void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundC // ******************************************************** -void CSoundAnimMarker::addSound(const NLMISC::TStringId& soundName) +void CSoundAnimMarker::addSound(const NLMISC::CSheetId& soundName) { pair inserted; inserted = _Sounds.insert(soundName); if (inserted.second == false) { - nlwarning("Duplicate sound (%s)", CStringMapper::unmap(soundName).c_str()); + nlwarning("Duplicate sound (%s)",/* CStringMapper::unmap(soundName).c_str()*/soundName.toString().c_str()); } } // ******************************************************** -void CSoundAnimMarker::removeSound(const NLMISC::TStringId &soundName) +void CSoundAnimMarker::removeSound(const NLMISC::CSheetId &soundName) { TMarkerSoundSet::iterator iter = _Sounds.find(soundName); if (iter != _Sounds.end()) @@ -74,13 +74,13 @@ void CSoundAnimMarker::removeSound(const NLMISC::TStringId &soundName) } else { - nlwarning("No sound was removed (%s)", CStringMapper::unmap(soundName).c_str()); + nlwarning("No sound was removed (%s)", soundName.toString().c_str()/*CStringMapper::unmap(soundName).c_str()*/); } } // ******************************************************** -void CSoundAnimMarker::getSounds(vector &sounds) +void CSoundAnimMarker::getSounds(vector &sounds) { sounds.insert(sounds.end(), _Sounds.begin(), _Sounds.end()); diff --git a/code/nel/src/sound/sound_animation.cpp b/code/nel/src/sound/sound_animation.cpp index 90ba1c123..ac3c1982d 100644 --- a/code/nel/src/sound/sound_animation.cpp +++ b/code/nel/src/sound/sound_animation.cpp @@ -73,7 +73,7 @@ void CSoundAnimation::save() { // File stream COFile file; - vector sounds; + vector sounds; // Open the file if (!file.open(_Filename.c_str())) @@ -108,11 +108,11 @@ void CSoundAnimation::save() marker->getSounds(sounds); - vector::iterator iter2; + vector::iterator iter2; for (iter2 = sounds.begin(); iter2 != sounds.end(); iter2++) { xmlNodePtr soundNode = xmlNewChild ( markerNode, NULL, (const xmlChar*)"SOUND", NULL ); - xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*) CStringMapper::unmap(*iter2).c_str()); + xmlSetProp (soundNode, (const xmlChar*)"name", (const xmlChar*)iter2->toString().c_str() /*CStringMapper::unmap(*iter2).c_str()*/); } sounds.clear(); @@ -190,7 +190,7 @@ void CSoundAnimation::load() throw NLMISC::Exception("Invalid sound animation marker"); } - marker->addSound(CStringMapper::map(string(name))); + marker->addSound(NLMISC::CSheetId(string(name))/*CStringMapper::map(string(name))*/); xmlFree ((void*)name); diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index dd2076a72..58b06b56a 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -128,7 +128,7 @@ void CSoundBank::addSound(CSound *sound) nlassert(ret.second); } -void CSoundBank::removeSound(const NLMISC::TStringId &name) +void CSoundBank::removeSound(const NLMISC::CSheetId &name) { _Sounds.erase(name); } @@ -258,14 +258,16 @@ public: void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) { // this structure is fill by the loadForm() function and will contain all you need - std::map Container; + //std::map Container; + std::map Container; nlassert(!_Loaded); // Just call the GEORGE::loadFrom method to read all available sounds ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", Container, packedSheetUpdate, false); _Loaded = true; // add all the loaded sound in the sound banks - std::map::iterator first(Container.begin()), last(Container.end()); + //std::map::iterator first(Container.begin()), last(Container.end()); + std::map::iterator first(Container.begin()), last(Container.end()); for (; first != last; ++first) { if (first->second.Sound != 0) @@ -328,7 +330,7 @@ bool CSoundBank::isLoaded() /* * Return a sound sample corresponding to a name. */ -CSound* CSoundBank::getSound(const NLMISC::TStringId &name) +CSound* CSoundBank::getSound(const NLMISC::CSheetId &name) { // Find sound TSoundTable::iterator iter = _Sounds.find(name); @@ -345,7 +347,7 @@ CSound* CSoundBank::getSound(const NLMISC::TStringId &name) /** * Return the names of the sounds */ -void CSoundBank::getNames( std::vector &names ) +void CSoundBank::getNames( std::vector &names ) { TSoundTable::const_iterator iter; for (iter = _Sounds.begin(); iter != _Sounds.end(); ++iter) diff --git a/code/nel/src/sound/source_common.cpp b/code/nel/src/sound/source_common.cpp index 7b27deb03..1049b2372 100644 --- a/code/nel/src/sound/source_common.cpp +++ b/code/nel/src/sound/source_common.cpp @@ -102,7 +102,7 @@ void CSourceCommon::play() _Playing = true; _PlayStart = CTime::getLocalTime(); - if (_UserVarControler != CStringMapper::emptyId()) + if (_UserVarControler != NLMISC::CSheetId::Unknown/*CStringMapper::emptyId()*/) CAudioMixerUser::instance()->addUserControledSource(this, _UserVarControler); } @@ -114,7 +114,7 @@ void CSourceCommon::stop() CAudioMixerUser::instance()->decPlayingSource(); _Playing = false; - if (_UserVarControler != CStringMapper::emptyId()) + if (_UserVarControler != NLMISC::CSheetId::Unknown/*CStringMapper::emptyId()*/) CAudioMixerUser::instance()->removeUserControledSource(this, _UserVarControler); } diff --git a/code/nel/src/sound/stream_file_sound.cpp b/code/nel/src/sound/stream_file_sound.cpp index 44da5a31d..34b121072 100644 --- a/code/nel/src/sound/stream_file_sound.cpp +++ b/code/nel/src/sound/stream_file_sound.cpp @@ -74,9 +74,11 @@ void CStreamFileSound::serial(NLMISC::IStream &s) void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop) { #if !FINAL_VERSION - _Name = NLMISC::CStringMapper::map(std::string(""); + //_Name = NLMISC::CStringMapper::map(std::string(""); + _Name = NLMISC::CSheetId(std::string(""); #else - _Name = NLMISC::CStringMapper::map(""); + //_Name = NLMISC::CStringMapper::map(""); + _Name = NLMISC::CSheetId(""); #endif _ConeInnerAngle = NLMISC::Pi * 2; _ConeOuterAngle = NLMISC::Pi * 2; From f70bdc4032e979c4423286ae69c2af0a53ce1190 Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Sat, 26 May 2012 19:21:19 +0200 Subject: [PATCH 02/39] Changed: #1469 StringId conversion to SheetId for sounds V2 (DOES NOT COMPILE YET) --HG-- branch : gsoc2012-fabien --- code/nel/include/nel/sound/audio_mixer_user.h | 18 +- .../nel/sound/background_sound_manager.h | 4 +- code/nel/include/nel/sound/clustered_sound.h | 5 +- code/nel/include/nel/sound/sound.h | 4 +- code/nel/include/nel/sound/sound_bank.h | 4 +- code/nel/include/nel/sound/source_common.h | 2 +- code/nel/include/nel/sound/u_audio_mixer.h | 4 +- code/nel/samples/sound/sound_sources/main.cpp | 2 +- .../samples/sound/stream_file/stream_file.cpp | 2 +- .../stream_ogg_vorbis/stream_ogg_vorbis.cpp | 2 +- code/nel/src/sound/audio_mixer_user.cpp | 22 +- .../src/sound/background_sound_manager.cpp | 8 +- code/nel/src/sound/clustered_sound.cpp | 2 +- code/nel/src/sound/sound.cpp | 2 +- code/nel/src/sound/sound_bank.cpp | 4 +- code/nel/src/sound/source_common.cpp | 4 +- code/ryzom/client/src/client_cfg.cpp | 2 +- code/ryzom/client/src/commands.cpp | 4 +- code/ryzom/client/src/sound_manager.cpp | 12 +- code/ryzom/client/src/sound_manager.h | 7 +- .../newbieland/urban_newbieland.primitive | 642 +++++++++++++++++- code/ryzom/server/frontend_service.cfg | 2 +- code/ryzom/server/shard_start_cmake.bat | 2 +- 23 files changed, 686 insertions(+), 74 deletions(-) diff --git a/code/nel/include/nel/sound/audio_mixer_user.h b/code/nel/include/nel/sound/audio_mixer_user.h index 48f07d8e2..a68eae065 100644 --- a/code/nel/include/nel/sound/audio_mixer_user.h +++ b/code/nel/include/nel/sound/audio_mixer_user.h @@ -93,9 +93,9 @@ public: //@{ /// @name IStringMapperProvider implementation /// map a string - NLMISC::CSheetId map(const std::string &str) { return NLMISC::CSheetId(str);/*NLMISC::CStringMapper::map(str);*/} + NLMISC::TStringId map(const std::string &str) { return NLMISC::CStringMapper::map(str);} /// unmap a string - const std::string &unmap(const NLMISC::CSheetId &stringId) { return stringId.toString();/*NLMISC::CStringMapper::unmap(stringId);*/} + const std::string &unmap(const NLMISC::TStringId &stringId) { return NLMISC::CStringMapper::unmap(stringId);} //@} @@ -321,8 +321,8 @@ public: void incPlayingSourceMuted() { ++_PlayingSourcesMuted; }; void decPlayingSourceMuted() { --_PlayingSourcesMuted; }; - void setUserVar(NLMISC::CSheetId varName, float value); - float getUserVar(NLMISC::CSheetId varName); + void setUserVar(NLMISC::TStringId varName, float value); + float getUserVar(NLMISC::TStringId varName); // music virtual bool playMusic(const std::string &fileName, uint xFadeTime= 0, bool async= true, bool loop=true); @@ -352,7 +352,7 @@ public: /// Add a reverb environment. void addEnvironment(const std::string &name, const IReverbEffect::CEnvironment &environment); /// Set the current reverb environment. - void setEnvironment(NLMISC::CSheetId environmentName, float roomSize); + void setEnvironment(NLMISC::TStringId environmentName, float roomSize); /// Set the current reverb environment. inline void setEnvironment(const std::string &environmentName, float roomSize) { setEnvironment(NLMISC::CStringMapper::map(environmentName), roomSize); } /// Get a reverb environment @@ -410,8 +410,8 @@ public: /// Read all user controled var sheets void initUserVar(); - void addUserControledSource(CSourceCommon *source, NLMISC::CSheetId varName); - void removeUserControledSource(CSourceCommon *source, NLMISC::CSheetId varName); + void addUserControledSource(CSourceCommon *source, NLMISC::TStringId varName); + void removeUserControledSource(CSourceCommon *source, NLMISC::TStringId varName); virtual void startDriverBench(); @@ -441,7 +441,7 @@ private: struct CControledSources { /// The user var name - NLMISC::CSheetId Name; + NLMISC::TStringId Name; /// Witch parameter to control TControledParamId ParamId; /// The controled sounds names. @@ -473,7 +473,7 @@ protected: /// Fill a vector of position and mute flag for all playing sound source. virtual void getPlayingSoundsPos(bool virtualPos, std::vector > &pos); - typedef CHashMap TUserVarControlsContainer; + typedef CHashMap TUserVarControlsContainer; /// Container for all user controler and currently controled playing source TUserVarControlsContainer _UserVarControls; diff --git a/code/nel/include/nel/sound/background_sound_manager.h b/code/nel/include/nel/sound/background_sound_manager.h index d06533475..b1405634c 100644 --- a/code/nel/include/nel/sound/background_sound_manager.h +++ b/code/nel/include/nel/sound/background_sound_manager.h @@ -282,7 +282,7 @@ private: struct TFxZone { /// Name of the env fx - NLMISC::CSheetId FxName; + NLMISC::TStringId FxName; /// The vector of points compositing the primitive std::vector Points; /// The min vector of the bounding box @@ -295,7 +295,7 @@ private: /// Container for the fx primitive. std::vector _FxZones; /// Last setted env fx. Used when clustered sound is not active - NLMISC::CSheetId _LastEnv; + NLMISC::TStringId _LastEnv; //@} }; diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index f29a850d0..4de54a3b8 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -249,11 +249,12 @@ private: /// The segment of all the audio path. std::vector > _AudioPath; - typedef CHashMap TClusterSoundCont; + typedef CHashMap TClusterSoundCont; /// The current cluster playing source indexed with sound group id TClusterSoundCont _Sources; - typedef CHashMap TStringStringMap; + //typedef CHashMap TStringStringMap; + typedef CHashMap TStringStringMap; /// The sound_group to sound assoc TStringStringMap _SoundGroupToSound; }; diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index 04b89ee67..d50266e3f 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -118,7 +118,7 @@ public: virtual void serial(NLMISC::IStream &s); - NLMISC::CSheetId getUserVarControler() { return _UserVarControler; } + NLMISC::TStringId getUserVarControler() { return _UserVarControler; } bool operator<( const CSound& otherSound ) const { @@ -146,7 +146,7 @@ protected: // Sound name. NLMISC::CSheetId _Name; /// An optional user var controler. - NLMISC::CSheetId _UserVarControler; + NLMISC::TStringId _UserVarControler; /// The group controller, always exists, owned by the audio mixer CGroupController *_GroupController; diff --git a/code/nel/include/nel/sound/sound_bank.h b/code/nel/include/nel/sound/sound_bank.h index 2d72f9935..d7cdf90d0 100644 --- a/code/nel/include/nel/sound/sound_bank.h +++ b/code/nel/include/nel/sound/sound_bank.h @@ -86,10 +86,10 @@ private: typedef CHashSet > TSimpleSoundContainer; // typedef std::hash_map TBufferAssocContainer; - typedef CHashMap TBufferAssocContainer; + typedef CHashMap TBufferAssocContainer; /// Sound names hash map // typedef std::hash_map TSoundTable; - typedef CHashMap TSoundTable; + typedef CHashMap TSoundTable; /// Assoc from buffer to sound. Used for sound unloading. TBufferAssocContainer _BufferAssoc; diff --git a/code/nel/include/nel/sound/source_common.h b/code/nel/include/nel/sound/source_common.h index 12c781ff6..4cc633957 100644 --- a/code/nel/include/nel/sound/source_common.h +++ b/code/nel/include/nel/sound/source_common.h @@ -150,7 +150,7 @@ protected: NL3D::CCluster *_Cluster; /// An optional user var controler. - NLMISC::CSheetId _UserVarControler; + NLMISC::TStringId _UserVarControler; /// Group controller for gain CGroupController *_GroupController; diff --git a/code/nel/include/nel/sound/u_audio_mixer.h b/code/nel/include/nel/sound/u_audio_mixer.h index fbac4a878..142ce7475 100644 --- a/code/nel/include/nel/sound/u_audio_mixer.h +++ b/code/nel/include/nel/sound/u_audio_mixer.h @@ -382,9 +382,9 @@ public: * Binding from user var to sound parameter is done in * one or more georges sheet .user_var_binding. */ - virtual void setUserVar(NLMISC::CSheetId varName, float value) =0; + virtual void setUserVar(NLMISC::TStringId varName, float value) =0; /// Return the current value of a user var. - virtual float getUserVar(NLMISC::CSheetId varName) =0; + virtual float getUserVar(NLMISC::TStringId varName) =0; //@} //@{ diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index fb6753f63..7dc8ecc9b 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -100,7 +100,7 @@ USource *OnAddSource( const char *name, float x, float y, float z ) /* * Create a source with sound 'name', and set some of its initial properties, if successful */ - USource *source = AudioMixer->createSource( CStringMapper::map(name) ); + USource *source = AudioMixer->createSource( /*CStringMapper::map(name)*/ CSheetId(name) ); if ( source != NULL ) { source->setPos( CVector(x,y,z) ); diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp index 06e768625..ed052e8b8 100644 --- a/code/nel/samples/sound/stream_file/stream_file.cpp +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -97,7 +97,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - s_Source = s_AudioMixer->createSource(CStringMapper::map("stream_file")); + s_Source = s_AudioMixer->createSource(/*CStringMapper::map("stream_file")*/ CSheetId("stream_file")); nlassert(s_Source); s_StreamFileSource = dynamic_cast(s_Source); nlassert(s_StreamFileSource); diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index c145d6972..fabb93c08 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -87,7 +87,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - USource *source = s_AudioMixer->createSource(CStringMapper::map("default_stream")); + USource *source = s_AudioMixer->createSource(CSheetId("default_stream")/*CStringMapper::map("default_stream")*/); nlassert(source); s_StreamSource = dynamic_cast(source); nlassert(s_StreamSource); diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index a348e57d3..4563ac039 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -1052,7 +1052,7 @@ public: items->getArrayValue(soundName, i); soundName = soundName.substr(0, soundName.find(".sound")); - cs.SoundNames.push_back(CStringMapper::map(soundName)); + cs.SoundNames.push_back(CSheetId(soundName)/*CStringMapper::map(soundName)*/); } if (!cs.SoundNames.empty()) @@ -1102,7 +1102,7 @@ void CAudioMixerUser::initUserVar() TUserVarControlsContainer::iterator first(_UserVarControls.begin()), last(_UserVarControls.end()); for(; first != last; ++first) { - std::vector::iterator first2(first->second.SoundNames.begin()), last2(first->second.SoundNames.end()); + std::vector::iterator first2(first->second.SoundNames.begin()), last2(first->second.SoundNames.end()); for (; first2 != last2; ++first2) { CSound *sound = getSoundId(*first2); @@ -1133,7 +1133,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s) for (uint i=0; igetName()).c_str()); + nlwarning("The sound %s contain an infinite recursion !", id->getName().toString()/*CStringMapper::unmap(id->getName()).c_str()*/); return NULL; } @@ -2768,7 +2768,7 @@ void CAudioMixerUser::addEnvironment(const std::string &environmentName, const I } /// Set the current reverb environment -void CAudioMixerUser::setEnvironment(NLMISC::CSheetId environmentName, float roomSize) +void CAudioMixerUser::setEnvironment(NLMISC::TStringId environmentName, float roomSize) { if (_ReverbEffect) { @@ -2777,7 +2777,7 @@ void CAudioMixerUser::setEnvironment(NLMISC::CSheetId environmentName, float roo } /// Get a reverb environment -const IReverbEffect::CEnvironment &CAudioMixerUser::getEnvironment(NLMISC::CSheetId environmentName) +const IReverbEffect::CEnvironment &CAudioMixerUser::getEnvironment(NLMISC::TStringId environmentName) { TEnvironments::iterator it(_Environments.find(environmentName)); if (it == _Environments.end()) diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index ec4c56b70..ab05ab548 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -465,7 +465,7 @@ void CBackgroundSoundManager::addFxZone(const std::string &fxName, const std::ve { TFxZone fxZone; - fxZone.FxName = /*CStringMapper::map(fxName)*/ NLMISC::CSheetId(fxName); + fxZone.FxName = CStringMapper::map(fxName); fxZone.Points.resize (points.size()); for (uint j=0; jsetEnvironmentFx(first->FxName.toString()); + rootCluster->setEnvironmentFx(first->FxName); } else { @@ -1461,11 +1461,11 @@ void CBackgroundSoundManager::TFxZone::serial(NLMISC::IStream &s) if (s.isReading()) { s.serial(str); - FxName= NLMISC::CSheetId(str);/*NLMISC::CStringMapper::map(str)*/; + FxName= NLMISC::CStringMapper::map(str); } else { - s.serial(const_cast(FxName.toString()/*NLMISC::CStringMapper::unmap(FxName)*/)); + s.serial(const_cast(NLMISC::CStringMapper::unmap(FxName))); } s.serialCont(Points); diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index 20693a277..a64e24af4 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -292,7 +292,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view TStringStringMap::iterator it2(_SoundGroupToSound.find(soundGroup)); if (it2 != _SoundGroupToSound.end()) { - NLMISC::CSheetId soundName = it2->second; + NLMISC::TStringId soundName = it2->second; CClusterSound cs; // nldebug("Found the sound [%s] for sound group [%s]", CStringMapper::unmap(soundName).c_str(), CStringMapper::unmap(soundGroup).c_str()); diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index 06bfc2c8a..18425bb63 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -115,7 +115,7 @@ CSound::CSound() : _Looping(false), _MinDist(1.0f), _MaxDist(1000000.0f), - _UserVarControler(NLMISC::CSheetId::Unknown), + _UserVarControler(CStringMapper::emptyId()), _GroupController(NULL) { } diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 58b06b56a..859ee9df3 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -152,10 +152,10 @@ public: {} // load the values using the george sheet (called by GEORGE::loadForm) - void readGeorges (const NLMISC::CSmartPtr &form, const std::string &name) + void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &name) { // just call the sound creation method with the xml form. - Sound = CSound::createSound(name, form->getRootNode()); + Sound = CSound::createSound(name.toString(), form->getRootNode()); // success ? // if (_Sound != 0) diff --git a/code/nel/src/sound/source_common.cpp b/code/nel/src/sound/source_common.cpp index 1049b2372..7b27deb03 100644 --- a/code/nel/src/sound/source_common.cpp +++ b/code/nel/src/sound/source_common.cpp @@ -102,7 +102,7 @@ void CSourceCommon::play() _Playing = true; _PlayStart = CTime::getLocalTime(); - if (_UserVarControler != NLMISC::CSheetId::Unknown/*CStringMapper::emptyId()*/) + if (_UserVarControler != CStringMapper::emptyId()) CAudioMixerUser::instance()->addUserControledSource(this, _UserVarControler); } @@ -114,7 +114,7 @@ void CSourceCommon::stop() CAudioMixerUser::instance()->decPlayingSource(); _Playing = false; - if (_UserVarControler != NLMISC::CSheetId::Unknown/*CStringMapper::emptyId()*/) + if (_UserVarControler != CStringMapper::emptyId()) CAudioMixerUser::instance()->removeUserControledSource(this, _UserVarControler); } diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index 081bc3ad5..ec2ce131a 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -419,7 +419,7 @@ CClientConfig::CClientConfig() // only force patching under Windows by default #ifdef NL_OS_WINDOWS - PatchWanted = true; + PatchWanted = false;//true; #else PatchWanted = false; #endif diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index f62d8f245..84c9a9ec5 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -5055,14 +5055,14 @@ NLMISC_COMMAND(reloadFogMaps, "Force to reload all the fog maps", "<>") NLMISC_COMMAND(dumpSounds, "Dump names of all loaded sound", "<>") { if (!args.empty()) return false; - std::vector sounds; + std::vector sounds; extern CSoundManager *SoundMngr; if (!SoundMngr) return false; if (!SoundMngr->getMixer()) return false; SoundMngr->getMixer()->getSoundNames(sounds); for(uint k = 0; k < sounds.size(); ++k) { - nlinfo(NLMISC::CStringMapper::unmap(sounds[k]).c_str()); + nlinfo(sounds[k].toString()/*NLMISC::CStringMapper::unmap(sounds[k])*/.c_str()); } return true; } diff --git a/code/ryzom/client/src/sound_manager.cpp b/code/ryzom/client/src/sound_manager.cpp index 4d8827875..948a13a51 100644 --- a/code/ryzom/client/src/sound_manager.cpp +++ b/code/ryzom/client/src/sound_manager.cpp @@ -624,7 +624,7 @@ void CSoundManager::init(IProgressCallback *progressCallBack) // add a new source to the world, attached to the specified entity // return 0 if creation failed, sound id if creation was successful //----------------------------------------------- -CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play, bool loop, const CEntityId &id) +CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::CSheetId &soundName, const NLMISC::CVector &position, bool play, bool loop, const CEntityId &id) { uint32 retValue = 0; @@ -634,7 +634,7 @@ CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::TStringId &soun // If the source is valid. if(pSource == 0) { - nlwarning("Sound '%s' not found !", CStringMapper::unmap(soundName).c_str()); + nlwarning("Sound '%s' not found !", /*CStringMapper::unmap(soundName).c_str()*/soundName.toString().c_str()); return retValue; } @@ -672,7 +672,7 @@ CSoundManager::TSourceId CSoundManager::addSource( const NLMISC::TStringId &soun // spawn a new source to the world // return false if creation failed, true if creation was successful //----------------------------------------------- -bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, CSoundContext &context) +bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, CSoundContext &context) { if (!_PlaySound) return false; @@ -683,7 +683,7 @@ bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, CSoundContex // If the source is valid. if(pSource == 0) { - nlwarning("Sound '%s' not found !", soundName); + nlwarning("Sound '%s' not found !", soundName.toString().c_str()); return false; } @@ -702,7 +702,7 @@ bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, CSoundContex // spawn a new source to the world // return false if creation failed, true if creation was successful //----------------------------------------------- -bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, const NLMISC::CVector &position) +bool CSoundManager::spawnSource(const NLMISC::CSheetId &soundName, const NLMISC::CVector &position) { if (!_PlaySound) return false; @@ -712,7 +712,7 @@ bool CSoundManager::spawnSource(const NLMISC::TStringId &soundName, const NLMISC // If the source is valid. if(pSource == 0) { - nlwarning("Sound '%s' not found !", CStringMapper::unmap(soundName).c_str ()); + nlwarning("Sound '%s' not found !", /*CStringMapper::unmap(soundName).c_str ()*/soundName.toString().c_str()); return false; } diff --git a/code/ryzom/client/src/sound_manager.h b/code/ryzom/client/src/sound_manager.h index 80401ea57..e4981055f 100644 --- a/code/ryzom/client/src/sound_manager.h +++ b/code/ryzom/client/src/sound_manager.h @@ -32,6 +32,7 @@ // sound #include "nel/sound/u_audio_mixer.h" #include "nel/sound/u_listener.h" +#include "nel/misc/sheet_id.h" extern class CSoundManager *SoundMngr; @@ -88,13 +89,13 @@ public: /// Return the audio mixer instance pointer. NLSOUND::UAudioMixer *getMixer(); - TSourceId addSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position, bool play = true , bool loop = false, const NLMISC::CEntityId &id = NLMISC::CEntityId::Unknown ); + TSourceId addSource( const NLMISC::CSheetId &soundName, const NLMISC::CVector &position, bool play = true , bool loop = false, const NLMISC::CEntityId &id = NLMISC::CEntityId::Unknown ); /// spawn a new source to the world but sound manager don't keep any link and the sound will be automatically deleted when finnished - bool spawnSource (const NLMISC::TStringId &soundName, NLSOUND::CSoundContext &context); + bool spawnSource (const NLMISC::CSheetId &soundName, NLSOUND::CSoundContext &context); /// spawn a new source to the world but sound manager don't keep any link and the sound will be automatically deleted when finnished - bool spawnSource( const NLMISC::TStringId &soundName, const NLMISC::CVector &position ); + bool spawnSource( const NLMISC::CSheetId &soundName, const NLMISC::CVector &position ); /** * remove a source diff --git a/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive b/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive index 0aa00b3bb..42cd70726 100644 --- a/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive +++ b/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive @@ -1,7 +1,7 @@ - + class @@ -126,6 +126,10 @@ #mission tags and pre-requisites replayable solo + mission_category : Killing + player_replay_timer : 10 + global_replay_timer : 10 + mission_icon : tets #Variables declaration decl : bot : giver @@ -138,7 +142,7 @@ mission_title : WELCOME_RYZOM_CORE_TITLE mission_desc : WELCOME_RYZOM_CORE_DESC # step_4 - kill_fauna : chdfa1 3 + kill_fauna : chdfa1 1 recv_money : 10000 @@ -154,6 +158,157 @@ + + + class + mission + + + name + HUNTING_GROUNDS + + + script + # script generated from 'urban_newbieland.primitive' + + #mission tags and pre-requisites + replayable + guild + mission_category : Killing + player_replay_timer : 10 + global_replay_timer : 10 + mission_icon : test + + #Variables declaration + decl : bot : giver + decl : bot : player + decl : bot : chiang_the_strong + + #pre-requisites + req_guild + req_grade : Leader + + #script + mission_title : WELCOME_RYZOM_CORE_DESC + mission_desc : WELCOME_RYZOM_CORE_TITLE + # step_4 + spawn_mission : WELCOME_RYZOM_CORE : chiang_the_strong : guild + set_obj : MIS_DO_MISSION + mission : WELCOME_RYZOM_CORE 2 + kill_fauna : chdfa1 2 + recv_money : 100000 + recv_money : 20: guild + + + + + + class + alias + + + name + alias + + + + + + class + mission + + + name + GUILD_MISSION + + + script + # script generated from 'guild_missions.primitive' + + #mission tags and pre-requisites + replayable + guild + mission_category : Killing + + #Variables declaration + decl : bot : giver + decl : bot : player + decl : bot : chiang_the_strong + + #pre-requisites + req_guild + req_grade : Leader + + #script + mission_title : GUILD_MISSION_TITLE + mission_desc : GUILD_MISSION_DESC + # step + spawn_mission : SOLO_GUILD_MISSION : chiang_the_strong : guild + set_obj : MIS_DO_MISSION + mission : SOLO_GUILD_MISSION 2 + kill_fauna : chdfa1 2 + recv_money : 100: guild + recv_money : 50 + + + + + + class + alias + + + name + alias + + + + + + class + mission + + + name + SOLO_GUILD_MISSION + + + script + # script generated from 'guild_missions.primitive' + + #mission tags and pre-requisites + replayable + solo + mission_category : Killing + not_proposed + + #Variables declaration + decl : bot : giver + decl : bot : player + decl : bot : chiang_the_strong + + #pre-requisites + + #script + mission_title : SOLO_GUILD_MISSION_TITLE + mission_desc : SOLO_GUILD_MISSION_DESC + # step + kill_fauna : chdfa1 1 + recv_money : 20 + + + + + + class + alias + + + name + alias + + + @@ -317,6 +472,46 @@ + + + + chat_parameters + shop:guild_creator + menu: MENU_WHOAMI WHOAMI_GUILD_CLERK + + + class + npc_bot + + + equipment + CU: 4 + CL: 4 + + + is_stuck + true + + + name + creator + + + sheet_client + fyhc3old + + + + + class + alias + + + name + alias + + + @@ -396,19 +591,8 @@ chat_parameters - shop : NEWBIELAND_LARMOR_ALL - item : icmalb.sitem 10 - item : icmalb.sitem 20 - item : icmalb.sitem 50 - item : icfalb.sitem 10 - item : icfalb.sitem 20 - item : icfalb.sitem 50 - item : ictalb.sitem 10 - item : ictalb.sitem 20 - item : ictalb.sitem 50 - item : iczalb.sitem 10 - item : iczalb.sitem 20 - item : iczalb.sitem 50 + shop:guild_creator + menu: MENU_WHOAMI WHOAMI_GUILD_CLERK class @@ -444,6 +628,119 @@ + + + class + npc_folder + + + name + Guild creator + + + + + class + alias + + + name + alias + + + + + class + npc_zone + + + name + Npc Zone + + + + + class + alias + + + name + alias + + + + + bot_sheet_client + maha2 + + + class + npc_group + + + name + Group + + + + class + npc_group_parameters + + + name + parameters + + + + + + class + alias + + + name + alias + + + + + + chat_parameters + shop:guild_creator + menu: MENU_WHOAMI WHOAMI_GUILD_CLERK + + + class + npc_bot + + + equipment + CU: 4 + CL: 4 + + + name + guild_creator + + + sheet_client + fyhc3old + + + + + class + alias + + + name + alias + + + + + + @@ -455,14 +752,38 @@ missions_editor + + audience + solo + + + auto_remove_from_journal + false + + + automatic + false + class mission_tree + + fail_if_inventory_is_full + false + giver_primitive urban_newbieland.primitive + + global_replay_timer + 10 + + + mission_category + Killing + mission_description WELCOME_RYZOM_CORE_DESC @@ -471,10 +792,18 @@ mission_giver $givervar@fullname$ + + mission_icon + tets + mission_title WELCOME_RYZOM_CORE_TITLE + + mono_instance + false + name WELCOME_RYZOM_CORE @@ -483,10 +812,34 @@ need_validation false + + non_abandonnable + false + + + not_in_journal + false + + + not_proposed + false + + + phrase_auto_menu + TEST + + + player_replay_timer + 10 + replayable true + + run_only_once + false + class @@ -571,7 +924,7 @@ fauna/quantity - chdfa1 3 + chdfa1 1 @@ -597,6 +950,263 @@ + + + audience + guild + + + auto_remove_from_journal + false + + + automatic + false + + + class + mission_tree + + + fail_if_inventory_is_full + false + + + giver_primitive + urban_newbieland.primitive + + + global_replay_timer + 10 + + + mission_category + Killing + + + mission_description + WELCOME_RYZOM_CORE_TITLE + + + mission_giver + $givervar@fullname$ + + + mission_icon + test + + + mission_title + WELCOME_RYZOM_CORE_DESC + + + mono_instance + false + + + name + HUNTING_GROUNDS + + + need_validation + false + + + non_abandonnable + false + + + not_in_journal + false + + + not_proposed + false + + + phrase_auto_menu + TEST + + + player_replay_timer + 10 + + + replayable + true + + + run_only_once + false + + + + class + variables + + + name + variables + + + + class + var_npc + + + npc_function + fct_ranger_leader + + + npc_name + chiang_the_strong + + + var_name + givervar + + + + + + class + pre_requisite + + + name + pre_requisite + + + require_guild_grade + Leader + + + require_guild_membership + true + + + + + + class + alias + + + name + alias + + + + + class + step + + + name + step_4 + + + + class + actions + + + name + pre_actions + + + + class + spawn_mission + + + giver_name + chiang_the_strong + + + guild + true + + + mission_name + WELCOME_RYZOM_CORE + + + + + + class + mission_objectives + + + name + objectives + + + + class + do_mission + + + mission_names + WELCOME_RYZOM_CORE 2 + + + overload_objective + MIS_DO_MISSION + + + + + class + kill + + + fauna/quantity + chdfa1 2 + + + name + kill chdfa1 2 + + + + + + class + actions + + + name + post_actions + + + + amount + 100000 + + + class + recv_money + + + + + amount + 20 + + + class + recv_money + + + guild + true + + + + + diff --git a/code/ryzom/server/frontend_service.cfg b/code/ryzom/server/frontend_service.cfg index c9392bd51..a73c02316 100644 --- a/code/ryzom/server/frontend_service.cfg +++ b/code/ryzom/server/frontend_service.cfg @@ -6,7 +6,7 @@ BandwidthRatio = 1; FSUDPPort = 47851; -FSListenHost = "open.ryzom.com"; +FSListenHost = "192.168.1.112"; #include "frontend_service_default.cfg" diff --git a/code/ryzom/server/shard_start_cmake.bat b/code/ryzom/server/shard_start_cmake.bat index 943a0b5f3..9d68b5272 100644 --- a/code/ryzom/server/shard_start_cmake.bat +++ b/code/ryzom/server/shard_start_cmake.bat @@ -3,7 +3,7 @@ REM This script will start all the services with good parameters REM set MODE=Debug -set MODE=..\..\build\bin\Release +set MODE=..\..\build\bin\Debug rem AS start %MODE%\ryzom_admin_service.exe --fulladminname=admin_executor_service --shortadminname=AES From a55297c29a190bd8a2944e6f5395cf21e3d9c28f Mon Sep 17 00:00:00 2001 From: Fabien_HENON Date: Sat, 26 May 2012 23:40:27 +0200 Subject: [PATCH 03/39] Changed: #1469 StringId conversion to CSheetId for sounds --HG-- branch : gsoc2012-fabien --- code/nel/include/nel/sound/clustered_sound.h | 4 ++-- code/nel/src/sound/audio_mixer_user.cpp | 2 +- code/nel/src/sound/clustered_sound.cpp | 12 ++++++------ code/ryzom/client/src/connection.cpp | 3 ++- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index 4de54a3b8..4e488dcc6 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -253,8 +253,8 @@ private: /// The current cluster playing source indexed with sound group id TClusterSoundCont _Sources; - //typedef CHashMap TStringStringMap; - typedef CHashMap TStringStringMap; + typedef CHashMap TStringStringMap; + //typedef CHashMap TStringStringMap; /// The sound_group to sound assoc TStringStringMap _SoundGroupToSound; }; diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 4563ac039..b1f10cbe6 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -1895,7 +1895,7 @@ retrySound: if (invalid) { - nlwarning("The sound %s contain an infinite recursion !", id->getName().toString()/*CStringMapper::unmap(id->getName()).c_str()*/); + nlwarning("The sound %s contain an infinite recursion !", id->getName().toString().c_str()/*CStringMapper::unmap(id->getName()).c_str()*/); return NULL; } diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index a64e24af4..d860e53d4 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -70,7 +70,7 @@ float EAX_MATERIAL_PARAM[] = class CSoundGroupSerializer { public: - std::vector > _SoundGroupAssoc; + std::vector > _SoundGroupAssoc; // load the values using the george sheet (called by GEORGE::loadForm) void readGeorges (const NLMISC::CSmartPtr &form, const std::string &/* name */) @@ -103,7 +103,7 @@ public: sound = sound.substr(0, n); } - _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CStringMapper::map(sound))); + _SoundGroupAssoc.push_back(make_pair(CSheetId(soundGroup), CSheetId(sound) /*CStringMapper::map(soundGroup), CStringMapper::map(sound)*/)); } } catch(...) @@ -131,15 +131,15 @@ public: s.serial(soundGroup); s.serial(sound); - _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CStringMapper::map(sound))); + _SoundGroupAssoc.push_back(make_pair(CSheetId(soundGroup), CSheetId(sound) /*CStringMapper::map(soundGroup), CStringMapper::map(sound)*/)); } else { std::string soundGroup; std::string sound; - soundGroup = CStringMapper::unmap(_SoundGroupAssoc[i].first); - sound = CStringMapper::unmap(_SoundGroupAssoc[i].second); + soundGroup = _SoundGroupAssoc[i].first.toString();// CStringMapper::unmap(_SoundGroupAssoc[i].first); + sound = _SoundGroupAssoc[i].second.toString(); //CStringMapper::unmap(_SoundGroupAssoc[i].second); s.serial(soundGroup); s.serial(sound); @@ -292,7 +292,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view TStringStringMap::iterator it2(_SoundGroupToSound.find(soundGroup)); if (it2 != _SoundGroupToSound.end()) { - NLMISC::TStringId soundName = it2->second; + NLMISC::CSheetId soundName = it2->second; CClusterSound cs; // nldebug("Found the sound [%s] for sound group [%s]", CStringMapper::unmap(soundName).c_str(), CStringMapper::unmap(soundGroup).c_str()); diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 32962cd93..75a87ce6b 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2006,7 +2006,8 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { string sName = getParam(Params, "name"); - TStringId id = CStringMapper::map(sName); + //TStringId id = CStringMapper::map(sName); + CSheetId id = CSheetId(sName); if (SoundMngr != NULL) SoundMngr->spawnSource(id,CVector(0,0,0)); } From 35503d03e50564f84d1b2d520eb8e1974b728352 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 14:53:11 +0200 Subject: [PATCH 04/39] Added: Missing implementation of initWithoutSheet to use CSheetId without a sheet_id.bin, required for leveldesign and build tools --HG-- branch : sound_dev --- code/nel/include/nel/misc/sheet_id.h | 10 +++ code/nel/src/misc/sheet_id.cpp | 100 ++++++++++++++++++++++++++- 2 files changed, 108 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/misc/sheet_id.h b/code/nel/include/nel/misc/sheet_id.h index 0edb2952d..9c13b6189 100644 --- a/code/nel/include/nel/misc/sheet_id.h +++ b/code/nel/include/nel/misc/sheet_id.h @@ -141,6 +141,7 @@ public : * Serial */ void serial(NLMISC::IStream &f) throw(NLMISC::EStream); + void serialString(NLMISC::IStream &f, const std::string &defaultType = "") throw(NLMISC::EStream); /** * Display the list of valid sheet ids with their associated file names @@ -221,7 +222,16 @@ private : static void loadSheetAlias (); static void cbFileChange (const std::string &filename); + /** + * When initialized without sheet_id.bin, the sheet id are assigned + * dynamically. Separate maps are used, because in sheet_id.bin + * mode it uses static maps optimized during load. + */ static bool _DontHaveSheetKnowledge; + static std::map _DevTypeNameToId; + /// outer vector is type, inner vector is sheet id + static std::vector > _DevSheetIdToName; + static std::map _DevSheetNameToId; }; diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index b68011cf9..28d6498b0 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -40,6 +40,9 @@ vector CSheetId::_FileExtensions; bool CSheetId::_Initialised=false; bool CSheetId::_RemoveUnknownSheet=true; bool CSheetId::_DontHaveSheetKnowledge = false; +std::map CSheetId::_DevTypeNameToId; +std::vector > CSheetId::_DevSheetIdToName; +std::map CSheetId::_DevSheetNameToId; const CSheetId CSheetId::Unknown(0); @@ -111,7 +114,38 @@ CSheetId::CSheetId( const string& sheetName ) bool CSheetId::buildSheetId(const std::string& sheetName) { nlassert(_Initialised); - nlassert(!_DontHaveSheetKnowledge); + + // When no sheet_id.bin is loaded, use dynamically assigned IDs. + if (_DontHaveSheetKnowledge) + { + std::string sheetNameLc = toLower(sheetName); + std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); + if (it == _DevSheetNameToId.end()) + { + // Create a new dynamic sheet ID. + std::string sheetType = CFile::getExtension(sheetNameLc); + std::string sheetName = CFile::getFilenameWithoutExtension(sheetNameLc); + std::map::iterator tit = _DevTypeNameToId.find(sheetType); + uint32 typeId; + if (tit == _DevTypeNameToId.end()) + { + _FileExtensions.push_back(sheetType); + _DevSheetIdToName.push_back(std::vector()); + typeId = _FileExtensions.size() - 1; + _DevTypeNameToId[sheetType] = typeId; + } + else + { + typeId = tit->second; + } + _DevSheetIdToName[typeId].push_back(sheetName); + _Id.IdInfos.Type = typeId; + _Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1; + _DevSheetNameToId[sheetNameLc] = _Id.Id; + } + _Id.Id = it->second; + return true; + } // try looking up the sheet name in _SheetNameToId CStaticMap::const_iterator itId; @@ -283,7 +317,10 @@ void CSheetId::init(bool removeUnknownSheet) { // allow multiple calls to init in case libraries depending on sheetid call this init from their own if (_Initialised) + { + nlassert(!_DontHaveSheetKnowledge); return; + } // CFile::addFileChangeCallback ("sheet_id.bin", cbFileChange); @@ -297,8 +334,23 @@ void CSheetId::init(bool removeUnknownSheet) void CSheetId::initWithoutSheet() { + if (_Initialised) + { + nlassert(_DontHaveSheetKnowledge); + return; + } + _Initialised = true; _DontHaveSheetKnowledge = true; + + /*_FileExtensions.push_back("unknown"); + _DevTypeNameToId["unknown"] = 0; + _DevSheetIdToName.push_back(std::vector()); + _DevSheetIdToName[0].push_back("unknown"); + _DevSheetNameToId["unknown.unknown"] = 0;*/ + + CSheetId unknown = CSheetId("unknown.unknown"); + nlassert(unknown == CSheetId::Unknown); } @@ -310,6 +362,10 @@ void CSheetId::initWithoutSheet() void CSheetId::uninit() { delete [] _AllStrings.Ptr; + _FileExtensions.clear(); + _DevTypeNameToId.clear(); + _DevSheetIdToName.clear(); + _DevSheetNameToId.clear(); } // uninit // //----------------------------------------------- @@ -343,7 +399,7 @@ CSheetId& CSheetId::operator=( const CSheetId& sheetId ) //----------------------------------------------- CSheetId& CSheetId::operator=( const string& sheetName ) { - nlassert(_Initialised); + /*nlassert(_Initialised); nlassert(!_DontHaveSheetKnowledge); CStaticMap::const_iterator itId; @@ -360,6 +416,12 @@ CSheetId& CSheetId::operator=( const string& sheetName ) return *this; } *this = Unknown; + return *this;*/ + + // doesn't make sense to have a copy of the same code here... + + if (!buildSheetId(sheetName)) + *this = Unknown; return *this; } // operator= // @@ -407,6 +469,13 @@ bool CSheetId::operator < (const CSheetId& sheetRef ) const string CSheetId::toString(bool ifNotFoundUseNumericId) const { if (!_Initialised) init(false); + + if (_DontHaveSheetKnowledge) + { + // FIXME: When someone punches in a fake sheet id this will + // fail. + return _DevSheetIdToName[_Id.IdInfos.Type][_Id.IdInfos.Id]; + } CStaticMap::const_iterator itStr = _SheetIdToName.find (_Id.Id); if( itStr != _SheetIdToName.end() ) @@ -432,6 +501,8 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { + nlassert(!_DontHaveSheetKnowledge); + f.serial( _Id.Id ); #ifdef NL_DEBUG_SHEET_ID @@ -443,6 +514,31 @@ void CSheetId::serial(NLMISC::IStream &f) throw(NLMISC::EStream) #endif } +void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) throw(NLMISC::EStream) +{ + nlassert(_Initialised); + + if (f.isReading()) + { + std::string sheetName; + f.serial(sheetName); + if (CFile::getExtension(sheetName) == "" && defaultType != "") + sheetName += std::string(".") + defaultType; + if (!buildSheetId(sheetName)) + { + if(sheetName.empty()) + nlwarning("SHEETID: Try to create an CSheetId with empty name. TODO: check why."); + else + nlwarning("SHEETID: The sheet '%s' is not in sheet_id.bin, setting it to Unknown",sheetName.c_str()); + *this = Unknown; + } + } + else + { + std::string sheetName = toString(); + f.serial(sheetName); + } +} //----------------------------------------------- From aa7598efe23e2474c68f6bcee4328b09fb263204 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 14:54:39 +0200 Subject: [PATCH 05/39] Fixed: Sound CSheetId implementation (part 1) (not tested) --HG-- branch : sound_dev --- code/nel/include/nel/3d/cluster.h | 7 +- code/nel/include/nel/sound/clustered_sound.h | 8 +- code/nel/include/nel/sound/sound.h | 2 +- code/nel/include/nel/sound/sound_bank.h | 9 ++- code/nel/samples/sound/sound_sources/main.cpp | 6 +- .../samples/sound/stream_file/stream_file.cpp | 2 +- .../stream_ogg_vorbis/stream_ogg_vorbis.cpp | 2 +- code/nel/src/3d/cluster.cpp | 20 ++--- code/nel/src/3d/ps_sound.cpp | 13 +-- code/nel/src/sound/audio_mixer_user.cpp | 10 +-- code/nel/src/sound/background_sound.cpp | 3 +- .../src/sound/background_sound_manager.cpp | 13 +-- code/nel/src/sound/clustered_sound.cpp | 38 +++------ code/nel/src/sound/sound.cpp | 5 +- code/nel/src/sound/sound_bank.cpp | 81 ++++++++++--------- 15 files changed, 98 insertions(+), 121 deletions(-) diff --git a/code/nel/include/nel/3d/cluster.h b/code/nel/include/nel/3d/cluster.h index 14b3fb13c..552d7474a 100644 --- a/code/nel/include/nel/3d/cluster.h +++ b/code/nel/include/nel/3d/cluster.h @@ -21,7 +21,6 @@ #include "nel/misc/string_mapper.h" #include "nel/misc/plane.h" #include "nel/misc/aabbox.h" -#include "nel/misc/sheet_id.h" #include "nel/3d/transform.h" @@ -126,9 +125,9 @@ public: //\name Sound related. //@{ void setSoundGroup(const std::string &soundGroup); - void setSoundGroup(const NLMISC::CSheetId &soundGroupId); + void setSoundGroup(const NLMISC::TStringId &soundGroupId); const std::string &getSoundGroup(); - NLMISC::CSheetId getSoundGroupId(); + NLMISC::TStringId getSoundGroupId(); void setEnvironmentFx(const std::string &environmentFx); void setEnvironmentFx(const NLMISC::TStringId &environmentFxId); const std::string &getEnvironmentFx(); @@ -189,7 +188,7 @@ private: std::vector _Volume; /// Sound group name id - NLMISC::CSheetId _SoundGroupId; + NLMISC::TStringId _SoundGroupId; /// Environement Fx name Id (using CStringMapper) NLMISC::TStringId _EnvironmentFxId; diff --git a/code/nel/include/nel/sound/clustered_sound.h b/code/nel/include/nel/sound/clustered_sound.h index 0736c5a5c..ed674f879 100644 --- a/code/nel/include/nel/sound/clustered_sound.h +++ b/code/nel/include/nel/sound/clustered_sound.h @@ -19,6 +19,7 @@ #include "nel/misc/types_nl.h" #include "nel/misc/string_mapper.h" +#include "nel/misc/sheet_id.h" #include #include @@ -249,14 +250,13 @@ private: /// The segment of all the audio path. std::vector > _AudioPath; - typedef CHashMap TClusterSoundCont; + typedef CHashMap TClusterSoundCont; /// The current cluster playing source indexed with sound group id TClusterSoundCont _Sources; - typedef CHashMap TStringStringMap; - //typedef CHashMap TStringStringMap; + typedef CHashMap TStringSheetMap; /// The sound_group to sound assoc - TStringStringMap _SoundGroupToSound; + TStringSheetMap _SoundGroupToSound; }; } // NLSOUND diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index c4c494912..a84393944 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -54,7 +54,7 @@ class CSound friend class CAudioMixerUser; public: /// Factory for specialized sound. - static CSound *createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot); + static CSound *createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot); enum TSOUND_TYPE { diff --git a/code/nel/include/nel/sound/sound_bank.h b/code/nel/include/nel/sound/sound_bank.h index 8a4573849..05993bb07 100644 --- a/code/nel/include/nel/sound/sound_bank.h +++ b/code/nel/include/nel/sound/sound_bank.h @@ -68,16 +68,16 @@ public: bool isLoaded(); /// Return a sound corresponding to a name. - CSound *getSound(const NLMISC::CSheetId &name); + CSound *getSound(const NLMISC::CSheetId &sheetId); /// Return the names of the sounds - void getNames( std::vector &names ); + void getNames( std::vector &sheetIds ); /// Return the number of sounds in this bank. uint countSounds(); void addSound(CSound *sound); - void removeSound(const NLMISC::CSheetId &name); + void removeSound(const NLMISC::CSheetId &sheetId); private: @@ -89,7 +89,8 @@ private: typedef CHashMap TBufferAssocContainer; /// Sound names hash map // typedef std::hash_map TSoundTable; - typedef CHashMap TSoundTable; +// typedef CHashMap TSoundTable; + typedef std::vector TSoundTable; // list the sheets by shortId of the sheetId /// Assoc from buffer to sound. Used for sound unloading. TBufferAssocContainer _BufferAssoc; diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index 3ece14f73..c4efa7a4e 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -100,7 +100,7 @@ USource *OnAddSource( const char *name, float x, float y, float z ) /* * Create a source with sound 'name', and set some of its initial properties, if successful */ - USource *source = AudioMixer->createSource( /*CStringMapper::map(name)*/ CSheetId(name) ); + USource *source = AudioMixer->createSource(CSheetId(name)); if ( source != NULL ) { source->setPos( CVector(x,y,z) ); @@ -161,8 +161,8 @@ int main() printf( "One is 20 meters ahead, on the right\n" ); printf( "The other is 5 meters ahead, on the left\n" ); getchar(); - USource *src1 = OnAddSource( "beep", 1.0f, 20.0f, 0.0f ); // Beep on the right, 20 meters ahead - USource *src2 = OnAddSource( "tuut", -2.0f, 5.0f, 0.0f ); // Tuut on the left, 5 meters ahead + USource *src1 = OnAddSource( "beep.sound", 1.0f, 20.0f, 0.0f ); // Beep on the right, 20 meters ahead + USource *src2 = OnAddSource( "tuut.sound", -2.0f, 5.0f, 0.0f ); // Tuut on the left, 5 meters ahead // Second step: we will move the listener ahead printf( "Press ENTER again to start moving the listener\n" ); diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp index 060c4b433..b07da8ba4 100644 --- a/code/nel/samples/sound/stream_file/stream_file.cpp +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -97,7 +97,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - s_Source = s_AudioMixer->createSource(/*CStringMapper::map("stream_file")*/ CSheetId("stream_file")); + s_Source = s_AudioMixer->createSource(CSheetId("stream_file.sound")); nlassert(s_Source); s_StreamFileSource = dynamic_cast(s_Source); nlassert(s_StreamFileSource); diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index 490ae8dd5..e4a2e507c 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -87,7 +87,7 @@ static void initSample() //NLMISC::CHTimer::startBench(); - USource *source = s_AudioMixer->createSource(CSheetId("default_stream")/*CStringMapper::map("default_stream")*/); + USource *source = s_AudioMixer->createSource(CSheetId("default_stream.sound")); nlassert(source); s_StreamSource = dynamic_cast(source); nlassert(s_StreamSource); diff --git a/code/nel/src/3d/cluster.cpp b/code/nel/src/3d/cluster.cpp index cb34b7f10..2faebcec7 100644 --- a/code/nel/src/3d/cluster.cpp +++ b/code/nel/src/3d/cluster.cpp @@ -51,9 +51,7 @@ CCluster::CCluster () // map a no fx string _EnvironmentFxId = CStringMapper::map("no fx"); // map a no soundgroup string - _SoundGroupId = NLMISC::CSheetId::Unknown; /*CStringMapper::map("")*/; - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); - + _SoundGroupId = CStringMapper::map(""); // I am a transform cluster CTransform::setIsCluster(true); @@ -78,21 +76,18 @@ CCluster::~CCluster() void CCluster::setSoundGroup(const std::string &soundGroup) { - _SoundGroupId = NLMISC::CSheetId(soundGroup);/*CStringMapper::map(soundGroup);*/ - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); - + _SoundGroupId = CStringMapper::map(soundGroup); } -void CCluster::setSoundGroup(const NLMISC::CSheetId &soundGroupId) +void CCluster::setSoundGroup(const NLMISC::TStringId &soundGroupId) { _SoundGroupId = soundGroupId; - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); } const std::string &CCluster::getSoundGroup() { - return _SoundGroupId.toString();/*CStringMapper::unmap(_SoundGroupId)*/; + return CStringMapper::unmap(_SoundGroupId); } -NLMISC::CSheetId CCluster::getSoundGroupId() +NLMISC::TStringId CCluster::getSoundGroupId() { return _SoundGroupId; } @@ -309,8 +304,7 @@ void CCluster::serial (NLMISC::IStream&f) std::string envFxName; f.serial(soundGroup); - _SoundGroupId = NLMISC::CSheetId(soundGroup); /*CStringMapper::map(soundGroup)*/; - nldebug("SOUNDSHEET: %s", _SoundGroupId.toString().c_str()); + _SoundGroupId = CStringMapper::map(soundGroup); f.serial(envFxName); if (envFxName == "") @@ -320,7 +314,7 @@ void CCluster::serial (NLMISC::IStream&f) else { // write the sound group - std::string soundGroup = _SoundGroupId.toString();/*CStringMapper::unmap(_SoundGroupId)*/; + std::string soundGroup = CStringMapper::unmap(_SoundGroupId); f.serial(soundGroup); // write the env fx name std::string envFxName = CStringMapper::unmap(_EnvironmentFxId); diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index 322bd2729..5cee12c3e 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -261,17 +261,8 @@ void CPSSound::serial(NLMISC::IStream &f) throw(NLMISC::EStream) CPSLocatedBindable::serial(f); // version 3 : added option to keep original pitch from the .sound sint ver = f.serialVersion(3); - if (f.isReading()) - { - std::string soundName; - f.serial(soundName); - _SoundName = NLMISC::CSheetId(soundName)/*NLMISC::CStringMapper::map(soundName)*/; - } - else - { - std::string soundName = _SoundName.toString()/*NLMISC::CStringMapper::unmap(_SoundName)*/; - f.serial(soundName); - } + + _SoundName.serialString(f, "sound"); sint32 nbSounds; bool hasScheme; diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 016f3d13d..61dca9f9e 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -1050,9 +1050,8 @@ public: for (uint i=0; igetArrayValue(soundName, i); - soundName = soundName.substr(0, soundName.find(".sound")); - - cs.SoundNames.push_back(CSheetId(soundName)/*CStringMapper::map(soundName)*/); + nlassert(soundName.find(".sound") != std::string::npos); + cs.SoundNames.push_back(CSheetId(soundName)); } if (!cs.SoundNames.empty()) @@ -1133,7 +1132,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s) for (uint i=0; igetValueByName(soundName, "Sound"); - sound.SoundName = NLMISC::CSheetId(CFile::getFilenameWithoutExtension(soundName));/*CStringMapper::map(CFile::getFilenameWithoutExtension(soundName))*/; + nlassert(soundName.find(".sound") != std::string::npos); + sound.SoundName = NLMISC::CSheetId(soundName); // Read the environnement flag. diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index 4eb5b042d..2008b37db 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -86,7 +86,8 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI CAudioMixerUser *mixer = CAudioMixerUser::instance(); TSoundData sd; - sd.SoundName = /*CStringMapper::map(soundName)*/ NLMISC::CSheetId(soundName); + nlassert(soundName.find(".sound") != std::string::npos); + sd.SoundName = NLMISC::CSheetId(soundName); sd.Sound = mixer->getSoundId(sd.SoundName); sd.Source = 0; @@ -1431,21 +1432,15 @@ void CBackgroundSoundManager::TBanksData::serial(NLMISC::IStream &s) void CBackgroundSoundManager::TSoundData::serial(NLMISC::IStream &s) { - std::string str; - + //std::string str; + SoundName.serialString(s, "sound"); if (s.isReading()) { CAudioMixerUser *mixer = CAudioMixerUser::instance(); - s.serial(str); - SoundName = /*NLMISC::CStringMapper::map(str)*/ NLMISC::CSheetId(str); Sound = mixer->getSoundId(SoundName); Source = NULL; Selected = false; } - else - { - s.serial(const_cast(SoundName.toString()/*NLMISC::CStringMapper::unmap(SoundName)*/)); - } s.serial(MinBox); s.serial(MaxBox); s.serial(Surface); diff --git a/code/nel/src/sound/clustered_sound.cpp b/code/nel/src/sound/clustered_sound.cpp index c2a8db8ef..25f0e5b64 100644 --- a/code/nel/src/sound/clustered_sound.cpp +++ b/code/nel/src/sound/clustered_sound.cpp @@ -70,7 +70,7 @@ float EAX_MATERIAL_PARAM[] = class CSoundGroupSerializer { public: - std::vector > _SoundGroupAssoc; + std::vector > _SoundGroupAssoc; // load the values using the george sheet (called by GEORGE::loadForm) void readGeorges (const NLMISC::CSmartPtr &form, const std::string &/* name */) @@ -95,15 +95,9 @@ public: item->getValueByName(soundGroup, ".SoundGroup"); item->getValueByName(sound, ".Sound"); - string::size_type n = sound.rfind(".sound"); + nlassert(sound.find(".sound") != std::string::npos); - if (n != string::npos) - { - // remove the tailing .sound - sound = sound.substr(0, n); - } - - _SoundGroupAssoc.push_back(make_pair(CSheetId(soundGroup), CSheetId(sound) /*CStringMapper::map(soundGroup), CStringMapper::map(sound)*/)); + _SoundGroupAssoc.push_back(make_pair(CStringMapper::map(soundGroup), CSheetId(sound))); } } catch(...) @@ -125,24 +119,18 @@ public: { if (s.isReading()) { - std::string soundGroup; - std::string sound; + TStringId soundGroup; + CSheetId sound; - s.serial(soundGroup); - s.serial(sound); + CStringMapper::serialString(s, soundGroup); + sound.serialString(s, "sound"); - _SoundGroupAssoc.push_back(make_pair(CSheetId(soundGroup), CSheetId(sound) /*CStringMapper::map(soundGroup), CStringMapper::map(sound)*/)); + _SoundGroupAssoc.push_back(make_pair(soundGroup, sound)); } else { - std::string soundGroup; - std::string sound; - - soundGroup = _SoundGroupAssoc[i].first.toString();// CStringMapper::unmap(_SoundGroupAssoc[i].first); - sound = _SoundGroupAssoc[i].second.toString(); //CStringMapper::unmap(_SoundGroupAssoc[i].second); - - s.serial(soundGroup); - s.serial(sound); + CStringMapper::serialString(s, _SoundGroupAssoc[i].first); + _SoundGroupAssoc[i].second.serialString(s, "sound"); } } } @@ -254,10 +242,10 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view TClusterStatusMap::const_iterator first(_AudibleClusters.begin()), last(_AudibleClusters.end()); for (; first != last; ++first ) { - static NLMISC::CSheetId NO_SOUND_GROUP = /*CStringMapper::emptyId()*/NLMISC::CSheetId::Unknown; + static NLMISC::TStringId NO_SOUND_GROUP = CStringMapper::emptyId(); const CClusterSoundStatus &css = first->second; CCluster *cluster = first->first; - NLMISC::CSheetId soundGroup; + NLMISC::TStringId soundGroup; soundGroup = cluster->getSoundGroupId(); @@ -289,7 +277,7 @@ void CClusteredSound::update(const CVector &listenerPos, const CVector &/* view // nldebug("Searching sound assoc for group [%s]", CStringMapper::unmap(soundGroup).c_str()); - TStringStringMap::iterator it2(_SoundGroupToSound.find(soundGroup)); + TStringSheetMap::iterator it2(_SoundGroupToSound.find(soundGroup)); if (it2 != _SoundGroupToSound.end()) { NLMISC::CSheetId soundName = it2->second; diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index bb9fd9372..f1d06bd5f 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -37,8 +37,9 @@ using namespace NLMISC; namespace NLSOUND { -CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot) +CSound *CSound::createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot) { + std::string filename = sheetId.toString(); CSound *ret = NULL; string soundType; @@ -170,7 +171,7 @@ void CSound::serial(NLMISC::IStream &s) void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root) { // Name - _Name = NLMISC::CSheetId(CFile::getFilenameWithoutExtension(filename));//CStringMapper::map(CFile::getFilenameWithoutExtension(filename)); + _Name = NLMISC::CSheetId(filename); // InternalConeAngle uint32 inner; diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 93cf09de4..1124eeaa5 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -123,14 +123,13 @@ CSoundBank::~CSoundBank() void CSoundBank::addSound(CSound *sound) { - std::pair ret; - ret = _Sounds.insert(make_pair(sound->getName(), sound)); - nlassert(ret.second); + nlassert(_Sounds.size() > sound->getName().getShortId()); + _Sounds[sound->getName().getShortId()] = sound; } -void CSoundBank::removeSound(const NLMISC::CSheetId &name) +void CSoundBank::removeSound(const NLMISC::CSheetId &sheetId) { - _Sounds.erase(name); + _Sounds[sheetId.getShortId()] = NULL; } @@ -155,7 +154,7 @@ public: void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &name) { // just call the sound creation method with the xml form. - Sound = CSound::createSound(name.toString(), form->getRootNode()); + Sound = CSound::createSound(name, form->getRootNode()); // success ? // if (_Sound != 0) @@ -259,36 +258,51 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) { // this structure is fill by the loadForm() function and will contain all you need //std::map Container; - std::map Container; + std::map container; nlassert(!_Loaded); // Just call the GEORGE::loadFrom method to read all available sounds - ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", Container, packedSheetUpdate, false); + ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", container, packedSheetUpdate, false); _Loaded = true; + // get the largest sheet id needed and init the sound bank + uint32 maxShortId = 0; + { + std::map::iterator first(container.begin()), last(container.end()); + for (; first != last; ++first) + { + if (first->first.getShortId() > maxShortId) + maxShortId = first->first.getShortId(); + } + ++maxShortId; // inc for size = last idx + 1 + nlassert(maxShortId < (container.size() * 8)); // ensure no ridiculous sheet id values + if (maxShortId > _Sounds.size()) + _Sounds.resize(maxShortId); + } + // add all the loaded sound in the sound banks - //std::map::iterator first(Container.begin()), last(Container.end()); - std::map::iterator first(Container.begin()), last(Container.end()); - for (; first != last; ++first) { - if (first->second.Sound != 0) - addSound(first->second.Sound); + std::map::iterator first(container.begin()), last(container.end()); + for (; first != last; ++first) + { + if (first->second.Sound != 0) + addSound(first->second.Sound); + } } - Container.clear(); + container.clear(); } /* * Unload all the sound samples in this bank. */ -void CSoundBank::unload() +void CSoundBank::unload() { nlassert(_Loaded); - TSoundTable::iterator first(_Sounds.begin()), last(_Sounds.end()); - for (; first != last; ++first) + for (TSoundTable::size_type i = 0; i < _Sounds.size(); ++i) { - delete first->second; + delete _Sounds[i]; } _Sounds.clear(); @@ -322,7 +336,7 @@ void CSoundBank::unload() /* * Returns true if the samples in this bank have been loaded. */ -bool CSoundBank::isLoaded() +bool CSoundBank::isLoaded() { return _Loaded; } @@ -330,37 +344,32 @@ bool CSoundBank::isLoaded() /* * Return a sound sample corresponding to a name. */ -CSound* CSoundBank::getSound(const NLMISC::CSheetId &name) +CSound* CSoundBank::getSound(const NLMISC::CSheetId &sheetId) { - // Find sound - TSoundTable::iterator iter = _Sounds.find(name); - if ( iter == _Sounds.end() ) - { - return 0; - } - else - { - return (*iter).second; - } + if (sheetId == NLMISC::CSheetId::Unknown) + return NULL; + + nlassert(sheetId.getShortId() < _Sounds.size()); + + return _Sounds[sheetId.getShortId()]; } /** * Return the names of the sounds */ -void CSoundBank::getNames( std::vector &names ) +void CSoundBank::getNames( std::vector &sheetIds ) { - TSoundTable::const_iterator iter; - for (iter = _Sounds.begin(); iter != _Sounds.end(); ++iter) + for (TSoundTable::size_type i = 0; i < _Sounds.size(); ++i) { - names.push_back((*iter).first); - //nlwarning("getting sound %s", (*iter).first); + if (_Sounds[i]) + sheetIds.push_back(_Sounds[i]->getName()); } } /* * Return the number of buffers in this bank. */ -uint CSoundBank::countSounds() +uint CSoundBank::countSounds() { return (uint)_Sounds.size(); } From 3608f0a4293e1e69b67e6f9173d94c6962306d2c Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 15:21:03 +0200 Subject: [PATCH 06/39] Added: Additional constructor for CSheetId with default type, in case the user did not put the type with the sheet name --HG-- branch : sound_dev --- code/nel/include/nel/misc/sheet_id.h | 6 ++++++ code/nel/src/misc/sheet_id.cpp | 19 +++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/code/nel/include/nel/misc/sheet_id.h b/code/nel/include/nel/misc/sheet_id.h index 9c13b6189..869a61af6 100644 --- a/code/nel/include/nel/misc/sheet_id.h +++ b/code/nel/include/nel/misc/sheet_id.h @@ -60,6 +60,12 @@ public : */ explicit CSheetId( const std::string& sheetName ); + /** + * Constructor, uses defaultType as extension when sheetName + * contains no file extension. + */ + explicit CSheetId( const std::string& sheetName, const std::string &defaultType ); + // build from a string and returns true if the build succeed bool buildSheetId(const std::string& sheetName); diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 28d6498b0..e76f66656 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -106,6 +106,14 @@ CSheetId::CSheetId( const string& sheetName ) } // CSheetId // +CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType ) +{ + if (CFile::getExtension(sheetName) == "" && defaultType != "") + *this = CSheetId(sheetName + "." + defaultType); + else + *this = CSheetId(sheetName); +} + //----------------------------------------------- // Build @@ -522,16 +530,7 @@ void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) { std::string sheetName; f.serial(sheetName); - if (CFile::getExtension(sheetName) == "" && defaultType != "") - sheetName += std::string(".") + defaultType; - if (!buildSheetId(sheetName)) - { - if(sheetName.empty()) - nlwarning("SHEETID: Try to create an CSheetId with empty name. TODO: check why."); - else - nlwarning("SHEETID: The sheet '%s' is not in sheet_id.bin, setting it to Unknown",sheetName.c_str()); - *this = Unknown; - } + *this = CSheetId(sheetName, defaultType); } else { From 9cd7498fe9bd494a0bc77b72765a679a0b4adb4b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 15:24:21 +0200 Subject: [PATCH 07/39] Fixed: Sound CSheetID implementation (part 2) (not tested) --HG-- branch : sound_dev --- code/nel/samples/sound/sound_sources/main.cpp | 6 +++--- code/nel/src/sound/audio_mixer_user.cpp | 2 +- code/nel/src/sound/complex_sound.cpp | 8 ++++---- code/nel/src/sound/sound.cpp | 13 ++----------- code/nel/src/sound/sound_anim_marker.cpp | 2 +- code/nel/src/sound/sound_animation.cpp | 2 +- code/nel/src/sound/stream_file_sound.cpp | 6 +++--- code/ryzom/client/src/client_cfg.cpp | 2 +- code/ryzom/client/src/connection.cpp | 3 +-- 9 files changed, 17 insertions(+), 27 deletions(-) diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index c4efa7a4e..2c0ccedab 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -100,7 +100,7 @@ USource *OnAddSource( const char *name, float x, float y, float z ) /* * Create a source with sound 'name', and set some of its initial properties, if successful */ - USource *source = AudioMixer->createSource(CSheetId(name)); + USource *source = AudioMixer->createSource(CSheetId(name, "sound")); if ( source != NULL ) { source->setPos( CVector(x,y,z) ); @@ -161,8 +161,8 @@ int main() printf( "One is 20 meters ahead, on the right\n" ); printf( "The other is 5 meters ahead, on the left\n" ); getchar(); - USource *src1 = OnAddSource( "beep.sound", 1.0f, 20.0f, 0.0f ); // Beep on the right, 20 meters ahead - USource *src2 = OnAddSource( "tuut.sound", -2.0f, 5.0f, 0.0f ); // Tuut on the left, 5 meters ahead + USource *src1 = OnAddSource( "beep", 1.0f, 20.0f, 0.0f ); // Beep on the right, 20 meters ahead + USource *src2 = OnAddSource( "tuut", -2.0f, 5.0f, 0.0f ); // Tuut on the left, 5 meters ahead // Second step: we will move the listener ahead printf( "Press ENTER again to start moving the listener\n" ); diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 61dca9f9e..6eb9a2a2c 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -1132,7 +1132,7 @@ void CAudioMixerUser::CControledSources::serial(NLMISC::IStream &s) for (uint i=0; igetArrayValue(soundname, i)) { - soundname = CFile::getFilenameWithoutExtension(soundname); - _Sounds.push_back(NLMISC::CSheetId(soundname)/*CStringMapper::map(soundname)*/); + nlassert(soundname.find(".sound") != std::string::npos); + _Sounds.push_back(NLMISC::CSheetId(soundname)); } } } diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index f1d06bd5f..cc69455af 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -134,17 +134,7 @@ void CSound::serial(NLMISC::IStream &s) s.serial(_Direction); s.serial(_Looping); s.serial(_MaxDist); - if (s.isReading()) - { - std::string name; - s.serial(name); - _Name = NLMISC::CSheetId(name);//CStringMapper::map(name); - } - else - { - std::string name = _Name.toString();//CStringMapper::unmap(_Name); - s.serial(name); - } + _Name.serialString(s, "sound"); nlassert(CGroupControllerRoot::getInstance()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 @@ -171,6 +161,7 @@ void CSound::serial(NLMISC::IStream &s) void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root) { // Name + nlassert(filename.find(".sound") != std::string::npos); _Name = NLMISC::CSheetId(filename); // InternalConeAngle diff --git a/code/nel/src/sound/sound_anim_marker.cpp b/code/nel/src/sound/sound_anim_marker.cpp index 40e058589..b64e02f3c 100644 --- a/code/nel/src/sound/sound_anim_marker.cpp +++ b/code/nel/src/sound/sound_anim_marker.cpp @@ -41,7 +41,7 @@ void CSoundAnimMarker::play(UAudioMixer* mixer, NL3D::CCluster *cluster, CSoundC for (; first != last; ++first) { - USource* source = mixer->createSource(NLMISC::CSheetId(*first), true, NULL, NULL, cluster, &context); + USource* source = mixer->createSource((*first), true, NULL, NULL, cluster, &context); if (source != NULL) { source->setRelativeGain(context.RelativeGain); diff --git a/code/nel/src/sound/sound_animation.cpp b/code/nel/src/sound/sound_animation.cpp index 5ea3f87cb..5a6f1c256 100644 --- a/code/nel/src/sound/sound_animation.cpp +++ b/code/nel/src/sound/sound_animation.cpp @@ -190,7 +190,7 @@ void CSoundAnimation::load() throw NLMISC::Exception("Invalid sound animation marker"); } - marker->addSound(NLMISC::CSheetId(string(name))/*CStringMapper::map(string(name))*/); + marker->addSound(NLMISC::CSheetId(string(name), "sound")); xmlFree ((void*)name); diff --git a/code/nel/src/sound/stream_file_sound.cpp b/code/nel/src/sound/stream_file_sound.cpp index b86f0b5df..fbf0c91a1 100644 --- a/code/nel/src/sound/stream_file_sound.cpp +++ b/code/nel/src/sound/stream_file_sound.cpp @@ -73,13 +73,13 @@ void CStreamFileSound::serial(NLMISC::IStream &s) void CStreamFileSound::setMusicFilePath(const std::string &filePath, bool async, bool loop) { -#if !FINAL_VERSION +/*#if !FINAL_VERSION //_Name = NLMISC::CStringMapper::map(std::string(""); _Name = NLMISC::CSheetId(std::string(""); #else //_Name = NLMISC::CStringMapper::map(""); - _Name = NLMISC::CSheetId(""); -#endif +#endif*/ + _Name = NLMISC::CSheetId("music_channel.sound"); _ConeInnerAngle = NLMISC::Pi * 2; _ConeOuterAngle = NLMISC::Pi * 2; _Looping = loop; diff --git a/code/ryzom/client/src/client_cfg.cpp b/code/ryzom/client/src/client_cfg.cpp index f6f7d7e3f..84ba25060 100644 --- a/code/ryzom/client/src/client_cfg.cpp +++ b/code/ryzom/client/src/client_cfg.cpp @@ -419,7 +419,7 @@ CClientConfig::CClientConfig() // only force patching under Windows by default #ifdef NL_OS_WINDOWS - PatchWanted = false;//true; + PatchWanted = true; #else PatchWanted = false; #endif diff --git a/code/ryzom/client/src/connection.cpp b/code/ryzom/client/src/connection.cpp index 3f94368d5..ffbba52e9 100644 --- a/code/ryzom/client/src/connection.cpp +++ b/code/ryzom/client/src/connection.cpp @@ -2006,8 +2006,7 @@ public: virtual void execute (CCtrlBase * /* pCaller */, const string &Params) { string sName = getParam(Params, "name"); - //TStringId id = CStringMapper::map(sName); - CSheetId id = CSheetId(sName); + CSheetId id = CSheetId(sName, "sound"); if (SoundMngr != NULL) SoundMngr->spawnSource(id,CVector(0,0,0)); } From f79f3fca4815ef46311b1d1d3d3e14700a1345d5 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 16:06:10 +0200 Subject: [PATCH 08/39] Fixed: Sound CSheetID implementation (part 3) (partially tested) --HG-- branch : sound_dev --- code/nel/samples/sound/sound_sources/main.cpp | 1 + .../samples/sound/stream_file/stream_file.cpp | 1 + .../stream_ogg_vorbis/stream_ogg_vorbis.cpp | 1 + code/nel/src/misc/sheet_id.cpp | 17 ++++++++--- code/nel/src/sound/sound_bank.cpp | 29 ++++++++++++++----- .../object_viewer/particle_sound_page.cpp | 10 +++---- .../plugins/object_viewer/sound_system.cpp | 13 +++++++-- 7 files changed, 53 insertions(+), 19 deletions(-) diff --git a/code/nel/samples/sound/sound_sources/main.cpp b/code/nel/samples/sound/sound_sources/main.cpp index 2c0ccedab..75f732b5a 100644 --- a/code/nel/samples/sound/sound_sources/main.cpp +++ b/code/nel/samples/sound/sound_sources/main.cpp @@ -49,6 +49,7 @@ void Init() { try { + CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); diff --git a/code/nel/samples/sound/stream_file/stream_file.cpp b/code/nel/samples/sound/stream_file/stream_file.cpp index b07da8ba4..6362a0414 100644 --- a/code/nel/samples/sound/stream_file/stream_file.cpp +++ b/code/nel/samples/sound/stream_file/stream_file.cpp @@ -62,6 +62,7 @@ static void initSample() { if (!INelContext::isContextInitialised()) new CApplicationContext(); + CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/data", true, false); printf("Sample demonstrating OGG playback using stream file .sound sheets."); diff --git a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp index e4a2e507c..1f491b21c 100644 --- a/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp +++ b/code/nel/samples/sound/stream_ogg_vorbis/stream_ogg_vorbis.cpp @@ -59,6 +59,7 @@ static void initSample() { if (!INelContext::isContextInitialised()) new CApplicationContext(); + CSheetId::initWithoutSheet(); CPath::addSearchPath(NL_SOUND_DATA"/database/build/", true, false); printf("Sample demonstrating OGG playback using UStreamSource."); diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index e76f66656..9bb5894b8 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -109,7 +109,11 @@ CSheetId::CSheetId( const string& sheetName ) CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType ) { if (CFile::getExtension(sheetName) == "" && defaultType != "") - *this = CSheetId(sheetName + "." + defaultType); + { + std::string withType = sheetName + "." + defaultType; + *this = CSheetId(withType); + nldebug("SHEETID: Constructing CSheetId from name '%s' without explicit type, defaulting as '%s' to '%s'", sheetName.c_str(), defaultType.c_str(), withType.c_str()); + } else *this = CSheetId(sheetName); } @@ -131,6 +135,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName) if (it == _DevSheetNameToId.end()) { // Create a new dynamic sheet ID. + nldebug("SHEETID: Creating a new dynamic sheet id for '%s'", sheetName.c_str()); std::string sheetType = CFile::getExtension(sheetNameLc); std::string sheetName = CFile::getFilenameWithoutExtension(sheetNameLc); std::map::iterator tit = _DevTypeNameToId.find(sheetType); @@ -149,7 +154,9 @@ bool CSheetId::buildSheetId(const std::string& sheetName) _DevSheetIdToName[typeId].push_back(sheetName); _Id.IdInfos.Type = typeId; _Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1; + // nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id); _DevSheetNameToId[sheetNameLc] = _Id.Id; + return true; } _Id.Id = it->second; return true; @@ -326,7 +333,8 @@ void CSheetId::init(bool removeUnknownSheet) // allow multiple calls to init in case libraries depending on sheetid call this init from their own if (_Initialised) { - nlassert(!_DontHaveSheetKnowledge); + if (_DontHaveSheetKnowledge) + nlinfo("SHEETID: CSheetId is already initialized without sheet_id.bin"); return; } @@ -357,8 +365,9 @@ void CSheetId::initWithoutSheet() _DevSheetIdToName[0].push_back("unknown"); _DevSheetNameToId["unknown.unknown"] = 0;*/ - CSheetId unknown = CSheetId("unknown.unknown"); - nlassert(unknown == CSheetId::Unknown); + CSheetId unknownunknown = CSheetId("unknown.unknown"); + // nldebug("SHEETID: unknown: %i, Unknown: %i", unknownunknown._Id, Unknown._Id); + nlassert(unknownunknown == CSheetId::Unknown); } diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 1124eeaa5..e48ed6254 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -123,7 +123,9 @@ CSoundBank::~CSoundBank() void CSoundBank::addSound(CSound *sound) { - nlassert(_Sounds.size() > sound->getName().getShortId()); + // nlassert(_Sounds.size() > sound->getName().getShortId()); + if (_Sounds.size() <= sound->getName().getShortId()) + _Sounds.resize(sound->getName().getShortId() + 1); _Sounds[sound->getName().getShortId()] = sound; } @@ -274,9 +276,16 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) maxShortId = first->first.getShortId(); } ++maxShortId; // inc for size = last idx + 1 - nlassert(maxShortId < (container.size() * 8)); // ensure no ridiculous sheet id values - if (maxShortId > _Sounds.size()) - _Sounds.resize(maxShortId); + if (container.size() == 0) + { + nlwarning("NLSOUND: No sound sheets have been loaded, missing sound sheet directory or packed sound sheets file"); + } + else + { + nlassert(maxShortId < (container.size() * 8)); // ensure no ridiculous sheet id values + if (maxShortId > _Sounds.size()) + _Sounds.resize(maxShortId); + } } // add all the loaded sound in the sound banks @@ -348,9 +357,15 @@ CSound* CSoundBank::getSound(const NLMISC::CSheetId &sheetId) { if (sheetId == NLMISC::CSheetId::Unknown) return NULL; - - nlassert(sheetId.getShortId() < _Sounds.size()); - + + // nlassert(sheetId.getShortId() < _Sounds.size()); + if (sheetId.getShortId() >= _Sounds.size()) + { + std::string sheetName = sheetId.toString(); + nlwarning("NLSOUND: Sound sheet id '%s' exceeds loaded sound sheets", sheetName.c_str()); + return NULL; + } + return _Sounds[sheetId.getShortId()]; } diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp index 17e0c09d7..ce7034e56 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/particle_sound_page.cpp @@ -86,7 +86,7 @@ void CSoundPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab _ui.pitchWidget->setWorkspaceNode(_Node); _ui.pitchWidget->updateUi(); - _ui.soundNameLineEdit->setText(QString(NLMISC::CStringMapper::unmap(_Sound->getSoundName()).c_str())); + _ui.soundNameLineEdit->setText(QString(_Sound->getSoundName().toString().c_str())); _ui.spawnCheckBox->setChecked(_Sound->getSpawn()); _ui.muteCheckBox->setChecked(_Sound->getMute()); @@ -95,7 +95,7 @@ void CSoundPage::setEditedItem(CWorkspaceNode *ownerNode, NL3D::CPSLocatedBindab void CSoundPage::browse() { - std::vector names; + std::vector names; NLSOUND::UAudioMixer *audioMixer = Modules::sound().getAudioMixer(); @@ -108,7 +108,7 @@ void CSoundPage::browse() QStringList items; items << tr(""); for(size_t i = 0; i < names.size(); ++i) - items << QString(names[i]->c_str()); + items << QString(names[i].toString().c_str()); bool ok; QString item = QInputDialog::getItem(this, tr("Select your sound"), @@ -162,7 +162,7 @@ void CSoundPage::setKeepPitch(bool state) void CSoundPage::setSoundName(const QString &text) { - _Sound->setSoundName(NLMISC::CStringMapper::map(text.toStdString())); + _Sound->setSoundName(NLMISC::CSheetId(text.toStdString())); } void CSoundPage::setEmissionPercent(float value) @@ -171,4 +171,4 @@ void CSoundPage::setEmissionPercent(float value) updateModifiedFlag(); } -} /* namespace NLQT */ \ No newline at end of file +} /* namespace NLQT */ diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp index a8a204c96..5ca313b0f 100644 --- a/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp +++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/object_viewer/sound_system.cpp @@ -30,6 +30,8 @@ #include #include #include +#include + // Qt includes #include @@ -67,6 +69,9 @@ void CSoundSystem::init() { //H_AUTO2 nldebug("CSoundSystem::init"); + + // require sheet id without sheet id bin + NLMISC::CSheetId::initWithoutSheet(); // create audiomixer _AudioMixer = NULL; @@ -153,9 +158,10 @@ void CSoundSystem::play(const std::string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CStringMapper::map(soundName), true); + NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), true); if (src) { + // FIXME: Use relative positioning, and set pos to 0,0,0 src->setLooping(false); const NLMISC::CVector &pos = _AudioMixer->getListener()->getPos(); src->setPos(pos); @@ -172,9 +178,10 @@ NLSOUND::USource *CSoundSystem::create(const std::string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CStringMapper::map(soundName), false); + NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), false); if (src) { + // FIXME: Use relative positioning, and set pos to 0,0,0 src->setLooping(false); const NLMISC::CVector &pos = _AudioMixer->getListener()->getPos(); src->setPos(pos); @@ -236,4 +243,4 @@ void CSoundSystem::releaseGraphics() NL3D::UParticleSystemSound::setPSSound(NULL); } -} /* namespace NLQT */ \ No newline at end of file +} /* namespace NLQT */ From fc4d91fad22e829536750d3af1ad901baafbb1d5 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 18:12:38 +0200 Subject: [PATCH 09/39] Fixed: Sound CSheetId implementation --HG-- branch : sound_dev --- code/nel/include/nel/sound/sound.h | 2 +- .../src/sound/background_sound_manager.cpp | 3 +-- code/nel/src/sound/sound.cpp | 6 ++--- code/nel/src/sound/sound_bank.cpp | 14 +++++----- code/ryzom/client/src/init.cpp | 26 ++++++++++++------- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/code/nel/include/nel/sound/sound.h b/code/nel/include/nel/sound/sound.h index a84393944..403034a8d 100644 --- a/code/nel/include/nel/sound/sound.h +++ b/code/nel/include/nel/sound/sound.h @@ -54,7 +54,7 @@ class CSound friend class CAudioMixerUser; public: /// Factory for specialized sound. - static CSound *createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot); + static CSound *createSound(const std::string &name, NLGEORGES::UFormElm& formRoot); enum TSOUND_TYPE { diff --git a/code/nel/src/sound/background_sound_manager.cpp b/code/nel/src/sound/background_sound_manager.cpp index 2008b37db..4713d03f8 100644 --- a/code/nel/src/sound/background_sound_manager.cpp +++ b/code/nel/src/sound/background_sound_manager.cpp @@ -86,8 +86,7 @@ void CBackgroundSoundManager::addSound(const std::string &soundName, uint layerI CAudioMixerUser *mixer = CAudioMixerUser::instance(); TSoundData sd; - nlassert(soundName.find(".sound") != std::string::npos); - sd.SoundName = NLMISC::CSheetId(soundName); + sd.SoundName = NLMISC::CSheetId(soundName, "sound"); // note: loaded from .primitive sd.Sound = mixer->getSoundId(sd.SoundName); sd.Source = 0; diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index cc69455af..e7162b3a1 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -37,9 +37,8 @@ using namespace NLMISC; namespace NLSOUND { -CSound *CSound::createSound(const NLMISC::CSheetId &sheetId, NLGEORGES::UFormElm& formRoot) +CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot) { - std::string filename = sheetId.toString(); CSound *ret = NULL; string soundType; @@ -134,8 +133,9 @@ void CSound::serial(NLMISC::IStream &s) s.serial(_Direction); s.serial(_Looping); s.serial(_MaxDist); + _Name.serialString(s, "sound"); - + nlassert(CGroupControllerRoot::getInstance()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 if (s.isReading()) _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER)); diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index e48ed6254..6e24947dd 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -153,7 +153,7 @@ public: {} // load the values using the george sheet (called by GEORGE::loadForm) - void readGeorges (const NLMISC::CSmartPtr &form, const NLMISC::CSheetId &name) + void readGeorges (const NLMISC::CSmartPtr &form, const std::string &name) { // just call the sound creation method with the xml form. Sound = CSound::createSound(name, form->getRootNode()); @@ -259,8 +259,7 @@ public: void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) { // this structure is fill by the loadForm() function and will contain all you need - //std::map Container; - std::map container; + std::map container; // load the old way for compatibility nlassert(!_Loaded); // Just call the GEORGE::loadFrom method to read all available sounds ::loadForm("sound", packedSheetDir + "sounds.packed_sheets", container, packedSheetUpdate, false); @@ -269,11 +268,12 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) // get the largest sheet id needed and init the sound bank uint32 maxShortId = 0; { - std::map::iterator first(container.begin()), last(container.end()); + std::map::iterator first(container.begin()), last(container.end()); for (; first != last; ++first) { - if (first->first.getShortId() > maxShortId) - maxShortId = first->first.getShortId(); + if (first->second.Sound != 0) + if (first->second.Sound->getName().getShortId() > maxShortId) + maxShortId = first->second.Sound->getName().getShortId(); } ++maxShortId; // inc for size = last idx + 1 if (container.size() == 0) @@ -290,7 +290,7 @@ void CSoundBank::load(const std::string &packedSheetDir, bool packedSheetUpdate) // add all the loaded sound in the sound banks { - std::map::iterator first(container.begin()), last(container.end()); + std::map::iterator first(container.begin()), last(container.end()); for (; first != last; ++first) { if (first->second.Sound != 0) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index d78864684..11d01934f 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -1265,6 +1265,19 @@ void postlogInit() // set the primitive context CPrimitiveContext::instance().CurrentLigoConfig = &LigoConfig; + { + H_AUTO(InitRZShIdI) + + nmsg = "Initializing sheets..."; + ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); + + // Initialize Sheet IDs. + CSheetId::init (ClientCfg.UpdatePackedSheet); + + initLast = initCurrent; + initCurrent = ryzomGetLocalTime(); + } + { H_AUTO(InitRZSound) @@ -1275,12 +1288,13 @@ void postlogInit() { // tmp fix : it seems that, at this point, if the bg downloader window has focus and // not the Ryzom one, then sound init fails - #ifdef NL_OS_WINDOWS + /*#ifdef NL_OS_WINDOWS HWND hWnd = Driver->getDisplay (); nlassert (hWnd); ShowWindow(hWnd, SW_RESTORE); SetForegroundWindow(hWnd); - #endif + #endif*/ + // bg downloader not used anymore anyways SoundMngr = new CSoundManager(&ProgressBar); try { @@ -1323,13 +1337,7 @@ void postlogInit() } { - H_AUTO(InitRZShIdI) - - nmsg = "Initializing sheets..."; - ProgressBar.newMessage ( ClientCfg.buildLoadingString(nmsg) ); - - // Initialize Sheet IDs. - CSheetId::init (ClientCfg.UpdatePackedSheet); + H_AUTO(InitRZSheetL) // load packed sheets nmsg = "Loading sheets..."; From 221d04642a99d103a12eab8c8400549ce5da06de Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 2 Jun 2012 23:06:48 +0200 Subject: [PATCH 10/39] Changed: Debug messages --HG-- branch : sound_dev --- code/nel/src/3d/ps_sound.cpp | 8 ++++++++ code/nel/src/misc/sheet_id.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/code/nel/src/3d/ps_sound.cpp b/code/nel/src/3d/ps_sound.cpp index 5cee12c3e..a5ae6ad26 100644 --- a/code/nel/src/3d/ps_sound.cpp +++ b/code/nel/src/3d/ps_sound.cpp @@ -262,6 +262,14 @@ void CPSSound::serial(NLMISC::IStream &f) throw(NLMISC::EStream) // version 3 : added option to keep original pitch from the .sound sint ver = f.serialVersion(3); + // FIXME: CPSSound is reserialized from the _ParticleSystemProto + // cache when a non-_Shared particle system is instanced, this + // causes unnecessary sheet id lookups from string. + // SLN1: Serialize as uint32, but this requires the editor to know + // the correct sheet id (and thus requires a built sheet_id.bin). + // SLN2: Create a tool that reserializes all ps with sound sheet id + // instead of sheet names, based on a global flag, and serialize + // a flag that specifies if the ps is serialized with id or name. _SoundName.serialString(f, "sound"); sint32 nbSounds; diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 9bb5894b8..b9811c201 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -112,7 +112,7 @@ CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType { std::string withType = sheetName + "." + defaultType; *this = CSheetId(withType); - nldebug("SHEETID: Constructing CSheetId from name '%s' without explicit type, defaulting as '%s' to '%s'", sheetName.c_str(), defaultType.c_str(), withType.c_str()); + // nldebug("SHEETID: Constructing CSheetId from name '%s' without explicit type, defaulting as '%s' to '%s'", sheetName.c_str(), defaultType.c_str(), withType.c_str()); } else *this = CSheetId(sheetName); From 19d2d91f865ce9ca55dcaecec868e66eb7e41c11 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 01:50:53 +0200 Subject: [PATCH 11/39] Added: Specific code for amplitude based rolloff to avoid unneccesary log10 and pow calls and improve performance --HG-- branch : sound_dev --- code/nel/src/sound/driver/source.cpp | 53 ++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index df99b59ee..3ef9aa279 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -65,12 +65,59 @@ sint32 ISource::computeManualRollOff(sint32 volumeMB, sint32 mbMin, sint32 mbMax // common method used only with OptionManualRolloff. return the rolloff in amplitude ratio (gain) float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, float distMax) { - static const sint32 mbMin = -10000; - static const sint32 mbMax = 0; + /*static const sint mbMin = -10000; + static const sint mbMax = 0; sint32 rolloffMb = ISource::computeManualRollOff(mbMax, mbMin, mbMax, alpha, sqrdist, distMin, distMax); float rolloffGain = (float)pow(10.0, (double)rolloffMb / 2000.0); clamp(rolloffGain, 0.0f, 1.0f); - return rolloffGain; + return rolloffGain;*/ + + static const double mbMin = -10000; + static const double mbMax = 0; + + if (sqrdist < distMin * distMin) + { + // no attenuation + return 1.0f; + } + else + { + double dist = (double)sqrt(sqrdist); + if (alpha < 0.0f) + { + // inverse distance rolloff + float rolloff = distMin / dist; + if (alpha <= -1.0f) return rolloff; + + double mb = mbMin * (dist - distMin) / (distMax - distMin); + float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); + return ((1.0 + alpha) * mbrolloff - alpha * rolloff); + } + else + { + if (sqrdist > distMax * distMax) + { + // full attenuation + return 0.0f; + } + if (alpha == 0.0f) + { + // linearly descending volume on a dB scale + double mb = mbMin * (dist - distMin) / (distMax - distMin); + return (float)pow(10.0, (double)mb / 2000.0); + } + else // if (alpha > 0.0f) + { + // linear distance rolloff + float rolloff = (distMax - dist) / (distMax - distMin); + if (alpha >= 1.0f) return rolloff; + + double mb = mbMin * (dist - distMin) / (distMax - distMin); + float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); + return ((1.0 - alpha) * mbrolloff + alpha * rolloff); + } + } + } } } // NLSOUND From 2fc601c556cc907fdaa8a45f8aa742b2e36935aa Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 02:00:32 +0200 Subject: [PATCH 12/39] Changed: Avoid some more sqrt calculations --HG-- branch : sound_dev --- code/nel/src/sound/driver/source.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index 3ef9aa279..a35698d1c 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -82,13 +82,13 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, } else { - double dist = (double)sqrt(sqrdist); if (alpha < 0.0f) { + double dist = (double)sqrt(sqrdist); // inverse distance rolloff float rolloff = distMin / dist; if (alpha <= -1.0f) return rolloff; - + double mb = mbMin * (dist - distMin) / (distMax - distMin); float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); return ((1.0 + alpha) * mbrolloff - alpha * rolloff); @@ -100,6 +100,7 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, // full attenuation return 0.0f; } + double dist = (double)sqrt(sqrdist); if (alpha == 0.0f) { // linearly descending volume on a dB scale @@ -111,7 +112,7 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, // linear distance rolloff float rolloff = (distMax - dist) / (distMax - distMin); if (alpha >= 1.0f) return rolloff; - + double mb = mbMin * (dist - distMin) / (distMax - distMin); float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); return ((1.0 - alpha) * mbrolloff + alpha * rolloff); From 6bc3ef2ba6df4c09d257da71be63fc86eea8019a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 15:56:47 +0200 Subject: [PATCH 13/39] Changed: Also handle distMax with negative alpha in new manual rolloff function --HG-- branch : sound_dev --- code/nel/src/sound/driver/source.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/code/nel/src/sound/driver/source.cpp b/code/nel/src/sound/driver/source.cpp index a35698d1c..6ef5e420c 100644 --- a/code/nel/src/sound/driver/source.cpp +++ b/code/nel/src/sound/driver/source.cpp @@ -89,9 +89,17 @@ float ISource::computeManualRolloff(double alpha, float sqrdist, float distMin, float rolloff = distMin / dist; if (alpha <= -1.0f) return rolloff; - double mb = mbMin * (dist - distMin) / (distMax - distMin); - float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); - return ((1.0 + alpha) * mbrolloff - alpha * rolloff); + if (dist > distMax) + { + // full attenuation of mbrolloff + return (-alpha * rolloff); + } + else + { + double mb = mbMin * (dist - distMin) / (distMax - distMin); + float mbrolloff = (float)pow(10.0, (double)mb / 2000.0); + return ((1.0 + alpha) * mbrolloff - alpha * rolloff); + } } else { From 497ae4d09baf9f2a3407fcc93ca698f2adf9a27e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 15:57:57 +0200 Subject: [PATCH 14/39] Added: Temporary workaround for using sound sheet id without updated sheet id bin --HG-- branch : sound_dev --- code/nel/src/misc/sheet_id.cpp | 46 +++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index b9811c201..72549de42 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -44,6 +44,12 @@ std::map CSheetId::_DevTypeNameToId; std::vector > CSheetId::_DevSheetIdToName; std::map CSheetId::_DevSheetNameToId; +#define NL_TEMP_YUBO_NO_SOUND_SHEET_ID + +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID +namespace { bool a_NoSoundSheetId = false; } +#endif + const CSheetId CSheetId::Unknown(0); void CSheetId::cbFileChange (const std::string &filename) @@ -135,7 +141,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName) if (it == _DevSheetNameToId.end()) { // Create a new dynamic sheet ID. - nldebug("SHEETID: Creating a new dynamic sheet id for '%s'", sheetName.c_str()); + nldebug("SHEETID: Creating a dynamic sheet id for '%s'", sheetName.c_str()); std::string sheetType = CFile::getExtension(sheetNameLc); std::string sheetName = CFile::getFilenameWithoutExtension(sheetNameLc); std::map::iterator tit = _DevTypeNameToId.find(sheetType); @@ -192,6 +198,27 @@ bool CSheetId::buildSheetId(const std::string& sheetName) return true; } } + +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (a_NoSoundSheetId && sheetName.find(".sound") != std::string::npos) + { + std::string sheetNameLc = toLower(sheetName); + std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); + if (it == _DevSheetNameToId.end()) + { + uint32 typeId = typeFromFileExtension("sound"); + nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); + _DevSheetIdToName[0].push_back(sheetName); + _Id.IdInfos.Type = typeId; + _Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; + _DevSheetNameToId[sheetNameLc] = _Id.Id; + return true; + } + _Id.Id = it->second; + return true; + } +#endif + return false; } @@ -345,6 +372,15 @@ void CSheetId::init(bool removeUnknownSheet) loadSheetId (); _Initialised=true; +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (typeFromFileExtension("sound") == std::numeric_limits::max()) + { + nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets"); + _FileExtensions.push_back("sound"); + _DevSheetIdToName.push_back(std::vector()); + a_NoSoundSheetId = true; + } +#endif } // init // @@ -501,6 +537,12 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const } else { +#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID + if (a_NoSoundSheetId && _FileExtensions[_Id.IdInfos.Type] == "sound") + { + return _DevSheetIdToName[0][_Id.IdInfos.Id]; + } +#endif // This nlwarning is commented out because the loggers are mutexed, therefore // you couldn't use toString() within a nlwarning(). //nlwarning(" The sheet %08x is not in sheet_id.bin",_Id.Id); @@ -543,6 +585,8 @@ void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) } else { + // if this assert fails, you may be using an outdated id bin + nlassert(*this != CSheetId::Unknown); std::string sheetName = toString(); f.serial(sheetName); } From 8a696b55e19f73567906f045b65e4b2c273c6b2a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 3 Jun 2012 16:00:43 +0200 Subject: [PATCH 15/39] Fixed: Make build_soundbank tool work with latest changes --HG-- branch : sound_dev --- code/nel/src/sound/audio_mixer_user.cpp | 6 +++++- code/nel/src/sound/group_controller_root.cpp | 2 +- code/nel/src/sound/sound.cpp | 8 ++++---- code/nel/src/sound/sound_bank.cpp | 1 + code/nel/tools/sound/build_soundbank/build_soundbank.cpp | 4 ++++ 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/code/nel/src/sound/audio_mixer_user.cpp b/code/nel/src/sound/audio_mixer_user.cpp index 6eb9a2a2c..da3c7d177 100644 --- a/code/nel/src/sound/audio_mixer_user.cpp +++ b/code/nel/src/sound/audio_mixer_user.cpp @@ -468,7 +468,7 @@ void CAudioMixerUser::initDevice(const std::string &deviceName, const CInitInfo nlwarning("AM: OptionSoftwareBuffer not available, forceSoftwareBuffer = false"); forceSoftware = false; // not really needed, but set anyway in case this is still used later in this function } - if (manualRolloff && !_SoundDriver->getOption(ISoundDriver::OptionLocalBufferCopy)) + if (manualRolloff && !_SoundDriver->getOption(ISoundDriver::OptionManualRolloff)) { nlwarning("AM: OptionManualRolloff not available, manualRolloff = false"); manualRolloff = false; // not really needed, but set anyway in case this is still used later in this function @@ -971,10 +971,14 @@ void CAudioMixerUser::buildSampleBankList() /// Build the sound bank packed sheets file from georges sound sheet files with .sound extension in the search path, and return the path to the written file. std::string UAudioMixer::buildSoundBank(const std::string &packedSheetDir) { + CGroupControllerRoot *tempRoot = NULL; + if (!CGroupControllerRoot::isInitialized()) + tempRoot = new CGroupControllerRoot(); std::string dir = CPath::standardizePath(packedSheetDir, true); CSoundBank *soundBank = new CSoundBank(); soundBank->load(dir, true); delete soundBank; + delete tempRoot; return dir + "sounds.packed_sheets"; } diff --git a/code/nel/src/sound/group_controller_root.cpp b/code/nel/src/sound/group_controller_root.cpp index f460a808b..254dc16f4 100644 --- a/code/nel/src/sound/group_controller_root.cpp +++ b/code/nel/src/sound/group_controller_root.cpp @@ -43,7 +43,7 @@ using namespace std; namespace NLSOUND { -CGroupControllerRoot::CGroupControllerRoot() : CGroupController(NULL) +CGroupControllerRoot::CGroupControllerRoot() : CGroupController(NULL), NLMISC::CManualSingleton() { } diff --git a/code/nel/src/sound/sound.cpp b/code/nel/src/sound/sound.cpp index e7162b3a1..a1c9fd595 100644 --- a/code/nel/src/sound/sound.cpp +++ b/code/nel/src/sound/sound.cpp @@ -136,15 +136,15 @@ void CSound::serial(NLMISC::IStream &s) _Name.serialString(s, "sound"); - nlassert(CGroupControllerRoot::getInstance()); // not sure + nlassert(CGroupControllerRoot::isInitialized()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 - if (s.isReading()) _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER)); + if (s.isReading()) _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER); #else if (s.isReading()) { std::string groupControllerPath; s.serial(groupControllerPath); - _GroupController = static_cast(CAudioMixerUser::instance()->getGroupController(groupControllerPath)); + _GroupController = CGroupControllerRoot::getInstance()->getGroupController(groupControllerPath); } else { @@ -245,7 +245,7 @@ void CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& roo _Priority = MidPri; } - nlassert(CGroupControllerRoot::getInstance()); // not sure + nlassert(CGroupControllerRoot::isInitialized()); // not sure #if NLSOUND_SHEET_VERSION_BUILT < 2 _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_GROUP_CONTROLLER); #else diff --git a/code/nel/src/sound/sound_bank.cpp b/code/nel/src/sound/sound_bank.cpp index 6e24947dd..6421e722b 100644 --- a/code/nel/src/sound/sound_bank.cpp +++ b/code/nel/src/sound/sound_bank.cpp @@ -124,6 +124,7 @@ CSoundBank::~CSoundBank() void CSoundBank::addSound(CSound *sound) { // nlassert(_Sounds.size() > sound->getName().getShortId()); + // nldebug("SOUNDBANK: Add %s", sound->getName().toString().c_str()); if (_Sounds.size() <= sound->getName().getShortId()) _Sounds.resize(sound->getName().getShortId() + 1); _Sounds[sound->getName().getShortId()] = sound; diff --git a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp index 60abe4592..53848e20e 100644 --- a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp +++ b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp @@ -29,6 +29,7 @@ #include #include #include +#include // Project includes // ... @@ -75,6 +76,9 @@ int main(int nNbArg, char **ppArgs) // add search paths CPath::addSearchPath(leveldesignDir, true, false); CPath::addSearchPath(dfnDir, true, false); + + // init sheet_id.bin + NLMISC::CSheetId::init(false); // build the sound bank UAudioMixer::buildSoundBank(exportDir); From d3352cecf6d83ad51ca0b57d0d68a7356983c53a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 4 Jun 2012 12:35:34 +0200 Subject: [PATCH 16/39] Changed: Removed some debug messages --HG-- branch : sound_dev --- code/nel/src/misc/sheet_id.cpp | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 72549de42..62dc19013 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -141,7 +141,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName) if (it == _DevSheetNameToId.end()) { // Create a new dynamic sheet ID. - nldebug("SHEETID: Creating a dynamic sheet id for '%s'", sheetName.c_str()); + // nldebug("SHEETID: Creating a dynamic sheet id for '%s'", sheetName.c_str()); std::string sheetType = CFile::getExtension(sheetNameLc); std::string sheetName = CFile::getFilenameWithoutExtension(sheetNameLc); std::map::iterator tit = _DevTypeNameToId.find(sheetType); @@ -207,7 +207,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName) if (it == _DevSheetNameToId.end()) { uint32 typeId = typeFromFileExtension("sound"); - nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); + // nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); _DevSheetIdToName[0].push_back(sheetName); _Id.IdInfos.Type = typeId; _Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; @@ -395,14 +395,8 @@ void CSheetId::initWithoutSheet() _Initialised = true; _DontHaveSheetKnowledge = true; - /*_FileExtensions.push_back("unknown"); - _DevTypeNameToId["unknown"] = 0; - _DevSheetIdToName.push_back(std::vector()); - _DevSheetIdToName[0].push_back("unknown"); - _DevSheetNameToId["unknown.unknown"] = 0;*/ - + // Initialize id 0,0 as unknown.unknown CSheetId unknownunknown = CSheetId("unknown.unknown"); - // nldebug("SHEETID: unknown: %i, Unknown: %i", unknownunknown._Id, Unknown._Id); nlassert(unknownunknown == CSheetId::Unknown); } @@ -452,26 +446,6 @@ CSheetId& CSheetId::operator=( const CSheetId& sheetId ) //----------------------------------------------- CSheetId& CSheetId::operator=( const string& sheetName ) { - /*nlassert(_Initialised); - nlassert(!_DontHaveSheetKnowledge); - - CStaticMap::const_iterator itId; - CChar c; - c.Ptr = new char [sheetName.size()+1]; - strcpy(c.Ptr, sheetName.c_str()); - toLower(c.Ptr); - - itId = _SheetNameToId.find (c); - delete [] c.Ptr; - if( itId != _SheetNameToId.end() ) - { - _Id.Id = (*itId).second; - return *this; - } - *this = Unknown; - return *this;*/ - - // doesn't make sense to have a copy of the same code here... if (!buildSheetId(sheetName)) *this = Unknown; From 36eb2a3057819382e16e0e948e46f0916b45492a Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 4 Jun 2012 12:37:56 +0200 Subject: [PATCH 17/39] Changed: Tool build_soundbank can also work without sheet id bin --HG-- branch : sound_dev --- code/nel/tools/sound/build_soundbank/build_soundbank.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp index 53848e20e..b8a79d9cf 100644 --- a/code/nel/tools/sound/build_soundbank/build_soundbank.cpp +++ b/code/nel/tools/sound/build_soundbank/build_soundbank.cpp @@ -78,7 +78,7 @@ int main(int nNbArg, char **ppArgs) CPath::addSearchPath(dfnDir, true, false); // init sheet_id.bin - NLMISC::CSheetId::init(false); + NLMISC::CSheetId::initWithoutSheet(); // build the sound bank UAudioMixer::buildSoundBank(exportDir); From fc8e83a0b922a193a586a07fae60153b03e6dc23 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 4 Jun 2012 13:27:12 +0200 Subject: [PATCH 18/39] Changed: Assign sane type id to temporary sound sheet ids --HG-- branch : sound_dev --- code/nel/src/misc/sheet_id.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index 62dc19013..fb2627b5e 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -206,7 +206,7 @@ bool CSheetId::buildSheetId(const std::string& sheetName) std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); if (it == _DevSheetNameToId.end()) { - uint32 typeId = typeFromFileExtension("sound"); + uint32 typeId = ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1); // nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); _DevSheetIdToName[0].push_back(sheetName); _Id.IdInfos.Type = typeId; @@ -376,7 +376,8 @@ void CSheetId::init(bool removeUnknownSheet) if (typeFromFileExtension("sound") == std::numeric_limits::max()) { nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets"); - _FileExtensions.push_back("sound"); + nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS)); + _FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound"; _DevSheetIdToName.push_back(std::vector()); a_NoSoundSheetId = true; } @@ -512,7 +513,7 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const else { #ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID - if (a_NoSoundSheetId && _FileExtensions[_Id.IdInfos.Type] == "sound") + if (a_NoSoundSheetId && _Id.IdInfos.Type == ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)) { return _DevSheetIdToName[0][_Id.IdInfos.Id]; } From a57881561be9cbb1918b6a160165aca5caf9a43e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 4 Jun 2012 13:28:03 +0200 Subject: [PATCH 19/39] Fixed: Bad serialization of sound name in background sounds --HG-- branch : sound_dev --- code/nel/include/nel/sound/background_sound.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/code/nel/include/nel/sound/background_sound.h b/code/nel/include/nel/sound/background_sound.h index 54e91e712..bf83f0413 100644 --- a/code/nel/include/nel/sound/background_sound.h +++ b/code/nel/include/nel/sound/background_sound.h @@ -69,17 +69,7 @@ public: void serial(NLMISC::IStream &s) { - std::string soundName; - if (s.isReading()) - { - s.serial(soundName); - SoundName = NLMISC::CSheetId(soundName);/*NLMISC::CStringMapper::map(soundName)*/; - } - else - { - soundName = SoundName.toString();/* NLMISC::CStringMapper::unmap(SoundName)*/; - s.serial(soundName); - } + SoundName.serialString(s, "sound"); s.serial(Filter); } }; From c618a292761c171eaefe45e73bc9e682d16a37f3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Mon, 4 Jun 2012 15:03:40 +0200 Subject: [PATCH 20/39] Reverted: Unnecessary changes to config and data from merge --- .../newbieland/urban_newbieland.primitive | 642 +----------------- code/ryzom/server/frontend_service.cfg | 2 +- code/ryzom/server/shard_start_cmake.bat | 2 +- 3 files changed, 18 insertions(+), 628 deletions(-) diff --git a/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive b/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive index 42cd70726..0aa00b3bb 100644 --- a/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive +++ b/code/ryzom/common/data_leveldesign/primitives/newbieland/urban_newbieland.primitive @@ -1,7 +1,7 @@ - + class @@ -126,10 +126,6 @@ #mission tags and pre-requisites replayable solo - mission_category : Killing - player_replay_timer : 10 - global_replay_timer : 10 - mission_icon : tets #Variables declaration decl : bot : giver @@ -142,7 +138,7 @@ mission_title : WELCOME_RYZOM_CORE_TITLE mission_desc : WELCOME_RYZOM_CORE_DESC # step_4 - kill_fauna : chdfa1 1 + kill_fauna : chdfa1 3 recv_money : 10000 @@ -158,157 +154,6 @@ - - - class - mission - - - name - HUNTING_GROUNDS - - - script - # script generated from 'urban_newbieland.primitive' - - #mission tags and pre-requisites - replayable - guild - mission_category : Killing - player_replay_timer : 10 - global_replay_timer : 10 - mission_icon : test - - #Variables declaration - decl : bot : giver - decl : bot : player - decl : bot : chiang_the_strong - - #pre-requisites - req_guild - req_grade : Leader - - #script - mission_title : WELCOME_RYZOM_CORE_DESC - mission_desc : WELCOME_RYZOM_CORE_TITLE - # step_4 - spawn_mission : WELCOME_RYZOM_CORE : chiang_the_strong : guild - set_obj : MIS_DO_MISSION - mission : WELCOME_RYZOM_CORE 2 - kill_fauna : chdfa1 2 - recv_money : 100000 - recv_money : 20: guild - - - - - - class - alias - - - name - alias - - - - - - class - mission - - - name - GUILD_MISSION - - - script - # script generated from 'guild_missions.primitive' - - #mission tags and pre-requisites - replayable - guild - mission_category : Killing - - #Variables declaration - decl : bot : giver - decl : bot : player - decl : bot : chiang_the_strong - - #pre-requisites - req_guild - req_grade : Leader - - #script - mission_title : GUILD_MISSION_TITLE - mission_desc : GUILD_MISSION_DESC - # step - spawn_mission : SOLO_GUILD_MISSION : chiang_the_strong : guild - set_obj : MIS_DO_MISSION - mission : SOLO_GUILD_MISSION 2 - kill_fauna : chdfa1 2 - recv_money : 100: guild - recv_money : 50 - - - - - - class - alias - - - name - alias - - - - - - class - mission - - - name - SOLO_GUILD_MISSION - - - script - # script generated from 'guild_missions.primitive' - - #mission tags and pre-requisites - replayable - solo - mission_category : Killing - not_proposed - - #Variables declaration - decl : bot : giver - decl : bot : player - decl : bot : chiang_the_strong - - #pre-requisites - - #script - mission_title : SOLO_GUILD_MISSION_TITLE - mission_desc : SOLO_GUILD_MISSION_DESC - # step - kill_fauna : chdfa1 1 - recv_money : 20 - - - - - - class - alias - - - name - alias - - - @@ -472,46 +317,6 @@ - - - - chat_parameters - shop:guild_creator - menu: MENU_WHOAMI WHOAMI_GUILD_CLERK - - - class - npc_bot - - - equipment - CU: 4 - CL: 4 - - - is_stuck - true - - - name - creator - - - sheet_client - fyhc3old - - - - - class - alias - - - name - alias - - - @@ -591,8 +396,19 @@ chat_parameters - shop:guild_creator - menu: MENU_WHOAMI WHOAMI_GUILD_CLERK + shop : NEWBIELAND_LARMOR_ALL + item : icmalb.sitem 10 + item : icmalb.sitem 20 + item : icmalb.sitem 50 + item : icfalb.sitem 10 + item : icfalb.sitem 20 + item : icfalb.sitem 50 + item : ictalb.sitem 10 + item : ictalb.sitem 20 + item : ictalb.sitem 50 + item : iczalb.sitem 10 + item : iczalb.sitem 20 + item : iczalb.sitem 50 class @@ -628,119 +444,6 @@ - - - class - npc_folder - - - name - Guild creator - - - - - class - alias - - - name - alias - - - - - class - npc_zone - - - name - Npc Zone - - - - - class - alias - - - name - alias - - - - - bot_sheet_client - maha2 - - - class - npc_group - - - name - Group - - - - class - npc_group_parameters - - - name - parameters - - - - - - class - alias - - - name - alias - - - - - - chat_parameters - shop:guild_creator - menu: MENU_WHOAMI WHOAMI_GUILD_CLERK - - - class - npc_bot - - - equipment - CU: 4 - CL: 4 - - - name - guild_creator - - - sheet_client - fyhc3old - - - - - class - alias - - - name - alias - - - - - - @@ -752,38 +455,14 @@ missions_editor - - audience - solo - - - auto_remove_from_journal - false - - - automatic - false - class mission_tree - - fail_if_inventory_is_full - false - giver_primitive urban_newbieland.primitive - - global_replay_timer - 10 - - - mission_category - Killing - mission_description WELCOME_RYZOM_CORE_DESC @@ -792,18 +471,10 @@ mission_giver $givervar@fullname$ - - mission_icon - tets - mission_title WELCOME_RYZOM_CORE_TITLE - - mono_instance - false - name WELCOME_RYZOM_CORE @@ -812,34 +483,10 @@ need_validation false - - non_abandonnable - false - - - not_in_journal - false - - - not_proposed - false - - - phrase_auto_menu - TEST - - - player_replay_timer - 10 - replayable true - - run_only_once - false - class @@ -924,7 +571,7 @@ fauna/quantity - chdfa1 1 + chdfa1 3 @@ -950,263 +597,6 @@ - - - audience - guild - - - auto_remove_from_journal - false - - - automatic - false - - - class - mission_tree - - - fail_if_inventory_is_full - false - - - giver_primitive - urban_newbieland.primitive - - - global_replay_timer - 10 - - - mission_category - Killing - - - mission_description - WELCOME_RYZOM_CORE_TITLE - - - mission_giver - $givervar@fullname$ - - - mission_icon - test - - - mission_title - WELCOME_RYZOM_CORE_DESC - - - mono_instance - false - - - name - HUNTING_GROUNDS - - - need_validation - false - - - non_abandonnable - false - - - not_in_journal - false - - - not_proposed - false - - - phrase_auto_menu - TEST - - - player_replay_timer - 10 - - - replayable - true - - - run_only_once - false - - - - class - variables - - - name - variables - - - - class - var_npc - - - npc_function - fct_ranger_leader - - - npc_name - chiang_the_strong - - - var_name - givervar - - - - - - class - pre_requisite - - - name - pre_requisite - - - require_guild_grade - Leader - - - require_guild_membership - true - - - - - - class - alias - - - name - alias - - - - - class - step - - - name - step_4 - - - - class - actions - - - name - pre_actions - - - - class - spawn_mission - - - giver_name - chiang_the_strong - - - guild - true - - - mission_name - WELCOME_RYZOM_CORE - - - - - - class - mission_objectives - - - name - objectives - - - - class - do_mission - - - mission_names - WELCOME_RYZOM_CORE 2 - - - overload_objective - MIS_DO_MISSION - - - - - class - kill - - - fauna/quantity - chdfa1 2 - - - name - kill chdfa1 2 - - - - - - class - actions - - - name - post_actions - - - - amount - 100000 - - - class - recv_money - - - - - amount - 20 - - - class - recv_money - - - guild - true - - - - - diff --git a/code/ryzom/server/frontend_service.cfg b/code/ryzom/server/frontend_service.cfg index a73c02316..c9392bd51 100644 --- a/code/ryzom/server/frontend_service.cfg +++ b/code/ryzom/server/frontend_service.cfg @@ -6,7 +6,7 @@ BandwidthRatio = 1; FSUDPPort = 47851; -FSListenHost = "192.168.1.112"; +FSListenHost = "open.ryzom.com"; #include "frontend_service_default.cfg" diff --git a/code/ryzom/server/shard_start_cmake.bat b/code/ryzom/server/shard_start_cmake.bat index 9d68b5272..943a0b5f3 100644 --- a/code/ryzom/server/shard_start_cmake.bat +++ b/code/ryzom/server/shard_start_cmake.bat @@ -3,7 +3,7 @@ REM This script will start all the services with good parameters REM set MODE=Debug -set MODE=..\..\build\bin\Debug +set MODE=..\..\build\bin\Release rem AS start %MODE%\ryzom_admin_service.exe --fulladminname=admin_executor_service --shortadminname=AES From 6a806d82d2016dab25b775528826fca2633a68d1 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 5 Jun 2012 14:03:38 +0200 Subject: [PATCH 21/39] Changed: Small optimization for sheet id constructor with default type --- code/nel/src/misc/sheet_id.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index fb2627b5e..dd9753ded 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -114,14 +114,19 @@ CSheetId::CSheetId( const string& sheetName ) CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType ) { - if (CFile::getExtension(sheetName) == "" && defaultType != "") + // Don't use this function without defaultType, use the one above. + nlassert(defaultType.size() != 0); + + if (sheetName.rfind('.') == std::string::npos) { std::string withType = sheetName + "." + defaultType; *this = CSheetId(withType); // nldebug("SHEETID: Constructing CSheetId from name '%s' without explicit type, defaulting as '%s' to '%s'", sheetName.c_str(), defaultType.c_str(), withType.c_str()); } else + { *this = CSheetId(sheetName); + } } From 8a80c21661ce3ddc14c0c98afdc091f222ba5aef Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 5 Jun 2012 15:13:13 +0200 Subject: [PATCH 22/39] Changed: Reserve sheet id with short id 0 for unknown sheet for new sheet types --- code/nel/src/misc/sheet_id.cpp | 16 ++++++++++++++-- .../tools/misc/make_sheet_id/make_sheet_id.cpp | 15 +++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index dd9753ded..a66d3c64f 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -157,13 +157,18 @@ bool CSheetId::buildSheetId(const std::string& sheetName) _DevSheetIdToName.push_back(std::vector()); typeId = _FileExtensions.size() - 1; _DevTypeNameToId[sheetType] = typeId; + std::string unknownNewType = std::string("unknown." + sheetType); + _DevSheetIdToName[typeId].push_back(unknownNewType); + _Id.IdInfos.Type = typeId; + _Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1; + _DevSheetNameToId[unknownNewType] = _Id.Id; } else { typeId = tit->second; + _Id.IdInfos.Type = typeId; } - _DevSheetIdToName[typeId].push_back(sheetName); - _Id.IdInfos.Type = typeId; + _DevSheetIdToName[typeId].push_back(sheetNameLc); _Id.IdInfos.Id = _DevSheetIdToName[typeId].size() - 1; // nldebug("SHEETID: Type %i, id %i, sheetid %i", _Id.IdInfos.Type, _Id.IdInfos.Id, _Id.Id); _DevSheetNameToId[sheetNameLc] = _Id.Id; @@ -381,9 +386,16 @@ void CSheetId::init(bool removeUnknownSheet) if (typeFromFileExtension("sound") == std::numeric_limits::max()) { nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets"); + uint32 typeId = ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1); nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS)); _FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound"; _DevSheetIdToName.push_back(std::vector()); + _DevSheetIdToName[0].push_back("unknown.sound"); + TSheetId id; + id.IdInfos.Type = typeId; + id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; + nlassert(id.IdInfos.Id == 0); + _DevSheetNameToId["unknown.sound"] = id.Id; a_NoSoundSheetId = true; } #endif diff --git a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp index 2756f1b09..b5dda0c06 100644 --- a/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp +++ b/code/nel/tools/misc/make_sheet_id/make_sheet_id.cpp @@ -336,16 +336,27 @@ void addId( string fileName ) if( firstFreeFileTypeId == -1 ) { nlwarning("MORE THAN 256 FILE TYPES!!!!"); + return; } else { FileTypeToId.insert( make_pair(fileType,(uint8)firstFreeFileTypeId) ); IdToFileType.insert( make_pair((uint8)firstFreeFileTypeId,fileType) ); - TypeToLastId.insert( make_pair((uint8)firstFreeFileTypeId,0) ); + // Reserve id 0 for unknown.newtype. + // User may supply a sheet called unknown.newtype + // that can safely be used as a fallback when a + // requested sheet does not exist. + // Only for newly added sheet types. fid.FormIDInfos.Type = (uint8)firstFreeFileTypeId; fid.FormIDInfos.Id = 0; - + std::string unknownNewType = std::string("unknown." + fileType); + FormToId.insert(make_pair(unknownNewType, fid)); + IdToForm.insert(make_pair(fid, unknownNewType)); + + TypeToLastId.insert( make_pair((uint8)firstFreeFileTypeId,1) ); + fid.FormIDInfos.Id = 1; + nlinfo("Adding file type '%s' with id %d", fileType.c_str(), firstFreeFileTypeId); NbTypesAdded++; } From 67c2eb523fdde99396515c9f027049e04d285e4c Mon Sep 17 00:00:00 2001 From: kaetemi Date: Tue, 5 Jun 2012 19:11:43 +0200 Subject: [PATCH 23/39] Changed: Different default type id for sound sheet id workaround --- code/nel/src/misc/sheet_id.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/code/nel/src/misc/sheet_id.cpp b/code/nel/src/misc/sheet_id.cpp index a66d3c64f..0ff90b1f8 100644 --- a/code/nel/src/misc/sheet_id.cpp +++ b/code/nel/src/misc/sheet_id.cpp @@ -47,7 +47,7 @@ std::map CSheetId::_DevSheetNameToId; #define NL_TEMP_YUBO_NO_SOUND_SHEET_ID #ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID -namespace { bool a_NoSoundSheetId = false; } +namespace { bool a_NoSoundSheetId = false; const uint32 a_NoSoundSheetType = 80; } #endif const CSheetId CSheetId::Unknown(0); @@ -110,6 +110,8 @@ CSheetId::CSheetId( const string& sheetName ) *this = Unknown; } + // nldebug("LIST_SHEET_ID: %s (%s)", toString().c_str(), sheetName.c_str()); + } // CSheetId // CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType ) @@ -216,10 +218,9 @@ bool CSheetId::buildSheetId(const std::string& sheetName) std::map::iterator it = _DevSheetNameToId.find(sheetNameLc); if (it == _DevSheetNameToId.end()) { - uint32 typeId = ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1); // nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str()); _DevSheetIdToName[0].push_back(sheetName); - _Id.IdInfos.Type = typeId; + _Id.IdInfos.Type = a_NoSoundSheetType; _Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; _DevSheetNameToId[sheetNameLc] = _Id.Id; return true; @@ -386,13 +387,13 @@ void CSheetId::init(bool removeUnknownSheet) if (typeFromFileExtension("sound") == std::numeric_limits::max()) { nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets"); - uint32 typeId = ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1); nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS)); - _FileExtensions[((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)] == "sound"; + nlassert(_FileExtensions[a_NoSoundSheetType].empty()); + _FileExtensions[a_NoSoundSheetType] == "sound"; _DevSheetIdToName.push_back(std::vector()); _DevSheetIdToName[0].push_back("unknown.sound"); TSheetId id; - id.IdInfos.Type = typeId; + id.IdInfos.Type = a_NoSoundSheetType; id.IdInfos.Id = _DevSheetIdToName[0].size() - 1; nlassert(id.IdInfos.Id == 0); _DevSheetNameToId["unknown.sound"] = id.Id; @@ -467,6 +468,9 @@ CSheetId& CSheetId::operator=( const string& sheetName ) if (!buildSheetId(sheetName)) *this = Unknown; + + // nldebug("LIST_SHEET_ID: %s (%s)", toString().c_str(), sheetName.c_str()); + return *this; } // operator= // @@ -530,7 +534,7 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const else { #ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID - if (a_NoSoundSheetId && _Id.IdInfos.Type == ((1 << (NL_SHEET_ID_TYPE_BITS)) - 1)) + if (a_NoSoundSheetId && _Id.IdInfos.Type == a_NoSoundSheetType) { return _DevSheetIdToName[0][_Id.IdInfos.Id]; } From e9f75e639d0f7278f03e7ed75453789f14795646 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 28 Jun 2012 11:08:36 +0200 Subject: [PATCH 24/39] Fixed: Valgrind warnings --- code/nel/src/3d/point_light.cpp | 1 + code/nel/src/3d/render_trav.cpp | 1 + code/nel/src/3d/visual_collision_mesh.cpp | 3 ++- code/nel/src/misc/fixed_size_allocator.cpp | 2 +- code/nel/src/misc/path.cpp | 2 +- code/nel/src/sound/complex_source.cpp | 3 ++- .../client/src/interface_v3/group_html.cpp | 23 ++++++++++--------- code/ryzom/common/src/game_share/fame.cpp | 4 ++-- 8 files changed, 22 insertions(+), 17 deletions(-) diff --git a/code/nel/src/3d/point_light.cpp b/code/nel/src/3d/point_light.cpp index a67125e21..e441e198e 100644 --- a/code/nel/src/3d/point_light.cpp +++ b/code/nel/src/3d/point_light.cpp @@ -40,6 +40,7 @@ CPointLight::CPointLight() : _LightedModels(/*&_LightedModelListMemory*/) _Diffuse= _Specular= CRGBA::White; // Default setup. this is arbitrary + _Type= PointLight; _AttenuationBegin= 10; _AttenuationEnd= 30; diff --git a/code/nel/src/3d/render_trav.cpp b/code/nel/src/3d/render_trav.cpp index 229c5846c..a8965f60e 100644 --- a/code/nel/src/3d/render_trav.cpp +++ b/code/nel/src/3d/render_trav.cpp @@ -69,6 +69,7 @@ CRenderTrav::CRenderTrav() _CurrentPassOpaque = true; _CacheLightContribution= NULL; + _LastLocalAttenuation= false; // Default light Setup. LightingSystemEnabled= false; diff --git a/code/nel/src/3d/visual_collision_mesh.cpp b/code/nel/src/3d/visual_collision_mesh.cpp index b5c58dc98..3217a560f 100644 --- a/code/nel/src/3d/visual_collision_mesh.cpp +++ b/code/nel/src/3d/visual_collision_mesh.cpp @@ -512,7 +512,8 @@ void CVisualCollisionMesh::receiveShadowMap(const NLMISC::CMatrix &instanceMatr } // if triangle not clipped, add the triangle - if( (triFlag & NL3D_VCM_SHADOW_NUM_CLIP_PLANE_MASK)==0 ) + // if( (triFlag & NL3D_VCM_SHADOW_NUM_CLIP_PLANE_MASK)==0 ) + if (triFlag == 0) // previous line not useful due to init { // Add the 3 index to the index buffer. ibPtr[currentTriIdx++]= (uint16) triId[0]; diff --git a/code/nel/src/misc/fixed_size_allocator.cpp b/code/nel/src/misc/fixed_size_allocator.cpp index 0744951a9..f16e87dd4 100644 --- a/code/nel/src/misc/fixed_size_allocator.cpp +++ b/code/nel/src/misc/fixed_size_allocator.cpp @@ -100,7 +100,7 @@ CFixedSizeAllocator::CChunk::~CChunk() nlassert(NumFreeObjs == 0); nlassert(Allocator->_NumChunks > 0); -- (Allocator->_NumChunks); - delete Mem; + delete[] Mem; } // ***************************************************************************************************************** diff --git a/code/nel/src/misc/path.cpp b/code/nel/src/misc/path.cpp index 59d887295..bcef9bdeb 100644 --- a/code/nel/src/misc/path.cpp +++ b/code/nel/src/misc/path.cpp @@ -83,7 +83,7 @@ CFileContainer::~CFileContainer() { if( _AllFileNames ) { - delete _AllFileNames; + delete[] _AllFileNames; _AllFileNames = NULL; } } diff --git a/code/nel/src/sound/complex_source.cpp b/code/nel/src/sound/complex_source.cpp index 685897413..103c6cc60 100644 --- a/code/nel/src/sound/complex_source.cpp +++ b/code/nel/src/sound/complex_source.cpp @@ -28,7 +28,8 @@ namespace NLSOUND CComplexSource::CComplexSource (CComplexSound *soundPattern, bool spawn, TSpawnEndCallback cb, void *cbUserParam, NL3D::CCluster *cluster, CGroupController *groupController) : CSourceCommon(soundPattern, spawn, cb, cbUserParam, cluster, groupController), _Source1(NULL), - _Source2(NULL) + _Source2(NULL), + _Muted(false) { nlassert(soundPattern->getSoundType() == CSound::SOUND_COMPLEX); _PatternSound = static_cast(soundPattern); diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index 7a599ff4b..166a26f63 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -223,7 +223,7 @@ bool CGroupHTML::addBnpDownload(const string &url, const string &action, const s #ifdef LOG_DL nlwarning("add to download '%s' dest '%s'", url.c_str(), dest.c_str()); #endif - + // erase the tmp file if exists if (NLMISC::CFile::fileExists(tmpdest)) NLMISC::CFile::deleteFile(tmpdest); @@ -622,7 +622,7 @@ void CGroupHTML::addLink (uint element_number, uint /* attribute_number */, HTCh _LinkTitle.push_back(""); } - + } } } @@ -948,7 +948,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c typedef pair TTmplParam; vector tmplParams; - + string templateName; if (!style.empty()) { @@ -1044,12 +1044,12 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c CRGBA bgColor = getColor (value[HTML_BODY_BGCOLOR]); setBackgroundColor (bgColor); } - + string style; if (present[HTML_BODY_STYLE] && value[HTML_BODY_STYLE]) style = value[HTML_BODY_STYLE]; - - + + if (!style.empty()) { TStyle styles = parseStyle(style); @@ -1057,7 +1057,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c it = styles.find("background-repeat"); bool repeat = (it != styles.end() && it->second == "1"); - + // Webig only it = styles.find("background-scale"); bool scale = (it != styles.end() && it->second == "1"); @@ -1187,7 +1187,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c if (it != styles.end() && (*it).second == "1") reloadImg = true; } - + addImage (value[MY_HTML_IMG_SRC], globalColor, reloadImg); } } @@ -1838,6 +1838,7 @@ CGroupHTML::CGroupHTML(const TCtorParam ¶m) _GroupHtmlByUID[_GroupHtmlUID]= this; // init + _TrustedDomain = false; _ParsingLua = false; _IgnoreText = false; _BrowseNextTime = false; @@ -2469,7 +2470,7 @@ void CGroupHTML::addString(const ucstring &str) getParagraph()->addChild (buttonGroup); paragraphChange (); } - + } else { @@ -3706,14 +3707,14 @@ int CGroupHTML::luaRemoveContent(CLuaState &ls) } // *************************************************************************** -int CGroupHTML::luaInsertText(CLuaState &ls) +int CGroupHTML::luaInsertText(CLuaState &ls) { const char *funcName = "insertText"; CLuaIHM::checkArgCount(ls, funcName, 3); CLuaIHM::checkArgType(ls, funcName, 1, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 2, LUA_TSTRING); CLuaIHM::checkArgType(ls, funcName, 3, LUA_TBOOLEAN); - + string name = ls.toString(1); ucstring text; diff --git a/code/ryzom/common/src/game_share/fame.cpp b/code/ryzom/common/src/game_share/fame.cpp index b3634f979..541a2e8d9 100644 --- a/code/ryzom/common/src/game_share/fame.cpp +++ b/code/ryzom/common/src/game_share/fame.cpp @@ -320,9 +320,9 @@ CStaticFames::CStaticFames() //---------------------------------------------------------------------------- CStaticFames::~CStaticFames() { - delete _FameTable; + delete[] _FameTable; _FameTable = NULL; - delete _PropagationFactorTable; + delete[] _PropagationFactorTable; _PropagationFactorTable = NULL; } From d79e04e4dd9ce0aee19b43973a627c70103522ef Mon Sep 17 00:00:00 2001 From: kaetemi Date: Thu, 28 Jun 2012 11:30:58 +0200 Subject: [PATCH 25/39] Fixed: Valgrind warnings --- code/nel/src/3d/render_trav.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/nel/src/3d/render_trav.cpp b/code/nel/src/3d/render_trav.cpp index a8965f60e..5cf6fd20e 100644 --- a/code/nel/src/3d/render_trav.cpp +++ b/code/nel/src/3d/render_trav.cpp @@ -69,7 +69,6 @@ CRenderTrav::CRenderTrav() _CurrentPassOpaque = true; _CacheLightContribution= NULL; - _LastLocalAttenuation= false; // Default light Setup. LightingSystemEnabled= false; @@ -624,7 +623,7 @@ void CRenderTrav::changeLightSetup(CLightContribution *lightContribution, bool uint i; // if same lightContribution, no-op. - if(_CacheLightContribution == lightContribution && _LastLocalAttenuation == useLocalAttenuation) + if (_CacheLightContribution == lightContribution && (lightContribution == NULL || _LastLocalAttenuation == useLocalAttenuation)) return; // else, must setup the lights into driver. else From 0e1d8836a783bb67ed745349f6a13cd1f3107526 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 20 Jul 2012 18:51:50 +0200 Subject: [PATCH 26/39] Fixed: Bad path in ryzom.desktop.in --- code/ryzom/client/unix/ryzom.desktop.in | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/ryzom/client/unix/ryzom.desktop.in b/code/ryzom/client/unix/ryzom.desktop.in index ded90c67f..6c967a61c 100644 --- a/code/ryzom/client/unix/ryzom.desktop.in +++ b/code/ryzom/client/unix/ryzom.desktop.in @@ -3,11 +3,14 @@ Version=1.0 Name=Ryzom Name[ru]=Ризом Type=Application -GenericName=ryzom +GenericName=Game client Comment=Ryzom client Comment[fr_FR]=Client Ryzom -Exec=${RYZOM_BIN_PREFIX}/ryzom_client +TryExec=${RYZOM_GAMES_PREFIX}/ryzom_client +Exec=${RYZOM_GAMES_PREFIX}/ryzom_client Icon=ryzom Terminal=false Hidden=false Categories=Game;RolePlaying; +StartupWMClass=ryzom +X-AppInstall-Package=ryzom-client From 1d35fd5b7b2584e49e6e805f12047f3c10f22b77 Mon Sep 17 00:00:00 2001 From: sfb Date: Mon, 23 Jul 2012 12:26:38 -0500 Subject: [PATCH 27/39] Additional build path ignore. --- .hgignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgignore b/.hgignore index 1fbad60fd..6f730f76e 100644 --- a/.hgignore +++ b/.hgignore @@ -153,6 +153,7 @@ code/nelns/build/* code/snowballs/build/* code/ryzom/build/* code/build/* +code/build-2010/* build/* install/* From 59bdae308e9521fcd446345112522928bb9df35e Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 25 Jul 2012 10:13:58 +0200 Subject: [PATCH 28/39] Fixed: Compile error in mfc world editor primitive plugin --- .../world_editor_primitive_plugin/primitive_plugin.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h index 416f05204..104f9d007 100644 --- a/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_primitive_plugin/primitive_plugin.h @@ -72,7 +72,7 @@ private: void serial (NLMISC::IStream &s); - static uint getVersion () + static uint getVersion (); void removed() {} }; From d44cbd240cdb56703ab147718b888f479e72271c Mon Sep 17 00:00:00 2001 From: kaetemi Date: Wed, 25 Jul 2012 10:15:04 +0200 Subject: [PATCH 29/39] Fixed: Compile error in MFC Object Viewer with sound sheet id as CSheetId --- code/nel/tools/3d/object_viewer/edit_ps_sound.cpp | 10 +++++----- code/nel/tools/3d/object_viewer/pick_sound.cpp | 4 ++-- code/nel/tools/3d/object_viewer/pick_sound.h | 8 ++++---- code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp | 10 +++++----- code/nel/tools/3d/object_viewer/sound_system.cpp | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp b/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp index afb53aa84..891818a43 100644 --- a/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp +++ b/code/nel/tools/3d/object_viewer/edit_ps_sound.cpp @@ -159,7 +159,7 @@ END_MESSAGE_MAP() void CEditPSSound::OnBrowseSound() { // CPickSound::TNameVect names; - vector names; + vector names; NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer(); @@ -172,7 +172,7 @@ void CEditPSSound::OnBrowseSound() if (ps.DoModal() == IDOK) { - m_SoundName = NLMISC::CStringMapper::unmap(ps.getName()).c_str(); + m_SoundName = ps.getName().toString().c_str(); _Sound->setSoundName(ps.getName()); updateModifiedFlag(); UpdateData(FALSE); @@ -184,7 +184,7 @@ BOOL CEditPSSound::OnInitDialog() CDialog::OnInitDialog(); nlassert(_Sound); - m_SoundName = NLMISC::CStringMapper::unmap(_Sound->getSoundName()).c_str(); + m_SoundName = _Sound->getSoundName().toString().c_str(); UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control @@ -195,7 +195,7 @@ void CEditPSSound::OnChangeSoundName() { nlassert(_Sound); UpdateData(); - _Sound->setSoundName( NLMISC::CStringMapper::map((LPCTSTR) m_SoundName) ); + _Sound->setSoundName(NLMISC::CSheetId((LPCTSTR)m_SoundName, "sound")); updateModifiedFlag(); } @@ -209,7 +209,7 @@ void CEditPSSound::OnSpawn() // play the currently selected sound void CEditPSSound::OnPlaySound() { - CSoundSystem::play(std::string((LPCTSTR) m_SoundName)); + CSoundSystem::play(std::string((LPCTSTR)m_SoundName)); } void CEditPSSound::OnMute() diff --git a/code/nel/tools/3d/object_viewer/pick_sound.cpp b/code/nel/tools/3d/object_viewer/pick_sound.cpp index 0a6452861..280a65326 100644 --- a/code/nel/tools/3d/object_viewer/pick_sound.cpp +++ b/code/nel/tools/3d/object_viewer/pick_sound.cpp @@ -74,7 +74,7 @@ BOOL CPickSound::OnInitDialog() for (TNameVect::iterator it = _Names.begin(); it != _Names.end(); ++it) { - m_NameList.AddString(NLMISC::CStringMapper::unmap(*it).c_str()); + m_NameList.AddString((*it).toString().c_str()); } _Timer = SetTimer (1, 100, NULL); @@ -111,7 +111,7 @@ void CPickSound::OnSelchange() nlassert(m_NameList.GetTextLen(m_NameList.GetCurSel()) < 1024); m_NameList.GetText(m_NameList.GetCurSel(), str); - _CurrName = NLMISC::CStringMapper::map(str); + _CurrName = NLMISC::CSheetId(str, "sound"); } diff --git a/code/nel/tools/3d/object_viewer/pick_sound.h b/code/nel/tools/3d/object_viewer/pick_sound.h index cbcf74601..5331ab912 100644 --- a/code/nel/tools/3d/object_viewer/pick_sound.h +++ b/code/nel/tools/3d/object_viewer/pick_sound.h @@ -23,7 +23,7 @@ #endif // _MSC_VER > 1000 // pick_sound.h : header file // -#include "nel/misc/string_mapper.h" +#include "nel/misc/sheet_id.h" #include #include @@ -40,11 +40,11 @@ class CPickSound : public CDialog { // Construction public: - typedef std::vector TNameVect; + typedef std::vector TNameVect; CPickSound(const TNameVect &names, CWnd* pParent = NULL); // standard constructor - const NLMISC::TStringId &getName(void) const { return _CurrName; } + const NLMISC::CSheetId &getName(void) const { return _CurrName; } // Dialog Data //{{AFX_DATA(CPickSound) @@ -63,7 +63,7 @@ public: // Implementation protected: TNameVect _Names; - NLMISC::TStringId _CurrName; + NLMISC::CSheetId _CurrName; UINT_PTR _Timer; diff --git a/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp b/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp index add1d14c0..965ad3d90 100644 --- a/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp +++ b/code/nel/tools/3d/object_viewer/sound_anim_dlg.cpp @@ -126,18 +126,18 @@ void CSoundAnimDlg::updateSounds() { if (_SelectedMarker != 0) { - vector sounds; + vector sounds; _SelectedMarker->getSounds(sounds); CListBox* list = (CListBox*) GetDlgItem(IDC_SOUND_ANIM_LIST); list->ResetContent(); - vector::iterator iter; + vector::iterator iter; for (iter = sounds.begin(); iter != sounds.end(); iter++) { - list->AddString(CStringMapper::unmap(*iter).c_str()); + list->AddString((*iter).toString().c_str()); } list->UpdateData(); @@ -151,7 +151,7 @@ void CSoundAnimDlg::OnAddSound() if (_SelectedMarker != 0) { // CPickSound::TNameVect names; - vector names; + vector names; NLSOUND::UAudioMixer *audioMixer = CSoundSystem::getAudioMixer(); @@ -183,7 +183,7 @@ void CSoundAnimDlg::OnRemoveSound() if (list->GetText(list->GetCurSel(), s) != LB_ERR) { string name(s); - _SelectedMarker->removeSound(CStringMapper::map(name)); + _SelectedMarker->removeSound(NLMISC::CSheetId(name, "sound")); updateSounds(); } } diff --git a/code/nel/tools/3d/object_viewer/sound_system.cpp b/code/nel/tools/3d/object_viewer/sound_system.cpp index 187a7f5c2..69e10ea18 100644 --- a/code/nel/tools/3d/object_viewer/sound_system.cpp +++ b/code/nel/tools/3d/object_viewer/sound_system.cpp @@ -168,7 +168,7 @@ void CSoundSystem::play(const string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(CStringMapper::map(soundName), true); + NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), true); if (src) { src->setLooping(false); @@ -187,7 +187,7 @@ USource *CSoundSystem::create(const std::string &soundName) { if (_AudioMixer) { - NLSOUND::USource *src = _AudioMixer->createSource(CStringMapper::map(soundName), false); + NLSOUND::USource *src = _AudioMixer->createSource(NLMISC::CSheetId(soundName, "sound"), false); if (src) { src->setLooping(false); From 09c3e0880d84a53e3f70bd3ba79ccf946a841940 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 12:36:36 +0200 Subject: [PATCH 30/39] Added: CMake projects for ryzom MFC tools (georges edit and world editor plugins) --- code/ryzom/tools/leveldesign/CMakeLists.txt | 3 +++ .../leveldesign/georges_dll/CMakeLists.txt | 19 ++++++++++++++ .../georges_dll/output_console_dlg.h | 2 +- .../leveldesign/georges_exe/CMakeLists.txt | 12 +++++++++ .../georges_plugin_sound/CMakeLists.txt | 26 +++++++++++++++++++ .../georges_plugin_sound/sound_plugin.cpp | 7 +++-- .../georges_plugin_sound/sound_plugin.h | 4 +-- .../leveldesign/world_editor/CMakeLists.txt | 4 +++ .../CMakeLists.txt | 21 +++++++++++++++ .../world_editor_graph_plugin/CMakeLists.txt | 22 ++++++++++++++++ .../CMakeLists.txt | 22 ++++++++++++++++ .../world_editor_sound_plugin/CMakeLists.txt | 21 +++++++++++++++ 12 files changed, 158 insertions(+), 5 deletions(-) create mode 100644 code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt create mode 100644 code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt create mode 100644 code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt create mode 100644 code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/CMakeLists.txt create mode 100644 code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/CMakeLists.txt create mode 100644 code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/CMakeLists.txt create mode 100644 code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/CMakeLists.txt diff --git a/code/ryzom/tools/leveldesign/CMakeLists.txt b/code/ryzom/tools/leveldesign/CMakeLists.txt index c490de731..fd3ddc94a 100644 --- a/code/ryzom/tools/leveldesign/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/CMakeLists.txt @@ -12,6 +12,9 @@ IF(WIN32) ADD_SUBDIRECTORY(world_editor) IF(WITH_MFC) ADD_SUBDIRECTORY(mission_compiler_fe) + ADD_SUBDIRECTORY(georges_dll) + ADD_SUBDIRECTORY(georges_exe) + ADD_SUBDIRECTORY(georges_plugin_sound) ENDIF(WITH_MFC) ENDIF(WIN32) diff --git a/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt new file mode 100644 index 000000000..92263a73c --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_dll/CMakeLists.txt @@ -0,0 +1,19 @@ + +FILE(GLOB SRC *.cpp *.h) + +ADD_LIBRARY(georges_dll SHARED ${SRC} georges_edit.rc) + +INCLUDE_DIRECTORIES(${NEL_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + +TARGET_LINK_LIBRARIES(georges_dll nelmisc nelgeorges) +NL_DEFAULT_PROPS(georges_dll "Ryzom, Tools, Georges: Georges Dll") +NL_ADD_RUNTIME_FLAGS(georges_dll) +NL_ADD_LIB_SUFFIX(georges_dll) + +ADD_DEFINITIONS(${MFC_DEFINITIONS} -DGEORGES_EXPORT) + +IF(WITH_PCH) + ADD_NATIVE_PRECOMPILED_HEADER(georges_dll ${CMAKE_CURRENT_SOURCE_DIR}/stdafx.h ${CMAKE_CURRENT_SOURCE_DIR}/stdafx.cpp) +ENDIF(WITH_PCH) + +INSTALL(TARGETS georges_dll LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT libraries) diff --git a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h index f3bc4a799..cdc9a4745 100644 --- a/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h +++ b/code/ryzom/tools/leveldesign/georges_dll/output_console_dlg.h @@ -37,7 +37,7 @@ public: // From CDialog void OnOK () {} - void OnCancel () + void OnCancel (); // Dialog Data //{{AFX_DATA(COutputConsoleDlg) diff --git a/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt new file mode 100644 index 000000000..064f1985e --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_exe/CMakeLists.txt @@ -0,0 +1,12 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_DEFINITIONS(${MFC_DEFINITIONS}) +SET(CMAKE_MFC_FLAG 2) +ADD_EXECUTABLE(georges_exe WIN32 ${SRC} georges_exe.rc) + +TARGET_LINK_LIBRARIES(georges_exe nelmisc nelgeorges georges_dll) + +NL_DEFAULT_PROPS(georges_exe "Ryzom, Tools, Georges: Georges Exe") +NL_ADD_RUNTIME_FLAGS(georges_exe) + +INSTALL(TARGETS georges_exe RUNTIME DESTINATION bin COMPONENT tools) diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt b/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt new file mode 100644 index 000000000..29f77d650 --- /dev/null +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/CMakeLists.txt @@ -0,0 +1,26 @@ + +FILE(GLOB SRC *.cpp *.h) + +# Bugfix... +IF (NOT DXSDK_INCLUDE_DIR) + IF (DXSDK_DIR) + SET(DXSDK_INCLUDE_DIR "${DXSDK_DIR}/Include") + ENDIF (DXSDK_DIR) +ENDIF (NOT DXSDK_INCLUDE_DIR) + +IF (NOT DXSDK_INCLUDE_DIR) + message(FATAL_ERROR "Configuration bad, cannot find DirectX include.") +ENDIF (NOT DXSDK_INCLUDE_DIR) + +ADD_LIBRARY(georges_plugin_sound SHARED ${SRC}) + +INCLUDE_DIRECTORIES(georges_plugin_sound ${NEL_INCLUDE_DIR} ${DXSDK_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(georges_plugin_sound nelmisc nelgeorges nelsound nelligo nelsnd_lowlevel georges_dll ${DXSDK_DSOUND_LIBRARY} ${DXSDK_GUID_LIBRARY}) +NL_DEFAULT_PROPS(georges_plugin_sound "Ryzom, Tools, Georges: Georges Plugin Sound") +NL_ADD_RUNTIME_FLAGS(georges_plugin_sound) +NL_ADD_LIB_SUFFIX(georges_plugin_sound) + +ADD_DEFINITIONS(${MFC_DEFINITIONS}) + +INSTALL(TARGETS georges_plugin_sound LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT libraries) diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp index d20c0347f..9a938eb7c 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.cpp @@ -68,6 +68,9 @@ CSoundPlugin::CSoundPlugin(IEdit *globalInterface) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); + // Initialize without sheet id bin + NLMISC::CSheetId::initWithoutSheet(); + CVector dir; _GlobalInterface = globalInterface; @@ -337,7 +340,7 @@ void CSoundPlugin::setActiveDocument(IEditDocument *pdoc) _Dialog.setName(_Filename); // 1st, try to found the sound in the preloaded sound bank. - _Sound = _Mixer->getSoundId(CStringMapper::map(_Filename)); + _Sound = _Mixer->getSoundId(CSheetId(_Filename, "sound")); if (_Sound == NULL) { // not found, create a new one. @@ -537,7 +540,7 @@ void CSoundPlugin::play(std::string &filename) // point.Name = string("simulation-")+_Sound->getName()+"-000"; region.VPoints.push_back(point); - string name = string("simulation-")+CStringMapper::unmap(_Sound->getName())+"-000"; + string name = string("simulation-")+NLMISC::CFile::getFilenameWithoutExtension(_Sound->getName().toString())+"-000"; if (region.VPoints.back().checkProperty("name")) region.VPoints.back().removePropertyByName("name"); diff --git a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h index c95077d68..021749d15 100644 --- a/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h +++ b/code/ryzom/tools/leveldesign/georges_plugin_sound/sound_plugin.h @@ -40,7 +40,7 @@ #include "nel/sound/driver/sound_driver.h" #include "nel/sound/driver/source.h" #include "nel/sound/driver/listener.h" -#include "sound/driver/dsound/source_dsound.h" +// #include "sound/driver/dsound/source_dsound.h" #include "nel/sound/u_audio_mixer.h" #include "nel/sound/u_listener.h" @@ -49,7 +49,7 @@ class NLSOUND::IBuffer; class NLSOUND::IListener; class NLSOUND::USource; -class NLSOUND::CSourceDSound; +// class NLSOUND::CSourceDSound; class NLSOUND::CSound; diff --git a/code/ryzom/tools/leveldesign/world_editor/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/CMakeLists.txt index f9d7908eb..4d23d04ec 100644 --- a/code/ryzom/tools/leveldesign/world_editor/CMakeLists.txt +++ b/code/ryzom/tools/leveldesign/world_editor/CMakeLists.txt @@ -3,7 +3,11 @@ ADD_SUBDIRECTORY(land_export_lib) IF(WITH_MFC) ADD_SUBDIRECTORY(world_editor) + ADD_SUBDIRECTORY(world_editor_fauna_graph_plugin) + ADD_SUBDIRECTORY(world_editor_graph_plugin) ADD_SUBDIRECTORY(world_editor_primitive_plugin) + ADD_SUBDIRECTORY(world_editor_shard_monitor_plugin) + ADD_SUBDIRECTORY(world_editor_sound_plugin) ENDIF(WITH_MFC) # This is an old plugin and is deprecated. It doesn't even compile anymore. diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/CMakeLists.txt new file mode 100644 index 000000000..04e11fd50 --- /dev/null +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_fauna_graph_plugin/CMakeLists.txt @@ -0,0 +1,21 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_LIBRARY(world_editor_fauna_graph_plugin SHARED ${SRC}) + +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(world_editor_fauna_graph_plugin + nelmisc + nel3d + nelsound + nelsnd_lowlevel) + +NL_DEFAULT_PROPS(world_editor_fauna_graph_plugin "Ryzom, Tools, World: World Editor Fauna Graph Plugin") +NL_ADD_RUNTIME_FLAGS(world_editor_fauna_graph_plugin) +NL_ADD_LIB_SUFFIX(world_editor_fauna_graph_plugin) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${MFC_DEFINITIONS} -DWIN32_DLL_EXPORTS) + + +INSTALL(TARGETS world_editor_fauna_graph_plugin LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) + diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/CMakeLists.txt new file mode 100644 index 000000000..4fc58a958 --- /dev/null +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_graph_plugin/CMakeLists.txt @@ -0,0 +1,22 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_LIBRARY(world_editor_graph_plugin SHARED ${SRC}) + +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(world_editor_graph_plugin + nelmisc + nel3d + nelsound + nelsnd_lowlevel + ryzom_mission_compiler_lib) + +NL_DEFAULT_PROPS(world_editor_graph_plugin "Ryzom, Tools, World: World Editor Graph Plugin") +NL_ADD_RUNTIME_FLAGS(world_editor_graph_plugin) +NL_ADD_LIB_SUFFIX(world_editor_graph_plugin) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${MFC_DEFINITIONS} -DWIN32_DLL_EXPORTS) + + +INSTALL(TARGETS world_editor_graph_plugin LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) + diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/CMakeLists.txt new file mode 100644 index 000000000..fdfa3e1ca --- /dev/null +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_shard_monitor_plugin/CMakeLists.txt @@ -0,0 +1,22 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_LIBRARY(world_editor_shard_monitor_plugin SHARED ${SRC}) + +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(world_editor_shard_monitor_plugin + nelmisc + nel3d + nelsound + nelsnd_lowlevel + ryzom_gameshare) + +NL_DEFAULT_PROPS(world_editor_shard_monitor_plugin "Ryzom, Tools, World: World Editor Shard Monitor Plugin") +NL_ADD_RUNTIME_FLAGS(world_editor_shard_monitor_plugin) +NL_ADD_LIB_SUFFIX(world_editor_shard_monitor_plugin) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${MFC_DEFINITIONS} -DWIN32_DLL_EXPORTS) + + +INSTALL(TARGETS world_editor_shard_monitor_plugin LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) + diff --git a/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/CMakeLists.txt b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/CMakeLists.txt new file mode 100644 index 000000000..298c0cc0d --- /dev/null +++ b/code/ryzom/tools/leveldesign/world_editor/world_editor_sound_plugin/CMakeLists.txt @@ -0,0 +1,21 @@ +FILE(GLOB SRC *.cpp *.h) + +ADD_LIBRARY(world_editor_sound_plugin SHARED ${SRC}) + +INCLUDE_DIRECTORIES(${LIBXML2_INCLUDE_DIR}) + +TARGET_LINK_LIBRARIES(world_editor_sound_plugin + nelmisc + nel3d + nelsound + nelsnd_lowlevel) + +NL_DEFAULT_PROPS(world_editor_sound_plugin "Ryzom, Tools, World: World Editor Sound Plugin") +NL_ADD_RUNTIME_FLAGS(world_editor_sound_plugin) +NL_ADD_LIB_SUFFIX(world_editor_sound_plugin) + +ADD_DEFINITIONS(${LIBXML2_DEFINITIONS} ${MFC_DEFINITIONS} -DWIN32_DLL_EXPORTS) + + +INSTALL(TARGETS world_editor_sound_plugin LIBRARY DESTINATION lib RUNTIME DESTINATION bin ARCHIVE DESTINATION lib COMPONENT tools3d) + From 96d8d45c1d18f1666cb34068de1a5eef79409e0b Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 21:20:07 +0200 Subject: [PATCH 31/39] Added: Function and tool to check system timer sanity across cpu cores --- code/nel/include/nel/misc/time_nl.h | 13 ++ code/nel/src/misc/time_nl.cpp | 136 ++++++++++++++++++ code/nel/tools/misc/CMakeLists.txt | 2 + .../tools/misc/probe_timers/CMakeLists.txt | 9 ++ code/nel/tools/misc/probe_timers/main.cpp | 38 +++++ 5 files changed, 198 insertions(+) create mode 100644 code/nel/tools/misc/probe_timers/CMakeLists.txt create mode 100644 code/nel/tools/misc/probe_timers/main.cpp diff --git a/code/nel/include/nel/misc/time_nl.h b/code/nel/include/nel/misc/time_nl.h index 2bd3edb72..9e44b4b36 100644 --- a/code/nel/include/nel/misc/time_nl.h +++ b/code/nel/include/nel/misc/time_nl.h @@ -48,6 +48,19 @@ typedef sint64 TTicks; class CTime { public: + struct CTimerInfo + { + /// Returns if there is a high precision timer that can be used. + bool IsHighPrecisionAvailable; + /// If a CPU specific timer is used and the values are not consistent accross threads. + bool RequiresSingleCore; + /// The resolution of the high resolution timer. + TTicks HighPrecisionResolution; + }; + + /** Get advanced information on the used timers. + */ + static void probeTimerInfo(CTimerInfo &result); /** Return the number of second since midnight (00:00:00), January 1, 1970, * coordinated universal time, according to the system clock. diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index f018208f9..4a3586baa 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -32,9 +32,145 @@ #include "nel/misc/time_nl.h" #include "nel/misc/sstring.h" +#include + namespace NLMISC { +void CTime::probeTimerInfo(CTime::CTimerInfo &result) +{ + breakable + { + #ifdef NL_OS_WINDOWS + LARGE_INTEGER winPerfFreq; + LARGE_INTEGER winPerfCount; + DWORD lowResTime; + if (!QueryPerformanceFrequency(&winPerfFreq)) + { + nldebug("Cannot query performance frequency"); + result.IsHighPrecisionAvailable = false; + } + else + { + result.HighPrecisionResolution = winPerfFreq.QuadPart; + } + if (winPerfFreq.QuadPart == 1000) + { + nldebug("Higher precision timer not available, OS defaulted to GetTickCount"); + result.IsHighPrecisionAvailable = false; + } + if (!QueryPerformanceCounter(&winPerfCount)) + { + nldebug("Cannot query performance counter"); + result.IsHighPrecisionAvailable = false; + result.HighPrecisionResolution = 1000; + } + if (!result.IsHighPrecisionAvailable) + { + lowResTime = timeGetTime(); + } + #else + // nldebug("Probe of timer info not implemented"); + result.IsHighPrecisionAvailable = false; + result.RequiresSingleCore = true; + break; + #endif + + uint64 cpuMask = IProcess::getCurrentProcess()->getCPUMask(); + uint64 threadMask = IThread::getCurrentThread()->getCPUMask(); + + #ifdef NL_OS_WINDOWS + + #else + TTicks timerFrequency = 0; + #endif + + uint identical = 0; // Identical stamps may indicate the os handling backwards glitches. + uint backwards = 0; // Happens when the timers are not always in sync and the implementation is faulty. + uint regular = 0; // How many times the number advanced normally. + uint skipping = 0; // Does not really mean anything necessarily. + uint frequencybug = 0; // Should never happen. + // uint badcore = 0; // Affinity does not work. + + // Cycle 32 times trough all cores, and verify if the timing remains consistent. + for (uint i = 32; i; --i) + { + uint64 currentBit = 1; + for (uint j = 64; j; --j) + { + if (cpuMask & currentBit) + { + IThread::getCurrentThread()->setCPUMask(currentBit); +#ifdef NL_OS_WINDOWS + // Make sure the thread is rescheduled. + SwitchToThread(); + Sleep(0); + // Verify the core + /* Can only verify on 2003, Vista and higher. + if (1 << GetCurrentProcessorNumber() != currentBit) + ++badcore; + */ + // Check if the timer is still sane. + if (result.IsHighPrecisionAvailable) + { + LARGE_INTEGER winPerfFreqN; + LARGE_INTEGER winPerfCountN; + QueryPerformanceFrequency(&winPerfFreqN); + if (winPerfFreqN.QuadPart != winPerfFreq.QuadPart) + ++frequencybug; + QueryPerformanceCounter(&winPerfCountN); + if (winPerfCountN.QuadPart == winPerfCount.QuadPart) + ++identical; + if (winPerfCountN.QuadPart < winPerfCount.QuadPart || winPerfCountN.QuadPart - winPerfCount.QuadPart < 0) + ++backwards; + if (winPerfCountN.QuadPart - winPerfCount.QuadPart > winPerfFreq.QuadPart / 20) // 50ms skipping check + ++skipping; + else if (winPerfCountN.QuadPart > winPerfCount.QuadPart) + ++regular; + winPerfCount.QuadPart = winPerfCountN.QuadPart; + } + else + { + DWORD lowResTimeN; + lowResTimeN = timeGetTime(); + if (lowResTimeN == lowResTime) + ++identical; + if (lowResTimeN < lowResTime || lowResTimeN - lowResTime < 0) + ++backwards; + if (lowResTimeN - lowResTime > 50) + ++skipping; + else if (lowResTimeN > lowResTime) + ++regular; + lowResTime = lowResTimeN; + } +#endif + } + currentBit <<= 1; + } + } + + IThread::getCurrentThread()->setCPUMask(threadMask); + + nldebug("Timer resolution: %i Hz", (int)(result.HighPrecisionResolution)); + nldebug("Time identical: %i, backwards: %i, regular: %i, skipping: %i, frequency bug: %i", identical, backwards, regular, skipping, frequencybug); + if (identical > regular) + nlwarning("The system timer is of relatively low resolution, you may experience issues"); + if (backwards > 0 || frequencybug > 0) + { + nlwarning("The current system timer is not reliable across multiple cpu cores"); + result.RequiresSingleCore = true; + } + else result.RequiresSingleCore = false; + + if (result.HighPrecisionResolution == 14318180) + nldebug("Detected known HPET era timer frequency"); + if (result.HighPrecisionResolution == 3579545) + nldebug("Detected known AHCI era timer frequency"); + if (result.HighPrecisionResolution == 1193182) + nldebug("Detected known i8253/i8254 era timer frequency"); + } +} + /* Return the number of second since midnight (00:00:00), January 1, 1970, * coordinated universal time, according to the system clock. * This values is the same on all computer if computers are synchronized (with NTP for example). diff --git a/code/nel/tools/misc/CMakeLists.txt b/code/nel/tools/misc/CMakeLists.txt index fcb259a64..5386cbbc6 100644 --- a/code/nel/tools/misc/CMakeLists.txt +++ b/code/nel/tools/misc/CMakeLists.txt @@ -18,3 +18,5 @@ IF(WIN32) ADD_SUBDIRECTORY(words_dic) ENDIF(MFC_FOUND) ENDIF(WIN32) + +ADD_SUBDIRECTORY(probe_timers) diff --git a/code/nel/tools/misc/probe_timers/CMakeLists.txt b/code/nel/tools/misc/probe_timers/CMakeLists.txt new file mode 100644 index 000000000..df0f34926 --- /dev/null +++ b/code/nel/tools/misc/probe_timers/CMakeLists.txt @@ -0,0 +1,9 @@ +FILE(GLOB SRC *.cpp) + +ADD_EXECUTABLE(nl_probe_timers ${SRC}) + +TARGET_LINK_LIBRARIES(nl_probe_timers nelmisc) +NL_DEFAULT_PROPS(nl_probe_timers "NeL, Tools, Misc: Probe Timers") +NL_ADD_RUNTIME_FLAGS(nl_probe_timers) + +INSTALL(TARGETS nl_probe_timers RUNTIME DESTINATION bin COMPONENT toolsmisc) diff --git a/code/nel/tools/misc/probe_timers/main.cpp b/code/nel/tools/misc/probe_timers/main.cpp new file mode 100644 index 000000000..de4c1f785 --- /dev/null +++ b/code/nel/tools/misc/probe_timers/main.cpp @@ -0,0 +1,38 @@ +// NeL - MMORPG Framework +// Copyright (C) 2012 by authors +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include +#include +#include + +#include "nel/misc/types_nl.h" +#include "nel/misc/time_nl.h" + +using namespace NLMISC; + +int main (int argc, char **argv) +{ + for (uint i = 0; i < 8; ++i) + { + CTime::CTimerInfo timerInfo; + CTime::probeTimerInfo(timerInfo); + } + + printf ("\nPress to exit\n"); + getchar (); + + return EXIT_SUCCESS; +} From bf70ca6bb2e3cd92e373205ed55f827e86a2f0cf Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 22:26:49 +0200 Subject: [PATCH 32/39] Added: Function to prefer high resolution local time --- code/nel/include/nel/misc/time_nl.h | 8 +++++- code/nel/src/misc/time_nl.cpp | 44 +++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/code/nel/include/nel/misc/time_nl.h b/code/nel/include/nel/misc/time_nl.h index 9e44b4b36..62161e304 100644 --- a/code/nel/include/nel/misc/time_nl.h +++ b/code/nel/include/nel/misc/time_nl.h @@ -86,7 +86,13 @@ public: * time that is the same on all computers. * \warning On Win32, the value is on 32 bits only. It wraps around to 0 every about 49.71 days. */ - static TTime getLocalTime (); + static TTime getLocalTime(); + + /** Same as getLocalTime, but prefers high resolution timers. + * Must call probe once in the beginning of the application before using, + * to ensure the correct settings are applied. + */ + static TTime getLocalTimeHR(); /** Return the time in processor ticks. Use it for profile purpose. * If the performance time is not supported on this hardware, it returns 0. diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 4a3586baa..11a920a79 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -37,6 +37,12 @@ namespace NLMISC { +namespace { +#ifdef NL_OS_WINDOWS +bool a_HaveQueryPerformance = false; +#endif +} + void CTime::probeTimerInfo(CTime::CTimerInfo &result) { breakable @@ -65,6 +71,7 @@ void CTime::probeTimerInfo(CTime::CTimerInfo &result) result.IsHighPrecisionAvailable = false; result.HighPrecisionResolution = 1000; } + a_HaveQueryPerformance = result.IsHighPrecisionAvailable; if (!result.IsHighPrecisionAvailable) { lowResTime = timeGetTime(); @@ -292,6 +299,43 @@ TTime CTime::getLocalTime () #endif } +#ifdef NL_OS_WINDOWS +namespace { +struct CQPFProvider +{ + CQPFProvider() + { + QueryPerformanceFrequency(&Frequency); + } + LARGE_INTEGER Frequency; +}; +CQPFProvider s_QPFProvider; +} +#endif + +/// Same as above but prefer high resolution timer +TTime CTime::getLocalTimeHR() +{ +#ifdef NL_OS_WINDOWS + if (a_HaveQueryPerformance) + { + // On a (fast) 15MHz timer this rolls over after 7000 days. + // If my calculations are right. + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + counter.QuadPart *= 1000; + counter.QuadPart /= s_QPFProvider.Frequency.QuadPart; + } + else + { + // Use default reliable low resolution timer. + return getLocalTime(); + } +#else + // Other OS always use the best available high resolution timer. + return getLocalTime(); +#endif +} /* Return the time in processor ticks. Use it for profile purpose. * If the performance time is not supported on this hardware, it returns 0. From 1c9c2eededb26c27544480202694e29cddb0a497 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 22:33:07 +0200 Subject: [PATCH 33/39] Changed: Simplify some things --- code/nel/include/nel/misc/time_nl.h | 2 +- code/nel/src/misc/time_nl.cpp | 20 ++++---------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/code/nel/include/nel/misc/time_nl.h b/code/nel/include/nel/misc/time_nl.h index 62161e304..ac9ea619c 100644 --- a/code/nel/include/nel/misc/time_nl.h +++ b/code/nel/include/nel/misc/time_nl.h @@ -84,7 +84,7 @@ public: * the value can jump backwards if the system time is changed by a user or a NTP time sync process. * The value is different on 2 different computers; use the CUniTime class to get a universal * time that is the same on all computers. - * \warning On Win32, the value is on 32 bits only. It wraps around to 0 every about 49.71 days. + * \warning On Win32, the value is on 32 bits only, and uses the low-res timer. It wraps around to 0 every about 49.71 days. */ static TTime getLocalTime(); diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 11a920a79..065db103e 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -40,6 +40,7 @@ namespace NLMISC namespace { #ifdef NL_OS_WINDOWS bool a_HaveQueryPerformance = false; +LARGE_INTEGER a_QueryPerformanceFrequency; #endif } @@ -72,6 +73,7 @@ void CTime::probeTimerInfo(CTime::CTimerInfo &result) result.HighPrecisionResolution = 1000; } a_HaveQueryPerformance = result.IsHighPrecisionAvailable; + a_QueryPerformanceFrequency.QuadPart = winPerfFreq.QuadPart; if (!result.IsHighPrecisionAvailable) { lowResTime = timeGetTime(); @@ -299,20 +301,6 @@ TTime CTime::getLocalTime () #endif } -#ifdef NL_OS_WINDOWS -namespace { -struct CQPFProvider -{ - CQPFProvider() - { - QueryPerformanceFrequency(&Frequency); - } - LARGE_INTEGER Frequency; -}; -CQPFProvider s_QPFProvider; -} -#endif - /// Same as above but prefer high resolution timer TTime CTime::getLocalTimeHR() { @@ -323,8 +311,8 @@ TTime CTime::getLocalTimeHR() // If my calculations are right. LARGE_INTEGER counter; QueryPerformanceCounter(&counter); - counter.QuadPart *= 1000; - counter.QuadPart /= s_QPFProvider.Frequency.QuadPart; + counter.QuadPart *= (LONGLONG)1000L; + counter.QuadPart /= a_QueryPerformanceFrequency.QuadPart; } else { From 6404f8eafaed13ccaef0d937a1ec187d92dff5c3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 22:35:26 +0200 Subject: [PATCH 34/39] Changed: Use the high resolution local time function instead of the funky code when getting the local time in the client. Use the timer probe function to check if it is necessary to set the cpu mask in the client --- code/ryzom/client/src/init.cpp | 7 +++++-- code/ryzom/client/src/time_client.h | 19 ++----------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 11d01934f..bb2540824 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -686,8 +686,11 @@ void prelogInit() #ifdef NL_OS_WINDOWS _control87 (_EM_INVALID|_EM_DENORMAL/*|_EM_ZERODIVIDE|_EM_OVERFLOW*/|_EM_UNDERFLOW|_EM_INEXACT, _MCW_EM); #endif // NL_OS_WINDOWS - - setCPUMask(); + + CTime::CTimerInfo timerInfo; + NLMISC::CTime::probeTimerInfo(timerInfo); + if (timerInfo.RequiresSingleCore) // TODO: Also have a FV configuration value to force single core. + setCPUMask(); FPU_CHECKER_ONCE diff --git a/code/ryzom/client/src/time_client.h b/code/ryzom/client/src/time_client.h index 80b21195b..436cf1465 100644 --- a/code/ryzom/client/src/time_client.h +++ b/code/ryzom/client/src/time_client.h @@ -134,24 +134,9 @@ void updateClientTime(); // update smoothed time (useful for sky animation) void updateSmoothedTime(); -inline TTime ryzomGetLocalTime () +inline NLMISC::TTime ryzomGetLocalTime() { -#ifdef NL_OS_WINDOWS - if (ClientCfg.TimerMode == 0) - { - return (TTime)(NLMISC::CTime::ticksToSecond (NLMISC::CTime::getPerformanceTime()) * 1000.0); - } - else // if (ClientCfg.TimerMode == 1) - { - // Use 1 ms timer precision - timeBeginPeriod(1); - DWORD start = timeGetTime(); - timeEndPeriod(1); - return (TTime)start; - } -#else // NL_OS_WINDOWS - return (TTime)(NLMISC::CTime::ticksToSecond (NLMISC::CTime::getPerformanceTime()) * 1000.0); -#endif // NL_OS_WINDOWS + return NLMISC::CTime::getLocalTimeHR(); } inline NLMISC::TTicks ryzomGetPerformanceTime() From 555336bbea88f1c71325ad2104e5200e2a7e4ab7 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 22:49:17 +0200 Subject: [PATCH 35/39] Changed: Simplify more --- code/nel/include/nel/misc/time_nl.h | 8 +---- code/nel/src/misc/time_nl.cpp | 45 +++++++++++++---------------- 2 files changed, 21 insertions(+), 32 deletions(-) diff --git a/code/nel/include/nel/misc/time_nl.h b/code/nel/include/nel/misc/time_nl.h index ac9ea619c..e7deaae24 100644 --- a/code/nel/include/nel/misc/time_nl.h +++ b/code/nel/include/nel/misc/time_nl.h @@ -84,16 +84,10 @@ public: * the value can jump backwards if the system time is changed by a user or a NTP time sync process. * The value is different on 2 different computers; use the CUniTime class to get a universal * time that is the same on all computers. - * \warning On Win32, the value is on 32 bits only, and uses the low-res timer. It wraps around to 0 every about 49.71 days. + * \warning On Win32, the value is on 32 bits only, and uses the low-res timer unless probeTimerInfo was called and a high resolution timer can be used. It wraps around to 0 every about 49.71 days. */ static TTime getLocalTime(); - /** Same as getLocalTime, but prefers high resolution timers. - * Must call probe once in the beginning of the application before using, - * to ensure the correct settings are applied. - */ - static TTime getLocalTimeHR(); - /** Return the time in processor ticks. Use it for profile purpose. * If the performance time is not supported on this hardware, it returns 0. * \warning On a multiprocessor system, the value returned by each processor may diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 065db103e..9237229d7 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -242,9 +242,28 @@ TTime CTime::getLocalTime () //else //{ // This is not affected by system time changes. But it cycles every 49 days. - return timeGetTime(); + // return timeGetTime(); // Only this was left active before it was commented. //} + /* + * The above is no longer relevant. + */ + + if (a_HaveQueryPerformance) + { + // On a (fast) 15MHz timer this rolls over after 7000 days. + // If my calculations are right. + LARGE_INTEGER counter; + QueryPerformanceCounter(&counter); + counter.QuadPart *= (LONGLONG)1000L; + counter.QuadPart /= a_QueryPerformanceFrequency.QuadPart; + } + else + { + // Use default reliable low resolution timer. + return getLocalTime(); + } + #elif defined (NL_OS_UNIX) static bool initdone = false; @@ -301,30 +320,6 @@ TTime CTime::getLocalTime () #endif } -/// Same as above but prefer high resolution timer -TTime CTime::getLocalTimeHR() -{ -#ifdef NL_OS_WINDOWS - if (a_HaveQueryPerformance) - { - // On a (fast) 15MHz timer this rolls over after 7000 days. - // If my calculations are right. - LARGE_INTEGER counter; - QueryPerformanceCounter(&counter); - counter.QuadPart *= (LONGLONG)1000L; - counter.QuadPart /= a_QueryPerformanceFrequency.QuadPart; - } - else - { - // Use default reliable low resolution timer. - return getLocalTime(); - } -#else - // Other OS always use the best available high resolution timer. - return getLocalTime(); -#endif -} - /* Return the time in processor ticks. Use it for profile purpose. * If the performance time is not supported on this hardware, it returns 0. * \warning On a multiprocessor system, the value returned by each processor may From ebabe8ed7364f77ca8923cfb7b206a5198e78f4c Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 27 Jul 2012 22:51:38 +0200 Subject: [PATCH 36/39] Fixed: Missed something --- code/ryzom/client/src/time_client.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/client/src/time_client.h b/code/ryzom/client/src/time_client.h index 436cf1465..9243a908d 100644 --- a/code/ryzom/client/src/time_client.h +++ b/code/ryzom/client/src/time_client.h @@ -136,7 +136,7 @@ void updateSmoothedTime(); inline NLMISC::TTime ryzomGetLocalTime() { - return NLMISC::CTime::getLocalTimeHR(); + return NLMISC::CTime::getLocalTime(); } inline NLMISC::TTicks ryzomGetPerformanceTime() From d14bbaf331be0106142f8d616f0f6f9a84e4f58d Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 28 Jul 2012 01:32:48 +0200 Subject: [PATCH 37/39] Added: Implementation of timer tests for linux --- code/nel/src/misc/p_thread.cpp | 51 ++++++--- code/nel/src/misc/time_nl.cpp | 182 +++++++++++++++++++++++---------- 2 files changed, 168 insertions(+), 65 deletions(-) diff --git a/code/nel/src/misc/p_thread.cpp b/code/nel/src/misc/p_thread.cpp index 4c4fe1101..ab5530342 100644 --- a/code/nel/src/misc/p_thread.cpp +++ b/code/nel/src/misc/p_thread.cpp @@ -34,16 +34,16 @@ struct CPMainThread : public CPThread { CPMainThread() : CPThread(NULL, 0) { - if(pthread_key_create(&threadSpecificKey, NULL) != 0) + if(pthread_key_create(&threadSpecificKey, NULL) != 0) throw EThread("cannot create thread specific storage key."); if(pthread_setspecific(threadSpecificKey, this) != 0) throw EThread("cannot set main thread ptr in thread specific storage."); } - ~CPMainThread() + ~CPMainThread() { - if(pthread_key_delete(threadSpecificKey) != 0) + if(pthread_key_delete(threadSpecificKey) != 0) throw EThread("cannot delete thread specific storage key."); } }; @@ -139,7 +139,7 @@ void CPThread::start() /* setting the size of the stack also */ ret = pthread_attr_setstacksize(&tattr, _StackSize); } - + bool detach_old_thread = false; pthread_t old_thread_handle; if (_State != ThreadStateNone) @@ -221,6 +221,9 @@ void CPThread::wait () bool CPThread::setCPUMask(uint64 cpuMask) { #ifdef __USE_GNU + + nlwarning("This code does not work. May cause a segmentation fault..."); + sint res = pthread_setaffinity_np(_ThreadHandle, sizeof(uint64), (const cpu_set_t*)&cpuMask); if (res) @@ -228,9 +231,14 @@ bool CPThread::setCPUMask(uint64 cpuMask) nlwarning("pthread_setaffinity_np() returned %d", res); return false; } -#endif // __USE_GNU return true; + +#else // __USE_GNU + + return false; + +#endif // __USE_GNU } /* @@ -238,9 +246,12 @@ bool CPThread::setCPUMask(uint64 cpuMask) */ uint64 CPThread::getCPUMask() { - uint64 cpuMask = 1; - #ifdef __USE_GNU + + nlwarning("This code does not work. May cause a segmentation fault..."); + + uint64 cpuMask = 0; + sint res = pthread_getaffinity_np(_ThreadHandle, sizeof(uint64), (cpu_set_t*)&cpuMask); if (res) @@ -248,9 +259,14 @@ uint64 CPThread::getCPUMask() nlwarning("pthread_getaffinity_np() returned %d", res); return 0; } -#endif // __USE_GNU return cpuMask; + +#else // __USE_GNU + + return 0; + +#endif // __USE_GNU } void CPThread::setPriority(TThreadPriority priority) @@ -311,9 +327,9 @@ IProcess *IProcess::getCurrentProcess () */ uint64 CPProcess::getCPUMask() { - uint64 cpuMask = 1; - #ifdef __USE_GNU + + uint64 cpuMask = 0; sint res = sched_getaffinity(getpid(), sizeof(uint64), (cpu_set_t*)&cpuMask); if (res) @@ -321,15 +337,21 @@ uint64 CPProcess::getCPUMask() nlwarning("sched_getaffinity() returned %d, errno = %d: %s", res, errno, strerror(errno)); return 0; } -#endif // __USE_GNU return cpuMask; + +#else // __USE_GNU + + return 0; + +#endif // __USE_GNU } /// set the CPU mask bool CPProcess::setCPUMask(uint64 cpuMask) { #ifdef __USE_GNU + sint res = sched_setaffinity(getpid(), sizeof(uint64), (const cpu_set_t*)&cpuMask); if (res) @@ -337,9 +359,14 @@ bool CPProcess::setCPUMask(uint64 cpuMask) nlwarning("sched_setaffinity() returned %d, errno = %d: %s", res, errno, strerror(errno)); return false; } -#endif // __USE_GNU return true; + +#else // __USE_GNU + + return false; + +#endif // __USE_GNU } diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 9237229d7..304426e26 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -42,13 +42,63 @@ namespace { bool a_HaveQueryPerformance = false; LARGE_INTEGER a_QueryPerformanceFrequency; #endif +#ifdef NL_OS_UNIX +# if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) +# if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) +# define NL_MONOTONIC_CLOCK +# endif +# endif +# ifdef NL_MONOTONIC_CLOCK +bool a_CheckedMonotonicClock = false; +bool a_HasMonotonicClock = false; +uint64 a_MonotonicClockFrequency = 0; +uint64 a_MonotonicClockResolutionNs = 0; +bool hasMonotonicClock() +{ + if (!a_CheckedMonotonicClock) + { + /* Initialize the local time engine. + * On Unix, this method will find out if the Monotonic Clock is supported + * (seems supported by kernel 2.6, not by kernel 2.4). See getLocalTime(). + */ + struct timespec tv; + if ((clock_gettime( CLOCK_MONOTONIC, &tv ) == 0) && + (clock_getres( CLOCK_MONOTONIC, &tv ) == 0)) + { +// nldebug( "Monotonic local time supported (resolution %.6f ms)", ((float)tv.tv_sec)*1000.0f + ((float)tv.tv_nsec)/1000000.0f ); + + if (tv.tv_sec > 0) + { + nlwarning("Monotonic clock not ok, resolution > 1s"); + a_HasMonotonicClock = false; + } + else + { + uint64 nsPerTick = tv.tv_nsec; + uint64 nsPerSec = 1000000000L; + uint64 tickPerSec = nsPerSec / nsPerTick; + a_MonotonicClockFrequency = tickPerSec; + a_MonotonicClockResolutionNs = nsPerTick; + a_HasMonotonicClock = true; + } + } + else + { + a_HasMonotonicClock = false; + } + a_CheckedMonotonicClock = true; + } + return a_HasMonotonicClock; +} +# endif +#endif } void CTime::probeTimerInfo(CTime::CTimerInfo &result) { breakable { - #ifdef NL_OS_WINDOWS +#ifdef NL_OS_WINDOWS LARGE_INTEGER winPerfFreq; LARGE_INTEGER winPerfCount; DWORD lowResTime; @@ -78,21 +128,34 @@ void CTime::probeTimerInfo(CTime::CTimerInfo &result) { lowResTime = timeGetTime(); } - #else - // nldebug("Probe of timer info not implemented"); - result.IsHighPrecisionAvailable = false; - result.RequiresSingleCore = true; - break; - #endif +#else + + // Other platforms are awesome. Generic implementation for now. + TTime localTime = getLocalTime(); + result.IsHighPrecisionAvailable = true; + result.HighPrecisionResolution = 0; + +# ifdef NL_MONOTONIC_CLOCK + timespec monoClock; + if (hasMonotonicClock()) + { + clock_gettime(CLOCK_MONOTONIC, &monoClock); + result.HighPrecisionResolution = a_MonotonicClockFrequency; + } + else + { + nldebug("Monotonic clock not available"); + } +# endif + +#endif uint64 cpuMask = IProcess::getCurrentProcess()->getCPUMask(); - uint64 threadMask = IThread::getCurrentThread()->getCPUMask(); - - #ifdef NL_OS_WINDOWS - - #else - TTicks timerFrequency = 0; - #endif +#ifdef NL_OS_WINDOWS + uint64 threadMask = IThread::getCurrentThread()->getCPUMask(); // broken on linux, don't expect it to work anywhere +#else + uint64 threadMask = cpuMask; +#endif uint identical = 0; // Identical stamps may indicate the os handling backwards glitches. uint backwards = 0; // Happens when the timers are not always in sync and the implementation is faulty. @@ -109,7 +172,12 @@ void CTime::probeTimerInfo(CTime::CTimerInfo &result) { if (cpuMask & currentBit) { - IThread::getCurrentThread()->setCPUMask(currentBit); +#ifdef NL_OS_WINDOWS + if (!IThread::getCurrentThread()->setCPUMask(currentBit)) +#else + if (!IProcess::getCurrentProcess()->setCPUMask(currentBit)) +#endif + break; // Thread was set to last cpu. #ifdef NL_OS_WINDOWS // Make sure the thread is rescheduled. SwitchToThread(); @@ -152,13 +220,53 @@ void CTime::probeTimerInfo(CTime::CTimerInfo &result) ++regular; lowResTime = lowResTimeN; } +#else +#ifdef NL_OS_UNIX + sched_yield(); +#else + nlSleep(0); +#endif +# ifdef NL_MONOTONIC_CLOCK + if (hasMonotonicClock()) + { + timespec monoClockN; + clock_gettime(CLOCK_MONOTONIC, &monoClockN); + if (monoClock.tv_sec == monoClockN.tv_sec && monoClock.tv_nsec == monoClockN.tv_nsec) + ++identical; + if (monoClockN.tv_sec < monoClock.tv_sec || (monoClock.tv_sec == monoClockN.tv_sec && monoClockN.tv_nsec < monoClock.tv_nsec)) + ++backwards; + if (monoClock.tv_sec == monoClockN.tv_sec && (monoClockN.tv_nsec - monoClock.tv_nsec > 50000000L)) + ++skipping; + else if ((monoClock.tv_sec == monoClockN.tv_sec && monoClock.tv_nsec < monoClockN.tv_nsec) || monoClock.tv_sec < monoClockN.tv_sec) + ++regular; + monoClock.tv_sec = monoClockN.tv_sec; + monoClock.tv_nsec = monoClockN.tv_nsec; + } + else +# endif + { + TTime localTimeN = getLocalTime(); + if (localTimeN == localTime) + ++identical; + if (localTimeN < localTime || localTimeN - localTime < 0) + ++backwards; + if (localTimeN - localTime > 50) + ++skipping; + else if (localTimeN > localTime) + ++regular; + localTime = localTimeN; + } #endif } currentBit <<= 1; } } +#ifdef NL_OS_WINDOWS IThread::getCurrentThread()->setCPUMask(threadMask); +#else + IProcess::getCurrentProcess()->setCPUMask(threadMask); +#endif nldebug("Timer resolution: %i Hz", (int)(result.HighPrecisionResolution)); nldebug("Time identical: %i, backwards: %i, regular: %i, skipping: %i, frequency bug: %i", identical, backwards, regular, skipping, frequencybug); @@ -245,10 +353,10 @@ TTime CTime::getLocalTime () // return timeGetTime(); // Only this was left active before it was commented. //} - /* + /* * The above is no longer relevant. */ - + if (a_HaveQueryPerformance) { // On a (fast) 15MHz timer this rolls over after 7000 days. @@ -266,49 +374,17 @@ TTime CTime::getLocalTime () #elif defined (NL_OS_UNIX) - static bool initdone = false; - static bool isMonotonicClockSupported = false; - if ( ! initdone ) - { - -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) -#if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) +#ifdef NL_MONOTONIC_CLOCK - /* Initialize the local time engine. - * On Unix, this method will find out if the Monotonic Clock is supported - * (seems supported by kernel 2.6, not by kernel 2.4). See getLocalTime(). - */ - struct timespec tv; - if ( (clock_gettime( CLOCK_MONOTONIC, &tv ) == 0) && - (clock_getres( CLOCK_MONOTONIC, &tv ) == 0) ) - { -// nldebug( "Monotonic local time supported (resolution %.6f ms)", ((float)tv.tv_sec)*1000.0f + ((float)tv.tv_nsec)/1000000.0f ); - isMonotonicClockSupported = true; - } - else - -#endif -#endif - { -// nlwarning( "Monotonic local time not supported, caution with time sync" ); - } - - initdone = true; - } - -#if defined(_POSIX_TIMERS) && (_POSIX_TIMERS > 0) -#if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) - - if ( isMonotonicClockSupported ) + if (hasMonotonicClock()) { - struct timespec tv; + timespec tv; // This is not affected by system time changes. if ( clock_gettime( CLOCK_MONOTONIC, &tv ) != 0 ) nlerror ("Can't get clock time again"); return (TTime)tv.tv_sec * (TTime)1000 + (TTime)((tv.tv_nsec/*+500*/) / 1000000); } -#endif #endif // This is affected by system time changes. @@ -346,7 +422,7 @@ TTicks CTime::getPerformanceTime () return (hi << 32) | (lo & 0xffffffff); #elif defined(HAVE_X86) and !defined(NL_OS_MAC) uint64 x; - // RDTSC - Read time-stamp counter into EDX:EAX. + // RDTSC - Read time-stamp counter into EDX:EAX. __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); return x; #else // HAVE_X86 From e029348d9aef9fe2b3c5466d7c0ef59dad62a284 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 28 Jul 2012 11:31:28 +0200 Subject: [PATCH 38/39] Fixed: Typos --- code/nel/src/misc/time_nl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/nel/src/misc/time_nl.cpp b/code/nel/src/misc/time_nl.cpp index 304426e26..dd43fd2f7 100644 --- a/code/nel/src/misc/time_nl.cpp +++ b/code/nel/src/misc/time_nl.cpp @@ -365,11 +365,12 @@ TTime CTime::getLocalTime () QueryPerformanceCounter(&counter); counter.QuadPart *= (LONGLONG)1000L; counter.QuadPart /= a_QueryPerformanceFrequency.QuadPart; + return counter.QuadPart; } else { // Use default reliable low resolution timer. - return getLocalTime(); + return timeGetTime(); } #elif defined (NL_OS_UNIX) From 1f5e08b20ff6befcf1958ef12746cd6db1bd9775 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sat, 28 Jul 2012 12:40:36 +0200 Subject: [PATCH 39/39] Fixed: A strange loading crash with bad textures --- .../nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp index b50709cd2..2cd16bf1c 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d_texture.cpp @@ -868,6 +868,13 @@ bool CDriverD3D::uploadTextureInternal (ITexture& tex, CRect& rect, uint8 destMi D3DFORMAT destFormat, D3DFORMAT srcFormat) { H_AUTO_D3D(CDriverD3D_uploadTextureInternal) + + if (rect.Width == 0 || rect.Height == 0) + { + nlwarning("Rectangle width or height cannot be 0"); + return false; + } + // The D3D texture CTextureDrvInfosD3D* d3dtext = getTextureD3D(tex);