summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/WorldStorage/FireworksSerializer.cpp12
-rw-r--r--src/WorldStorage/FireworksSerializer.h4
2 files changed, 11 insertions, 5 deletions
diff --git a/src/WorldStorage/FireworksSerializer.cpp b/src/WorldStorage/FireworksSerializer.cpp
index 7f5077912..34204ae8a 100644
--- a/src/WorldStorage/FireworksSerializer.cpp
+++ b/src/WorldStorage/FireworksSerializer.cpp
@@ -89,26 +89,28 @@ void cFireworkItem::ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNB
if (ExplosionName == "Colors")
{
- if (a_NBT.GetDataLength(explosiontag) == 0)
+ int DataLength = a_NBT.GetDataLength(explosiontag);
+ if (DataLength == 0)
{
continue;
}
const int * ColourData = (const int *)(a_NBT.GetData(explosiontag));
- for (int i = 0; i < ARRAYCOUNT(ColourData); i++)
+ for (int i = 0; i < DataLength; i++)
{
a_FireworkItem.m_Colours.push_back(ntohl(ColourData[i]));
}
}
else if (ExplosionName == "FadeColors")
{
- if (a_NBT.GetDataLength(explosiontag) == 0)
+ int DataLength = a_NBT.GetDataLength(explosiontag);
+ if (DataLength == 0)
{
continue;
}
const int * FadeColourData = (const int *)(a_NBT.GetData(explosiontag));
- for (int i = 0; i < ARRAYCOUNT(FadeColourData); i++)
+ for (int i = 0; i < DataLength; i++)
{
a_FireworkItem.m_FadeColours.push_back(ntohl(FadeColourData[i]));
}
@@ -244,6 +246,6 @@ int cFireworkItem::GetVanillaColourCodeFromDye(short a_DyeMeta)
case E_META_DYE_MAGENTA: return 12801229;
case E_META_DYE_ORANGE: return 15435844;
case E_META_DYE_WHITE: return 15790320;
- default: ASSERT(!"Unhandled dye meta whilst trying to get colour code for fireworks!"); break;
+ default: ASSERT(!"Unhandled dye meta whilst trying to get colour code for fireworks!"); return 0;
}
}
diff --git a/src/WorldStorage/FireworksSerializer.h b/src/WorldStorage/FireworksSerializer.h
index 37fb6c883..5b87bafdb 100644
--- a/src/WorldStorage/FireworksSerializer.h
+++ b/src/WorldStorage/FireworksSerializer.h
@@ -64,15 +64,19 @@ public:
/** Writes firework NBT data to a Writer object */
static void WriteToNBTCompound(const cFireworkItem & a_FireworkItem, cFastNBTWriter & a_Writer, const ENUM_ITEM_ID a_Type);
+
/** Reads NBT data from a NBT object and populates a FireworkItem with it */
static void ParseFromNBT(cFireworkItem & a_FireworkItem, const cParsedNBT & a_NBT, int a_TagIdx, const ENUM_ITEM_ID a_Type);
/** Converts the firework's vector of colours into a string of values separated by a semicolon */
static AString ColoursToString(const cFireworkItem & a_FireworkItem);
+
/** Parses a string containing encoded firework colours and populates a FireworkItem with it */
static void ColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem);
+
/** Converts the firework's vector of fade colours into a string of values separated by a semicolon */
static AString FadeColoursToString(const cFireworkItem & a_FireworkItem);
+
/** Parses a string containing encoded firework fade colours and populates a FireworkItem with it */
static void FadeColoursFromString(const AString & a_String, cFireworkItem & a_FireworkItem);