| 102 | } |
| 103 | |
| 104 | void LaunchProfile::applyMods(const QList<LibraryPtr>& mods) |
| 105 | { |
| 106 | QList<LibraryPtr> * list = &m_mods; |
| 107 | for(auto & mod: mods) |
| 108 | { |
| 109 | auto modCopy = Library::limitedCopy(mod); |
| 110 | |
| 111 | // find the mod by name. |
| 112 | const int index = findLibraryByName(list, mod->rawName()); |
| 113 | // mod not found? just add it. |
| 114 | if (index < 0) |
| 115 | { |
| 116 | list->append(modCopy); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | auto existingLibrary = list->at(index); |
| 121 | // if we are higher it means we should update |
| 122 | if (Version(mod->version()) > Version(existingLibrary->version())) |
| 123 | { |
| 124 | list->replace(index, modCopy); |
| 125 | } |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | void LaunchProfile::applyLibrary(LibraryPtr library) |
| 130 | { |