mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-11 17:59:02 +00:00
Added: Additional constructor for CSheetId with default type, in case the user did not put the type with the sheet name
This commit is contained in:
parent
ec318f0393
commit
b755bafdae
2 changed files with 15 additions and 10 deletions
|
@ -60,6 +60,12 @@ public :
|
||||||
*/
|
*/
|
||||||
explicit CSheetId( const std::string& sheetName );
|
explicit CSheetId( const std::string& sheetName );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor, uses defaultType as extension when sheetName
|
||||||
|
* contains no file extension.
|
||||||
|
*/
|
||||||
|
explicit CSheetId( const std::string& sheetName, const std::string &defaultType );
|
||||||
|
|
||||||
// build from a string and returns true if the build succeed
|
// build from a string and returns true if the build succeed
|
||||||
bool buildSheetId(const std::string& sheetName);
|
bool buildSheetId(const std::string& sheetName);
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,14 @@ CSheetId::CSheetId( const string& sheetName )
|
||||||
|
|
||||||
} // CSheetId //
|
} // CSheetId //
|
||||||
|
|
||||||
|
CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType )
|
||||||
|
{
|
||||||
|
if (CFile::getExtension(sheetName) == "" && defaultType != "")
|
||||||
|
*this = CSheetId(sheetName + "." + defaultType);
|
||||||
|
else
|
||||||
|
*this = CSheetId(sheetName);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
// Build
|
// Build
|
||||||
|
@ -522,16 +530,7 @@ void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType)
|
||||||
{
|
{
|
||||||
std::string sheetName;
|
std::string sheetName;
|
||||||
f.serial(sheetName);
|
f.serial(sheetName);
|
||||||
if (CFile::getExtension(sheetName) == "" && defaultType != "")
|
*this = CSheetId(sheetName, defaultType);
|
||||||
sheetName += std::string(".") + defaultType;
|
|
||||||
if (!buildSheetId(sheetName))
|
|
||||||
{
|
|
||||||
if(sheetName.empty())
|
|
||||||
nlwarning("SHEETID: Try to create an CSheetId with empty name. TODO: check why.");
|
|
||||||
else
|
|
||||||
nlwarning("SHEETID: The sheet '%s' is not in sheet_id.bin, setting it to Unknown",sheetName.c_str());
|
|
||||||
*this = Unknown;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue