|
|
|
@ -110,7 +110,7 @@ void setVersion(const std::string &version)
|
|
|
|
|
if(VerboseLog) nlinfo("setVersion to '%s'", version.c_str());
|
|
|
|
|
|
|
|
|
|
string fn = "VERSION";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setRWAccess(fn);
|
|
|
|
|
FILE *fp = fopen (fn.c_str(), "wb");
|
|
|
|
|
if (fp == NULL)
|
|
|
|
@ -157,16 +157,16 @@ int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow);
|
|
|
|
|
class CPatchThread : public IRunnable
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CPatchThread(const string &sp, const string &sv, const std::string &urlOk, const std::string &urlFailed, const std::string &logSeparator) :
|
|
|
|
|
ServerPath (sp), ServerVersion(sv), UrlOk(urlOk), UrlFailed(urlFailed), Ended(false), StateChanged(true), LogSeparator(logSeparator)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool Ended; // true if the thread have ended the patch
|
|
|
|
|
bool PatchOk; // true if the patch was good
|
|
|
|
|
string Url; // url to display after the patch
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string State;
|
|
|
|
|
string StateLog;
|
|
|
|
|
bool StateChanged;
|
|
|
|
@ -177,7 +177,7 @@ private:
|
|
|
|
|
string ClientPatchPath; // the patch path (c:\ryzom\patch)
|
|
|
|
|
string ServerRootPath; // the root server path (http://www.toto.com)
|
|
|
|
|
string DisplayedServerRootPath; // contains the serverpath without login and password
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get a file and decompress it in the patch directory
|
|
|
|
|
void getFile (const CEntry &e)
|
|
|
|
|
{
|
|
|
|
@ -207,7 +207,7 @@ private:
|
|
|
|
|
ClientPatchPath = "./patch/";
|
|
|
|
|
ServerRootPath = CPath::standardizePath (ServerPath)+ServerVersion+"/";
|
|
|
|
|
DisplayedServerRootPath; // contains the serverpath without login and password
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint pos = ServerRootPath.find ("@");
|
|
|
|
|
if (pos != string::npos)
|
|
|
|
|
{
|
|
|
|
@ -269,7 +269,7 @@ private:
|
|
|
|
|
const char *gzerr = gzerror (gz, &gzerrno);
|
|
|
|
|
throw Exception ("Can't read '%s' : code=%d %s (error code 27)", DirFilename.c_str(), gzerrno, gzerr);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string b = buffer;
|
|
|
|
|
uint pos1 = b.find ("/");
|
|
|
|
|
uint pos2 = b.find ("/", pos1+1);
|
|
|
|
@ -309,7 +309,7 @@ private:
|
|
|
|
|
// nel_launcher.exe and relaunch it now
|
|
|
|
|
|
|
|
|
|
bool patchExe = false, patchCfg = false, patchBat = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint i;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < needToGetFilesList.size(); i++)
|
|
|
|
@ -336,42 +336,42 @@ private:
|
|
|
|
|
if (patchBat)
|
|
|
|
|
{
|
|
|
|
|
setState (true, true, "Launching %s", RelaunchNelLauncherBatchFilename.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1)
|
|
|
|
|
STARTUPINFO si;
|
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZeroMemory( &si, sizeof(si) );
|
|
|
|
|
// Flag permettant de prendre en compte wShowWindow
|
|
|
|
|
si.dwFlags = STARTF_USESHOWWINDOW;
|
|
|
|
|
si.wShowWindow = SW_HIDE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZeroMemory( &pi, sizeof(pi) );
|
|
|
|
|
|
|
|
|
|
// Start the child process.
|
|
|
|
|
if( !CreateProcess( NULL, // No module name (use command line).
|
|
|
|
|
(char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line.
|
|
|
|
|
NULL, // Process handle not inheritable.
|
|
|
|
|
NULL, // Thread handle not inheritable.
|
|
|
|
|
FALSE, // Set handle inheritance to FALSE.
|
|
|
|
|
0, // No creation flags.
|
|
|
|
|
NULL, // Use parent's environment block.
|
|
|
|
|
NULL, // Use parent's starting directory.
|
|
|
|
|
|
|
|
|
|
// Start the child process.
|
|
|
|
|
if( !CreateProcess( NULL, // No module name (use command line).
|
|
|
|
|
(char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line.
|
|
|
|
|
NULL, // Process handle not inheritable.
|
|
|
|
|
NULL, // Thread handle not inheritable.
|
|
|
|
|
FALSE, // Set handle inheritance to FALSE.
|
|
|
|
|
0, // No creation flags.
|
|
|
|
|
NULL, // Use parent's environment block.
|
|
|
|
|
NULL, // Use parent's starting directory.
|
|
|
|
|
&si, // Pointer to STARTUPINFO structure.
|
|
|
|
|
&pi ) // Pointer to PROCESS_INFORMATION structure.
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// error occurs during the launch
|
|
|
|
|
string str = toString("Can't execute '%s': code=%d %s (error code 28)", RelaunchNelLauncherBatchFilename.c_str(), errno, strerror(errno));
|
|
|
|
|
throw Exception (str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Close process and thread handles.
|
|
|
|
|
|
|
|
|
|
// Close process and thread handles.
|
|
|
|
|
CloseHandle( pi.hProcess );
|
|
|
|
|
CloseHandle( pi.hThread );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
else if (patchExe || patchCfg)
|
|
|
|
@ -384,7 +384,7 @@ private:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(fp, "@echo off\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (patchExe)
|
|
|
|
|
{
|
|
|
|
|
nlinfo ("Need to special patch '%s'",NelLauncherFilename.c_str());
|
|
|
|
@ -408,52 +408,52 @@ private:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(fp, "start %s\n", NelLauncherFilename.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
|
|
|
|
|
// remove the files list file
|
|
|
|
|
setState (true, true, "Deleting %s", DirFilename.c_str());
|
|
|
|
|
string err = deleteFile (DirFilename, false);
|
|
|
|
|
if (!err.empty()) setState(true, true, err.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// launching the .bat
|
|
|
|
|
setState (true, true, "Launching %s", UpdateNelLauncherBatchFilename.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1)
|
|
|
|
|
STARTUPINFO si;
|
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZeroMemory( &si, sizeof(si) );
|
|
|
|
|
// Flag permettant de prendre en compte wShowWindow
|
|
|
|
|
si.dwFlags = STARTF_USESHOWWINDOW;
|
|
|
|
|
si.wShowWindow = SW_HIDE;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
si.cb = sizeof(si);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ZeroMemory( &pi, sizeof(pi) );
|
|
|
|
|
|
|
|
|
|
// Start the child process.
|
|
|
|
|
if( !CreateProcess( NULL, // No module name (use command line).
|
|
|
|
|
(char*)UpdateNelLauncherBatchFilename.c_str(), // Command line.
|
|
|
|
|
NULL, // Process handle not inheritable.
|
|
|
|
|
NULL, // Thread handle not inheritable.
|
|
|
|
|
FALSE, // Set handle inheritance to FALSE.
|
|
|
|
|
0, // No creation flags.
|
|
|
|
|
NULL, // Use parent's environment block.
|
|
|
|
|
NULL, // Use parent's starting directory.
|
|
|
|
|
|
|
|
|
|
// Start the child process.
|
|
|
|
|
if( !CreateProcess( NULL, // No module name (use command line).
|
|
|
|
|
(char*)UpdateNelLauncherBatchFilename.c_str(), // Command line.
|
|
|
|
|
NULL, // Process handle not inheritable.
|
|
|
|
|
NULL, // Thread handle not inheritable.
|
|
|
|
|
FALSE, // Set handle inheritance to FALSE.
|
|
|
|
|
0, // No creation flags.
|
|
|
|
|
NULL, // Use parent's environment block.
|
|
|
|
|
NULL, // Use parent's starting directory.
|
|
|
|
|
&si, // Pointer to STARTUPINFO structure.
|
|
|
|
|
&pi ) // Pointer to PROCESS_INFORMATION structure.
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
// error occurs during the launch
|
|
|
|
|
string str = toString("Can't execute '%s': code=%d %s (error code 30)", UpdateNelLauncherBatchFilename.c_str(), errno, strerror(errno));
|
|
|
|
|
throw Exception (str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Close process and thread handles.
|
|
|
|
|
|
|
|
|
|
// Close process and thread handles.
|
|
|
|
|
CloseHandle( pi.hProcess );
|
|
|
|
|
CloseHandle( pi.hThread );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
quit();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -471,12 +471,12 @@ private:
|
|
|
|
|
{
|
|
|
|
|
executeFinalizeBat = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// put the file in the ryzom patch directory
|
|
|
|
|
string path = ClientPatchPath + needToGetFilesList[i].Filename;
|
|
|
|
|
|
|
|
|
|
//nldebug ("path '%s' -> %d %s", path.c_str(), NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename), strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)).c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// move dll exe and already existing file in the root directory
|
|
|
|
|
if (NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename) ||
|
|
|
|
|
strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)) == "dll" ||
|
|
|
|
@ -500,7 +500,7 @@ private:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// now, we have to delete files that are not in the server list
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setState(true, true, "Scanning patch directory");
|
|
|
|
|
vector<string> res;
|
|
|
|
|
CPath::getPathContent(ClientPatchPath, false, false, true, res);
|
|
|
|
@ -541,10 +541,10 @@ private:
|
|
|
|
|
setState (true, true, "Launching %s", fn.c_str());
|
|
|
|
|
system(fn.c_str());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// it s the end of the patch process
|
|
|
|
|
setState (true, true, "Patching completed");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Url = UrlOk;
|
|
|
|
|
PatchOk = true;
|
|
|
|
|
Ended = true;
|
|
|
|
@ -590,12 +590,12 @@ private:
|
|
|
|
|
if (fp == NULL)
|
|
|
|
|
{
|
|
|
|
|
string err = toString("Can't open file '%s' : code=%d %s, (error code 32)", dest.c_str(), errno, strerror(errno));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gzclose(gz);
|
|
|
|
|
deleteFile (filename);
|
|
|
|
|
throw Exception (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(VerboseLog) nlinfo("Entering the while loop decompression");
|
|
|
|
|
|
|
|
|
|
uint32 currentSize = 0;
|
|
|
|
@ -656,7 +656,7 @@ private:
|
|
|
|
|
}
|
|
|
|
|
if(VerboseLog) nlinfo("Exiting the decompressing file");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void downloadFileWithCurl (const string &source, const string &dest)
|
|
|
|
|
{
|
|
|
|
|
#ifdef USE_CURL
|
|
|
|
@ -723,7 +723,7 @@ private:
|
|
|
|
|
// file not found, delete it
|
|
|
|
|
NLMISC::CFile::deleteFile(dest.c_str());
|
|
|
|
|
throw Exception ("curl download failed: (ec %d %d)", res, r);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
throw Exception("USE_CURL is not defined, no curl method");
|
|
|
|
|
#endif
|
|
|
|
@ -747,7 +747,7 @@ private:
|
|
|
|
|
uint8 buffer[bufferSize];
|
|
|
|
|
|
|
|
|
|
if(VerboseLog) nlinfo("downloadFile '%s'", dest.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (RootInternet == NULL)
|
|
|
|
|
{
|
|
|
|
|
RootInternet = InternetOpen("nel_launcher", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
|
|
|
|
@ -768,7 +768,7 @@ private:
|
|
|
|
|
{
|
|
|
|
|
errorstr = "FormatMessage can't get the message";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Exception ("InternetOpen() failed: %s (ec %d) (error code 35)", errorstr.c_str(), errcode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -826,7 +826,7 @@ private:
|
|
|
|
|
{
|
|
|
|
|
errorstr = "FormatMessage can't get the message";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fclose(fp);
|
|
|
|
|
deleteFile (dest);
|
|
|
|
|
|
|
|
|
@ -849,7 +849,7 @@ private:
|
|
|
|
|
deleteFile (dest);
|
|
|
|
|
throw Exception (err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CurrentBytesToGet += realSize;
|
|
|
|
|
|
|
|
|
|
if (TotalBytesToGet == 0 && TotalFilesToGet == 0)
|
|
|
|
@ -878,7 +878,7 @@ private:
|
|
|
|
|
{
|
|
|
|
|
errorstr = "FormatMessage can't get the message";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d) (error code 40)", source.c_str (), errorstr.c_str(), errcode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -892,7 +892,7 @@ private:
|
|
|
|
|
nlinfo (str);
|
|
|
|
|
State = str;
|
|
|
|
|
if(log)
|
|
|
|
|
{
|
|
|
|
|
{
|
|
|
|
|
StateLog += str;
|
|
|
|
|
StateLog += LogSeparator;
|
|
|
|
|
}
|
|
|
|
@ -907,7 +907,7 @@ private:
|
|
|
|
|
string UrlOk;
|
|
|
|
|
string UrlFailed;
|
|
|
|
|
|
|
|
|
|
friend int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow);
|
|
|
|
|
friend int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
uint TotalFilesToGet;
|
|
|
|
@ -917,7 +917,7 @@ public:
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
CPatchThread *PatchThread = NULL;
|
|
|
|
|
IThread *thread = NULL;
|
|
|
|
|
CThread *thread = NULL;
|
|
|
|
|
|
|
|
|
|
int myProgressFunc(void *foo, double t, double d, double ultotal, double ulnow)
|
|
|
|
|
{
|
|
|
|
@ -936,11 +936,11 @@ void startPatchThread (const std::string &serverPath, const std::string &serverV
|
|
|
|
|
nlwarning ("patch thread already running");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator);
|
|
|
|
|
nlassert (PatchThread != NULL);
|
|
|
|
|
|
|
|
|
|
thread = IThread::create (PatchThread);
|
|
|
|
|
thread = CThread::create (PatchThread);
|
|
|
|
|
nlassert (thread != NULL);
|
|
|
|
|
thread->start ();
|
|
|
|
|
}
|
|
|
|
|