mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-20 16:08:44 +00:00
Added linux patcher!
This commit is contained in:
parent
e728daa7cd
commit
666ab7ebec
4 changed files with 115 additions and 23 deletions
|
@ -237,6 +237,7 @@ MACRO(NL_SETUP_DEFAULT_OPTIONS)
|
|||
OPTION(WITH_PCH "With Precompiled Headers" ON )
|
||||
OPTION(FINAL_VERSION "Build in Final Version mode" ON )
|
||||
OPTION(WITH_PERFHUD "Build with NVIDIA PerfHUD support" OFF )
|
||||
OPTION(WITH_PATCH_SUPPORT "Build with in-game Patch Support" OFF )
|
||||
|
||||
# Default to static building on Windows.
|
||||
IF(WIN32)
|
||||
|
|
|
@ -423,11 +423,11 @@ CClientConfig::CClientConfig()
|
|||
SelectionFXSize = 0.8f;
|
||||
|
||||
// only force patching under Windows by default
|
||||
#ifdef NL_OS_WINDOWS
|
||||
PatchWanted = true;
|
||||
#else
|
||||
PatchWanted = false;
|
||||
#endif
|
||||
#if WITH_PATCH_SUPPORT
|
||||
PatchWanted = true;
|
||||
#else
|
||||
PatchWanted = false;
|
||||
#endif
|
||||
PatchUrl = "";
|
||||
PatchletUrl = "";
|
||||
PatchVersion = "";
|
||||
|
@ -846,7 +846,6 @@ void CClientConfig::setValues()
|
|||
if (nlstricmp(varPtr->asString(), "Auto") == 0 || nlstricmp(varPtr->asString(), "0") == 0) ClientCfg.Driver3D = CClientConfig::DrvAuto;
|
||||
else if (nlstricmp(varPtr->asString(), "OpenGL") == 0 || nlstricmp(varPtr->asString(), "1") == 0) ClientCfg.Driver3D = CClientConfig::OpenGL;
|
||||
else if (nlstricmp(varPtr->asString(), "Direct3D") == 0 || nlstricmp(varPtr->asString(), "2") == 0) ClientCfg.Driver3D = CClientConfig::Direct3D;
|
||||
else if (nlstricmp(varPtr->asString(), "OpenGLES") == 0 || nlstricmp(varPtr->asString(), "3") == 0) ClientCfg.Driver3D = CClientConfig::OpenGLES;
|
||||
}
|
||||
else
|
||||
cfgWarning ("Default value used for 'Driver3D' !!!");
|
||||
|
@ -892,7 +891,9 @@ void CClientConfig::setValues()
|
|||
READ_STRING_FV(CreateAccountURL)
|
||||
READ_STRING_FV(EditAccountURL)
|
||||
READ_STRING_FV(ConditionsTermsURL)
|
||||
READ_STRING_FV(BetaAccountURL)
|
||||
READ_STRING_FV(ForgetPwdURL)
|
||||
READ_STRING_FV(FreeTrialURL)
|
||||
READ_STRING_FV(LoginSupportURL)
|
||||
|
||||
#ifndef RZ_NO_CLIENT
|
||||
|
@ -1057,11 +1058,18 @@ void CClientConfig::setValues()
|
|||
/////////////////////////
|
||||
// NEW PATCHING SYSTEM //
|
||||
READ_BOOL_FV(PatchWanted)
|
||||
READ_STRING_FV(PatchServer)
|
||||
READ_STRING_FV(PatchUrl)
|
||||
READ_STRING_FV(PatchVersion)
|
||||
READ_STRING_FV(RingReleaseNotePath)
|
||||
READ_STRING_FV(ReleaseNotePath)
|
||||
READ_BOOL_DEV(PatchWanted)
|
||||
READ_STRING_DEV(PatchServer)
|
||||
READ_STRING_DEV(PatchUrl)
|
||||
READ_STRING_DEV(PatchVersion)
|
||||
READ_STRING_DEV(RingReleaseNotePath)
|
||||
READ_STRING_DEV(ReleaseNotePath)
|
||||
READ_STRING_FV(PatchServer)
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// NEW PATCHLET SYSTEM //
|
||||
|
|
|
@ -18,6 +18,14 @@
|
|||
// Includes
|
||||
//
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef NL_OS_WINDOWS
|
||||
//windows doesnt have unistd.h
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "stdpch.h"
|
||||
|
||||
#include <memory>
|
||||
|
@ -38,9 +46,7 @@
|
|||
#include "nel/misc/big_file.h"
|
||||
#include "nel/misc/i18n.h"
|
||||
|
||||
#ifdef NL_OS_WINOWS
|
||||
#define NL_USE_SEVENZIP 1
|
||||
#endif
|
||||
#define NL_USE_SEVENZIP 1
|
||||
|
||||
// 7 zip includes
|
||||
#ifdef NL_USE_SEVENZIP
|
||||
|
@ -740,6 +746,7 @@ void CPatchManager::deleteBatchFile()
|
|||
// ****************************************************************************
|
||||
void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool wantRyzomRestart, bool useBatchFile)
|
||||
{
|
||||
|
||||
uint nblab = 0;
|
||||
|
||||
FILE *fp = NULL;
|
||||
|
@ -753,7 +760,14 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
string err = toString("Can't open file '%s' for writing: code=%d %s (error code 29)", UpdateBatchFilename.c_str(), errno, strerror(errno));
|
||||
throw Exception (err);
|
||||
}
|
||||
fprintf(fp, "@echo off\n");
|
||||
//use bat if windows if not use sh
|
||||
#ifdef NL_OS_WINDOWS
|
||||
fprintf(fp, "@echo off\n");
|
||||
#else NL_OS_MAC
|
||||
//mac patcher doesn't work yet
|
||||
#else
|
||||
fprintf(fp, "#!/bin/sh\npwd\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
// Unpack files with category ExtractPath non empty
|
||||
|
@ -808,8 +822,15 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
|
||||
if (useBatchFile)
|
||||
{
|
||||
SrcPath = CPath::standardizeDosPath(SrcPath);
|
||||
DstPath = CPath::standardizeDosPath(DstPath);
|
||||
#ifdef NL_OS_WINDOWS
|
||||
SrcPath = CPath::standardizeDosPath(SrcPath);
|
||||
DstPath = CPath::standardizeDosPath(DstPath);
|
||||
#elseif NL_OS_MAC
|
||||
//no patcher on mac yet
|
||||
#else
|
||||
SrcPath = CPath::standardizePath(SrcPath);
|
||||
DstPath = CPath::standardizePath(DstPath);
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string SrcName = SrcPath + vFilenames[fff];
|
||||
|
@ -817,11 +838,21 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
|
||||
if (useBatchFile)
|
||||
{
|
||||
fprintf(fp, ":loop%u\n", nblab);
|
||||
fprintf(fp, "attrib -r -a -s -h %s\n", DstName.c_str());
|
||||
fprintf(fp, "del %s\n", DstName.c_str());
|
||||
fprintf(fp, "if exist %s goto loop%u\n", DstName.c_str(), nblab);
|
||||
fprintf(fp, "move %s %s\n", SrcName.c_str(), DstPath.c_str());
|
||||
//write windows .bat format else write sh format
|
||||
#ifdef NL_OS_WINDOWS
|
||||
fprintf(fp, ":loop%u\n", nblab);
|
||||
fprintf(fp, "attrib -r -a -s -h %s\n", DstName.c_str());
|
||||
fprintf(fp, "del %s\n", DstName.c_str());
|
||||
fprintf(fp, "if exist %s goto loop%u\n", DstName.c_str(), nblab);
|
||||
fprintf(fp, "move %s %s\n", SrcName.c_str(), DstPath.c_str());
|
||||
#elseif NL_OS_MAC
|
||||
//no patcher on osx
|
||||
#else
|
||||
fprintf(fp, "chmod 777 %s\n", DstName.c_str());
|
||||
fprintf(fp, "rm -rf %s\n", DstName.c_str());
|
||||
fprintf(fp, "mv %s %s\n", SrcName.c_str(), DstPath.c_str());
|
||||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -838,10 +869,12 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
// Finalize batch file
|
||||
if (NLMISC::CFile::isExists("patch") && NLMISC::CFile::isDirectory("patch"))
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
if (useBatchFile)
|
||||
{
|
||||
fprintf(fp, ":looppatch\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<string> vFileList;
|
||||
CPath::getPathContent ("patch", false, false, true, vFileList, NULL, false);
|
||||
|
@ -849,7 +882,13 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
{
|
||||
if (useBatchFile)
|
||||
{
|
||||
fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str());
|
||||
#ifdef NL_OS_WINDOWS
|
||||
fprintf(fp, "del %s\n", CPath::standardizeDosPath(vFileList[i]).c_str());
|
||||
#elseif NL_OS_MAC
|
||||
//no patcher on MAC yet
|
||||
#else
|
||||
fprintf(fp, "rm -f %s\n", CPath::standardizePath(vFileList[i]).c_str());
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -859,8 +898,14 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
|
||||
if (useBatchFile)
|
||||
{
|
||||
fprintf(fp, "rd /Q /S patch\n");
|
||||
fprintf(fp, "if exist patch goto looppatch\n");
|
||||
#ifdef NL_OS_WINDOWS
|
||||
fprintf(fp, "rd /Q /S patch\n");
|
||||
fprintf(fp, "if exist patch goto looppatch\n");
|
||||
#elseif NL_OS_MAC
|
||||
//no patcher on mac yet
|
||||
#else
|
||||
fprintf(fp, "rm -rf patch\n");
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -872,7 +917,11 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
{
|
||||
if (wantRyzomRestart)
|
||||
{
|
||||
#ifdef NL_OS_WINDOWS
|
||||
fprintf(fp, "start %s %%1 %%2 %%3\n", RyzomFilename.c_str());
|
||||
#else
|
||||
fprintf(fp, "/opt/tita/%s $1 $2 $3\n", RyzomFilename.c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool writeError = ferror(fp) != 0;
|
||||
|
@ -887,6 +936,7 @@ void CPatchManager::createBatchFile(CProductDescriptionForClient &descFile, bool
|
|||
throw NLMISC::EWriteError(UpdateBatchFilename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ****************************************************************************
|
||||
|
@ -944,7 +994,36 @@ void CPatchManager::executeBatchFile()
|
|||
// CloseHandle( pi.hThread );
|
||||
|
||||
#else
|
||||
// TODO for Linux and Mac OS
|
||||
// Start the child process.
|
||||
bool r2Mode = false;
|
||||
#ifndef RY_BG_DOWNLOADER
|
||||
r2Mode = ClientCfg.R2Mode;
|
||||
#endif
|
||||
string strCmdLine;
|
||||
|
||||
strCmdLine = "./" + UpdateBatchFilename;
|
||||
|
||||
chmod(strCmdLine.c_str(), S_IRWXU);
|
||||
if (r2Mode)
|
||||
{
|
||||
if (execl(strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str()) == -1)
|
||||
{
|
||||
int errsv = errno;
|
||||
nlerror("Execl Error: %d %s", errsv, strCmdLine.c_str(), (char *) NULL);
|
||||
} else {
|
||||
nlinfo("Ran batch file r2Mode Success");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (execl(strCmdLine.c_str(), LoginLogin.c_str(), LoginPassword.c_str(), LoginShardId, (char *) NULL) == -1)
|
||||
{
|
||||
int errsv = errno;
|
||||
nlerror("Execl r2mode Error: %d %s", errsv, strCmdLine.c_str());
|
||||
} else {
|
||||
nlinfo("Ran batch file Success");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// exit(0);
|
||||
|
|
|
@ -323,6 +323,8 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
|||
|
||||
for (uint32 i=packageIndex.fileCount();i--;)
|
||||
{
|
||||
bool deleteRefAfterDelta= true;
|
||||
bool usingTemporaryFile = false;
|
||||
// generate file name root
|
||||
std::string bnpFileName= _BnpDirectory+packageIndex.getFile(i).getFileName();
|
||||
std::string refNameRoot= _RefDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||
|
@ -345,6 +347,8 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
|||
prevVersionFileName= _RootDirectory + "empty";
|
||||
NLMISC::COFile tmpFile(prevVersionFileName);
|
||||
tmpFile.close();
|
||||
usingTemporaryFile = true;
|
||||
deleteRefAfterDelta= false;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue