std::string GameListItem::GetUniqueIdentifier() const { const DiscIO::Language lang = DiscIO::Language::LANGUAGE_ENGLISH; std::vector<std::string> info; if (!GetGameID().empty()) info.push_back(GetGameID()); if (GetRevision() != 0) { std::string rev_str = "Revision "; info.push_back(rev_str + std::to_string((long long)GetRevision())); } std::string name(GetName(lang)); if (name.empty()) name = GetName(); int disc_number = GetDiscNumber() + 1; std::string lower_name = name; std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); if (disc_number > 1 && lower_name.find(std::string(wxString::Format("disc %i", disc_number))) == std::string::npos && lower_name.find(std::string(wxString::Format("disc%i", disc_number))) == std::string::npos) { std::string disc_text = "Disc "; info.push_back(disc_text + std::to_string(disc_number)); } if (info.empty()) return name; std::ostringstream ss; std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", ")); ss << info.back(); return name + " (" + ss.str() + ")"; }
std::string GameFile::GetUniqueIdentifier() const { std::vector<std::string> info; if (!GetGameID().empty()) info.push_back(GetGameID()); if (GetRevision() != 0) info.push_back("Revision " + std::to_string(GetRevision())); std::string name = GetLongName(DiscIO::Language::English); if (name.empty()) { // Use the file name as a fallback. Not necessarily consistent, but it's the best we have name = m_file_name; } int disc_number = GetDiscNumber() + 1; std::string lower_name = name; std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); if (disc_number > 1 && lower_name.find(StringFromFormat("disc %i", disc_number)) == std::string::npos && lower_name.find(StringFromFormat("disc%i", disc_number)) == std::string::npos) { std::string disc_text = "Disc "; info.push_back(disc_text + std::to_string(disc_number)); } if (info.empty()) return name; std::ostringstream ss; std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", ")); ss << info.back(); return name + " (" + ss.str() + ")"; }
std::string GameFile::GetUniqueIdentifier() const { std::vector<std::string> info; if (!GetGameID().empty()) info.push_back(GetGameID()); if (GetRevision() != 0) info.push_back("Revision " + std::to_string(GetRevision())); const std::string& name = GetName(); int disc_number = GetDiscNumber() + 1; std::string lower_name = name; std::transform(lower_name.begin(), lower_name.end(), lower_name.begin(), ::tolower); if (disc_number > 1 && lower_name.find(StringFromFormat("disc %i", disc_number)) == std::string::npos && lower_name.find(StringFromFormat("disc%i", disc_number)) == std::string::npos) { std::string disc_text = "Disc "; info.push_back(disc_text + std::to_string(disc_number)); } if (info.empty()) return name; std::ostringstream ss; std::copy(info.begin(), info.end() - 1, std::ostream_iterator<std::string>(ss, ", ")); ss << info.back(); return name + " (" + ss.str() + ")"; }
void CheatsManager::OnStateChanged(Core::State state) { if (state != Core::State::Running && state != Core::State::Paused) return; auto* model = Settings::Instance().GetGameListModel(); for (int i = 0; i < model->rowCount(QModelIndex()); i++) { auto file = model->GetGameFile(i); if (file->GetGameID() == SConfig::GetInstance().GetGameID()) { m_game_file = file; if (m_tab_widget->count() == 3) { m_tab_widget->removeTab(0); m_tab_widget->removeTab(0); } if (m_tab_widget->count() == 1) { if (m_ar_code) m_ar_code->deleteLater(); m_ar_code = new ARCodeWidget(*m_game_file, false); m_tab_widget->insertTab(0, m_ar_code, tr("AR Code")); m_tab_widget->insertTab(1, new GeckoCodeWidget(*m_game_file, false), tr("Gecko Codes")); } } } }
// 加载数据 bool CPlayer::LoadData(Msg *pMsg) { svrData::LoadPlayerData msg; _CHECK_PARSE_(pMsg, msg) false; if (!UnPackData(msg.data().c_str(), msg.data().size())) return false; SetAccount(msg.account()); SetName(msg.name().c_str()); SetGuid(msg.nguid()); SetSex(msg.nsex()); SetJob(msg.njob()); SetLevel(msg.nlevel()); SetCreateTime(msg.ncreatetime()); SetLoginTime(msg.nlogintime()); SetMapID(msg.nmapid()); SetNowPos(msg.nx(), msg.ny(), msg.nz()); m_LastSaveTime = CTimer::GetTime() + CRandomPool::GetOneLess(60); RunStateLog("加载玩家:%s数据成功!账号:%s", GetName(), msg.account().c_str()); if (!msg.bchangeline()) { svrData::AddPlayerToCenter SendMsg; SendMsg.set_nguid(GetGuid()); SendMsg.set_ngameid(GetGameID()); SendMsg.set_nclientid(GetClientID()); SendMsg.set_ngateid(GetGateID()); SendMsg.set_account(GetAccount()); FuncUti::SendMsgToCenter(this, SendMsg, SERVER_TYPE_MAIN, SVR_SUB_ADD_PLAYER_TO_CENTER); } m_LoadDataSucc = true; return true; }
bool SmallNineAndroid::OnApplyBanker(const void* pBuffer, WORD wDataSize) { if (wDataSize != sizeof(CMD_S_ApplyBanker)) return 0; CMD_S_ApplyBanker* pApplyBanker = (CMD_S_ApplyBanker *)pBuffer; SUser* pUser = m_pUserManager->Search(pApplyBanker->szAccount); if (pUser != NULL) { if (pApplyBanker->bApplyBanker) { if (BankerManager::GetSingleton().Search(pUser->dwUserID) == NULL) { BankerManager::GetSingleton().Insert( new SBanker(pApplyBanker->szAccount, pApplyBanker->lScore, pUser->dwUserID) ); } } else { BankerManager::GetSingleton().Remove(pUser->dwUserID); } if (isSelf(pUser->dwUserID)) { BankerManager::GetSingleton().RemoveRequest(pUser->dwUserID); CString szMessage; szMessage.Format("[%d][%d]已移除上庄请求,当前请求次数%d", GetUserID(), GetGameID(), BankerManager::GetSingleton().GetRequestCount()); LogEvent(szMessage, TraceLevel_Debug); } } return true; }
bool SmallNineAndroid::OnUpdateTime(float fElapsed) { m_fElapsed += fElapsed; if ((m_fElapsed / 60) >= m_fOnlineTime) { if (isSelf(m_wCurBanker)) { m_fOnlineTime = AndroidTimer::rdit(5, 15); m_fElapsed = 0; } else { if (m_nChipInScore <= 0) { CString szMessage; szMessage.Format("[%d][%d]到达在线时间, 立刻下线", GetUserID(), GetGameID()); LogEvent(szMessage, TraceLevel_Exception); BankerManager::GetSingleton().Remove(m_dwUserID); SetStatus(US_OFFLINE); } else { m_fOnlineTime = AndroidTimer::rdit(5, 15); m_fElapsed = 0; } } } return true; }
int main() { double begin = clock(); aobscan(GetGameID(), "807f49 00"); printf("time:%.0fms", clock() - begin); getchar(); }
void GameList::OpenGCSaveFolder() { const auto game = GetSelectedGame(); if (!game) return; bool found = false; for (int i = 0; i < 2; i++) { QUrl url; switch (SConfig::GetInstance().m_EXIDevice[i]) { case ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER: { std::string path = StringFromFormat("%s/%s/%s", File::GetUserPath(D_GCUSER_IDX).c_str(), SConfig::GetDirectoryForRegion(game->GetRegion()), i == 0 ? "Card A" : "Card B"); std::string override_path = i == 0 ? Config::Get(Config::MAIN_GCI_FOLDER_A_PATH_OVERRIDE) : Config::Get(Config::MAIN_GCI_FOLDER_B_PATH_OVERRIDE); if (!override_path.empty()) path = override_path; QDir dir(QString::fromStdString(path)); if (!dir.entryList({QStringLiteral("%1-%2-*.gci") .arg(QString::fromStdString(game->GetMakerID())) .arg(QString::fromStdString(game->GetGameID().substr(0, 4)))}) .empty()) { url = QUrl::fromLocalFile(dir.absolutePath()); } break; } case ExpansionInterface::EXIDEVICE_MEMORYCARD: std::string memcard_path = i == 0 ? Config::Get(Config::MAIN_MEMCARD_A_PATH) : Config::Get(Config::MAIN_MEMCARD_B_PATH); std::string memcard_dir; SplitPath(memcard_path, &memcard_dir, nullptr, nullptr); url = QUrl::fromLocalFile(QString::fromStdString(memcard_dir)); break; } found |= !url.isEmpty(); if (!url.isEmpty()) QDesktopServices::openUrl(url); } if (!found) ModalMessageBox::information(this, tr("Information"), tr("No save data found.")); }
void GameList::OpenWiki() { const auto game = GetSelectedGame(); if (!game) return; QString game_id = QString::fromStdString(game->GetGameID()); QString url = QStringLiteral("https://wiki.dolphin-emu.org/index.php?title=").append(game_id); QDesktopServices::openUrl(QUrl(url)); }
void GameList::CompressISO() { const auto original_path = GetSelectedGame(); auto file = GameFile(original_path); const bool compressed = (file.GetBlobType() == DiscIO::BlobType::GCZ); if (!compressed && file.GetPlatformID() == DiscIO::Platform::WII_DISC) { QMessageBox wii_warning(this); wii_warning.setIcon(QMessageBox::Warning); wii_warning.setText(tr("Are you sure?")); wii_warning.setInformativeText( tr("Compressing a Wii disc image will irreversibly change the compressed copy by removing " "padding data. Your disc image will still work.")); wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (wii_warning.exec() == QMessageBox::No) return; } QString dst_path = QFileDialog::getSaveFileName( this, compressed ? tr("Select where you want to save the decompressed image") : tr("Select where you want to save the compressed image"), QFileInfo(GetSelectedGame()) .dir() .absoluteFilePath(file.GetGameID()) .append(compressed ? QStringLiteral(".gcm") : QStringLiteral(".gcz")), compressed ? tr("Uncompressed GC/Wii images (*.iso *.gcm") : tr("Compressed GC/Wii images (*.gcz)")); if (dst_path.isEmpty()) return; QProgressDialog progress_dialog(compressed ? tr("Decompressing...") : tr("Compressing..."), tr("Abort"), 0, 100, this); progress_dialog.setWindowModality(Qt::WindowModal); bool good; if (compressed) { good = DiscIO::DecompressBlobToFile(original_path.toStdString(), dst_path.toStdString(), &CompressCB, &progress_dialog); } else { good = DiscIO::CompressFileToBlob(original_path.toStdString(), dst_path.toStdString(), file.GetPlatformID() == DiscIO::Platform::WII_DISC ? 1 : 0, 16384, &CompressCB, &progress_dialog); } if (good) { QMessageBox(QMessageBox::Information, tr("Success!"), tr("Successfully compressed image."), QMessageBox::Ok, this) .exec(); } else { QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action.")); } }
bool SmallNineAndroid::OnUpBankerRequest(float fElapsed) { SAppConfig* pConfig = ConfigFile::GetSingleton().GetAppConfig(); SUser* pUser = GetUserInfo(); if (pUser == NULL) return 0; // 上庄处理 if (BankerManager::GetSingleton().CheckRequest(m_dwUserID) || BankerManager::GetSingleton().Search(m_dwUserID)) return 0; DWORD dwBankerCount = BankerManager::GetSingleton().GetBankerCount(); DWORD dwRequest = BankerManager::GetSingleton().GetRequestCount(); if (dwBankerCount >= pConfig->wMaxDeque) { if (dwRequest > 0) BankerManager::GetSingleton().ClearRequest(); return 0; } m_fRequestTime -= fElapsed; if (m_fRequestTime <= 0) { bool bSendReq = 0; if (m_wCurBanker != INVALID_CHAIR) { if (!isSelf(m_wCurBanker)) bSendReq = ((dwBankerCount + dwRequest) < pConfig->wMaxDeque) ? true : 0; } else { bSendReq = true; } if (bSendReq && pUser->nScore > m_nReqBankerScore) { if (dwBankerCount >= MIN_LINUP) { WORD wRate = rand() % 100; if (wRate <= 80) { m_fRequestTime = AndroidTimer::rdit(10, 20); return 0; } } BankerManager::GetSingleton().AddRequest(GetUserID()); CString szMessage; szMessage.Format("[%d][%d]已发送上庄请求,当前请求次数%d", GetUserID(), GetGameID(), BankerManager::GetSingleton().GetRequestCount()); LogEvent(szMessage, TraceLevel_Debug); CMD_C_ApplyBanker req; req.bApplyBanker = true; SendData(MDM_GF_GAME, SUB_C_APPLY_BANKER, &req, sizeof( req )); } m_fRequestTime = AndroidTimer::rdit(5, 15); } return true; }
IniFile SConfig::LoadGameIni() const { return LoadGameIni(GetGameID(), m_revision); }
// called from ---GUI--- thread bool NetPlayServer::SyncSaveData() { m_save_data_synced_players = 0; u8 save_count = 0; constexpr size_t exi_device_count = 2; for (size_t i = 0; i < exi_device_count; i++) { if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARD || SConfig::GetInstance().m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER) { save_count++; } } const auto game = m_dialog->FindGameFile(m_selected_game); if (game == nullptr) { PanicAlertT("Selected game doesn't exist in game list!"); return false; } bool wii_save = false; if (m_settings.m_CopyWiiSave && (game->GetPlatform() == DiscIO::Platform::WiiDisc || game->GetPlatform() == DiscIO::Platform::WiiWAD)) { wii_save = true; save_count++; } { sf::Packet pac; pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << static_cast<MessageId>(SYNC_SAVE_DATA_NOTIFY); pac << save_count; SendAsyncToClients(std::move(pac)); } if (save_count == 0) return true; const std::string region = SConfig::GetDirectoryForRegion(SConfig::ToGameCubeRegion(game->GetRegion())); for (size_t i = 0; i < exi_device_count; i++) { const bool is_slot_a = i == 0; if (m_settings.m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARD) { std::string path = is_slot_a ? Config::Get(Config::MAIN_MEMCARD_A_PATH) : Config::Get(Config::MAIN_MEMCARD_B_PATH); MemoryCard::CheckPath(path, region, is_slot_a); bool mc251; IniFile gameIni = SConfig::LoadGameIni(game->GetGameID(), game->GetRevision()); gameIni.GetOrCreateSection("Core")->Get("MemoryCard251", &mc251, false); if (mc251) path.insert(path.find_last_of('.'), ".251"); sf::Packet pac; pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << static_cast<MessageId>(SYNC_SAVE_DATA_RAW); pac << is_slot_a << region << mc251; if (File::Exists(path)) { if (!CompressFileIntoPacket(path, pac)) return false; } else { // No file, so we'll say the size is 0 pac << sf::Uint64{0}; } SendAsyncToClients(std::move(pac)); } else if (SConfig::GetInstance().m_EXIDevice[i] == ExpansionInterface::EXIDEVICE_MEMORYCARDFOLDER) { const std::string path = File::GetUserPath(D_GCUSER_IDX) + region + DIR_SEP + StringFromFormat("Card %c", is_slot_a ? 'A' : 'B'); sf::Packet pac; pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << static_cast<MessageId>(SYNC_SAVE_DATA_GCI); pac << is_slot_a; if (File::IsDirectory(path)) { std::vector<std::string> files = GCMemcardDirectory::GetFileNamesForGameID(path + DIR_SEP, game->GetGameID()); pac << static_cast<u8>(files.size()); for (const std::string& file : files) { pac << file.substr(file.find_last_of('/') + 1); if (!CompressFileIntoPacket(file, pac)) return false; } } else { pac << static_cast<u8>(0); } SendAsyncToClients(std::move(pac)); } } if (wii_save) { const auto configured_fs = IOS::HLE::FS::MakeFileSystem(IOS::HLE::FS::Location::Configured); const auto save = WiiSave::MakeNandStorage(configured_fs.get(), game->GetTitleID()); sf::Packet pac; pac << static_cast<MessageId>(NP_MSG_SYNC_SAVE_DATA); pac << static_cast<MessageId>(SYNC_SAVE_DATA_WII); if (save->SaveExists()) { const std::optional<WiiSave::Header> header = save->ReadHeader(); const std::optional<WiiSave::BkHeader> bk_header = save->ReadBkHeader(); const std::optional<std::vector<WiiSave::Storage::SaveFile>> files = save->ReadFiles(); if (!header || !bk_header || !files) return false; pac << true; // save exists // Header pac << sf::Uint64{header->tid}; pac << header->banner_size << header->permissions << header->unk1; for (size_t i = 0; i < header->md5.size(); i++) pac << header->md5[i]; pac << header->unk2; for (size_t i = 0; i < header->banner_size; i++) pac << header->banner[i]; // BkHeader pac << bk_header->size << bk_header->magic << bk_header->ngid << bk_header->number_of_files << bk_header->size_of_files << bk_header->unk1 << bk_header->unk2 << bk_header->total_size; for (size_t i = 0; i < bk_header->unk3.size(); i++) pac << bk_header->unk3[i]; pac << sf::Uint64{bk_header->tid}; for (size_t i = 0; i < bk_header->mac_address.size(); i++) pac << bk_header->mac_address[i]; // Files for (const WiiSave::Storage::SaveFile& file : *files) { pac << file.mode << file.attributes << static_cast<u8>(file.type) << file.path; if (file.type == WiiSave::Storage::SaveFile::Type::File) { const std::optional<std::vector<u8>>& data = *file.data; if (!data || !CompressBufferIntoPacket(*data, pac)) return false; } } } else { pac << false; // save does not exist } SendAsyncToClients(std::move(pac)); } return true; }