Ejemplo n.º 1
0
// ---------------------------------------------------------------------------
void CZoneRegion::serial (NLMISC::IStream &f)
{
	f.xmlPush ("LAND");

		sint32 version = f.serialVersion (1);
		f.serialCheck ((uint32)'DNAL');

		f.xmlSerial (_MinX, "MIN_X");
		f.xmlSerial (_MinY, "MIN_Y");
		f.xmlSerial (_MaxX, "MAX_X");
		f.xmlSerial (_MaxY, "MAX_Y");

		if (version == 1)
		{
			f.serialCont (_Zones);
		}

		if (version == 0)
		{
			std::vector<SZoneUnit> vZonesTmp;
			f.serialCont (vZonesTmp);
			_Zones.resize (vZonesTmp.size());
			for (uint32 i = 0; i < vZonesTmp.size(); ++i)
				_Zones[i] = vZonesTmp[i];
		}

	f.xmlPop ();
}
Ejemplo n.º 2
0
// ***************************************************************************
void			CSkills::serial(NLMISC::IStream &f)
{
    if (ShowDebugInChat) nlinfo("Skill are about to...");
    uint	ver= f.serialVersion(0);
    f.serialCont(_I16Skills);
    f.serialCont(_I16Tallies);
    if (ShowDebugInChat) nlinfo("Skills are in!");
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
void CPowerActivationDateVector::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	if (f.isReading())
	{
		f.serialCont(PowerActivationDates);
		cleanVector();
	}
	else
	{
		cleanVector();
		f.serialCont(PowerActivationDates);
	}
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
void CAuraActivationDateVector::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	if (f.isReading())
	{
		f.serialCont(_AuraActivationDates);						
		_AuraUsers.resize(_AuraActivationDates.size(), NLMISC::CEntityId::Unknown);
		cleanVector();
	}
	else
	{
		cleanVector();
		f.serialCont(_AuraActivationDates);
	}
}
Ejemplo n.º 5
0
// ***************************************************************************
void		CVegetableShape::serial(NLMISC::IStream &f)
{
	/*
	Version 1:
		- BestSidedPreComputeLighting
	*/
	sint	ver= f.serialVersion(1);
	f.serialCheck((uint32)'_LEN');
	f.serialCheck((uint32)'GEV_');
	f.serialCheck((uint32)'BATE');
	f.serialCheck((uint32)'__EL');

	f.serial(Lighted);
	f.serial(DoubleSided);
	f.serial(PreComputeLighting);
	f.serial(AlphaBlend);
	f.serialEnum(BendCenterMode);
	f.serial(VB);
	f.serialCont(TriangleIndices);

	if(ver>=1)
		f.serial(BestSidedPreComputeLighting);
	else if(f.isReading())
		BestSidedPreComputeLighting= false;

	// if reading
	if(f.isReading())
	{
		// prepare for instanciation
		InstanceVertices.resize(VB.getNumVertices());
	}
}
Ejemplo n.º 6
0
// ***************************************************************************
void	CSkeletonShape::CLod::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	(void)f.serialVersion(0);

	f.serial(Distance);
	f.serialCont(ActiveBones);
}
Ejemplo n.º 7
0
//===========================================================
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);
	}
}
Ejemplo n.º 8
0
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);			
		}
	}
}
Ejemplo n.º 9
0
void CZoneEdge::serial (NLMISC::IStream& s)
{
	// Serial the version
	/*sint ver =*/ s.serialVersion (0);

	s.xmlPush ("VERTICES");
		s.serialCont (_TheEdge);
	s.xmlPop ();

	s.xmlPush ("VERTICES_ID");
		s.serialCont (_Id);
	s.xmlPop ();

	s.xmlSerial (_Rotation, "ROTATION");

	s.xmlSerial (_OffsetX, _OffsetY, "OFFSET");
}
void	NLPACS::CRetrievableSurface::serial(NLMISC::IStream &f)
{
	/*
	Version 0:
		- base version.
	Version 1:
		- absolute water height and flag
	Version 2:
		- no more topologies in stream (obsolete)
		- no more height quad
		- quantized height (_QuantHeight)
	*/
	sint	ver= f.serialVersion(2);

	if (ver < 2)
		throw EOlderStream();

	uint	i;
	f.serial(_NormalQuanta);
	f.serial(_OrientationQuanta);
	f.serial(_Material);
	f.serial(_Character);
	f.serial(_Level);
	f.serialCont(_Chains);
	f.serialCont(_Loops);
	if (ver <= 1)
	{
		f.serial(_Quad);
		for (i=0; i<NumMaxCreatureModels; ++i)
			f.serial(_Topologies[i]);
	}
	f.serial(_Center);
	f.serial(_IsFloor, _IsCeiling);
	f.serial(_Flags);

	if (ver >= 1)
	{
		f.serial(_WaterHeight);
	}

	if (ver >= 2)
	{
		f.serial(_QuantHeight);
	}
}
Ejemplo n.º 11
0
void CBackgroundSound::serial(NLMISC::IStream &s)
{
	CSound::serial(s);

	s.serialCont(_Sounds);

	if (s.isReading())
		_DurationValid = false;
}
Ejemplo n.º 12
0
///===========================================================================
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);
	}
}
Ejemplo n.º 13
0
///=======================================================================================
void CPSFloatCurveFunctor::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	f.serialVersion(1);
	f.serial(_NumSamples, _Smoothing);
	f.serialCont(_CtrlPoints);
	if (f.isReading())
	{
		updateTab();
	}
}
Ejemplo n.º 14
0
// Fetch data
void	CPDSLib::setupIndexAllocators(NLMISC::IStream &f)
{
	std::vector<CIndexAllocator>	allocators;

	f.serialCont(allocators);

	uint	i;
	for (i=0; i<allocators.size() && i<_Allocators.size(); ++i)
		if (_Allocators[i] != NULL)
			*(_Allocators[i]) = allocators[i];
}
Ejemplo n.º 15
0
// ***************************************************************************
void CMeshMorpher::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
	 * ***********************************************/

	(void)f.serialVersion (0);

	f.serialCont (BlendShapes);
}
// ***************************************************************************
void CAnimationSet::serial (NLMISC::IStream& f)
{
	// serial not possible if header optimisation enabled
	nlassert(!_AnimHeaderOptimisation);

	// Serial an header
	f.serialCheck ((uint32)'_LEN');
	f.serialCheck ((uint32)'MINA');
	f.serialCheck ((uint32)'TES_');

	// Serial a version
	uint	ver= f.serialVersion (1);

	// Serial the class
	f.serialContPtr (_Animation);
	f.serialContPtr (_SkeletonWeight);
	f.serialCont (_AnimationName);
	f.serialCont (_SkeletonWeightName);
	f.serialCont(_ChannelIdByName);
	f.serialCont(_AnimationIdByName);
	f.serialCont(_SkeletonWeightIdByName);
	if(ver>=1)
		f.serialCont(_ChannelName);
	else
		buildChannelNameFromMap();
}
Ejemplo n.º 17
0
/*
 * Serial Mapper
 */
void	CPDStringMapper::serial(NLMISC::IStream& f)
{
	f.serialCheck((uint32)'PDSM');

	uint	version = f.serialVersion(0);

	f.serialCont(_StringMap);

	if (f.isReading())
	{
		buildIdMap();
	}
}
Ejemplo n.º 18
0
// ***************************************************************************
void			CSkeletonShape::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	/*
	Version 1:
		- _Lods.
	*/
	sint	ver= f.serialVersion(1);

	f.serialCont(_Bones);
	f.serialCont(_BoneMap);

	if(ver>=1)
		f.serialCont(_Lods);
	else
	{
		// create a skeleton shape with bones activated all the time
		_Lods.resize(1);
		// create the default lod: all bones activated.
		_Lods[0].Distance=0;
		_Lods[0].ActiveBones.resize(_Bones.size(), 0xFF);
	}
}
Ejemplo n.º 19
0
void CAnimation::serial (NLMISC::IStream& f)
{
	// cannot save if anim header compressed
	nlassert(_IdByChannelId.empty());

	// Serial a header
	f.serialCheck (NELID("_LEN"));
	f.serialCheck (NELID("MINA"));

	// Serial a version
	sint version=f.serialVersion (2);

	// Serial the name
	f.serial (_Name);

	// Serial the name/id map
	f.serialCont(_IdByName);

	// Serial the vector
	f.serialContPolyPtr (_TrackVector);

	// Serial the min end time
	if (version>=1)
	{
		f.serial (_MinEndTime);
	}

	// Serial the SSS shapes
	if (version>=2)
	{
		f.serialCont (_SSSShapes);
	}

	// TestYoyo
	//nlinfo("ANIMYOYO: Anim NumTracks: %d", _TrackVector.size());
}
// ***************************************************************************
void CInterfaceConfig::CDesktopImage::write(NLMISC::IStream &f)
{
	nlassert(!f.isReading());
	// Version is important when the stream will be saved on Disk.
	f.serialVersion(Version);
	f.serialCont(GCImages);
	// serial extra datas
	uint32 length = ExtraDatas.length();
	if (length > 0)
	{
		uint8 *pBuffer = new uint8[length];
		memcpy(pBuffer, ExtraDatas.buffer(), length);
		f.serialBuffer(pBuffer, length);
		delete [] pBuffer;
	}
}
Ejemplo n.º 21
0
void CPrimitiveBlock::serial (NLMISC::IStream &s)
{
	s.xmlPush ("PRIMITIVE_BLOCK");

	// Serial checks
	s.serialCheck ((uint32)'KBRP');

	// Serial the version
	(void)s.serialVersion (0);

	s.xmlPush ("PRIMITIVES");
	s.serialCont (Primitives);
	s.xmlPop ();

	s.xmlPop ();
}
Ejemplo n.º 22
0
// ***************************************************************************
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]);
        }
    }
}
Ejemplo n.º 23
0
void CModifiersInDB::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	f.serialCont(Bonus);
	f.serialCont(Malus);
	// let s be sure that the vector have the right size
	if ( f.isReading() )
	{
		if ( Bonus.size() != NbBonusModifiers )
		{
			nlwarning("BUG: number of bonus modifier is not %d but is %d", NbBonusModifiers, Bonus.size());
			Bonus.resize(NbBonusModifiers);
		}
		if ( Malus.size() != NbMalusModifiers )
		{	
			nlwarning("BUG: number of Malus modifier is not %d but is %d", NbMalusModifiers, Malus.size());
			Malus.resize(NbMalusModifiers);
		}
	}
}
Ejemplo n.º 24
0
// ***************************************************************************
void CPortal::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
	 * ***********************************************/

	int version = f.serialVersion (1);

	f.serialCont (_LocalPoly);
	if (f.isReading())
		_Poly = _LocalPoly;
	f.serial (_Name);

	if (version >= 1)
	{
		if (f.isReading())
		{
			std::string occName;
			f.serial(occName);
			if (occName.empty())
				occName = "no occlusion";
			_OcclusionModelId = CStringMapper::map(occName);

			f.serial(occName);
			if (occName.empty())
				occName = "no occlusion";
			_OpenOcclusionModelId = CStringMapper::map(occName);
		}
		else
		{
			std::string occName = CStringMapper::unmap(_OcclusionModelId);
			if (occName == "no occlusion")
				occName = "";
			f.serial(occName);
			occName = CStringMapper::unmap(_OpenOcclusionModelId);
			if (occName == "no occlusion")
				occName = "";
			f.serial(occName);
		}
	}
}
// ***************************************************************************
void CInterfaceConfig::CDesktopImage::read(NLMISC::IStream &f)
{
	nlassert(f.isReading());
	f.serialVersion(Version);
	f.serialCont(GCImages);
	// extra datas go until the end of stream
	sint32 begPos = f.getPos();
	f.seek (0, NLMISC::IStream::end);
	sint32 endPos = f.getPos();
	f.seek (begPos, NLMISC::IStream::begin);
	NLMISC::contReset(ExtraDatas);
	if (ExtraDatas.isReading())
	{
		ExtraDatas.invert();
	}
	sint32 length = endPos - begPos;
	if (length > 0)
	{
		uint8 *pBuffer = new uint8[length];
		f.serialBuffer(pBuffer, length); // read buffer from file
		ExtraDatas.serialBuffer(pBuffer, length); // copy buffer to memstream
		delete [] pBuffer;
	}
}
Ejemplo n.º 26
0
// ***************************************************************************
void CBlendShape::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 1 : added tangent space support
	sint ver = f.serialVersion (1);

	f.serial (Name);

	f.serialCont (deltaPos);
	f.serialCont (deltaNorm);
	f.serialCont (deltaUV);
	f.serialCont (deltaCol);

	if (ver >= 1) f.serialCont(deltaTgSpace);

	f.serialCont (VertRefs);
}
void	NLPACS::CRetrievableSurface::TLoop::serial(NLMISC::IStream &f)
{
	f.serialCont(*this);
	f.serial(Length);
}
void CFileDescriptionContainer::serial(NLMISC::IStream& stream)
{
	stream.serialCont(_FileDescriptions);
}
Ejemplo n.º 29
0
/*
 * Serial CRangeList
 */
void				CRangeList::serial( NLMISC::IStream& s )
{
	s.serial( _TotalMaxRows );
	s.serialCont( _RangeList );
}
Ejemplo n.º 30
0
// ***************************************************************************
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]);
			}
		}
	}

}