std::vector<bspAdvertisement_t> bspAds
This commit is contained in:
parent
ce0dd55cc5
commit
ecf9a46e78
|
|
@ -96,55 +96,43 @@ static void ProcessAdvertisements( void ) {
|
|||
|
||||
/* is an advertisement? */
|
||||
if ( e.classname_is( "advertisement" ) ) {
|
||||
bspAdvertisement_t& ad = bspAds.emplace_back();
|
||||
ad.cellId = e.intForKey( "cellId" );
|
||||
// copy and clear the rest of memory // check for overflow by String64
|
||||
const auto modelKey = String64()( e.valueForKey( "model" ) );
|
||||
strncpy( ad.model, modelKey, sizeof( ad.model ) );
|
||||
|
||||
const char* modelKey = e.valueForKey( "model" );
|
||||
const bspModel_t& adModel = bspModels[atoi( modelKey.c_str() + 1 )];
|
||||
|
||||
if ( strlen( modelKey ) > MAX_QPATH - 1 ) {
|
||||
Error( "Model Key for entity exceeds ad struct string length." );
|
||||
if ( adModel.numBSPSurfaces != 1 ) {
|
||||
Error( "Ad cell id %d has more than one surface.", ad.cellId );
|
||||
}
|
||||
|
||||
const bspDrawSurface_t& 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
|
||||
ad.normal = bspDrawVerts[adSurface.firstVert].normal;
|
||||
|
||||
// store the ad quad for quick use at run time
|
||||
if ( adSurface.surfaceType == MST_PATCH ) {
|
||||
const int v0 = adSurface.firstVert + adSurface.patchHeight - 1;
|
||||
const int v1 = adSurface.firstVert + adSurface.numVerts - 1;
|
||||
const int v2 = adSurface.firstVert + adSurface.numVerts - adSurface.patchWidth;
|
||||
const int v3 = adSurface.firstVert;
|
||||
ad.rect[0] = bspDrawVerts[v0].xyz;
|
||||
ad.rect[1] = bspDrawVerts[v1].xyz;
|
||||
ad.rect[2] = bspDrawVerts[v2].xyz;
|
||||
ad.rect[3] = bspDrawVerts[v3].xyz;
|
||||
}
|
||||
else {
|
||||
if ( numBSPAds < MAX_MAP_ADVERTISEMENTS ) {
|
||||
bspAds[numBSPAds].cellId = e.intForKey( "cellId" );
|
||||
strncpy( bspAds[numBSPAds].model, modelKey, sizeof( bspAds[numBSPAds].model ) );
|
||||
|
||||
const bspModel_t& adModel = bspModels[atoi( modelKey + 1 )];
|
||||
|
||||
if ( adModel.numBSPSurfaces != 1 ) {
|
||||
Error( "Ad cell id %d has more than one surface.", bspAds[numBSPAds].cellId );
|
||||
}
|
||||
|
||||
const bspDrawSurface_t& 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
|
||||
bspAds[numBSPAds].normal = bspDrawVerts[adSurface.firstVert].normal;
|
||||
|
||||
// store the ad quad for quick use at run time
|
||||
if ( adSurface.surfaceType == MST_PATCH ) {
|
||||
const int v0 = adSurface.firstVert + adSurface.patchHeight - 1;
|
||||
const int v1 = adSurface.firstVert + adSurface.numVerts - 1;
|
||||
const int v2 = adSurface.firstVert + adSurface.numVerts - adSurface.patchWidth;
|
||||
const int v3 = adSurface.firstVert;
|
||||
bspAds[numBSPAds].rect[0] = bspDrawVerts[v0].xyz;
|
||||
bspAds[numBSPAds].rect[1] = bspDrawVerts[v1].xyz;
|
||||
bspAds[numBSPAds].rect[2] = bspDrawVerts[v2].xyz;
|
||||
bspAds[numBSPAds].rect[3] = bspDrawVerts[v3].xyz;
|
||||
}
|
||||
else {
|
||||
Error( "Ad cell %d has an unsupported Ad Surface type.", bspAds[numBSPAds].cellId );
|
||||
}
|
||||
|
||||
numBSPAds++;
|
||||
}
|
||||
else {
|
||||
Error( "Maximum number of map advertisements exceeded." );
|
||||
}
|
||||
Error( "Ad cell %d has an unsupported Ad Surface type.", ad.cellId );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sys_FPrintf( SYS_VRB, "%9d in-game advertisements\n", numBSPAds );
|
||||
Sys_FPrintf( SYS_VRB, "%9zu in-game advertisements\n", bspAds.size() );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -92,9 +92,6 @@ void SwapBlock( std::vector<T>& block ){
|
|||
*/
|
||||
|
||||
void SwapBSPFile( void ){
|
||||
int i, j;
|
||||
shaderInfo_t *si;
|
||||
|
||||
/* models */
|
||||
SwapBlock( bspModels );
|
||||
|
||||
|
|
@ -102,7 +99,7 @@ void SwapBSPFile( void ){
|
|||
for ( bspShader_t& shader : bspShaders )
|
||||
{
|
||||
if ( doingBSP ){
|
||||
si = ShaderInfoForShader( shader.shader );
|
||||
const shaderInfo_t *si = ShaderInfoForShader( shader.shader );
|
||||
if ( !strEmptyOrNull( si->remapShader ) ) {
|
||||
// copy and clear the rest of memory // check for overflow by String64
|
||||
const auto remap = String64()( si->remapShader );
|
||||
|
|
@ -171,21 +168,19 @@ void SwapBSPFile( void ){
|
|||
}
|
||||
|
||||
/* advertisements */
|
||||
for ( i = 0; i < numBSPAds; i++ )
|
||||
for ( bspAdvertisement_t& ad : bspAds )
|
||||
{
|
||||
bspAds[ i ].cellId = LittleLong( bspAds[ i ].cellId );
|
||||
bspAds[ i ].normal[ 0 ] = LittleFloat( bspAds[ i ].normal[ 0 ] );
|
||||
bspAds[ i ].normal[ 1 ] = LittleFloat( bspAds[ i ].normal[ 1 ] );
|
||||
bspAds[ i ].normal[ 2 ] = LittleFloat( bspAds[ i ].normal[ 2 ] );
|
||||
ad.cellId = LittleLong( ad.cellId );
|
||||
ad.normal[ 0 ] = LittleFloat( ad.normal[ 0 ] );
|
||||
ad.normal[ 1 ] = LittleFloat( ad.normal[ 1 ] );
|
||||
ad.normal[ 2 ] = LittleFloat( ad.normal[ 2 ] );
|
||||
|
||||
for ( j = 0; j < 4; j++ )
|
||||
for ( Vector3& v : ad.rect )
|
||||
{
|
||||
bspAds[ i ].rect[j][ 0 ] = LittleFloat( bspAds[ i ].rect[j][ 0 ] );
|
||||
bspAds[ i ].rect[j][ 1 ] = LittleFloat( bspAds[ i ].rect[j][ 1 ] );
|
||||
bspAds[ i ].rect[j][ 2 ] = LittleFloat( bspAds[ i ].rect[j][ 2 ] );
|
||||
v[ 0 ] = LittleFloat( v[ 0 ] );
|
||||
v[ 1 ] = LittleFloat( v[ 1 ] );
|
||||
v[ 2 ] = LittleFloat( v[ 2 ] );
|
||||
}
|
||||
|
||||
//bspAds[ i ].model[ MAX_QPATH ];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -267,10 +267,10 @@ void LoadIBSPFile( const char *filename ){
|
|||
|
||||
/* advertisements */
|
||||
if ( header->version == 47 && strEqual( g_game->arg, "quakelive" ) ) { // quake live's bsp version minus wolf, et, etut
|
||||
numBSPAds = CopyLump( (bspHeader_t*) header, LUMP_ADVERTISEMENTS, bspAds, sizeof( bspAdvertisement_t ) );
|
||||
CopyLump( (bspHeader_t*) header, LUMP_ADVERTISEMENTS, bspAds );
|
||||
}
|
||||
else{
|
||||
numBSPAds = 0;
|
||||
bspAds.clear();
|
||||
}
|
||||
|
||||
/* free the file buffer */
|
||||
|
|
@ -366,7 +366,7 @@ void WriteIBSPFile( const char *filename ){
|
|||
AddLump( file, header->lumps[LUMP_DRAWINDEXES], bspDrawIndexes );
|
||||
|
||||
/* advertisements */
|
||||
AddLump( file, (bspHeader_t*) header, LUMP_ADVERTISEMENTS, bspAds, numBSPAds * sizeof( bspAdvertisement_t ) );
|
||||
AddLump( file, header->lumps[LUMP_ADVERTISEMENTS], bspAds );
|
||||
|
||||
/* emit bsp size */
|
||||
size = ftell( file );
|
||||
|
|
|
|||
|
|
@ -243,8 +243,6 @@ enum class EBrushType
|
|||
|
||||
#define MAX_MAP_DRAW_SURFS 0x20000
|
||||
|
||||
#define MAX_MAP_ADVERTISEMENTS 30
|
||||
|
||||
/* the editor uses these predefined yaw angles to orient entities up or down */
|
||||
#define ANGLE_UP -1
|
||||
#define ANGLE_DOWN -2
|
||||
|
|
@ -2361,8 +2359,7 @@ Q_EXTERN std::vector<bspDrawSurface_t> bspDrawSurfaces; // MAX_MAP_DRAW_SURFS
|
|||
|
||||
Q_EXTERN std::vector<bspFog_t> bspFogs; // MAX_MAP_FOGS
|
||||
|
||||
Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
|
||||
Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
|
||||
Q_EXTERN std::vector<bspAdvertisement_t> bspAds;
|
||||
|
||||
#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
|
||||
do \
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user