| 177 | } |
| 178 | |
| 179 | void GameLoop::init() |
| 180 | { |
| 181 | /* Unvalidate the game pid */ |
| 182 | context->game_pid = 0; |
| 183 | MemAccess::fini(); |
| 184 | |
| 185 | /* Unvalidate the game window id */ |
| 186 | context->game_window = 0; |
| 187 | |
| 188 | /* Reset the frame count if not restarting */ |
| 189 | if (context->status != Context::RESTARTING) |
| 190 | context->framecount = 0; |
| 191 | |
| 192 | /* Reset the rerecord count if not restarting */ |
| 193 | if (context->status != Context::RESTARTING) |
| 194 | context->rerecord_count = 0; |
| 195 | |
| 196 | /* Reset the encoding segment if not restarting */ |
| 197 | if (context->status != Context::RESTARTING) |
| 198 | encoding_segment = 0; |
| 199 | |
| 200 | /* Extract the game executable name from the game executable path */ |
| 201 | context->gamename = context->gamepath.filename(); |
| 202 | |
| 203 | /* Clear the event queue and parameters */ |
| 204 | gameEvents->init(); |
| 205 | |
| 206 | /* Remove savestates again in case we did not exist cleanly the previous time */ |
| 207 | remove_savestates(context); |
| 208 | |
| 209 | /* Remove the file socket */ |
| 210 | int err = removeSocket(); |
| 211 | if (err != 0) |
| 212 | emit alertToShow(QString("Could not remove socket file /tmp/libTAS.socket: %2").arg(strerror(err))); |
| 213 | |
| 214 | /* Clear addresses of loaded files */ |
| 215 | BaseAddresses::clear(); |
| 216 | |
| 217 | /* Init savestate list */ |
| 218 | SaveStateList::init(context); |
| 219 | |
| 220 | /* Compute the MD5 hash of the game binary */ |
| 221 | context->md5_game.clear(); |
| 222 | std::ostringstream cmd; |
| 223 | cmd << "md5sum -b \"" << context->gamepath << "\" 2> /dev/null"; |
| 224 | |
| 225 | context->md5_game = queryCmd(cmd.str()); |
| 226 | if (context->md5_game.size() > 32) |
| 227 | context->md5_game.resize(32); |
| 228 | |
| 229 | /* Only open the movie if we did not restart */ |
| 230 | if (context->status != Context::RESTARTING) { |
| 231 | /* Opening a movie, which imports the inputs and parameters if in read mode, |
| 232 | * or prepare a movie if in write mode. |
| 233 | */ |
| 234 | if (context->config.sc.recording == SharedConfig::RECORDING_READ) { |
| 235 | int ret = movie.loadMovie(); |
| 236 | if (ret < 0) { |
nothing calls this directly
no test coverage detected