| 367 | } |
| 368 | |
| 369 | optional<int64_t> read_long(nbt::value& parent, const char* name) |
| 370 | { |
| 371 | try { |
| 372 | auto& namedValue = parent.at(name); |
| 373 | if (namedValue.get_type() != nbt::tag_type::Long) { |
| 374 | return nullopt; |
| 375 | } |
| 376 | auto& tag_str = namedValue.as<nbt::tag_long>(); |
| 377 | return tag_str.get(); |
| 378 | } catch ([[maybe_unused]] const std::out_of_range& e) { |
| 379 | // fallback for old world formats |
| 380 | qWarning() << "Long NBT tag" << name << "could not be found."; |
| 381 | return nullopt; |
| 382 | } catch ([[maybe_unused]] const std::bad_cast& e) { |
| 383 | // type mismatch |
| 384 | qWarning() << "NBT tag" << name << "could not be converted to long."; |
| 385 | return nullopt; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | optional<int> read_int(nbt::value& parent, const char* name) |
| 390 | { |
no test coverage detected