Example #1
0
/*
=======================================================================================================================================
WriteFuzzyWeight
=======================================================================================================================================
*/
qboolean WriteFuzzyWeight(FILE *fp, fuzzyseperator_t *fs) {

	if (fs->type == WT_BALANCE) {
		if (fprintf(fp, " return balance(") < 0) {
			return qfalse;
		}

		if (!WriteFloat(fp, fs->weight)) {
			return qfalse;
		}

		if (fprintf(fp, ",") < 0) {
			return qfalse;
		}

		if (!WriteFloat(fp, fs->minweight)) {
			return qfalse;
		}

		if (fprintf(fp, ",") < 0) {
			return qfalse;
		}

		if (!WriteFloat(fp, fs->maxweight)) {
			return qfalse;
		}

		if (fprintf(fp, ");\n") < 0) {
			return qfalse;
		}
	} else {
		if (fprintf(fp, " return ") < 0) {
			return qfalse;
		}

		if (!WriteFloat(fp, fs->weight)) {
			return qfalse;
		}

		if (fprintf(fp, ";\n") < 0) {
			return qfalse;
		}
	}

	return qtrue;
}
size_t PlayerPositionAndLook::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteDouble(_dst, _offset, _pf_x);
	_offset = WriteDouble(_dst, _offset, _pf_y);
	_offset = WriteDouble(_dst, _offset, _pf_stance);
	_offset = WriteDouble(_dst, _offset, _pf_z);
	_offset = WriteFloat(_dst, _offset, _pf_yaw);
	_offset = WriteFloat(_dst, _offset, _pf_pitch);
	_offset = WriteBool(_dst, _offset, _pf_onGround);


	return _offset;
}
Example #3
0
void CFileDataIO::WriteTag(const CTag& tag)
{
	try
	{
		WriteUInt8(tag.GetType());
		
		if (!tag.GetName().IsEmpty()) {
			WriteString(tag.GetName(),utf8strNone);
		} else {
			WriteUInt16(1);
			WriteUInt8(tag.GetNameID());
		}
		
		switch (tag.GetType())
		{
			case TAGTYPE_HASH16:
				// Do NOT use this to transfer any tags for at least half a year!!
				WriteHash(CMD4Hash(tag.GetHash()));
				break;
			case TAGTYPE_STRING:
				WriteString(tag.GetStr(), utf8strRaw); // Always UTF8
				break;
			case TAGTYPE_UINT64:
				WriteUInt64(tag.GetInt());
				break;
			case TAGTYPE_UINT32:
				WriteUInt32(tag.GetInt());
				break;
			case TAGTYPE_FLOAT32:
				WriteFloat(tag.GetFloat());
				break;
			case TAGTYPE_BSOB:
				WriteBsob(tag.GetBsob(), tag.GetBsobSize());
				break;
			case TAGTYPE_UINT16:
				WriteUInt16(tag.GetInt());
				break;
			case TAGTYPE_UINT8:
				WriteUInt8(tag.GetInt());
				break;
			case TAGTYPE_BLOB:
				// NOTE: This will break backward compatibility with met files for eMule versions prior to 0.44a
				// and any aMule prior to SVN 26/02/2005
				WriteUInt32(tag.GetBlobSize());
				Write(tag.GetBlob(), tag.GetBlobSize());
				break;
			default:
				//TODO: Support more tag types
				// With the if above, this should NEVER happen.
				AddLogLineNS(CFormat(wxT("CFileDataIO::WriteTag: Unknown tag: type=0x%02X")) % tag.GetType());
				wxFAIL;
				break;
		}				
	} catch (...) {
		AddLogLineNS(wxT("Exception in CDataIO:WriteTag"));
		throw;
	}
}
Example #4
0
void Serializer::InitForWriting()
{
   ASSERT(mode==SERIALIZE_NONE);

   mode=SERIALIZE_WRITE;
   ver=1.0f;

   WriteFloat(ver);    //shrugs
}
Example #5
0
void NifStream( Key<Quaternion> const & key, ostream& file, const NifInfo & info,  KeyType type ) {
	WriteFloat( key.time, file );

	//If key type is not 1, 2, or 3, throw an exception
	if ( type < 1 || type > 3 ) {
		type = LINEAR_KEY;
		//throw runtime_error("Invalid key type.");
	}

	//Read data based on the type of key
	NifStream( key.data, file, info );
	if ( type == TBC_KEY ) {
		//Uses TBC interpolation
		WriteFloat( key.tension, file);
		WriteFloat( key.bias, file);
		WriteFloat( key.continuity, file);
	}
}
Example #6
0
void cProtocol125::SendHealth(void)
{
	cCSLock Lock(m_CSPacket);
	WriteByte (PACKET_UPDATE_HEALTH);
	WriteShort((short)m_Client->GetPlayer()->GetHealth());
	WriteShort(m_Client->GetPlayer()->GetFoodLevel());
	WriteFloat((float)m_Client->GetPlayer()->GetFoodSaturationLevel());
	Flush();
}
Example #7
0
/*
================
idSaveGame::WriteRefSound
================
*/
void idSaveGame::WriteRefSound( const refSound_t &refSound ) {
	if( refSound.referenceSound ) {
		WriteInt( refSound.referenceSound->Index() );
	} else {
		WriteInt( 0 );
	}
	WriteVec3( refSound.origin );
	WriteInt( refSound.listenerId );
	WriteSoundShader( refSound.shader );
	WriteFloat( refSound.diversity );
	WriteBool( refSound.waitfortrigger );
	WriteFloat( refSound.parms.minDistance );
	WriteFloat( refSound.parms.maxDistance );
	WriteFloat( refSound.parms.volume );
	WriteFloat( refSound.parms.shakes );
	WriteInt( refSound.parms.soundShaderFlags );
	WriteInt( refSound.parms.soundClass );
}
Example #8
0
void cProtocol125::SendExperience(void)
{
	cCSLock Lock(m_CSPacket);
	cPlayer * Player = m_Client->GetPlayer();
	WriteByte  (PACKET_EXPERIENCE);
	WriteFloat (Player->GetXpPercentage());
	WriteShort (Player->GetXpLevel());
	WriteShort (Player->GetCurrentXp());
	Flush();
}
void writeTeleopForwards()
{
  TFileHandle hFileHandle;
  TFileIOResult nIoResult;
  float teleopForwards=readCompass();
  short nFileSize=sizeof(teleopForwards);
  OpenWrite(hFileHandle, nIoResult, TELEOPFORWARDSDAT, nFileSize);
  WriteFloat(hFileHandle, nIoResult, teleopForwards);
  Close(hFileHandle, nIoResult);
}
size_t Explosion::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteDouble(_dst, _offset, _pf_x);
	_offset = WriteDouble(_dst, _offset, _pf_y);
	_offset = WriteDouble(_dst, _offset, _pf_z);
	_offset = WriteFloat(_dst, _offset, _pf_radius);
	_offset = WriteInt32(_dst, _offset, _pf_recordCount);
	_offset = WriteByteArray(_dst, _offset, _pf_records);
	_offset = WriteFloat(_dst, _offset, _pf_playerMotionX);
	_offset = WriteFloat(_dst, _offset, _pf_playerMotionY);
	_offset = WriteFloat(_dst, _offset, _pf_playerMotionZ);


	return _offset;
}
//===========================================================================
//
// Parameter:				-
// Returns:					-
// Changes Globals:		-
//===========================================================================
qboolean WriteFuzzyWeight(FILE *fp, fuzzyseperator_t *fs)
{
	if (fs->type == WT_BALANCE)
	{
		if (fprintf(fp, " return balance(") < 0) return qfalse;
		if (!WriteFloat(fp, fs->weight)) return qfalse;
		if (fprintf(fp, ",") < 0) return qfalse;
		if (!WriteFloat(fp, fs->minweight)) return qfalse;
		if (fprintf(fp, ",") < 0) return qfalse;
		if (!WriteFloat(fp, fs->maxweight)) return qfalse;
		if (fprintf(fp, ");\n") < 0) return qfalse;
	} //end if
	else
	{
		if (fprintf(fp, " return ") < 0) return qfalse;
		if (!WriteFloat(fp, fs->weight)) return qfalse;
		if (fprintf(fp, ";\n") < 0) return qfalse;
	} //end else
	return qtrue;
} //end of the function WriteFuzzyWeight
Example #12
0
void Write1DMatrix( idFile *f, int x, float *m ) {
	int		i;

	f->WriteFloatString( "( " );

	for ( i = 0; i < x; i++ ) {
		WriteFloat( f, m[i] );
	}

	f->WriteFloatString( ") " );
}
Example #13
0
void cProtocol125::SendExplosion(double a_BlockX, double a_BlockY, double a_BlockZ, float a_Radius, const cVector3iArray & a_BlocksAffected, const Vector3d & a_PlayerMotion)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_EXPLOSION);
	WriteDouble (a_BlockX);
	WriteDouble (a_BlockY);
	WriteDouble (a_BlockZ);
	WriteFloat  (a_Radius);
	WriteInt    (a_BlocksAffected.size());
	for (cVector3iArray::const_iterator itr = a_BlocksAffected.begin(); itr != a_BlocksAffected.end(); ++itr)
	{
		WriteByte   ((Byte)(itr->x - a_BlockX));
		WriteByte   ((Byte)(itr->y - a_BlockY));
		WriteByte   ((Byte)(itr->z - a_BlockZ));
	}
	WriteFloat  ((float)a_PlayerMotion.x);
	WriteFloat  ((float)a_PlayerMotion.y);
	WriteFloat  ((float)a_PlayerMotion.z);
	Flush();
}
Example #14
0
/*
===================
idSaveGame::WriteContactInfo
===================
*/
void idSaveGame::WriteContactInfo( const contactInfo_t &contactInfo ) {
	WriteInt( (int)contactInfo.type );
	WriteVec3( contactInfo.point );
	WriteVec3( contactInfo.normal );
	WriteFloat( contactInfo.dist );
	WriteInt( contactInfo.contents );
	WriteMaterial( contactInfo.material );
	WriteInt( contactInfo.modelFeature );
	WriteInt( contactInfo.trmFeature );
	WriteInt( contactInfo.entityNum );
	WriteInt( contactInfo.id );
}
Example #15
0
void cProtocol132::SendSoundEffect(const AString & a_SoundName, int a_SrcX, int a_SrcY, int a_SrcZ, float a_Volume, float a_Pitch)
{
	cCSLock Lock(m_CSPacket);
	WriteByte   (PACKET_SOUND_EFFECT);
	WriteString (a_SoundName);
	WriteInt    (a_SrcX);
	WriteInt    (a_SrcY);
	WriteInt    (a_SrcZ);
	WriteFloat  (a_Volume);
	WriteChar   ((char)(a_Pitch * 63.0f));
	Flush();
}
Example #16
0
void cProtocol125::SendPlayerMoveLook(void)
{
	cCSLock Lock(m_CSPacket);

	/*
	LOGD("Sending PlayerMoveLook: {%0.2f, %0.2f, %0.2f}, stance %0.2f, OnGround: %d",
		m_Player->GetPosX(), m_Player->GetPosY(), m_Player->GetPosZ(), m_Player->GetStance(), m_Player->IsOnGround() ? 1 : 0
	);
	*/

	WriteByte	(PACKET_PLAYER_MOVE_LOOK);
	cPlayer * Player = m_Client->GetPlayer();
	WriteDouble(Player->GetPosX());
	WriteDouble(Player->GetStance() + 0.03);  // Add a small amount so that the player doesn't start inside a block
	WriteDouble(Player->GetPosY()   + 0.03);  // Add a small amount so that the player doesn't start inside a block
	WriteDouble(Player->GetPosZ());
	WriteFloat ((float)(Player->GetYaw()));
	WriteFloat ((float)(Player->GetPitch()));
	WriteBool  (Player->IsOnGround());
	Flush();
}
Example #17
0
void Serializer::WriteRepeatedMessageField(google::protobuf::Message const& value, google::protobuf::FieldDescriptor const* field)
{
    google::protobuf::Reflection const* reflection = value.GetReflection();
    for (int32 i = 0; i < reflection->FieldSize(value, field); ++i)
    {
        switch (field->cpp_type())
        {
            case google::protobuf::FieldDescriptor::CPPTYPE_INT32:
                WriteInt32(reflection->GetRepeatedInt32(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_INT64:
                WriteInt64(reflection->GetRepeatedInt64(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_UINT32:
                WriteUInt32(reflection->GetRepeatedUInt32(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_UINT64:
                WriteUInt64(reflection->GetRepeatedUInt64(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_DOUBLE:
                WriteDouble(reflection->GetRepeatedDouble(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT:
                WriteFloat(reflection->GetRepeatedFloat(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_BOOL:
                WriteBool(reflection->GetRepeatedBool(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_ENUM:
                WriteEnum(reflection->GetRepeatedEnum(value, field, i));
                break;
            case google::protobuf::FieldDescriptor::CPPTYPE_STRING:
            {
                std::string strValue = reflection->GetRepeatedString(value, field, i);
                if (field->type() == google::protobuf::FieldDescriptor::TYPE_STRING)
                    WriteString(strValue);
                else
                {
                    _writer.StartArray();
                    for (std::size_t j = 0; j < strValue.length(); ++j)
                        WriteUInt32(uint32(strValue[j]));
                    _writer.EndArray();
                }
                break;
            }
            case google::protobuf::FieldDescriptor::CPPTYPE_MESSAGE:
                WriteMessage(reflection->GetRepeatedMessage(value, field, i));
                break;
            default:
                break;
        }
    }
}
Example #18
0
void cProtocol132::SendSoundEffect(const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch)
{
	cCSLock Lock(m_CSPacket);
	WriteByte   (PACKET_SOUND_EFFECT);
	WriteString (a_SoundName);
	WriteInt    ((int)(a_X * 8.0));
	WriteInt    ((int)(a_Y * 8.0));
	WriteInt    ((int)(a_Z * 8.0));
	WriteFloat  (a_Volume);
	WriteChar   ((char)(a_Pitch * 63.0f));
	Flush();
}
Example #19
0
/*
================
idSaveGame::WriteRenderView
================
*/
void idSaveGame::WriteRenderView( const renderView_t &view ) {
	int i;

	WriteInt( view.viewID );
	WriteInt( view.x );
	WriteInt( view.y );
	WriteInt( view.width );
	WriteInt( view.height );

	WriteFloat( view.fov_x );
	WriteFloat( view.fov_y );
	WriteVec3( view.vieworg );
	WriteMat3( view.viewaxis );

	WriteBool( view.cramZNear );

	WriteInt( view.time );

	for( i = 0; i < MAX_GLOBAL_SHADER_PARMS; i++ ) {
		WriteFloat( view.shaderParms[ i ] );
	}
}
Example #20
0
int WriteActionResponseHeader(LinkSocket *link, LinkArgs *linkArgs){
    if (Debug(LINK))
        printf("WriteActionResponseHeader: writing ACTION Response header %s\n",
               GESTURE_RESPONSE_HEADER);
    WriteChars(link, GESTURE_RESPONSE_HEADER, lGESTURE_RESPONSE_HEADER); 

    if (Debug(LINK))
        printf("WriteActionResponseHeader: writing version %f\n", VERSION);
    WriteFloat(link, VERSION); /*writing version 0.2*/
    if (WriteLinkArgs(link, linkArgs) == -1)
      return -1; /* Memory allocation error */
    return OK;
}
Example #21
0
/*
=================
WriteFaceFile_r
=================
*/
void WriteFaceFile_r (node_t *node)
{
	int			i, s;	
	portal_t	*p;
	winding_t	*w;

	// decision node
	if (node->planenum != PLANENUM_LEAF) {
		WriteFaceFile_r (node->children[0]);
		WriteFaceFile_r (node->children[1]);
		return;
	}
	
	if (node->opaque) {
		return;
	}

	for (p = node->portals ; p ; p=p->next[s])
	{
		w = p->winding;
		s = (p->nodes[1] == node);
		if (w)
		{
			if (PortalPassable(p))
				continue;
			if(p->nodes[0]->cluster == p->nodes[1]->cluster)
				continue;
			// write out to the file

			if (p->nodes[0] == node)
			{
				fprintf (pf,"%i %i ",w->numpoints, p->nodes[0]->cluster);
				for (i=0 ; i<w->numpoints ; i++)
				{
					fprintf (pf,"(");
					WriteFloat (pf, w->p[i][0]);
					WriteFloat (pf, w->p[i][1]);
					WriteFloat (pf, w->p[i][2]);
					fprintf (pf,") ");
				}
				fprintf (pf,"\n");
			}
			else
			{
				fprintf (pf,"%i %i ",w->numpoints, p->nodes[1]->cluster);
				for (i = w->numpoints-1; i >= 0; i--)
				{
					fprintf (pf,"(");
					WriteFloat (pf, w->p[i][0]);
					WriteFloat (pf, w->p[i][1]);
					WriteFloat (pf, w->p[i][2]);
					fprintf (pf,") ");
				}
				fprintf (pf,"\n");
			}
		}
	}
}
Example #22
0
//----Writes the initial data----//
void writeLocal()
{
	CloseAllHandles(nIoResult);
	OpenWrite(hFileHandle,nIoResult,sFileName1,nFileSize);
	char x;
  for(x = 0; x<numNeuralUnits; x++)
  {
    WriteFloat(hFileHandle, nIoResult, localTemp.localArray[x]);
  }
  WriteByte(hFileHandle, nIoResult, poseWorld.maxActivatedCell.x);
  WriteByte(hFileHandle, nIoResult, poseWorld.maxActivatedCell.y);
  WriteByte(hFileHandle, nIoResult, poseWorld.maxActivatedCell.theta);
  Close(hFileHandle,nIoResult);
}
static void
generate_nd(const int nPoints, const int nHashSize, const int fHeader, bearoffcontext * pbc, FILE * output)
{

    int n = Combination(nPoints + 15, nPoints);

    int i, j;
    char sz[41];
    float ar[4];
    int fTTY = isatty(STDERR_FILENO);

    xhash h;

    /* initialise xhash */


    if (XhashCreate(&h, nHashSize / (4 * sizeof(float)))) {
        fprintf(stderr, "Error creating cache\n");
        return;
    }

    XhashStatus(&h);

    if (fHeader) {
        sprintf(sz, "gnubg-OS-%02d-15-1-0-1xxxxxxxxxxxxxxxxxxx\n", nPoints);
        fputs(sz, output);
    }


    for (i = 0; i < n; ++i) {

        if (i)
            NDBearoff(i, nPoints, ar, &h, pbc);
        else
            ar[0] = ar[1] = ar[2] = ar[3] = 0.0f;

        for (j = 0; j < 4; ++j)
            WriteFloat(ar[j], output);

        XhashAdd(&h, i, ar, 16);
        if (!(i % 100) && fTTY)
            fprintf(stderr, "1:%d/%d        \r", i, n);

    }
    putc('\n', stderr);
    XhashStatus(&h);

    XhashDestroy(&h);

}
/*
================
idSaveGame::WriteRenderLight
================
*/
void idSaveGame::WriteRenderLight( const renderLight_t &renderLight ) {
    int i;

    WriteMat3( renderLight.axis );
    WriteVec3( renderLight.origin );

    WriteInt( renderLight.suppressLightInViewID );
    WriteInt( renderLight.allowLightInViewID );
    WriteBool( renderLight.noShadows );
    WriteBool( renderLight.pointLight );
    WriteBool( renderLight.parallel );

    WriteVec3( renderLight.lightRadius );
    WriteVec3( renderLight.lightCenter );

    WriteVec3( renderLight.target );
    WriteVec3( renderLight.right );
    WriteVec3( renderLight.up );
    WriteVec3( renderLight.start );
    WriteVec3( renderLight.end );

    WriteBool( renderLight.ambient );	// sikk - Ambient Light Flag
// ---> sikk - Ambient Light Color
    WriteVec3( renderLight.ambColor_X_Neg );
    WriteVec3( renderLight.ambColor_X_Pos );
    WriteVec3( renderLight.ambColor_Y_Neg );
    WriteVec3( renderLight.ambColor_Y_Pos );
    WriteVec3( renderLight.ambColor_Z_Neg );
    WriteVec3( renderLight.ambColor_Z_Pos );
// <--- sikk - Ambient Light Color
    WriteVec3( renderLight.ambRotation );	// sikk - Ambient Light Rotation

    // only idLight has a prelightModel and it's always based on the entityname, so we'll restore it there
    // WriteModel( renderLight.prelightModel );

    WriteInt( renderLight.lightId );

    WriteMaterial( renderLight.shader );

    for( i = 0; i < MAX_ENTITY_SHADER_PARMS; i++ ) {
        WriteFloat( renderLight.shaderParms[ i ] );
    }

    if ( renderLight.referenceSound != NULL ) {
        WriteInt( renderLight.referenceSound->Index() );
    } else {
        WriteInt( 0 );
    }
}
Example #25
0
int WriteMapResponseHeader(LinkSocket *link, LinkArgs *linkArgs){
    if (Debug(LINK))
        printf("WriteMapResponseHeader: writing MAP Response header %s\n",
               GRAPHICS_RESPONSE_HEADER);
    WriteChars(link, GRAPHICS_RESPONSE_HEADER, lGRAPHICS_RESPONSE_HEADER); 

    if (Debug(LINK))
        printf("WriteMapResponseHeader: writing version %f\n", VERSION);
    WriteFloat(link, VERSION); /*writing version 0.2*/
    if (WriteLinkArgs(link, linkArgs) == -1)
      return -1; /* Memory allocation error */
    if (Debug(LINK))
        printf("WriteMapResponseHeader: All done writing header...\n");
    return OK;
}
Example #26
0
void debug_stream_test_cb (puObject* obj)
{
  SStream* s = new SStream;
  strncpy (s->filename, "teststream.txt",(PATH_MAX-1));
  strncpy (s->mode, "w",3);
  OpenStream (s);

  WriteComment ("Comment...testing testing testing", s);
  WriteComment ("", s);
  WriteTag ('bgno', "---- object ----", s);
  WriteTag ('bgno', "---- nested Object ----", s);
  WriteTag ('int_', "---- int ----", s);
  int i = 500;
  WriteInt (&i, s);
  WriteTag ('uint', "---- unsigned int ----", s);
  unsigned int ui = 12345678;
  WriteUInt (&ui, s);
  float f = 12345.67f;
  WriteTag ('flot', "---- float ----", s);
  WriteFloat (&f, s);
  double d = 987654.3210;
  WriteTag ('dubl', "---- double ----", s);
  WriteDouble (&d, s);
  WriteTag ('stng', "---- string ----", s);
  WriteString ("This a string", s);
  SVector v;
  v.x = 1.0;
  v.y = 2.0;
  v.z = 3.0;
  WriteTag ('vect', "--- vector ----", s);
  WriteVector (&v, s);
  SPosition pos;
  pos.lat = 1000.0;
  pos.lon = 2000.0;
  pos.alt = 3000.0;
  WriteTag ('posn', "---- position ----", s);
  WritePosition (&pos, s);
  SMessage mesg;
  WriteTag ('mesg', "---- message ----", s);
  WriteMessage (&mesg, s);
  WriteTag ('endo', s);
  WriteTag ('endo', s);

  CloseStream (s);
  delete s;
}
Example #27
0
void cProtocol150::SendParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmmount)
{
	cCSLock Lock(m_CSPacket);
	WriteByte(PACKET_PARTICLE_EFFECT);
	WriteString(a_ParticleName);
	WriteFloat(a_SrcX);
	WriteFloat(a_SrcY);
	WriteFloat(a_SrcZ);
	WriteFloat(a_OffsetX);
	WriteFloat(a_OffsetY);
	WriteFloat(a_OffsetZ);
	WriteFloat(a_ParticleData);
	WriteInt(a_ParticleAmmount);
	Flush();
}
size_t Particle::serialize(Buffer& _dst, size_t _offset)
{
	_pm_checkInit();
	if(_offset == 0) _dst.clear();

	_offset = WriteInt8(_dst, _offset, _pf_packetId);
	_offset = WriteString16(_dst, _offset, _pf_particleName);
	_offset = WriteFloat(_dst, _offset, _pf_x);
	_offset = WriteFloat(_dst, _offset, _pf_y);
	_offset = WriteFloat(_dst, _offset, _pf_z);
	_offset = WriteFloat(_dst, _offset, _pf_offsetX);
	_offset = WriteFloat(_dst, _offset, _pf_offsetY);
	_offset = WriteFloat(_dst, _offset, _pf_offsetZ);
	_offset = WriteFloat(_dst, _offset, _pf_particleSpeed);
	_offset = WriteInt32(_dst, _offset, _pf_numOfParticles);


	return _offset;
}
Example #29
0
/*
 ===================
 idRestoreGame::WriteTraceModel
 ===================
 */
void idSaveGame::WriteTraceModel(const idTraceModel &trace)
{
	int j, k;

	WriteInt((int &)trace.type);
	WriteInt(trace.numVerts);

	for (j = 0; j < MAX_TRACEMODEL_VERTS; j++) {
		WriteVec3(trace.verts[j]);
	}

	WriteInt(trace.numEdges);

	for (j = 0; j < (MAX_TRACEMODEL_EDGES+1); j++) {
		WriteInt(trace.edges[j].v[0]);
		WriteInt(trace.edges[j].v[1]);
		WriteVec3(trace.edges[j].normal);
	}

	WriteInt(trace.numPolys);

	for (j = 0; j < MAX_TRACEMODEL_POLYS; j++) {
		WriteVec3(trace.polys[j].normal);
		WriteFloat(trace.polys[j].dist);
		WriteBounds(trace.polys[j].bounds);
		WriteInt(trace.polys[j].numEdges);

		for (k = 0; k < MAX_TRACEMODEL_POLYEDGES; k++) {
			WriteInt(trace.polys[j].edges[k]);
		}
	}

	WriteVec3(trace.offset);
	WriteBounds(trace.bounds);
	WriteBool(trace.isConvex);
	// padding win32 native structs
	char tmp[3];
	memset(tmp, 0, sizeof(tmp));
	file->Write(tmp, 3);
}
Example #30
0
void cProtocol125::WriteEntityMetadata(const cEntity & a_Entity)
{
	if (a_Entity.IsMinecart())
	{
		WriteByte(0x51);
		// No idea how Mojang makes their carts shakey shakey, so here is a complicated one-liner expression that does something similar
		WriteInt( (((a_Entity.GetMaxHealth() / 2) - (a_Entity.GetHealth() - (a_Entity.GetMaxHealth() / 2))) * ((const cMinecart &)a_Entity).LastDamage()) * 4 );
		WriteByte(0x52);
		WriteInt(1); // Shaking direction, doesn't seem to affect anything
		WriteByte(0x73);
		WriteFloat((float)(((const cMinecart &)a_Entity).LastDamage() + 10)); // Damage taken / shake effect multiplyer
		
		if (((cMinecart &)a_Entity).GetPayload() == cMinecart::mpFurnace)
		{
			WriteByte(0x10);
			WriteByte(((const cMinecartWithFurnace &)a_Entity).IsFueled() ? 1 : 0); // Fueled?
		}
	}
	else if ((a_Entity.IsProjectile() && ((cProjectileEntity &)a_Entity).GetProjectileKind() == cProjectileEntity::pkArrow))
	{
		WriteByte(0x10);
		WriteByte(((const cArrowEntity &)a_Entity).IsCritical() ? 1 : 0); // Critical hitting arrow?
	}
}