Skip to content

Instantly share code, notes, and snippets.

@kahrl
Created July 6, 2013 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kahrl/5938740 to your computer and use it in GitHub Desktop.
Save kahrl/5938740 to your computer and use it in GitHub Desktop.
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 905e80e..29a2e23 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -659,8 +659,9 @@ void DecoSchematic::placeStructure(Map *map, v3s16 p) {
bool DecoSchematic::loadSchematicFile() {
std::ifstream is(filename.c_str(), std::ios_base::binary);
- u32 signature = readU32(is);
- if (signature != 'MTSM') {
+ char signature[4] = {0};
+ is.read(signature, 4);
+ if (memcmp(signature, "MTSM", 4) != 0) {
errorstream << "loadSchematicFile: invalid schematic "
"file" << std::endl;
return false;
@@ -719,7 +720,7 @@ bool DecoSchematic::loadSchematicFile() {
void DecoSchematic::saveSchematicFile(INodeDefManager *ndef) {
std::ofstream os(filename.c_str(), std::ios_base::binary);
- writeU32(os, 'MTSM'); // signature
+ os << "MTSM"; // signature
writeU16(os, 1); // version
writeV3S16(os, size); // schematic size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment