Skip to content

Commit 7b7960f

Browse files
committed
bugfix: Apply poison source to poison behaviour damage info
1 parent 1bab18e commit 7b7960f

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

Generals/Code/GameEngine/Include/GameLogic/Module/PoisonedBehavior.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class PoisonedBehavior : public UpdateModule,
9292
UnsignedInt m_poisonDamageFrame;
9393
UnsignedInt m_poisonOverallStopFrame;
9494
Real m_poisonDamageAmount;
95+
ObjectID m_poisonSource;
9596
DeathType m_deathType;
9697

9798
};

Generals/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ PoisonedBehavior::PoisonedBehavior( Thing *thing, const ModuleData* moduleData )
7070
m_poisonDamageFrame = 0;
7171
m_poisonOverallStopFrame = 0;
7272
m_poisonDamageAmount = 0.0f;
73+
m_poisonSource = INVALID_ID;
7374
m_deathType = DEATH_POISONED;
7475
setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
7576
}
@@ -117,7 +118,7 @@ UpdateSleepTime PoisonedBehavior::update()
117118
// If it is time to do damage, then do it and reset the damage timer
118119
DamageInfo damage;
119120
damage.in.m_amount = m_poisonDamageAmount;
120-
damage.in.m_sourceID = INVALID_ID;
121+
damage.in.m_sourceID = m_poisonSource;
121122
damage.in.m_damageType = DAMAGE_UNRESISTABLE; // Not poison, as that will infect us again
122123
damage.in.m_deathType = m_deathType;
123124
getObject()->attemptDamage( &damage );
@@ -157,6 +158,9 @@ void PoisonedBehavior::startPoisonedEffects( const DamageInfo *damageInfo )
157158

158159
// We are going to take the damage dealt by the original poisoner every so often for a while.
159160
m_poisonDamageAmount = damageInfo->out.m_actualDamageDealt;
161+
#if !RETAIL_COMPATIBLE_CRC
162+
m_poisonSource = damageInfo->in.m_sourceID;
163+
#endif
160164

161165
m_poisonOverallStopFrame = now + d->m_poisonDurationData;
162166

@@ -182,6 +186,7 @@ void PoisonedBehavior::stopPoisonedEffects()
182186
m_poisonDamageFrame = 0;
183187
m_poisonOverallStopFrame = 0;
184188
m_poisonDamageAmount = 0.0f;
189+
m_poisonSource = INVALID_ID;
185190

186191
Drawable *myDrawable = getObject()->getDrawable();
187192
if( myDrawable )
@@ -208,7 +213,7 @@ void PoisonedBehavior::xfer( Xfer *xfer )
208213
{
209214

210215
// version
211-
const XferVersion currentVersion = 2;
216+
const XferVersion currentVersion = 3;
212217
XferVersion version = currentVersion;
213218
xfer->xferVersion( &version, currentVersion );
214219

@@ -229,6 +234,10 @@ void PoisonedBehavior::xfer( Xfer *xfer )
229234
xfer->xferUser(&m_deathType, sizeof(m_deathType));
230235
}
231236

237+
if (version >= 3)
238+
{
239+
xfer->xferObjectID(&m_poisonSource);
240+
}
232241
}
233242

234243
// ------------------------------------------------------------------------------------------------

GeneralsMD/Code/GameEngine/Include/GameLogic/Module/PoisonedBehavior.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class PoisonedBehavior : public UpdateModule,
9292
UnsignedInt m_poisonDamageFrame;
9393
UnsignedInt m_poisonOverallStopFrame;
9494
Real m_poisonDamageAmount;
95+
ObjectID m_poisonSource;
9596
DeathType m_deathType;
9697

9798
};

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/PoisonedBehavior.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ PoisonedBehavior::PoisonedBehavior( Thing *thing, const ModuleData* moduleData )
7070
m_poisonDamageFrame = 0;
7171
m_poisonOverallStopFrame = 0;
7272
m_poisonDamageAmount = 0.0f;
73+
m_poisonSource = INVALID_ID;
7374
m_deathType = DEATH_POISONED;
7475
setWakeFrame(getObject(), UPDATE_SLEEP_FOREVER);
7576
}
@@ -117,7 +118,7 @@ UpdateSleepTime PoisonedBehavior::update()
117118
// If it is time to do damage, then do it and reset the damage timer
118119
DamageInfo damage;
119120
damage.in.m_amount = m_poisonDamageAmount;
120-
damage.in.m_sourceID = INVALID_ID;
121+
damage.in.m_sourceID = m_poisonSource;
121122
damage.in.m_damageType = DAMAGE_UNRESISTABLE; // Not poison, as that will infect us again
122123
damage.in.m_damageFXOverride = DAMAGE_POISON; // but this will ensure that the right effect is played
123124
damage.in.m_deathType = m_deathType;
@@ -158,6 +159,9 @@ void PoisonedBehavior::startPoisonedEffects( const DamageInfo *damageInfo )
158159

159160
// We are going to take the damage dealt by the original poisoner every so often for a while.
160161
m_poisonDamageAmount = damageInfo->out.m_actualDamageDealt;
162+
#if !RETAIL_COMPATIBLE_CRC
163+
m_poisonSource = damageInfo->in.m_sourceID;
164+
#endif
161165

162166
m_poisonOverallStopFrame = now + d->m_poisonDurationData;
163167

@@ -183,6 +187,7 @@ void PoisonedBehavior::stopPoisonedEffects()
183187
m_poisonDamageFrame = 0;
184188
m_poisonOverallStopFrame = 0;
185189
m_poisonDamageAmount = 0.0f;
190+
m_poisonSource = INVALID_ID;
186191

187192
Drawable *myDrawable = getObject()->getDrawable();
188193
if( myDrawable )
@@ -209,7 +214,7 @@ void PoisonedBehavior::xfer( Xfer *xfer )
209214
{
210215

211216
// version
212-
const XferVersion currentVersion = 2;
217+
const XferVersion currentVersion = 3;
213218
XferVersion version = currentVersion;
214219
xfer->xferVersion( &version, currentVersion );
215220

@@ -230,6 +235,10 @@ void PoisonedBehavior::xfer( Xfer *xfer )
230235
xfer->xferUser(&m_deathType, sizeof(m_deathType));
231236
}
232237

238+
if (version >= 3)
239+
{
240+
xfer->xferObjectID(&m_poisonSource);
241+
}
233242
}
234243

235244
// ------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)