Changed: Minor changes
--HG-- branch : develop
This commit is contained in:
parent
84831a4b34
commit
189fc7a2d9
17 changed files with 56 additions and 55 deletions
|
@ -825,14 +825,14 @@ bool CPersistentDataRecord::writeToFile(const std::string &fileName, TFileFormat
|
|||
goto binary_file;
|
||||
}
|
||||
}
|
||||
BOMB("Bad file type supplied to writeToFile() - file not saved: "<<fileName,return false);
|
||||
BOMB("Bad file type supplied to writeToFile() - file not saved: " << fileName, return false);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// set of accessors for retrieving a data record from various sources
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
bool CPersistentDataRecord::fromBuffer(const char *src,uint32 bufferSize)
|
||||
bool CPersistentDataRecord::fromBuffer(const char *src, uint32 bufferSize)
|
||||
{
|
||||
H_AUTO(CPersistentDataRecordFromBuffer);
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName)
|
|||
// read the data
|
||||
uint32 blocksRead= (uint32)fread(&buffer[0],length,1,inf);
|
||||
fclose(inf);
|
||||
DROP_IF( blocksRead!=1, "Failed to read data from file "<<fileName, return false);
|
||||
DROP_IF( blocksRead!=1, "Failed to read data from file " << fileName, return false);
|
||||
|
||||
// test whether our data buffer is binary
|
||||
bool isBinary=(length>8 && *(uint32*)&buffer[4]==length);
|
||||
|
@ -1143,7 +1143,7 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName)
|
|||
}
|
||||
|
||||
// it's not a valid binary file so see whether it looks like a valid text file
|
||||
DROP_IF(!buffer.isValidText(),"File is binary but 'file size' header entry doesn't match true file size",return false);
|
||||
DROP_IF(!buffer.isValidText(),"File is binary but 'file size' header entry doesn't match true file size", return false);
|
||||
|
||||
// parse the data as text...
|
||||
return fromString(buffer);
|
||||
|
@ -1153,13 +1153,13 @@ bool CPersistentDataRecord::readFromFile(const std::string &fileName)
|
|||
// open the file
|
||||
CIFile f;
|
||||
bool open = f.open(fileName);
|
||||
DROP_IF( !open, "Failed to open input file "<<fileName, return false);
|
||||
DROP_IF( !open, "Failed to open input file " << fileName, return false);
|
||||
|
||||
// get the file size
|
||||
uint32 len= f.getFileSize();
|
||||
|
||||
bool result= fromStream(f, len);
|
||||
DROP_IF( !result, "Failed to parse input file "<<fileName, return false);
|
||||
DROP_IF( !result, "Failed to parse input file " << fileName, return false);
|
||||
|
||||
return true;
|
||||
|
||||
|
@ -1194,7 +1194,7 @@ bool CPersistentDataRecord::readFromBinFile(const std::string &fileName)
|
|||
|
||||
// parse the buffer contents to re-generate the data
|
||||
bool result= fromBuffer(&s[0],(uint32)s.size());
|
||||
DROP_IF( !result, "Failed to parse input file "<<fileName, return false);
|
||||
DROP_IF( !result, "Failed to parse input file " << fileName, return false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -427,7 +427,7 @@ public:
|
|||
|
||||
// read from a binary data buffer
|
||||
// if the input data looks like text then calls fromString()
|
||||
bool fromBuffer(const char *src,uint32 bufferSize);
|
||||
bool fromBuffer(const char *src, uint32 bufferSize);
|
||||
|
||||
// read from a text string (either xml or lines)
|
||||
// note 1: This routine is not at all optimised
|
||||
|
|
|
@ -118,7 +118,7 @@ NLMISC_COMMAND ( dumpCharacterFile, "dump the content of the save file for a cha
|
|||
}
|
||||
|
||||
// the file exist !
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
|
||||
if (!pdr.readFromBinFile(fileName))
|
||||
|
|
|
@ -2223,7 +2223,7 @@ NLMISC_CATEGORISED_COMMAND(pdr,loadFromXML,"load a character from an XML file","
|
|||
uint32 guildId= c->getGuildId();
|
||||
NLMISC::CEntityId id= c->getId();
|
||||
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromTxtFile(fileName+".xml");
|
||||
c->apply(pdr);
|
||||
|
@ -2249,7 +2249,7 @@ NLMISC_CATEGORISED_COMMAND(pdr,saveToPDR,"save a character to a binary PDR file"
|
|||
if (args.size () < 2) return false;
|
||||
GET_CHARACTER
|
||||
|
||||
std::string fileName = args[1];
|
||||
std::string fileName = args[1];
|
||||
|
||||
if( c )
|
||||
{
|
||||
|
@ -2280,7 +2280,7 @@ NLMISC_CATEGORISED_COMMAND(pdr,loadFromPDR,"load a character from a binary PDR f
|
|||
uint32 guildId= c->getGuildId();
|
||||
NLMISC::CEntityId id= c->getId();
|
||||
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromBinFile(fileName+".pdr");
|
||||
c->apply(pdr);
|
||||
|
|
|
@ -64,7 +64,7 @@ void CGameEventManager::init()
|
|||
|
||||
if (CFile::fileExists(sFilename))
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromTxtFile(sFilename);
|
||||
apply(pdr);
|
||||
|
|
|
@ -53,7 +53,7 @@ void CMissionQueueManager::init()
|
|||
|
||||
if (CFile::fileExists(sFilename))
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromTxtFile(sFilename);
|
||||
apply(pdr);
|
||||
|
|
|
@ -428,7 +428,7 @@ void COutpostManager::loadOutpostSaveFiles()
|
|||
// else
|
||||
// {
|
||||
// // load dynamic data
|
||||
// static CPersistentDataRecord pdr;
|
||||
// static CPersistentDataRecord pdr;
|
||||
// pdr.clear();
|
||||
// pdr.readFromBinFile(files[i]);
|
||||
// outpost->apply( pdr );
|
||||
|
|
|
@ -66,7 +66,7 @@ void CNamedItems::loadNamedItemsFromFile(const std::string & fileName)
|
|||
return;
|
||||
}
|
||||
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromTxtFile(path);
|
||||
CInventoryPtr inv = loadFromPdr(pdr);
|
||||
|
|
|
@ -60,7 +60,7 @@ NLMISC_CATEGORISED_COMMAND(ShardMerge,mergeGuildIdFix,"set the guild ids in the
|
|||
nlinfo("Setting id for guild: %s to: %d",fdc[i].FileName.c_str(),id);
|
||||
|
||||
// read the file
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(fdc[i].FileName.c_str());
|
||||
|
||||
|
@ -107,7 +107,7 @@ NLMISC_CATEGORISED_COMMAND(ShardMerge,mergeChangeCharacterNames,"change names of
|
|||
// read the file
|
||||
NLMISC::CSString fileName= args[0]+NLMISC::toString("/characters/account_%d_%d_pdr.bin",account,slot);
|
||||
DROP_IF(!NLMISC::CFile::fileExists(fileName),"Skipping inexistant file: "+fileName,continue);
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(fileName.c_str());
|
||||
|
||||
|
|
|
@ -139,7 +139,7 @@ NLMISC_CATEGORISED_COMMAND(Stats,listCharNames,"display the names of the charact
|
|||
std::sort(files.begin(),files.end());
|
||||
for (uint32 i=0;i<files.size();++i)
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(files[i]);
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ NLMISC_CATEGORISED_COMMAND(Stats,listCharNames,"display the names of the charact
|
|||
std::sort(files.begin(),files.end());
|
||||
for (uint32 i=0;i<files.size();++i)
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(files[i]);
|
||||
|
||||
|
|
|
@ -284,7 +284,7 @@ bool CCharacterScanJob::deleteFilesInOutputDirectory() const
|
|||
bool CCharacterScanJob::runForFile(const std::string& fileName)
|
||||
{
|
||||
// load the file into a pdr record
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(fileName);
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ NLMISC_CATEGORISED_COMMAND(utils,pdr2xml,"convert one or more sets of pdr files
|
|||
fd.FileName.rightCrop(4)+".xml": fd.FileName+".xml";
|
||||
|
||||
log.displayNL("Converting to XML : %s => %s",fd.FileName.c_str(),outputFileName.c_str());
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(fd.FileName);
|
||||
pdr.writeToFile(outputFileName);
|
||||
|
@ -168,7 +168,7 @@ NLMISC_CATEGORISED_COMMAND(utils,pdr2bin,"convert one or more sets of pdr files
|
|||
fd.FileName.rightCrop(4)+".bin": fd.FileName+".bin";
|
||||
|
||||
log.displayNL("Converting to Binary : %s => %s",fd.FileName.c_str(),outputFileName.c_str());
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(fd.FileName);
|
||||
pdr.writeToFile(outputFileName);
|
||||
|
@ -200,7 +200,7 @@ NLMISC_CATEGORISED_COMMAND(utils,pdr2txt,"convert one or more sets of pdr files
|
|||
fd.FileName.rightCrop(4)+".txt": fd.FileName+".txt";
|
||||
|
||||
log.displayNL("Converting to TXT : %s => %s",fd.FileName.c_str(),outputFileName.c_str());
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(fd.FileName);
|
||||
pdr.writeToFile(outputFileName);
|
||||
|
@ -264,17 +264,18 @@ NLMISC_CATEGORISED_COMMAND(utils,pdrInfo,"Extract info from pdr file(s)","<input
|
|||
for (uint32 j=0;j<fdc.size();++j)
|
||||
{
|
||||
H_AUTO(pdrInfo_treatFile)
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
|
||||
const CFileDescription& fd=fdc[j];
|
||||
log.display("- %s: ",fd.FileName.quoteIfNotQuoted().c_str());
|
||||
log.display("- %s: ", fd.FileName.quoteIfNotQuoted().c_str());
|
||||
|
||||
{
|
||||
H_AUTO(pdrInfo_readFromFile)
|
||||
pdr.readFromFile(fd.FileName);
|
||||
}
|
||||
log.displayNL("%s",pdr.getInfo().c_str());
|
||||
|
||||
log.displayNL("%s", pdr.getInfo().c_str());
|
||||
|
||||
if (!outputFileName.empty())
|
||||
{
|
||||
|
|
|
@ -78,7 +78,7 @@ void GenerateLZMA(const std::string sourceFile, const std::string &outputFile)
|
|||
{
|
||||
{
|
||||
// old syntax incompatible with new versions
|
||||
std::string cmd = "lzma e ";
|
||||
std::string cmd = "lzma e";
|
||||
cmd += " " + sourceFile + " " + outputFile;
|
||||
nlinfo("Executing system command: %s", cmd.c_str());
|
||||
}
|
||||
|
@ -187,38 +187,38 @@ void CPackageDescription::setup(const std::string& packageName)
|
|||
clear();
|
||||
|
||||
// read new contents from input file
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromTxtFile(packageName);
|
||||
apply(pdr);
|
||||
|
||||
// root directory
|
||||
if (_RootDirectory.empty())
|
||||
_RootDirectory= NLMISC::CFile::getPath(packageName);
|
||||
_RootDirectory= NLMISC::CPath::standardizePath(_RootDirectory,true);
|
||||
_RootDirectory = NLMISC::CFile::getPath(packageName);
|
||||
_RootDirectory = NLMISC::CPath::standardizePath(_RootDirectory, true);
|
||||
|
||||
// patch directory
|
||||
if (_PatchDirectory.empty())
|
||||
_PatchDirectory= _RootDirectory+"patch";
|
||||
_PatchDirectory= NLMISC::CPath::standardizePath(_PatchDirectory,true);
|
||||
_PatchDirectory = _RootDirectory + "patch";
|
||||
_PatchDirectory = NLMISC::CPath::standardizePath(_PatchDirectory, true);
|
||||
|
||||
// BNP directory
|
||||
if (_BnpDirectory.empty())
|
||||
_BnpDirectory= _RootDirectory+"bnp";
|
||||
_BnpDirectory= NLMISC::CPath::standardizePath(_BnpDirectory,true);
|
||||
_BnpDirectory = _RootDirectory+"bnp";
|
||||
_BnpDirectory = NLMISC::CPath::standardizePath(_BnpDirectory, true);
|
||||
|
||||
// ref directory
|
||||
if (_RefDirectory.empty())
|
||||
_RefDirectory= _RootDirectory+"ref";
|
||||
_RefDirectory= NLMISC::CPath::standardizePath(_RefDirectory,true);
|
||||
_RefDirectory = _RootDirectory+"ref";
|
||||
_RefDirectory = NLMISC::CPath::standardizePath(_RefDirectory, true);
|
||||
|
||||
// client index file
|
||||
if (_ClientIndexFileName.empty())
|
||||
_ClientIndexFileName= NLMISC::CFile::getFilenameWithoutExtension(packageName)+".idx";
|
||||
_ClientIndexFileName = NLMISC::CFile::getFilenameWithoutExtension(packageName)+".idx";
|
||||
|
||||
// index file
|
||||
if (_IndexFileName.empty())
|
||||
_IndexFileName= NLMISC::CFile::getFilenameWithoutExtension(_ClientIndexFileName)+".hist";
|
||||
_IndexFileName = NLMISC::CFile::getFilenameWithoutExtension(_ClientIndexFileName)+".hist";
|
||||
}
|
||||
|
||||
void CPackageDescription::storeToPdr(CPersistentDataRecord& pdr) const
|
||||
|
@ -239,7 +239,7 @@ void CPackageDescription::readIndex(CBNPFileSet& packageIndex) const
|
|||
// read new contents from input file
|
||||
if (NLMISC::CFile::fileExists(indexPath))
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromTxtFile(indexPath);
|
||||
packageIndex.apply(pdr);
|
||||
|
@ -253,7 +253,7 @@ void CPackageDescription::writeIndex(const CBNPFileSet& packageIndex) const
|
|||
nlinfo("Writing history file: %s ...", indexPath.c_str());
|
||||
|
||||
// write contents to output file
|
||||
static CPersistentDataRecordRyzomStore pdr;
|
||||
static CPersistentDataRecordRyzomStore pdr;
|
||||
pdr.clear();
|
||||
packageIndex.store(pdr);
|
||||
pdr.writeToTxtFile(indexPath);
|
||||
|
@ -304,7 +304,7 @@ void CPackageDescription::generateClientIndex(CProductDescriptionForClient& theC
|
|||
theClientPackage.clear();
|
||||
|
||||
// copy the categories using a pdr record
|
||||
static CPersistentDataRecordRyzomStore pdr;
|
||||
static CPersistentDataRecordRyzomStore pdr;
|
||||
pdr.clear();
|
||||
_Categories.store(pdr);
|
||||
theClientPackage.setCategories(pdr);
|
||||
|
@ -348,14 +348,14 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
|||
{
|
||||
nlinfo("Generating patches ...");
|
||||
|
||||
for (uint32 i=packageIndex.fileCount();i--;)
|
||||
for (uint32 i = packageIndex.fileCount(); i--;)
|
||||
{
|
||||
bool deleteRefAfterDelta= true;
|
||||
bool deleteRefAfterDelta = true;
|
||||
bool usingTemporaryFile = false;
|
||||
// generate file name root
|
||||
std::string bnpFileName= _BnpDirectory+packageIndex.getFile(i).getFileName();
|
||||
std::string refNameRoot= _RefDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||
std::string patchNameRoot= _PatchDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||
std::string bnpFileName = _BnpDirectory + packageIndex.getFile(i).getFileName();
|
||||
std::string refNameRoot = _RefDirectory + NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||
std::string patchNameRoot = _PatchDirectory + NLMISC::CFile::getFilenameWithoutExtension(bnpFileName);
|
||||
|
||||
// if the file has no versions then skip on to the next file
|
||||
if (packageIndex.getFile(i).versionCount()==0)
|
||||
|
@ -365,7 +365,7 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
|||
const CBNPFileVersion& curVersion= packageIndex.getFile(i).getVersion(packageIndex.getFile(i).versionCount()-1);
|
||||
std::string curVersionFileName= refNameRoot+NLMISC::toString("_%05u.%s",curVersion.getVersionNumber(),NLMISC::CFile::getExtension(bnpFileName).c_str());
|
||||
// std::string patchFileName= patchNameRoot+NLMISC::toString("_%05d.patch",curVersion.getVersionNumber());
|
||||
std::string patchFileName= _PatchDirectory+toString("%05u/",curVersion.getVersionNumber())+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+toString("_%05u",curVersion.getVersionNumber())+".patch";
|
||||
std::string patchFileName= _PatchDirectory + toString("%05u/",curVersion.getVersionNumber())+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+toString("_%05u",curVersion.getVersionNumber())+".patch";
|
||||
|
||||
// get the second last version number and the related file name
|
||||
std::string prevVersionFileName;
|
||||
|
@ -413,7 +413,7 @@ void CPackageDescription::generatePatches(CBNPFileSet& packageIndex) const
|
|||
refVersionFileName= _BnpDirectory+NLMISC::CFile::getFilenameWithoutExtension(bnpFileName)+"_.ref";
|
||||
|
||||
// delete the previous patch - because we only need the latest patch for non-incremental files
|
||||
std::string lastPatch= _PatchDirectory+NLMISC::CFile::getFilenameWithoutExtension(prevVersionFileName)+".patch";
|
||||
std::string lastPatch= _PatchDirectory + NLMISC::CFile::getFilenameWithoutExtension(prevVersionFileName)+".patch";
|
||||
if (NLMISC::CFile::fileExists(lastPatch.c_str()))
|
||||
NLMISC::CFile::deleteFile(lastPatch.c_str());
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ static bool createNewProduct(std::string fileName)
|
|||
|
||||
// create a new package, store it to a persistent data record and write the latter to a file
|
||||
CPackageDescription package;
|
||||
static CPersistentDataRecordRyzomStore pdr;
|
||||
static CPersistentDataRecordRyzomStore pdr;
|
||||
pdr.clear();
|
||||
package.storeToPdr(pdr);
|
||||
pdr.writeToTxtFile(fileName);
|
||||
|
@ -563,7 +563,7 @@ static bool createNewProduct(std::string fileName)
|
|||
pdr.writeToTxtFile(fileName);
|
||||
|
||||
BOMB_IF(!NLMISC::CFile::fileExists(fileName),("Failed to create new package file: "+fileName).c_str(),return false);
|
||||
nlinfo("New package description file created successfully: %s",fileName.c_str());
|
||||
nlinfo("New package description file created successfully: %s", fileName.c_str());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -243,7 +243,7 @@ int main(int argc, char *argv[])
|
|||
outputFileName += outExt;
|
||||
}
|
||||
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
|
||||
switch(mode)
|
||||
|
|
|
@ -140,14 +140,14 @@ NLMISC_COMMAND(listCharNames,"display the names of the characters int he listed
|
|||
std::sort(files.begin(),files.end());
|
||||
for (uint32 i=0;i<files.size();++i)
|
||||
{
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(files[i]);
|
||||
|
||||
CStatsScanCharacter c;
|
||||
c.apply(pdr);
|
||||
|
||||
log.displayNL("%-40s Name: %s ",files[i].c_str(),c.EntityBase._Name.c_str());
|
||||
log.displayNL("%-40s Name: %s ", files[i].c_str(), c.EntityBase._Name.c_str());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -97,7 +97,7 @@ void CCharacterScanJob::update()
|
|||
return;
|
||||
|
||||
// load the file into a pdr record
|
||||
static CPersistentDataRecord pdr;
|
||||
static CPersistentDataRecord pdr;
|
||||
pdr.clear();
|
||||
pdr.readFromFile(_Files[_NextFile]);
|
||||
++_NextFile;
|
||||
|
|
Loading…
Reference in a new issue