Skip to content

Commit

Permalink
Dual bug fixes, export only exported default values, import loaded de…
Browse files Browse the repository at this point in the history
…faults for arrays.
  • Loading branch information
Robadob committed Nov 4, 2024
1 parent edf905b commit 5cbf796
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/flamegpu/io/JSONRunPlanReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class JSONRunPlanReader_impl : public rapidjson::BaseReaderHandler<rapidjson::UT
rp.property_overrides.emplace(lastKey, detail::Any(it->second.data));
}
// Copy in the specific value
const auto prop_it = rp.property_overrides.at(lastKey);
const auto &prop_it = rp.property_overrides.at(lastKey);
if (val_type == std::type_index(typeid(float))) {
static_cast<float*>(const_cast<void*>(prop_it.ptr))[current_array_index++] = static_cast<float>(val);
} else if (val_type == std::type_index(typeid(double))) {
Expand Down
20 changes: 10 additions & 10 deletions src/flamegpu/io/JSONRunPlanWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,25 +54,25 @@ void JSONRunPlanWriter::writeRunPlan(std::unique_ptr<T> &writer, const RunPlan &
// Loop through elements, to construct array
for (unsigned int el = 0; el < p_meta.data.elements; ++el) {
if (p_meta.data.type == std::type_index(typeid(float))) {
writer->Double(*(reinterpret_cast<const float*>(p_meta.data.ptr) + el));
writer->Double(*(reinterpret_cast<const float*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(double))) {
writer->Double(*(reinterpret_cast<const double*>(p_meta.data.ptr) + el));
writer->Double(*(reinterpret_cast<const double*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(int64_t))) {
writer->Int64(*(reinterpret_cast<const int64_t*>(p_meta.data.ptr) + el));
writer->Int64(*(reinterpret_cast<const int64_t*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(uint64_t))) {
writer->Uint64(*(reinterpret_cast<const uint64_t*>(p_meta.data.ptr) + el));
writer->Uint64(*(reinterpret_cast<const uint64_t*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(int32_t))) {
writer->Int(*(reinterpret_cast<const int32_t*>(p_meta.data.ptr) + el));
writer->Int(*(reinterpret_cast<const int32_t*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(uint32_t))) {
writer->Uint(*(reinterpret_cast<const uint32_t*>(p_meta.data.ptr) + el));
writer->Uint(*(reinterpret_cast<const uint32_t*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(int16_t))) {
writer->Int(*(reinterpret_cast<const int16_t*>(p_meta.data.ptr) + el));
writer->Int(*(reinterpret_cast<const int16_t*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(uint16_t))) {
writer->Uint(*(reinterpret_cast<const uint16_t*>(p_meta.data.ptr) + el));
writer->Uint(*(reinterpret_cast<const uint16_t*>(p.ptr) + el));
} else if (p_meta.data.type == std::type_index(typeid(int8_t))) {
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
writer->Int(static_cast<int32_t>(*(reinterpret_cast<const int8_t*>(p.ptr) + el))); // Char outputs weird if being used as an integer
} else if (p_meta.data.type == std::type_index(typeid(uint8_t))) {
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
writer->Uint(static_cast<uint32_t>(*(reinterpret_cast<const uint8_t*>(p.ptr) + el))); // Char outputs weird if being used as an integer
} else {
THROW exception::RapidJSONError("RunPlan contains environment property '%s' of unsupported type '%s', "
"in JSONRunPlanWriter::writeRunPlan()\n", name.c_str(), p_meta.data.type.name());
Expand Down

0 comments on commit 5cbf796

Please sign in to comment.