// *************************************************************************** void CInterfaceConfig::dataBaseToStream (NLMISC::IStream &f) { if (f.isReading()) { nlwarning("stream is not in writing mode"); return; } CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Save branch of the database SDBLeaf leafTmp; CCDBNodeBranch *pDB = pIM->getDbBranch ("UI:SAVE"); if (pDB != NULL) { // Number of leaf to save uint32 nbLeaves = pDB->countLeaves(); f.serial(nbLeaves); for (uint32 i = 0; i < nbLeaves; ++i) { uint count = i; CCDBNodeLeaf *pNL = pDB->findLeafAtCount(count); leafTmp.setFrom(pNL); f.serial(leafTmp); } } }
//*********************************************************************************************** void CParticleWorkspace::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { f.xmlPush("PARTICLE_WORKSPACE"); f.serialVersion(0); f.xmlSerial(_Name, "NAME"); f.xmlPush("PS_LIST"); uint32 numNodes = (uint32)_Nodes.size(); // TODO : avoid to store the number of nodes f.xmlSerial(numNodes, "NUM_NODES"); if (f.isReading()) { for(uint k = 0; k < numNodes; ++k) { _Nodes.push_back(new CNode()); _Nodes.back()->init(this); f.serial(*_Nodes.back()); } } else { for(uint k = 0; k < numNodes; ++k) { f.serial(*_Nodes[k]); } } f.xmlPop(); f.xmlPop(); }
void CScriptData::serial(NLMISC::IStream &f) { uint16 size; if (f.isReading()) { Scripts.clear(); f.serial(size); uint32 i = 0; for (; i < size; ++i) { //std::string tmpKey; CCustomElementId tmpKey; std::vector<std::string> tmpVal; f.serial(tmpKey); f.serialCont(tmpVal); Scripts.insert(make_pair(tmpKey,tmpVal)); } } else { size = (uint16)Scripts.size(); f.serial(size); for (TScripts::iterator it = Scripts.begin(); it != Scripts.end(); ++it) { //std::string tmp = it->first; nlWrite(f, serial, it->first); nlWrite(f, serialCont, it->second); } } }
void CStreamSound::serial(NLMISC::IStream &s) { CSound::serial(s); s.serial(_MinDist); s.serial(m_Alpha); }
// *************************************************************************** void CVegetable::serial(NLMISC::IStream &f) { /* Version 1: - add BendFrequencyFactor Version 0: - base version */ sint ver= f.serialVersion(1); f.serial(ShapeName); f.serial(Density); f.serial(MaxDensity); f.serial(_CosAngleMin, _CosAngleMax, _CosAngleMiddle, _OOCosAngleDist); f.serialEnum(_AngleType); f.serial(Sxy, Sz); f.serial(Rx, Ry, Rz); f.serial(BendFactor); f.serial(BendPhase); f.serial(Color); f.serial(DistType); if(ver>=1) f.serial(BendFrequencyFactor); else BendFrequencyFactor= 1; }
void CSimpleSound::serial(NLMISC::IStream &s) { std::string bufferName; CSound::serial(s); s.serial(_MinDist); s.serial(_Alpha); if (s.isReading()) { s.serial(bufferName); _Buffername = CStringMapper::map(bufferName); setBuffer(NULL); // contain % so it need a context to play if (bufferName.find ("%") != string::npos) { _NeedContext = true; } } else { bufferName = CStringMapper::unmap(_Buffername); s.serial(bufferName); } }
void CCustomLootTableManager::serial(NLMISC::IStream &f) { uint16 size; if (f.isReading()) { Tables.clear(); f.serial(size); uint32 i = 0; for (; i < size; ++i) { //std::string tmpKey; CCustomElementId tmpKey; CCustomLootTable tmpVal; f.serial(tmpKey); f.serial(tmpVal); Tables.insert(make_pair(tmpKey,tmpVal)); } } else { size = (uint16)Tables.size(); f.serial(size); for (TCustomLootTable::iterator it = Tables.begin(); it != Tables.end(); ++it) { nlWrite(f, serial, it->first); nlWrite(f, serial, it->second); } } }
// *************************************************************************** void CCtrlBase::serial(NLMISC::IStream &f) { CViewBase::serial(f); f.serial(_ContextHelp); f.serial(_OnContextHelp); f.serial(_OnContextHelpParams); f.serial(_ToolTipSpecialParent); f.serialEnum(_ToolTipParent); // THotSpot tmpToolTipParentPosRef = _ToolTipParentPosRef; THotSpot tmpToolTipPosRef = _ToolTipPosRef; THotSpot tmpToolTipParentPosRefAlt = _ToolTipParentPosRefAlt; THotSpot tmpToolTipPosRefAlt = _ToolTipPosRefAlt; f.serialEnum(tmpToolTipParentPosRef); f.serialEnum(tmpToolTipPosRef); f.serialEnum(tmpToolTipParentPosRefAlt); f.serialEnum(tmpToolTipPosRefAlt); _ToolTipParentPosRef = tmpToolTipParentPosRef; _ToolTipPosRef = tmpToolTipPosRef; _ToolTipParentPosRefAlt = tmpToolTipParentPosRefAlt; _ToolTipPosRefAlt = tmpToolTipPosRefAlt; // nlSerialBitBool(f, _ToolTipInstant); }
///====================================================================================== void CPSFace::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { NL_PS_FUNC(CPSFace_IStream ) f.serialVersion(1); CPSQuad::serial(f); CPSRotated3DPlaneParticle::serialPlaneBasisScheme(f); if (f.isReading()) { uint32 nbConfigurations; f.serial(nbConfigurations); if (nbConfigurations) { f.serial(_MinAngularVelocity, _MaxAngularVelocity); } hintRotateTheSame(nbConfigurations, _MinAngularVelocity, _MaxAngularVelocity); init(); } else { uint32 nbConfigurations = (uint32)_PrecompBasis.size(); f.serial(nbConfigurations); if (nbConfigurations) { f.serial(_MinAngularVelocity, _MaxAngularVelocity); } } }
void CCustomLootTable::serial(NLMISC::IStream &f) { f.serial(LootSets); f.serial(MoneyFactor); f.serial(MoneyProba); f.serial(MoneyBase); }
// *************************************************************************** void CInterfaceConfig::streamToDataBase (NLMISC::IStream &f, uint32 uiDbSaveVersion) { if (!f.isReading()) { nlwarning("stream is not in reading mode"); return; } sint32 begPos = f.getPos(); f.seek (0, NLMISC::IStream::end); sint32 endPos = f.getPos(); if ((begPos - endPos) == 0) return; f.seek (begPos, NLMISC::IStream::begin); CInterfaceManager *pIM = CInterfaceManager::getInstance(); // Load branch of the database SDBLeaf leafTmp; CCDBNodeBranch *pDB = pIM->getDbBranch ("UI:SAVE"); if (pDB != NULL) { // Number of leaf to save uint32 nbLeaves = 0; f.serial(nbLeaves); for (uint32 i = 0; i < nbLeaves; ++i) { f.serial(leafTmp); // If there is a define RESET_VER_dbName that exist for this DB, check if version is OK bool wantRead= true; // Format dbName for version check string defVerId= "RESET_VER_"; defVerId+= leafTmp.Name; for(uint i=0;i<defVerId.size();i++) { if(defVerId[i]==':') defVerId[i]='_'; } // check if exist if(pIM->isDefineExist(defVerId)) { uint32 dbVer; fromString(pIM->getDefine(defVerId), dbVer); // if the version in the file is older than the version this db want, abort read if(uiDbSaveVersion<dbVer) wantRead= false; } // if want read the value from file, read it, else keep the default one if(wantRead) { CCDBNodeLeaf *pNL = pIM->getDbProp(leafTmp.Name,false); if (pNL != NULL) leafTmp.setTo(pNL); } } } }
// *************************************************************************** void CTrackSampledCommon::CTimeBlock::serial(NLMISC::IStream &f) { (void)f.serialVersion(0); f.serial(TimeOffset); f.serial(KeyOffset); f.serial(Times); }
void CPrimitivePlugin::TCreatureInfo::serial (NLMISC::IStream &s) { s.serial(HaveRadius); s.serial(Radius); s.serial(HaveBox); s.serial(Width); s.serial(Length); }
void CModifierInDB::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { f.serial(Disabled); if(Disabled) { f.serial(ActivationDate); f.serial(SheetId); } }
///=========================================================================== void CParticleSystemShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance * It can be loaded/called through CAsyncFileManager for instance * ***********************************************/ sint ver = f.serialVersion(6); /// version 6 : added sharing flag //NLMISC::CVector8 &buf = _ParticleSystemProto.bufferAsVector(); //f.serialCont(buf); if (f.isReading ()) { std::vector<uint8> buf; f.serialCont(buf); _ParticleSystemProto.fill(&buf[0], (uint32)buf.size()); } else { f.serialBufferWithSize ((uint8*)_ParticleSystemProto.buffer(), _ParticleSystemProto.length()); } if (ver > 1) { // serial default tracks for (uint k = 0; k < 4; ++k) { f.serial(_UserParamDefaultTrack[k]); } } if ( ver > 2) { f.serial (_DefaultPos); f.serial (_DefaultScale); f.serial (_DefaultRotQuat); } if ( ver > 3) { f.serial(_MaxViewDist); f.serial(_DestroyWhenOutOfFrustum); f.serial(_DestroyModelWhenOutOfRange); } if ( ver > 4) { f.serial(_UsePrecomputedBBox); if (_UsePrecomputedBBox) { f.serial(_PrecomputedBBox); } } if ( ver > 5) { f.serial(_Sharing); } }
// *************************************************************************** void CAABBox::serial(NLMISC::IStream &f) { /* *********************************************** * WARNING: This Class/Method must be thread-safe (ctor/dtor/serial): no static access for instance * It can be loaded/called through CAsyncFileManager for instance * ***********************************************/ (void)f.serialVersion(0); f.serial(Center); f.serial(HalfSize); }
void CFormBodyEltAtom::serial( NLMISC::IStream& s) { s.xmlPushBegin( "Atom" ); s.xmlSetAttrib( "Name" ); s.serial( sxname ); s.xmlSetAttrib( "Value" ); s.serial( sxvalue ); s.xmlPushEnd(); s.xmlPop(); }
// *************************************************************************** void CMaterial::CLightMap::serial2(NLMISC::IStream &f) { sint ver= f.serialVersion(1); f.serial(Factor); f.serial(LMCDiffuse); if(ver>=1) f.serial(LMCAmbient); // Serial texture descriptor. Texture.serialPolyPtr(f); }
void CStreamSound::serial(NLMISC::IStream &s) { CSound::serial(s); s.serial(_MinDist); s.serial(m_Alpha); #if NLSOUND_SHEET_VERSION_BUILT < 2 if (s.isReading()) _GroupController = CGroupControllerRoot::getInstance()->getGroupController(NLSOUND_SHEET_V1_DEFAULT_SOUND_STREAM_GROUP_CONTROLLER); #endif }
// *************************************************************************** void CInterfaceConfig::SDBLeaf::serial(NLMISC::IStream &f) { // version 1 : added old value ( else some observers are not launched ) // version 0 : base version sint ver = f.serialVersion(1); f.serial(Name); f.serial(Value); if (ver >= 1) f.serial(OldValue); else OldValue = Value; }
//=========================================================== void CSegRemanenceShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { // version 2 : added default tracks // version 1 : rollup ratio // version 0 : base version sint ver = f.serialVersion(2); f.serial(_NumSlices); f.serial(_SliceTime); f.serialCont(_Corners); f.serial(_Mat); f.serial(_BBox); f.serial(_TextureShifting); f.serialPtr(_AnimatedMat); if (f.isReading()) { _GeomTouched = true; _MatTouched = true; } if (ver >= 1) { f.serial(_RollUpRatio); } if (ver >= 2) { f.serial(_DefaultPos); f.serial(_DefaultRotQuat); f.serial(_DefaultScale); } }
// *************************************************************************** void CStringMapper::localSerialString(NLMISC::IStream &f, TStringId &id) { std::string str; if(f.isReading()) { f.serial(str); id= localMap(str); } else { str= localUnmap(id); f.serial(str); } }
// *************************************************************************** void CInterfaceElement::serialAH(NLMISC::IStream &f, IActionHandler *&ah) { std::string ahName; if (f.isReading()) { f.serial(ahName); ah = CAHManager::getInstance()->getActionHandler(ahName); } else { ahName = CAHManager::getInstance()->getActionHandlerName(ah); f.serial(ahName); } }
//======================================================= void CPSRibbonLookAt::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { NL_PS_FUNC(CPSRibbonLookAt_serial) /** Version 4 : added CPSRibbonBase has a base class instead of CPSParticle * */ sint ver = f.serialVersion(4); if (ver > 3) { CPSRibbonBase::serial(f); } else { CPSParticle::serial(f); } CPSColoredParticle::serialColorScheme(f); CPSSizedParticle::serialSizeScheme(f); serialMaterial(f); uint32 dummy = 0; /* _NbDyingRibbons */ if (ver <= 3) { f.serial(_SegDuration, _NbSegs, dummy /*_NbDyingRibbons*/); } ITexture *tex = NULL; if (ver > 2) { f.serial(_Parametric); } if (!f.isReading()) { tex = _Tex; f.serialPolyPtr(tex); } else { f.serialPolyPtr(tex); setTexture(tex); _Tex = tex; if (_Tex) { _Tex->setWrapS(ITexture::Clamp); _Tex->setWrapT(ITexture::Clamp); } setTailNbSeg(_NbSegs); // force to build the vb } }
// *************************************************************************** void CMaterialBase::serial(NLMISC::IStream &f) { sint ver= f.serialVersion(1); f.serial(Name); f.serial(DefaultAmbient, DefaultDiffuse, DefaultSpecular); f.serial(DefaultShininess, DefaultEmissive, DefaultOpacity, DefaultTexture); f.serialCont(_AnimatedTextures); if (ver > 0) { for (uint k = 0; k < IDRV_MAT_MAXTEXTURES; ++k) { f.serial(DefaultTexAnimTracks[k]); } } }
// *************************************************************************** void CSkeletonShape::CLod::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { (void)f.serialVersion(0); f.serial(Distance); f.serialCont(ActiveBones); }
//----------------------------------------------------------------------------- void CPowerActivationDate::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { f.serial( DeactivationDate ); f.serial( ActivationDate ); if (f.isReading()) { std::string tmp; f.serial( tmp); PowerType = POWERS::toPowerType(tmp); } else { std::string tmp = POWERS::toString(PowerType); f.serial( tmp); } }
void CSheetId::serialString(NLMISC::IStream &f, const std::string &defaultType) throw(NLMISC::EStream) { nlassert(_Initialised); if (f.isReading()) { std::string sheetName; f.serial(sheetName); *this = CSheetId(sheetName, defaultType); } else { // if this assert fails, you may be using an outdated id bin nlassert(*this != CSheetId::Unknown); std::string sheetName = toString(); f.serial(sheetName); } }
// *************************************************************************** void CInterfaceElement::serial(NLMISC::IStream &f) { f.serialPolyPtr(_Parent); f.serial(_Id); f.serial(_Active); f.serial(_InvalidCoords); f.serial(_XReal, _YReal, _WReal, _HReal); f.serial(_X, _Y, _W, _H); f.serialEnum(_PosRef); f.serialEnum(_ParentPosRef); _ParentPos.serialPolyPtr(f); f.serial(_SizeRef); f.serial(_SizeDivW, _SizeDivH); _ParentSize.serialPolyPtr(f); f.serial(_ModulateGlobalColor); f.serial(_RenderLayer); f.serial(_AvoidResizeParent); nlassert(_Links == NULL); // not supported }
///======================================================================================= void CPSFloatCurveFunctor::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { f.serialVersion(1); f.serial(_NumSamples, _Smoothing); f.serialCont(_CtrlPoints); if (f.isReading()) { updateTab(); } }