diff --git a/client/lobby/CSelectionBase.cpp b/client/lobby/CSelectionBase.cpp index 9a0be245e..2f602e023 100644 --- a/client/lobby/CSelectionBase.cpp +++ b/client/lobby/CSelectionBase.cpp @@ -69,7 +69,7 @@ int ISelectionScreenInfo::getCurrentDifficulty() PlayerInfo ISelectionScreenInfo::getPlayerInfo(PlayerColor color) { - return getMapInfo()->mapHeader->players[color.getNum()]; + return getMapInfo()->mapHeader->players.at(color.getNum()); } CSelectionBase::CSelectionBase(ESelectionScreen type) diff --git a/lib/mapObjectConstructors/CObjectClassesHandler.cpp b/lib/mapObjectConstructors/CObjectClassesHandler.cpp index 987034a83..2c758b0f6 100644 --- a/lib/mapObjectConstructors/CObjectClassesHandler.cpp +++ b/lib/mapObjectConstructors/CObjectClassesHandler.cpp @@ -291,28 +291,28 @@ void CObjectClassesHandler::loadObject(std::string scope, std::string name, cons void CObjectClassesHandler::loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) { - assert(objects[index] == nullptr); // ensure that this id was not loaded before + assert(objects.at(index) == nullptr); // ensure that this id was not loaded before - objects[index] = loadFromJson(scope, data, name, index); - VLC->identifiersHandler->registerObject(scope, "object", name, objects[index]->id); + objects.at(index) = loadFromJson(scope, data, name, index); + VLC->identifiersHandler->registerObject(scope, "object", name, objects.at(index)->id); } void CObjectClassesHandler::loadSubObject(const std::string & identifier, JsonNode config, MapObjectID ID, MapObjectSubID subID) { config.setType(JsonNode::JsonType::DATA_STRUCT); // ensure that input is not NULL - assert(objects[ID.getNum()]); + assert(objects.at(ID.getNum())); - if ( subID.getNum() >= objects[ID.getNum()]->objects.size()) - objects[ID.getNum()]->objects.resize(subID.getNum()+1); + if ( subID.getNum() >= objects.at(ID.getNum())->objects.size()) + objects.at(ID.getNum())->objects.resize(subID.getNum()+1); JsonUtils::inherit(config, objects.at(ID.getNum())->base); - loadSubObject(config.meta, identifier, config, objects[ID.getNum()].get(), subID.getNum()); + loadSubObject(config.meta, identifier, config, objects.at(ID.getNum()).get(), subID.getNum()); } void CObjectClassesHandler::removeSubObject(MapObjectID ID, MapObjectSubID subID) { - assert(objects[ID.getNum()]); - objects[ID.getNum()]->objects[subID.getNum()] = nullptr; + assert(objects.at(ID.getNum())); + objects.at(ID.getNum())->objects.at(subID.getNum()) = nullptr; } TObjectTypeHandler CObjectClassesHandler::getHandlerFor(MapObjectID type, MapObjectSubID subtype) const @@ -345,11 +345,11 @@ TObjectTypeHandler CObjectClassesHandler::getHandlerFor(const std::string & scop std::optional id = VLC->identifiers()->getIdentifier(scope, "object", type); if(id) { - const auto & object = objects[id.value()]; + const auto & object = objects.at(id.value()); std::optional subID = VLC->identifiers()->getIdentifier(scope, object->getJsonKey(), subtype); if (subID) - return object->objects[subID.value()]; + return object->objects.at(subID.value()); } std::string errorString = "Failed to find object of type " + type + "::" + subtype; @@ -480,8 +480,8 @@ std::string CObjectClassesHandler::getObjectName(MapObjectID type, MapObjectSubI if (handler && handler->hasNameTextID()) return handler->getNameTranslated(); - if (objects[type.getNum()]) - return objects[type.getNum()]->getNameTranslated(); + if (objects.at(type.getNum())) + return objects.at(type.getNum())->getNameTranslated(); return objects.front()->getNameTranslated(); } @@ -495,7 +495,7 @@ SObjectSounds CObjectClassesHandler::getObjectSounds(MapObjectID type, MapObject if(type == Obj::PRISON || type == Obj::HERO || type == Obj::SPELL_SCROLL) subtype = 0; - if(objects[type.getNum()]) + if(objects.at(type.getNum())) return getHandlerFor(type, subtype)->getSounds(); else return objects.front()->objects.front()->getSounds();