Merge with develop

--HG--
branch : compatibility-develop
hg/compatibility-develop
kervala 7 years ago
commit 52fe4dd7fe

@ -9,7 +9,7 @@ os:
matrix: matrix:
fast_finish: true fast_finish: true
env: env:
- CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF" - CMAKE_CONFIGURE_OPTIONS="-DWITH_NEL_TESTS=OFF -DWITH_NEL_SAMPLES=OFF -DWITH_LUA51=ON -DWITH_RYZOM_SERVER=OFF -DWITH_RYZOM_TOOLS=OFF -DWITH_NEL_TOOLS=OFF"
- CMAKE_CONFIGURE_OPTIONS="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so" - CMAKE_CONFIGURE_OPTIONS="-DCPPTEST_LIBRARY_DEBUG:STRING=/usr/lib/libcpptest.so"
CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2" CMAKE_BUILD_OPTIONS="--target nel_unit_test -- -j 2"
RUN="build/bin/nel_unit_test" RUN="build/bin/nel_unit_test"

@ -233,6 +233,26 @@ char toLower ( const char ch ); // convert only one character
std::string toUpper ( const std::string &str); std::string toUpper ( const std::string &str);
void toUpper ( char *str); void toUpper ( char *str);
/**
* Convert to an hexadecimal std::string
*/
std::string toHexa(const uint8 &b);
std::string toHexa(const uint8 *data, uint size);
std::string toHexa(const std::string &str);
std::string toHexa(const char *str);
/**
* Convert from an hexadecimal std::string
*/
bool fromHexa(const std::string &hexa, uint8 &b);
bool fromHexa(const std::string &hexa, uint8 *data);
bool fromHexa(const std::string &hexa, std::string &str);
bool fromHexa(const char *hexa, uint8 &b);
bool fromHexa(const char *hexa, uint8 *data);
bool fromHexa(const char *hexa, std::string &str);
bool fromHexa(const char hexa, uint8 &b);
// Remove all the characters <= 32 (tab, space, new line, return, vertical tab etc..) at the beginning and at the end of a string // Remove all the characters <= 32 (tab, space, new line, return, vertical tab etc..) at the beginning and at the end of a string
template <class T> T trim (const T &str) template <class T> T trim (const T &str)
{ {

@ -46,7 +46,7 @@ public:
double getSamplingPeriod() const { return _SamplingPeriod; } double getSamplingPeriod() const { return _SamplingPeriod; }
// Reset smoother. The next returned position will be the exact position of mouse (no smoothing with previous position is done) // Reset smoother. The next returned position will be the exact position of mouse (no smoothing with previous position is done)
void reset(); void reset();
// \return trueif no sampling has occurred since last resetor construction // \return true if no sampling has occurred since last resetor construction
bool isReseted() const { return !_Init; } bool isReseted() const { return !_Init; }
// Sample pos, and return smoothed position // Sample pos, and return smoothed position
CVector2f samplePos(const CVector2f &wantedPos, double date); CVector2f samplePos(const CVector2f &wantedPos, double date);

@ -1802,7 +1802,7 @@ namespace NLGUI
return 0; return 0;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
int CGroupSubMenu::luaAddIconLine(CLuaState &ls) int CGroupSubMenu::luaAddIconLine(CLuaState &ls)
{ {
const char *funcName = "addIconLine"; const char *funcName = "addIconLine";

@ -633,7 +633,7 @@ void toLower(char *str)
} }
} }
std::string toUpper(const std::string &str) std::string toUpper(const std::string &str)
{ {
string res; string res;
res.reserve(str.size()); res.reserve(str.size());
@ -647,7 +647,7 @@ std::string toUpper(const std::string &str)
return res; return res;
} }
void toUpper(char *str) void toUpper(char *str)
{ {
if (str == 0) if (str == 0)
return; return;
@ -662,6 +662,109 @@ void toUpper(char *str)
} }
} }
std::string toHexa(const uint8 &b)
{
return toString("%02hhx", b);
}
std::string toHexa(const uint8 *data, uint size)
{
std::string res;
// hexadecimal string will be always twice the original size
res.reserve(size * 2);
// process each byte
for (uint i = 0; i < size; ++i)
{
res += toHexa(data[i]);
}
return res;
}
std::string toHexa(const std::string &str)
{
return toHexa((uint8*)str.c_str(), (uint)str.length());
}
std::string toHexa(const char *str)
{
return toHexa((uint8*)str, (uint)strlen(str));
}
bool fromHexa(const std::string &hexa, uint8 &b)
{
return fromHexa(hexa.c_str(), b);
}
bool fromHexa(const std::string &hexa, uint8 *data)
{
return fromHexa(hexa.c_str(), data);
}
bool fromHexa(const std::string &hexa, std::string &str)
{
return fromHexa(hexa.c_str(), str);
}
bool fromHexa(const char *hexa, uint8 &b)
{
char c1 = *hexa;
char c2 = *(hexa+1);
uint8 x1, x2;
if (!fromHexa(c1, x1)) return false;
if (!fromHexa(c2, x2)) return false;
b = (x1 << 4) | x2;
return true;
}
bool fromHexa(const char *hexa, uint8 *data)
{
// length of the string
uint len = strlen(hexa);
// process each byte
for (uint i = 0; i < len; i += 2)
{
if (!fromHexa(hexa + i, *(data++))) return false;
}
return true;
}
bool fromHexa(const char *hexa, std::string &str)
{
str.resize(strlen(hexa) * 2);
return fromHexa(hexa, (uint8*)str.c_str());
}
bool fromHexa(const char hexa, uint8 &b)
{
if (hexa >= '0' && hexa <= '9')
{
b = hexa - '0';
return true;
}
if (hexa >= 'A' && hexa <= 'F')
{
b = hexa - 'A' + 10;
return true;
}
if (hexa >= 'a' && hexa <= 'f')
{
b = hexa - 'a' + 10;
return true;
}
return false;
}
std::string formatThousands(const std::string& s) std::string formatThousands(const std::string& s)
{ {
sint i, k; sint i, k;
@ -1253,7 +1356,7 @@ std::string escapeArgument(const std::string &arg)
// we can't escape %VARIABLE% on command-line under Windows // we can't escape %VARIABLE% on command-line under Windows
return arg; return arg;
#else #else
// characters to escapce, only " and $ (to prevent a $something replaced by an environment variable) // characters to escape, only " and $ (to prevent a $something replaced by an environment variable)
static const char s_charsToEscape[] = "\"$"; static const char s_charsToEscape[] = "\"$";
std::string res; std::string res;

@ -118,31 +118,6 @@ CHashKeyMD5 getMD5(const uint8 *buffer, uint32 size)
return Message_Digest; return Message_Digest;
} }
// ****************************************************************************
// Helper
// ****************************************************************************
static bool fromHex(char c, uint8 &x)
{
if (c >= '0' && c <= '9')
{
x = c - '0';
return true;
}
else if (c >= 'A' && c <= 'F')
{
x = c - 'A' + 10;
return true;
}
else if (c >= 'a' && c <= 'f')
{
x = c - 'a' + 10;
return true;
}
nlwarning("cannot convert to hexa");
return false;
}
// **************************************************************************** // ****************************************************************************
// **************************************************************************** // ****************************************************************************
// CHashKeyMD5 // CHashKeyMD5
@ -159,10 +134,7 @@ void CHashKeyMD5::clear()
// **************************************************************************** // ****************************************************************************
string CHashKeyMD5::toString() const string CHashKeyMD5::toString() const
{ {
string sTmp; return toHexa(Data, 16);
for (uint32 i = 0; i < 16; ++i)
sTmp += NLMISC::toString("%02x", Data[i]);
return sTmp;
} }
// **************************************************************************** // ****************************************************************************
@ -174,16 +146,7 @@ bool CHashKeyMD5::fromString(const std::string &in)
return false; return false;
} }
for (uint32 i = 0; i < 16; ++i) return fromHexa(in, Data);
{
char c1 = in[2*i];
char c2 = in[2*i+1];
uint8 x1, x2;
if (!fromHex(c1, x1)) return false;
if (!fromHex(c2, x2)) return false;
Data[i] = (x1 << 4) | x2;
}
return true;
} }
// **************************************************************************** // ****************************************************************************

@ -828,7 +828,6 @@ void CUnifiedNetwork::addService(const string &name, const vector<CInetAddress>
for (uint i = 0; i < addr.size(); i++) for (uint i = 0; i < addr.size(); i++)
{ {
// first we have to look if we have a network that can established the connection // first we have to look if we have a network that can established the connection
uint j = 0; uint j = 0;
// it's loopback ip address, it's ok // it's loopback ip address, it's ok

@ -205,6 +205,19 @@ int main(int argc, char **argv)
{ {
LoginPassword = Args.getAdditionalArg("password").front(); LoginPassword = Args.getAdditionalArg("password").front();
// password in hexadecimal
if (LoginPassword.compare(0, 2, "0x") == 0)
{
std::string decodedPassword;
// decode password
if (fromHexa(LoginPassword.substr(2), decodedPassword))
{
// only use it if real hexadecimal
LoginPassword = decodedPassword;
}
}
if (Args.haveAdditionalArg("shard_id")) if (Args.haveAdditionalArg("shard_id"))
sLoginShardId = Args.getAdditionalArg("shard_id").front(); sLoginShardId = Args.getAdditionalArg("shard_id").front();
} }

@ -800,7 +800,8 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
if (param == "transparency") if (param == "transparency")
{ {
uint t; uint t;
if( fromString( values[i], t ) ) { if (fromString(values[i], t))
{
t = max(0, min((int)t, 255)); t = max(0, min((int)t, 255));
makeInstanceTransparent(instance, t, t == 255); makeInstanceTransparent(instance, t, t == 255);
} }
@ -864,9 +865,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
float v; float v;
CVector pos = getInstancePos(idx); CVector pos = getInstancePos(idx);
if( getRelativeFloatFromString( values[i], v ) ) { if (getRelativeFloatFromString(values[i], v))
{
updateVector(param, pos, v, true); updateVector(param, pos, v, true);
} else { }
else
{
updateVector(param, pos, v, false); updateVector(param, pos, v, false);
} }
setInstancePos(idx, pos); setInstancePos(idx, pos);
@ -877,9 +881,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
float v; float v;
CVector rot = getInstanceRot(idx); CVector rot = getInstanceRot(idx);
if( getRelativeFloatFromString( values[i], v ) ) { if (getRelativeFloatFromString(values[i], v))
{
updateVector(param, rot, v, true); updateVector(param, rot, v, true);
} else { }
else
{
updateVector(param, rot, v, false); updateVector(param, rot, v, false);
} }
setInstanceRot(idx, rot); setInstanceRot(idx, rot);
@ -889,9 +896,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
float v; float v;
CVector scale = instance.getScale(); CVector scale = instance.getScale();
if( getRelativeFloatFromString( values[i], v ) ) { if (getRelativeFloatFromString(values[i], v))
{
updateVector(param, scale, v, true); updateVector(param, scale, v, true);
} else { }
else
{
updateVector(param, scale, v, false); updateVector(param, scale, v, false);
} }
instance.setScale(scale); instance.setScale(scale);
@ -909,9 +919,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
CVector size = CVector(width, depth, height); CVector size = CVector(width, depth, height);
float v; float v;
if( getRelativeFloatFromString( values[i], v ) ) { if (getRelativeFloatFromString(values[i], v))
{
updateVector(param, size, v, true); updateVector(param, size, v, true);
} else { }
else
{
updateVector(param, size, v, false); updateVector(param, size, v, false);
} }
primitive->setSize(size.x, size.y); primitive->setSize(size.x, size.y);
@ -922,9 +935,12 @@ bool CEntityManager::setupInstance(uint32 idx, const vector<string> &keys, const
CVector pos = instance.getPos(); CVector pos = instance.getPos();
float v; float v;
if( getRelativeFloatFromString( values[i], v ) ) { if (getRelativeFloatFromString(values[i], v))
{
updateVector(param, _ShapeInstances[idx].PrimRelativePos, v, false); updateVector(param, _ShapeInstances[idx].PrimRelativePos, v, false);
} else { }
else
{
if (param == "col pos x") if (param == "col pos x")
_ShapeInstances[idx].PrimRelativePos.x = v - pos.x; _ShapeInstances[idx].PrimRelativePos.x = v - pos.x;
if (param == "col pos y") if (param == "col pos y")
@ -1023,7 +1039,8 @@ CShapeInstanceReference CEntityManager::getShapeInstanceUnderPos(float x, float
// if intersect the bbox // if intersect the bbox
NLMISC::CAABBox bbox; NLMISC::CAABBox bbox;
//= _ShapeInstances[i].SelectionBox; //= _ShapeInstances[i].SelectionBox;
if(!_ShapeInstances[i].Instance.empty()) { if(!_ShapeInstances[i].Instance.empty())
{
_ShapeInstances[i].Instance.getShapeAABBox(bbox); _ShapeInstances[i].Instance.getShapeAABBox(bbox);
CVector bbox_min; CVector bbox_min;
CVector bbox_max; CVector bbox_max;

@ -1036,7 +1036,8 @@ void CPatchManager::executeBatchFile()
if (!LoginPassword.empty()) if (!LoginPassword.empty())
{ {
arguments.push_back(LoginPassword); // encode password in hexadecimal to avoid invalid characters on command-line
arguments.push_back("0x" + toHexa(LoginPassword));
if (!r2Mode) if (!r2Mode)
{ {

@ -25,6 +25,11 @@
#include "nel/misc/cmd_args.h" #include "nel/misc/cmd_args.h"
#include <steam_api.h> #include <steam_api.h>
#include <isteamutils.h>
#ifdef DEBUG_NEW
#define new DEBUG_NEW
#endif
// prototypes definitions for Steam API functions we'll call // prototypes definitions for Steam API functions we'll call
typedef bool (__cdecl *SteamAPI_InitFuncPtr)(); typedef bool (__cdecl *SteamAPI_InitFuncPtr)();
@ -222,18 +227,8 @@ public:
// if expired or error, ticket is not available // if expired or error, ticket is not available
if (!_AuthSessionTicketCallbackCalled || _AuthSessionTicketCallbackError || _AuthSessionTicketCallbackTimeout) return ""; if (!_AuthSessionTicketCallbackCalled || _AuthSessionTicketCallbackError || _AuthSessionTicketCallbackTimeout) return "";
std::string authSessionTicket;
// optimize string by allocating the final string size
authSessionTicket.reserve(_AuthSessionTicketSize*2);
// convert buffer to hexadecimal string // convert buffer to hexadecimal string
for (uint32 i = 0; i < _AuthSessionTicketSize; ++i) return NLMISC::toHexa(_AuthSessionTicketData, _AuthSessionTicketSize);
{
authSessionTicket += NLMISC::toString("%02x", _AuthSessionTicketData[i]);
}
return authSessionTicket;
} }
private: private:

@ -560,17 +560,6 @@ inline CLFECOMMON::TCoord getAbsoluteCoordinateFrom64( uint64 posvalue )
}*/ }*/
inline std::string toHexaString(const std::vector<uint8> &v)
{
std::string res;
for (uint i = 0; i < v.size(); i++)
{
res += NLMISC::toString("%x",v[i]);
}
return res;
}
#endif // NL_ENTITY_TYPES_H #endif // NL_ENTITY_TYPES_H
/* End of entity_types.h */ /* End of entity_types.h */

Loading…
Cancel
Save