Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
kervala 2015-12-17 13:04:56 +01:00
commit 1e9092a385
3 changed files with 255 additions and 250 deletions

View file

@ -122,7 +122,7 @@ int main(int argc, char* argv[])
std::string _Path_Input_TexBases; std::string _Path_Input_TexBases;
std::string _Path_Input_Masks; std::string _Path_Input_Masks;
std::string _Path_Output_MaksOptimized; std::string _Path_Output_MasksOptimized;
std::string _Path_Output_Gtm; std::string _Path_Output_Gtm;
std::string _Path_Output_Cgi; std::string _Path_Output_Cgi;
@ -162,10 +162,10 @@ int main(int argc, char* argv[])
{ {
} }
/// repertory output of masks optimized created /// optimized masks output directory created
try try
{ {
_Path_Output_MaksOptimized = NLMISC::CPath::standardizePath(cf.getVar ("output_path_mask_optimized").asString()); _Path_Output_MasksOptimized = NLMISC::CPath::standardizePath(cf.getVar ("output_path_mask_optimized").asString());
} }
catch (const NLMISC::EUnknownVar &) catch (const NLMISC::EUnknownVar &)
{ {
@ -192,8 +192,7 @@ int main(int argc, char* argv[])
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
nlwarning("Panoply building failed."); nlerror("Panoply building failed: %s", e.what());
nlwarning(e.what());
return -1; return -1;
} }
@ -203,7 +202,7 @@ int main(int argc, char* argv[])
{ {
CInfoMaskGeneration infoMaskGen(_Path_Input_TexBases, CInfoMaskGeneration infoMaskGen(_Path_Input_TexBases,
_Path_Input_Masks, _Path_Input_Masks,
_Path_Output_MaksOptimized, _Path_Output_MasksOptimized,
_Path_Output_Gtm, _Path_Output_Gtm,
argv[3], argv[3],
1); 1);
@ -228,7 +227,7 @@ int main(int argc, char* argv[])
if (argc != 2) if (argc != 2)
{ {
nlwarning("usage : %s [config_file name]", argv[0]); nlinfo("Usage : %s [config_file name]", argv[0]);
return -1; return -1;
} }
@ -349,8 +348,7 @@ int main(int argc, char* argv[])
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
nlwarning("Panoply building failed."); nlerror("Panoply building failed: %s", e.what());
nlwarning(e.what());
return -1; return -1;
} }
@ -363,7 +361,7 @@ int main(int argc, char* argv[])
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
nlwarning("Something went wrong while building bitmap : %s", e.what()); nlerror("Something went wrong while building bitmap: %s", e.what());
return -1; return -1;
} }
return 0; return 0;
@ -391,7 +389,7 @@ static void validateCgiInfo()
} }
catch(const std::exception &e) catch(const std::exception &e)
{ {
nlwarning("Panoply building failed."); nlerror("Panoply building failed: %s", e.what());
} }
uint16 a = temp.size(); uint16 a = temp.size();
@ -455,7 +453,7 @@ static void BuildColoredVersions(const CBuildInfo &bi)
{ {
if (!NLMISC::CFile::isExists(bi.InputPath)) if (!NLMISC::CFile::isExists(bi.InputPath))
{ {
nlwarning(("Path not found : " + bi.InputPath).c_str()); nlerror("Path not found: %s", bi.InputPath.c_str());
return; return;
} }
for(uint sizeVersion= 0; sizeVersion<2; sizeVersion++) for(uint sizeVersion= 0; sizeVersion<2; sizeVersion++)
@ -493,7 +491,7 @@ static void BuildColoredVersions(const CBuildInfo &bi)
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
nlwarning("Processing of %s failed : %s \n", files[k].c_str(), e.what()); nlerror("Processing of %s failed: %s", files[k].c_str(), e.what());
} }
} }
} }
@ -565,7 +563,7 @@ static bool CheckIfNeedRebuildColoredVersionForOneBitmap(const CBuildInfo &bi, c
// ok, can move the cache // ok, can move the cache
if (!NLMISC::CFile::moveFile(outputHLSInfo, cacheHLSInfo)) if (!NLMISC::CFile::moveFile(outputHLSInfo, cacheHLSInfo))
{ {
nlwarning(("Couldn't move " + cacheHLSInfo + " to " + outputHLSInfo).c_str()); nlerror("Couldn't move %s to %s", cacheHLSInfo.c_str(), outputHLSInfo.c_str());
return true; return true;
} }
} }
@ -595,9 +593,10 @@ static bool CheckIfNeedRebuildColoredVersionForOneBitmap(const CBuildInfo &bi, c
// get version that is in the cache // get version that is in the cache
std::string cacheDest = bi.OutputPath + outputFileName + bi.OutputFormat; std::string cacheDest = bi.OutputPath + outputFileName + bi.OutputFormat;
if (!NLMISC::CFile::moveFile(cacheDest, searchName)) if (!NLMISC::CFile::moveFile(cacheDest, searchName))
{ {
nlwarning(("Couldn't move " + searchName + " to " + cacheDest).c_str()); nlerror("Couldn't move %s to %s", searchName.c_str(), cacheDest.c_str());
return true; return true;
} }
@ -641,16 +640,19 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
actualInputPath= bi.InputPath; actualInputPath= bi.InputPath;
// load // load
std::string fullInputBitmapPath = actualInputPath + fileNameWithExtension;
NLMISC::CIFile is; NLMISC::CIFile is;
try try
{ {
if (is.open(actualInputPath + fileNameWithExtension)) if (is.open(fullInputBitmapPath))
{ {
depth = srcBitmap.load(is); depth = srcBitmap.load(is);
if (depth == 0 || srcBitmap.getPixels().empty()) if (depth == 0 || srcBitmap.getPixels().empty())
{ {
throw NLMISC::Exception(std::string("Failed to load bitmap ") + actualInputPath + fileNameWithExtension); throw NLMISC::Exception("Failed to load bitmap");
} }
if (srcBitmap.PixelFormat != NLMISC::CBitmap::RGBA) if (srcBitmap.PixelFormat != NLMISC::CBitmap::RGBA)
{ {
srcBitmap.convertToType(NLMISC::CBitmap::RGBA); srcBitmap.convertToType(NLMISC::CBitmap::RGBA);
@ -658,13 +660,13 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
} }
else else
{ {
nlwarning("Unable to open %s. Processing next", (actualInputPath + fileNameWithExtension).c_str()); nlerror("Unable to open %s. Processing next", fullInputBitmapPath.c_str());
return; return;
} }
} }
catch (const NLMISC::Exception &) catch (const NLMISC::Exception &e)
{ {
nlwarning("File or format error with : %s. Processing next...", fileNameWithExtension.c_str()); nlerror("File or format error with %s (%s). Processing next...", fullInputBitmapPath.c_str(), e.what());
return; return;
} }
} }
@ -715,13 +717,9 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
if (is.open(maskFileName)) if (is.open(maskFileName))
{ {
if (li.Mask.load(is) == 0) if (li.Mask.load(is) == 0 || li.Mask.getPixels().empty())
{ {
throw NLMISC::Exception(std::string("Failed to load mask ") + maskFileName); throw NLMISC::Exception("Failed to load mask");
}
if (li.Mask.getPixels().empty())
{
throw NLMISC::Exception(std::string("Failed to load mask ") + maskFileName);
} }
if (li.Mask.PixelFormat != NLMISC::CBitmap::RGBA) if (li.Mask.PixelFormat != NLMISC::CBitmap::RGBA)
@ -735,17 +733,18 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
{ {
throw NLMISC::Exception("Bitmap and mask do not have the same size"); throw NLMISC::Exception("Bitmap and mask do not have the same size");
} }
masks.push_back(li); masks.push_back(li);
} }
else else
{ {
nlwarning("Unable to open %s. Processing next", maskFileName.c_str()); nlerror("Unable to open %s. Processing next", maskFileName.c_str());
return; return;
} }
} }
catch (const std::exception &e) catch (const std::exception &e)
{ {
nlwarning("Error with : %s : %s. Aborting this bitmap processing", maskFileName.c_str(), e.what()); nlerror("Error with %s: %s. Aborting this bitmap processing", maskFileName.c_str(), e.what());
return; return;
} }
} }
@ -801,13 +800,15 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
// save good hlsInfo instance name // save good hlsInfo instance name
hlsTextInstance.Name = outputFileName + bi.OutputFormat; hlsTextInstance.Name = outputFileName + bi.OutputFormat;
nlwarning("Writing %s", outputFileName.c_str()); nlinfo("Writing %s", outputFileName.c_str());
/// Save the result. We let propagate exceptions (if there's no more space disk it useless to continue...) /// Save the result. We let propagate exceptions (if there's no more space disk it useless to continue...)
{ {
std::string fullOutputPath = bi.OutputPath + "/" + outputFileName + bi.OutputFormat;
try try
{ {
NLMISC::COFile os; NLMISC::COFile os;
if (os.open(bi.OutputPath + "/" + outputFileName + bi.OutputFormat)) if (os.open(fullOutputPath))
{ {
// divide by 2 when needed. // divide by 2 when needed.
if(mustDivideBy2) if(mustDivideBy2)
@ -824,12 +825,12 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
} }
else else
{ {
nlwarning(("Couldn't open " + bi.OutputPath + outputFileName + bi.OutputFormat + " for writing").c_str()); nlerror("Couldn't open %s for writing", fullOutputPath.c_str());
} }
} }
catch(const NLMISC::EStream &e) catch(const NLMISC::EStream &e)
{ {
nlwarning(("Couldn't write " + bi.OutputPath + outputFileName + bi.OutputFormat + " : " + e.what()).c_str()); nlerror("Couldn't write %s: %s", fullOutputPath.c_str(), e.what());
} }
} }
@ -853,14 +854,16 @@ static void BuildColoredVersionForOneBitmap(const CBuildInfo &bi, const std::str
} }
// **** save the TMP hlsInfo // **** save the TMP hlsInfo
std::string fullHlsInfoPath = bi.HlsInfoPath + fileName + ".hlsinfo";
NLMISC::COFile os; NLMISC::COFile os;
if (os.open(bi.HlsInfoPath + fileName + ".hlsinfo")) if (os.open(fullHlsInfoPath))
{ {
os.serial(hlsInfo); os.serial(hlsInfo);
} }
else else
{ {
nlwarning(("Couldn't write " + bi.HlsInfoPath + fileName + ".hlsinfo").c_str()); nlerror("Couldn't write %s", fullHlsInfoPath.c_str());
} }
} }

View file

@ -847,10 +847,10 @@ bool CGrpFauna::spawnPop(uint popVersion)
return false; return false;
} }
popVersion = ~0; popVersion = std::numeric_limits<uint>::max();
// if we are in a cycle. // if we are in a cycle.
if (_CurrentCycle!=~0) if (_CurrentCycle != std::numeric_limits<uint32>::max())
{ {
Cycle const& cycle = _Cycles[_CurrentCycle]; Cycle const& cycle = _Cycles[_CurrentCycle];
@ -858,26 +858,28 @@ bool CGrpFauna::spawnPop(uint popVersion)
do do
{ {
++_CurrentCycleIndex; ++_CurrentCycleIndex;
} while ( _CurrentCycleIndex<(sint32)cycle._PopList.size() }
while ( _CurrentCycleIndex<(sint32)cycle._PopList.size()
&& !_Populations[cycle._PopList[_CurrentCycleIndex]]); && !_Populations[cycle._PopList[_CurrentCycleIndex]]);
if (_CurrentCycleIndex<(sint32)cycle._PopList.size()) if (_CurrentCycleIndex<(sint32)cycle._PopList.size())
{ {
popVersion=cycle._PopList[_CurrentCycleIndex]; popVersion=cycle._PopList[_CurrentCycleIndex];
if (!timeAllowSpawn(popVersion)) if (!timeAllowSpawn(popVersion))
{ {
popVersion=~0; popVersion = std::numeric_limits<uint>::max();
} }
} }
if (popVersion==~0) if (popVersion == std::numeric_limits<uint>::max())
{ {
_CurrentCycle = ~0; _CurrentCycle = std::numeric_limits<uint32>::max();
} }
} }
// if the population version has not been specified then select one at weighted random with day/night difference. // if the population version has not been specified then select one at weighted random with day/night difference.
if (popVersion==~0) if (popVersion == std::numeric_limits<uint>::max())
{ {
uint32 totalWeight = 0; uint32 totalWeight = 0;
@ -911,9 +913,9 @@ bool CGrpFauna::spawnPop(uint popVersion)
} }
#if !FINAL_VERSION #if !FINAL_VERSION
nlassert(popVersion!=~0); nlassert(popVersion != std::numeric_limits<uint>::max());
#endif #endif
if (popVersion==~0) if (popVersion == std::numeric_limits<uint>::max())
return false; return false;
// find if we are starting a new cycle .. // find if we are starting a new cycle ..
@ -950,7 +952,7 @@ bool CGrpFauna::spawnPop(uint popVersion)
despawnGrp(); despawnGrp();
} }
nlassert(_CurPopulation!=~0); nlassert(_CurPopulation != std::numeric_limits<uint32>::max());
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
// Init the group type. // Init the group type.
@ -988,14 +990,14 @@ bool CGrpFauna::spawnPop(uint popVersion)
void CGrpFauna::despawnGrp() void CGrpFauna::despawnGrp()
{ {
CGroup::despawnGrp(); CGroup::despawnGrp();
_CurPopulation = ~0u; _CurPopulation = std::numeric_limits<uint32>::max();
} }
// reads cycle from primitive (string representation). // reads cycle from primitive (string representation).
void CGrpFauna::setCyles(std::string const& cycles) void CGrpFauna::setCyles(std::string const& cycles)
{ {
uint32 strIndex = 0; uint32 strIndex = 0;
uint32 curCycle = ~0; uint32 curCycle = std::numeric_limits<uint32>::max();
while (strIndex<cycles.size()) while (strIndex<cycles.size())
{ {
@ -1006,7 +1008,7 @@ void CGrpFauna::setCyles(std::string const& cycles)
if (carac>='a' && carac<='z') if (carac>='a' && carac<='z')
{ {
if (curCycle==~0) if (curCycle == std::numeric_limits<uint32>::max())
{ {
curCycle = (uint32)_Cycles.size(); curCycle = (uint32)_Cycles.size();
_Cycles.push_back(Cycle()); _Cycles.push_back(Cycle());
@ -1016,7 +1018,7 @@ void CGrpFauna::setCyles(std::string const& cycles)
} }
else else
{ {
curCycle = ~0; curCycle = std::numeric_limits<uint32>::max();
} }
} }
} }
@ -1024,7 +1026,7 @@ void CGrpFauna::setCyles(std::string const& cycles)
void CGrpFauna::setPopulation(CPopulation* pop) void CGrpFauna::setPopulation(CPopulation* pop)
{ {
CPopulation* sameAliasPop = NULL; CPopulation* sameAliasPop = NULL;
uint32 index = ~0; uint32 index = std::numeric_limits<uint32>::max();
if (pop) if (pop)
sameAliasPop = _Populations.getChildByAlias(pop->getAlias()); sameAliasPop = _Populations.getChildByAlias(pop->getAlias());

View file

@ -412,7 +412,7 @@ CAIEntity* CAIInstance::tryToGetEntity(char const* str, CAIS::TSearchType search
CManager *mgrPtr=NULL; CManager *mgrPtr=NULL;
CGroup *grpPtr=NULL; CGroup *grpPtr=NULL;
CBot *botPtr=NULL; CBot *botPtr=NULL;
uint32 localIndex=~0; uint32 localIndex = std::numeric_limits<uint32>::max();
mgr = id; mgr = id;
while((*id!=':')&&(*id!=0)) id++; while((*id!=':')&&(*id!=0)) id++;
@ -635,7 +635,7 @@ static CAIVector randomPos(double dispersionRadius)
{ {
return CAIVector(0., 0.); return CAIVector(0., 0.);
} }
uint32 const maxLimit=((uint32)~0U)>>1; const uint32 maxLimit = std::numeric_limits<uint32>::max() >>1;
double rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[ double rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[
double r = dispersionRadius*sqrt(rval); double r = dispersionRadius*sqrt(rval);
rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[ rval = (double)CAIS::rand32(maxLimit)/(double)maxLimit; // [0-1[