From 8d9dfc5d1a090f163f927484a43baaad49052f31 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Tue, 23 Sep 2014 22:22:38 +0200 Subject: Anvil: Wolf collar color is a byte in Vanilla. Kept the old Int reading for compatibility reasons. Ref.: #1448 --- src/WorldStorage/NBTChunkSerializer.cpp | 2 +- src/WorldStorage/WSSAnvil.cpp | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index 1962d42ff..3c9da6de7 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -582,7 +582,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) } m_Writer.AddByte("Sitting", Wolf.IsSitting() ? 1 : 0); m_Writer.AddByte("Angry", Wolf.IsAngry() ? 1 : 0); - m_Writer.AddInt("CollarColor", Wolf.GetCollarColor()); + m_Writer.AddByte("CollarColor", (unsigned char)Wolf.GetCollarColor()); break; } case cMonster::mtZombie: diff --git a/src/WorldStorage/WSSAnvil.cpp b/src/WorldStorage/WSSAnvil.cpp index e132a0c26..be526e74e 100644 --- a/src/WorldStorage/WSSAnvil.cpp +++ b/src/WorldStorage/WSSAnvil.cpp @@ -2476,10 +2476,24 @@ void cWSSAnvil::LoadWolfFromNBT(cEntityList & a_Entities, const cParsedNBT & a_N Monster->SetIsAngry(Angry); } int CollarColorIdx = a_NBT.FindChildByName(a_TagIdx, "CollarColor"); - if ((CollarColorIdx > 0) && (a_NBT.GetType(CollarColorIdx) == TAG_Int)) + if (CollarColorIdx > 0) { - int CollarColor = a_NBT.GetInt(CollarColorIdx); - Monster->SetCollarColor(CollarColor); + switch (a_NBT.GetType(CollarColorIdx)) + { + case TAG_Byte: + { + // Vanilla uses this + unsigned char CollarColor = a_NBT.GetByte(CollarColorIdx); + Monster->SetCollarColor(CollarColor); + break; + } + case TAG_Int: + { + // Old MCS code used this, keep reading it for compatibility reasons: + Monster->SetCollarColor(a_NBT.GetInt(CollarColorIdx)); + break; + } + } } a_Entities.push_back(Monster.release()); } -- cgit v1.2.3 From 34b83656b3dc0da7deb69851f6b8239e492d2862 Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Wed, 24 Sep 2014 11:21:59 +0200 Subject: QtBiomeVisualiser: Fixed MSVC path-crossing. MSVC would occasionally compile the wrong CPP file - the same name, but wrong path. --- Tools/QtBiomeVisualiser/BiomeView.cpp | 2 +- Tools/QtBiomeVisualiser/Chunk.cpp | 36 ------------------------ Tools/QtBiomeVisualiser/Chunk.h | 40 --------------------------- Tools/QtBiomeVisualiser/ChunkSource.cpp | 2 +- Tools/QtBiomeVisualiser/ChunkSource.h | 2 +- Tools/QtBiomeVisualiser/QtBiomeVisualiser.cpp | 20 ++++++++++++++ Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro | 16 +++++++---- Tools/QtBiomeVisualiser/QtChunk.cpp | 35 +++++++++++++++++++++++ Tools/QtBiomeVisualiser/QtChunk.h | 40 +++++++++++++++++++++++++++ Tools/QtBiomeVisualiser/main.cpp | 20 -------------- 10 files changed, 109 insertions(+), 104 deletions(-) delete mode 100644 Tools/QtBiomeVisualiser/Chunk.cpp delete mode 100644 Tools/QtBiomeVisualiser/Chunk.h create mode 100644 Tools/QtBiomeVisualiser/QtBiomeVisualiser.cpp create mode 100644 Tools/QtBiomeVisualiser/QtChunk.cpp create mode 100644 Tools/QtBiomeVisualiser/QtChunk.h delete mode 100644 Tools/QtBiomeVisualiser/main.cpp diff --git a/Tools/QtBiomeVisualiser/BiomeView.cpp b/Tools/QtBiomeVisualiser/BiomeView.cpp index bbaccb369..ce5a870cd 100644 --- a/Tools/QtBiomeVisualiser/BiomeView.cpp +++ b/Tools/QtBiomeVisualiser/BiomeView.cpp @@ -1,6 +1,6 @@ #include "Globals.h" #include "BiomeView.h" -#include "Chunk.h" +#include "QtChunk.h" #include #include diff --git a/Tools/QtBiomeVisualiser/Chunk.cpp b/Tools/QtBiomeVisualiser/Chunk.cpp deleted file mode 100644 index d3419af9c..000000000 --- a/Tools/QtBiomeVisualiser/Chunk.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "Globals.h" -#include "Globals.h" -#include "Chunk.h" - - - - - -Chunk::Chunk() : - m_IsValid(false) -{ -} - - - - - -const uchar * Chunk::getImage(void) const -{ - ASSERT(m_IsValid); - return m_Image; -} - - - - - -void Chunk::setImage(const Image & a_Image) -{ - memcpy(m_Image, a_Image, sizeof(a_Image)); - m_IsValid = true; -} - - - - diff --git a/Tools/QtBiomeVisualiser/Chunk.h b/Tools/QtBiomeVisualiser/Chunk.h deleted file mode 100644 index 03e7bd1b3..000000000 --- a/Tools/QtBiomeVisualiser/Chunk.h +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include - - - - - -class Chunk -{ -public: - /** The type used for storing image data for a chunk. */ - typedef uchar Image[16 * 16 * 4]; - - - Chunk(void); - - /** Returns true iff the chunk data is valid - loaded or generated. */ - bool isValid(void) const { return m_IsValid; } - - /** Returns the image of the chunk's biomes. Assumes that the chunk is valid. */ - const uchar * getImage(void) const; - - /** Sets the image data for this chunk. */ - void setImage(const Image & a_Image); - -protected: - /** Flag that specifies if the chunk data is valid - loaded or generated. */ - bool m_IsValid; - - /** Cached rendered image of this chunk's biomes. Updated in render(). */ - Image m_Image; -}; - -typedef std::shared_ptr ChunkPtr; - - - - - diff --git a/Tools/QtBiomeVisualiser/ChunkSource.cpp b/Tools/QtBiomeVisualiser/ChunkSource.cpp index 28d184615..bebf89a0a 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.cpp +++ b/Tools/QtBiomeVisualiser/ChunkSource.cpp @@ -2,9 +2,9 @@ #include "ChunkSource.h" #include #include "src/Generating/BioGen.h" -#include "inifile/iniFile.h" #include "src/StringCompression.h" #include "src/WorldStorage/FastNBT.h" +#include "inifile/iniFile.h" diff --git a/Tools/QtBiomeVisualiser/ChunkSource.h b/Tools/QtBiomeVisualiser/ChunkSource.h index 05e8ac5de..7bd1865ff 100644 --- a/Tools/QtBiomeVisualiser/ChunkSource.h +++ b/Tools/QtBiomeVisualiser/ChunkSource.h @@ -2,7 +2,7 @@ #include "Globals.h" #include #include -#include "Chunk.h" +#include "QtChunk.h" diff --git a/Tools/QtBiomeVisualiser/QtBiomeVisualiser.cpp b/Tools/QtBiomeVisualiser/QtBiomeVisualiser.cpp new file mode 100644 index 000000000..f41cdcfb2 --- /dev/null +++ b/Tools/QtBiomeVisualiser/QtBiomeVisualiser.cpp @@ -0,0 +1,20 @@ +#include "Globals.h" +#include "MainWindow.h" +#include + + + + + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} + + + + diff --git a/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro b/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro index d6630bd34..9e5d1303c 100644 --- a/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro +++ b/Tools/QtBiomeVisualiser/QtBiomeVisualiser.pro @@ -12,7 +12,7 @@ TARGET = QtBiomeVisualiser TEMPLATE = app -SOURCES += main.cpp\ +SOURCES +=\ MainWindow.cpp \ BiomeView.cpp \ ../../src/Generating/BioGen.cpp \ @@ -27,7 +27,6 @@ SOURCES += main.cpp\ ../../src/OSSupport/IsThread.cpp \ ../../src/BiomeDef.cpp \ ChunkCache.cpp \ - Chunk.cpp \ ChunkSource.cpp \ ChunkLoader.cpp \ ../../src/StringCompression.cpp \ @@ -47,7 +46,9 @@ SOURCES += main.cpp\ ../../lib/zlib/trees.c \ ../../lib/zlib/uncompr.c \ ../../lib/zlib/zutil.c \ - GeneratorSetup.cpp + GeneratorSetup.cpp \ + QtBiomeVisualiser.cpp \ + QtChunk.cpp HEADERS += MainWindow.h \ Globals.h \ @@ -64,7 +65,6 @@ HEADERS += MainWindow.h \ ../../src/OSSupport/IsThread.h \ ../../src/BiomeDef.h \ ChunkCache.h \ - Chunk.h \ ChunkSource.h \ ChunkLoader.h \ ../../src/StringCompression.h \ @@ -80,13 +80,19 @@ HEADERS += MainWindow.h \ ../../lib/zlib/zconf.h \ ../../lib/zlib/zlib.h \ ../../lib/zlib/zutil.h \ - GeneratorSetup.h + GeneratorSetup.h \ + QtChunk.h INCLUDEPATH += $$_PRO_FILE_PWD_ \ $$_PRO_FILE_PWD_/../../lib \ + $$_PRO_FILE_PWD_/../../lib/jsoncpp/include \ + $$_PRO_FILE_PWD_/../../lib/polarssl/include \ + $$_PRO_FILE_PWD_/../../lib/sqlite \ + $$_PRO_FILE_PWD_/../../lib/SQLiteCpp/include \ $$_PRO_FILE_PWD_/../../ + CONFIG += C++11 OTHER_FILES += diff --git a/Tools/QtBiomeVisualiser/QtChunk.cpp b/Tools/QtBiomeVisualiser/QtChunk.cpp new file mode 100644 index 000000000..80109b2f8 --- /dev/null +++ b/Tools/QtBiomeVisualiser/QtChunk.cpp @@ -0,0 +1,35 @@ +#include "Globals.h" +#include "QtChunk.h" + + + + + +Chunk::Chunk() : + m_IsValid(false) +{ +} + + + + + +const uchar * Chunk::getImage(void) const +{ + ASSERT(m_IsValid); + return m_Image; +} + + + + + +void Chunk::setImage(const Image & a_Image) +{ + memcpy(m_Image, a_Image, sizeof(a_Image)); + m_IsValid = true; +} + + + + diff --git a/Tools/QtBiomeVisualiser/QtChunk.h b/Tools/QtBiomeVisualiser/QtChunk.h new file mode 100644 index 000000000..03e7bd1b3 --- /dev/null +++ b/Tools/QtBiomeVisualiser/QtChunk.h @@ -0,0 +1,40 @@ +#pragma once + +#include + + + + + +class Chunk +{ +public: + /** The type used for storing image data for a chunk. */ + typedef uchar Image[16 * 16 * 4]; + + + Chunk(void); + + /** Returns true iff the chunk data is valid - loaded or generated. */ + bool isValid(void) const { return m_IsValid; } + + /** Returns the image of the chunk's biomes. Assumes that the chunk is valid. */ + const uchar * getImage(void) const; + + /** Sets the image data for this chunk. */ + void setImage(const Image & a_Image); + +protected: + /** Flag that specifies if the chunk data is valid - loaded or generated. */ + bool m_IsValid; + + /** Cached rendered image of this chunk's biomes. Updated in render(). */ + Image m_Image; +}; + +typedef std::shared_ptr ChunkPtr; + + + + + diff --git a/Tools/QtBiomeVisualiser/main.cpp b/Tools/QtBiomeVisualiser/main.cpp deleted file mode 100644 index f41cdcfb2..000000000 --- a/Tools/QtBiomeVisualiser/main.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "Globals.h" -#include "MainWindow.h" -#include - - - - - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} - - - - -- cgit v1.2.3