SDL2: Compile fix

--HG--
branch : sdl2
hg/feature/sdl2
kaetemi 11 years ago
parent ff1059f735
commit 23cbacc0c9

@ -69,7 +69,7 @@ public:
} }
}; };
/// Thread priorities, numbering follows Win32 for now /// Thread priorities
enum TThreadPriority enum TThreadPriority
{ {
ThreadPriorityLow, ThreadPriorityLow,

@ -180,7 +180,7 @@ public:
for (i=0; i<NumThreads; ++i) for (i=0; i<NumThreads; ++i)
{ {
IRunnable *runnable = (IRunnable *)(new CPinger()); IRunnable *runnable = (IRunnable *)(new CPinger());
IThread *thread = IThread::create(runnable); CThread *thread = CThread::create(runnable);
thread->start(); thread->start();
} }
} }

@ -140,7 +140,7 @@ CBufFIFO *CurrentReadQueue = NULL;
TReceivedMessage *CurrentInMsg = NULL; TReceivedMessage *CurrentInMsg = NULL;
IThread *ReceiveThread = NULL; CThread *ReceiveThread = NULL;
CReceiveTask *ReceiveTask = NULL; CReceiveTask *ReceiveTask = NULL;
list<CClient> Clients; // contains all clients list<CClient> Clients; // contains all clients
@ -259,7 +259,7 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u
// increase only for new pong // increase only for new pong
NbPong++; NbPong++;
MeanPongTime += (uint32)(pongTime-pingTime); MeanPongTime += (uint32)(pongTime-pingTime);
FullNbPong++; FullNbPong++;
FullMeanPongTime += (uint32)(pongTime-pingTime); FullMeanPongTime += (uint32)(pongTime-pingTime);
@ -276,7 +276,7 @@ void CClient::updatePong (sint64 pingTime, sint64 pongTime, uint32 pongNumber, u
ha = Address.ipAddress(); ha = Address.ipAddress();
} }
string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".pong"; string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".pong";
FILE *fp = fopen (fn.c_str(), "rt"); FILE *fp = fopen (fn.c_str(), "rt");
if (fp == NULL) if (fp == NULL)
{ {
@ -318,7 +318,7 @@ void CClient::updateFullStat ()
for (uint i = 0; i < LastPongReceived; i++) for (uint i = 0; i < LastPongReceived; i++)
{ {
if (PongReceived[i].first == 0) NbLost++; if (PongReceived[i].first == 0) NbLost++;
else else
{ {
NbPong++; NbPong++;
NbDup += PongReceived[i].first - 1; NbDup += PongReceived[i].first - 1;
@ -333,7 +333,7 @@ void CClient::updateFullStat ()
ha = Address.ipAddress(); ha = Address.ipAddress();
} }
string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".stat"; string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".stat";
string line = "Full Summary: "; string line = "Full Summary: ";
line += "NbPing " + toString(LastPongReceived) + " "; line += "NbPing " + toString(LastPongReceived) + " ";
line += "NbPong " + toString(NbPong) + " "; line += "NbPong " + toString(NbPong) + " ";
@ -375,7 +375,7 @@ void CClient::updateFullStat ()
ha = Address.ipAddress(); ha = Address.ipAddress();
} }
string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".ping"; string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".ping";
FILE *fp = fopen (fn.c_str(), "rt"); FILE *fp = fopen (fn.c_str(), "rt");
if (fp == NULL) if (fp == NULL)
{ {
@ -432,7 +432,7 @@ void CClient::updateStat ()
ha = Address.ipAddress(); ha = Address.ipAddress();
} }
string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".stat"; string fn = StatPathName + ConnectionName + "_" + ha + "_" + getDate() + ".stat";
string line; string line;
line += "NbPing " + toString(NbPing) + " "; line += "NbPing " + toString(NbPing) + " ";
line += "NbPong " + toString(NbPong) + " "; line += "NbPong " + toString(NbPong) + " ";
@ -455,7 +455,7 @@ void CClient::updateStat ()
fprintf (fp, "HostAddress: %s\n", Address.asString().c_str()); fprintf (fp, "HostAddress: %s\n", Address.asString().c_str());
FirstWrite = false; FirstWrite = false;
} }
fprintf (fp, "%s\n", line.c_str()); fprintf (fp, "%s\n", line.c_str());
fclose (fp); fclose (fp);
} }
@ -535,7 +535,7 @@ void handleReceivedPong (CClient *client, sint64 pongTime)
uint32 session = 0; uint32 session = 0;
msgin.serial (session); msgin.serial (session);
// Find a new udp connection, find the linked // Find a new udp connection, find the linked
list<CClient>::iterator it; list<CClient>::iterator it;
for (it = Clients.begin(); it != Clients.end(); it++) for (it = Clients.begin(); it != Clients.end(); it++)
{ {
@ -630,7 +630,7 @@ void sendPing ()
class CBenchService : public IService class CBenchService : public IService
{ {
public: public:
void init() void init()
{ {
nlassert( ReceiveTask==NULL && ReceiveThread==NULL ); nlassert( ReceiveTask==NULL && ReceiveThread==NULL );
@ -649,7 +649,7 @@ public:
CurrentReadQueue = &Queue2; CurrentReadQueue = &Queue2;
ReceiveTask->setWriteQueue( &Queue1 ); ReceiveTask->setWriteQueue( &Queue1 );
nlassert( ReceiveTask != NULL ); nlassert( ReceiveTask != NULL );
ReceiveThread = IThread::create( ReceiveTask ); ReceiveThread = CThread::create( ReceiveTask );
nlassert( ReceiveThread != NULL ); nlassert( ReceiveThread != NULL );
ReceiveThread->start(); ReceiveThread->start();
@ -704,7 +704,7 @@ public:
// Handle the UDP message // Handle the UDP message
// Retrieve client info or add one // Retrieve client info or add one
TClientMap::iterator ihm = ClientMap.find( CurrentInMsg->AddrFrom ); TClientMap::iterator ihm = ClientMap.find( CurrentInMsg->AddrFrom );
if ( ihm == ClientMap.end() ) if ( ihm == ClientMap.end() )
{ {
@ -757,7 +757,7 @@ public:
delete ReceiveThread; delete ReceiveThread;
ReceiveThread = NULL; ReceiveThread = NULL;
} }
if (ReceiveTask != NULL) if (ReceiveTask != NULL)
{ {
delete ReceiveTask; delete ReceiveTask;
@ -779,5 +779,5 @@ public:
} }
}; };
NLNET_SERVICE_MAIN (CBenchService, "BS", "bench_service", 45459, EmptyCallbackArray, UDP_DIR, "") NLNET_SERVICE_MAIN (CBenchService, "BS", "bench_service", 45459, EmptyCallbackArray, UDP_DIR, "")

@ -151,7 +151,7 @@ public:
void tasksAndThreads() void tasksAndThreads()
{ {
// test running task in two separate thread (this stress the // test running task in two separate thread (this stress the
// multithreading support of task). CoTask API ;ake use of // multithreading support of task). CoTask API ;ake use of
// thread local storage API to store by thread current task info. // thread local storage API to store by thread current task info.
@ -159,7 +159,7 @@ public:
result2.clear(); result2.clear();
CTaskThread tt; CTaskThread tt;
NLMISC::IThread *th = NLMISC::IThread::create(&tt); NLMISC::CThread *th = NLMISC::CThread::create(&tt);
CTask2 t2; CTask2 t2;
@ -196,7 +196,7 @@ public:
TEST_ASSERT(referenceResultThread2[i] == result[i]); TEST_ASSERT(referenceResultThread2[i] == result[i]);
} }
} }
void runTasks() void runTasks()
{ {
/// Run two main task and two working task at once and check that the result /// Run two main task and two working task at once and check that the result

@ -63,7 +63,7 @@ string deleteFile (const string &filename, bool throwException=true)
void setVersion(const std::string &version) void setVersion(const std::string &version)
{ {
string fn = "VERSION"; string fn = "VERSION";
setRWAccess(fn); setRWAccess(fn);
FILE *fp = fopen (fn.c_str(), "wb"); FILE *fp = fopen (fn.c_str(), "wb");
if (fp == NULL) if (fp == NULL)
@ -105,16 +105,16 @@ string getVersion()
class CPatchThread : public IRunnable class CPatchThread : public IRunnable
{ {
public: public:
CPatchThread(const string &sp, const string &sv, const std::string &urlOk, const std::string &urlFailed, const std::string &logSeparator) : 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) 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 Ended; // true if the thread have ended the patch
bool PatchOk; // true if the patch was good bool PatchOk; // true if the patch was good
string Url; // url to display after the patch string Url; // url to display after the patch
string State; string State;
string StateLog; string StateLog;
bool StateChanged; bool StateChanged;
@ -136,7 +136,7 @@ private:
string ClientPatchPath = "./patch/"; string ClientPatchPath = "./patch/";
string ServerRootPath = CPath::standardizePath (ServerPath); string ServerRootPath = CPath::standardizePath (ServerPath);
string DisplayedServerRootPath; // contains the serverpath without login and password string DisplayedServerRootPath; // contains the serverpath without login and password
uint pos = ServerRootPath.find ("@"); uint pos = ServerRootPath.find ("@");
if (pos != string::npos) if (pos != string::npos)
{ {
@ -198,7 +198,7 @@ private:
const char *gzerr = gzerror (gz, &gzerrno); const char *gzerr = gzerror (gz, &gzerrno);
throw Exception ("Can't read '%s' : code=%d %s", DirFilename.c_str(), gzerrno, gzerr); throw Exception ("Can't read '%s' : code=%d %s", DirFilename.c_str(), gzerrno, gzerr);
} }
string b = buffer; string b = buffer;
uint pos1 = b.find ("/"); uint pos1 = b.find ("/");
uint pos2 = b.find ("/", pos1+1); uint pos2 = b.find ("/", pos1+1);
@ -238,9 +238,9 @@ private:
string path = ClientPatchPath + needToGetFilesList[i].Filename; string path = ClientPatchPath + needToGetFilesList[i].Filename;
nlinfo ("Get the file from '%s' to '%s'", string(DisplayedServerRootPath+needToGetFilesList[i].Filename).c_str(), path.c_str()); nlinfo ("Get the file from '%s' to '%s'", string(DisplayedServerRootPath+needToGetFilesList[i].Filename).c_str(), path.c_str());
// get the new file // get the new file
downloadFile (ServerRootPath+needToGetFilesList[i].Filename+".ngz", path+".ngz"); downloadFile (ServerRootPath+needToGetFilesList[i].Filename+".ngz", path+".ngz");
// decompress it // decompress it
decompressFile (path+".ngz", needToGetFilesList[i].Date); decompressFile (path+".ngz", needToGetFilesList[i].Date);
@ -280,7 +280,7 @@ private:
// special case for nel_launcher.exe // special case for nel_launcher.exe
if (needToGetFilesList[i].Filename == "nel_launcher.exe") if (needToGetFilesList[i].Filename == "nel_launcher.exe")
continue; continue;
string path = ClientRootPath+needToGetFilesList[i].Filename; string path = ClientRootPath+needToGetFilesList[i].Filename;
if (!NLMISC::CFile::fileExists (path)) if (!NLMISC::CFile::fileExists (path))
{ {
@ -308,7 +308,7 @@ private:
} }
// now, we have to delete files that are not in the server list // now, we have to delete files that are not in the server list
setState(true, "Scanning patch directory"); setState(true, "Scanning patch directory");
vector<string> res; vector<string> res;
CPath::getPathContent(ClientPatchPath, false, false, true, res); CPath::getPathContent(ClientPatchPath, false, false, true, res);
@ -337,11 +337,11 @@ private:
setState (true, "Deleting %s", DirFilename.c_str()); setState (true, "Deleting %s", DirFilename.c_str());
string err = deleteFile (DirFilename, false); string err = deleteFile (DirFilename, false);
if (!err.empty()) setState(true, err.c_str()); if (!err.empty()) setState(true, err.c_str());
// now that all is ok, we set the new client version // now that all is ok, we set the new client version
setState (true, "set client version to %s", ServerVersion.c_str ()); setState (true, "set client version to %s", ServerVersion.c_str ());
setVersion (ServerVersion); setVersion (ServerVersion);
if (needToExecuteAPatch) if (needToExecuteAPatch)
{ {
setState (true, "Launching patch_execute.bat"); setState (true, "Launching patch_execute.bat");
@ -358,7 +358,7 @@ private:
nlinfo ("Patching completed"); nlinfo ("Patching completed");
setState (true, "Patching completed"); setState (true, "Patching completed");
Url = UrlOk; Url = UrlOk;
PatchOk = true; PatchOk = true;
Ended = true; Ended = true;
@ -401,12 +401,12 @@ private:
if (fp == NULL) if (fp == NULL)
{ {
string err = toString("Can't open file '%s' : code=%d %s", dest.c_str(), errno, strerror(errno)); string err = toString("Can't open file '%s' : code=%d %s", dest.c_str(), errno, strerror(errno));
gzclose(gz); gzclose(gz);
deleteFile (filename); deleteFile (filename);
throw Exception (err); throw Exception (err);
} }
uint8 buffer[10000]; uint8 buffer[10000];
while (!gzeof(gz)) while (!gzeof(gz))
{ {
@ -473,7 +473,7 @@ private:
errorstr = (LPCTSTR)lpMsgBuf; errorstr = (LPCTSTR)lpMsgBuf;
} }
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
throw Exception ("InternetOpen() failed: %s (ec %d)", errorstr.c_str(), errcode); throw Exception ("InternetOpen() failed: %s (ec %d)", errorstr.c_str(), errcode);
} }
} }
@ -523,7 +523,7 @@ private:
errorstr = (LPCTSTR)lpMsgBuf; errorstr = (LPCTSTR)lpMsgBuf;
} }
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
throw Exception ("InternetOpenUrl() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); throw Exception ("InternetOpenUrl() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode);
} }
else else
@ -543,7 +543,7 @@ private:
deleteFile (dest); deleteFile (dest);
throw Exception (err); throw Exception (err);
} }
CurrentBytesToGet += realSize; CurrentBytesToGet += realSize;
if (TotalBytesToGet == 0 && TotalFilesToGet == 0) if (TotalBytesToGet == 0 && TotalFilesToGet == 0)
@ -568,7 +568,7 @@ private:
errorstr = (LPCTSTR)lpMsgBuf; errorstr = (LPCTSTR)lpMsgBuf;
} }
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode);
} }
} }
@ -611,11 +611,11 @@ void startPatchThread (const std::string &serverPath, const std::string &serverV
nlwarning ("patch thread already running"); nlwarning ("patch thread already running");
return; return;
} }
PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator); PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator);
nlassert (PatchThread != NULL); nlassert (PatchThread != NULL);
IThread *thread = IThread::create (PatchThread); CThread *thread = CThread::create (PatchThread);
nlassert (thread != NULL); nlassert (thread != NULL);
thread->start (); thread->start ();
} }

@ -96,7 +96,7 @@ string deleteFile (const string &filename, bool throwException=true)
void setVersion(const std::string &version) void setVersion(const std::string &version)
{ {
string fn = "VERSION"; string fn = "VERSION";
setRWAccess(fn); setRWAccess(fn);
FILE *fp = fopen (fn.c_str(), "wb"); FILE *fp = fopen (fn.c_str(), "wb");
if (fp == NULL) if (fp == NULL)
@ -138,16 +138,16 @@ string getVersion()
class CPatchThread : public IRunnable class CPatchThread : public IRunnable
{ {
public: public:
CPatchThread(const string &sp, const string &sv, const std::string &urlOk, const std::string &urlFailed, const std::string &logSeparator) : 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) 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 Ended; // true if the thread have ended the patch
bool PatchOk; // true if the patch was good bool PatchOk; // true if the patch was good
string Url; // url to display after the patch string Url; // url to display after the patch
string State; string State;
string StateLog; string StateLog;
bool StateChanged; bool StateChanged;
@ -158,7 +158,7 @@ private:
string ClientPatchPath; // the patch path (c:\ryzom\patch) string ClientPatchPath; // the patch path (c:\ryzom\patch)
string ServerRootPath; // the root server path (http://www.toto.com) string ServerRootPath; // the root server path (http://www.toto.com)
string DisplayedServerRootPath; // contains the serverpath without login and password string DisplayedServerRootPath; // contains the serverpath without login and password
// get a file and decompress it in the patch directory // get a file and decompress it in the patch directory
void getFile (const CEntry &e) void getFile (const CEntry &e)
{ {
@ -186,7 +186,7 @@ private:
ClientPatchPath = "./patch/"; ClientPatchPath = "./patch/";
ServerRootPath = CPath::standardizePath (ServerPath); ServerRootPath = CPath::standardizePath (ServerPath);
DisplayedServerRootPath; // contains the serverpath without login and password DisplayedServerRootPath; // contains the serverpath without login and password
uint pos = ServerRootPath.find ("@"); uint pos = ServerRootPath.find ("@");
if (pos != string::npos) if (pos != string::npos)
{ {
@ -248,7 +248,7 @@ private:
const char *gzerr = gzerror (gz, &gzerrno); const char *gzerr = gzerror (gz, &gzerrno);
throw Exception ("Can't read '%s' : code=%d %s", DirFilename.c_str(), gzerrno, gzerr); throw Exception ("Can't read '%s' : code=%d %s", DirFilename.c_str(), gzerrno, gzerr);
} }
string b = buffer; string b = buffer;
uint pos1 = b.find ("/"); uint pos1 = b.find ("/");
uint pos2 = b.find ("/", pos1+1); uint pos2 = b.find ("/", pos1+1);
@ -280,7 +280,7 @@ private:
// nel_launcher.exe and relaunch it now // nel_launcher.exe and relaunch it now
bool patchExe = false, patchCfg = false, patchBat = false; bool patchExe = false, patchCfg = false, patchBat = false;
uint i; uint i;
for (i = 0; i < needToGetFilesList.size(); i++) for (i = 0; i < needToGetFilesList.size(); i++)
@ -307,42 +307,42 @@ private:
if (patchBat) if (patchBat)
{ {
setState (true, true, "Launching %s", RelaunchNelLauncherBatchFilename.c_str()); setState (true, true, "Launching %s", RelaunchNelLauncherBatchFilename.c_str());
//if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1) //if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1)
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) ); ZeroMemory( &si, sizeof(si) );
// Flag permettant de prendre en compte wShowWindow // Flag permettant de prendre en compte wShowWindow
si.dwFlags = STARTF_USESHOWWINDOW; si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE; si.wShowWindow = SW_HIDE;
si.cb = sizeof(si); si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) ); ZeroMemory( &pi, sizeof(pi) );
// Start the child process. // Start the child process.
if( !CreateProcess( NULL, // No module name (use command line). if( !CreateProcess( NULL, // No module name (use command line).
(char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line. (char*)RelaunchNelLauncherBatchFilename.c_str(), // Command line.
NULL, // Process handle not inheritable. NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable. NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE. FALSE, // Set handle inheritance to FALSE.
0, // No creation flags. 0, // No creation flags.
NULL, // Use parent's environment block. NULL, // Use parent's environment block.
NULL, // Use parent's starting directory. NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure. &si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure. &pi ) // Pointer to PROCESS_INFORMATION structure.
) )
{ {
// error occurs during the launch // error occurs during the launch
string str = toString("Can't execute '%s': code=%d %s", RelaunchNelLauncherBatchFilename.c_str(), errno, strerror(errno)); string str = toString("Can't execute '%s': code=%d %s", RelaunchNelLauncherBatchFilename.c_str(), errno, strerror(errno));
throw Exception (str); throw Exception (str);
} }
// Close process and thread handles. // Close process and thread handles.
CloseHandle( pi.hProcess ); CloseHandle( pi.hProcess );
CloseHandle( pi.hThread ); CloseHandle( pi.hThread );
exit(0); exit(0);
} }
else if (patchExe || patchCfg) else if (patchExe || patchCfg)
@ -355,7 +355,7 @@ private:
} }
fprintf(fp, "@echo off\n"); fprintf(fp, "@echo off\n");
if (patchExe) if (patchExe)
{ {
nlinfo ("Need to special patch '%s'",NelLauncherFilename.c_str()); nlinfo ("Need to special patch '%s'",NelLauncherFilename.c_str());
@ -379,52 +379,52 @@ private:
} }
fprintf(fp, "start %s\n", NelLauncherFilename.c_str()); fprintf(fp, "start %s\n", NelLauncherFilename.c_str());
fclose (fp); fclose (fp);
// remove the files list file // remove the files list file
setState (true, true, "Deleting %s", DirFilename.c_str()); setState (true, true, "Deleting %s", DirFilename.c_str());
string err = deleteFile (DirFilename, false); string err = deleteFile (DirFilename, false);
if (!err.empty()) setState(true, true, err.c_str()); if (!err.empty()) setState(true, true, err.c_str());
// launching the .bat // launching the .bat
setState (true, true, "Launching %s", UpdateNelLauncherBatchFilename.c_str()); setState (true, true, "Launching %s", UpdateNelLauncherBatchFilename.c_str());
//if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1) //if (_execlp ("update_nel_launcher.bat", "update_nel_launcher.bat", NULL) == -1)
STARTUPINFO si; STARTUPINFO si;
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) ); ZeroMemory( &si, sizeof(si) );
// Flag permettant de prendre en compte wShowWindow // Flag permettant de prendre en compte wShowWindow
si.dwFlags = STARTF_USESHOWWINDOW; si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_HIDE; si.wShowWindow = SW_HIDE;
si.cb = sizeof(si); si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) ); ZeroMemory( &pi, sizeof(pi) );
// Start the child process. // Start the child process.
if( !CreateProcess( NULL, // No module name (use command line). if( !CreateProcess( NULL, // No module name (use command line).
(char*)UpdateNelLauncherBatchFilename.c_str(), // Command line. (char*)UpdateNelLauncherBatchFilename.c_str(), // Command line.
NULL, // Process handle not inheritable. NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable. NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE. FALSE, // Set handle inheritance to FALSE.
0, // No creation flags. 0, // No creation flags.
NULL, // Use parent's environment block. NULL, // Use parent's environment block.
NULL, // Use parent's starting directory. NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure. &si, // Pointer to STARTUPINFO structure.
&pi ) // Pointer to PROCESS_INFORMATION structure. &pi ) // Pointer to PROCESS_INFORMATION structure.
) )
{ {
// error occurs during the launch // error occurs during the launch
string str = toString("Can't execute '%s': code=%d %s", UpdateNelLauncherBatchFilename.c_str(), errno, strerror(errno)); string str = toString("Can't execute '%s': code=%d %s", UpdateNelLauncherBatchFilename.c_str(), errno, strerror(errno));
throw Exception (str); throw Exception (str);
} }
// Close process and thread handles. // Close process and thread handles.
CloseHandle( pi.hProcess ); CloseHandle( pi.hProcess );
CloseHandle( pi.hThread ); CloseHandle( pi.hThread );
exit(0); exit(0);
} }
@ -442,12 +442,12 @@ private:
{ {
executeFinalizeBat = true; executeFinalizeBat = true;
} }
// put the file in the ryzom patch directory // put the file in the ryzom patch directory
string path = ClientPatchPath + needToGetFilesList[i].Filename; 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()); //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 // move dll exe and already existing file in the root directory
if (NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename) || if (NLMISC::CFile::fileExists (ClientRootPath + needToGetFilesList[i].Filename) ||
strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)) == "dll" || strlwr(NLMISC::CFile::getExtension(needToGetFilesList[i].Filename)) == "dll" ||
@ -471,7 +471,7 @@ private:
} }
// now, we have to delete files that are not in the server list // now, we have to delete files that are not in the server list
setState(true, true, "Scanning patch directory"); setState(true, true, "Scanning patch directory");
vector<string> res; vector<string> res;
CPath::getPathContent(ClientPatchPath, false, false, true, res); CPath::getPathContent(ClientPatchPath, false, false, true, res);
@ -512,10 +512,10 @@ private:
setState (true, true, "Launching %s", fn.c_str()); setState (true, true, "Launching %s", fn.c_str());
system(fn.c_str()); system(fn.c_str());
} }
// it s the end of the patch process // it s the end of the patch process
setState (true, true, "Patching completed"); setState (true, true, "Patching completed");
Url = UrlOk; Url = UrlOk;
PatchOk = true; PatchOk = true;
Ended = true; Ended = true;
@ -558,12 +558,12 @@ private:
if (fp == NULL) if (fp == NULL)
{ {
string err = toString("Can't open file '%s' : code=%d %s", dest.c_str(), errno, strerror(errno)); string err = toString("Can't open file '%s' : code=%d %s", dest.c_str(), errno, strerror(errno));
gzclose(gz); gzclose(gz);
deleteFile (filename); deleteFile (filename);
throw Exception (err); throw Exception (err);
} }
uint32 currentSize = 0; uint32 currentSize = 0;
uint8 buffer[10000]; uint8 buffer[10000];
while (!gzeof(gz)) while (!gzeof(gz))
@ -633,7 +633,7 @@ private:
errorstr = (LPCTSTR)lpMsgBuf; errorstr = (LPCTSTR)lpMsgBuf;
} }
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
throw Exception ("InternetOpen() failed: %s (ec %d)", errorstr.c_str(), errcode); throw Exception ("InternetOpen() failed: %s (ec %d)", errorstr.c_str(), errcode);
} }
} }
@ -683,7 +683,7 @@ private:
errorstr = (LPCTSTR)lpMsgBuf; errorstr = (LPCTSTR)lpMsgBuf;
} }
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
throw Exception ("InternetOpenUrl() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); throw Exception ("InternetOpenUrl() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode);
} }
else else
@ -703,7 +703,7 @@ private:
deleteFile (dest); deleteFile (dest);
throw Exception (err); throw Exception (err);
} }
CurrentBytesToGet += realSize; CurrentBytesToGet += realSize;
if (TotalBytesToGet == 0 && TotalFilesToGet == 0) if (TotalBytesToGet == 0 && TotalFilesToGet == 0)
@ -728,7 +728,7 @@ private:
errorstr = (LPCTSTR)lpMsgBuf; errorstr = (LPCTSTR)lpMsgBuf;
} }
LocalFree(lpMsgBuf); LocalFree(lpMsgBuf);
throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode); throw Exception ("InternetCloseHandle() failed on file '%s': %s (ec %d)", source.c_str (), errorstr.c_str(), errcode);
} }
} }
@ -742,7 +742,7 @@ private:
nlinfo (str); nlinfo (str);
State = str; State = str;
if(log) if(log)
{ {
StateLog += str; StateLog += str;
StateLog += LogSeparator; StateLog += LogSeparator;
} }
@ -773,11 +773,11 @@ void startPatchThread (const std::string &serverPath, const std::string &serverV
nlwarning ("patch thread already running"); nlwarning ("patch thread already running");
return; return;
} }
PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator); PatchThread = new CPatchThread (serverPath, serverVersion, urlOk, urlFailed, logSeparator);
nlassert (PatchThread != NULL); nlassert (PatchThread != NULL);
IThread *thread = IThread::create (PatchThread); CThread *thread = CThread::create (PatchThread);
nlassert (thread != NULL); nlassert (thread != NULL);
thread->start (); thread->start ();
} }

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

@ -144,7 +144,7 @@ private:
private: private:
// data for the singleton instance // data for the singleton instance
CStdinMonitorThread* _StdinMonitorThreadInstance; CStdinMonitorThread* _StdinMonitorThreadInstance;
NLMISC::IThread* _StdinMonitorThreadHandle; NLMISC::CThread* _StdinMonitorThreadHandle;
}; };
CStdinMonitorSingleton StdinMonitorSingleton; CStdinMonitorSingleton StdinMonitorSingleton;
@ -165,7 +165,7 @@ static CStdinMonitorSingleton& getInstance()
void CStdinMonitorSingleton::init() void CStdinMonitorSingleton::init()
{ {
_StdinMonitorThreadInstance= new CStdinMonitorThread; _StdinMonitorThreadInstance= new CStdinMonitorThread;
_StdinMonitorThreadHandle = NLMISC::IThread::create (_StdinMonitorThreadInstance); _StdinMonitorThreadHandle = NLMISC::CThread::create (_StdinMonitorThreadInstance);
_StdinMonitorThreadHandle->start(); _StdinMonitorThreadHandle->start();
} }

@ -159,7 +159,7 @@ int CPatchManager::getTotalFilesToGet()
{ {
if (ScanDataThread != NULL) if (ScanDataThread != NULL)
return ScanDataThread->TotalFileToScan; return ScanDataThread->TotalFileToScan;
return 1; return 1;
} }
@ -168,7 +168,7 @@ int CPatchManager::getCurrentFilesToGet()
{ {
if (ScanDataThread != NULL) if (ScanDataThread != NULL)
return ScanDataThread->CurrentFileScanned; return ScanDataThread->CurrentFileScanned;
return 1; return 1;
} }
@ -226,7 +226,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn,
ftpOut.FileName = rFilename; ftpOut.FileName = rFilename;
ftpOut.LocalFileToDelete = false; ftpOut.LocalFileToDelete = false;
ftpOut.LocalFileExists = false; ftpOut.LocalFileExists = false;
// It happens some time (maybe a bug) that the versionCount is 0... => // It happens some time (maybe a bug) that the versionCount is 0... =>
// it happens if the BNP file is empty (8 bytes) // it happens if the BNP file is empty (8 bytes)
ftpOut.FinalFileSize = EmptyBnpFileSize; ftpOut.FinalFileSize = EmptyBnpFileSize;
// BNP does not exists : get all the patches version // BNP does not exists : get all the patches version
@ -261,7 +261,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn,
} }
} }
} }
// If the version cannot be found with size and time try with sha1 // If the version cannot be found with size and time try with sha1
if (nVersionFound == 0xFFFFFFFF) if (nVersionFound == 0xFFFFFFFF)
{ {
@ -280,7 +280,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn,
} }
} }
} }
// No version available found // No version available found
if (nVersionFound == 0xFFFFFFFF) if (nVersionFound == 0xFFFFFFFF)
{ {
@ -290,7 +290,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn,
ftpOut.FileName = rFilename; ftpOut.FileName = rFilename;
ftpOut.LocalFileToDelete = true; ftpOut.LocalFileToDelete = true;
ftpOut.LocalFileExists = true; ftpOut.LocalFileExists = true;
// It happens some time (maybe a bug) that the versionCount is 0... => // It happens some time (maybe a bug) that the versionCount is 0... =>
// it happens if the BNP file is empty (8 bytes) // it happens if the BNP file is empty (8 bytes)
ftpOut.FinalFileSize = EmptyBnpFileSize; ftpOut.FinalFileSize = EmptyBnpFileSize;
// Get all the patches version // Get all the patches version
@ -314,7 +314,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn,
for (j = 0; j < rFile.versionCount(); ++j) for (j = 0; j < rFile.versionCount(); ++j)
if (rFile.getVersion(j).getVersionNumber() == nVersionFound) if (rFile.getVersion(j).getVersionNumber() == nVersionFound)
break; break;
nlassert(j != rFile.versionCount()); // Not normal if we cant find the version we found previously nlassert(j != rFile.versionCount()); // Not normal if we cant find the version we found previously
// Point on the next version // Point on the next version
@ -335,7 +335,7 @@ void CPatchManager::getPatchFromDesc(SFileToPatch &ftpOut, const CBNPFile &fIn,
// For info, get its final file size // For info, get its final file size
ftpOut.FinalFileSize= rFile.getVersion(rFile.versionCount()-1).getFileSize(); ftpOut.FinalFileSize= rFile.getVersion(rFile.versionCount()-1).getFileSize();
} }
} // end of else local BNP file exists } // end of else local BNP file exists
} }
@ -352,7 +352,7 @@ void CPatchManager::startScanDataThread()
nlwarning ("a thread is already running"); nlwarning ("a thread is already running");
return; return;
} }
// Reset result // Reset result
clearDataScanLog(); clearDataScanLog();
@ -362,8 +362,8 @@ void CPatchManager::startScanDataThread()
// start thread // start thread
ScanDataThread = new CScanDataThread(); ScanDataThread = new CScanDataThread();
nlassert (ScanDataThread != NULL); nlassert (ScanDataThread != NULL);
thread = IThread::create (ScanDataThread); thread = CThread::create (ScanDataThread);
nlassert (thread != NULL); nlassert (thread != NULL);
thread->start (); thread->start ();
} }
@ -376,14 +376,14 @@ bool CPatchManager::isScanDataThreadEnded(bool &ok)
ok = false; ok = false;
return true; return true;
} }
bool end = ScanDataThread->Ended; bool end = ScanDataThread->Ended;
if (end) if (end)
{ {
ok = ScanDataThread->CheckOk; ok = ScanDataThread->CheckOk;
stopScanDataThread(); stopScanDataThread();
} }
return end; return end;
} }
@ -430,7 +430,7 @@ bool CPatchManager::getDataScanLog(ucstring &text)
} }
// then reset // then reset
val.Changed= false; val.Changed= false;
} }
return changed; return changed;
} }
@ -443,7 +443,7 @@ void CPatchManager::addDataScanLogCorruptedFile(const SFileToPatch &ftp)
CDataScanState &val= ac.value(); CDataScanState &val= ac.value();
val.FilesWithScanDataError.push_back(ftp); val.FilesWithScanDataError.push_back(ftp);
val.Changed= true; val.Changed= true;
} }
} }
// *************************************************************************** // ***************************************************************************
@ -454,7 +454,7 @@ void CPatchManager::clearDataScanLog()
CDataScanState &val= ac.value(); CDataScanState &val= ac.value();
val.FilesWithScanDataError.clear(); val.FilesWithScanDataError.clear();
val.Changed= true; val.Changed= true;
} }
} }
// *************************************************************************** // ***************************************************************************
@ -494,8 +494,8 @@ void CScanDataThread::run ()
string sClientVersion = pPM->getClientVersion(); string sClientVersion = pPM->getClientVersion();
ucstring sTranslate = dummyI18N("Client Version") + " (" + sClientVersion + ") "; ucstring sTranslate = dummyI18N("Client Version") + " (" + sClientVersion + ") ";
pPM->setState(true, sTranslate); pPM->setState(true, sTranslate);
// For all bnp in the description file get all patches to apply // For all bnp in the description file get all patches to apply
// depending on the version of the client bnp files // depending on the version of the client bnp files
const CBNPFileSet &rDescFiles = pPM->DescFile.getFiles(); const CBNPFileSet &rDescFiles = pPM->DescFile.getFiles();
TotalFileToScan = rDescFiles.fileCount(); TotalFileToScan = rDescFiles.fileCount();

@ -61,7 +61,7 @@ public:
_Instance = new CPatchManager(); _Instance = new CPatchManager();
return _Instance; return _Instance;
} }
// init // init
void init(); void init();
@ -69,31 +69,31 @@ public:
std::string getClientVersion (); std::string getClientVersion ();
bool isVerboseLog() { return VerboseLog; } bool isVerboseLog() { return VerboseLog; }
void setVerboseLog(bool b) { VerboseLog = b; } void setVerboseLog(bool b) { VerboseLog = b; }
// Get the string information about what the threads are doing // Get the string information about what the threads are doing
// Return true if the state has changed // Return true if the state has changed
bool getThreadState (ucstring &state, std::vector<ucstring> &stateLog); bool getThreadState (ucstring &state, std::vector<ucstring> &stateLog);
// TODO : Revoir ca pour la seconde partie ... // TODO : Revoir ca pour la seconde partie ...
// On a peut etre pas les informations de taille des patches ... voir avec daniel // On a peut etre pas les informations de taille des patches ... voir avec daniel
// pour l'instant c'est un fake qui retourne 1 ! // pour l'instant c'est un fake qui retourne 1 !
int getTotalFilesToGet(); int getTotalFilesToGet();
int getCurrentFilesToGet(); int getCurrentFilesToGet();
// ---------------------------------------------- // ----------------------------------------------
// ScanData Part : optional task wich verify all data // ScanData Part : optional task wich verify all data
// ---------------------------------------------- // ----------------------------------------------
// start the full check of BNP // start the full check of BNP
void startScanDataThread(); void startScanDataThread();
// if the scan data thread has ended // if the scan data thread has ended
bool isScanDataThreadEnded(bool &ok); bool isScanDataThreadEnded(bool &ok);
// ask to stop the Scan Data thread. NB: for security, the thread will continue to the current scanned file, // ask to stop the Scan Data thread. NB: for security, the thread will continue to the current scanned file,
// then stop. Hence, you must still wait isScanDataThreadEnded() return true // then stop. Hence, you must still wait isScanDataThreadEnded() return true
void askForStopScanDataThread(); void askForStopScanDataThread();
@ -109,7 +109,7 @@ private:
// Set the thread state (called by threads to let us know what they are doing) // Set the thread state (called by threads to let us know what they are doing)
void setState (bool bOutputToLog, const ucstring &ucsState); void setState (bool bOutputToLog, const ucstring &ucsState);
/// Read the description file (throw exception if it doesn't exists) /// Read the description file (throw exception if it doesn't exists)
void readDescFile(sint32 nVersion); void readDescFile(sint32 nVersion);
@ -126,7 +126,7 @@ private:
void addDataScanLogCorruptedFile(const SFileToPatch &ftp); void addDataScanLogCorruptedFile(const SFileToPatch &ftp);
void clearDataScanLog(); void clearDataScanLog();
static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate); static void getCorruptedFileInfo(const SFileToPatch &ftp, ucstring &sTranslate);
private: private:
/// Constructor /// Constructor
@ -143,7 +143,7 @@ private:
// Threads // Threads
CScanDataThread *ScanDataThread; CScanDataThread *ScanDataThread;
NLMISC::IThread *thread; NLMISC::CThread *thread;
// State // State
struct CState struct CState
@ -197,7 +197,7 @@ public:
public: public:
// Written by MainThread, read by thread // Written by MainThread, read by thread
bool AskForCancel; // true if the main thread ask to cancel the task bool AskForCancel; // true if the main thread ask to cancel the task
// Written by thread, read by Main Thread // Written by thread, read by Main Thread
bool Ended; // true if the thread have ended bool Ended; // true if the thread have ended

Loading…
Cancel
Save