MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / QuickLoad

Method QuickLoad

neo/framework/Session.cpp:2228–2271  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2226}
2227
2228bool idSessionLocal::QuickLoad()
2229{
2230 idStr saveName = common->GetLanguageDict()->GetString( "#str_07178" );
2231
2232 idStr saveFilePathBase = saveName;
2233 ScrubSaveGameFileName( saveFilePathBase );
2234 saveFilePathBase = "savegames/" + saveFilePathBase;
2235
2236 const char* game = cvarSystem->GetCVarString( "fs_game" );
2237 if ( game != NULL && game[0] == '\0' ) {
2238 game = NULL;
2239 }
2240
2241 // find the newest QuickSave (or QuickSave2, QuickSave3, ...)
2242 const int maxNum = com_numQuicksaves.GetInteger();
2243 int indexToUse = 1;
2244 ID_TIME_T newestTime = 0;
2245 for( int i = 1; i <= maxNum; ++i ) {
2246 idStr saveFilePath = saveFilePathBase;
2247 if ( i > 1 ) {
2248 // the first one is just called "QuickSave" without a number, like before.
2249 // the others are called "QuickSave2" "QuickSave3" etc
2250 saveFilePath += i;
2251 }
2252 saveFilePath.SetFileExtension( ".save" );
2253
2254 idFile *f = fileSystem->OpenFileRead( saveFilePath, true, game );
2255 if ( f != NULL ) {
2256 ID_TIME_T ts = f->Timestamp();
2257 assert( ts != 0 );
2258 if ( ts > newestTime ) {
2259 indexToUse = i;
2260 newestTime = ts;
2261 }
2262 delete f;
2263 }
2264 }
2265
2266 if ( indexToUse > 1 ) {
2267 saveName += indexToUse;
2268 }
2269
2270 return sessLocal.LoadGame( saveName );
2271}
2272
2273/*
2274===============

Callers 1

LoadGame_fFunction · 0.80

Calls 7

GetCVarStringMethod · 0.80
GetIntegerMethod · 0.80
OpenFileReadMethod · 0.80
LoadGameMethod · 0.80
GetStringMethod · 0.45
GetLanguageDictMethod · 0.45
TimestampMethod · 0.45

Tested by

no test coverage detected