MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / loadMods

Method loadMods

game/state/gamestate.cpp:1625–1659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1623}
1624
1625void 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
1661bool GameState::appendGameState(const UString &gamestatePath)
1662{

Callers 1

loadGameFunction · 0.80

Calls 5

loadGameMethod · 0.95
splitFunction · 0.85
emptyMethod · 0.80
runScriptMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected