Skip to content

Commit 5cbf796

Browse files
committed
Dual bug fixes, export only exported default values, import loaded defaults for arrays.
1 parent edf905b commit 5cbf796

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

Diff for: src/flamegpu/io/JSONRunPlanReader.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class JSONRunPlanReader_impl : public rapidjson::BaseReaderHandler<rapidjson::UT
8080
rp.property_overrides.emplace(lastKey, detail::Any(it->second.data));
8181
}
8282
// Copy in the specific value
83-
const auto prop_it = rp.property_overrides.at(lastKey);
83+
const auto &prop_it = rp.property_overrides.at(lastKey);
8484
if (val_type == std::type_index(typeid(float))) {
8585
static_cast<float*>(const_cast<void*>(prop_it.ptr))[current_array_index++] = static_cast<float>(val);
8686
} else if (val_type == std::type_index(typeid(double))) {

Diff for: src/flamegpu/io/JSONRunPlanWriter.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ void JSONRunPlanWriter::writeRunPlan(std::unique_ptr<T> &writer, const RunPlan &
5454
// Loop through elements, to construct array
5555
for (unsigned int el = 0; el < p_meta.data.elements; ++el) {
5656
if (p_meta.data.type == std::type_index(typeid(float))) {
57-
writer->Double(*(reinterpret_cast<const float*>(p_meta.data.ptr) + el));
57+
writer->Double(*(reinterpret_cast<const float*>(p.ptr) + el));
5858
} else if (p_meta.data.type == std::type_index(typeid(double))) {
59-
writer->Double(*(reinterpret_cast<const double*>(p_meta.data.ptr) + el));
59+
writer->Double(*(reinterpret_cast<const double*>(p.ptr) + el));
6060
} else if (p_meta.data.type == std::type_index(typeid(int64_t))) {
61-
writer->Int64(*(reinterpret_cast<const int64_t*>(p_meta.data.ptr) + el));
61+
writer->Int64(*(reinterpret_cast<const int64_t*>(p.ptr) + el));
6262
} else if (p_meta.data.type == std::type_index(typeid(uint64_t))) {
63-
writer->Uint64(*(reinterpret_cast<const uint64_t*>(p_meta.data.ptr) + el));
63+
writer->Uint64(*(reinterpret_cast<const uint64_t*>(p.ptr) + el));
6464
} else if (p_meta.data.type == std::type_index(typeid(int32_t))) {
65-
writer->Int(*(reinterpret_cast<const int32_t*>(p_meta.data.ptr) + el));
65+
writer->Int(*(reinterpret_cast<const int32_t*>(p.ptr) + el));
6666
} else if (p_meta.data.type == std::type_index(typeid(uint32_t))) {
67-
writer->Uint(*(reinterpret_cast<const uint32_t*>(p_meta.data.ptr) + el));
67+
writer->Uint(*(reinterpret_cast<const uint32_t*>(p.ptr) + el));
6868
} else if (p_meta.data.type == std::type_index(typeid(int16_t))) {
69-
writer->Int(*(reinterpret_cast<const int16_t*>(p_meta.data.ptr) + el));
69+
writer->Int(*(reinterpret_cast<const int16_t*>(p.ptr) + el));
7070
} else if (p_meta.data.type == std::type_index(typeid(uint16_t))) {
71-
writer->Uint(*(reinterpret_cast<const uint16_t*>(p_meta.data.ptr) + el));
71+
writer->Uint(*(reinterpret_cast<const uint16_t*>(p.ptr) + el));
7272
} else if (p_meta.data.type == std::type_index(typeid(int8_t))) {
73-
writer->Int(static_cast<int32_t>(*(reinterpret_cast<const int8_t*>(p_meta.data.ptr) + el))); // Char outputs weird if being used as an integer
73+
writer->Int(static_cast<int32_t>(*(reinterpret_cast<const int8_t*>(p.ptr) + el))); // Char outputs weird if being used as an integer
7474
} else if (p_meta.data.type == std::type_index(typeid(uint8_t))) {
75-
writer->Uint(static_cast<uint32_t>(*(reinterpret_cast<const uint8_t*>(p_meta.data.ptr) + el))); // Char outputs weird if being used as an integer
75+
writer->Uint(static_cast<uint32_t>(*(reinterpret_cast<const uint8_t*>(p.ptr) + el))); // Char outputs weird if being used as an integer
7676
} else {
7777
THROW exception::RapidJSONError("RunPlan contains environment property '%s' of unsupported type '%s', "
7878
"in JSONRunPlanWriter::writeRunPlan()\n", name.c_str(), p_meta.data.type.name());

0 commit comments

Comments
 (0)