Skip to content

Commit

Permalink
Fix a memory curreption.
Browse files Browse the repository at this point in the history
  • Loading branch information
kochol committed Aug 22, 2019
1 parent e06d1d5 commit 0a69496
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/net/PropertyReplicator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "core/containers/Array.hpp"
#include "core/defines.hpp"
#include "en/World.hpp"
#include "core/log.h"

namespace ari::net
{
Expand All @@ -21,6 +22,28 @@ namespace ari::net
uint32_t ComponentId;
bool(*isDiffFn)(void*, void*, int);

PropertyIndex() = default;

PropertyIndex(PropertyIndex& other)
{
Index = other.Index;
Component = other.Component;
PropertyClone = other.PropertyClone;
ComponentId = other.ComponentId;
isDiffFn = other.isDiffFn;
other.PropertyClone = nullptr;
}

PropertyIndex(PropertyIndex&& other)
{
Index = other.Index;
Component = other.Component;
PropertyClone = other.PropertyClone;
ComponentId = other.ComponentId;
isDiffFn = other.isDiffFn;
other.PropertyClone = nullptr;
}

~PropertyIndex()
{
core::Memory::Free(PropertyClone);
Expand All @@ -47,6 +70,8 @@ namespace ari::net
clone = core::Memory::Alloc(sizeof(MemberT));
if (member.canGetConstRef()) {
*((MemberT*)clone) = member.get(*cmp.Component);
MemberT* temp = (MemberT*)clone;
int hj = 0;
}
else if (member.hasGetter()) {
*((MemberT*)clone) = member.getCopy(*cmp.Component);
Expand All @@ -61,7 +86,13 @@ namespace ari::net
{
// We found the property add it to the list
en::ComponentHandle<void> cmpVoid = { cmp.Handle, cmp.Index, (void*)cmp.Component };
Properties.Add({ property_index, cmpVoid, clone, T::Id, T::IsDiff });
PropertyIndex property;
property.Component = cmpVoid;
property.ComponentId = T::Id;
property.Index = property_index;
property.PropertyClone = clone;
property.isDiffFn = T::IsDiff;
Properties.Add(property);
}
}
};
Expand Down

0 comments on commit 0a69496

Please sign in to comment.