mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 01:06:19 +00:00
Merge with develop
This commit is contained in:
parent
1354d99609
commit
7879ca7566
8 changed files with 129 additions and 27 deletions
|
@ -349,6 +349,10 @@ std::string formatThousands(const std::string& s);
|
||||||
/// The program will be launched in the current directory
|
/// The program will be launched in the current directory
|
||||||
bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true);
|
bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true);
|
||||||
|
|
||||||
|
/// This function executes a program and wait for result (used for example for crash report).
|
||||||
|
/// The program will be launched in the current directory
|
||||||
|
sint launchProgramAndWaitForResult (const std::string &programName, const std::string &arguments, bool log = true);
|
||||||
|
|
||||||
/// This function executes a program and returns output as a string
|
/// This function executes a program and returns output as a string
|
||||||
std::string getCommandOutput(const std::string &command);
|
std::string getCommandOutput(const std::string &command);
|
||||||
|
|
||||||
|
|
|
@ -677,7 +677,6 @@ bool abortProgram(uint32 pid)
|
||||||
|
|
||||||
bool launchProgram(const std::string &programName, const std::string &arguments, bool log)
|
bool launchProgram(const std::string &programName, const std::string &arguments, bool log)
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
#ifdef NL_OS_WINDOWS
|
||||||
STARTUPINFOA si;
|
STARTUPINFOA si;
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
|
@ -723,16 +722,19 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
|
||||||
{
|
{
|
||||||
// we need to open bundles with "open" command
|
// we need to open bundles with "open" command
|
||||||
command = NLMISC::toString("open \"%s\"", programName.c_str());
|
command = NLMISC::toString("open \"%s\"", programName.c_str());
|
||||||
|
|
||||||
|
// append arguments if any
|
||||||
|
if (!arguments.empty())
|
||||||
|
{
|
||||||
|
command += NLMISC::toString(" --args %s", arguments.c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
command = programName;
|
command = programName;
|
||||||
}
|
|
||||||
|
|
||||||
// append arguments if any
|
// append arguments if any
|
||||||
if (!arguments.empty())
|
if (!arguments.empty()) command += " " + arguments;
|
||||||
{
|
|
||||||
command += NLMISC::toString(" --args %s", arguments.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = system(command.c_str());
|
int res = system(command.c_str());
|
||||||
|
@ -825,7 +827,92 @@ bool launchProgram(const std::string &programName, const std::string &arguments,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
sint launchProgramAndWaitForResult(const std::string &programName, const std::string &arguments, bool log)
|
||||||
|
{
|
||||||
|
sint res = 0;
|
||||||
|
|
||||||
|
#ifdef NL_OS_WINDOWS
|
||||||
|
STARTUPINFOA si;
|
||||||
|
PROCESS_INFORMATION pi;
|
||||||
|
|
||||||
|
memset(&si, 0, sizeof(si));
|
||||||
|
memset(&pi, 0, sizeof(pi));
|
||||||
|
|
||||||
|
si.cb = sizeof(si);
|
||||||
|
|
||||||
|
// Enable nlassert/nlstop to display the error reason & callstack
|
||||||
|
const TCHAR *SE_TRANSLATOR_IN_MAIN_MODULE = _T("NEL_SE_TRANS");
|
||||||
|
TCHAR envBuf [2];
|
||||||
|
if ( GetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, envBuf, 2 ) != 0)
|
||||||
|
{
|
||||||
|
SetEnvironmentVariable( SE_TRANSLATOR_IN_MAIN_MODULE, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
string arg = " " + arguments;
|
||||||
|
BOOL ok = CreateProcessA(programName.c_str(), (char*)arg.c_str(), NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
// Successfully created the process. Wait for it to finish.
|
||||||
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||||
|
|
||||||
|
// Get the exit code.
|
||||||
|
DWORD exitCode = 0;
|
||||||
|
ok = GetExitCodeProcess(pi.hProcess, &exitCode);
|
||||||
|
|
||||||
|
//nldebug("LAUNCH: Successful launch '%s' with arg '%s'", programName.c_str(), arguments.c_str());
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
res = (sint)exitCode;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (log)
|
||||||
|
nlwarning("LAUNCH: Failed launched '%s' with arg '%s'", programName.c_str(), arguments.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LPVOID lpMsgBuf;
|
||||||
|
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL);
|
||||||
|
|
||||||
|
if (log)
|
||||||
|
nlwarning("LAUNCH: Failed launched '%s' with arg '%s' err %d: '%s'", programName.c_str(), arguments.c_str(), GetLastError(), lpMsgBuf);
|
||||||
|
|
||||||
|
LocalFree(lpMsgBuf);
|
||||||
|
|
||||||
|
CloseHandle(pi.hProcess);
|
||||||
|
CloseHandle(pi.hThread);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// save LD_LIBRARY_PATH
|
||||||
|
const char *previousEnv = getenv("LD_LIBRARY_PATH");
|
||||||
|
|
||||||
|
// clear LD_LIBRARY_PATH to avoid problems with Steam Runtime
|
||||||
|
setenv("LD_LIBRARY_PATH", "", 1);
|
||||||
|
|
||||||
|
// program name is the only required string
|
||||||
|
std::string command = programName;
|
||||||
|
|
||||||
|
// only appends arguments if any
|
||||||
|
if (!arguments.empty()) command += " " + arguments;
|
||||||
|
|
||||||
|
// execute the command
|
||||||
|
res = system(command.c_str());
|
||||||
|
|
||||||
|
// restore previous LD_LIBRARY_PATH
|
||||||
|
setenv("LD_LIBRARY_PATH", previousEnv, 1);
|
||||||
|
|
||||||
|
if (res && log)
|
||||||
|
nlwarning ("LAUNCH: Failed launched '%s' with arg '%s' return code %d", programName.c_str(), arguments.c_str(), res);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getCommandOutput(const std::string &command)
|
std::string getCommandOutput(const std::string &command)
|
||||||
|
|
|
@ -105,7 +105,6 @@ TReportResult report(const std::string &title, const std::string &subject, const
|
||||||
&& CFile::isExists(NL_CRASH_REPORT_TOOL))
|
&& CFile::isExists(NL_CRASH_REPORT_TOOL))
|
||||||
{
|
{
|
||||||
std::string params;
|
std::string params;
|
||||||
params += NL_CRASH_REPORT_TOOL;
|
|
||||||
|
|
||||||
if (!reportPath.empty())
|
if (!reportPath.empty())
|
||||||
params += NLMISC::toString(" -log \"%s\"", reportPath.c_str());
|
params += NLMISC::toString(" -log \"%s\"", reportPath.c_str());
|
||||||
|
@ -131,7 +130,8 @@ TReportResult report(const std::string &title, const std::string &subject, const
|
||||||
|
|
||||||
if (synchronous)
|
if (synchronous)
|
||||||
{
|
{
|
||||||
TReportResult result = (TReportResult)::system(params.c_str());
|
TReportResult result = (TReportResult)NLMISC::launchProgramAndWaitForResult(NL_CRASH_REPORT_TOOL, params);
|
||||||
|
|
||||||
if (result != ReportAlwaysIgnore
|
if (result != ReportAlwaysIgnore
|
||||||
&& result != ReportIgnore
|
&& result != ReportIgnore
|
||||||
&& result != ReportAbort
|
&& result != ReportAbort
|
||||||
|
|
|
@ -920,6 +920,14 @@ int main(int nNbArg, char **ppArgs)
|
||||||
const CMeshGeom *pMG = dynamic_cast<const CMeshGeom*>(&pMeshML->getMeshGeom(m));
|
const CMeshGeom *pMG = dynamic_cast<const CMeshGeom*>(&pMeshML->getMeshGeom(m));
|
||||||
pVB = const_cast<CVertexBuffer*>(&pMG->getVertexBuffer());
|
pVB = const_cast<CVertexBuffer*>(&pMG->getVertexBuffer());
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pVB = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// to avoid a possible crash
|
||||||
|
if (!pVB) continue;
|
||||||
|
|
||||||
CVertexBufferReadWrite vba;
|
CVertexBufferReadWrite vba;
|
||||||
pVB->lock (vba);
|
pVB->lock (vba);
|
||||||
|
|
||||||
|
|
|
@ -131,6 +131,9 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
NLMISC::CBitmap bitmap;
|
NLMISC::CBitmap bitmap;
|
||||||
|
|
||||||
|
// all 8 bits textures are grayscale and not alpha
|
||||||
|
bitmap.loadGrayscaleAsAlpha(false);
|
||||||
|
|
||||||
uint8 depth = bitmap.load(input);
|
uint8 depth = bitmap.load(input);
|
||||||
|
|
||||||
// don't need file so close it
|
// don't need file so close it
|
||||||
|
|
|
@ -360,24 +360,24 @@ void dividSize (CBitmap &bitmap)
|
||||||
}
|
}
|
||||||
|
|
||||||
const int bayerDiv8R[4][4] = {
|
const int bayerDiv8R[4][4] = {
|
||||||
7, 3, 6, 2,
|
{ 7, 3, 6, 2 },
|
||||||
1, 5, 0, 4,
|
{ 1, 5, 0, 4 },
|
||||||
6, 2, 7, 3,
|
{ 6, 2, 7, 3 },
|
||||||
0, 4, 1, 5,
|
{ 0, 4, 1, 5 }
|
||||||
};
|
};
|
||||||
|
|
||||||
const int bayerDiv8G[4][4] = {
|
const int bayerDiv8G[4][4] = {
|
||||||
0, 4, 1, 5,
|
{ 0, 4, 1, 5 },
|
||||||
6, 2, 7, 3,
|
{ 6, 2, 7, 3 },
|
||||||
1, 5, 0, 4,
|
{ 1, 5, 0, 4 },
|
||||||
7, 3, 6, 2,
|
{ 7, 3, 6, 2 }
|
||||||
};
|
};
|
||||||
|
|
||||||
const int bayerDiv8B[4][4] = {
|
const int bayerDiv8B[4][4] = {
|
||||||
5, 1, 4, 0,
|
{ 5, 1, 4, 0 },
|
||||||
3, 7, 2, 6,
|
{ 3, 7, 2, 6 },
|
||||||
4, 0, 5, 1,
|
{ 4, 0, 5, 1 },
|
||||||
2, 6, 3, 7,
|
{ 2, 6, 3, 7 }
|
||||||
};
|
};
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
|
|
||||||
#include "crypt.h"
|
#include "crypt.h"
|
||||||
|
|
||||||
char * rz_crypt(register const char *key, register const char *setting, char *buf);
|
std::string rz_crypt(register const char *key, register const char *setting, char *buf);
|
||||||
char *__crypt_sha512(const char *key, const char *setting, char *output);
|
std::string __crypt_sha512(const char *key, const char *setting, char *output);
|
||||||
|
|
||||||
|
|
||||||
// Crypts password using salt
|
// Crypts password using salt
|
||||||
|
@ -505,7 +505,7 @@ static char cryptresult[1+4+4+11+1]; /* encrypted result */
|
||||||
* Return a pointer to static data consisting of the "setting"
|
* Return a pointer to static data consisting of the "setting"
|
||||||
* followed by an encryption produced by the "key" and "setting".
|
* followed by an encryption produced by the "key" and "setting".
|
||||||
*/
|
*/
|
||||||
char * rz_crypt(register const char *key, register const char *setting, char *buf) {
|
std::string rz_crypt(register const char *key, register const char *setting, char *buf) {
|
||||||
register char *encp;
|
register char *encp;
|
||||||
register long i;
|
register long i;
|
||||||
register int t;
|
register int t;
|
||||||
|
@ -580,7 +580,7 @@ char * rz_crypt(register const char *key, register const char *setting, char *bu
|
||||||
encp += salt_size;
|
encp += salt_size;
|
||||||
if (rz_des_cipher((char *)&constdatablock, (char *)&rsltblock,
|
if (rz_des_cipher((char *)&constdatablock, (char *)&rsltblock,
|
||||||
salt, num_iter))
|
salt, num_iter))
|
||||||
return (NULL);
|
return "";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Encode the 64 cipher bits as 11 ascii characters.
|
* Encode the 64 cipher bits as 11 ascii characters.
|
||||||
|
@ -602,7 +602,7 @@ char * rz_crypt(register const char *key, register const char *setting, char *bu
|
||||||
|
|
||||||
encp[3] = 0;
|
encp[3] = 0;
|
||||||
|
|
||||||
return (cryptresult);
|
return cryptresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ static char *sha512crypt(const char *key, const char *setting, char *output)
|
||||||
|
|
||||||
/* DS = sha(repeat-salt) */
|
/* DS = sha(repeat-salt) */
|
||||||
sha512_init(&ctx);
|
sha512_init(&ctx);
|
||||||
for (i = 0; i < 16 + md[0]; i++)
|
for (i = 0; i < 16u + md[0]; i++)
|
||||||
sha512_update(&ctx, salt, slen);
|
sha512_update(&ctx, salt, slen);
|
||||||
sha512_sum(&ctx, smd);
|
sha512_sum(&ctx, smd);
|
||||||
|
|
||||||
|
@ -373,7 +373,7 @@ static char *sha512crypt(const char *key, const char *setting, char *output)
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *__crypt_sha512(const char *key, const char *setting, char *output)
|
std::string __crypt_sha512(const char *key, const char *setting, char *output)
|
||||||
{
|
{
|
||||||
static const char testkey[] = "Xy01@#\x01\x02\x80\x7f\xff\r\n\x81\t !";
|
static const char testkey[] = "Xy01@#\x01\x02\x80\x7f\xff\r\n\x81\t !";
|
||||||
static const char testsetting[] = "$6$rounds=1234$abc0123456789$";
|
static const char testsetting[] = "$6$rounds=1234$abc0123456789$";
|
||||||
|
|
Loading…
Reference in a new issue