std::vector<bspAdvertisement_t> bspAds
This commit is contained in:
parent
ce0dd55cc5
commit
ecf9a46e78
|
|
@ -96,21 +96,16 @@ static void ProcessAdvertisements( void ) {
|
||||||
|
|
||||||
/* is an advertisement? */
|
/* is an advertisement? */
|
||||||
if ( e.classname_is( "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." );
|
|
||||||
}
|
|
||||||
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 ) {
|
if ( adModel.numBSPSurfaces != 1 ) {
|
||||||
Error( "Ad cell id %d has more than one surface.", bspAds[numBSPAds].cellId );
|
Error( "Ad cell id %d has more than one surface.", ad.cellId );
|
||||||
}
|
}
|
||||||
|
|
||||||
const bspDrawSurface_t& adSurface = bspDrawSurfaces[adModel.firstBSPSurface];
|
const bspDrawSurface_t& adSurface = bspDrawSurfaces[adModel.firstBSPSurface];
|
||||||
|
|
@ -118,7 +113,7 @@ static void ProcessAdvertisements( void ) {
|
||||||
// store the normal for use at run time.. all ad verts are assumed to
|
// store the normal for use at run time.. all ad verts are assumed to
|
||||||
// have identical normals (because they should be a simple rectangle)
|
// have identical normals (because they should be a simple rectangle)
|
||||||
// so just use the first vert's normal
|
// so just use the first vert's normal
|
||||||
bspAds[numBSPAds].normal = bspDrawVerts[adSurface.firstVert].normal;
|
ad.normal = bspDrawVerts[adSurface.firstVert].normal;
|
||||||
|
|
||||||
// store the ad quad for quick use at run time
|
// store the ad quad for quick use at run time
|
||||||
if ( adSurface.surfaceType == MST_PATCH ) {
|
if ( adSurface.surfaceType == MST_PATCH ) {
|
||||||
|
|
@ -126,25 +121,18 @@ static void ProcessAdvertisements( void ) {
|
||||||
const int v1 = adSurface.firstVert + adSurface.numVerts - 1;
|
const int v1 = adSurface.firstVert + adSurface.numVerts - 1;
|
||||||
const int v2 = adSurface.firstVert + adSurface.numVerts - adSurface.patchWidth;
|
const int v2 = adSurface.firstVert + adSurface.numVerts - adSurface.patchWidth;
|
||||||
const int v3 = adSurface.firstVert;
|
const int v3 = adSurface.firstVert;
|
||||||
bspAds[numBSPAds].rect[0] = bspDrawVerts[v0].xyz;
|
ad.rect[0] = bspDrawVerts[v0].xyz;
|
||||||
bspAds[numBSPAds].rect[1] = bspDrawVerts[v1].xyz;
|
ad.rect[1] = bspDrawVerts[v1].xyz;
|
||||||
bspAds[numBSPAds].rect[2] = bspDrawVerts[v2].xyz;
|
ad.rect[2] = bspDrawVerts[v2].xyz;
|
||||||
bspAds[numBSPAds].rect[3] = bspDrawVerts[v3].xyz;
|
ad.rect[3] = bspDrawVerts[v3].xyz;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Error( "Ad cell %d has an unsupported Ad Surface type.", bspAds[numBSPAds].cellId );
|
Error( "Ad cell %d has an unsupported Ad Surface type.", ad.cellId );
|
||||||
}
|
|
||||||
|
|
||||||
numBSPAds++;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Error( "Maximum number of map advertisements exceeded." );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ){
|
void SwapBSPFile( void ){
|
||||||
int i, j;
|
|
||||||
shaderInfo_t *si;
|
|
||||||
|
|
||||||
/* models */
|
/* models */
|
||||||
SwapBlock( bspModels );
|
SwapBlock( bspModels );
|
||||||
|
|
||||||
|
|
@ -102,7 +99,7 @@ void SwapBSPFile( void ){
|
||||||
for ( bspShader_t& shader : bspShaders )
|
for ( bspShader_t& shader : bspShaders )
|
||||||
{
|
{
|
||||||
if ( doingBSP ){
|
if ( doingBSP ){
|
||||||
si = ShaderInfoForShader( shader.shader );
|
const shaderInfo_t *si = ShaderInfoForShader( shader.shader );
|
||||||
if ( !strEmptyOrNull( si->remapShader ) ) {
|
if ( !strEmptyOrNull( si->remapShader ) ) {
|
||||||
// copy and clear the rest of memory // check for overflow by String64
|
// copy and clear the rest of memory // check for overflow by String64
|
||||||
const auto remap = String64()( si->remapShader );
|
const auto remap = String64()( si->remapShader );
|
||||||
|
|
@ -171,21 +168,19 @@ void SwapBSPFile( void ){
|
||||||
}
|
}
|
||||||
|
|
||||||
/* advertisements */
|
/* advertisements */
|
||||||
for ( i = 0; i < numBSPAds; i++ )
|
for ( bspAdvertisement_t& ad : bspAds )
|
||||||
{
|
{
|
||||||
bspAds[ i ].cellId = LittleLong( bspAds[ i ].cellId );
|
ad.cellId = LittleLong( ad.cellId );
|
||||||
bspAds[ i ].normal[ 0 ] = LittleFloat( bspAds[ i ].normal[ 0 ] );
|
ad.normal[ 0 ] = LittleFloat( ad.normal[ 0 ] );
|
||||||
bspAds[ i ].normal[ 1 ] = LittleFloat( bspAds[ i ].normal[ 1 ] );
|
ad.normal[ 1 ] = LittleFloat( ad.normal[ 1 ] );
|
||||||
bspAds[ i ].normal[ 2 ] = LittleFloat( bspAds[ i ].normal[ 2 ] );
|
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 ] );
|
v[ 0 ] = LittleFloat( v[ 0 ] );
|
||||||
bspAds[ i ].rect[j][ 1 ] = LittleFloat( bspAds[ i ].rect[j][ 1 ] );
|
v[ 1 ] = LittleFloat( v[ 1 ] );
|
||||||
bspAds[ i ].rect[j][ 2 ] = LittleFloat( bspAds[ i ].rect[j][ 2 ] );
|
v[ 2 ] = LittleFloat( v[ 2 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
//bspAds[ i ].model[ MAX_QPATH ];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -267,10 +267,10 @@ void LoadIBSPFile( const char *filename ){
|
||||||
|
|
||||||
/* advertisements */
|
/* advertisements */
|
||||||
if ( header->version == 47 && strEqual( g_game->arg, "quakelive" ) ) { // quake live's bsp version minus wolf, et, etut
|
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{
|
else{
|
||||||
numBSPAds = 0;
|
bspAds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* free the file buffer */
|
/* free the file buffer */
|
||||||
|
|
@ -366,7 +366,7 @@ void WriteIBSPFile( const char *filename ){
|
||||||
AddLump( file, header->lumps[LUMP_DRAWINDEXES], bspDrawIndexes );
|
AddLump( file, header->lumps[LUMP_DRAWINDEXES], bspDrawIndexes );
|
||||||
|
|
||||||
/* advertisements */
|
/* advertisements */
|
||||||
AddLump( file, (bspHeader_t*) header, LUMP_ADVERTISEMENTS, bspAds, numBSPAds * sizeof( bspAdvertisement_t ) );
|
AddLump( file, header->lumps[LUMP_ADVERTISEMENTS], bspAds );
|
||||||
|
|
||||||
/* emit bsp size */
|
/* emit bsp size */
|
||||||
size = ftell( file );
|
size = ftell( file );
|
||||||
|
|
|
||||||
|
|
@ -243,8 +243,6 @@ enum class EBrushType
|
||||||
|
|
||||||
#define MAX_MAP_DRAW_SURFS 0x20000
|
#define MAX_MAP_DRAW_SURFS 0x20000
|
||||||
|
|
||||||
#define MAX_MAP_ADVERTISEMENTS 30
|
|
||||||
|
|
||||||
/* the editor uses these predefined yaw angles to orient entities up or down */
|
/* the editor uses these predefined yaw angles to orient entities up or down */
|
||||||
#define ANGLE_UP -1
|
#define ANGLE_UP -1
|
||||||
#define ANGLE_DOWN -2
|
#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 std::vector<bspFog_t> bspFogs; // MAX_MAP_FOGS
|
||||||
|
|
||||||
Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
|
Q_EXTERN std::vector<bspAdvertisement_t> bspAds;
|
||||||
Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
|
|
||||||
|
|
||||||
#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
|
#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
|
||||||
do \
|
do \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user