MCPcopy Create free account
hub / github.com/PolyMC/PolyMC / read_int

Function read_int

launcher/minecraft/World.cpp:448–472  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448optional<int> read_int (nbt::value& parent, const char * name)
449{
450 try
451 {
452 auto &namedValue = parent.at(name);
453 if(namedValue.get_type() != nbt::tag_type::Int)
454 {
455 return nullopt;
456 }
457 auto & tag_str = namedValue.as<nbt::tag_int>();
458 return tag_str.get();
459 }
460 catch (const std::out_of_range &e)
461 {
462 // fallback for old world formats
463 qWarning() << "Int NBT tag" << name << "could not be found.";
464 return nullopt;
465 }
466 catch (const std::bad_cast &e)
467 {
468 // type mismatch
469 qWarning() << "NBT tag" << name << "could not be converted to int.";
470 return nullopt;
471 }
472}
473
474GameType read_gametype(nbt::value& parent, const char * name) {
475 return GameType(read_int(parent, name));

Callers 1

read_gametypeFunction · 0.85

Calls 2

atMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected