Ejemplo n.º 1
0
// ***************************************************************************
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);	
}
Ejemplo n.º 2
0
void CScenario::serial( NLMISC::IStream &f)
{
    // _Palette is not backuped because only on client side
    // There is no characters connected so _CurrentChars is not need,
    // _InstanceMap is set dynamically

    if ( f.isReading())
    {
        _Clean = false;
    }
    f.serialEnum(_SessionType);
    f.serial(_Mode);
    f.serial(_InitialActIndex);

    if (!f.isReading())
    {

        CObjectSerializerServer hl(_HighLevel);
        f.serial(hl);
        CObjectSerializerServer bb(_BasicBricks);
        f.serial(bb);
    }
    else
    {
        CObjectSerializerServer hl;
        f.serial(hl);
        CObjectSerializerServer bb;
        f.serial(bb);
        setHighLevel( hl.getData() ) ;	// Set instance Map
        delete _BasicBricks;
        _BasicBricks = bb.getData();
    }
}
Ejemplo n.º 3
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.º 4
0
// ***************************************************************************
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;
}
Ejemplo n.º 5
0
	// ***************************************************************************
	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
	}
Ejemplo n.º 6
0
void CPrimitiveDesc::serial (NLMISC::IStream &s)
{
	// Serial the version
	sint ver = s.serialVersion (1);

	s.xmlPush ("LENGTH");
	s.serial (Length[0]);
	s.serial (Length[1]);
	s.xmlPop ();

	s.xmlSerial (Height, "HEIGHT");
	s.xmlSerial (Attenuation, "ATTENUATION");

	s.xmlPush ("TYPE");
	s.serialEnum (Type);
	s.xmlPop ();

	s.xmlPush ("REACTION");
	s.serialEnum (Reaction);
	s.xmlPop ();

	s.xmlPush ("TRIGGER");
	s.serialEnum (Trigger);
	s.xmlPop ();

	s.xmlSerial (Obstacle, "OBSTACLE");
	s.xmlSerial (OcclusionMask, "OCCLUSION_MASK");
	s.xmlSerial (CollisionMask, "COLLISION_MASK");
	s.xmlSerial (Position, "POSITION");
	s.xmlSerial (Orientation, "ORIENTATION");

	if (ver>=1)
	{
		s.xmlSerial (UserData, "USER_DATA");
	}
	else
	{
		UserData = 0;
	}
}
Ejemplo n.º 7
0
void CPSZone::serial(NLMISC::IStream &f) throw(NLMISC::EStream)
{
	NL_PS_FUNC(CPSZone_serial)
	f.serialVersion(1);
	CPSTargetLocatedBindable::serial(f);
	f.serialEnum(_CollisionBehaviour);
	f.serial(_BounceFactor);
	if (f.isReading())
	{
		for (TTargetCont::iterator it = _Targets.begin(); it != _Targets.end(); ++it)
		{
			// though this is not a force, this prevent parametric motion
			(*it)->addNonIntegrableForceRef();
		}
	}
}
// ***************************************************************************
void			CPointLight::serial(NLMISC::IStream &f)
{
	sint	ver= f.serialVersion(2);

	if(ver>=2)
		f.serial(_AddAmbientWithSun);
	else
		_AddAmbientWithSun= false;

	if(ver>=1)
	{
		f.serialEnum(_Type);
		f.serial(_SpotDirection);
		f.serial(_SpotAngleBegin);
		f.serial(_SpotAngleEnd);
	}
	else if(f.isReading())
	{
		_Type= PointLight;
		_SpotDirection.set(0,1,0);
		_SpotAngleBegin= float(NLMISC::Pi/4);
		_SpotAngleEnd= float(NLMISC::Pi/2);
	}

	f.serial(_Position);
	f.serial(_Ambient);
	f.serial(_Diffuse);
	f.serial(_Specular);
	f.serial(_AttenuationBegin);
	f.serial(_AttenuationEnd);

	// precompute.
	if(f.isReading())
	{
		computeAttenuationFactors();
		computeSpotAttenuationFactors();
	}

}
Ejemplo n.º 9
0
void  CUserComponent::serial(NLMISC::IStream &f)
{
    f.serial(Md5);
    f.serial(Md5Id);
    f.serialEnum(ComponentType);

    f.serial(Name);
    f.serial(Description);

    f.serial(Filename);
    f.serial(CompressedDataLength);
    f.serial(UncompressedDataLength);

    if (f.isReading())
    {
        delete [] CompressedData;
        CompressedData = new uint8[CompressedDataLength];
    }

    f.serialBuffer(CompressedData, CompressedDataLength);

}
Ejemplo n.º 10
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]);
			}
		}
	}

}
Ejemplo n.º 11
0
// ***************************************************************************
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);
		}
	}
}
Ejemplo n.º 12
0
///==================================================================================================================
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();
	}