Exemple #1
0
Fichier : misc.c Projet : deurk/ktx
void barrel_explode()
{
	self->s.v.takedamage = DAMAGE_NO;
	self->classname = "explo_box";

	// did say self.owner
	T_RadiusDamage(self, self, 160, world, dtEXPLO_BOX);

	WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	WriteByte( MSG_MULTICAST, TE_EXPLOSION );
	WriteCoord( MSG_MULTICAST, self->s.v.origin[0] );
	WriteCoord( MSG_MULTICAST, self->s.v.origin[1] );
	WriteCoord( MSG_MULTICAST, self->s.v.origin[2] + 32 );

	trap_multicast( PASSVEC3( self->s.v.origin ), MULTICAST_PHS );

	ent_remove( self );
}
Exemple #2
0
// all these sent values MUST have corresponding read values in CSQC (CSQC_Ent_Update() in main.c )
float Player_SendEntityToCSQC()
{
	WriteByte(MSG_ENTITY, ENT_CSPLAYER);
	WriteByte(MSG_ENTITY, player.frame);	//FIXME NEED COMPRESSION
	//WriteByte(MSG_ENTITY, player.movetype); -- not used, uncomment and delete this if needed
	//WriteByte(MSG_ENTITY, player.solid); -- not used, uncomment and delete this if needed
	//WriteString(MSG_ENTITY,player.model);	-- not used, uncomment and delete this if needed
	//WriteByte(MSG_ENTITY, player.skeletonindex); -- DON'T SEND IT - it will break code driven animation
	WriteByte(MSG_ENTITY, player.modelindex);
	WriteByte(MSG_ENTITY, player.PersID);
	WriteShort(MSG_ENTITY, player.angles_x);
	WriteShort(MSG_ENTITY, player.angles_y);
	WriteShort(MSG_ENTITY, player.angles_z);
	WriteCoord(MSG_ENTITY, player.origin_x);
	WriteCoord(MSG_ENTITY, player.origin_y);
	WriteCoord(MSG_ENTITY, player.origin_z);
	WriteShort(MSG_ENTITY, player.velocity_x);
	WriteShort(MSG_ENTITY, player.velocity_y);
	WriteShort(MSG_ENTITY, player.velocity_z);
	return TRUE;
}
Exemple #3
0
Fichier : misc.c Projet : deurk/ktx
void Laser_Touch()
{
	vec3_t          org;

	if ( other == PROG_TO_EDICT( self->s.v.owner ) )
		return;		// don't explode on owner

	if ( trap_pointcontents( PASSVEC3( self->s.v.origin ) ) == CONTENT_SKY )
	{
		ent_remove( self );
		return;
	}

	sound( self, CHAN_WEAPON, "enforcer/enfstop.wav", 1, ATTN_STATIC );
	
	normalize( self->s.v.velocity, org );
	VectorScale( org, 8, org );
	VectorSubtract( self->s.v.origin, org, org );
	//org = self->s.v.origin - 8*normalize(self->s.v.velocity);

	if ( ISLIVE( other ) )
	{
		SpawnBlood( org, 15 );
		other->deathtype = dtLASER;
		T_Damage( other, self, PROG_TO_EDICT( self->s.v.owner ), 15 );
	} else
	{
		WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
		WriteByte( MSG_MULTICAST, TE_GUNSHOT );
		WriteByte( MSG_MULTICAST, 5 );
		WriteCoord( MSG_MULTICAST, org[0] );
		WriteCoord( MSG_MULTICAST, org[1] );
		WriteCoord( MSG_MULTICAST, org[2] );

		trap_multicast( PASSVEC3( org ), MULTICAST_PVS );
	}

	ent_remove( self );
}
Exemple #4
0
OGRErr OGRBNALayer::CreateFeature( OGRFeature *poFeature )

{
    int i,j,k,n;
    OGRGeometry     *poGeom = poFeature->GetGeometryRef();
    char eol[3];
    const char* partialEol = (poDS->GetMultiLine()) ? eol : poDS->GetCoordinateSeparator();

    if (poGeom == NULL || poGeom->IsEmpty() )
    {
        CPLError(CE_Failure, CPLE_AppDefined,
                 "OGR BNA driver cannot write features with empty geometries.");
        return OGRERR_FAILURE;
    }

    if (poDS->GetUseCRLF())
    {
        eol[0] = 13;
        eol[1] = 10;
        eol[2] = 0;
    }
    else
    {
        eol[0] = 10;
        eol[1] = 0;
    }
    
    if ( ! bWriter )
    {
        return OGRERR_FAILURE;
    }
    
    if( poFeature->GetFID() == OGRNullFID )
        poFeature->SetFID( nFeatures++ );
    
    VSILFILE* fp = poDS->GetOutputFP();
    int nbPairPerLine = poDS->GetNbPairPerLine();

    switch( poGeom->getGeometryType() )
    {
        case wkbPoint:
        case wkbPoint25D:
        {
            OGRPoint* point = (OGRPoint*)poGeom;
            WriteFeatureAttributes(fp, poFeature);
            VSIFPrintfL( fp, "1");
            VSIFPrintfL( fp, "%s", partialEol);
            WriteCoord(fp, point->getX(), point->getY());
            VSIFPrintfL( fp, "%s", eol);
            break;
        }
            
        case wkbPolygon:
        case wkbPolygon25D:
        {
            OGRPolygon* polygon = (OGRPolygon*)poGeom;
            OGRLinearRing* ring = polygon->getExteriorRing();
            if (ring == NULL)
            {
                return OGRERR_FAILURE;
            }
            
            double firstX = ring->getX(0);
            double firstY = ring->getY(0);
            int nBNAPoints = ring->getNumPoints();
            int is_ellipse = FALSE;
            
            /* This code tries to detect an ellipse in a polygon geometry */
            /* This will only work presumably on ellipses already read from a BNA file */
            /* Mostly a BNA to BNA feature... */
            if (poDS->GetEllipsesAsEllipses() &&
                polygon->getNumInteriorRings() == 0 &&
                nBNAPoints == 361)
            {
                double oppositeX = ring->getX(180);
                double oppositeY = ring->getY(180);
                double quarterX = ring->getX(90);
                double quarterY = ring->getY(90);
                double antiquarterX = ring->getX(270);
                double antiquarterY = ring->getY(270);
                double center1X = 0.5*(firstX + oppositeX);
                double center1Y = 0.5*(firstY + oppositeY);
                double center2X = 0.5*(quarterX + antiquarterX);
                double center2Y = 0.5*(quarterY + antiquarterY);
                if (fabs(center1X - center2X) < 1e-5 && fabs(center1Y - center2Y) < 1e-5 &&
                    fabs(oppositeY - firstY) < 1e-5 &&
                    fabs(quarterX - antiquarterX) < 1e-5)
                {
                    double major_radius = fabs(firstX - center1X);
                    double minor_radius = fabs(quarterY - center1Y);
                    is_ellipse = TRUE;
                    for(i=0;i<360;i++)
                    {
                        if (!(fabs(center1X + major_radius * cos(i * (M_PI / 180)) - ring->getX(i)) < 1e-5 &&
                              fabs(center1Y + minor_radius * sin(i * (M_PI / 180)) - ring->getY(i)) < 1e-5))
                        {
                            is_ellipse = FALSE;
                            break;
                        }
                    }
                    if ( is_ellipse == TRUE )
                    {
                        WriteFeatureAttributes(fp, poFeature);
                        VSIFPrintfL( fp, "2");
                        VSIFPrintfL( fp, "%s", partialEol);
                        WriteCoord(fp, center1X, center1Y);
                        VSIFPrintfL( fp, "%s", partialEol);
                        WriteCoord(fp, major_radius, minor_radius);
                        VSIFPrintfL( fp, "%s", eol);
                    }
                }
            }

            if ( is_ellipse == FALSE)
            {
                int nInteriorRings = polygon->getNumInteriorRings();
                for(i=0;i<nInteriorRings;i++)
                {
                    nBNAPoints += polygon->getInteriorRing(i)->getNumPoints() + 1;
                }
                if (nBNAPoints <= 3)
                {
                    CPLError( CE_Failure, CPLE_AppDefined, "Invalid geometry" );
                    return OGRERR_FAILURE;
                }
                WriteFeatureAttributes(fp, poFeature);
                VSIFPrintfL( fp, "%d", nBNAPoints);
                n = ring->getNumPoints();
                int nbPair = 0;
                for(i=0;i<n;i++)
                {
                    VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                    WriteCoord(fp, ring->getX(i), ring->getY(i));
                    nbPair++;
                }
                for(i=0;i<nInteriorRings;i++)
                {
                    ring = polygon->getInteriorRing(i);
                    n = ring->getNumPoints();
                    for(j=0;j<n;j++)
                    {
                        VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                        WriteCoord(fp, ring->getX(j), ring->getY(j));
                        nbPair++;
                    }
                    VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                    WriteCoord(fp, firstX, firstY);
                    nbPair++;
                }
                VSIFPrintfL( fp, "%s", eol);
            }
            break;
        }

        case wkbMultiPolygon:
        case wkbMultiPolygon25D:
        {
            OGRMultiPolygon* multipolygon = (OGRMultiPolygon*)poGeom;
            int N = multipolygon->getNumGeometries();
            int nBNAPoints = 0;
            double firstX = 0, firstY = 0; 
            for(i=0;i<N;i++)
            {
                OGRPolygon* polygon = (OGRPolygon*)multipolygon->getGeometryRef(i);
                OGRLinearRing* ring = polygon->getExteriorRing();
                if (ring == NULL)
                    continue;

                if (nBNAPoints)
                    nBNAPoints ++;
                else
                {
                    firstX = ring->getX(0);
                    firstY = ring->getY(0);
                }
                nBNAPoints += ring->getNumPoints();
                int nInteriorRings = polygon->getNumInteriorRings();
                for(j=0;j<nInteriorRings;j++)
                {
                    nBNAPoints += polygon->getInteriorRing(j)->getNumPoints() + 1;
                }
            }
            if (nBNAPoints <= 3)
            {
                CPLError( CE_Failure, CPLE_AppDefined, "Invalid geometry" );
                return OGRERR_FAILURE;
            }
            WriteFeatureAttributes(fp, poFeature);
            VSIFPrintfL( fp, "%d", nBNAPoints);
            int nbPair = 0;
            for(i=0;i<N;i++)
            {
                OGRPolygon* polygon = (OGRPolygon*)multipolygon->getGeometryRef(i);
                OGRLinearRing* ring = polygon->getExteriorRing();
                if (ring == NULL)
                    continue;

                n = ring->getNumPoints();
                int nInteriorRings = polygon->getNumInteriorRings();
                for(j=0;j<n;j++)
                {
                    VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                    WriteCoord(fp, ring->getX(j), ring->getY(j));
                    nbPair++;
                }
                if (i != 0)
                {
                    VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                    WriteCoord(fp, firstX, firstY);
                    nbPair++;
                }
                for(j=0;j<nInteriorRings;j++)
                {
                    ring = polygon->getInteriorRing(j);
                    n = ring->getNumPoints();
                    for(k=0;k<n;k++)
                    {
                        VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                        WriteCoord(fp, ring->getX(k), ring->getY(k));
                        nbPair++;
                    }
                    VSIFPrintfL( fp, "%s", ((nbPair % nbPairPerLine) == 0) ? partialEol : " ");
                    WriteCoord(fp, firstX, firstY);
                    nbPair++;
                }
            }
            VSIFPrintfL( fp, "%s", eol);
            break;
        }

        case wkbLineString:
        case wkbLineString25D:
        {
            OGRLineString* line = (OGRLineString*)poGeom;
            int n = line->getNumPoints();
            int i;
            if (n < 2)
            {
                CPLError( CE_Failure, CPLE_AppDefined, "Invalid geometry" );
                return OGRERR_FAILURE;
            }
            WriteFeatureAttributes(fp, poFeature);
            VSIFPrintfL( fp, "-%d", n);
            int nbPair = 0;
            for(i=0;i<n;i++)
            {
                VSIFPrintfL( fp, "%s", partialEol);
                WriteCoord(fp, line->getX(i), line->getY(i));
                nbPair++;
            }
            VSIFPrintfL( fp, "%s", eol);
            break;
        }
            
        default:
        {
            CPLError( CE_Failure, CPLE_AppDefined,
                      "Unsupported geometry type : %s.",
                      poGeom->getGeometryName() );

            return OGRERR_UNSUPPORTED_GEOMETRY_TYPE;
        }
    }
    
    return OGRERR_NONE;
}
Exemple #5
0
VOID
MainLoop(VOID)
{
    WCHAR NameString[RES_BUFFER_SIZE];
    DWORD NameIndex  = 0;
    INT   NameLength = 0;
    COORD xy;
    INT   n = RES_DELAY_CHANGE;
    INT   dir_y  = 1;
    INT   dir_x  = 1;
    WORD  wColor = 1;

    xy.X = ScreenBufferInfo.dwSize.X / 2;
    xy.Y = ScreenBufferInfo.dwSize.Y / 2;

    for ( ; 1; ++n )
    {
        if (n == RES_DELAY_CHANGE)
        {
            n = 0;

            GetNextString(NameString,
                          RES_BUFFER_SIZE,
                          &NameIndex);
            NameLength = wcslen(NameString);

            wColor++;
            if ((wColor & 0x000F) == 0)
                wColor = 1;
        }
        if (xy.X == 0)
        {
            if (dir_x == -1)
                dir_x = 1;
        }
        else if (xy.X >= ScreenBufferInfo.dwSize.X - NameLength - 1)
        {
            if (dir_x == 1)
                dir_x = -1;
        }
        xy.X += dir_x;

        if (xy.Y == 0)
        {
            if (dir_y == -1)
                dir_y = 1;
        }
        else if (xy.Y >= ScreenBufferInfo.dwSize.Y - 1)
        {
            if (dir_y == 1)
                dir_y = -1;
        }
        xy.Y += dir_y;

#ifdef DISPLAY_COORD
        WriteCoord(xy);
#endif /* def DISPLAY_COORD */

        DisplayTitle();
        WriteStringAt(NameString, xy, wColor);
        WaitForSingleObject(WaitableTimer, INFINITE);
        WriteStringAt(NameString, xy, 0);
    }
}
	void CQuakePacket::WriteVector(const CVector& rData)
	{
		WriteCoord( rData.GetX() );
		WriteCoord( rData.GetY() );
		WriteCoord( rData.GetZ() );
	}