-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0efc57
commit 5860e38
Showing
73 changed files
with
3,934 additions
and
4,234 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,38 @@ | ||
#include <map> | ||
#include <variant> | ||
#include <type_traits> | ||
#include <string> | ||
#include <functional> | ||
#include <map> | ||
#include <stdexcept> | ||
#include <string> | ||
#include <type_traits> | ||
#include <variant> | ||
|
||
#include <amulet/dll.hpp> | ||
#include <amulet/biome.hpp> | ||
#include <amulet/dll.hpp> | ||
#include <amulet_nbt/nbt_encoding/binary.hpp> | ||
#include <amulet_nbt/nbt_encoding/string.hpp> | ||
|
||
namespace Amulet { | ||
void Biome::serialise(BinaryWriter& writer) const { | ||
writer.writeNumeric<std::uint8_t>(1); | ||
writer.writeSizeAndBytes(get_platform()); | ||
get_version()->serialise(writer); | ||
writer.writeSizeAndBytes(namespace_); | ||
writer.writeSizeAndBytes(base_name); | ||
void Biome::serialise(BinaryWriter& writer) const | ||
{ | ||
writer.writeNumeric<std::uint8_t>(1); | ||
writer.writeSizeAndBytes(get_platform()); | ||
get_version()->serialise(writer); | ||
writer.writeSizeAndBytes(namespace_); | ||
writer.writeSizeAndBytes(base_name); | ||
} | ||
std::shared_ptr<Biome> Biome::deserialise(BinaryReader& reader) | ||
{ | ||
auto version_number = reader.readNumeric<std::uint8_t>(); | ||
switch (version_number) { | ||
case 1: { | ||
std::string platform = reader.readSizeAndBytes(); | ||
std::shared_ptr<VersionNumber> version = VersionNumber::deserialise(reader); | ||
std::string namespace_ = reader.readSizeAndBytes(); | ||
std::string base_name = reader.readSizeAndBytes(); | ||
return std::make_shared<Biome>(platform, version, namespace_, base_name); | ||
} | ||
std::shared_ptr<Biome> Biome::deserialise(BinaryReader& reader){ | ||
auto version_number = reader.readNumeric<std::uint8_t>(); | ||
switch (version_number) { | ||
case 1: | ||
{ | ||
std::string platform = reader.readSizeAndBytes(); | ||
std::shared_ptr<VersionNumber> version = VersionNumber::deserialise(reader); | ||
std::string namespace_ = reader.readSizeAndBytes(); | ||
std::string base_name = reader.readSizeAndBytes(); | ||
return std::make_shared<Biome>(platform, version, namespace_, base_name); | ||
} | ||
default: | ||
throw std::invalid_argument("Unsupported version " + std::to_string(version_number)); | ||
} | ||
default: | ||
throw std::invalid_argument("Unsupported version " + std::to_string(version_number)); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.