}
}
- /* get scale */
+ /* get shift */
// if(argc-2 >= i) // always true
scale[2] = scale[1] = scale[0] = atof( argv[ argc - 2 ] );
if ( argc - 3 >= i ) {
Sys_Printf( "--- ShiftBSP ---\n" );
Sys_FPrintf( SYS_VRB, "%9d entities\n", numEntities );
- /* scale entity keys */
+ /* shift entity keys */
for ( i = 0; i < numBSPEntities && i < numEntities; i++ )
{
- /* scale origin */
+ /* shift origin */
GetVectorForKey( &entities[ i ], "origin", vec );
if ( ( vec[ 0 ] || vec[ 1 ] || vec[ 2 ] ) ) {
if ( !strncmp( ValueForKey( &entities[i], "classname" ), "info_player_", 12 ) ) {
}
- /* scale models */
+ /* shift models */
for ( i = 0; i < numBSPModels; i++ )
{
bspModels[ i ].mins[0] += scale[0];
bspModels[ i ].maxs[2] += scale[2];
}
- /* scale nodes */
+ /* shift nodes */
for ( i = 0; i < numBSPNodes; i++ )
{
bspNodes[ i ].mins[0] += scale[0];
bspNodes[ i ].maxs[2] += scale[2];
}
- /* scale leafs */
+ /* shift leafs */
for ( i = 0; i < numBSPLeafs; i++ )
{
bspLeafs[ i ].mins[0] += scale[0];
bspLeafs[ i ].maxs[1] += scale[1];
bspLeafs[ i ].maxs[2] += scale[2];
}
- /*
- if ( texscale ) {
- Sys_Printf( "Using texture unlocking (and probably breaking texture alignment a lot)\n" );
- old_xyzst = safe_malloc( sizeof( *old_xyzst ) * numBSPDrawVerts * 5 );
- for ( i = 0; i < numBSPDrawVerts; i++ )
- {
- old_xyzst[5 * i + 0] = bspDrawVerts[i].xyz[0];
- old_xyzst[5 * i + 1] = bspDrawVerts[i].xyz[1];
- old_xyzst[5 * i + 2] = bspDrawVerts[i].xyz[2];
- old_xyzst[5 * i + 3] = bspDrawVerts[i].st[0];
- old_xyzst[5 * i + 4] = bspDrawVerts[i].st[1];
- }
- }
- */
- /* scale drawverts */
+
+ /* shift drawverts */
for ( i = 0; i < numBSPDrawVerts; i++ )
{
bspDrawVerts[i].xyz[0] += scale[0];
bspDrawVerts[i].xyz[1] += scale[1];
bspDrawVerts[i].xyz[2] += scale[2];
- // bspDrawVerts[i].normal[0] /= scale[0];
- // bspDrawVerts[i].normal[1] /= scale[1];
- // bspDrawVerts[i].normal[2] /= scale[2];
- // VectorNormalize( bspDrawVerts[i].normal, bspDrawVerts[i].normal );
}
- /*
- if ( texscale ) {
- for ( i = 0; i < numBSPDrawSurfaces; i++ )
- {
- switch ( bspDrawSurfaces[i].surfaceType )
- {
- case SURFACE_FACE:
- case SURFACE_META:
- if ( bspDrawSurfaces[i].numIndexes % 3 ) {
- Error( "Not a triangulation!" );
- }
- for ( j = bspDrawSurfaces[i].firstIndex; j < bspDrawSurfaces[i].firstIndex + bspDrawSurfaces[i].numIndexes; j += 3 )
- {
- int ia = bspDrawIndexes[j] + bspDrawSurfaces[i].firstVert, ib = bspDrawIndexes[j + 1] + bspDrawSurfaces[i].firstVert, ic = bspDrawIndexes[j + 2] + bspDrawSurfaces[i].firstVert;
- bspDrawVert_t *a = &bspDrawVerts[ia], *b = &bspDrawVerts[ib], *c = &bspDrawVerts[ic];
- float *oa = &old_xyzst[ia * 5], *ob = &old_xyzst[ib * 5], *oc = &old_xyzst[ic * 5];
- // extrapolate:
- // a->xyz -> oa
- // b->xyz -> ob
- // c->xyz -> oc
- ExtrapolateTexcoords(
- &oa[0], &oa[3],
- &ob[0], &ob[3],
- &oc[0], &oc[3],
- a->xyz, a->st,
- b->xyz, b->st,
- c->xyz, c->st );
- }
- break;
- }
- }
- }
- */
- /* scale planes */
+
+ /* shift planes */
+
+ vec3_t point;
for ( i = 0; i < numBSPPlanes; i++ )
{
- if ( bspPlanes[ i ].dist > 0 ){
- if ( bspPlanes[ i ].normal[0] ){
- bspPlanes[ i ].dist += scale[0];
- continue;
- }
- else if ( bspPlanes[ i ].normal[1] ){
- bspPlanes[ i ].dist += scale[1];
- continue;
- }
- else if ( bspPlanes[ i ].normal[2] ){
- bspPlanes[ i ].dist += scale[2];
- continue;
- }
+ //find point on plane
+ for ( j=0; j<3; j++ ){
+ if ( fabs( bspPlanes[ i ].normal[j] ) > 0.5 ){
+ point[j] = bspPlanes[ i ].dist / bspPlanes[ i ].normal[j];
+ point[(j+1)%3] = point[(j+2)%3] = 0;
+ break;
+ }
}
- else{
- if ( bspPlanes[ i ].normal[0] ){
- bspPlanes[ i ].dist -= scale[0];
- continue;
- }
- else if ( bspPlanes[ i ].normal[1] ){
- bspPlanes[ i ].dist -= scale[1];
- continue;
- }
- else if ( bspPlanes[ i ].normal[2] ){
- bspPlanes[ i ].dist -= scale[2];
- continue;
- }
+ //shift point
+ for ( j=0; j<3; j++ ){
+ point[j] += scale[j];
}
+ //calc new plane dist
+ bspPlanes[ i ].dist = DotProduct( point, bspPlanes[ i ].normal );
}
-
- /* if ( uniform ) {
- for ( i = 0; i < numBSPPlanes; i++ )
- {
- bspPlanes[ i ].dist += scale[0];
- }
- }
- else
- {
- for ( i = 0; i < numBSPPlanes; i++ )
- {
- // bspPlanes[ i ].normal[0] /= scale[0];
- // bspPlanes[ i ].normal[1] /= scale[1];
- // bspPlanes[ i ].normal[2] /= scale[2];
- f = 1 / VectorLength( bspPlanes[i].normal );
- VectorScale( bspPlanes[i].normal, f, bspPlanes[i].normal );
- bspPlanes[ i ].dist *= f;
- }
- }*/
-
/* scale gridsize */
/*
GetVectorForKey( &entities[ 0 ], "gridsize", vec );
/* -help */
if ( !strcmp( argv[ i ], "-h" ) || !strcmp( argv[ i ], "--help" )
|| !strcmp( argv[ i ], "-help" ) ) {
- HelpMain(argv[i+1]);
+ HelpMain( ( i + 1 < argc ) ? argv[ i + 1 ] : NULL );
return 0;
}
/* -connect */
if ( !strcmp( argv[ i ], "-connect" ) ) {
- argv[ i ] = NULL;
- i++;
+ if ( ++i >= argc || !argv[ i ] ) {
+ Error( "Out of arguments: No address specified after %s", argv[ i - 1 ] );
+ }
+ argv[ i - 1 ] = NULL;
Broadcast_Setup( argv[ i ] );
argv[ i ] = NULL;
}
/* patch subdivisions */
else if ( !strcmp( argv[ i ], "-subdivisions" ) ) {
- argv[ i ] = NULL;
- i++;
+ if ( ++i >= argc || !argv[ i ] ) {
+ Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
+ }
+ argv[ i - 1 ] = NULL;
patchSubdivisions = atoi( argv[ i ] );
argv[ i ] = NULL;
if ( patchSubdivisions <= 0 ) {
/* threads */
else if ( !strcmp( argv[ i ], "-threads" ) ) {
- argv[ i ] = NULL;
- i++;
+ if ( ++i >= argc || !argv[ i ] ) {
+ Error( "Out of arguments: No value specified after %s", argv[ i - 1 ] );
+ }
+ argv[ i - 1 ] = NULL;
numthreads = atoi( argv[ i ] );
argv[ i ] = NULL;
}
Sys_Printf( "Q3Map - v1.0r (c) 1999 Id Software Inc.\n" );
Sys_Printf( "Q3Map (ydnar) - v" Q3MAP_VERSION "\n" );
- Sys_Printf( "NetRadiant - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
+ Sys_Printf( RADIANT_NAME " - v" RADIANT_VERSION " " __DATE__ " " __TIME__ "\n" );
Sys_Printf( "%s\n", Q3MAP_MOTD );
/* ydnar: new path initialization */
}
/* ydnar: otherwise create a bsp */
- else{
+ else {
+ /* used to write Smokin'Guns like tex file */
+ compile_map = qtrue;
+
r = BSPMain( argc, argv );
}
VectorSet( mult, 1.0f, 1.0f, 1.0f );
mult[ 3 ] = 1.0f;
VectorSet( add, 0.0f, 0.0f, 0.0f );
- mult[ 3 ] = 0.0f;
+ add[ 3 ] = 0.0f;
/* switch on type */
switch ( cm2->type )
else if ( !Q_stricmp( token, "sun" ) /* sof2 */ || !Q_stricmp( token, "q3map_sun" ) || !Q_stricmp( token, "q3map_sunExt" ) ) {
float a, b;
sun_t *sun;
- qboolean ext;
-
+ qboolean ext = qfalse;
/* ydnar: extended sun directive? */
if ( !Q_stricmp( token, "q3map_sunext" ) ) {
}
/* allocate sun */
- sun = safe_malloc( sizeof( *sun ) );
- memset( sun, 0, sizeof( *sun ) );
+ sun = safe_malloc0( sizeof( *sun ) );
/* set style */
sun->style = si->lightStyle;
surfaceModel_t *model;
/* allocate new model and attach it */
- model = safe_malloc( sizeof( *model ) );
- memset( model, 0, sizeof( *model ) );
+ model = safe_malloc0( sizeof( *model ) );
model->next = si->surfaceModel;
si->surfaceModel = model;
/* allocate new foliage struct and attach it */
- foliage = safe_malloc( sizeof( *foliage ) );
- memset( foliage, 0, sizeof( *foliage ) );
+ foliage = safe_malloc0( sizeof( *foliage ) );
foliage->next = si->foliage;
si->foliage = foliage;
alpha = ( !Q_stricmp( token, "q3map_alphaGen" ) || !Q_stricmp( token, "q3map_alphaMod" ) ) ? 1 : 0;
/* allocate new colormod */
- cm = safe_malloc( sizeof( *cm ) );
- memset( cm, 0, sizeof( *cm ) );
+ cm = safe_malloc0( sizeof( *cm ) );
/* attach to shader */
if ( si->colorMod == NULL ) {