Skip to content

Commit

Permalink
fix mvalue crash
Browse files Browse the repository at this point in the history
  • Loading branch information
Doxoh committed Sep 11, 2023
1 parent 5b0f9be commit 3f35961
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion c-api/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ alt::IVirtualEntity* Core_CreateVirtualEntity(alt::ICore* core, alt::IVirtualEnt
std::unordered_map<std::string, alt::MValue> data = {};

for (uint64_t i = 0; i < size; i++) {
data[keys[i]] = values[i]->get()->Clone();
if (values[i] == nullptr || values[i]->get() == nullptr) {
data[keys[i]] = core->CreateMValueNil();
} else {
data[keys[i]] = values[i]->get()->Clone();
}
}

auto virtualEntity = core->CreateVirtualEntity(group, pos, streamingDistance, data);
Expand Down
2 changes: 2 additions & 0 deletions c-api/entities/baseObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void BaseObject_SetMultipleMetaData(alt::IBaseObject* baseObject, const char* ke
std::unordered_map<std::string, alt::MValue> data = {};

for (uint64_t i = 0; i < size; i++) {
if (values[i]->get() == nullptr) continue;
data[keys[i]] = values[i]->get()->Clone();
}

Expand All @@ -81,6 +82,7 @@ void BaseObject_SetMultipleSyncedMetaData(alt::IBaseObject* baseObject, const ch
std::unordered_map<std::string, alt::MValue> data = {};

for (uint64_t i = 0; i < size; i++) {
if (values[i]->get() == nullptr) continue;
data[keys[i]] = values[i]->get()->Clone();
}

Expand Down
1 change: 1 addition & 0 deletions c-api/entities/checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ void Checkpoint_SetMultipleStreamSyncedMetaData(alt::ICheckpoint* checkpoint, co
std::unordered_map<std::string, alt::MValue> data = {};

for (uint64_t i = 0; i < size; i++) {
if (values[i]->get() == nullptr) continue;
data[keys[i]] = values[i]->get()->Clone();
}

Expand Down
1 change: 1 addition & 0 deletions c-api/entities/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void Entity_SetMultipleStreamSyncedMetaData(alt::IEntity* entity, const char* ke
std::unordered_map<std::string, alt::MValue> data = {};

for (uint64_t i = 0; i < size; i++) {
if (values[i]->get() == nullptr) continue;
data[keys[i]] = values[i]->get()->Clone();
}

Expand Down
1 change: 1 addition & 0 deletions c-api/entities/virtual_entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ void VirtualEntity_SetMultipleStreamSyncedMetaData(alt::IVirtualEntity* virtualE
std::unordered_map<std::string, alt::MValue> data = {};

for (uint64_t i = 0; i < size; i++) {
if (values[i]->get() == nullptr) continue;
data[keys[i]] = values[i]->get()->Clone();
}

Expand Down

0 comments on commit 3f35961

Please sign in to comment.