bool StarTrekEngine::loadGame(int slot) { Common::String filename = getSavegameFilename(slot); Common::InSaveFile *in; if (!(in = _saveFileMan->openForLoading(filename))) { warning("Can't open file '%s', game not loaded", filename.c_str()); return false; } else { debug(3, "Successfully opened %s for loading", filename.c_str()); } SavegameMetadata meta; if (!saveOrLoadMetadata(in, nullptr, &meta)) { delete in; return false; } if (meta.version > CURRENT_SAVEGAME_VERSION) { delete in; error("Savegame version (%u) is newer than current version (%u). A newer version of ScummVM is needed", meta.version, CURRENT_SAVEGAME_VERSION); } if (!saveOrLoadGameData(in, nullptr, &meta)) { delete in; return false; } delete in; _lastGameMode = _gameMode; if (_gameMode == GAMEMODE_AWAYMISSION) { for (int i = 0; i < NUM_ACTORS; i++) { Actor *a = &_actorList[i]; if (a->spriteDrawn) { if (a->animType != 1) a->animFile = loadFile(Common::String(a->animFilename) + ".anm"); _gfx->addSprite(&a->sprite); a->sprite.setBitmap(loadAnimationFrame(a->bitmapFilename, a->scale)); } } } else if (_gameMode == -1) { initBridge(true); _lastGameMode = GAMEMODE_BRIDGE; // TODO: mode change } else { _txtFilename = _missionToLoad; initBridge(false); // TODO: mode change } return true; }
bool NetworkBridge::connectBridge(){ //closeBridge(); initBridge(); int iResult = getaddrinfo(DEFAULT_IP, DEFAULT_PORT, &hints, &result); if(iResult!=0){ std::cout << "couldn't connect: " << iResult << std::endl; return false; } // Attempt to connect to an address until one succeeds for (ptr = result; ptr != NULL; ptr = ptr->ai_next) { // Create a SOCKET for connecting to server ConnectSocket = socket(ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol); if (ConnectSocket == INVALID_SOCKET) { std::cout << "socket failed with error: " << WSAGetLastError() << std::endl; continue; } // Connect to server. iResult = connect(ConnectSocket, ptr->ai_addr, (int)ptr->ai_addrlen); if (iResult == SOCKET_ERROR) { closesocket(ConnectSocket); ConnectSocket = INVALID_SOCKET; continue; } break; } freeaddrinfo(result); if (ConnectSocket == INVALID_SOCKET) { std::cout << "\n*** Unable to connect to server! ***\n"; connectBridge(); return false; } return true; }