| 34 | const std::vector<const SpawnCondition*> SpawnCondition::EMPTY_SPAWNCONDITIONS; |
| 35 | |
| 36 | SpawnCondition* SpawnCondition::load(std::istream& defFile) |
| 37 | { |
| 38 | std::string nextParam; |
| 39 | SpawnCondition* condition = nullptr; |
| 40 | while (defFile.good()) |
| 41 | { |
| 42 | if(!(defFile >> nextParam)) |
| 43 | break; |
| 44 | |
| 45 | if (nextParam == "[/Condition]" || nextParam == "[/SpawnCondition]" || nextParam == "[/SpawnConditions]") |
| 46 | return condition; |
| 47 | |
| 48 | if(condition != nullptr) |
| 49 | { |
| 50 | // The previous line was a valid condition so we should have had an ending tag |
| 51 | OD_LOG_ERR("nextParam=" + nextParam); |
| 52 | return condition; |
| 53 | } |
| 54 | if (nextParam == "Room") |
| 55 | { |
| 56 | if(!(defFile >> nextParam)) |
| 57 | break; |
| 58 | RoomType roomType = RoomManager::getRoomTypeFromRoomName(nextParam); |
| 59 | if(roomType == RoomType::nullRoomType) |
| 60 | { |
| 61 | OD_LOG_ERR("nextParam=" + nextParam); |
| 62 | break; |
| 63 | } |
| 64 | if(!(defFile >> nextParam)) |
| 65 | break; |
| 66 | int32_t nbActiveSpotsMin = Helper::toInt(nextParam); |
| 67 | if(!(defFile >> nextParam)) |
| 68 | break; |
| 69 | int32_t pointsPerAdditionalActiveSpots = Helper::toInt(nextParam); |
| 70 | |
| 71 | condition = new SpawnConditionRoom(roomType, nbActiveSpotsMin, pointsPerAdditionalActiveSpots); |
| 72 | } |
| 73 | |
| 74 | if (nextParam == "Creature") |
| 75 | { |
| 76 | if(!(defFile >> nextParam)) |
| 77 | break; |
| 78 | const CreatureDefinition* creatureDefinition = ConfigManager::getSingleton().getCreatureDefinition(nextParam); |
| 79 | if(creatureDefinition == nullptr) |
| 80 | { |
| 81 | OD_LOG_ERR("nextParam=" + nextParam); |
| 82 | return nullptr; |
| 83 | } |
| 84 | if(!(defFile >> nextParam)) |
| 85 | break; |
| 86 | int32_t nbCreatureMin = Helper::toInt(nextParam); |
| 87 | if(!(defFile >> nextParam)) |
| 88 | break; |
| 89 | int32_t pointsPerAdditionalCreature = Helper::toInt(nextParam); |
| 90 | |
| 91 | condition = new SpawnConditionCreature(creatureDefinition, nbCreatureMin, pointsPerAdditionalCreature); |
| 92 | } |
| 93 |
nothing calls this directly
no test coverage detected