mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-22 06:46:14 +00:00
Merge with develop
This commit is contained in:
parent
dab3de7a74
commit
486a5e4638
4 changed files with 34 additions and 31 deletions
|
@ -63,7 +63,7 @@ void XMLError (xmlNodePtr xmlNode, const std::string &filename, const char *form
|
|||
vsnprintf( buffer, 1024, format, args );
|
||||
va_end( args );
|
||||
|
||||
Error (filename, "node (%s), line (%p) : %s", xmlNode->name, xmlNode->content, buffer);
|
||||
Error (filename, "node (%s), line (%d) : %s", xmlNode->name, xmlNode->line, buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ xmlNodePtr GetFirstChildNode (xmlNodePtr xmlNode, const std::string &filename, c
|
|||
if (result) return result;
|
||||
|
||||
// Output a formated error
|
||||
XMLError (xmlNode, filename.c_str(), "Can't find XML node named (%s)", childName);
|
||||
XMLError (xmlNode, filename.c_str(), "Can't find XML node named (%s)", childName.c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ bool GetPropertyString (string &result, const std::string &filename, xmlNodePtr
|
|||
if (!CIXml::getPropertyString (result, xmlNode, propName))
|
||||
{
|
||||
// Output a formated error
|
||||
XMLError (xmlNode, filename, "Can't find XML node property (%s)", propName);
|
||||
XMLError (xmlNode, filename, "Can't find XML node property (%s)", propName.c_str());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -204,14 +204,14 @@ bool GetNodeString (string &result, const std::string &filename, xmlNodePtr xmlN
|
|||
xmlNodePtr node = CIXml::getFirstChildNode (xmlNode, nodeName);
|
||||
if (!node)
|
||||
{
|
||||
XMLError (xmlNode, filename, "Can't find XML node named (%s)", nodeName);
|
||||
XMLError (xmlNode, filename, "Can't find XML node named (%s)", nodeName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the node string
|
||||
if (!CIXml::getContentString (result, node))
|
||||
{
|
||||
XMLError (xmlNode, filename, "Can't find any text in the node named (%s)", nodeName);
|
||||
XMLError (xmlNode, filename, "Can't find any text in the node named (%s)", nodeName.c_str());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1282,7 +1282,7 @@ bool IPrimitive::getProperty (uint index, std::string &property_name, const IPro
|
|||
index--;
|
||||
ite ++;
|
||||
}
|
||||
nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %d, size : %d).", index, _Properties.size ());
|
||||
nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %u, size : %u).", index, (uint)_Properties.size ());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1303,7 +1303,7 @@ bool IPrimitive::getProperty (uint index, std::string &property_name, IProperty
|
|||
index--;
|
||||
ite ++;
|
||||
}
|
||||
nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %d, size : %d).", index, _Properties.size ());
|
||||
nlwarning ("NLLIGO::IPrimitive::getProperty : invalid index (index : %u, size : %u).", index, (uint)_Properties.size ());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ bool IPrimitive::removeProperty (uint index)
|
|||
index--;
|
||||
ite ++;
|
||||
}
|
||||
nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %d, size : %d).", index, _Properties.size ());
|
||||
nlwarning ("NLLIGO::IPrimitive::removeProperty : invalid index (index : %u, size : %u).", index, (uint)_Properties.size ());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1503,7 @@ bool IPrimitive::getChild (const IPrimitive *&result, uint childId) const
|
|||
}
|
||||
else
|
||||
{
|
||||
nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ());
|
||||
nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1519,7 +1519,7 @@ bool IPrimitive::getChild (IPrimitive *&result, uint childId)
|
|||
}
|
||||
else
|
||||
{
|
||||
nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %d, size %d).", childId, _Children.size ());
|
||||
nlwarning ("NLLIGO::IPrimitive::getChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1553,7 +1553,7 @@ bool IPrimitive::removeChild (uint childId)
|
|||
}
|
||||
else
|
||||
{
|
||||
nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %d, size %d).", childId, _Children.size ());
|
||||
nlwarning ("NLLIGO::IPrimitive::removeChild : invalid index (index : %u, size %u).", childId, (uint)_Children.size ());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2510,7 +2510,7 @@ bool CPrimitives::read (xmlNodePtr xmlNode, const std::string &filename, CLigoCo
|
|||
}
|
||||
else
|
||||
{
|
||||
Error (filename, "CPrimitives::read : Unknown file version (%d)", version);
|
||||
Error (filename, "CPrimitives::read : Unknown file version (%u)", version);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const TCHAR *name, CString
|
|||
return;
|
||||
}
|
||||
|
||||
CUniquePtr<TCHAR[]> tmpDest(new TCHAR[size]);
|
||||
result = RegQueryValueEx(hKey, name, NULL, &type, (BYTE*)tmpDest.get(), &size);
|
||||
std::vector<TCHAR> tmpDest(size);
|
||||
result = RegQueryValueEx(hKey, name, NULL, &type, (BYTE*)&tmpDest[0], &size);
|
||||
|
||||
if (result != ERROR_SUCCESS)
|
||||
{
|
||||
|
@ -130,7 +130,7 @@ void CSnapshotToolDlg::stringFromRegistry(HKEY hKey, const TCHAR *name, CString
|
|||
return;
|
||||
}
|
||||
|
||||
dest = tmpDest.get();
|
||||
dest = &tmpDest[0];
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,14 +85,14 @@ bool i_comp(const string &s0, const string &s1)
|
|||
return nlstricmp (CFile::getFilename(s0).c_str(), CFile::getFilename(s1).c_str()) < 0;
|
||||
}
|
||||
|
||||
void packSubRecurse(const std::string &srcDirectory)
|
||||
bool packSubRecurse(const std::string &srcDirectory)
|
||||
{
|
||||
vector<string> pathContent;
|
||||
|
||||
printf ("Treating directory: %s\n", srcDirectory.c_str());
|
||||
CPath::getPathContent(srcDirectory, true, false, true, pathContent);
|
||||
|
||||
if (pathContent.empty()) return;
|
||||
if (pathContent.empty()) return true;
|
||||
|
||||
// Sort filename
|
||||
sort (pathContent.begin(), pathContent.end(), i_comp);
|
||||
|
@ -102,8 +102,8 @@ void packSubRecurse(const std::string &srcDirectory)
|
|||
{
|
||||
if (toLower(CFile::getFilename(pathContent[i-1])) == toLower(CFile::getFilename(pathContent[i])))
|
||||
{
|
||||
nlerror("File %s is not unique in BNP!", CFile::getFilename(pathContent[i]).c_str());
|
||||
return;
|
||||
nlwarning("File %s is not unique in BNP!", CFile::getFilename(pathContent[i]).c_str());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,6 +121,8 @@ void packSubRecurse(const std::string &srcDirectory)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -194,7 +196,8 @@ int main(int argc, char **argv)
|
|||
|
||||
CFile::deleteFile(gBNPHeader.BigFileName);
|
||||
|
||||
packSubRecurse(srcDirectory);
|
||||
if (!packSubRecurse(srcDirectory)) return 1;
|
||||
|
||||
return gBNPHeader.appendHeader() ? 0:-1;
|
||||
}
|
||||
|
||||
|
|
|
@ -196,26 +196,26 @@ bool unpackLZMA(const std::string &lzmaFile, const std::string &destFileName)
|
|||
}
|
||||
|
||||
// allocate input buffer for props
|
||||
CUniquePtr<uint8[]> propsBuffer(new uint8[LZMA_PROPS_SIZE]);
|
||||
std::vector<uint8> propsBuffer(LZMA_PROPS_SIZE);
|
||||
|
||||
// size of LZMA content
|
||||
inSize -= LZMA_PROPS_SIZE + 8;
|
||||
|
||||
// allocate input buffer for lzma data
|
||||
CUniquePtr<uint8[]> inBuffer(new uint8[inSize]);
|
||||
std::vector<uint8> inBuffer(inSize);
|
||||
|
||||
uint64 fileSize = 0;
|
||||
|
||||
try
|
||||
{
|
||||
// read props
|
||||
inStream.serialBuffer(propsBuffer.get(), LZMA_PROPS_SIZE);
|
||||
inStream.serialBuffer(&propsBuffer[0], LZMA_PROPS_SIZE);
|
||||
|
||||
// read uncompressed size
|
||||
inStream.serial(fileSize);
|
||||
|
||||
// read lzma content
|
||||
inStream.serialBuffer(inBuffer.get(), inSize);
|
||||
inStream.serialBuffer(&inBuffer[0], inSize);
|
||||
}
|
||||
catch(const EReadError &e)
|
||||
{
|
||||
|
@ -224,14 +224,14 @@ bool unpackLZMA(const std::string &lzmaFile, const std::string &destFileName)
|
|||
}
|
||||
|
||||
// allocate the output buffer
|
||||
CUniquePtr<uint8[]> outBuffer(new uint8[fileSize]);
|
||||
std::vector<uint8> outBuffer(fileSize);
|
||||
|
||||
// in and out file sizes
|
||||
SizeT outProcessed = (SizeT)fileSize;
|
||||
SizeT inProcessed = (SizeT)inSize;
|
||||
|
||||
// decompress the file in memory
|
||||
sint res = LzmaUncompress(outBuffer.get(), &outProcessed, inBuffer.get(), &inProcessed, propsBuffer.get(), LZMA_PROPS_SIZE);
|
||||
sint res = LzmaUncompress(&outBuffer[0], &outProcessed, &inBuffer[0], &inProcessed, &propsBuffer[0], LZMA_PROPS_SIZE);
|
||||
|
||||
if (res != 0 || outProcessed != fileSize)
|
||||
{
|
||||
|
@ -245,7 +245,7 @@ bool unpackLZMA(const std::string &lzmaFile, const std::string &destFileName)
|
|||
try
|
||||
{
|
||||
// write content
|
||||
outStream.serialBuffer(outBuffer.get(), (uint)fileSize);
|
||||
outStream.serialBuffer(&outBuffer[0], (uint)fileSize);
|
||||
}
|
||||
catch(const EFile &e)
|
||||
{
|
||||
|
@ -273,12 +273,12 @@ bool packLZMA(const std::string &srcFileName, const std::string &lzmaFileName)
|
|||
}
|
||||
|
||||
// allocate input buffer
|
||||
CUniquePtr<uint8[]> inBuffer(new uint8[inSize]);
|
||||
std::vector<uint8> inBuffer(inSize);
|
||||
|
||||
try
|
||||
{
|
||||
// read file in buffer
|
||||
inStream.serialBuffer(inBuffer.get(), inSize);
|
||||
inStream.serialBuffer(&inBuffer[0], inSize);
|
||||
}
|
||||
catch(const EReadError &e)
|
||||
{
|
||||
|
@ -288,11 +288,11 @@ bool packLZMA(const std::string &srcFileName, const std::string &lzmaFileName)
|
|||
|
||||
// allocate output buffer
|
||||
size_t outSize = (11 * inSize / 10) + 65536; // worst case = 1.1 * size + 64K
|
||||
CUniquePtr<uint8[]> outBuffer(new uint8[outSize]);
|
||||
std::vector<uint8> outBuffer(outSize);
|
||||
|
||||
// allocate buffer for props
|
||||
size_t outPropsSize = LZMA_PROPS_SIZE;
|
||||
CUniquePtr<uint8[]> outProps(new uint8[outPropsSize]);
|
||||
std::vector<uint8> outProps(outPropsSize);
|
||||
|
||||
// compress with best compression and other default settings
|
||||
sint res = LzmaCompress(outBuffer.get(), &outSize, inBuffer.get(), inSize, outProps.get(), &outPropsSize, 9, 1 << 27, -1, -1, -1, -1, 1);
|
||||
|
|
Loading…
Reference in a new issue