Changed: #1469 parsing string to TPositionOrEntity when launching instead of during parsing because entityIds where not properly set at this moment

--HG--
branch : gsoc2012-fabien
hg/feature/gsoc2012-fabien
Fabien_HENON 12 years ago
parent 29dca7b9d7
commit 5f2b62c32c

@ -70,13 +70,13 @@ CAMERA_ANIMATION_REGISTER_MODIFIER(CCameraAnimationModifierShake, "camera_modifi
class CCameraAnimationModifierSoundTrigger : public ICameraAnimationModifier
{
protected:
TPositionOrEntity SoundPos;
std::string SoundPos;
NLMISC::CSheetId SoundId;
public:
CCameraAnimationModifierSoundTrigger()
{
SoundPos = CPositionOrEntityHelper::Invalid;
SoundPos = "";
SoundId = NLMISC::CSheetId::Unknown;
}
@ -102,19 +102,21 @@ public:
nlwarning("<CCameraAnimationModifierSoundTrigger parseModifier> impossible to get the sound_position property of the basic modifier in primitive : %s", filename.c_str());
return false;
}
SoundPos = CPositionOrEntityHelper::fromString(value);
if (SoundPos == CPositionOrEntityHelper::Invalid)
{
nlwarning("<CCameraAnimationModifierSoundTrigger parseModifier> invalid soundpos in primitive : %s", filename.c_str());
return false;
}
SoundPos = value;
return true;
}
virtual void sendCameraModifier(NLMISC::CBitMemStream& bms)
{
bms.serial(const_cast<TPositionOrEntity&>(SoundPos));
TPositionOrEntity pos = CPositionOrEntityHelper::fromString(SoundPos);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationModifierSoundTrigger parseModifier> invalid soundpos %s", SoundPos.c_str());
}
bms.serial(const_cast<TPositionOrEntity&>(pos));
bms.serial(const_cast<NLMISC::CSheetId&>(SoundId));
}

@ -27,14 +27,14 @@
class CCameraAnimationStepBasic : public ICameraAnimationStep
{
protected:
TPositionOrEntity LookAtPos;
std::string LookAtPos;
std::string Text;
float Duration;
public:
CCameraAnimationStepBasic()
{
LookAtPos = CPositionOrEntityHelper::Invalid;
LookAtPos = "";
Text = "";
Duration = 0.f;
}
@ -49,12 +49,7 @@ public:
nlwarning("<CCameraAnimationStepBasic parseStep> impossible to get the look_at_position property of the basic step in primitive : %s", filename.c_str());
return false;
}
LookAtPos = CPositionOrEntityHelper::fromString(value);
if (LookAtPos == CPositionOrEntityHelper::Invalid)
{
nlwarning("<CCameraAnimationStepBasic parseStep> invalid lookatpos in primitive : %s", filename.c_str());
return false;
}
LookAtPos = value;
// We get the text
if (!prim->getPropertyByName("text", value))
@ -81,7 +76,13 @@ public:
virtual void sendAnimationStep(NLMISC::CBitMemStream& bms)
{
bms.serial(const_cast<TPositionOrEntity&>(LookAtPos));
TPositionOrEntity pos = CPositionOrEntityHelper::fromString(LookAtPos);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationStepBasic parseStep> invalid lookatpos %s", LookAtPos.c_str());
}
bms.serial(const_cast<TPositionOrEntity&>(pos));
bms.serial(const_cast<std::string&>(Text));
bms.serial(const_cast<float&>(Duration));
}
@ -122,12 +123,12 @@ CAMERA_ANIMATION_REGISTER_STEP(CCameraAnimationStepStatic, "camera_animation_sta
class CCameraAnimationStepGoTo: public CCameraAnimationStepBasic
{
protected:
TPositionOrEntity EndPos;
std::string EndPos;
public:
CCameraAnimationStepGoTo()
{
EndPos = CPositionOrEntityHelper::Invalid;
EndPos = "";
}
virtual bool parseStep(const NLLIGO::IPrimitive* prim, const std::string& filename)
@ -146,12 +147,7 @@ public:
nlwarning("<CCameraAnimationStepGoTo parseStep> impossible to get the end_position property of the basic step in primitive : %s", filename.c_str());
return false;
}
EndPos = CPositionOrEntityHelper::fromString(value);
if (EndPos == CPositionOrEntityHelper::Invalid)
{
nlwarning("<CCameraAnimationStepGoTo parseStep> invalid endpos in primitive : %s", filename.c_str());
return false;
}
EndPos = value;
return true;
}
@ -160,7 +156,13 @@ public:
{
CCameraAnimationStepBasic::sendAnimationStep(bms);
bms.serial(const_cast<TPositionOrEntity&>(EndPos));
TPositionOrEntity pos = CPositionOrEntityHelper::fromString(EndPos);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationStepGoTo parseStep> invalid endpos %s", EndPos.c_str());
}
bms.serial(const_cast<TPositionOrEntity&>(pos));
}
CAMERA_ANIMATION_STEP_NAME("camera_animation_go_to");
@ -174,13 +176,13 @@ CAMERA_ANIMATION_REGISTER_STEP(CCameraAnimationStepGoTo, "camera_animation_go_to
class CCameraAnimationStepFollowEntity: public CCameraAnimationStepBasic
{
protected:
TPositionOrEntity EntityToFollow;
std::string EntityToFollow;
float DistanceToEntity;
public:
CCameraAnimationStepFollowEntity()
{
EntityToFollow = CPositionOrEntityHelper::Invalid;
EntityToFollow = "";
DistanceToEntity = 0.f;
}
@ -200,12 +202,7 @@ public:
nlwarning("<CCameraAnimationStepFollowEntity parseStep> impossible to get the entity_to_follow property of the basic step in primitive : %s", filename.c_str());
return false;
}
EntityToFollow = CPositionOrEntityHelper::fromString(value);
if (EntityToFollow == CPositionOrEntityHelper::Invalid)
{
nlwarning("<CCameraAnimationStepFollowEntity parseStep> invalid entitytofollow in primitive : %s", filename.c_str());
return false;
}
EntityToFollow = value;
// We get the distance to the entity
if (!prim->getPropertyByName("distance_to_entity", value))
@ -226,7 +223,13 @@ public:
{
CCameraAnimationStepBasic::sendAnimationStep(bms);
bms.serial(const_cast<TPositionOrEntity&>(EntityToFollow));
TPositionOrEntity pos = CPositionOrEntityHelper::fromString(EntityToFollow);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationStepFollowEntity parseStep> invalid entitytofollow %s", EntityToFollow.c_str());
}
bms.serial(const_cast<TPositionOrEntity&>(pos));
bms.serial(const_cast<float&>(DistanceToEntity));
}
@ -242,14 +245,14 @@ CAMERA_ANIMATION_REGISTER_STEP(CCameraAnimationStepFollowEntity, "camera_animati
class CCameraAnimationStepTurnAround: public CCameraAnimationStepBasic
{
protected:
TPositionOrEntity PointToTurnAround;
std::string PointToTurnAround;
float DistanceToPoint;
float Speed;
public:
CCameraAnimationStepTurnAround()
{
PointToTurnAround = CPositionOrEntityHelper::Invalid;
PointToTurnAround = "";
DistanceToPoint = 0.f;
Speed = 0.f;
}
@ -270,12 +273,7 @@ public:
nlwarning("<CCameraAnimationStepTurnAround parseStep> impossible to get the point_to_turn_around property of the basic step in primitive : %s", filename.c_str());
return false;
}
PointToTurnAround = CPositionOrEntityHelper::fromString(value);
if (PointToTurnAround == CPositionOrEntityHelper::Invalid)
{
nlwarning("<CCameraAnimationStepTurnAround parseStep> invalidpointtoturnaround in primitive : %s", filename.c_str());
return false;
}
PointToTurnAround = value;
// We get the distance to the point
if (!prim->getPropertyByName("distance_to_point", value))
@ -308,7 +306,13 @@ public:
{
CCameraAnimationStepBasic::sendAnimationStep(bms);
bms.serial(const_cast<TPositionOrEntity&>(PointToTurnAround));
TPositionOrEntity pos = CPositionOrEntityHelper::fromString(PointToTurnAround);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<CCameraAnimationStepTurnAround parseStep> invalidpointtoturnaround %s", PointToTurnAround.c_str());
}
bms.serial(const_cast<TPositionOrEntity&>(pos));
bms.serial(const_cast<float&>(DistanceToPoint));
bms.serial(const_cast<float&>(Speed));
}

@ -29,6 +29,12 @@ const TPositionOrEntity CPositionOrEntityHelper::Invalid = TPositionOrEntity();
TPositionOrEntity CPositionOrEntityHelper::fromString(const std::string& s)
{
if (s.empty())
{
nlerror("TPositionOrentityHelper : empty position or entity given to parse");
return TPositionOrEntity();
}
std::string str = s;
CMissionParser::removeBlanks(str);

@ -5459,9 +5459,9 @@ class CMissionActionSoundTrigger : public IMissionAction
std::string SoundName = script[1];
if (script.size() >= 3)
_SoundPosition = CPositionOrEntityHelper::fromString(script[2]);
_SoundPosition = script[2];
else
_SoundPosition = CPositionOrEntityHelper::Invalid;
_SoundPosition = "";
_SoundId = NLMISC::CSheetId(SoundName);
if (_SoundId == NLMISC::CSheetId::Unknown)
@ -5480,15 +5480,23 @@ class CMissionActionSoundTrigger : public IMissionAction
// We tell the client to play the sound
std::vector<TDataSetRow> entities;
instance->getEntities(entities);
// We get the position or entity
TPositionOrEntity pos = CPositionOrEntityHelper::fromString(_SoundPosition);
if (pos == CPositionOrEntityHelper::Invalid)
{
nlerror("<sound_trigger mission_action launch> invalid position or entity from %s", _SoundPosition.c_str());
}
// For all entities that do this mission
for (uint i = 0; i < entities.size(); i++)
{
// We send the message
CEntityId eid = TheDataset.getEntityId(entities[i]);
PlayerManager.sendImpulseToClient(eid, "SOUND_TRIGGER:PLAY", _SoundId, _SoundPosition);
PlayerManager.sendImpulseToClient(eid, "SOUND_TRIGGER:PLAY", _SoundId, pos);
}
};
TPositionOrEntity _SoundPosition;
std::string _SoundPosition;
NLMISC::CSheetId _SoundId;
MISSION_ACTION_GETNEWPTR(CMissionActionSoundTrigger)

Loading…
Cancel
Save