| 235 | } |
| 236 | |
| 237 | void sGameRecorded::save() { |
| 238 | std::lock_guard<std::mutex> lock(mLockMtx); |
| 239 | |
| 240 | if (g_Fodder->mParams->mDemoRecord) { |
| 241 | std::string Filename = g_Fodder->mParams->mDemoFile; |
| 242 | if (Filename == "-") { |
| 243 | Filename = std::to_string(g_Fodder->mGame_Data.mMission_Number); |
| 244 | Filename += "-"; |
| 245 | Filename += std::to_string(g_Fodder->mGame_Data.mMission_Phase); |
| 246 | } |
| 247 | |
| 248 | if (Filename.find(".") == Filename.npos) |
| 249 | Filename += DEMO_EXTENSION; |
| 250 | |
| 251 | g_Debugger->Notice("Writing demo to " + Filename); |
| 252 | std::ofstream outfile(Filename, std::ofstream::binary); |
| 253 | outfile << ToJson(); |
| 254 | outfile.close(); |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | std::string sGameRecorded::ToJson() { |
| 259 | auto now = std::chrono::system_clock::now(); |