Changed: Created NELID macro to fix warning "multi-character character constant"

This commit is contained in:
kervala 2013-09-22 13:10:57 +02:00
parent 725093587d
commit df8c6e9b08
37 changed files with 76 additions and 69 deletions

View file

@ -109,7 +109,7 @@ struct TLoadFormDicoEntry
}
};
*/
const uint32 PACKED_SHEET_HEADER = 'PKSH';
const uint32 PACKED_SHEET_HEADER = NELID("PKSH");
const uint32 PACKED_SHEET_VERSION = 5;
// This Version may be used if you want to use the serialVersion() system in loadForm()
const uint32 PACKED_SHEET_VERSION_COMPATIBLE = 0;

View file

@ -53,6 +53,13 @@ class CMemStream;
# endif
# define NLMISC_BSWAP64(src) (src) = (((src)>>56)&0xFF) | ((((src)>>48)&0xFF)<<8) | ((((src)>>40)&0xFF)<<16) | ((((src)>>32)&0xFF)<<24) | ((((src)>>24)&0xFF)<<32) | ((((src)>>16)&0xFF)<<40) | ((((src)>>8)&0xFF)<<48) | (((src)&0xFF)<<56)
// convert a 4 characters string to uint32
#ifdef NL_LITTLE_ENDIAN
# define NELID(x) (uint32((x[0] << 24) | (x[1] << 16) | (x[2] << 8) | (x[3])))
#else
# define NELID(x) (uint32((x[3] << 24) | (x[2] << 16) | (x[1] << 8) | (x[0])))
#endif
// ======================================================================================================
/**
* Stream Exception.

View file

@ -89,8 +89,8 @@ void CAnimation::serial (NLMISC::IStream& f)
nlassert(_IdByChannelId.empty());
// Serial a header
f.serialCheck ((uint32)'_LEN');
f.serialCheck ((uint32)'MINA');
f.serialCheck (NELID("_LEN"));
f.serialCheck (NELID("MINA"));
// Serial a version
sint version=f.serialVersion (2);

View file

@ -185,9 +185,9 @@ void CAnimationSet::serial (NLMISC::IStream& f)
nlassert(!_AnimHeaderOptimisation);
// Serial an header
f.serialCheck ((uint32)'_LEN');
f.serialCheck ((uint32)'MINA');
f.serialCheck ((uint32)'TES_');
f.serialCheck (NELID("_LEN"));
f.serialCheck (NELID("MINA"));
f.serialCheck (NELID("TES_"));
// Serial a version
uint ver= f.serialVersion (1);

View file

@ -264,9 +264,9 @@ void CLodCharacterShapeBuild::compile(const std::vector<bool> &triangleSelection
void CLodCharacterShapeBuild::serial(NLMISC::IStream &f)
{
// NEL_CLODBULD
f.serialCheck((uint32)'_LEN');
f.serialCheck((uint32)'DOLC');
f.serialCheck((uint32)'DLUB');
f.serialCheck(NELID("_LEN"));
f.serialCheck(NELID("DOLC"));
f.serialCheck(NELID("DLUB"));
/*
Version 1:
@ -525,9 +525,9 @@ void CLodCharacterShape::CBoneInfluence::serial(NLMISC::IStream &f)
void CLodCharacterShape::serial(NLMISC::IStream &f)
{
// NEL_CLODSHAP
f.serialCheck((uint32)'_LEN');
f.serialCheck((uint32)'DOLC');
f.serialCheck((uint32)'PAHS');
f.serialCheck(NELID("_LEN"));
f.serialCheck(NELID("DOLC"));
f.serialCheck(NELID("PAHS"));
/*
Version 1:

View file

@ -152,7 +152,7 @@ void CPackedWorld::getZones(std::vector<TPackedZoneBaseSPtr> &zones)
void CPackedWorld::serialZoneNames(NLMISC::IStream &f) throw(NLMISC::EStream)
{
f.serialVersion(1);
f.serialCheck((uint32) 'OWPA');
f.serialCheck(NELID("OWPA"));
f.serialCont(ZoneNames);
}

View file

@ -73,7 +73,7 @@ CPSLocated::CPSLocated() : /*_MaxNumFaces(0),*/
_ParametricMotion(false),
_TriggerOnDeath(false),
_LastForever(true),
_TriggerID((uint32) 'NONE'),
_TriggerID(NELID("NONE")),
_NonIntegrableForceNbRefs(0),
_NumIntegrableForceWithDifferentBasis(0)
{

View file

@ -405,7 +405,7 @@ void CInstanceGroup::serial (NLMISC::IStream& f)
* ***********************************************/
// Serial a header
f.serialCheck ((uint32)'TPRG');
f.serialCheck (NELID("TPRG"));
/*
Version 5:

View file

@ -116,7 +116,7 @@ IShape* CShapeStream::getShapePointer () const
void CShapeStream::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
// First, serial an header or checking if it is correct
f.serialCheck ((uint32)'PAHS');
f.serialCheck (NELID("PAHS"));
// Then, serial the shape
f.serialPolyPtr (_Shape);

View file

@ -60,7 +60,7 @@ void CSkeletonWeight::build (const TNodeArray& array)
void CSkeletonWeight::serial (NLMISC::IStream& f)
{
// Serial a header
f.serialCheck ((uint32)'TWKS');
f.serialCheck (NELID("TWKS"));
// Serial a version number
(void)f.serialVersion (0);

View file

@ -104,8 +104,8 @@ const sint CTileFarBank::_Version=0x0;
void CTileFarBank::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
// Write/Check "FAR_BANK" in header of the stream
f.serialCheck ((uint32)'_RAF');
f.serialCheck ((uint32)'KNAB');
f.serialCheck (NELID("_RAF"));
f.serialCheck (NELID("KNAB"));
// Serial version
(void)f.serialVersion(_Version);

View file

@ -192,10 +192,10 @@ void CVegetableShape::serial(NLMISC::IStream &f)
- BestSidedPreComputeLighting
*/
sint ver= f.serialVersion(1);
f.serialCheck((uint32)'_LEN');
f.serialCheck((uint32)'GEV_');
f.serialCheck((uint32)'BATE');
f.serialCheck((uint32)'__EL');
f.serialCheck(NELID("_LEN"));
f.serialCheck(NELID("GEV_"));
f.serialCheck(NELID("BATE"));
f.serialCheck(NELID("__EL"));
f.serial(Lighted);
f.serial(DoubleSided);

View file

@ -458,7 +458,7 @@ void CZone::serial(NLMISC::IStream &f)
throw EOlderStream(f);
}
f.serialCheck((uint32)'ENOZ');
f.serialCheck(NELID("ENOZ"));
f.xmlSerial (ZoneId, "ZONE_ID");
f.xmlSerial (ZoneBB, "BB");

View file

@ -41,7 +41,7 @@
#ifdef LUA_NEVRAX_VERSION
#include "lua_ide_dll_nevrax/include/lua_ide_dll/ide_interface.h" // external debugger
#endif
const uint32 UI_CACHE_SERIAL_CHECK = (uint32) 'IUG_';
const uint32 UI_CACHE_SERIAL_CHECK = NELID("IUG_");
using namespace NLMISC;
using namespace std;

View file

@ -80,7 +80,7 @@ void CMaterial::serial (NLMISC::IStream &s)
s.xmlPush ("LIGO_MATERIAL");
// Serial the header
s.serialCheck ((uint32)'TMOL');
s.serialCheck (NELID("TMOL"));
// Serial the version
/*sint ver =*/ s.serialVersion (0);

View file

@ -199,7 +199,7 @@ void CTransition::serial (NLMISC::IStream &s)
s.xmlPush ("LIGO_TRANSITION");
// Serial the header
s.serialCheck ((uint32)'STGL');
s.serialCheck (NELID("STGL"));
// Serial the version
/*sint ver =*/ s.serialVersion (0);

View file

@ -153,7 +153,7 @@ void CZoneRegion::serial (NLMISC::IStream &f)
f.xmlPush ("LAND");
sint32 version = f.serialVersion (1);
f.serialCheck ((uint32)'DNAL');
f.serialCheck (NELID("DNAL"));
f.xmlSerial (_MinX, "MIN_X");
f.xmlSerial (_MinY, "MIN_Y");

View file

@ -85,7 +85,7 @@ void CPrimitiveBlock::serial (NLMISC::IStream &s)
s.xmlPush ("PRIMITIVE_BLOCK");
// Serial checks
s.serialCheck ((uint32)'KBRP');
s.serialCheck (NELID("KBRP"));
// Serial the version
(void)s.serialVersion (0);

View file

@ -1711,8 +1711,8 @@ void CObjectViewer::serial (NLMISC::IStream& f)
{
// version 4: include particle workspace infos
// serial "OBJV_CFG"
f.serialCheck ((uint32)'VJBO');
f.serialCheck ((uint32)'GFC_');
f.serialCheck (NELID("VJBO');
f.serialCheck (NELID("GFC_');
// serial the version
int ver=f.serialVersion (4);

View file

@ -64,7 +64,7 @@ bool CPositionState::getPos(sint32 &px, sint32 &py)
// ***************************************************************************
void CPositionState::serialNodeLeaf(NLMISC::IStream &f, CCDBNodeLeaf *&dbNode)
{
f.serialCheck((uint32) 'NL__');
f.serialCheck(NELID("NL__"));
f.serialVersion(0);
std::string dbPath;
if (f.isReading())
@ -85,18 +85,18 @@ void CPositionState::serialNodeLeaf(NLMISC::IStream &f, CCDBNodeLeaf *&dbNode)
}
f.serial(dbPath);
}
f.serialCheck((uint32) 'END_');
f.serialCheck(NELID("END_"));
}
// ***************************************************************************
void CUIDEntityPositionState::serial(NLMISC::IStream &f)
{
f.serialCheck((uint32) 'UIDE');
f.serialCheck(NELID("UIDE"));
f.serialVersion(0);
serialNodeLeaf(f, _DBPos);
serialNodeLeaf(f, _Uid);
f.serialCheck((uint32) '_END');
f.serialCheck(NELID("_END"));
}
// ***************************************************************************
@ -241,11 +241,11 @@ bool CAnimalPositionState::getPos(sint32 &px, sint32 &py)
// ***************************************************************************
void CAnimalPositionState::serial(NLMISC::IStream &f)
{
f.serialCheck((uint32) 'APS_');
f.serialCheck(NELID("APS_"));
f.serialVersion(0);
CUIDEntityPositionState::serial(f);
serialNodeLeaf(f, _Status);
f.serialCheck((uint32) 'END_');
f.serialCheck(NELID("END_"));
}
@ -299,11 +299,11 @@ bool CDialogEntityPositionState::getDbPos(sint32 &px, sint32 &py)
// ***************************************************************************
void CNamedEntityPositionState::serial(NLMISC::IStream &f)
{
f.serialCheck((uint32) 'NEPS');
f.serialCheck(NELID("NEPS"));
f.serialVersion(0);
serialNodeLeaf(f, _Name);
serialNodeLeaf(f, _X);
serialNodeLeaf(f, _Y);
f.serialCheck((uint32) 'END_');
f.serialCheck(NELID("END_"));
}

View file

@ -23,7 +23,7 @@
void CFilteredChatSummary::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
sint ver= f.serialVersion(2);
f.serialCheck((uint32) 'USHC');
f.serialCheck(NELID("USHC"));
f.serial(SrcGuild);
f.serial(SrcTeam);
f.serial(SrcAroundMe);
@ -42,7 +42,7 @@ void CFilteredChatSummary::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
void CFilteredDynChatSummary::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
sint ver = f.serialVersion(0);
f.serialCheck((uint32) 'USHC');
f.serialCheck((NELID("USHC"));
if (ver >= 0)
{
for (uint8 i = 0; i < CChatGroup::MaxDynChanPerPlayer; i++)

View file

@ -68,7 +68,7 @@ void CCompassTarget::serial(NLMISC::IStream &f)
return;
}
}
f.serialCheck((uint32) 'CTAR');
f.serialCheck(NELID("CTAR"));
f.serialVersion(0);
f.serial(Pos);
// for the name, try to save a string identifier if possible, because language may be changed between
@ -95,7 +95,7 @@ void CCompassTarget::serial(NLMISC::IStream &f)
_PositionState = NULL;
}
}
f.serialCheck((uint32) '_END');
f.serialCheck(NELID("_END"));
// if language has been modified, then we are not able to display correctly the name, so just
// reset the compass to north to avoid incoherency
if (f.isReading())

View file

@ -1663,7 +1663,7 @@ bool CInterfaceManager::loadConfig (const string &filename)
// serial user chats info (serial it before position of windows so that they can be updated properly)
if (ver >= 1)
{
f.serialCheck(uint32('_ICU'));
f.serialCheck(NELID("_ICU"));
if (!PeopleInterraction.loadUserChatsInfos(f))
{
nlwarning("Bad user chat saving");
@ -1671,7 +1671,7 @@ bool CInterfaceManager::loadConfig (const string &filename)
}
// header
f.serialCheck(uint32('GFCI'));
f.serialCheck(NELID("GFCI"));
f.serial(nNbMode);
f.serial(_CurrentMode);
if(ver>=10)
@ -1897,7 +1897,7 @@ bool CInterfaceManager::saveConfig (const string &filename)
f.serialVersion(ICFG_STREAM_VERSION);
// serial user chats info (serial it before position of windows so that they can be updated properly)
f.serialCheck(uint32('_ICU'));
f.serialCheck(NELID("_ICU"));
if (!PeopleInterraction.saveUserChatsInfos(f))
{
nlwarning("Config saving failed");
@ -1907,7 +1907,7 @@ bool CInterfaceManager::saveConfig (const string &filename)
}
// header
f.serialCheck(uint32('GFCI'));
f.serialCheck(NELID("GFCI"));
f.serial(i);
f.serial(_CurrentMode);
f.serial(_LastInGameScreenW);

View file

@ -1695,14 +1695,14 @@ bool CPeopleInterraction::saveUserChatsInfos(NLMISC::IStream &f)
try
{
sint ver= f.serialVersion(USER_CHATS_INFO_VERSION);
f.serialCheck((uint32) 'TAHC');
f.serialCheck(NELID("TAHC"));
//saveFilteredChat(f, MainChat);
saveFilteredChat(f, ChatGroup);
for(uint k = 0; k < MaxNumUserChats; ++k)
{
saveFilteredChat(f, UserChat[k]);
}
f.serialCheck((uint32) 'TAHC');
f.serialCheck(NELID("TAHC"));
if (ver>=1)
{
CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow();
@ -1732,7 +1732,7 @@ bool CPeopleInterraction::saveUserDynChatsInfos(NLMISC::IStream &f)
try
{
sint ver = f.serialVersion(USER_DYN_CHATS_INFO_VERSION);
f.serialCheck((uint32) 'OMGY');
f.serialCheck(NELID("OMGY"));
if (ver >= 1)
{
saveFilteredDynChat(f, TheUserChat);
@ -1755,7 +1755,7 @@ bool CPeopleInterraction::loadUserChatsInfos(NLMISC::IStream &f)
{
bool present;
sint ver = f.serialVersion(USER_CHATS_INFO_VERSION);
f.serialCheck((uint32) 'TAHC');
f.serialCheck(NELID("TAHC"));
f.serial(present);
if (!present)
{
@ -1777,7 +1777,7 @@ bool CPeopleInterraction::loadUserChatsInfos(NLMISC::IStream &f)
setupUserChatFromSummary(fcs, UserChat[k]);
}
}
f.serialCheck((uint32) 'TAHC');
f.serialCheck(NELID("TAHC"));
if (ver>=1)
{
// CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow();
@ -1819,7 +1819,7 @@ bool CPeopleInterraction::loadUserDynChatsInfos(NLMISC::IStream &f)
{
bool present;
sint ver = f.serialVersion(USER_DYN_CHATS_INFO_VERSION);
f.serialCheck((uint32) 'OMGY');
f.serialCheck(NELID("OMGY"));
f.serial(present);
if (!present)
{

View file

@ -429,7 +429,7 @@ CPackedWorld *CIslandCollision::reloadPackedIsland(const CScenarioEntryPoints::C
try
{
CIFile f(CPath::lookup(islandDesc.Island + ".island_hm"));
f.serialCheck((uint32) 'MHSI');
f.serialCheck(NELID("MHSI"));
f.serial(_HeightMap);
}
catch(const Exception &e)

View file

@ -341,8 +341,8 @@ private:
void serial(NLMISC::IStream &f)
{
f.serialCheck((uint32)'_RTS');
f.serialCheck((uint32)'KCAP');
f.serialCheck(NELID("_RTS"));
f.serialCheck(NELID("KCAP"));
f.serialVersion(0);
f.serial(PackedVersion);
f.serial(LanguageCode);

View file

@ -553,7 +553,7 @@ void CWorldMap::clear()
void CWorldMap::serial(NLMISC::IStream &f)
{
f.serialCheck((uint32)'WMAP');
f.serialCheck(NELID("WMAP');
// Version
// 0: initial version

View file

@ -259,7 +259,7 @@ bool CDBDeltaFile::preload()
*/
bool CDBDeltaFile::serialHeader()
{
serialCheck((uint32)'DbDt');
serialCheck(NELID("DbDt');
uint version = serialVersion(0);
if (isReading())
@ -280,7 +280,7 @@ bool CDBDeltaFile::serialHeader()
serial(_Header);
}
serialCheck((uint32)'Data');
serialCheck(NELID("Data');
_DataStart = ftell(_File);

View file

@ -189,7 +189,7 @@ private:
void serial(NLMISC::IStream& s)
{
s.serialCheck((uint32)'DHdr');
s.serialCheck(NELID("DHdr');
uint version = s.serialVersion(0);
s.serial(RowSize);

View file

@ -483,7 +483,7 @@ bool CDBReferenceFile::read(uint32 index, uint8* rowdata)
*/
bool CDBReferenceFile::serialHeader()
{
serialCheck((uint32)'DbRf');
serialCheck(NELID("DbRf');
uint version = serialVersion(0);
if (isReading())
@ -504,7 +504,7 @@ bool CDBReferenceFile::serialHeader()
serial(_Header);
}
serialCheck((uint32)'Data');
serialCheck(NELID("Data');
_DataStart = ftell(_File);

View file

@ -199,7 +199,7 @@ private:
void serial(NLMISC::IStream& s)
{
s.serialCheck((uint32)'RHdr');
s.serialCheck(NELID("RHdr');
uint version = s.serialVersion(0);
s.serial(BaseIndex);

View file

@ -1436,7 +1436,7 @@ inline uint32 CDbMessage::getMessageHeaderSize()
*/
inline void CUpdateLog::serial(NLMISC::IStream& f)
{
f.serialCheck((uint32)'ULOG');
f.serialCheck(NELID("ULOG');
uint version = f.serialVersion(1);

View file

@ -331,7 +331,7 @@ void CDatabaseState::serial(NLMISC::IStream& s)
{
s.xmlPush("database_state");
s.serialCheck((uint32)'DBST');
s.serialCheck(NELID("DBST');
uint version = s.serialVersion(0);
s.xmlPush("name");

View file

@ -60,7 +60,7 @@ public:
{
s.xmlPush("reference");
s.serialCheck((uint32)'RIDX');
s.serialCheck(NELID("RIDX');
uint version = s.serialVersion(0);
s.xmlPush("database");

View file

@ -73,7 +73,7 @@ void CPDStringMapper::setMapping(const std::string& str, uint32 id)
*/
void CPDStringMapper::serial(NLMISC::IStream& f)
{
f.serialCheck((uint32)'PDSM');
f.serialCheck(NELID("PDSM');
uint version = f.serialVersion(0);

View file

@ -714,7 +714,7 @@ public:
void serial(NLMISC::IStream& f)
{
f.serialCheck((uint32)'IALC');
f.serialCheck(NELID("IALC');
f.serialVersion(0);
f.serial(_NextIndex);

View file

@ -114,7 +114,7 @@ void CLightIGLoader::loadIG(const string &filename)
// Serial a header
_File.serialCheck ((uint32)'TPRG');
_File.serialCheck (NELID("TPRG');
// Serial a version number
sint version = _File.serialVersion (5);