=============== idSessionLocal::LoadGame =============== */
| 2067 | =============== |
| 2068 | */ |
| 2069 | bool idSessionLocal::LoadGame( const char *saveName ) { |
| 2070 | #ifdef ID_DEDICATED |
| 2071 | common->Printf( "Dedicated servers cannot load games.\n" ); |
| 2072 | return false; |
| 2073 | #else |
| 2074 | int i; |
| 2075 | idStr in, loadFile, saveMap, gamename; |
| 2076 | |
| 2077 | if ( IsMultiplayer() ) { |
| 2078 | common->Printf( "Can't load during net play.\n" ); |
| 2079 | return false; |
| 2080 | } |
| 2081 | |
| 2082 | //Hide the dialog box if it is up. |
| 2083 | StopBox(); |
| 2084 | |
| 2085 | loadFile = saveName; |
| 2086 | ScrubSaveGameFileName( loadFile ); |
| 2087 | loadFile.SetFileExtension( ".save" ); |
| 2088 | |
| 2089 | in = "savegames/"; |
| 2090 | in += loadFile; |
| 2091 | |
| 2092 | // Open savegame file |
| 2093 | // only allow loads from the game directory because we don't want a base game to load |
| 2094 | idStr game = cvarSystem->GetCVarString( "fs_game" ); |
| 2095 | savegameFile = fileSystem->OpenFileRead( in, true, game.Length() ? game : NULL ); |
| 2096 | |
| 2097 | if ( savegameFile == NULL ) { |
| 2098 | common->Warning( "Couldn't open savegame file %s", in.c_str() ); |
| 2099 | return false; |
| 2100 | } |
| 2101 | |
| 2102 | loadingSaveGame = true; |
| 2103 | |
| 2104 | // Read in save game header |
| 2105 | // Game Name / Version / Map Name / Persistant Player Info |
| 2106 | |
| 2107 | // game |
| 2108 | savegameFile->ReadString( gamename ); |
| 2109 | |
| 2110 | // if this isn't a savegame for the correct game, abort loadgame |
| 2111 | if ( ! (gamename == GAME_NAME || gamename == "DOOM 3") ) { |
| 2112 | common->Warning( "Attempted to load an invalid savegame: %s", in.c_str() ); |
| 2113 | |
| 2114 | loadingSaveGame = false; |
| 2115 | fileSystem->CloseFile( savegameFile ); |
| 2116 | savegameFile = NULL; |
| 2117 | return false; |
| 2118 | } |
| 2119 | |
| 2120 | // version |
| 2121 | savegameFile->ReadInt( savegameVersion ); |
| 2122 | |
| 2123 | // map |
| 2124 | savegameFile->ReadString( saveMap ); |
| 2125 | |
| 2126 | // persistent player info |
no test coverage detected