| 122 | |
| 123 | |
| 124 | bool cMapSerializer::LoadMapFromNBT(const cParsedNBT & a_NBT) |
| 125 | { |
| 126 | int Data = a_NBT.FindChildByName(0, "data"); |
| 127 | if (Data < 0) |
| 128 | { |
| 129 | return false; |
| 130 | } |
| 131 | |
| 132 | int CurrLine = a_NBT.FindChildByName(Data, "scale"); |
| 133 | if (CurrLine >= 0) |
| 134 | { |
| 135 | unsigned int Scale = a_NBT.GetByte(CurrLine); |
| 136 | m_Map->SetScale(Scale); |
| 137 | } |
| 138 | |
| 139 | CurrLine = a_NBT.FindChildByName(Data, "dimension"); |
| 140 | if (CurrLine >= 0) |
| 141 | { |
| 142 | eDimension Dimension = (eDimension) a_NBT.GetByte(CurrLine); |
| 143 | |
| 144 | if (Dimension != m_Map->m_World->GetDimension()) |
| 145 | { |
| 146 | // TODO 2014-03-20 xdot: We should store nether maps in nether worlds, e.t.c. |
| 147 | return false; |
| 148 | } |
| 149 | } |
| 150 | |
| 151 | CurrLine = a_NBT.FindChildByName(Data, "width"); |
| 152 | if (CurrLine >= 0) |
| 153 | { |
| 154 | unsigned int Width = a_NBT.GetShort(CurrLine); |
| 155 | m_Map->m_Width = Width; |
| 156 | } |
| 157 | |
| 158 | CurrLine = a_NBT.FindChildByName(Data, "height"); |
| 159 | if (CurrLine >= 0) |
| 160 | { |
| 161 | unsigned int Height = a_NBT.GetShort(CurrLine); |
| 162 | m_Map->m_Height = Height; |
| 163 | } |
| 164 | |
| 165 | CurrLine = a_NBT.FindChildByName(Data, "xCenter"); |
| 166 | if (CurrLine >= 0) |
| 167 | { |
| 168 | int CenterX = a_NBT.GetInt(CurrLine); |
| 169 | m_Map->m_CenterX = CenterX; |
| 170 | } |
| 171 | |
| 172 | CurrLine = a_NBT.FindChildByName(Data, "zCenter"); |
| 173 | if (CurrLine >= 0) |
| 174 | { |
| 175 | int CenterZ = a_NBT.GetInt(CurrLine); |
| 176 | m_Map->m_CenterZ = CenterZ; |
| 177 | } |
| 178 | |
| 179 | unsigned int NumPixels = m_Map->GetNumPixels(); |
| 180 | m_Map->m_Data.resize(NumPixels); |
| 181 |
nothing calls this directly
no test coverage detected