diff --git a/code/ryzom/client/src/net_manager.cpp b/code/ryzom/client/src/net_manager.cpp index 8a6e1083e..50df3c89b 100644 --- a/code/ryzom/client/src/net_manager.cpp +++ b/code/ryzom/client/src/net_manager.cpp @@ -3564,6 +3564,8 @@ void impulsePlaySoundTrigger(NLMISC::CBitMemStream& impulse) impulse.serial(SoundId); impulse.serial(SoundPosition); + + SoundMngr->spawnSource(SoundId, SoundPosition); } void impulseCameraAnimationPlay(NLMISC::CBitMemStream& impulse) diff --git a/code/ryzom/common/src/game_share/position_or_entity_type.h b/code/ryzom/common/src/game_share/position_or_entity_type.h index 9f949b780..990ba5c75 100644 --- a/code/ryzom/common/src/game_share/position_or_entity_type.h +++ b/code/ryzom/common/src/game_share/position_or_entity_type.h @@ -17,6 +17,99 @@ #ifndef RY_POSITIONORENTITYTYPE_H #define RY_POSITIONORENTITYTYPE_H -typedef std::string TPositionOrEntity; +#include "nel/misc/entity_id.h" +#include "nel/misc/vector.h" + +////////////////////////////////////////////////////////////////////////// +/************************************************************************/ +/* Class that can contain either an entity id or a position */ +/************************************************************************/ +class TPositionOrEntity +{ +public: + TPositionOrEntity() + { + _isPosition = -1; + } + + TPositionOrEntity(const NLMISC::CVector& position) + { + _isPosition = 1; + Position = position; + } + + TPositionOrEntity(const NLMISC::CEntityId& eid) + { + _isPosition = 0; + EntityId = eid; + } + + TPositionOrEntity(const TPositionOrEntity& c) + { + _isPosition = c._isPosition; + if (c.isPosition()) + Position = c.getPosition(); + else + EntityId = c.getEntityId(); + } + + TPositionOrEntity& operator=(const TPositionOrEntity& c) + { + _isPosition = c._isPosition; + if (c.isPosition()) + Position = c.getPosition(); + else if (c.isEntityId()) + EntityId = c.getEntityId(); + + return *this; + } + + void setPosition(const NLMISC::CVector& position) + { + _isPosition = 1; + Position = position; + } + + void setEntityId(const NLMISC::CEntityId& eid) + { + _isPosition = 0; + EntityId = eid; + } + + bool isPosition() const + { + return _isPosition == 1; + } + + bool isEntityId() const + { + return _isPosition == 0; + } + + NLMISC::CVector getPosition() const + { + if (!isPosition()) + return NLMISC::CVector(); + return Position; + } + + NLMISC::CEntityId getEntityId() const + { + if (!isEntityId()) + return NLMISC::CEntityId(); + return EntityId; + } + + bool isValid() const + { + return isPosition() || isEntityId(); + } + +private: + char _isPosition; + NLMISC::CVector Position; + NLMISC::CEntityId EntityId; +}; + #endif /* RY_POSITIONORENTITYTYPE_H */ diff --git a/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.h b/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.h new file mode 100644 index 000000000..43aeaf450 --- /dev/null +++ b/code/ryzom/server/src/entities_game_service/camera_animation_manager/position_or_entity_type_helper.h @@ -0,0 +1,108 @@ +// Ryzom - MMORPG Framework +// Copyright (C) 2010 Winch Gate Property Limited +// +// 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 . + +#ifndef RY_POSITIONORENTITYTYPEHELPER_H +#define RY_POSITIONORENTITYTYPEHELPER_H + +#include "pd_support_service\stat_character.h" +#include "mission_manager\ai_alias_translator.h" +#include "nel\misc\entity_id.h" +#include "game_share\position_or_entity_type.h" +#include "mission_manager\mission_parser.h" +#include "nel\misc\string_mapper.h" + + +////////////////////////////////////////////////////////////////////////// +/************************************************************************/ +/* Class that can contain either an entity id or a position */ +/************************************************************************/ +class CPositionOrEntityHelper +{ +public: + + TPositionOrEntity fromString(const std::string& s) + { + std::string str = s; + CMissionParser::removeBlanks(str); + + std::vector res; + NLMISC::splitString(str, ";", res); + // If we don't have 3 components, it's an entityid + if (res.size() != 3) + { + std::vector res; + CAIAliasTranslator::getInstance()->getNPCAliasesFromName(str, res); + if (res.size() != 1) + { + nlerror("TPositionOrentityHelper : no alias for entity name %s", str); + return TPositionOrEntity(); + } + TAIAlias alias = res[0]; + if (alias == CAIAliasTranslator::Invalid) + { + nlerror("TPositionOrentityHelper : invalid alias for entity name %s", str); + return TPositionOrEntity(); + } + NLMISC::CEntityId eid = CAIAliasTranslator::getInstance()->getEntityId(alias); + if (eid == NLMISC::CEntityId::Unknown) + { + nlerror("TPositionOrentityHelper : invalid entity id from alias %d", alias); + return TPositionOrEntity(); + } + + return TPositionOrEntity(eid); + } + else + { + // It's a position + std::string xStr = res[0]; + std::string yStr = res[1]; + std::string zStr = res[2]; + + CMissionParser::removeBlanks(xStr); + CMissionParser::removeBlanks(yStr); + CMissionParser::removeBlanks(zStr); + + float x = 0.f; + float y = 0.f; + float z = 0.f; + + if (!NLMISC::fromString(xStr, x)) + { + nlerror("TPositionOrentityHelper : invalid x component from string %s", xStr); + return TPositionOrEntity(); + } + if (!NLMISC::fromString(yStr, y)) + { + nlerror("TPositionOrentityHelper : invalid y component from string %s", yStr); + return TPositionOrEntity(); + } + if (!NLMISC::fromString(yStr, x)) + { + nlerror("TPositionOrentityHelper : invalid z component from string %s", zStr); + return TPositionOrEntity(); + } + + return TPositionOrEntity(NLMISC::CVector(x, y, z)); + } + + return TPositionOrEntity(); + } + +}; + + +#endif /* RY_POSITIONORENTITYTYPEHELPER_H */