Exemplo n.º 1
0
/*
================
ProcessMapEntity
================
*/
static bool	ProcessMapEntity( idMapEntity *mapEnt ) {
	idMapPrimitive	*prim;

	uEntity = &dmapGlobals.uEntities[dmapGlobals.num_entities];
	memset( uEntity, 0, sizeof(*uEntity) );
	uEntity->mapEntity = mapEnt;
	dmapGlobals.num_entities++;

	for ( entityPrimitive = 0; entityPrimitive < mapEnt->GetNumPrimitives(); entityPrimitive++ ) {
		prim = mapEnt->GetPrimitive(entityPrimitive);

		if ( prim->GetType() == idMapPrimitive::TYPE_BRUSH ) {
			ParseBrush( static_cast<idMapBrush*>(prim), entityPrimitive );
		}
		else if ( prim->GetType() == idMapPrimitive::TYPE_PATCH ) {
			ParsePatch( static_cast<idMapPatch*>(prim), entityPrimitive );
		}
	}

	// never put an origin on the world, even if the editor left one there
	if ( dmapGlobals.num_entities != 1 ) {
		uEntity->mapEntity->epairs.GetVector( "origin", "", uEntity->origin );
	}

	return true;
}
Exemplo n.º 2
0
/*
================
ParseEntity
================
*/
qboolean	ParseEntity (void)
{
	if (!GetToken (true))
		return false;

	if (strcmp (token, "{") )
		Error ("ParseEntity: { not found");

	if (num_entities == MAX_MAP_ENTITIES)
		Error ("num_entities == MAX_MAP_ENTITIES");

	mapent = &entities[num_entities];
	num_entities++;

	do
	{
		fflush(stdout);
		if (!GetToken (true))
			Error ("ParseEntity: EOF without closing brace");
		if (!strcmp (token, "}") )
			break;
		if (!strcmp (token, "{") )
			ParseBrush ();
		else
			ParseEpair ();
	}
	while (1);

	GetVectorForKey (mapent, "origin", mapent->origin);
	return true;
}
Exemplo n.º 3
0
static bool
ParseEntity(mapentity_t *e)
{
    if (!ParseToken(PARSE_NORMAL))
	return false;

    if (strcmp(token, "{"))
	Message(msgError, errParseEntity, linenum);

    if (map.iEntities >= map.cEntities)
	Message(msgError, errLowEntCount);

    e->iBrushEnd = map.iBrushes + 1;

    do {
	if (!ParseToken(PARSE_NORMAL))
	    Message(msgError, errUnexpectedEOF);
	if (!strcmp(token, "}"))
	    break;
	else if (!strcmp(token, "{"))
	    ParseBrush();
	else
	    ParseEpair();
    } while (1);

    // Allocate some model memory while we're here
    e->iBrushStart = map.iBrushes + 1;
    if (e->iBrushStart != e->iBrushEnd) {
	e->lumps[BSPMODEL].data = AllocMem(BSPMODEL, 1, true);
	e->lumps[BSPMODEL].count = 1;
    }

    return true;
}
Exemplo n.º 4
0
static bool
ParseEntity(parser_t *parser, mapentity_t *ent)
{
    mapbrush_t *brush;

    if (!ParseToken(parser, PARSE_NORMAL))
	return false;

    if (strcmp(parser->token, "{"))
	Error(errParseEntity, parser->linenum);

    if (map.numentities == map.maxentities)
	Error(errLowEntCount);

    ent->mapbrushes = brush = map.brushes + map.numbrushes;
    do {
	if (!ParseToken(parser, PARSE_NORMAL))
	    Error(errUnexpectedEOF);
	if (!strcmp(parser->token, "}"))
	    break;
	else if (!strcmp(parser->token, "{")) {
	    if (map.numbrushes == map.maxbrushes)
		Error(errLowMapbrushCount);
	    ParseBrush(parser, brush++);
	    map.numbrushes++;
	} else
	    ParseEpair(parser, ent);
    } while (1);

    ent->nummapbrushes = brush - ent->mapbrushes;
    if (!ent->nummapbrushes)
	ent->mapbrushes = NULL;

    return true;
}
BOOL CBCGPTagManager::ReadBrush (const CString& strValue, CBCGPBrush& value)
{
	CString strItem;

	if (ExcludeTag (strValue, strItem))
	{
		return ParseBrush (strItem, value);
	}

	return FALSE;
}
Exemplo n.º 6
0
Arquivo: map.c Projeto: dommul/super8
/*
================
ParseEntity
================
*/
qboolean ParseEntity (void)
{
	epair_t *e, *next;
	entity_t *ent;

	if( !GetToken( true ) )
		return false;
	if (!strcmp(token, "Version"))
	{
		GetToken(true);
		mapversion = atof(token);
		GetToken(true);
	}
	if( strcmp( token, "{" ) )
		Error( "ParseEntity: line %i: { not found", scriptline );

	if( num_entities == MAX_MAP_ENTITIES )
		Error( "num_entities == MAX_MAP_ENTITIES" );

	ent = &entities[num_entities++];
	ent->epairs = NULL;
	ent->scriptline = scriptline; // LordHavoc: better error reporting

	do {
		fflush( stdout );

		if( !GetToken( true ) )
			Error( "ParseEntity: line %i: EOF without closing brace", scriptline );

		if( !strcmp (token, "}") )
			break;
		else if( !strcmp( token, "{" ) )  {
			ParseBrush( ent );
		} else {
			e = ParseEpair ();
			e->next = ent->epairs;
			ent->epairs = e;
		}
	} while( 1 );

	if( !strcmp( ValueForKey( ent, "classname" ), "func_group" ) ) {
		MoveEntityBrushesIntoWorld( ent );

		for( e = ent->epairs; e; e = next ) {
			next = e->next;
			qfree( e );
		}

		num_entities--;
	}

	return true;
}
Exemplo n.º 7
0
/*
================
ParseEntity
================
*/
qboolean	ParseEntity (void)
{
	if (!GetToken (true))
		return false;

	if (strcmp (token, "{") )
		Error ("ParseEntity: { not found");

	if (num_entities == MAX_MAP_ENTITIES)
		Error ("num_entities == MAX_MAP_ENTITIES");

	mapent = &entities[num_entities];
	num_entities++;

	do
	{
		fflush(stdout);
		if (!GetToken (true))
			Error ("ParseEntity: EOF without closing brace");
		if (!strcmp (token, "}") )
			break;
		if (!strcmp (token, "{") )
			ParseBrush ();
		else
			ParseEpair ();
	} while (1);

	// all fields have been parsed
	if (!strncmp (mapent->classname, "light", 5))
	{
		if (!mapent->light)
		{
			mapent->color[0] = mapent->color[1] = mapent->color[2] = 1;
			mapent->light = DEFAULTLIGHTLEVEL;
		}
		// LordHavoc: added falloff and color
		if (!mapent->falloff)
			mapent->falloff = DEFAULTFALLOFF * DEFAULTFALLOFF;
	}

	if (!strcmp (mapent->classname, "light"))
		if (mapent->targetname[0] && !mapent->style)
		{
			char	s[16];
			mapent->style = LightStyleForTargetname (mapent->targetname, true);
			sprintf (s,"%i", mapent->style);
			SetKeyValue (mapent, "style", s);
		}

	GetVectorForKey (mapent, "origin", mapent->origin);
	return true;
}
Exemplo n.º 8
0
/*
================
ParseEntity
================
*/
static qboolean ParseEntity (void)
{
	if (!GetToken (true))
		return false;

	if (strcmp (token, "{") )
		Error ("%s: { not found", __thisfunc__);

	if (num_entities == MAX_MAP_ENTITIES)
		Error ("num_entities == MAX_MAP_ENTITIES");

	mapent = &entities[num_entities];
	num_entities++;

	do
	{
		if (!GetToken (true))
			Error ("%s: EOF without closing brace", __thisfunc__);
		if (!strcmp (token, "}") )
			break;
		if (!strcmp (token, "{") )
			ParseBrush ();
		else
			ParseEpair ();
	} while (1);

	GetVectorForKey (mapent, "origin", mapent->origin);

	// JDC 8/8/97: adjust for origin brush
	if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])
	{
		mbrush_t	*b;
		mface_t		*f;

		for (b = mapent->brushes ; b ; b = b->next)
		{
			for (f = b->faces ; f ; f = f->next)
				f->plane.dist -= DotProduct (mapent->origin, f->plane.normal);
		}
	}

	return true;
}
Exemplo n.º 9
0
/*
=================
ParseMapEntity

parses a single entity out of a map file
=================
*/
static bool ParseMapEntity( bool onlyLights )
{
	epair_t		*ep;
	token_t		token;
	const char	*classname, *value;
	float		lightmapScale;
	char		shader[ MAX_SHADERPATH ];
	shaderInfo_t	*celShader = NULL;
	brush_t		*brush;
	parseMesh_t	*patch;
	bool		funcGroup;
	int		castShadows, recvShadows;
	static bool	map_type = false;

	if( !Com_ReadToken( mapfile, SC_ALLOW_NEWLINES|SC_COMMENT_SEMICOLON, &token ))
		return false; // end of .map file
	if( com.stricmp( token.string, "{" ))  Sys_Break( "ParseEntity: found %s instead {\n", token.string );
	if( numEntities >= MAX_MAP_ENTITIES ) Sys_Break( "MAX_MAP_ENTITIES limit exceeded\n" );	

	entitySourceBrushes = 0;
	mapEnt = &entities[numEntities];
	numEntities++;
	memset( mapEnt, 0, sizeof( *mapEnt ));
	
	mapEnt->mapEntityNum = numMapEntities;
	numMapEntities++;
	
	while( 1 )
	{
		if( !Com_ReadToken( mapfile, SC_ALLOW_NEWLINES|SC_COMMENT_SEMICOLON, &token ))
			Sys_Break( "ParseEntity: EOF without closing brace\n" );

		if( !com.stricmp( token.string, "}" )) break;
		if( !com.stricmp( token.string, "{" ))
		{
			// parse a brush or patch
			if( !Com_ReadToken( mapfile, SC_ALLOW_NEWLINES, &token )) break;
			
			if( !com.stricmp( token.string, "patchDef2" ))
			{
				numMapPatches++;
				ParsePatch( onlyLights );
				g_bBrushPrimit = BRUSH_RADIANT;
			}
			else if( !com.stricmp( token.string, "terrainDef" ))
			{
				MsgDev( D_WARN, "Terrain entity parsing not supported in this build.\n" );
				Com_SkipBracedSection( mapfile, 0 );
				g_bBrushPrimit = BRUSH_RADIANT;
			}
			else if( !com.stricmp( token.string, "brushDef" ))
			{
				// parse brush primitive
				g_bBrushPrimit = BRUSH_RADIANT;
				ParseBrush( onlyLights );
			}
			else
			{
				if( g_bBrushPrimit == BRUSH_RADIANT )
					Sys_Break( "mixed brush primitive with another format\n" );
				if( g_bBrushPrimit == BRUSH_UNKNOWN ) g_bBrushPrimit = BRUSH_WORLDCRAFT_21;
				
				// QuArK or WorldCraft map (unknown at this point)
				Com_SaveToken( mapfile, &token );
				ParseBrush( onlyLights );
			}
			entitySourceBrushes++;
		}
		else
		{
			// parse a key / value pair
			ep = ParseEpair( mapfile, &token );

			if( !com.strcmp( ep->key, "mapversion" ))
			{
				if( com.atoi( ep->value ) == VALVE_FORMAT )
				{
					Msg( "Valve Format Map detected\n" );
					g_bBrushPrimit = BRUSH_WORLDCRAFT_22;
				}
				else if( com.atoi( ep->value ) == GEARBOX_FORMAT )
				{
					Msg( "Gearcraft Format Map detected\n" );
					g_bBrushPrimit = BRUSH_GEARCRAFT_40;
				}
				else g_bBrushPrimit = BRUSH_WORLDCRAFT_21;
			}
			if( ep->key[0] != '\0' && ep->value[0] != '\0' )
			{
				ep->next = mapEnt->epairs;
				mapEnt->epairs = ep;
			}
		}
	}

	if( !map_type && g_bBrushPrimit != BRUSH_UNKNOWN )
	{
		MAPTYPE();
		map_type = true;
	}
	
	classname = ValueForKey( mapEnt, "classname" );
	
	if( onlyLights && com.strnicmp( classname, "light", 5 ))
	{
		numEntities--;
		return true;
	}
	
	if( !com.stricmp( "func_group", classname ))
		funcGroup = true;
	else funcGroup = false;
	
	// worldspawn (and func_groups) default to cast/recv shadows in worldspawn group
	if( funcGroup || mapEnt->mapEntityNum == 0 )
	{
		castShadows = WORLDSPAWN_CAST_SHADOWS;
		recvShadows = WORLDSPAWN_RECV_SHADOWS;
	}
	else // other entities don't cast any shadows, but recv worldspawn shadows
	{
		castShadows = ENTITY_CAST_SHADOWS;
		recvShadows = ENTITY_RECV_SHADOWS;
	}
	
	// get explicit shadow flags
	GetEntityShadowFlags( mapEnt, NULL, &castShadows, &recvShadows );
	
	// get lightmap scaling value for this entity
	if( com.strcmp( "", ValueForKey( mapEnt, "lightmapscale" )) || com.strcmp( "", ValueForKey( mapEnt, "_lightmapscale" )))
	{
		// get lightmap scale from entity
		lightmapScale = FloatForKey( mapEnt, "lightmapscale" );
		if( lightmapScale <= 0.0f ) lightmapScale = FloatForKey( mapEnt, "_lightmapscale" );
		if( lightmapScale > 0.0f ) Msg( "Entity %d (%s) has lightmap scale of %.4f\n", mapEnt->mapEntityNum, classname, lightmapScale );
	}
	else lightmapScale = 0.0f;
	
	// get cel shader :) for this entity
	value = ValueForKey( mapEnt, "_celshader" );
	if( value[0] == '\0' ) value = ValueForKey( &entities[0], "_celshader" );
	if( value[0] != '\0' )
	{
		com.snprintf( shader, sizeof( shader ), "textures/%s", value );
		celShader = ShaderInfoForShader( shader );
		Msg( "Entity %d (%s) has cel shader %s\n", mapEnt->mapEntityNum, classname, celShader->shader );
	}
	else celShader = NULL;
	
	// attach stuff to everything in the entity
	for( brush = mapEnt->brushes; brush != NULL; brush = brush->next )
	{
		brush->entityNum = mapEnt->mapEntityNum;
		brush->castShadows = castShadows;
		brush->recvShadows = recvShadows;
		brush->lightmapScale = lightmapScale;
		brush->celShader = celShader;
	}
	
	for( patch = mapEnt->patches; patch != NULL; patch = patch->next )
	{
		patch->entityNum = mapEnt->mapEntityNum;
		patch->castShadows = castShadows;
		patch->recvShadows = recvShadows;
		patch->lightmapScale = lightmapScale;
		patch->celShader = celShader;
	}
	
	SetEntityBounds( mapEnt );
	
	// load shader index map (equivalent to old terrain alphamap)
	LoadEntityIndexMap( mapEnt );
	
	// get entity origin and adjust brushes
	GetVectorForKey( mapEnt, "origin", mapEnt->origin );
	if( mapEnt->origin[0] || mapEnt->origin[1] || mapEnt->origin[2] )
		AdjustBrushesForOrigin( mapEnt );

	// group_info entities are just for editor grouping
	if( !com.stricmp( "group_info", classname ))
	{
		numEntities--;
		return true;
	}
	
	// group entities are just for editor convenience, toss all brushes into worldspawn
	if( funcGroup )
	{
		MoveBrushesToWorld( mapEnt );
		numEntities--;
		return true;
	}
	return true;
}
Exemplo n.º 10
0
/*
================
ParseMapEntity
================
*/
qboolean	ParseMapEntity (void)
{
	entity_t	*mapent;
	epair_t		*e;
	side_t		*s;
	int			i, j;
	int			startbrush, startsides;
	vec_t		newdist;
	mapbrush_t	*b;

	if (!GetToken (true))
		return false;

	if (strcmp (token, "{") )
		Error ("ParseEntity: { not found");
	
	if (num_entities == MAX_MAP_ENTITIES)
		Error ("num_entities == MAX_MAP_ENTITIES");

	startbrush = nummapbrushes;
	startsides = nummapbrushsides;

	mapent = &entities[num_entities];
	num_entities++;
	memset (mapent, 0, sizeof(*mapent));
	mapent->firstbrush = nummapbrushes;
	mapent->numbrushes = 0;
//	mapent->portalareas[0] = -1;
//	mapent->portalareas[1] = -1;

	do
	{
		if (!GetToken (true))
			Error ("ParseEntity: EOF without closing brace");
		if (!strcmp (token, "}") )
			break;
		if (!strcmp (token, "{") )
			ParseBrush (mapent);
		else
		{
			e = ParseEpair ();
			e->next = mapent->epairs;
			mapent->epairs = e;
		}
	} while (1);

	GetVectorForKey (mapent, "origin", mapent->origin);

	//
	// if there was an origin brush, offset all of the planes and texinfo
	//
	if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2])
	{
		for (i=0 ; i<mapent->numbrushes ; i++)
		{
			b = &mapbrushes[mapent->firstbrush + i];
			for (j=0 ; j<b->numsides ; j++)
			{
				s = &b->original_sides[j];
				newdist = mapplanes[s->planenum].dist -
					DotProduct (mapplanes[s->planenum].normal, mapent->origin);
				s->planenum = FindFloatPlane (mapplanes[s->planenum].normal, newdist);
				s->texinfo = TexinfoForBrushTexture (&mapplanes[s->planenum],
					&side_brushtextures[s-brushsides], mapent->origin);
			}
			MakeBrushWindings (b);
		}
	}

	// group entities are just for editor convenience
	// toss all brushes into the world entity
	if (!strcmp ("func_group", ValueForKey (mapent, "classname")))
	{
		MoveBrushesToWorld (mapent);
		mapent->numbrushes = 0;
		return true;
	}

	// areaportal entities move their brushes, but don't eliminate
	// the entity
	if (!strcmp ("func_areaportal", ValueForKey (mapent, "classname")))
	{
		char	str[128];

		if (mapent->numbrushes != 1)
			Error ("Entity %i: func_areaportal can only be a single brush", num_entities-1);

		b = &mapbrushes[nummapbrushes-1];
		b->contents = CONTENTS_AREAPORTAL;
		c_areaportals++;
		mapent->areaportalnum = c_areaportals;
		// set the portal number as "style"
		sprintf (str, "%i", c_areaportals);
		SetKeyValue (mapent, "style", str);
		MoveBrushesToWorld (mapent);
		return true;
	}

	return true;
}
Exemplo n.º 11
0
/*
 * @brief
 */
static _Bool ParseMapEntity(void) {
	entity_t *mapent;
	epair_t *e;
	side_t *s;
	int32_t i, j;
	vec_t newdist;
	map_brush_t *b;

	if (!GetToken(true))
		return false;

	if (g_strcmp0(token, "{"))
		Com_Error(ERR_FATAL, "\"{\" not found\n");

	if (num_entities == MAX_BSP_ENTITIES)
		Com_Error(ERR_FATAL, "MAX_BSP_ENTITIES\n");

	mapent = &entities[num_entities];
	num_entities++;
	memset(mapent, 0, sizeof(*mapent));
	mapent->first_brush = num_map_brushes;
	mapent->num_brushes = 0;

	do {
		if (!GetToken(true))
			Com_Error(ERR_FATAL, "EOF without closing brace\n");
		if (!g_strcmp0(token, "}"))
			break;
		if (!g_strcmp0(token, "{"))
			ParseBrush(mapent);
		else {
			e = ParseEpair();
			e->next = mapent->epairs;
			mapent->epairs = e;
		}
	} while (true);

	VectorForKey(mapent, "origin", mapent->origin);

	// if there was an origin brush, offset all of the planes and texinfo
	if (mapent->origin[0] || mapent->origin[1] || mapent->origin[2]) {
		for (i = 0; i < mapent->num_brushes; i++) {
			b = &map_brushes[mapent->first_brush + i];
			for (j = 0; j < b->num_sides; j++) {

				s = &b->original_sides[j];

				newdist = map_planes[s->plane_num].dist
						- DotProduct(map_planes[s->plane_num].normal, mapent->origin);

				s->plane_num = FindPlane(map_planes[s->plane_num].normal, newdist);

				s->texinfo = TexinfoForBrushTexture(&map_planes[s->plane_num],
						&map_brush_textures[s - map_brush_sides], mapent->origin);
			}
			MakeBrushWindings(b);
		}
	}

	// group entities are just for editor convenience
	// toss all brushes into the world entity
	if (!g_strcmp0("func_group", ValueForKey(mapent, "classname"))) {
		MoveBrushesToWorld(mapent);
		mapent->num_brushes = 0;
		return true;
	}

	// areaportal entities move their brushes, but don't eliminate the entity
	if (!g_strcmp0("func_areaportal", ValueForKey(mapent, "classname"))) {
		char str[128];

		if (mapent->num_brushes != 1)
			Com_Error(
					ERR_FATAL,
					"ParseMapEntity: %i func_areaportal can only be a single brush\n",
					num_entities - 1);

		b = &map_brushes[num_map_brushes - 1];
		b->contents = CONTENTS_AREA_PORTAL;
		c_area_portals++;
		mapent->area_portal_num = c_area_portals;
		// set the portal number as "style"
		sprintf(str, "%i", c_area_portals);
		SetKeyValue(mapent, "areaportal", str);
		MoveBrushesToWorld(mapent);
		return true;
	}

	return true;
}
Exemplo n.º 12
0
/*************
 * DESCRIPTION:   read surface from scene file
 * INPUT:         iff      iff handler
 *                obj      object for this surface (needed for pre V2.0 files)
 * OUTPUT:        FALSE if failed else TRUE
 *************/
BOOL SURFACE::Read(struct IFFHandle *iff, OBJECT *obj)
{
	struct ContextNode *cn;
	long error = 0;
	char buffer[256];
	BRUSH_OBJECT *brushobj;
	BRUSH *brush;
	TEXTURE_OBJECT *textureobj;
	TEXTURE *texture;

	while(!error)
	{
		error = ParseIFF(iff, IFFPARSE_RAWSTEP);
		if(error < 0 && error != IFFERR_EOC)
			return FALSE;

		// Get a pointer to the context node describing the current context
		cn = CurrentChunk(iff);
		if(!cn)
			continue;

		if((cn->cn_ID == ID_FORM) && (cn->cn_Type == ID_SURF))
			break;

		if(error == IFFERR_EOC)
		{
			error = 0;
			continue;
		}

		switch (cn->cn_ID)
		{
			case ID_FORM:
				switch(cn->cn_Type)
				{
					case ID_BRSH:
						if((rscn_version < 200) && obj)
						{
							brushobj = ParseBrushObject(iff, obj);
							if(!brushobj)
								return FALSE;
						}
						brush = ParseBrush(iff,this);
						if(!brush)
							return FALSE;

						if((rscn_version < 200) && obj)
							brushobj->brush = brush;
						break;
					case ID_ITXT:
						if((rscn_version < 200) && obj)
						{
							textureobj = ParseTextureObject(iff, obj);
							if(!textureobj)
								return FALSE;
						}
						texture = ParseImagineTexture(iff,this);
						if(!texture)
							return FALSE;

						if((rscn_version < 200) && obj)
							textureobj->texture = texture;
						break;
					case ID_RTXT:
						texture = ParseRayStormTexture(iff,this);
						if(!texture)
							return FALSE;
						break;
					case ID_HTXT:
						texture = ParseHyperTexture(iff,this);
						if(!texture)
							return FALSE;
						break;
				}
				break;
			case ID_NAME:
				if(!ReadString(iff,buffer,256))
					return FALSE;
				SetName(buffer);
				break;
			case ID_FLGS:
				if(!ReadULONG(iff,&flags,1))
					return FALSE;
				break;
			case ID_AMBT:
				if(!ReadFloat(iff,(float*)&ambient,3))
					return FALSE;
				break;
			case ID_DIFU:
				if(!ReadFloat(iff,(float*)&diffuse,3))
					return FALSE;
				break;
			case ID_SPEC:
				if(!ReadFloat(iff,(float*)&specular,3))
					return FALSE;
				break;
			case ID_REFL:
				if(!ReadFloat(iff,(float*)&reflect,3))
					return FALSE;
				break;
			case ID_TRNS:
				if(!ReadFloat(iff,(float*)&transpar,3))
					return FALSE;
				break;
			case ID_DIFT:
				if(!ReadFloat(iff,(float*)&difftrans,3))
					return FALSE;
				break;
			case ID_SPCT:
				if(!ReadFloat(iff,(float*)&spectrans,3))
					return FALSE;
				break;
			case ID_RPHG:
				if(!ReadFloat(iff,&refphong,1))
					return FALSE;
				break;
			case ID_TPHG:
				if(!ReadFloat(iff,&transphong,1))
					return FALSE;
				break;
			case ID_FLEN:
				if(!ReadFloat(iff,&foglength,1))
					return FALSE;
				break;
			case ID_IXOR:
				if(!ReadFloat(iff,&refrindex,1))
					return FALSE;
				break;
			case ID_TNSL:
				if(!ReadFloat(iff,&translucency,1))
					return FALSE;
				break;
		}
	}

	return TRUE;
}
Exemplo n.º 13
0
/**
 * @brief Parsed map entites and brushes
 * @sa ParseBrush
 * @param[in] filename The map filename
 * @param[in] entityString The body of the entity we are parsing
 */
static bool ParseMapEntity (const char* filename, const char* entityString)
{
	entity_t* mapent;
	const char* entName;
	static int worldspawnCount = 0;
	int notCheckOrFix = !(config.performMapCheck || config.fixMap);

	if (Q_strnull(GetToken()))
		return false;

	if (*parsedToken != '{')
		Sys_Error("ParseMapEntity: { not found");

	if (num_entities == MAX_MAP_ENTITIES)
		Sys_Error("num_entities == MAX_MAP_ENTITIES (%i)", num_entities);

	mapent = &entities[num_entities++];
	OBJZERO(*mapent);
	mapent->firstbrush = nummapbrushes;
	mapent->numbrushes = 0;

	do {
		if (Q_strnull(GetToken()))
			Sys_Error("ParseMapEntity: EOF without closing brace");
		if (*parsedToken == '}')
			break;
		if (*parsedToken == '{')
			ParseBrush(mapent, filename);
		else {
			epair_t* e = ParseEpair(num_entities);
			e->next = mapent->epairs;
			mapent->epairs = e;
		}
	} while (true);

	GetVectorForKey(mapent, "origin", mapent->origin);

	entName = ValueForKey(mapent, "classname");

	/* offset all of the planes and texinfo if needed */
	if (IsInlineModelEntity(entName) && VectorNotEmpty(mapent->origin))
		AdjustBrushesForOrigin(mapent);

	if (num_entities == 1 && !Q_streq("worldspawn", entName))
		Sys_Error("The first entity must be worldspawn, it is: %s", entName);
	if (notCheckOrFix && Q_streq("func_group", entName)) {
		/* group entities are just for editor convenience
		 * toss all brushes into the world entity */
		MoveBrushesToWorld(mapent);
		num_entities--;
	} else if (IsInlineModelEntity(entName)) {
		if (mapent->numbrushes == 0 && notCheckOrFix) {
			Com_Printf("Warning: %s has no brushes assigned (entnum: %i)\n", entName, num_entities);
			num_entities--;
		}
	} else if (Q_streq("worldspawn", entName)) {
		worldspawnCount++;
		if (worldspawnCount > 1)
			Com_Printf("Warning: more than one %s in one map\n", entName);

		const char* text = entityString;
		do {
			const char* token = Com_Parse(&text);
			if (Q_strnull(token))
				break;
			const char* key = Mem_StrDup(token);
			token = Com_Parse(&text);
			if (Q_strnull(token))
				break;
			const char* value = Mem_StrDup(token);
			epair_t* e = AddEpair(key, value, num_entities);
			e->next = mapent->epairs;
			mapent->epairs = e;
		} while (true);
	}
	return true;
}
Exemplo n.º 14
0
Arquivo: map.c Projeto: kellyrm/Q1
/*
================
ParseEntity
================
*/
qboolean ParseEntity (void)
{
	epair_t	   *ep;
	entity_t   *world;
	mbrush_t   *b, *next;
	int	   Line, i;
	char	   *Classname;
	static int WorldSpawns = 0;

	if (!GetToken (true))
		return false;

	Line = scriptline;

	if (strcmp (token, "{") )
		Message (MSGERR, "Invalid entity format, { not found on line %d", Line);

	ExtendArray(entities, num_entities);
	mapent = &entities[num_entities];
	mapent->Line = Line;
	num_entities++;

	do
	{
		if (!GetToken (true))
			Message (MSGERR, "ParseEntity: EOF without closing brace");
		if (!strcmp (token, "}") )
			break;
		if (!strcmp (token, "{") )
			ParseBrush ();
		else
			ParseEpair ();
	} while (1);

	Classname = ValueForKey(mapent, "classname");

	if (strlen(Classname) == 0)
		Message (MSGERR, "No classname in entity on line %d", Line); // Missing classname

	if (!stricmp(Classname, "worldspawn"))
	{
		if (++WorldSpawns > 1)
			Message (MSGERR, "Multiple world entities on line %d", Line); // Multiple worlds

		if (!options.onlyents && !mapent->brushes)
			Message (MSGERR, "No world brushes on line %d", Line); // No world brushes

		// Get map title
		strcpy(MapTitle, ValueForKey(mapent, "message"));

		// Translate into simplified Quake character set
		for (i = 0; MapTitle[i] != '\0'; ++i)
		{
			MapTitle[i] &= 0x7F; // Ignore colour bit

			if (MapTitle[i] >= 0x12 && MapTitle[i] <= 0x1B)
				MapTitle[i] += 0x1E; // Extra 0-9 area
			else if (MapTitle[i] == 0x10)
				MapTitle[i] = '['; // Extra bracket
			else if (MapTitle[i] == 0x11)
				MapTitle[i] = ']'; // Extra bracket

			if (!isprint(MapTitle[i] & 0xFF))
				MapTitle[i] = ' ';
		}
	}
	else if (options.noents && strnicmp(Classname, "info_player_", 12))
	{
		// Only world and players allowed; drop entity
		
		for (ep = mapent->epairs; ep; ep = ep->next)
			FreeOther (ep->value);

		memset (mapent, 0, sizeof(entity_t));

		--num_entities;
		
		return true;
	}
	else if (options.group && !stricmp(Classname, "func_group"))
	{
		// Move entity brushes into world
		world = &entities[0];

		for (b = mapent->brushes; b; b = next)
		{
			next = b->next;
			b->next = world->brushes;
			world->brushes = b;
		}
		
		for (ep = mapent->epairs; ep; ep = ep->next)
			FreeOther (ep->value);

		memset (mapent, 0, sizeof(entity_t));

		--num_entities;
		
		return true;
	}

	if (num_entities == 1 && WorldSpawns == 0)
		Message (MSGERR, "World is not first entity on line %d", Line); // World is not first entity

	GetVectorForKey (mapent, "origin", mapent->origin);
	return true;
}