void CVisualConfig::serial(NLMISC::IStream & f) throw (NLMISC::EStream) { if (!f.isReading()) { throw "This is only for reading"; } uint8 ver; f.serial(ver); nldebug("CVisualConfig::serial version %d", ver); if (ver < 2) { pktFormat = (EPacketFormat) ver; } else { f.serialShortEnum(pktFormat); } f.serialShortEnum(Race); if (ver >= 2) { f.serial(Age); if (Age > 2) { Age = 2; } } else { Age = 0; } if (pktFormat == PKT_SHORT) { nldebug(">> short packet"); vpa.serial(f); vpb.serial(f); vpc.serial(f); nlinfo("1"); } else { nldebug(">> long packet"); // they say bitfields are compiler and platform specific - this is mainly for php uint32 b; f.serial(b); vpa.PropertySubData.Sex = b; f.serial(b); vpa.PropertySubData.JacketModel = b; f.serial(b); vpa.PropertySubData.JacketColor = b; f.serial(b); vpa.PropertySubData.TrouserModel = b; f.serial(b); vpa.PropertySubData.TrouserColor = b; f.serial(b); vpa.PropertySubData.WeaponRightHand = b; f.serial(b); vpa.PropertySubData.WeaponLeftHand = b; f.serial(b); vpa.PropertySubData.ArmModel = b; f.serial(b); vpa.PropertySubData.ArmColor = b; f.serial(b); vpa.PropertySubData.HatModel = b; f.serial(b); vpa.PropertySubData.HatColor = b; f.serial(b); vpb.PropertySubData.Name = b; f.serial(b); vpb.PropertySubData.HandsModel = b; f.serial(b); vpb.PropertySubData.HandsColor = b; f.serial(b); vpb.PropertySubData.FeetModel = b; f.serial(b); vpb.PropertySubData.FeetColor = b; f.serial(b); vpb.PropertySubData.RTrail = b; f.serial(b); vpb.PropertySubData.LTrail = b; f.serial(b); vpc.PropertySubData.MorphTarget1 = b; f.serial(b); vpc.PropertySubData.MorphTarget2 = b; f.serial(b); vpc.PropertySubData.MorphTarget3 = b; f.serial(b); vpc.PropertySubData.MorphTarget4 = b; f.serial(b); vpc.PropertySubData.MorphTarget5 = b; f.serial(b); vpc.PropertySubData.MorphTarget6 = b; f.serial(b); vpc.PropertySubData.MorphTarget7 = b; f.serial(b); vpc.PropertySubData.MorphTarget8 = b; f.serial(b); vpc.PropertySubData.EyesColor = b; f.serial(b); vpc.PropertySubData.Tattoo = b; f.serial(b); vpc.PropertySubData.CharacterHeight = b; f.serial(b); vpc.PropertySubData.TorsoWidth = b; f.serial(b); vpc.PropertySubData.ArmsWidth = b; f.serial(b); vpc.PropertySubData.LegsWidth = b; f.serial(b); vpc.PropertySubData.BreastSize = b; } // hair color can only come from HEAD_SLOT, so use it and clamp it HairColor = vpa.PropertySubData.HatColor; NLMISC::clamp(HairColor, (uint) 1, (uint) 6); // H1..H6 sint32 angle; f.serial(angle); // convert angle from CCW to CW (clockwise) angle = (270 - angle); if (angle < 0) { angle += 360; } Theta = angle * 3.14 / 180; nlinfo("2"); f.serial(angle); Phi = angle * 3.14 / 180; nlinfo("3"); f.serial(FaceShot); nlinfo("4"); Background.serial(f); nlinfo("5"); if (ver >= 2) { f.serial(useFx); nlinfo("6"); } else { useFx = Background.A == 255; } nldebug(">> serial in"); nldebug(">> race: %s", EGSPD::CPeople::toString(Race).c_str()); nldebug(">> age: %d", Age); nldebug("VPA: %"NL_I64"u : Chest(%d,%d) Legs(%d,%d) Arms(%d,%d) Hat(%d,%d) RH(%d) LH(%d)", vpa.PropertyA, (uint) vpa.PropertySubData.JacketModel, (uint) vpa.PropertySubData.JacketColor, (uint) vpa.PropertySubData.TrouserModel, (uint) vpa.PropertySubData.TrouserColor, (uint) vpa.PropertySubData.ArmModel, (uint) vpa.PropertySubData.ArmColor, (uint) vpa.PropertySubData.HatModel, (uint) vpa.PropertySubData.HatColor, (uint) vpa.PropertySubData.WeaponRightHand, (uint) vpa.PropertySubData.WeaponLeftHand); nldebug("VPB: %"NL_I64"u : Hands(%d,%d) Feet(%d,%d).", vpb.PropertyB, (uint) vpb.PropertySubData.HandsModel, (uint) vpb.PropertySubData.HandsColor, (uint) vpb.PropertySubData.FeetModel, (uint) vpb.PropertySubData.FeetColor); nldebug("VPC: %"NL_I64"u : EyesColor(%d) Tattoo(%d).", vpc.PropertyC, (uint) vpc.PropertySubData.EyesColor, (uint) vpc.PropertySubData.Tattoo); nldebug("VPC: morph(%d,%d,%d,%d,%d,%d,%d,%d), gabarit(%d,%d,%d,%d,%d)", (uint) vpc.PropertySubData.MorphTarget1, (uint) vpc.PropertySubData.MorphTarget2, (uint) vpc.PropertySubData.MorphTarget3, (uint) vpc.PropertySubData.MorphTarget4, (uint) vpc.PropertySubData.MorphTarget5, (uint) vpc.PropertySubData.MorphTarget6, (uint) vpc.PropertySubData.MorphTarget7, (uint) vpc.PropertySubData.MorphTarget8, (uint) vpc.PropertySubData.CharacterHeight, (uint) vpc.PropertySubData.TorsoWidth, (uint) vpc.PropertySubData.ArmsWidth, (uint) vpc.PropertySubData.LegsWidth, (uint) vpc.PropertySubData.BreastSize); nldebug(">> angle = %f, %f", Theta, Phi); nldebug(">> face shot: %s", FaceShot ? "yes" : "no"); nldebug(">> use fx: %s", useFx ? "yes" : "no"); }
// *************************************************************************** void CMaterial::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 * ***********************************************/ /* Version 9: - Added support for third operand (for Mad operator) Version 8: - Serial _TexCoordGenMode Version 7: - Lightmap color and Mulx2 Version 6: - Texture matrix animation Version 5: - AlphaTest threshold Version 4: - Texture Addressing modes Version 3: - LightMaps. Version 2: - Shininess. Version 1: - texture environement. Version 0: - base version. */ sint ver= f.serialVersion(9); // For the version <=1: nlassert(IDRV_MAT_MAXTEXTURES==4); f.serialEnum(_ShaderType); f.serial(_Flags); f.serialEnum(_SrcBlend); f.serialEnum(_DstBlend); f.serialEnum(_ZFunction); f.serial(_ZBias); f.serial(_Color); f.serial(_Emissive, _Ambient, _Diffuse, _Specular); if(ver>=2) { f.serial(_Shininess); } if(ver>=5) { f.serial(_AlphaTestThreshold); } if(ver>=8) { f.serial(_TexCoordGenMode); } else _TexCoordGenMode = 0; for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++) { // Serial texture descriptor. _Textures[i].serialPolyPtr(f); // Read texture environnement, or setup them. if(ver>=1) { _TexEnvs[i].serial(f, ver >= 9 ? 1 : 0); } else { // Else setup as default behavior, like before... if(f.isReading()) _TexEnvs[i].setDefault(); } } if(ver>=3) { if(ver>=7) { uint32 n; if (f.isReading()) { f.serial(n); _LightMaps.resize(n); } else { n = (uint32)_LightMaps.size(); f.serial(n); } for (uint32 i = 0; i < n; ++i) _LightMaps[i].serial2(f); f.serial(_LightMapsMulx2); } else { f.serialCont(_LightMaps); } } if (ver >= 4) { if (_Flags & IDRV_MAT_TEX_ADDR) { for(uint32 i=0;i<IDRV_MAT_MAXTEXTURES;i++) { f.serial(_TexAddrMode[i]); } } } if(f.isReading()) { // Converte Deprecated DEFMAT to std Mat. if(_Flags & IDRV_MAT_DEFMAT) { setEmissive(CRGBA::Black); setAmbient(CRGBA::White); setDiffuse(CRGBA::White); setSpecular(CRGBA::Black); } // All states of material are modified. _Touched= IDRV_TOUCHED_ALL; if ((_Flags & IDRV_MAT_USER_TEX_MAT_ALL)) // are there user textrue coordinates matrix ? { std::auto_ptr<CUserTexMat> newPtr(new CUserTexMat); // create new //std::swap(_TexUserMat, newPtr); // replace old _TexUserMat = newPtr; } } if (ver >= 6) { for(uint i=0; i < IDRV_MAT_MAXTEXTURES; ++i) { if (isUserTexMatEnabled(i)) { f.serial(_TexUserMat->TexMat[i]); } } } }
// *************************************************************************** void CSheetManagerEntry::serial (NLMISC::IStream &s) { if (s.isReading()) { // if (EntitySheet != NULL) // delete EntitySheet; CEntitySheet::TType type = CEntitySheet::TypeCount; s.serialEnum(type); switch(type) { case CEntitySheet::FAUNA: { EntitySheet = new CCharacterSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::FLORA: { EntitySheet = new CFloraSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::CHAR: { EntitySheet = new CPlayerSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::FX: { EntitySheet = new CFXSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::BUILDING: { EntitySheet = new CBuildingSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::ITEM: { EntitySheet = new CItemSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::PLANT: { EntitySheet = new CPlantSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::PACT: { EntitySheet = new CPactSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::MISSION: { EntitySheet = new CMissionSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::MISSION_ICON: { EntitySheet = new CMissionIconSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::RACE_STATS: { EntitySheet = new CRaceStatsSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::LIGHT_CYCLE: { EntitySheet = new CLightCycleSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::WEATHER_SETUP: { EntitySheet = new CWeatherSetupSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::CONTINENT: { EntitySheet = new CContinentSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::WORLD: { EntitySheet = new CWorldSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::WEATHER_FUNCTION_PARAMS: { EntitySheet = new CWeatherFunctionParamsSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::SBRICK: { EntitySheet = new CSBrickSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::SPHRASE: { EntitySheet = new CSPhraseSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::SKILLS_TREE: { EntitySheet = new CSkillsTreeSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::UNBLOCK_TITLES: { EntitySheet = new CUnblockTitlesSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::SUCCESS_TABLE: { EntitySheet = new CSuccessTableSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::AUTOMATON_LIST: { EntitySheet = new CAutomatonListSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::ANIMATION_SET_LIST: { EntitySheet = new CAnimationSetListSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::ANIMATION_FX: { EntitySheet = new CAnimationFXSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::ID_TO_STRING_ARRAY: { EntitySheet = new CIDToStringArraySheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::EMOT: { EntitySheet = new CEmotListSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::FORAGE_SOURCE: { EntitySheet = new CForageSourceSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::ANIMATION_FX_SET: { EntitySheet = new CAnimationFXSetSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::ATTACK_LIST: { EntitySheet = new CAttackListSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::TEXT_EMOT: { EntitySheet = new CTextEmotListSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::SKY: { EntitySheet = new CSkySheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::OUTPOST: { EntitySheet = new COutpostSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::OUTPOST_BUILDING: { EntitySheet = new COutpostBuildingSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::OUTPOST_SQUAD: { EntitySheet = new COutpostSquadSheet; initSheet(EntitySheet, s, type); } break; case CEntitySheet::FACTION: { EntitySheet = new CFactionSheet; initSheet(EntitySheet, s, type); } break; default: nlwarning("CSheetManager::load: Unknown type '%d' in the packed file. Rebuild=true and Ignore this sheet.", type); EntitySheet = NULL; break; } } else { if (EntitySheet != NULL) { s.serialEnum(EntitySheet->Type); EntitySheet->Id.serial(s); EntitySheet->serial(s); } else { // write a speudo entry into the stream CEntitySheet::TType tmp = CEntitySheet::UNKNOWN; s.serialEnum(tmp); } } }
// *************************************************************************** void CInterfaceConfig::CDesktopImage::serial(NLMISC::IStream &s) { if (s.isReading()) read(s); else write(s); }
// *************************************************************************** void CInterfaceConfig::SCont::serial(NLMISC::IStream &f) { // version 10 : added minW & maxW // version 9 : Backuped position & touchFlag // version 8 : ContainerMode // version 7 : RolloverAlphaContainer and RolloverAlphaContent separated // version 6 : added 'pop_max_h' value // version 5 : added 'active_savable' flag // version 4 : added 'movable' flag // version 3 : added 'locked' flag // version 2 : added 'useGlobalAlpha' flag // version 1 : added alpha's & popup coords & size // version 0 : base version sint ver = f.serialVersion(10); if (ver >= 10) { f.serial(MinW); f.serial(MaxW); } if (ver >= 8) { if (f.isReading()) { f.serial(Id); Id = "ui:interface:"+Id; } else { std::string shortId; std::string startString; if (Id.size() >= 13) { startString = Id.substr(0, 13); } if (startString == "ui:interface:") { shortId = Id.substr(13,Id.size()); } else { shortId = Id; } f.serial(shortId); } f.serial(ContainerMode); if (ContainerMode == 0) { f.serial(Popuped); f.serial(Opened); f.serial(X); f.serial(Y); f.serial(W); f.serial(H); f.serial(Active); f.serial(ScrollPos); f.serial(BgAlpha); f.serial(ContentAlpha); f.serial(RolloverAlphaContent); f.serial(PopupX); f.serial(PopupY); f.serial(PopupW); f.serial(PopupH); f.serial(UseGlobalAlpha); f.serial(Locked); f.serial(Movable); f.serial(ActiveSavable); f.serial(PopupMaxH); f.serial(RolloverAlphaContainer); if (ver >= 9) { f.serial(BackupedPositionValid); if (BackupedPositionValid) { f.serial(BackupX); f.serial(BackupY); } f.serial(TouchFlag); } } else if (ContainerMode == 1) { f.serial(Opened); f.serial(Active); f.serial(ActiveSavable); } } else { ContainerMode = 0; f.serial(Id); f.serial(Popuped); f.serial(Opened); f.serial(X); f.serial(Y); f.serial(W); f.serial(H); f.serial(Active); f.serial(ScrollPos); if (ver >= 1) { f.serial(BgAlpha); f.serial(ContentAlpha); f.serial(RolloverAlphaContent); f.serial(PopupX); f.serial(PopupY); f.serial(PopupW); f.serial(PopupH); } else { BgAlpha = 255; ContentAlpha = 255; RolloverAlphaContent = RolloverAlphaContainer = 255; PopupX = -1; PopupY = -1; PopupW = -1; PopupH = -1; } if (ver >= 2) f.serial(UseGlobalAlpha); else UseGlobalAlpha = true; if (ver >= 3) f.serial(Locked); else Locked = false; if (ver >= 4) f.serial(Movable); else Movable = true; if (ver >= 5) f.serial(ActiveSavable); else ActiveSavable = true; if (ver >= 6) f.serial(PopupMaxH); else PopupMaxH = 512; if (ver >= 7) f.serial(RolloverAlphaContainer); else RolloverAlphaContainer = RolloverAlphaContent; } }
///================================================================================================================== void CPSRibbon::serial(NLMISC::IStream &f) throw(NLMISC::EStream) { NL_PS_FUNC(CPSRibbon_serial) // Version 3 : - added brace mode // - added orientation enum sint ver = f.serialVersion(3); if (ver == 1) { nlassert(f.isReading()); /// we had CPSParticle::serial(f), but this is not the base class anymore, so we emulate this... /// version 2 : auto-lod saved sint ver2 = f.serialVersion(2); // here is CPSLocatedBindable::serial(f) sint ver3 = f.serialVersion(4); f.serialPtr(_Owner); if (ver3 > 1) f.serialEnum(_LOD); if (ver3 > 2) f.serial(_Name); if (ver3 > 3) { if (f.isReading()) { uint32 id; f.serial(id); setExternID(id); } else { f.serial(_ExternID); } } if (ver2 >= 2) { bool bDisableAutoLOD; f.serial(bDisableAutoLOD); disableAutoLOD(bDisableAutoLOD); } uint32 tailNbSegs; bool colorFading; bool systemBasisEnabled; bool drEnabled; // dying ribbons, not supported in this version CPSColoredParticle::serialColorScheme(f); CPSSizedParticle::serialSizeScheme(f); // we dont use the 2d angle anymore...serial a dummy one { CDummy2DAngle _Dummy2DAngle; _Dummy2DAngle.serialAngle2DScheme(f); } f.serial(colorFading, systemBasisEnabled); serialMaterial(f); f.serial(drEnabled); f.serial(tailNbSegs); ITexture *tex = NULL; f.serialPolyPtr(tex); _Tex = tex; if (_Tex != NULL) { f.serial(_UFactor, _VFactor) ; } // shape serialization f.serialCont(_Shape); _NbSegs = tailNbSegs >> 1; if (_NbSegs < 1) _NbSegs = 2; setInterpolationMode(Linear); nlassert(_Owner); resize(_Owner->getMaxSize()); initDateVect(); resetFromOwner(); }
//============================================ void CWaterShape::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 * ***********************************************/ // version 4 : added scene water env map // version 3 : added '_Splashenabled' flag sint ver = f.serialVersion(4); // serial 'shape' f.serial(_Poly); // serial heightMap identifier f.serial(_WaterPoolID); //serial maps ITexture *map = NULL; if (f.isReading()) { f.serialPolyPtr(map); _EnvMap[0] = map; f.serialPolyPtr(map); _EnvMap[1] = map; f.serialPolyPtr(map); _BumpMap[0] = map; f.serialPolyPtr(map); _BumpMap[1] = map; f.serialPolyPtr(map); _ColorMap = map; computeBBox(); } else { map = _EnvMap[0]; f.serialPolyPtr(map); map = _EnvMap[1]; f.serialPolyPtr(map); map = _BumpMap[0]; f.serialPolyPtr(map); map = _BumpMap[1]; f.serialPolyPtr(map); map = _ColorMap; f.serialPolyPtr(map); } f.serial(_HeightMapScale[0], _HeightMapScale[1], _HeightMapSpeed[0], _HeightMapSpeed[1]); f.serial(_ColorMapMatColumn0, _ColorMapMatColumn1, _ColorMapMatPos); // serial default tracks f.serial(_DefaultPos); f.serial(_DefaultScale); f.serial(_DefaultRotQuat); f.serial(_TransitionRatio); f.serial(_WaveHeightFactor); if (ver >= 1) f.serial (_ComputeLightmap); if (ver >= 2) f.serial (_DistMax); if (ver >= 3) f.serial(_SplashEnabled); if (ver >= 4) { f.serial(_UsesSceneWaterEnvMap[0], _UsesSceneWaterEnvMap[1]); } // tmp /* if (f.isReading()) { _UsesSceneWaterEnvMap[0] = true; _UsesSceneWaterEnvMap[1] = true; } */ }