|
|
|
@ -33,7 +33,8 @@ using namespace std;
|
|
|
|
|
#define new DEBUG_NEW
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
namespace NLMISC {
|
|
|
|
|
namespace NLMISC
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
CSheetId::CChar CSheetId::_AllStrings;
|
|
|
|
|
CStaticMap<uint32, CSheetId::CChar> CSheetId::_SheetIdToName;
|
|
|
|
@ -48,12 +49,6 @@ std::map<std::string, uint32> CSheetId::_DevTypeNameToId;
|
|
|
|
|
std::vector<std::vector<std::string>> CSheetId::_DevSheetIdToName;
|
|
|
|
|
std::map<std::string, uint32> CSheetId::_DevSheetNameToId;
|
|
|
|
|
|
|
|
|
|
#define NL_TEMP_YUBO_NO_SOUND_SHEET_ID
|
|
|
|
|
|
|
|
|
|
#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID
|
|
|
|
|
namespace { bool a_NoSoundSheetId = false; const uint32 a_NoSoundSheetType = 80; }
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
const CSheetId CSheetId::Unknown(0);
|
|
|
|
|
|
|
|
|
|
void CSheetId::cbFileChange(const std::string &filename)
|
|
|
|
@ -91,7 +86,6 @@ CSheetId::CSheetId( uint32 sheetRef)
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// CSheetId
|
|
|
|
|
//
|
|
|
|
@ -135,7 +129,6 @@ CSheetId::CSheetId( const std::string& sheetName, const std::string &defaultType
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// Build
|
|
|
|
|
//
|
|
|
|
@ -218,25 +211,6 @@ bool CSheetId::buildSheetId(const std::string& sheetName)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID
|
|
|
|
|
if (a_NoSoundSheetId && sheetName.find(".sound") != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
std::string sheetNameLc = toLower(sheetName);
|
|
|
|
|
std::map<std::string, uint32>::iterator it = _DevSheetNameToId.find(sheetNameLc);
|
|
|
|
|
if (it == _DevSheetNameToId.end())
|
|
|
|
|
{
|
|
|
|
|
// nldebug("SHEETID: Creating a temporary sheet id for '%s'", sheetName.c_str());
|
|
|
|
|
_DevSheetIdToName[0].push_back(sheetName);
|
|
|
|
|
_Id.IdInfos.Type = a_NoSoundSheetType;
|
|
|
|
|
_Id.IdInfos.Id = _DevSheetIdToName[0].size() - 1;
|
|
|
|
|
_DevSheetNameToId[sheetNameLc] = _Id.Id;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
_Id.Id = it->second;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -368,7 +342,6 @@ void CSheetId::loadSheetId ()
|
|
|
|
|
nldebug("Finished loading sheet_id.bin: %u entries read", _SheetIdToName.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// init
|
|
|
|
|
//
|
|
|
|
@ -390,24 +363,6 @@ void CSheetId::init(bool removeUnknownSheet)
|
|
|
|
|
loadSheetId();
|
|
|
|
|
_Initialised = true;
|
|
|
|
|
|
|
|
|
|
#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID
|
|
|
|
|
if (typeFromFileExtension("sound") == std::numeric_limits<uint32>::max())
|
|
|
|
|
{
|
|
|
|
|
nlwarning("SHEETID: Loading without known sound sheet id, please update sheet_id.bin with .sound sheets");
|
|
|
|
|
nlassert(_FileExtensions.size() == 1 << (NL_SHEET_ID_TYPE_BITS));
|
|
|
|
|
nlassert(_FileExtensions[a_NoSoundSheetType].empty());
|
|
|
|
|
_FileExtensions[a_NoSoundSheetType] = "sound";
|
|
|
|
|
_DevSheetIdToName.push_back(std::vector<std::string>());
|
|
|
|
|
_DevSheetIdToName[0].push_back("unknown.sound");
|
|
|
|
|
TSheetId id;
|
|
|
|
|
id.IdInfos.Type = a_NoSoundSheetType;
|
|
|
|
|
id.IdInfos.Id = _DevSheetIdToName[0].size() - 1;
|
|
|
|
|
nlassert(id.IdInfos.Id == 0);
|
|
|
|
|
_DevSheetNameToId["unknown.sound"] = id.Id;
|
|
|
|
|
a_NoSoundSheetId = true;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
} // init //
|
|
|
|
|
|
|
|
|
|
void CSheetId::initWithoutSheet()
|
|
|
|
@ -422,12 +377,10 @@ void CSheetId::initWithoutSheet()
|
|
|
|
|
_DontHaveSheetKnowledge = true;
|
|
|
|
|
|
|
|
|
|
// Initialize id 0,0 as unknown.unknown
|
|
|
|
|
CSheetId unknownunknown = CSheetId("unknown.unknown");
|
|
|
|
|
nlassert(unknownunknown == CSheetId::Unknown);
|
|
|
|
|
CSheetId unknownUnknown = CSheetId("unknown.unknown");
|
|
|
|
|
nlassert(unknownUnknown == CSheetId::Unknown);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// uninit
|
|
|
|
|
//
|
|
|
|
@ -447,7 +400,8 @@ void CSheetId::uninit()
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
CSheetId &CSheetId::operator=(const CSheetId &sheetId)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
if (this == &sheetId)
|
|
|
|
|
{
|
|
|
|
@ -462,10 +416,8 @@ CSheetId& CSheetId::operator=( const CSheetId& sheetId )
|
|
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // operator= //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// operator=
|
|
|
|
|
//
|
|
|
|
@ -482,14 +434,14 @@ CSheetId& CSheetId::operator=( const string& sheetName )
|
|
|
|
|
|
|
|
|
|
} // operator= //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// operator=
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
CSheetId &CSheetId::operator=(uint32 sheetRef)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
_Id.Id = sheetRef;
|
|
|
|
|
|
|
|
|
@ -497,15 +449,14 @@ CSheetId& CSheetId::operator=( uint32 sheetRef )
|
|
|
|
|
|
|
|
|
|
} // operator= //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// operator<
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
bool CSheetId::operator<(const CSheetId &sheetRef) const
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
if (_Id.Id < sheetRef.asInt())
|
|
|
|
|
{
|
|
|
|
@ -516,22 +467,34 @@ bool CSheetId::operator < (const CSheetId& sheetRef ) const
|
|
|
|
|
|
|
|
|
|
} // operator< //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// toString
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
string CSheetId::toString(bool ifNotFoundUseNumericId) const
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
if (_DontHaveSheetKnowledge)
|
|
|
|
|
{
|
|
|
|
|
// FIXME: When someone punches in a fake sheet id this will
|
|
|
|
|
// fail.
|
|
|
|
|
if (_Id.IdInfos.Type < _DevSheetIdToName.size()
|
|
|
|
|
&& _Id.IdInfos.Id < _DevSheetIdToName[_Id.IdInfos.Type].size())
|
|
|
|
|
{
|
|
|
|
|
return _DevSheetIdToName[_Id.IdInfos.Type][_Id.IdInfos.Id];
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (ifNotFoundUseNumericId)
|
|
|
|
|
{
|
|
|
|
|
return NLMISC::toString("#%u", _Id.Id);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return NLMISC::toString("<Sheet %u not found in loaded sheets>", _Id.Id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CStaticMap<uint32, CChar>::const_iterator itStr = _SheetIdToName.find(_Id.Id);
|
|
|
|
|
if (itStr != _SheetIdToName.end())
|
|
|
|
@ -540,12 +503,6 @@ string CSheetId::toString(bool ifNotFoundUseNumericId) const
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
#ifdef NL_TEMP_YUBO_NO_SOUND_SHEET_ID
|
|
|
|
|
if (a_NoSoundSheetId && _Id.IdInfos.Type == a_NoSoundSheetType)
|
|
|
|
|
{
|
|
|
|
|
return _DevSheetIdToName[0][_Id.IdInfos.Id];
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
// This nlwarning is commented out because the loggers are mutexed, therefore
|
|
|
|
|
// you couldn't use toString() within a nlwarning().
|
|
|
|
|
//nlwarning("<CSheetId::toString> The sheet %08x is not in sheet_id.bin",_Id.Id);
|
|
|
|
@ -595,14 +552,14 @@ void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// display
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
void CSheetId::display()
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
CStaticMap<uint32, CChar>::const_iterator itStr;
|
|
|
|
|
for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr)
|
|
|
|
@ -613,15 +570,14 @@ void CSheetId::display()
|
|
|
|
|
|
|
|
|
|
} // display //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// display
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
void CSheetId::display(uint32 type)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
CStaticMap<uint32, CChar>::const_iterator itStr;
|
|
|
|
|
for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr)
|
|
|
|
@ -640,15 +596,14 @@ void CSheetId::display(uint32 type)
|
|
|
|
|
|
|
|
|
|
} // display //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// buildIdVector
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
void CSheetId::buildIdVector(std::vector<CSheetId> &result)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
CStaticMap<uint32, CChar>::const_iterator itStr;
|
|
|
|
|
for (itStr = _SheetIdToName.begin(); itStr != _SheetIdToName.end(); ++itStr)
|
|
|
|
@ -658,14 +613,14 @@ void CSheetId::buildIdVector(std::vector <CSheetId> &result)
|
|
|
|
|
|
|
|
|
|
} // buildIdVector //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// buildIdVector
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
void CSheetId::buildIdVector(std::vector<CSheetId> &result, uint32 type)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
nlassert(type < (1 << (NL_SHEET_ID_TYPE_BITS)));
|
|
|
|
|
|
|
|
|
|
CStaticMap<uint32, CChar>::const_iterator itStr;
|
|
|
|
@ -690,7 +645,8 @@ void CSheetId::buildIdVector(std::vector <CSheetId> &result, uint32 type)
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
void CSheetId::buildIdVector(std::vector<CSheetId> &result, std::vector<std::string> &resultFilenames, uint32 type)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
nlassert(type < (1 << (NL_SHEET_ID_TYPE_BITS)));
|
|
|
|
|
|
|
|
|
|
CStaticMap<uint32, CChar>::const_iterator itStr;
|
|
|
|
@ -734,14 +690,14 @@ void CSheetId::buildIdVector(std::vector <CSheetId> &result, std::vector <std::s
|
|
|
|
|
|
|
|
|
|
} // buildIdVector //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// typeFromFileExtension
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
uint32 CSheetId::typeFromFileExtension(const std::string &fileExtension)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
|
|
|
|
|
uint i;
|
|
|
|
|
for (i = 0; i < _FileExtensions.size(); i++)
|
|
|
|
@ -751,14 +707,14 @@ uint32 CSheetId::typeFromFileExtension(const std::string &fileExtension)
|
|
|
|
|
return std::numeric_limits<uint32>::max();
|
|
|
|
|
} // typeFromFileExtension //
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
// fileExtensionFromType
|
|
|
|
|
//
|
|
|
|
|
//-----------------------------------------------
|
|
|
|
|
const std::string &CSheetId::fileExtensionFromType(uint32 type)
|
|
|
|
|
{
|
|
|
|
|
if (!_Initialised) init(false);
|
|
|
|
|
if (!_Initialised)
|
|
|
|
|
init(false);
|
|
|
|
|
nlassert(type < (1 << (NL_SHEET_ID_TYPE_BITS)));
|
|
|
|
|
|
|
|
|
|
return _FileExtensions[type];
|
|
|
|
@ -786,7 +742,6 @@ void CSheetId::buildSheetId(uint32 shortId, uint32 type)
|
|
|
|
|
else
|
|
|
|
|
_DebugSheetName = NULL;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // NLMISC
|
|
|
|
|