-/*
+/* -------------------------------------------------------------------------------
+
Copyright (C) 1999-2007 id Software, Inc. and contributors.
For a list of contributors, see the accompanying CONTRIBUTORS file.
if(bspDrawVerts == 0)
{
- numBSPDrawVertsBuffer = MAX_MAP_DRAW_VERTS / 37;
+ numBSPDrawVertsBuffer = 1024;
bspDrawVerts = safe_malloc_info(sizeof(bspDrawVert_t) * numBSPDrawVertsBuffer, "IncDrawVerts");
numBSPDrawVertsBuffer *= 3; // multiply by 1.5
numBSPDrawVertsBuffer /= 2;
- if(numBSPDrawVertsBuffer > MAX_MAP_DRAW_VERTS)
- numBSPDrawVertsBuffer = MAX_MAP_DRAW_VERTS;
-
bspDrawVerts = realloc(bspDrawVerts, sizeof(bspDrawVert_t) * numBSPDrawVertsBuffer);
if(!bspDrawVerts)
bspFogs[ i ].brushNum = LittleLong( bspFogs[ i ].brushNum );
bspFogs[ i ].visibleSide = LittleLong( bspFogs[ i ].visibleSide );
}
+
+ /* advertisements */
+ for( i = 0; i < numBSPAds; i++ )
+ {
+ 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 ] );
+
+ for( j = 0; j < 4; j++ )
+ {
+ 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 ] );
+ }
+
+ //bspAds[ i ].model[ MAX_QPATH ];
+ }
}
return length / size;
}
+int CopyLump_Allocate( bspHeader_t *header, int lump, void **dest, int size, int *allocationVariable )
+{
+ /* get lump length and offset */
+ *allocationVariable = header->lumps[ lump ].length / size;
+ *dest = realloc(*dest, size * *allocationVariable);
+ return CopyLump(header, lump, *dest, size);
+}
/*
Sys_Printf( "\n");
Sys_Printf( "%9d lightmaps %9d\n",
- numBSPLightBytes / (LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT * 3), numBSPLightBytes );
+ numBSPLightBytes / (game->lightmapSize * game->lightmapSize * 3), numBSPLightBytes );
Sys_Printf( "%9d lightgrid %9d *\n",
numBSPGridPoints, (int) (numBSPGridPoints * sizeof( *bspGridPoints )) );
Sys_Printf( " visibility %9d\n",
return qfalse;
if( strcmp( token, "{" ) )
Error( "ParseEntity: { not found" );
- if( numEntities == MAX_MAP_ENTITIES )
- Error( "numEntities == MAX_MAP_ENTITIES" );
+ AUTOEXPAND_BY_REALLOC(entities, numEntities, allocatedEntities, 32);
/* create new entity */
mapEnt = &entities[ numEntities ];
numEntities++;
-
+ memset( mapEnt, 0, sizeof( *mapEnt ) );
+
/* parse */
while( 1 )
{
numBSPEntities = numEntities;
}
+/*
+ * must be called before UnparseEntities
+ */
+void InjectCommandLine(char **argv, int beginArgs, int endArgs)
+{
+ const char *previousCommandLine;
+ char newCommandLine[1024];
+ const char *inpos;
+ char *outpos = newCommandLine;
+ char *sentinel = newCommandLine + sizeof(newCommandLine) - 1;
+ int i;
+
+ previousCommandLine = ValueForKey(&entities[0], "_q3map2_cmdline");
+ if(previousCommandLine && *previousCommandLine)
+ {
+ inpos = previousCommandLine;
+ while(outpos != sentinel && *inpos)
+ *outpos++ = *inpos++;
+ if(outpos != sentinel)
+ *outpos++ = ';';
+ if(outpos != sentinel)
+ *outpos++ = ' ';
+ }
+
+ for(i = beginArgs; i < endArgs; ++i)
+ {
+ if(outpos != sentinel && i != beginArgs)
+ *outpos++ = ' ';
+ inpos = argv[i];
+ while(outpos != sentinel && *inpos)
+ if(*inpos != '\\' && *inpos != '"' && *inpos != ';' && (unsigned char) *inpos >= ' ')
+ *outpos++ = *inpos++;
+ }
+ *outpos = 0;
+ SetKeyValue(&entities[0], "_q3map2_cmdline", newCommandLine);
+ SetKeyValue(&entities[0], "_q3map2_version", Q3MAP_VERSION);
+}
/*
UnparseEntities()
/* setup */
+ AUTOEXPAND_BY_REALLOC(bspEntData, 0, allocatedBSPEntData, 1024);
buf = bspEntData;
end = buf;
*end = 0;
+
/* run through entity list */
for( i = 0; i < numBSPEntities && i < numEntities; i++ )
{
+ {
+ int sz = end - buf;
+ AUTOEXPAND_BY_REALLOC(bspEntData, sz + 65536, allocatedBSPEntData, 1024);
+ buf = bspEntData;
+ end = buf + sz;
+ }
+
/* get epair */
ep = entities[ i ].epairs;
if( ep == NULL )
end += 2;
/* check for overflow */
- if( end > buf + MAX_MAP_ENTSTRING )
+ if( end > buf + allocatedBSPEntData )
Error( "Entity text too long" );
}
ep->value = copystring( value );
}
+/*
+KeyExists()
+returns true if entity has this key
+*/
+qboolean KeyExists( const entity_t *ent, const char *key )
+{
+ epair_t *ep;
+
+ /* walk epair list */
+ for( ep = ent->epairs; ep != NULL; ep = ep->next )
+ {
+ if( !EPAIR_STRCMP( ep->key, key ) )
+ return qtrue;
+ }
+
+ /* no match */
+ return qfalse;
+}
/*
ValueForKey()
{
const char *value;
-
/* get cast shadows */
if( castShadows != NULL )
{
if( value[ 0 ] != '\0' )
*recvShadows = atoi( value );
}
+
+ /* vortex: game-specific default eneity keys */
+ value = ValueForKey( ent, "classname" );
+ if (!Q_stricmp( game->magic, "dq" ) || !Q_stricmp( game->magic, "prophecy" ) )
+ {
+ /* vortex: deluxe quake default shadow flags */
+ if (!Q_stricmp( value, "func_wall" ) )
+ {
+ if( recvShadows != NULL )
+ *recvShadows = 1;
+ if( castShadows != NULL )
+ *castShadows = 1;
+ }
+ }
}