Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 9398f91

Browse files
committed
Added some missing stuff in Attachable Clear and Save that should have been there
Cleaned up some whitespace and method comments in attachable
1 parent 1a7bef6 commit 9398f91

File tree

2 files changed

+28
-38
lines changed

2 files changed

+28
-38
lines changed

Entities/Attachable.cpp

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ namespace RTE {
3535

3636
m_InheritsHFlipped = 1;
3737
m_InheritsRotAngle = true;
38-
m_InheritedRotAngleOffset = 0.0F;
38+
m_InheritedRotAngleOffset = 0;
3939
m_InheritsFrame = false;
4040

4141
m_AtomSubgroupID = -1L;
4242
m_CollidesWithTerrainWhileAttached = true;
4343

44-
m_PrevRotAngleOffset = 0.0F;
44+
m_PrevParentOffset.Reset();
45+
m_PrevJointOffset.Reset();
46+
m_PrevRotAngleOffset = 0;
47+
m_PreUpdateHasRunThisFrame = false;
4548
}
4649

4750
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -142,36 +145,23 @@ namespace RTE {
142145
int Attachable::Save(Writer &writer) const {
143146
MOSRotating::Save(writer);
144147

145-
writer.NewProperty("ParentOffset");
146-
writer << m_ParentOffset;
147-
writer.NewProperty("DrawAfterParent");
148-
writer << m_DrawAfterParent;
149-
writer.NewProperty("DeleteWhenRemovedFromParent");
150-
writer << m_DeleteWhenRemovedFromParent;
151-
writer.NewProperty("ApplyTransferredForcesAtOffset");
152-
writer << m_ApplyTransferredForcesAtOffset;
153-
154-
writer.NewProperty("JointStrength");
155-
writer << m_JointStrength;
156-
writer.NewProperty("JointStiffness");
157-
writer << m_JointStiffness;
158-
writer.NewProperty("JointOffset");
159-
writer << m_JointOffset;
160-
161-
writer.NewProperty("BreakWound");
162-
writer << m_BreakWound;
163-
writer.NewProperty("ParentBreakWound");
164-
writer << m_ParentBreakWound;
165-
166-
writer.NewProperty("InheritsHFlipped");
167-
writer << ((m_InheritsHFlipped == 0 || m_InheritsHFlipped == 1) ? m_InheritsHFlipped : 2);
168-
writer.NewProperty("InheritsRotAngle");
169-
writer << m_InheritsRotAngle;
170-
writer.NewProperty("InheritedRotAngleOffset");
171-
writer << m_InheritedRotAngleOffset;
172-
173-
writer.NewProperty("CollidesWithTerrainWhileAttached");
174-
writer << m_CollidesWithTerrainWhileAttached;
148+
writer.NewPropertyWithValue("ParentOffset", m_ParentOffset);
149+
writer.NewPropertyWithValue("DrawAfterParent", m_DrawAfterParent);
150+
writer.NewPropertyWithValue("DeleteWhenRemovedFromParent", m_DeleteWhenRemovedFromParent);
151+
writer.NewPropertyWithValue("ApplyTransferredForcesAtOffset", m_ApplyTransferredForcesAtOffset);
152+
153+
writer.NewPropertyWithValue("JointStrength", m_JointStrength);
154+
writer.NewPropertyWithValue("JointStiffness", m_JointStiffness);
155+
writer.NewPropertyWithValue("JointOffset", m_JointOffset);
156+
157+
writer.NewPropertyWithValue("BreakWound", m_BreakWound);
158+
writer.NewPropertyWithValue("ParentBreakWound", m_ParentBreakWound);
159+
160+
writer.NewPropertyWithValue("InheritsHFlipped", ((m_InheritsHFlipped == 0 || m_InheritsHFlipped == 1) ? m_InheritsHFlipped : 2));
161+
writer.NewPropertyWithValue("InheritsRotAngle", m_InheritsRotAngle);
162+
writer.NewPropertyWithValue("InheritedRotAngleOffset", m_InheritedRotAngleOffset);
163+
164+
writer.NewPropertyWithValue("CollidesWithTerrainWhileAttached", m_CollidesWithTerrainWhileAttached);
175165

176166
return 0;
177167
}
@@ -452,7 +442,7 @@ namespace RTE {
452442
//TODO Get rid of the need for calling ResetAllTimers, if something like inventory swapping needs timers reset it should do it itself! This blanket handling probably has side-effects.
453443
// Timers are reset here as a precaution, so that if something was sitting in an inventory, it doesn't cause backed up emissions.
454444
ResetAllTimers();
455-
445+
456446
if (newParent) {
457447
m_Parent = newParent;
458448
m_Team = newParent->GetTeam();

Entities/Attachable.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace RTE {
2525
/// Constructor method used to instantiate a Attachable object in system memory. Create() should be called before using the object.
2626
/// </summary>
2727
Attachable() { Clear(); }
28-
28+
2929
/// <summary>
3030
/// Makes the Attachable object ready for use.
3131
/// </summary>
@@ -304,14 +304,14 @@ namespace RTE {
304304
#pragma region Inherited Value Getters and Setters
305305
/// <summary>
306306
/// Gets whether or not this Attachable inherits its parent's HFlipped value, i.e. whether it has its HFlipped value reset to match/reverse its parent's every frame, if attached.
307-
/// -1 (or technically any value that's not 0 or 1) means reversed inheritance (i.e. if the parent's HFlipped value is true, this Attachable's HFlipped value will be false), 0 means no inheritance, 1 means normal inheritance.
307+
/// 0 means no inheritance, 1 means normal inheritance, anything else means reversed inheritance (i.e. if the parent's HFlipped value is true, this Attachable's HFlipped value will be false).
308308
/// </summary>
309309
/// <returns>Whether or not this Attachable inherits its parent's HFlipped value.</returns>
310310
int InheritsHFlipped() const { return m_InheritsHFlipped; }
311311

312312
/// <summary>
313313
/// Sets whether or not this Attachable inherits its parent's HFlipped value, i.e. whether it has its HFlipped value reset to match/reverse its parent's every frame, if attached.
314-
/// -1 (or technically any value that's not 0 or 1) means reversed inheritance (i.e. if the parent's HFlipped value is true, this Attachable's HFlipped value will be false), 0 means no inheritance, 1 means normal inheritance.
314+
/// 0 means no inheritance, 1 means normal inheritance, anything else means reversed inheritance (i.e. if the parent's HFlipped value is true, this Attachable's HFlipped value will be false).
315315
/// </summary>
316316
/// <param name="inheritsRotAngle">Whether or not to inherit its parent's HFlipped value.</param>
317317
void SetInheritsHFlipped(int inheritsHFlipped) { m_InheritsHFlipped = inheritsHFlipped; }
@@ -524,10 +524,10 @@ namespace RTE {
524524
bool m_DrawnNormallyByParent; //!< Whether this Attachable will be drawn normally when attached, or will require special handling by some non-MOSR parent type.
525525
bool m_DeleteWhenRemovedFromParent; //!< Whether this Attachable should be deleted when it's removed from its parent.
526526
bool m_ApplyTransferredForcesAtOffset; //!< Whether forces transferred from this Attachable should be applied at the rotated parent offset (which will produce torque), or directly at the parent's position. Mostly useful to make jetpacks and similar emitters viable.
527-
527+
528528
float m_GibWithParentChance; //!< The percentage chance that this Attachable will gib when its parent does. 0 means never, 1 means always.
529529
float m_ParentGibBlastStrengthMultiplier; //!< The multiplier for how strongly this Attachable's parent's gib blast strength will be applied to it when its parent's gibs.
530-
530+
531531
//TODO This is a stopgap for a dedicated Wound class, that would be helpful to simplify things like this and default damage multiplier handling.
532532
bool m_IsWound; //!< Whether or not this Attachable has been added as a wound. Only set and applied for Attachables with parents.
533533

0 commit comments

Comments
 (0)