X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=tools%2Fquake3%2Fq3map2%2Fbsp.c;h=aeaf73635c618d713f3e04fd87e105d2e482c17c;hb=33da149be0b7c6be289f453f263fa483ea518414;hp=fedf46c59bd88d642576d2ae80976cd5a070da73;hpb=12b372f89ce109a4db9d510884fbe7d05af79870;p=xonotic%2Fnetradiant.git diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index fedf46c5..aeaf7363 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -1,6 +1,6 @@ /* ------------------------------------------------------------------------------- -Copyright (C) 1999-2006 Id Software, Inc. and contributors. +Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. This file is part of GtkRadiant. @@ -45,6 +45,76 @@ functions ------------------------------------------------------------------------------- */ +/* +ProcessAdvertisements() +copies advertisement info into the BSP structures +*/ + +static void ProcessAdvertisements( void ) { + int i; + const char* className; + const char* modelKey; + int modelNum; + bspModel_t* adModel; + bspDrawSurface_t* adSurface; + + Sys_FPrintf( SYS_VRB, "--- ProcessAdvertisements ---\n" ); + + for( i = 0; i < numEntities; i++ ) { + + /* is an advertisement? */ + className = ValueForKey( &entities[ i ], "classname" ); + + if( !Q_stricmp( "advertisement", className ) ) { + + modelKey = ValueForKey( &entities[ i ], "model" ); + + if( strlen( modelKey ) > MAX_QPATH - 1 ) { + Error( "Model Key for entity exceeds ad struct string length." ); + } else { + if( numBSPAds < MAX_MAP_ADVERTISEMENTS ) { + bspAds[numBSPAds].cellId = IntForKey( &entities[ i ], "cellId" ); + strncpy( bspAds[numBSPAds].model, modelKey, sizeof( bspAds[numBSPAds].model ) ); + + modelKey++; + modelNum = atoi( modelKey ); + adModel = &bspModels[modelNum]; + + if( adModel->numBSPSurfaces != 1 ) { + Error( "Ad cell id %d has more than one surface.", bspAds[numBSPAds].cellId ); + } + + adSurface = &bspDrawSurfaces[adModel->firstBSPSurface]; + + // store the normal for use at run time.. all ad verts are assumed to + // have identical normals (because they should be a simple rectangle) + // so just use the first vert's normal + VectorCopy( bspDrawVerts[adSurface->firstVert].normal, bspAds[numBSPAds].normal ); + + // store the ad quad for quick use at run time + if( adSurface->surfaceType == MST_PATCH ) { + int v0 = adSurface->firstVert + adSurface->patchHeight - 1; + int v1 = adSurface->firstVert + adSurface->numVerts - 1; + int v2 = adSurface->firstVert + adSurface->numVerts - adSurface->patchWidth; + int v3 = adSurface->firstVert; + VectorCopy( bspDrawVerts[v0].xyz, bspAds[numBSPAds].rect[0] ); + VectorCopy( bspDrawVerts[v1].xyz, bspAds[numBSPAds].rect[1] ); + VectorCopy( bspDrawVerts[v2].xyz, bspAds[numBSPAds].rect[2] ); + VectorCopy( bspDrawVerts[v3].xyz, bspAds[numBSPAds].rect[3] ); + } else { + Error( "Ad cell %d has an unsupported Ad Surface type.", bspAds[numBSPAds].cellId ); + } + + numBSPAds++; + } else { + Error( "Maximum number of map advertisements exceeded." ); + } + } + } + } + + Sys_FPrintf( SYS_VRB, "%9d in-game advertisements\n", numBSPAds ); +} /* SetCloneModelNumbers() - ydnar @@ -845,6 +915,9 @@ int BSPMain( int argc, char **argv ) /* set light styles from targetted light entities */ SetLightStyles(); + /* process in game advertisements */ + ProcessAdvertisements(); + /* finish and write bsp */ EndBSPFile();