int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // Prepare the XML file QFile file("list.xml"); file.remove(); QDomDocument xml; QDomNode declaration = xml.createProcessingInstruction("xml",QString("version=\"1.0\" encoding=\"UTF-8\"")); xml.insertBefore(declaration,xml.firstChild()); QDomComment comment = xml.createComment("Do not edit this file, it is regenerated automatically!"); xml.appendChild(comment); QDomNode root = xml.createElement("files"); xml.appendChild(root); // Liste tous les fichiers QStringList liste; QDirIterator it(".", QDir::Files, QDirIterator::Subdirectories); while (it.hasNext()) { if(QString(it.hasNext()).startsWith("./Assets/Modules/Custom_Civilizations_MCP/")) {} else{ // Add the file to the list QDomElement entity = xml.createElement("file"); entity.appendChild(xml.createTextNode(it.next())); entity.setAttribute("md5", checkMd5(it.next())); root.appendChild(entity); } } // Save the file file.open(QIODevice::Truncate | QIODevice::WriteOnly); QTextStream ts(&file); xml.save(ts, 4); file.close(); return a.exec(); }
void w_main::on_bt_launch_clicked() // GUI : Launch game button { // Check if the game path is known if(readCheckerParam("Main/ExecutablePath") == "error") { QMessageBox::information(0, "Information", tr("To be able to launch the game from the launcher, you need to set the game path in the options window. (Options > Select game path)")); return; } else { QString lang = getCurrentLanguage(); QString executable; if(lang == "ko" || lang == "ja" || lang == "zh") { // Asian language have a different executable, supporting 2-bytes encoding executable = readCheckerParam("Main/ExecutablePath"); QString asian_executable = executable; asian_executable.replace("Civ4BeyondSword.exe","Civ4BeyondSword_Asian.exe"); QFile exe(executable); if(!exe.exists()) { QMessageBox::information(0, "Information", tr("The executable hasn't been found. Please set the game path in the options window. (Options > Select game path)")); return; } QFile asian_exe(asian_executable); if(!asian_exe.exists()) { // Make a question box QMessageBox question; question.setWindowTitle(tr("Asian language patch not applied")); question.setText(tr("You need to apply a patch on the base game for the extension to be compatible with Asian languages. The original version won't be modified. Would you like to apply it now ?")); question.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); int ret = question.exec(); switch(ret){ case QMessageBox::Ok: system("checker\\asian_patcher.exe"); return; break; case QMessageBox::Cancel: return; break; default: return; break; } } launchGame(asian_executable); } else { executable = readCheckerParam("Main/ExecutablePath"); QFile exe(executable); if(!exe.exists()) { QMessageBox::information(0, "Information", tr("The executable hasn't been found. Please set the game path in the options window. (Options > Select game path)")); return; } //qDebug() << "Executable checksum is " << checkMd5(executable); // Warn when the latest Steam version is used if(checkMd5(executable) == "93a64f40d3d4093faeac3e9e626f79de" && readCheckerParam("Main/DisableWarning") != "1") { QMessageBox::information(0, "Information", tr("The game version you are using is known for causing some display problems, like invisible religion icons. Please read the 'note for Steam users' on our website to fix the problem. The website help page will now open.")+ "\n\n" + tr("You can disable this warning in the options.")); openURL("http://anewdawn.sourceforge.net/pages/install/"); return; } launchGame(executable); } } // Check if the launcher should quit if(readCheckerParam("Main/QuitLauncher") == "1") { qApp->exit(); } else { this->setWindowState(Qt::WindowMinimized); } }
CUploader::result_code CUploader::upload(CAsset * p) { assert(_crt == nullptr); assert(_f == nullptr); assert( p ); assert( !p->isFolder() ); LOGD("uploading {}", p->getRelativePath()); auto hLocal = p->getSrcHash(); _crt = p; _totalReaded= _totalUploaded= 0; _bStarting = true; _bDone = false; if (!hLocal._md5.isValid()) _md5Computer.init(); if (crypted()) { _md5EncComputer.init(); assert( _cryptoContext == nullptr ); // create one context for each upload so the salt will be regenerated ! _cryptoContext = CCryptoContext::create(_ctx._options->_cryptoPassword); } _rq.addHeader(headerAuthToken, _ctx._cr.token()); _rq.addHeader(metaVersion, HUBACK_VERSION); if (crypted()) _rq.addHeader("Content-Type", "application/octet-stream"); else _rq.addHeader("Content-Length", fmt::format("{}", hLocal._len)); const std::string url= fmt::format("{}/{}/{}", _ctx._cr.endpoint(), _ctx._options->_dstContainer, (_ctx._options->_dstFolder / _rq.escapePath(p->getRelativePath())).string() ); addMetaDatasToRequest(_rq, p, crypted() ); _rq.setopt(CURLOPT_READDATA, this); _rq.setopt(CURLOPT_READFUNCTION, CUploader::_rdd); _f = fopen(p->getFullPath().c_str(), "rb"); _rq.put(url); fclose(_f); _f = nullptr; if (_md5Computer.isInitialised()) { _md5Computer.done(); assert( !hLocal._md5.isValid() ); hLocal._computed = true; hLocal._md5= _md5Computer.getDigest(); p->setSrcHash(hLocal); } if (_cryptoContext) { delete _cryptoContext; _cryptoContext = nullptr; _md5EncComputer.done(); LOGD("md5 encrypted '{}' = '{}'", _crt->getRelativePath().string(), _md5EncComputer.getDigest().hex()); } if (_rq.getHttpResponseCode() != 201) { _crt = nullptr; if (_rq.getHttpResponseCode() == 500) { LOGW("Server internal error (500) uploading '{}' [will retry]", url); return resRetry; } LOGE("Error uploading '{}' [http response : {}]", url, _rq.getHttpResponseCode()); return resError; } // Check uploaded file // sometime, hubic return a bad md5 tag once. (is it a bug from this app ??) // we need to check it twice in this case if (!checkMd5(url)) { // try again std::this_thread::sleep_for(std::chrono::seconds(5)); if (!checkMd5(url)) { LOGE("Error uploading encrypted {}", url); LOGE("md5 mismatch got '{}' != expected '{}'", _rq.getResponseHeaderField("Etag"), (crypted() ? _md5EncComputer.getDigest().hex() : _md5Computer.getDigest().hex())); LOGE("http response : {}", _rq.getHeaderResponse()); _crt = nullptr; return resError; } } // update meta datas _rq.addHeader(headerAuthToken, _ctx._cr.token()); addMetaDatasToRequest(_rq, p, crypted() ); _rq.post(url); LOGD("'{}' uploaded Ok.", url ); _crt = nullptr; return resOk; }