| 1623 | } |
| 1624 | |
| 1625 | void GameState::loadMods() |
| 1626 | { |
| 1627 | auto mods = split(Options::modList.get(), ":"); |
| 1628 | for (const auto &modString : mods) |
| 1629 | { |
| 1630 | LogWarning("loading mod \"%s\"", modString); |
| 1631 | auto modPath = Options::modPath.get() + "/" + modString; |
| 1632 | auto modInfo = ModInfo::getInfo(modPath); |
| 1633 | if (!modInfo) |
| 1634 | { |
| 1635 | LogError("Failed to load ModInfo for mod \"%s\"", modString); |
| 1636 | continue; |
| 1637 | } |
| 1638 | LogWarning("Loaded modinfo for mod ID \"%s\"", modInfo->getID()); |
| 1639 | if (modInfo->getStatePath() != "") |
| 1640 | { |
| 1641 | auto modStatePath = modPath + "/" + modInfo->getStatePath(); |
| 1642 | LogWarning("Loading mod gamestate \"%s\"", modStatePath); |
| 1643 | |
| 1644 | if (!this->loadGame(modStatePath)) |
| 1645 | { |
| 1646 | LogError("Failed to load mod ID \"%s\"", modInfo->getID()); |
| 1647 | } |
| 1648 | } |
| 1649 | |
| 1650 | const auto &modLoadScript = modInfo->getModLoadScript(); |
| 1651 | |
| 1652 | if (!modLoadScript.empty()) |
| 1653 | { |
| 1654 | LogInfo("Executing modLoad script \"%s\" for mod \"%s\"", modLoadScript, |
| 1655 | modInfo->getID()); |
| 1656 | this->luaGameState.runScript(modLoadScript); |
| 1657 | } |
| 1658 | } |
| 1659 | } |
| 1660 | |
| 1661 | bool GameState::appendGameState(const UString &gamestatePath) |
| 1662 | { |