MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / saveGame

Method saveGame

src/Menu/ListSaveState.cpp:163–191  ·  view source on GitHub ↗

* Saves the selected save. */

Source from the content-addressed store, hash-verified

161 * Saves the selected save.
162 */
163void ListSaveState::saveGame()
164{
165 _game->getSavedGame()->setName(_edtSave->getText());
166 std::string oldFilename, newFilename;
167 newFilename = CrossPlatform::sanitizeFilename(Language::wstrToFs(_edtSave->getText()));
168 if (_selectedRow > 0)
169 {
170 oldFilename = _saves[_selectedRow - 1].fileName;
171 if (oldFilename != newFilename + ".sav")
172 {
173 while (CrossPlatform::fileExists(Options::getUserFolder() + newFilename + ".sav"))
174 {
175 newFilename += "_";
176 }
177 std::string oldPath = Options::getUserFolder() + oldFilename;
178 std::string newPath = Options::getUserFolder() + newFilename + ".sav";
179 CrossPlatform::moveFile(oldPath, newPath);
180 }
181 }
182 else
183 {
184 while (CrossPlatform::fileExists(Options::getUserFolder() + newFilename + ".sav"))
185 {
186 newFilename += "_";
187 }
188 }
189 newFilename += ".sav";
190 _game->pushState(new SaveGameState(_game, _origin, newFilename));
191}
192
193}

Callers

nothing calls this directly

Calls 8

sanitizeFilenameFunction · 0.85
fileExistsFunction · 0.85
getUserFolderFunction · 0.85
moveFileFunction · 0.85
getSavedGameMethod · 0.80
pushStateMethod · 0.80
setNameMethod · 0.45
getTextMethod · 0.45

Tested by

no test coverage detected