Ejemplo n.º 1
0
Archivo: fill.c Proyecto: adsr/agar
void
RG_FillSave(void *p, AG_DataSource *buf)
{
	struct rg_fill_feature *f = p;

	AG_WriteVersion(buf, "RG_Feature:RG_Fill", &rgFillVer);

	AG_WriteUint8(buf, (Uint8)f->type);
	switch (f->type) {
	case FILL_SOLID:
		AG_WriteColor(buf, f->f_solid.c);
		break;
	case FILL_HGRADIENT:
	case FILL_VGRADIENT:
	case FILL_CGRADIENT:
		AG_WriteColor(buf, f->f_gradient.c1);
		AG_WriteColor(buf, f->f_gradient.c2);
		break;
	case FILL_PATTERN:
		AG_WriteUint32(buf, (Uint32)f->f_pattern.texid);
		AG_WriteUint32(buf, (Uint32)f->f_pattern.tex_xoffs);
		AG_WriteUint32(buf, (Uint32)f->f_pattern.tex_yoffs);
		break;
	}
}
Ejemplo n.º 2
0
void
AG_WriteRect(AG_DataSource *ds, AG_Rect r)
{
	AG_WriteSint32(ds, (Sint32)r.x);
	AG_WriteSint32(ds, (Sint32)r.y);
	AG_WriteUint32(ds, (Uint32)r.w);
	AG_WriteUint32(ds, (Uint32)r.h);
}
Ejemplo n.º 3
0
void
M_PolyhedronWrite(AG_DataSource *ds, const M_Polyhedron *P)
{
	Uint i, j;
	
	AG_WriteUint32(ds, (Uint32)P->nv);
	AG_WriteUint32(ds, (Uint32)P->ne);
	AG_WriteUint32(ds, (Uint32)P->nf);

	/* Write vertices */
	for (i = 0; i < P->nv; i++)
		M_WriteVector3(ds, &P->v[i]);
	
	/* Write edges */
	for (i = 0; i < P->ne; i+=2) {
		M_Halfedge *eHead = &P->e[i];
		M_Halfedge *eTail = &P->e[i+1];

		AG_WriteUint32(ds, (Uint32)eHead->v);
		AG_WriteUint32(ds, (Uint32)eTail->v);
		AG_WriteUint32(ds, (Uint32)eHead->f);
		AG_WriteUint32(ds, (Uint32)eTail->f);
	}
	
	/* Write facets */
	for (i = 0; i < P->nf; i++) {
		M_Facet *f = &P->f[i];

		AG_WriteUint8(ds, (Uint8)f->n);
		for (j = 0; j < f->n; j++)
			AG_WriteUint32(ds, (Uint32)f->e[j]);
	}
}
Ejemplo n.º 4
0
Archivo: load_den.c Proyecto: adsr/agar
/* Write a den header and skip the mapping table. */
void
AG_DenWriteHeader(AG_Den *den, int nmemb)
{
    Uint32 i;

    AG_WriteString(den->buf, den->hint);
    AG_WriteString(den->buf, den->name);

    AG_WriteString(den->buf, den->author);
    AG_WriteString(den->buf, den->copyright);
    AG_WriteString(den->buf, den->descr);
    AG_WriteString(den->buf, den->keywords);

    /* Initialize the mapping table. */
    den->members = Malloc(nmemb*sizeof(AG_DenMember));
    den->nmembers = (Uint32)nmemb;
    for (i = 0; i < den->nmembers; i++) {
        AG_DenMember *memb = &den->members[i];

        memset(memb->name, '\0', sizeof(memb->name));
        memset(memb->lang, '\0', sizeof(memb->lang));
    }

    AG_WriteUint32(den->buf, den->nmembers);

    /* Skip the mappings. */
    den->mapoffs = AG_Tell(den->buf);
    AG_Seek(den->buf, den->nmembers*AG_DEN_MAPPING_SIZE, AG_SEEK_CUR);
}
Ejemplo n.º 5
0
void
M_WriteVector_FPU(AG_DataSource *buf, const M_Vector *v)
{
	Uint i;

	AG_WriteUint32(buf, (Uint)MVECSIZE(v));
	for (i = 0; i < MVECSIZE(v); i++)
		M_WriteReal(buf, v->v[i]);
}
Ejemplo n.º 6
0
void
M_PolygonWrite(AG_DataSource *ds, const M_Polygon *P)
{
	Uint i;

	AG_WriteUint32(ds, (Uint32)P->n);
	for (i = 0; i < P->n; i++)
		M_WriteVector2(ds, &P->v[i]);
}
Ejemplo n.º 7
0
Archivo: animal.c Proyecto: adsr/agar
/*
 * Save routine. This operation saves the state of the object to a
 * data source.
 *
 * The object system will automatically invoke the save routines of
 * the parent beforehand.
 */
static int
Save(void *obj, AG_DataSource *ds)
{
	Animal *animal = obj;

	AG_WriteFloat(ds, animal->age);
	AG_WriteUint32(ds, (int)animal->cellCount);
	return (0);
}
Ejemplo n.º 8
0
Archivo: load_den.c Proyecto: adsr/agar
/* Write the den mappings. */
void
AG_DenWriteMappings(AG_Den *den)
{
    Uint32 i;

    AG_Seek(den->buf, den->mapoffs, AG_SEEK_SET);

    for (i = 0; i < den->nmembers; i++) {
        AG_DenMember *memb = &den->members[i];

        AG_WriteUint32(den->buf, (Uint32)sizeof(memb->name));

        if (AG_Write(den->buf, memb->name, sizeof(memb->name), 1) != 0)
            AG_FatalError(NULL);

        AG_WriteUint32(den->buf, (Uint32)sizeof(memb->lang));

        if (AG_Write(den->buf, memb->lang, sizeof(memb->lang), 1) != 0)
            AG_FatalError(NULL);

        AG_WriteUint32(den->buf, (Uint32)memb->offs);
        AG_WriteUint32(den->buf, (Uint32)memb->size);
    }
}