* Load a single custom map */
| 91 | * Load a single custom map |
| 92 | */ |
| 93 | bool cCampaign::LoadCustomMap(const std::string& pMapName) { |
| 94 | Clear(); |
| 95 | std::string CustomMapName = pMapName; |
| 96 | |
| 97 | // ".map" |
| 98 | CustomMapName.resize(CustomMapName.size() - 4); |
| 99 | |
| 100 | // Map / Phase names must be upper case |
| 101 | std::transform(CustomMapName.begin(), CustomMapName.end(), CustomMapName.begin(), ::toupper); |
| 102 | |
| 103 | SetSingleMapCampaign(); |
| 104 | std::shared_ptr<cMission> Mission = mMissions.back(); |
| 105 | std::shared_ptr<cPhase> Phase = Mission->mPhases.back(); |
| 106 | |
| 107 | Mission->mName = CustomMapName; |
| 108 | |
| 109 | Phase->mMapFilename = pMapName.substr(0, pMapName.size() - 4); |
| 110 | |
| 111 | // TODO: Try load these from file before using defaults |
| 112 | Phase->mName = CustomMapName; |
| 113 | Phase->mGoals.push_back({ eObjective_Kill_All_Enemy }); |
| 114 | Phase->mAggression = { 4, 8 }; |
| 115 | |
| 116 | mIsCustomMap = true; |
| 117 | return true; |
| 118 | } |
| 119 | |
| 120 | bool cCampaign::SaveCampaign() { |
| 121 | Json Campaign; |