forked from 0ad/0ad
Recreate some tech modified values upon deserialization. Fixes #3055.
Also check for some possible null pointers. This was SVN commit r16364.
This commit is contained in:
parent
0da0b062e1
commit
f8ff206169
@ -9,7 +9,7 @@ function ApplyValueModificationsToEntity(tech_type, current_value, entity)
|
||||
|
||||
let cmpAuraManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_AuraManager);
|
||||
if (!cmpAuraManager)
|
||||
return value;
|
||||
return value;
|
||||
return cmpAuraManager.ApplyModifications(tech_type, value, entity);
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -102,8 +102,10 @@ public:
|
||||
virtual u32 GetRadius()
|
||||
{
|
||||
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
|
||||
u32 newRadius = cmpValueModificationManager->ApplyModifications(L"TerritoryInfluence/Radius", m_Radius, GetEntityId());
|
||||
if (!cmpValueModificationManager)
|
||||
return m_Radius;
|
||||
|
||||
u32 newRadius = cmpValueModificationManager->ApplyModifications(L"TerritoryInfluence/Radius", m_Radius, GetEntityId());
|
||||
return newRadius;
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -118,6 +118,7 @@ public:
|
||||
componentManager.SubscribeToMessageType(MT_Update_MotionUnit);
|
||||
componentManager.SubscribeToMessageType(MT_PathResult);
|
||||
componentManager.SubscribeToMessageType(MT_ValueModification);
|
||||
componentManager.SubscribeToMessageType(MT_Deserialized);
|
||||
}
|
||||
|
||||
DEFAULT_COMPONENT_ALLOCATOR(UnitMotion)
|
||||
@ -418,8 +419,13 @@ public:
|
||||
const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg);
|
||||
if (msgData.component != L"UnitMotion")
|
||||
break;
|
||||
|
||||
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSimContext(), SYSTEM_ENTITY);
|
||||
}
|
||||
// fall-through
|
||||
case MT_Deserialized:
|
||||
{
|
||||
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
|
||||
if (!cmpValueModificationManager)
|
||||
break;
|
||||
|
||||
fixed newWalkSpeed = cmpValueModificationManager->ApplyModifications(L"UnitMotion/WalkSpeed", m_OriginalWalkSpeed, GetEntityId());
|
||||
fixed newRunSpeed = cmpValueModificationManager->ApplyModifications(L"UnitMotion/Run/Speed", m_OriginalRunSpeed, GetEntityId());
|
||||
@ -432,6 +438,7 @@ public:
|
||||
|
||||
m_WalkSpeed = newWalkSpeed;
|
||||
m_RunSpeed = newRunSpeed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -31,6 +31,7 @@ public:
|
||||
static void ClassInit(CComponentManager& componentManager)
|
||||
{
|
||||
componentManager.SubscribeToMessageType(MT_ValueModification);
|
||||
componentManager.SubscribeToMessageType(MT_Deserialized);
|
||||
}
|
||||
|
||||
DEFAULT_COMPONENT_ALLOCATOR(Vision)
|
||||
@ -73,19 +74,22 @@ public:
|
||||
case MT_ValueModification:
|
||||
{
|
||||
const CMessageValueModification& msgData = static_cast<const CMessageValueModification&> (msg);
|
||||
if (msgData.component == L"Vision")
|
||||
{
|
||||
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
|
||||
entity_pos_t newRange = cmpValueModificationManager->ApplyModifications(L"Vision/Range", m_BaseRange, GetEntityId());
|
||||
if (newRange != m_Range)
|
||||
{
|
||||
// Update our vision range and broadcast message
|
||||
entity_pos_t oldRange = m_Range;
|
||||
m_Range = newRange;
|
||||
CMessageVisionRangeChanged msg(GetEntityId(), oldRange, newRange);
|
||||
GetSimContext().GetComponentManager().BroadcastMessage(msg);
|
||||
}
|
||||
}
|
||||
if (msgData.component != L"Vision")
|
||||
break;
|
||||
}
|
||||
// fall-through
|
||||
case MT_Deserialized:
|
||||
{
|
||||
CmpPtr<ICmpValueModificationManager> cmpValueModificationManager(GetSystemEntity());
|
||||
entity_pos_t newRange = cmpValueModificationManager->ApplyModifications(L"Vision/Range", m_BaseRange, GetEntityId());
|
||||
if (newRange == m_Range)
|
||||
break;
|
||||
|
||||
// Update our vision range and broadcast message
|
||||
entity_pos_t oldRange = m_Range;
|
||||
m_Range = newRange;
|
||||
CMessageVisionRangeChanged msg(GetEntityId(), oldRange, newRange);
|
||||
GetSimContext().GetComponentManager().BroadcastMessage(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user