MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / LoadCustomMap

Method LoadCustomMap

Source/Campaign.cpp:93–118  ·  view source on GitHub ↗

* Load a single custom map */

Source from the content-addressed store, hash-verified

91 * Load a single custom map
92 */
93bool 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
120bool cCampaign::SaveCampaign() {
121 Json Campaign;

Callers

nothing calls this directly

Calls 5

resizeMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected