bool GlulxeMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { const char *const EXTENSIONS[3] = { ".ulx", ".blb", ".gblorb" }; // Loop through the files of the folder for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { // Check for a recognised filename if (file->isDirectory()) continue; Common::String filename = file->getName(); bool hasExt = false; for (int idx = 0; idx < 3 && !hasExt; ++idx) hasExt = filename.hasSuffixIgnoreCase(EXTENSIONS[idx]); if (!hasExt) continue; // Open up the file and calculate the md5 Common::File gameFile; if (!gameFile.open(*file)) continue; Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000); size_t filesize = gameFile.size(); gameFile.close(); // Check for known games const GlulxeGameDescription *p = GLULXE_GAMES; while (p->_gameId && (md5 != p->_md5 || filesize != p->_filesize)) ++p; DetectedGame gd; if (!p->_gameId) { if (filename.hasSuffixIgnoreCase(".blb")) continue; if (gDebugLevel > 0) { // Print an entry suitable for putting into the detection_tables.h, using the // name of the parent folder the game is in as the presumed game Id Common::String folderName = file->getParent().getName(); if (folderName.hasSuffix("\\")) folderName.deleteLastChar(); Common::String fname = filename; const char *dot = strchr(fname.c_str(), '.'); if (dot) fname = Common::String(fname.c_str(), dot); debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize); } const PlainGameDescriptor &desc = GLULXE_GAME_LIST[0]; gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown); } else { PlainGameDescriptor gameDesc = findGame(p->_gameId); gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra); gd.setGUIOptions(GUIO4(GUIO_NOSPEECH, GUIO_NOSFX, GUIO_NOMUSIC, GUIO_NOSUBTITLES)); } gd.addExtraEntry("filename", filename); gameList.push_back(gd); } return !gameList.empty(); }
void PlayerSocket::readyReadHandler() { QDataStream in(socket.data()); in.setVersion(Protocol::QDataStreamVersion); if (blockSize == 0) { // first two bytes are the size of the rest message // so wait until we recive the size of message if (socket->bytesAvailable() < (int)sizeof(quint16)) return; in >> blockSize; } if (socket->bytesAvailable() < blockSize - 2) return; quint8 _type; Protocol::RequestType type; in >> _type; type = Protocol::RequestType(_type); blockSize = 0; if (type == Protocol::SEARCH_GAME) { quint16 servPort; in >> servPort; findGame(servPort); }
IGamePackage* GamePackageManager::changeGame( char const* name ) { IGamePackage* game = findGame( name ); if ( !game ) return NULL; if ( mCurGame ) mCurGame->release(); try { if ( !game->load() ) { mCurGame = NULL; return NULL; } mCurGame = game; return game; } catch( ... ) { mCurGame = NULL; return NULL; } }
bool TADSMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { // Loop through the files of the folder for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { // Check for a recognised filename Common::String filename = file->getName(); if (file->isDirectory() || !(filename.hasSuffixIgnoreCase(".gam") || filename.hasSuffixIgnoreCase(".blorb"))) continue; // Open up the file and calculate the md5 Common::File gameFile; if (!gameFile.open(*file)) continue; Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000); size_t filesize = gameFile.size(); gameFile.close(); // Check for known games const TADSGameDescription *p = TADS_GAMES; while (p->_gameId && p->_md5 && (md5 != p->_md5 || filesize != p->_filesize)) ++p; DetectedGame gd; if (!p->_gameId) { if (!filename.hasSuffixIgnoreCase(".gam")) continue; if (gDebugLevel > 0) { // Print an entry suitable for putting into the detection_tables.h, using the Common::String fname = filename; const char *dot = strchr(fname.c_str(), '.'); if (dot) fname = Common::String(fname.c_str(), dot); debug("ENTRY0(\"%s\", \"%s\", %u),", fname.c_str(), md5.c_str(), (uint)filesize); } const TADSDescriptor &desc = TADS_GAME_LIST[0]; gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown); } else { PlainGameDescriptor gameDesc = findGame(p->_gameId); gd = DetectedGame(p->_gameId, gameDesc.description, p->_language, Common::kPlatformUnknown, p->_extra); } gd.addExtraEntry("filename", filename); gameList.push_back(gd); } return !gameList.empty(); }
bool GamePackageManager::registerGame( IGamePackage* game ) { assert( game ); if ( findGame( game->getName() ) ) return false; if ( !game->create() ) return false; if ( !mPackageMap.insert( std::make_pair( game->getName() , game ) ).second ) { game->cleanup(); return false; } AttribValue attrSetting( ATTR_CONTROLLER_DEFUAULT_SETTING ); game->getAttribValue( attrSetting ); mGamePackages.push_back( game ); return true; }
bool FrotzMetaEngine::detectGames(const Common::FSList &fslist, DetectedGames &gameList) { const char *const EXTENSIONS[] = { ".z1", ".z2", ".z3", ".z4", ".z5", ".z6", ".z7", ".z8", ".dat", ".zip", nullptr }; // Loop through the files of the folder for (Common::FSList::const_iterator file = fslist.begin(); file != fslist.end(); ++file) { // Check for a recognised filename if (file->isDirectory()) continue; Common::String filename = file->getName(); bool hasExt = Blorb::hasBlorbExt(filename), isBlorb = false; for (const char *const *ext = &EXTENSIONS[0]; *ext && !hasExt; ++ext) hasExt = filename.hasSuffixIgnoreCase(*ext); if (!hasExt) continue; // Open up the file and calculate the md5, and get the serial Common::File gameFile; if (!gameFile.open(*file)) continue; Common::String md5 = Common::computeStreamMD5AsString(gameFile, 5000); size_t filesize = gameFile.size(); char serial[9] = ""; bool emptyBlorb = false; gameFile.seek(0); isBlorb = Blorb::isBlorb(gameFile, ID_ZCOD); if (!isBlorb) { if (Blorb::hasBlorbExt(filename)) { gameFile.close(); continue; } gameFile.seek(18); strcpy(&serial[0], "\""); gameFile.read(&serial[1], 6); strcpy(&serial[7], "\""); } else { Blorb b(*file, INTERPRETER_FROTZ); Common::SeekableReadStream *f = b.createReadStreamForMember("game"); emptyBlorb = f == nullptr; if (!emptyBlorb) { f->seek(18); strcpy(&serial[0], "\""); f->read(&serial[1], 6); strcpy(&serial[7], "\""); delete f; } } gameFile.close(); // Check for known games. Note that there has been some variation in exact filesizes // for Infocom games due to padding at the end of files. So we match on md5s for the // first 5Kb, and only worry about filesize for more recent Blorb based Zcode games const FrotzGameDescription *p = FROTZ_GAMES; while (p->_gameId && p->_md5 && (md5 != p->_md5 || (filesize != p->_filesize && isBlorb))) ++p; DetectedGame gd; if (!p->_gameId) { // Generic .dat/.zip files don't get reported as matches unless they have a known md5 if (filename.hasSuffixIgnoreCase(".dat") || filename.hasSuffixIgnoreCase(".zip") || emptyBlorb) continue; if (gDebugLevel > 0) { // Print an entry suitable for putting into the detection_tables.h, using the // name of the parent folder the game is in as the presumed game Id Common::String folderName = file->getParent().getName(); if (folderName.hasSuffix("\\")) folderName.deleteLastChar(); Common::String fname = filename; const char *dot = strchr(fname.c_str(), '.'); if (dot) fname = Common::String(fname.c_str(), dot); debug("ENTRY0(\"%s\", %s, \"%s\", %u),", fname.c_str(), strlen(serial) ? serial : "nullptr", md5.c_str(), (uint)filesize); } const PlainGameDescriptor &desc = ZCODE_GAME_LIST[0]; gd = DetectedGame(desc.gameId, desc.description, Common::UNK_LANG, Common::kPlatformUnknown); } else { GameDescriptor gameDesc = findGame(p->_gameId); gd = DetectedGame(p->_gameId, gameDesc._description, p->_language, Common::kPlatformUnknown, p->_extra); gd.setGUIOptions(p->_guiOptions); } gd.addExtraEntry("filename", filename); gameList.push_back(gd); } return !gameList.empty(); }
void multiPlayer(GlobalState* globalData) { int connect = 0; int hostOrFind = 0; // 0 host game, 1 find game char* mySelections[2] = {"Host Game", "Find Game"}; setupXbee(); printMenu(mySelections, BLACK, GRAY, WHITE, YELLOW, 2); prints(25, 7, YELLOW, GRAY, "Multiplayer", 1); processPrintCursor(globalData, 2, BLACK, YELLOW); switch (hostOrFind) { case 0: prints(3, 48, YELLOW, GRAY, "Waiting for players...", 1); hostGame(); break; case 1: prints(3, 88, YELLOW, GRAY, "Looking for games...", 1); findGame(); break; case 0xFF: return; break; } setupGame(); // // Find other players // while (!connect) { // connect = findPlayer(); // } // // // NOTE: Need to build something to determine who goes first // // Compare Xbee ID's perhaps? // // // Begin game // while (!game.gameOver && connect) { // if (game.turn) { // // Pick Move // game.myMove = pickMove(globalData); // // Send Move // sendMove(); // // Receive new score after opponent takes damage // game.oppScore = receiveScore(); // printGame(globalData); // prints(0, 10, RED, BLACK, " ", 1); // prints(0, 10, RED, BLACK, "Opponent took damage:", 1); // prints(0, 21, RED, BLACK, "-", 1); // integerprint(6, 21, RED, BLACK, game.myMove, 1); // } else { // // Receive player move and take damage // game.myScore = attack(receiveMove(), game.myScore); // prints(0, 10, RED, BLACK, " ", 1); // prints(0, 10, RED, BLACK, "Taken damage:", 1); // prints(0, 21, RED, BLACK, "-", 1); // integerprint(6, 21, RED, BLACK, game.oppMove, 1); // // Send new score // sendScore(); // } // prints(0, 45, YELLOW, BLACK, " ", 1); // integerprint(0, 45, YELLOW, BLACK, game.myScore, 1); // prints(0, 75, WHITE, BLACK, " ", 1); // integerprint(0, 75, WHITE, BLACK, game.oppScore, 1); // // Check game status // game.gameOver = gameStatus(); // game.turn =!game.turn; // } // if (!connect) { // printBSOD(); // } else { // printResults(); // } }