Merge with develop
This commit is contained in:
parent
63a6f0f837
commit
df6397132f
8 changed files with 378 additions and 221 deletions
|
@ -375,6 +375,10 @@ IF(WITH_QT5)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)
|
SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core)
|
||||||
|
|
||||||
|
IF(WIN32)
|
||||||
|
SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::WinExtras)
|
||||||
|
ENDIF()
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ELSE()
|
ELSE()
|
||||||
MESSAGE(WARNING "Unable to find Qt 5")
|
MESSAGE(WARNING "Unable to find Qt 5")
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include "nel/misc/config_file.h"
|
#include "nel/misc/config_file.h"
|
||||||
#include "nel/misc/file.h"
|
#include "nel/misc/file.h"
|
||||||
|
#include "nel/misc/path.h"
|
||||||
#include "nel/misc/bitmap.h"
|
#include "nel/misc/bitmap.h"
|
||||||
#include "nel/misc/block_memory.h"
|
#include "nel/misc/block_memory.h"
|
||||||
#include "nel/misc/i_xml.h"
|
#include "nel/misc/i_xml.h"
|
||||||
|
@ -35,15 +36,6 @@
|
||||||
|
|
||||||
#include "nel/3d/scene_group.h"
|
#include "nel/3d/scene_group.h"
|
||||||
|
|
||||||
#ifdef NL_OS_WINDOWS
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <dirent.h> /* for directories functions */
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h> /* getcwd, chdir -- replacement for getCurDiretory & setCurDirectory on windows */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -132,75 +124,6 @@ struct CZoneLimits
|
||||||
sint32 _ZoneMaxY;
|
sint32 _ZoneMaxY;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
#ifdef NL_OS_WINDOWS // win32 code
|
|
||||||
void dir (const string &sFilter, vector<string> &sAllFiles, bool bFullPath)
|
|
||||||
{
|
|
||||||
WIN32_FIND_DATA findData;
|
|
||||||
HANDLE hFind;
|
|
||||||
char sCurDir[MAX_PATH];
|
|
||||||
sAllFiles.clear ();
|
|
||||||
GetCurrentDirectory (MAX_PATH, sCurDir);
|
|
||||||
hFind = FindFirstFile (("*"+sFilter).c_str(), &findData);
|
|
||||||
while (hFind != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
DWORD res = GetFileAttributes(findData.cFileName);
|
|
||||||
if (res != INVALID_FILE_ATTRIBUTES && !(res&FILE_ATTRIBUTE_DIRECTORY))
|
|
||||||
{
|
|
||||||
if (bFullPath)
|
|
||||||
sAllFiles.push_back(string(sCurDir) + "\\" + findData.cFileName);
|
|
||||||
else
|
|
||||||
sAllFiles.push_back(findData.cFileName);
|
|
||||||
}
|
|
||||||
if (FindNextFile (hFind, &findData) == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
FindClose (hFind);
|
|
||||||
}
|
|
||||||
|
|
||||||
void getcwd (char *dir, int length)
|
|
||||||
{
|
|
||||||
GetCurrentDirectoryA (length, dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
void chdir(const char *path)
|
|
||||||
{
|
|
||||||
SetCurrentDirectoryA (path);
|
|
||||||
}
|
|
||||||
|
|
||||||
#else // posix version of the void dir(...) function.
|
|
||||||
void dir (const string &sFilter, vector<string> &sAllFiles, bool bFullPath)
|
|
||||||
{
|
|
||||||
char sCurDir[MAX_PATH];
|
|
||||||
DIR* dp = NULL;
|
|
||||||
struct dirent *dirp= NULL;
|
|
||||||
|
|
||||||
getcwd ( sCurDir, MAX_PATH ) ;
|
|
||||||
sAllFiles.clear ();
|
|
||||||
if ( (dp = opendir( sCurDir )) == NULL)
|
|
||||||
{
|
|
||||||
string sTmp = string("ERROR : Can't open the dir : \"")+string(sCurDir)+string("\"") ;
|
|
||||||
outString ( sTmp ) ;
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( (dirp = readdir(dp)) != NULL)
|
|
||||||
{
|
|
||||||
std:string sFileName = std::string(dirp->d_name) ;
|
|
||||||
if (sFileName.substr((sFileName.length()-sFilter.length()),sFilter.length()).find(sFilter)!= std::string::npos )
|
|
||||||
{
|
|
||||||
if (bFullPath)
|
|
||||||
sAllFiles.push_back(string(sCurDir) + "/" + sFileName);
|
|
||||||
else
|
|
||||||
sAllFiles.push_back(sFileName);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
closedir(dp);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
CZoneRegion *loadLand (const string &filename)
|
CZoneRegion *loadLand (const string &filename)
|
||||||
{
|
{
|
||||||
|
@ -219,21 +142,19 @@ CZoneRegion *loadLand (const string &filename)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string sTmp = string("Can't open the land file : ") + filename;
|
outString (toString("Can't open the land files: %s", filename.c_str()));
|
||||||
outString (sTmp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Exception& e)
|
catch (const Exception& e)
|
||||||
{
|
{
|
||||||
string sTmp = string("Error in land file : ") + e.what();
|
outString(toString("Error in land file: %s", e.what()));
|
||||||
outString (sTmp);
|
|
||||||
}
|
}
|
||||||
return ZoneRegion;
|
return ZoneRegion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
CInstanceGroup* LoadInstanceGroup (const char* sFilename)
|
CInstanceGroup* LoadInstanceGroup (const std::string &sFilename)
|
||||||
{
|
{
|
||||||
CIFile file;
|
CIFile file;
|
||||||
CInstanceGroup *newIG = new CInstanceGroup;
|
CInstanceGroup *newIG = new CInstanceGroup;
|
||||||
|
@ -260,7 +181,7 @@ CInstanceGroup* LoadInstanceGroup (const char* sFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ***************************************************************************
|
// ***************************************************************************
|
||||||
void SaveInstanceGroup (const char* sFilename, CInstanceGroup *pIG)
|
void SaveInstanceGroup (const std::string &sFilename, CInstanceGroup *pIG)
|
||||||
{
|
{
|
||||||
COFile file;
|
COFile file;
|
||||||
|
|
||||||
|
@ -272,14 +193,12 @@ void SaveInstanceGroup (const char* sFilename, CInstanceGroup *pIG)
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
string stTmp = string(e.what()) ;
|
outString(e.what());
|
||||||
outString( stTmp );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string stTemp = string("Couldn't create ") + string(sFilename) ;
|
outString(toString("Couldn't create %s", sFilename.c_str()));
|
||||||
outString( stTemp );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -325,8 +244,7 @@ int main(int nNbArg, char**ppArgs)
|
||||||
new CApplicationContext();
|
new CApplicationContext();
|
||||||
|
|
||||||
NL3D_BlockMemoryAssertOnPurge = false;
|
NL3D_BlockMemoryAssertOnPurge = false;
|
||||||
char sCurDir[MAX_PATH];
|
std::string sCurDir = CPath::getCurrentPath();
|
||||||
getcwd (sCurDir, MAX_PATH);
|
|
||||||
|
|
||||||
if (nNbArg != 2)
|
if (nNbArg != 2)
|
||||||
{
|
{
|
||||||
|
@ -386,17 +304,14 @@ int main(int nNbArg, char**ppArgs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string sTmp = string("Couldn't not open ")+string(options.HeightMapFile1)
|
outString(toString("Couldn't not open %s: heightmap 1 map ignored", options.HeightMapFile1.c_str()));
|
||||||
+string(" : heightmap 1 map ignored");
|
|
||||||
outString(sTmp);
|
|
||||||
delete HeightMap1;
|
delete HeightMap1;
|
||||||
HeightMap1 = NULL;
|
HeightMap1 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
string sTmp = string("Cant load height map : ") + options.HeightMapFile1 + " : " + e.what();
|
outString(toString("Cant load height map : %s : %s", options.HeightMapFile1.c_str(), e.what()));
|
||||||
outString (sTmp);
|
|
||||||
delete HeightMap1;
|
delete HeightMap1;
|
||||||
HeightMap1 = NULL;
|
HeightMap1 = NULL;
|
||||||
}
|
}
|
||||||
|
@ -414,33 +329,37 @@ int main(int nNbArg, char**ppArgs)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string sTmp = string("Couldn't not open ")+string(options.HeightMapFile2)
|
outString(toString("Couldn't not open %s: heightmap 2 map ignored", options.HeightMapFile2.c_str()));
|
||||||
+string(" : heightmap 2 map ignored\n");
|
|
||||||
outString(sTmp);
|
|
||||||
delete HeightMap2;
|
delete HeightMap2;
|
||||||
HeightMap2 = NULL;
|
HeightMap2 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (const Exception &e)
|
catch (const Exception &e)
|
||||||
{
|
{
|
||||||
string sTmp = string("Cant load height map : ") + options.HeightMapFile2 + " : " + e.what() + "\n";
|
outString (string("Cant load height map : ") + options.HeightMapFile2 + " : " + e.what() + "\n");
|
||||||
outString (sTmp);
|
|
||||||
delete HeightMap2;
|
delete HeightMap2;
|
||||||
HeightMap1 = NULL;
|
HeightMap1 = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all files
|
// get all files
|
||||||
|
vector<string> vAllFilesUnfiltered;
|
||||||
|
CPath::getPathContent(options.InputIGDir, false, false, true, vAllFilesUnfiltered);
|
||||||
|
|
||||||
|
// keep only .ig files
|
||||||
vector<string> vAllFiles;
|
vector<string> vAllFiles;
|
||||||
chdir (options.InputIGDir.c_str());
|
for(uint i = 0, len = (uint)vAllFilesUnfiltered.size(); i < len; ++i)
|
||||||
dir (".ig", vAllFiles, false);
|
{
|
||||||
chdir (sCurDir);
|
if (toLower(CFile::getExtension(vAllFilesUnfiltered[i])) == "ig")
|
||||||
|
{
|
||||||
|
vAllFiles.push_back(vAllFilesUnfiltered[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (uint32 i = 0; i < vAllFiles.size(); ++i)
|
for (uint32 i = 0; i < vAllFiles.size(); ++i)
|
||||||
{
|
{
|
||||||
chdir (options.InputIGDir.c_str());
|
CInstanceGroup *pIG = LoadInstanceGroup (CPath::standardizePath(options.InputIGDir) + vAllFiles[i]);
|
||||||
CInstanceGroup *pIG = LoadInstanceGroup (vAllFiles[i].c_str());
|
|
||||||
chdir (sCurDir);
|
|
||||||
if (pIG != NULL)
|
if (pIG != NULL)
|
||||||
{
|
{
|
||||||
bool realTimeSunContribution = pIG->getRealTimeSunContribution();
|
bool realTimeSunContribution = pIG->getRealTimeSunContribution();
|
||||||
|
@ -511,10 +430,8 @@ int main(int nNbArg, char**ppArgs)
|
||||||
pIGout->build (vGlobalPos, IA, Clusters, Portals, PLN);
|
pIGout->build (vGlobalPos, IA, Clusters, Portals, PLN);
|
||||||
pIGout->enableRealTimeSunContribution(realTimeSunContribution);
|
pIGout->enableRealTimeSunContribution(realTimeSunContribution);
|
||||||
|
|
||||||
|
SaveInstanceGroup (CPath::standardizePath(options.OutputIGDir) + vAllFiles[i], pIGout);
|
||||||
|
|
||||||
chdir (options.OutputIGDir.c_str());
|
|
||||||
SaveInstanceGroup (vAllFiles[i].c_str(), pIGout);
|
|
||||||
chdir (sCurDir);
|
|
||||||
delete pIG;
|
delete pIG;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,12 @@ struct CUTMiscStringCommon : public Test::Suite
|
||||||
TEST_ADD(CUTMiscStringCommon::fromStringUint16);
|
TEST_ADD(CUTMiscStringCommon::fromStringUint16);
|
||||||
TEST_ADD(CUTMiscStringCommon::fromStringSint32);
|
TEST_ADD(CUTMiscStringCommon::fromStringSint32);
|
||||||
TEST_ADD(CUTMiscStringCommon::fromStringUint32);
|
TEST_ADD(CUTMiscStringCommon::fromStringUint32);
|
||||||
|
TEST_ADD(CUTMiscStringCommon::fromStringSint64);
|
||||||
|
TEST_ADD(CUTMiscStringCommon::fromStringUint64);
|
||||||
|
TEST_ADD(CUTMiscStringCommon::fromStringFloat);
|
||||||
|
TEST_ADD(CUTMiscStringCommon::fromStringDouble);
|
||||||
|
TEST_ADD(CUTMiscStringCommon::fromStringBool);
|
||||||
|
|
||||||
// Add a line here when adding a new test METHOD
|
// Add a line here when adding a new test METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,6 +409,322 @@ struct CUTMiscStringCommon : public Test::Suite
|
||||||
ret = NLMISC::fromString("+1", val);
|
ret = NLMISC::fromString("+1", val);
|
||||||
TEST_ASSERT(ret && val == 1);
|
TEST_ASSERT(ret && val == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fromStringSint64()
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
// tests for sint64
|
||||||
|
sint64 val;
|
||||||
|
|
||||||
|
// positive value
|
||||||
|
ret = NLMISC::fromString("1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// negative value
|
||||||
|
ret = NLMISC::fromString("-1", val);
|
||||||
|
TEST_ASSERT(ret && val == -1);
|
||||||
|
|
||||||
|
// bad character
|
||||||
|
ret = NLMISC::fromString("a", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// right character and bad character
|
||||||
|
ret = NLMISC::fromString("1a", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// min limit
|
||||||
|
ret = NLMISC::fromString("-9223372036854775808", val);
|
||||||
|
TEST_ASSERT(ret && val == LLONG_MIN);
|
||||||
|
|
||||||
|
// max limit
|
||||||
|
ret = NLMISC::fromString("9223372036854775807", val);
|
||||||
|
TEST_ASSERT(ret && val == LLONG_MAX);
|
||||||
|
|
||||||
|
// min limit -1
|
||||||
|
ret = NLMISC::fromString("-9223372036854775809", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// max limit +1
|
||||||
|
ret = NLMISC::fromString("9223372036854775808", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// with period
|
||||||
|
ret = NLMISC::fromString("1.2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with coma
|
||||||
|
ret = NLMISC::fromString("1,2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with spaces before
|
||||||
|
ret = NLMISC::fromString(" 10", val);
|
||||||
|
TEST_ASSERT(ret && val == 10);
|
||||||
|
|
||||||
|
// with spaces after
|
||||||
|
ret = NLMISC::fromString("10 ", val);
|
||||||
|
TEST_ASSERT(ret && val == 10);
|
||||||
|
|
||||||
|
// with 0s before
|
||||||
|
ret = NLMISC::fromString("001", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with + before
|
||||||
|
ret = NLMISC::fromString("+1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fromStringUint64()
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
// tests for uint64
|
||||||
|
uint64 val;
|
||||||
|
|
||||||
|
// positive value
|
||||||
|
ret = NLMISC::fromString("1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// bad character
|
||||||
|
ret = NLMISC::fromString("a", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// right character and bad character
|
||||||
|
ret = NLMISC::fromString("1a", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// min limit
|
||||||
|
ret = NLMISC::fromString("0", val);
|
||||||
|
TEST_ASSERT(ret && val == 0);
|
||||||
|
|
||||||
|
// max limit
|
||||||
|
ret = NLMISC::fromString("4294967295", val);
|
||||||
|
TEST_ASSERT(ret && val == 4294967295);
|
||||||
|
|
||||||
|
// min limit -1
|
||||||
|
ret = NLMISC::fromString("-1", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// max limit +1
|
||||||
|
ret = NLMISC::fromString("4294967296", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// with period
|
||||||
|
ret = NLMISC::fromString("1.2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with coma
|
||||||
|
ret = NLMISC::fromString("1,2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with spaces before
|
||||||
|
ret = NLMISC::fromString(" 10", val);
|
||||||
|
TEST_ASSERT(ret && val == 10);
|
||||||
|
|
||||||
|
// with spaces after
|
||||||
|
ret = NLMISC::fromString("10 ", val);
|
||||||
|
TEST_ASSERT(ret && val == 10);
|
||||||
|
|
||||||
|
// with 0s before
|
||||||
|
ret = NLMISC::fromString("001", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with + before
|
||||||
|
ret = NLMISC::fromString("+1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fromStringFloat()
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
// tests for float
|
||||||
|
float val;
|
||||||
|
|
||||||
|
// positive value
|
||||||
|
ret = NLMISC::fromString("1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// negative value
|
||||||
|
ret = NLMISC::fromString("-1", val);
|
||||||
|
TEST_ASSERT(ret && val == -1);
|
||||||
|
|
||||||
|
// bad character
|
||||||
|
ret = NLMISC::fromString("a", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// right character and bad character
|
||||||
|
ret = NLMISC::fromString("1a", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// min limit
|
||||||
|
ret = NLMISC::fromString("-2147483648", val);
|
||||||
|
TEST_ASSERT(ret && val == INT_MIN);
|
||||||
|
|
||||||
|
// max limit
|
||||||
|
ret = NLMISC::fromString("2147483647", val);
|
||||||
|
TEST_ASSERT(ret && val == INT_MAX);
|
||||||
|
|
||||||
|
// min limit -1
|
||||||
|
ret = NLMISC::fromString("-2147483649", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// max limit +1
|
||||||
|
ret = NLMISC::fromString("2147483648", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// with period
|
||||||
|
ret = NLMISC::fromString("1.2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with coma
|
||||||
|
ret = NLMISC::fromString("1,2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with spaces before
|
||||||
|
ret = NLMISC::fromString(" 10", val);
|
||||||
|
TEST_ASSERT(ret && val == 10);
|
||||||
|
|
||||||
|
// with spaces after
|
||||||
|
ret = NLMISC::fromString("10 ", val);
|
||||||
|
TEST_ASSERT(ret && val == 10);
|
||||||
|
|
||||||
|
// with 0s before
|
||||||
|
ret = NLMISC::fromString("001", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
|
||||||
|
// with + before
|
||||||
|
ret = NLMISC::fromString("+1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fromStringDouble()
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
// tests for double
|
||||||
|
double val;
|
||||||
|
|
||||||
|
// positive value
|
||||||
|
ret = NLMISC::fromString("1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1.0);
|
||||||
|
|
||||||
|
// negative value
|
||||||
|
ret = NLMISC::fromString("-1", val);
|
||||||
|
TEST_ASSERT(ret && val == -1.0);
|
||||||
|
|
||||||
|
// bad character
|
||||||
|
ret = NLMISC::fromString("a", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0);
|
||||||
|
|
||||||
|
// right character and bad character
|
||||||
|
ret = NLMISC::fromString("1a", val);
|
||||||
|
TEST_ASSERT(ret && val == 1.0);
|
||||||
|
|
||||||
|
// min limit
|
||||||
|
ret = NLMISC::fromString("2.2250738585072014e-308", val);
|
||||||
|
TEST_ASSERT(ret && val == DBL_MIN);
|
||||||
|
|
||||||
|
// max limit
|
||||||
|
ret = NLMISC::fromString("1.7976931348623158e+308", val);
|
||||||
|
TEST_ASSERT(ret && val == DBL_MAX);
|
||||||
|
|
||||||
|
// min limit -1
|
||||||
|
ret = NLMISC::fromString("3e-408", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0.0);
|
||||||
|
|
||||||
|
// max limit +1
|
||||||
|
ret = NLMISC::fromString("2e+308", val);
|
||||||
|
TEST_ASSERT(!ret && val == 0.0);
|
||||||
|
|
||||||
|
// with period
|
||||||
|
ret = NLMISC::fromString("1.2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1.2);
|
||||||
|
|
||||||
|
// with coma
|
||||||
|
ret = NLMISC::fromString("1,2", val);
|
||||||
|
TEST_ASSERT(ret && val == 1.0);
|
||||||
|
|
||||||
|
// with spaces before
|
||||||
|
ret = NLMISC::fromString(" 10", val);
|
||||||
|
TEST_ASSERT(ret && val == 10.0);
|
||||||
|
|
||||||
|
// with spaces after
|
||||||
|
ret = NLMISC::fromString("10 ", val);
|
||||||
|
TEST_ASSERT(ret && val == 10.0);
|
||||||
|
|
||||||
|
// with 0s before
|
||||||
|
ret = NLMISC::fromString("001", val);
|
||||||
|
TEST_ASSERT(ret && val == 1.0);
|
||||||
|
|
||||||
|
// with + before
|
||||||
|
ret = NLMISC::fromString("+1", val);
|
||||||
|
TEST_ASSERT(ret && val == 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fromStringBool()
|
||||||
|
{
|
||||||
|
bool ret;
|
||||||
|
|
||||||
|
// tests for bool
|
||||||
|
bool val;
|
||||||
|
|
||||||
|
// true value
|
||||||
|
ret = NLMISC::fromString("1", val);
|
||||||
|
TEST_ASSERT(ret && val);
|
||||||
|
|
||||||
|
// false value
|
||||||
|
ret = NLMISC::fromString("0", val);
|
||||||
|
TEST_ASSERT(ret && !val);
|
||||||
|
|
||||||
|
// bad character
|
||||||
|
ret = NLMISC::fromString("a", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// right character and bad character
|
||||||
|
ret = NLMISC::fromString("1a", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// min limit
|
||||||
|
ret = NLMISC::fromString("-2147483648", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// max limit
|
||||||
|
ret = NLMISC::fromString("2147483647", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// min limit -1
|
||||||
|
ret = NLMISC::fromString("-2147483649", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// max limit +1
|
||||||
|
ret = NLMISC::fromString("2147483648", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// with period
|
||||||
|
ret = NLMISC::fromString("1.2", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// with coma
|
||||||
|
ret = NLMISC::fromString("1,2", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// with spaces before
|
||||||
|
ret = NLMISC::fromString(" 10", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// with spaces after
|
||||||
|
ret = NLMISC::fromString("10 ", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// with 0s before
|
||||||
|
ret = NLMISC::fromString("001", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
|
||||||
|
// with + before
|
||||||
|
ret = NLMISC::fromString("+1", val);
|
||||||
|
TEST_ASSERT(!ret && val);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1068,7 +1068,7 @@ NLMISC_COMMAND(accessPowo, "give access to the powo", "<uid> player_name number"
|
||||||
sint32 cell;
|
sint32 cell;
|
||||||
buildingPlayer->addUser(c, 0, ownerId, cell);
|
buildingPlayer->addUser(c, 0, ownerId, cell);
|
||||||
// c->setPowoCell(cell);
|
// c->setPowoCell(cell);
|
||||||
CBuildingManager::getInstance()->setRoomLifeTime(cell, TGameCycle(NLMISC::TGameTime(4*60*60) / CTickEventHandler::getGameTimeStep()));
|
// CBuildingManager::getInstance()->setRoomLifeTime(cell, TGameCycle(NLMISC::TGameTime(4*60*60) / CTickEventHandler::getGameTimeStep()));
|
||||||
log.displayNL("%d", cell);
|
log.displayNL("%d", cell);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -146,7 +146,6 @@
|
||||||
#include "modules/client_command_forwarder.h"
|
#include "modules/client_command_forwarder.h"
|
||||||
#include "server_share/log_character_gen.h"
|
#include "server_share/log_character_gen.h"
|
||||||
#include "server_share/log_item_gen.h"
|
#include "server_share/log_item_gen.h"
|
||||||
#include "server_share/mongo_wrapper.h"
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// USING //
|
// USING //
|
||||||
|
|
|
@ -842,7 +842,7 @@ void CFeReceiveSub::handleReceivedMsg( CClientHost *clienthost )
|
||||||
{
|
{
|
||||||
// The client has neither been authenticated nor provided a user id, but is allowed to connect (dev mode)
|
// The client has neither been authenticated nor provided a user id, but is allowed to connect (dev mode)
|
||||||
nlinfo ("%s using AutoAllocUserid", _CurrentInMsg->AddrFrom.asString().c_str() );
|
nlinfo ("%s using AutoAllocUserid", _CurrentInMsg->AddrFrom.asString().c_str() );
|
||||||
string filename = CPath::standardizePath( SaveShardRoot.get() ) + CPath::standardizePath( IService::getInstance()->SaveFilesDirectory.get() ) + "auto_uid_map.bin";
|
string filename = CPath::standardizePath( SaveShardRootGameShare.get() ) + CPath::standardizePath( IService::getInstance()->SaveFilesDirectory.get() ) + "auto_uid_map.bin";
|
||||||
|
|
||||||
// Get previously allocated user ids
|
// Get previously allocated user ids
|
||||||
if ( _AutoUidMap.empty() )
|
if ( _AutoUidMap.empty() )
|
||||||
|
|
|
@ -45,9 +45,6 @@ extern CGenericXmlMsgHeaderManager GenericXmlMsgHeaderMngr;
|
||||||
|
|
||||||
extern CVariable<bool> VerboseChatManagement;
|
extern CVariable<bool> VerboseChatManagement;
|
||||||
|
|
||||||
typedef NLMISC::CTwinMap<TChanID, string> TChanTwinMap;
|
|
||||||
extern TChanTwinMap _ChanNames;
|
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
// cbImpulsionReadyString :
|
// cbImpulsionReadyString :
|
||||||
|
@ -1587,26 +1584,15 @@ void cbDynChatAddChan(CMessage& msgin, const string &serviceName, TServiceId ser
|
||||||
bool noBroadcast;
|
bool noBroadcast;
|
||||||
bool forwardInput;
|
bool forwardInput;
|
||||||
bool unify;
|
bool unify;
|
||||||
string name;
|
|
||||||
|
|
||||||
msgin.serial(chanID);
|
msgin.serial(chanID);
|
||||||
msgin.serial(noBroadcast);
|
msgin.serial(noBroadcast);
|
||||||
msgin.serial(forwardInput);
|
msgin.serial(forwardInput);
|
||||||
msgin.serial(unify);
|
msgin.serial(unify);
|
||||||
msgin.serial(name);
|
nlinfo("cbDynChatAddChan: add channel");
|
||||||
|
|
||||||
nlinfo("cbDynChatAddChan: add channel : %s", name.c_str());
|
|
||||||
bool res = IOS->getChatManager().getDynChat().addChan(chanID, noBroadcast, forwardInput, unify);
|
bool res = IOS->getChatManager().getDynChat().addChan(chanID, noBroadcast, forwardInput, unify);
|
||||||
if (!res)
|
if (!res) nlwarning("Couldn't add chan %s", chanID.toString().c_str());
|
||||||
nlwarning("Couldn't add chan %s", chanID.toString().c_str());
|
else nlinfo("cbDynChatAddChan: add channel %s",chanID.toString().c_str());
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_ChanNames.getA(name) == NULL && _ChanNames.getB(chanID) == NULL)
|
|
||||||
_ChanNames.add(chanID, name);
|
|
||||||
else
|
|
||||||
nlwarning("Couldn't add chan %s. already added! %p %p", chanID.toString().c_str(), _ChanNames.getA(name), _ChanNames.getB(chanID));
|
|
||||||
nlinfo("cbDynChatAddChan: add channel %s",chanID.toString().c_str());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
@ -1816,23 +1802,7 @@ void cbDynChatSetHideBubble(CMessage& msgin, const string &serviceName, TService
|
||||||
chan->HideBubble = hideBubble;
|
chan->HideBubble = hideBubble;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cbDynChatSetUniversalChannel(CMessage& msgin, const string &serviceName, TServiceId serviceId)
|
|
||||||
{
|
|
||||||
TChanID chanID;
|
|
||||||
bool universalChannel;
|
|
||||||
|
|
||||||
msgin.serial(chanID);
|
|
||||||
msgin.serial(universalChannel);
|
|
||||||
|
|
||||||
CChatManager &cm = IOS->getChatManager();
|
|
||||||
CDynChatChan *chan = cm.getDynChat().getChan(chanID);
|
|
||||||
if (!chan)
|
|
||||||
{
|
|
||||||
nlwarning("Unknown chan");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
chan->UniversalChannel = universalChannel;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cbDynChatServiceChat(CMessage& msgin, const string &serviceName, TServiceId serviceId)
|
void cbDynChatServiceChat(CMessage& msgin, const string &serviceName, TServiceId serviceId)
|
||||||
{
|
{
|
||||||
|
@ -2102,7 +2072,6 @@ TUnifiedCallbackItem CbIOSArray[]=
|
||||||
{ "DYN_CHAT:SERVICE_CHAT", cbDynChatServiceChat }, // a service send a chat message in the channel without sender id
|
{ "DYN_CHAT:SERVICE_CHAT", cbDynChatServiceChat }, // a service send a chat message in the channel without sender id
|
||||||
{ "DYN_CHAT:SERVICE_TELL", cbDynChatServiceTell }, // a service send a chat message to a specific client in the channel without sender id
|
{ "DYN_CHAT:SERVICE_TELL", cbDynChatServiceTell }, // a service send a chat message to a specific client in the channel without sender id
|
||||||
{ "DYN_CHAT:SET_HIDE_BUBBLE", cbDynChatSetHideBubble }, // a service send a chat message to a specific client in the channel without sender id
|
{ "DYN_CHAT:SET_HIDE_BUBBLE", cbDynChatSetHideBubble }, // a service send a chat message to a specific client in the channel without sender id
|
||||||
{ "DYN_CHAT:SET_UNIVERSAL_CHANNEL", cbDynChatSetUniversalChannel },
|
|
||||||
//received from DSS
|
//received from DSS
|
||||||
{ "REQUEST_DSR", cbRequestDsr},
|
{ "REQUEST_DSR", cbRequestDsr},
|
||||||
// { "ADD_DM", cbAddDM }, // A character enter a ring session that he own
|
// { "ADD_DM", cbAddDM }, // A character enter a ring session that he own
|
||||||
|
|
|
@ -246,60 +246,6 @@ void CStringManager::clearCache(NLMISC::CLog *log)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// load the values using the george sheet
|
|
||||||
void CStringManager::TSheetInfo::readGeorges (const NLMISC::CSmartPtr<NLGEORGES::UForm> &form, const NLMISC::CSheetId &sheetId)
|
|
||||||
{
|
|
||||||
if (form)
|
|
||||||
{
|
|
||||||
SheetName = sheetId.toString();
|
|
||||||
|
|
||||||
std::string ext = NLMISC::CSheetId::fileExtensionFromType(sheetId.getSheetType());
|
|
||||||
|
|
||||||
SheetName = SheetName.substr(0, SheetName.find(ext));
|
|
||||||
// remove ending '.'
|
|
||||||
if (!SheetName.empty() && *SheetName.rbegin() == '.')
|
|
||||||
SheetName.resize(SheetName.size()-1);
|
|
||||||
|
|
||||||
std::string gender;
|
|
||||||
|
|
||||||
if (sheetId.getSheetType() == NLMISC::CSheetId::typeFromFileExtension("creature"))
|
|
||||||
{
|
|
||||||
form->getRootNode ().getValueByName (gender, "Basics.Gender");
|
|
||||||
sint genderId;
|
|
||||||
NLMISC::fromString(gender, genderId);
|
|
||||||
Gender = GSGENDER::EGender(genderId);
|
|
||||||
|
|
||||||
form->getRootNode ().getValueByName (Race, "Basics.Race");
|
|
||||||
|
|
||||||
// form->getRootNode ().getValueByName (DisplayName, "Basics.First Name");
|
|
||||||
// std::string s;
|
|
||||||
// form->getRootNode ().getValueByName (s, "Basics.CharacterName");
|
|
||||||
// if (!DisplayName.empty())
|
|
||||||
// DisplayName+=' ';
|
|
||||||
// DisplayName+=s;
|
|
||||||
|
|
||||||
form->getRootNode ().getValueByName (Profile, "Basics.Profile");
|
|
||||||
form->getRootNode ().getValueByName (ChatProfile, "Basics.ChatProfile");
|
|
||||||
}
|
|
||||||
else if (sheetId.getSheetType() == NLMISC::CSheetId::typeFromFileExtension("race_stats"))
|
|
||||||
{
|
|
||||||
form->getRootNode ().getValueByName (Race, "Race");
|
|
||||||
}
|
|
||||||
/* else if (sheetId.getType() == NLMISC::CSheetId::typeFromFileExtension("sitem"))
|
|
||||||
{
|
|
||||||
// read any item specific data
|
|
||||||
}
|
|
||||||
*/ else
|
|
||||||
{
|
|
||||||
nlwarning("CStringManager::TEntityInfo : Do not know the type of the sheet '%s'.", sheetId.toString().c_str());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const CStringManager::CEntityWords &CStringManager::getEntityWords(TLanguages lang, STRING_MANAGER::TParamType type) const
|
const CStringManager::CEntityWords &CStringManager::getEntityWords(TLanguages lang, STRING_MANAGER::TParamType type) const
|
||||||
{
|
{
|
||||||
nlassert(lang < NB_LANGUAGES);
|
nlassert(lang < NB_LANGUAGES);
|
||||||
|
|
Loading…
Reference in a new issue