| 2173 | } |
| 2174 | |
| 2175 | bool idSessionLocal::QuickSave() |
| 2176 | { |
| 2177 | idStr saveName = common->GetLanguageDict()->GetString( "#str_07178" ); |
| 2178 | |
| 2179 | idStr saveFilePathBase = saveName; |
| 2180 | ScrubSaveGameFileName( saveFilePathBase ); |
| 2181 | saveFilePathBase = "savegames/" + saveFilePathBase; |
| 2182 | |
| 2183 | const char* game = cvarSystem->GetCVarString( "fs_game" ); |
| 2184 | if ( game != NULL && game[0] == '\0' ) { |
| 2185 | game = NULL; |
| 2186 | } |
| 2187 | |
| 2188 | const int maxNum = com_numQuicksaves.GetInteger(); |
| 2189 | int indexToUse = 1; |
| 2190 | ID_TIME_T oldestTime = 0; |
| 2191 | for( int i = 1; i <= maxNum; ++i ) { |
| 2192 | idStr saveFilePath = saveFilePathBase; |
| 2193 | if ( i > 1 ) { |
| 2194 | // the first one is just called "QuickSave" without a number, like before. |
| 2195 | // the others are called "QuickSave2" "QuickSave3" etc |
| 2196 | saveFilePath += i; |
| 2197 | } |
| 2198 | saveFilePath.SetFileExtension( ".save" ); |
| 2199 | |
| 2200 | idFile *f = fileSystem->OpenFileRead( saveFilePath, true, game ); |
| 2201 | if ( f == NULL ) { |
| 2202 | // this savegame doesn't exist yet => we can use this index for the name |
| 2203 | indexToUse = i; |
| 2204 | break; |
| 2205 | } else { |
| 2206 | ID_TIME_T ts = f->Timestamp(); |
| 2207 | assert( ts != 0 ); |
| 2208 | if ( ts < oldestTime || oldestTime == 0 ) { |
| 2209 | // this is the oldest quicksave we found so far => a candidate to be overwritten |
| 2210 | indexToUse = i; |
| 2211 | oldestTime = ts; |
| 2212 | } |
| 2213 | delete f; |
| 2214 | } |
| 2215 | } |
| 2216 | |
| 2217 | if ( indexToUse > 1 ) { |
| 2218 | saveName += indexToUse; |
| 2219 | } |
| 2220 | |
| 2221 | if ( SaveGame( saveName ) ) { |
| 2222 | common->Printf( "%s\n", saveName.c_str() ); |
| 2223 | return true; |
| 2224 | } |
| 2225 | return false; |
| 2226 | } |
| 2227 | |
| 2228 | bool idSessionLocal::QuickLoad() |
| 2229 | { |
no test coverage detected