| 268 | |
| 269 | |
| 270 | void cWSSCompact::LoadEntitiesFromJson(Json::Value & a_Value, cEntityList & a_Entities, cBlockEntityList & a_BlockEntities, cWorld * a_World) |
| 271 | { |
| 272 | // Load chests: |
| 273 | Json::Value AllChests = a_Value.get("Chests", Json::nullValue); |
| 274 | if (!AllChests.empty()) |
| 275 | { |
| 276 | for (Json::Value::iterator itr = AllChests.begin(); itr != AllChests.end(); ++itr ) |
| 277 | { |
| 278 | std::auto_ptr<cChestEntity> ChestEntity(new cChestEntity(0, 0, 0, a_World)); |
| 279 | if (!ChestEntity->LoadFromJson(*itr)) |
| 280 | { |
| 281 | LOGWARNING("ERROR READING CHEST FROM JSON!" ); |
| 282 | } |
| 283 | else |
| 284 | { |
| 285 | a_BlockEntities.push_back(ChestEntity.release()); |
| 286 | } |
| 287 | } // for itr - AllChests[] |
| 288 | } |
| 289 | |
| 290 | // Load dispensers: |
| 291 | Json::Value AllDispensers = a_Value.get("Dispensers", Json::nullValue); |
| 292 | for (Json::Value::iterator itr = AllDispensers.begin(); itr != AllDispensers.end(); ++itr) |
| 293 | { |
| 294 | std::auto_ptr<cDispenserEntity> DispenserEntity(new cDispenserEntity(0, 0, 0, a_World)); |
| 295 | if (!DispenserEntity->LoadFromJson(*itr)) |
| 296 | { |
| 297 | LOGWARNING("ERROR READING DISPENSER FROM JSON!" ); |
| 298 | } |
| 299 | else |
| 300 | { |
| 301 | a_BlockEntities.push_back(DispenserEntity.release()); |
| 302 | } |
| 303 | } // for itr - AllDispensers[] |
| 304 | |
| 305 | // Load Flowerpots: |
| 306 | Json::Value AllFlowerPots = a_Value.get("FlowerPots", Json::nullValue); |
| 307 | for (Json::Value::iterator itr = AllFlowerPots.begin(); itr != AllFlowerPots.end(); ++itr) |
| 308 | { |
| 309 | std::auto_ptr<cFlowerPotEntity> FlowerPotEntity(new cFlowerPotEntity(0, 0, 0, a_World)); |
| 310 | if (!FlowerPotEntity->LoadFromJson(*itr)) |
| 311 | { |
| 312 | LOGWARNING("ERROR READING FLOWERPOT FROM JSON!" ); |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | a_BlockEntities.push_back(FlowerPotEntity.release()); |
| 317 | } |
| 318 | } // for itr - AllFlowerPots[] |
| 319 | |
| 320 | // Load furnaces: |
| 321 | Json::Value AllFurnaces = a_Value.get("Furnaces", Json::nullValue); |
| 322 | for (Json::Value::iterator itr = AllFurnaces.begin(); itr != AllFurnaces.end(); ++itr) |
| 323 | { |
| 324 | // TODO: The block type and meta aren't correct, there's no way to get them here |
| 325 | std::auto_ptr<cFurnaceEntity> FurnaceEntity(new cFurnaceEntity(0, 0, 0, E_BLOCK_FURNACE, 0, a_World)); |
| 326 | if (!FurnaceEntity->LoadFromJson(*itr)) |
| 327 | { |