| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
#define BSP_C |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
#include "q3map2.h" |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
static void ProcessAdvertisements( void ) { |
| 53 |
int i; |
| 54 |
const char* className; |
| 55 |
const char* modelKey; |
| 56 |
int modelNum; |
| 57 |
bspModel_t* adModel; |
| 58 |
bspDrawSurface_t* adSurface; |
| 59 |
|
| 60 |
Sys_FPrintf( SYS_VRB, "--- ProcessAdvertisements ---\n" ); |
| 61 |
|
| 62 |
for ( i = 0; i < numEntities; i++ ) { |
| 63 |
|
| 64 |
|
| 65 |
className = ValueForKey( &entities[ i ], "classname" ); |
| 66 |
|
| 67 |
if ( !Q_stricmp( "advertisement", className ) ) { |
| 68 |
|
| 69 |
modelKey = ValueForKey( &entities[ i ], "model" ); |
| 70 |
|
| 71 |
if ( strlen( modelKey ) > MAX_QPATH - 1 ) { |
| 72 |
Error( "Model Key for entity exceeds ad struct string length." ); |
| 73 |
} |
| 74 |
else { |
| 75 |
if ( numBSPAds < MAX_MAP_ADVERTISEMENTS ) { |
| 76 |
bspAds[numBSPAds].cellId = IntForKey( &entities[ i ], "cellId" ); |
| 77 |
strncpy( bspAds[numBSPAds].model, modelKey, sizeof( bspAds[numBSPAds].model ) ); |
| 78 |
|
| 79 |
modelKey++; |
| 80 |
modelNum = atoi( modelKey ); |
| 81 |
adModel = &bspModels[modelNum]; |
| 82 |
|
| 83 |
if ( adModel->numBSPSurfaces != 1 ) { |
| 84 |
Error( "Ad cell id %d has more than one surface.", bspAds[numBSPAds].cellId ); |
| 85 |
} |
| 86 |
|
| 87 |
adSurface = &bspDrawSurfaces[adModel->firstBSPSurface]; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
VectorCopy( bspDrawVerts[adSurface->firstVert].normal, bspAds[numBSPAds].normal ); |
| 93 |
|
| 94 |
|
| 95 |
if ( adSurface->surfaceType == MST_PATCH ) { |
| 96 |
int v0 = adSurface->firstVert + adSurface->patchHeight - 1; |
| 97 |
int v1 = adSurface->firstVert + adSurface->numVerts - 1; |
| 98 |
int v2 = adSurface->firstVert + adSurface->numVerts - adSurface->patchWidth; |
| 99 |
int v3 = adSurface->firstVert; |
| 100 |
VectorCopy( bspDrawVerts[v0].xyz, bspAds[numBSPAds].rect[0] ); |
| 101 |
VectorCopy( bspDrawVerts[v1].xyz, bspAds[numBSPAds].rect[1] ); |
| 102 |
VectorCopy( bspDrawVerts[v2].xyz, bspAds[numBSPAds].rect[2] ); |
| 103 |
VectorCopy( bspDrawVerts[v3].xyz, bspAds[numBSPAds].rect[3] ); |
| 104 |
} |
| 105 |
else { |
| 106 |
Error( "Ad cell %d has an unsupported Ad Surface type.", bspAds[numBSPAds].cellId ); |
| 107 |
} |
| 108 |
|
| 109 |
numBSPAds++; |
| 110 |
} |
| 111 |
else { |
| 112 |
Error( "Maximum number of map advertisements exceeded." ); |
| 113 |
} |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
|
| 118 |
Sys_FPrintf( SYS_VRB, "%9d in-game advertisements\n", numBSPAds ); |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
static void SetCloneModelNumbers( void ){ |
| 127 |
int i, j; |
| 128 |
int models; |
| 129 |
char modelValue[ 10 ]; |
| 130 |
const char *value, *value2, *value3; |
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
models = 1; |
| 135 |
for ( i = 1; i < numEntities; i++ ) |
| 136 |
{ |
| 137 |
|
| 138 |
if ( entities[ i ].brushes == NULL && entities[ i ].patches == NULL ) { |
| 139 |
continue; |
| 140 |
} |
| 141 |
|
| 142 |
|
| 143 |
value = ValueForKey( &entities[ i ], "_ins" ); |
| 144 |
if ( value[ 0 ] == '\0' ) { |
| 145 |
value = ValueForKey( &entities[ i ], "_instance" ); |
| 146 |
} |
| 147 |
if ( value[ 0 ] == '\0' ) { |
| 148 |
value = ValueForKey( &entities[ i ], "_clone" ); |
| 149 |
} |
| 150 |
if ( value[ 0 ] != '\0' ) { |
| 151 |
continue; |
| 152 |
} |
| 153 |
|
| 154 |
|
| 155 |
sprintf( modelValue, "*%d", models ); |
| 156 |
SetKeyValue( &entities[ i ], "model", modelValue ); |
| 157 |
|
| 158 |
|
| 159 |
models++; |
| 160 |
} |
| 161 |
|
| 162 |
|
| 163 |
for ( i = 1; i < numEntities; i++ ) |
| 164 |
{ |
| 165 |
|
| 166 |
if ( entities[ i ].brushes == NULL && entities[ i ].patches == NULL ) { |
| 167 |
continue; |
| 168 |
} |
| 169 |
|
| 170 |
|
| 171 |
value = ValueForKey( &entities[ i ], "_ins" ); |
| 172 |
if ( value[ 0 ] == '\0' ) { |
| 173 |
value = ValueForKey( &entities[ i ], "_instance" ); |
| 174 |
} |
| 175 |
if ( value[ 0 ] == '\0' ) { |
| 176 |
value = ValueForKey( &entities[ i ], "_clone" ); |
| 177 |
} |
| 178 |
if ( value[ 0 ] == '\0' ) { |
| 179 |
continue; |
| 180 |
} |
| 181 |
|
| 182 |
|
| 183 |
for ( j = 0; j < numEntities; j++ ) |
| 184 |
{ |
| 185 |
|
| 186 |
value2 = ValueForKey( &entities[ j ], "_clonename" ); |
| 187 |
if ( value2[ 0 ] == '\0' ) { |
| 188 |
continue; |
| 189 |
} |
| 190 |
|
| 191 |
|
| 192 |
if ( strcmp( value, value2 ) == 0 ) { |
| 193 |
|
| 194 |
value3 = ValueForKey( &entities[ j ], "model" ); |
| 195 |
if ( value3[ 0 ] == '\0' ) { |
| 196 |
Sys_FPrintf( SYS_WRN, "WARNING: Cloned entity %s referenced entity without model\n", value2 ); |
| 197 |
continue; |
| 198 |
} |
| 199 |
models = atoi( &value2[ 1 ] ); |
| 200 |
|
| 201 |
|
| 202 |
sprintf( modelValue, "*%d", models ); |
| 203 |
SetKeyValue( &entities[ i ], "model", modelValue ); |
| 204 |
|
| 205 |
|
| 206 |
entities[ i ].brushes = NULL; |
| 207 |
entities[ i ].patches = NULL; |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
static void FixBrushSides( entity_t *e ){ |
| 221 |
int i; |
| 222 |
mapDrawSurface_t *ds; |
| 223 |
sideRef_t *sideRef; |
| 224 |
bspBrushSide_t *side; |
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
Sys_FPrintf( SYS_VRB, "--- FixBrushSides ---\n" ); |
| 229 |
|
| 230 |
|
| 231 |
for ( i = e->firstDrawSurf; i < numMapDrawSurfs; i++ ) |
| 232 |
{ |
| 233 |
|
| 234 |
ds = &mapDrawSurfs[ i ]; |
| 235 |
if ( ds->outputNum < 0 ) { |
| 236 |
continue; |
| 237 |
} |
| 238 |
|
| 239 |
|
| 240 |
for ( sideRef = ds->sideRef; sideRef != NULL; sideRef = sideRef->next ) |
| 241 |
{ |
| 242 |
|
| 243 |
if ( sideRef->side == NULL || sideRef->side->outputNum < 0 ) { |
| 244 |
continue; |
| 245 |
} |
| 246 |
side = &bspBrushSides[ sideRef->side->outputNum ]; |
| 247 |
|
| 248 |
|
| 249 |
side->surfaceNum = ds->outputNum; |
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
if ( strcmp( bspShaders[ side->shaderNum ].shader, ds->shaderInfo->shader ) ) { |
| 254 |
|
| 255 |
side->shaderNum = EmitShader( ds->shaderInfo->shader, &ds->shaderInfo->contentFlags, &ds->shaderInfo->surfaceFlags ); |
| 256 |
} |
| 257 |
} |
| 258 |
} |
| 259 |
} |
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
void ProcessWorldModel( const char *portalFilePath, const char *lineFilePath ){ |
| 269 |
int i, s; |
| 270 |
entity_t *e; |
| 271 |
tree_t *tree; |
| 272 |
face_t *faces; |
| 273 |
qboolean ignoreLeaks, leaked; |
| 274 |
xmlNodePtr polyline, leaknode; |
| 275 |
char level[ 2 ], shader[ 1024 ]; |
| 276 |
const char *value; |
| 277 |
int leakStatus; |
| 278 |
|
| 279 |
|
| 280 |
value = ValueForKey( &entities[ 0 ], "_blocksize" ); |
| 281 |
if ( value[ 0 ] == '\0' ) { |
| 282 |
value = ValueForKey( &entities[ 0 ], "blocksize" ); |
| 283 |
} |
| 284 |
if ( value[ 0 ] == '\0' ) { |
| 285 |
value = ValueForKey( &entities[ 0 ], "chopsize" ); |
| 286 |
} |
| 287 |
if ( value[ 0 ] != '\0' ) { |
| 288 |
|
| 289 |
s = sscanf( value, "%d %d %d", &blockSize[ 0 ], &blockSize[ 1 ], &blockSize[ 2 ] ); |
| 290 |
|
| 291 |
|
| 292 |
if ( s == 1 ) { |
| 293 |
blockSize[ 1 ] = blockSize[ 0 ]; |
| 294 |
blockSize[ 2 ] = blockSize[ 0 ]; |
| 295 |
} |
| 296 |
} |
| 297 |
Sys_Printf( "block size = { %d %d %d }\n", blockSize[ 0 ], blockSize[ 1 ], blockSize[ 2 ] ); |
| 298 |
|
| 299 |
|
| 300 |
value = ValueForKey( &entities[ 0 ], "_ignoreleaks" ); |
| 301 |
if ( value[ 0 ] == '\0' ) { |
| 302 |
value = ValueForKey( &entities[ 0 ], "ignoreleaks" ); |
| 303 |
} |
| 304 |
if ( value[ 0 ] == '1' ) { |
| 305 |
ignoreLeaks = qtrue; |
| 306 |
} |
| 307 |
else{ |
| 308 |
ignoreLeaks = qfalse; |
| 309 |
} |
| 310 |
|
| 311 |
|
| 312 |
BeginModel(); |
| 313 |
e = &entities[ 0 ]; |
| 314 |
e->firstDrawSurf = 0; |
| 315 |
|
| 316 |
|
| 317 |
ClearMetaTriangles(); |
| 318 |
|
| 319 |
|
| 320 |
PatchMapDrawSurfs( e ); |
| 321 |
|
| 322 |
if ( debugClip ) { |
| 323 |
AddTriangleModels( e ); |
| 324 |
} |
| 325 |
|
| 326 |
|
| 327 |
faces = MakeStructuralBSPFaceList( entities[ 0 ].brushes ); |
| 328 |
tree = FaceBSP( faces ); |
| 329 |
MakeTreePortals( tree ); |
| 330 |
FilterStructuralBrushesIntoTree( e, tree ); |
| 331 |
|
| 332 |
|
| 333 |
leakStatus = FloodEntities( tree ); |
| 334 |
if ( ignoreLeaks ) { |
| 335 |
if ( leakStatus == FLOODENTITIES_LEAKED ) { |
| 336 |
leakStatus = FLOODENTITIES_GOOD; |
| 337 |
} |
| 338 |
} |
| 339 |
|
| 340 |
if ( leakStatus == FLOODENTITIES_GOOD ) { |
| 341 |
leaked = qfalse; |
| 342 |
} |
| 343 |
else |
| 344 |
{ |
| 345 |
leaked = qtrue; |
| 346 |
|
| 347 |
Sys_FPrintf( SYS_NOXML, "**********************\n" ); |
| 348 |
Sys_FPrintf( SYS_NOXML, "******* leaked *******\n" ); |
| 349 |
Sys_FPrintf( SYS_NOXML, "**********************\n" ); |
| 350 |
polyline = LeakFile( tree, lineFilePath ); |
| 351 |
leaknode = xmlNewNode( NULL, (xmlChar*)"message" ); |
| 352 |
xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" ); |
| 353 |
xmlAddChild( leaknode, polyline ); |
| 354 |
level[0] = (int) '0' + SYS_ERR; |
| 355 |
level[1] = 0; |
| 356 |
xmlSetProp( leaknode, (xmlChar*)"level", (xmlChar*) &level ); |
| 357 |
xml_SendNode( leaknode ); |
| 358 |
if ( leaktest ) { |
| 359 |
Sys_Printf( "--- MAP LEAKED, ABORTING LEAKTEST ---\n" ); |
| 360 |
exit( 0 ); |
| 361 |
} |
| 362 |
} |
| 363 |
|
| 364 |
if ( leakStatus != FLOODENTITIES_EMPTY ) { |
| 365 |
|
| 366 |
FillOutside( tree->headnode ); |
| 367 |
|
| 368 |
|
| 369 |
ClipSidesIntoTree( e, tree ); |
| 370 |
|
| 371 |
|
| 372 |
faces = MakeVisibleBSPFaceList( entities[ 0 ].brushes ); |
| 373 |
FreeTree( tree ); |
| 374 |
tree = FaceBSP( faces ); |
| 375 |
MakeTreePortals( tree ); |
| 376 |
FilterStructuralBrushesIntoTree( e, tree ); |
| 377 |
|
| 378 |
|
| 379 |
if ( skyboxPresent ) { |
| 380 |
FloodEntities( tree ); |
| 381 |
} |
| 382 |
} |
| 383 |
|
| 384 |
|
| 385 |
NumberClusters( tree ); |
| 386 |
if ( !leaked ) { |
| 387 |
WritePortalFile( tree, portalFilePath ); |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
FloodAreas( tree ); |
| 392 |
|
| 393 |
|
| 394 |
if ( !debugClip ) { |
| 395 |
AddTriangleModels( e ); |
| 396 |
} |
| 397 |
|
| 398 |
|
| 399 |
AddEntitySurfaceModels( e ); |
| 400 |
|
| 401 |
|
| 402 |
EmitBrushes( e->brushes, &e->firstBrush, &e->numBrushes ); |
| 403 |
|
| 404 |
|
| 405 |
FilterDetailBrushesIntoTree( e, tree ); |
| 406 |
|
| 407 |
|
| 408 |
if ( !nofog ) { |
| 409 |
FogDrawSurfaces( e ); |
| 410 |
} |
| 411 |
|
| 412 |
|
| 413 |
if ( !nosubdivide ) { |
| 414 |
SubdivideFaceSurfaces( e, tree ); |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
if ( !notjunc ) { |
| 419 |
FixTJunctions( e ); |
| 420 |
} |
| 421 |
|
| 422 |
|
| 423 |
ClassifyEntitySurfaces( e ); |
| 424 |
|
| 425 |
|
| 426 |
MakeEntityDecals( e ); |
| 427 |
|
| 428 |
|
| 429 |
MakeEntityMetaTriangles( e ); |
| 430 |
SmoothMetaTriangles(); |
| 431 |
FixMetaTJunctions(); |
| 432 |
MergeMetaTriangles(); |
| 433 |
|
| 434 |
|
| 435 |
if ( debugPortals ) { |
| 436 |
MakeDebugPortalSurfs( tree ); |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
value = ValueForKey( &entities[ 0 ], "_foghull" ); |
| 441 |
if ( value[ 0 ] != '\0' ) { |
| 442 |
sprintf( shader, "textures/%s", value ); |
| 443 |
MakeFogHullSurfs( e, tree, shader ); |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
for ( i = 0; i < numEntities && emitFlares; i++ ) |
| 448 |
{ |
| 449 |
entity_t *light, *target; |
| 450 |
const char *value, *flareShader; |
| 451 |
vec3_t origin, targetOrigin, normal, color; |
| 452 |
int lightStyle; |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
light = &entities[ i ]; |
| 457 |
value = ValueForKey( light, "classname" ); |
| 458 |
if ( !strcmp( value, "light" ) ) { |
| 459 |
|
| 460 |
flareShader = ValueForKey( light, "_flareshader" ); |
| 461 |
value = ValueForKey( light, "_flare" ); |
| 462 |
if ( flareShader[ 0 ] != '\0' || value[ 0 ] != '\0' ) { |
| 463 |
|
| 464 |
GetVectorForKey( light, "origin", origin ); |
| 465 |
GetVectorForKey( light, "_color", color ); |
| 466 |
lightStyle = IntForKey( light, "_style" ); |
| 467 |
if ( lightStyle == 0 ) { |
| 468 |
lightStyle = IntForKey( light, "style" ); |
| 469 |
} |
| 470 |
|
| 471 |
|
| 472 |
value = ValueForKey( light, "target" ); |
| 473 |
if ( value[ 0 ] != '\0' ) { |
| 474 |
|
| 475 |
target = FindTargetEntity( value ); |
| 476 |
if ( target != NULL ) { |
| 477 |
GetVectorForKey( target, "origin", targetOrigin ); |
| 478 |
VectorSubtract( targetOrigin, origin, normal ); |
| 479 |
VectorNormalize( normal, normal ); |
| 480 |
} |
| 481 |
} |
| 482 |
else{ |
| 483 |
|
| 484 |
VectorSet( normal, 0, 0, -1 ); |
| 485 |
} |
| 486 |
|
| 487 |
if ( colorsRGB ) { |
| 488 |
color[0] = Image_LinearFloatFromsRGBFloat( color[0] ); |
| 489 |
color[1] = Image_LinearFloatFromsRGBFloat( color[1] ); |
| 490 |
color[2] = Image_LinearFloatFromsRGBFloat( color[2] ); |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
DrawSurfaceForFlare( mapEntityNum, origin, normal, color, flareShader, lightStyle ); |
| 495 |
} |
| 496 |
} |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
FilterDrawsurfsIntoTree( e, tree ); |
| 501 |
|
| 502 |
|
| 503 |
FixBrushSides( e ); |
| 504 |
|
| 505 |
|
| 506 |
EndModel( e, tree->headnode ); |
| 507 |
FreeTree( tree ); |
| 508 |
} |
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
void ProcessSubModel( void ){ |
| 518 |
entity_t *e; |
| 519 |
tree_t *tree; |
| 520 |
brush_t *b, *bc; |
| 521 |
node_t *node; |
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
BeginModel(); |
| 526 |
e = &entities[ mapEntityNum ]; |
| 527 |
e->firstDrawSurf = numMapDrawSurfs; |
| 528 |
|
| 529 |
|
| 530 |
ClearMetaTriangles(); |
| 531 |
|
| 532 |
|
| 533 |
PatchMapDrawSurfs( e ); |
| 534 |
|
| 535 |
|
| 536 |
node = AllocNode(); |
| 537 |
node->planenum = PLANENUM_LEAF; |
| 538 |
tree = AllocTree(); |
| 539 |
tree->headnode = node; |
| 540 |
|
| 541 |
|
| 542 |
ClipSidesIntoTree( e, tree ); |
| 543 |
|
| 544 |
|
| 545 |
AddTriangleModels( e ); |
| 546 |
|
| 547 |
|
| 548 |
AddEntitySurfaceModels( e ); |
| 549 |
|
| 550 |
|
| 551 |
EmitBrushes( e->brushes, &e->firstBrush, &e->numBrushes ); |
| 552 |
|
| 553 |
|
| 554 |
for ( b = e->brushes; b; b = b->next ) |
| 555 |
{ |
| 556 |
bc = CopyBrush( b ); |
| 557 |
bc->next = node->brushlist; |
| 558 |
node->brushlist = bc; |
| 559 |
} |
| 560 |
|
| 561 |
|
| 562 |
if ( !nosubdivide ) { |
| 563 |
SubdivideFaceSurfaces( e, tree ); |
| 564 |
} |
| 565 |
|
| 566 |
|
| 567 |
if ( !notjunc ) { |
| 568 |
FixTJunctions( e ); |
| 569 |
} |
| 570 |
|
| 571 |
|
| 572 |
ClassifyEntitySurfaces( e ); |
| 573 |
|
| 574 |
|
| 575 |
MakeEntityDecals( e ); |
| 576 |
|
| 577 |
|
| 578 |
MakeEntityMetaTriangles( e ); |
| 579 |
SmoothMetaTriangles(); |
| 580 |
FixMetaTJunctions(); |
| 581 |
MergeMetaTriangles(); |
| 582 |
|
| 583 |
|
| 584 |
FilterDrawsurfsIntoTree( e, tree ); |
| 585 |
|
| 586 |
|
| 587 |
FixBrushSides( e ); |
| 588 |
|
| 589 |
|
| 590 |
EndModel( e, node ); |
| 591 |
FreeTree( tree ); |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
void ProcessModels( const char *portalFilePath, const char *lineFilePath ){ |
| 602 |
qboolean oldVerbose; |
| 603 |
entity_t *entity; |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
oldVerbose = verbose; |
| 608 |
|
| 609 |
|
| 610 |
BeginBSPFile(); |
| 611 |
|
| 612 |
|
| 613 |
CreateMapFogs(); |
| 614 |
|
| 615 |
|
| 616 |
for ( mapEntityNum = 0; mapEntityNum < numEntities; mapEntityNum++ ) |
| 617 |
{ |
| 618 |
|
| 619 |
entity = &entities[ mapEntityNum ]; |
| 620 |
if ( entity->brushes == NULL && entity->patches == NULL ) { |
| 621 |
continue; |
| 622 |
} |
| 623 |
|
| 624 |
|
| 625 |
Sys_FPrintf( SYS_VRB, "############### model %i ###############\n", numBSPModels ); |
| 626 |
if ( mapEntityNum == 0 ) { |
| 627 |
ProcessWorldModel(portalFilePath, lineFilePath); |
| 628 |
} |
| 629 |
else{ |
| 630 |
ProcessSubModel(); |
| 631 |
} |
| 632 |
|
| 633 |
|
| 634 |
verbose = verboseEntities; |
| 635 |
} |
| 636 |
|
| 637 |
|
| 638 |
verbose = oldVerbose; |
| 639 |
|
| 640 |
Sys_FPrintf( SYS_VRB, "%9i bspModels in total\n", numBSPModels ); |
| 641 |
|
| 642 |
|
| 643 |
EmitFogs(); |
| 644 |
|
| 645 |
|
| 646 |
EmitMetaStats(); |
| 647 |
} |
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
void OnlyEnts( const char *BSPFilePath ){ |
| 657 |
char save_cmdline[1024], save_version[1024], save_gridsize[1024]; |
| 658 |
const char *p; |
| 659 |
|
| 660 |
|
| 661 |
Sys_Printf( "--- OnlyEnts ---\n" ); |
| 662 |
|
| 663 |
LoadBSPFile( BSPFilePath ); |
| 664 |
|
| 665 |
ParseEntities(); |
| 666 |
p = ValueForKey( &entities[0], "_q3map2_cmdline" ); |
| 667 |
strncpy( save_cmdline, p, sizeof( save_cmdline ) ); |
| 668 |
save_cmdline[sizeof( save_cmdline ) - 1] = 0; |
| 669 |
p = ValueForKey( &entities[0], "_q3map2_version" ); |
| 670 |
strncpy( save_version, p, sizeof( save_version ) ); |
| 671 |
save_version[sizeof( save_version ) - 1] = 0; |
| 672 |
p = ValueForKey( &entities[0], "gridsize" ); |
| 673 |
strncpy( save_gridsize, p, sizeof( save_gridsize ) ); |
| 674 |
save_gridsize[sizeof( save_gridsize ) - 1] = 0; |
| 675 |
|
| 676 |
numEntities = 0; |
| 677 |
|
| 678 |
LoadShaderInfo(); |
| 679 |
LoadMapFile( name, qfalse, qfalse ); |
| 680 |
SetModelNumbers(); |
| 681 |
SetLightStyles(); |
| 682 |
|
| 683 |
if ( *save_cmdline ) { |
| 684 |
SetKeyValue( &entities[0], "_q3map2_cmdline", save_cmdline ); |
| 685 |
} |
| 686 |
if ( *save_version ) { |
| 687 |
SetKeyValue( &entities[0], "_q3map2_version", save_version ); |
| 688 |
} |
| 689 |
if ( *save_gridsize ) { |
| 690 |
SetKeyValue( &entities[0], "gridsize", save_gridsize ); |
| 691 |
} |
| 692 |
|
| 693 |
numBSPEntities = numEntities; |
| 694 |
UnparseEntities(); |
| 695 |
|
| 696 |
WriteBSPFile( BSPFilePath ); |
| 697 |
} |
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
int BSPMain( int argc, char **argv ){ |
| 707 |
int i; |
| 708 |
char path[ 1024 ], tempSource[ 1024 ]; |
| 709 |
qboolean onlyents = qfalse; |
| 710 |
char BSPFilePath [ 1024 ]; |
| 711 |
char lineFilePath [ 1024 ]; |
| 712 |
char portalFilePath [ 1024 ]; |
| 713 |
char surfaceFilePath [ 1024 ]; |
| 714 |
BSPFilePath[0] = 0; |
| 715 |
lineFilePath[0] = 0; |
| 716 |
portalFilePath[0] = 0; |
| 717 |
surfaceFilePath[0] = 0; |
| 718 |
|
| 719 |
if ( argc >= 2 && !strcmp( argv[ 1 ], "-bsp" ) ) { |
| 720 |
argv++; |
| 721 |
argc--; |
| 722 |
} |
| 723 |
|
| 724 |
|
| 725 |
Sys_Printf( "--- BSP ---\n" ); |
| 726 |
|
| 727 |
doingBSP = qtrue; |
| 728 |
SetDrawSurfacesBuffer(); |
| 729 |
mapDrawSurfs = safe_malloc0( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS ); |
| 730 |
numMapDrawSurfs = 0; |
| 731 |
|
| 732 |
tempSource[ 0 ] = '\0'; |
| 733 |
globalCelShader[0] = 0; |
| 734 |
|
| 735 |
|
| 736 |
maxSurfaceVerts = game->maxSurfaceVerts; |
| 737 |
maxSurfaceIndexes = game->maxSurfaceIndexes; |
| 738 |
emitFlares = game->emitFlares; |
| 739 |
texturesRGB = game->texturesRGB; |
| 740 |
colorsRGB = game->colorsRGB; |
| 741 |
|
| 742 |
|
| 743 |
for ( i = 1; i < ( argc - 1 ); i++ ) |
| 744 |
{ |
| 745 |
if ( !strcmp( argv[ i ], "-onlyents" ) ) { |
| 746 |
Sys_Printf( "Running entity-only compile\n" ); |
| 747 |
onlyents = qtrue; |
| 748 |
} |
| 749 |
else if ( !strcmp( argv[ i ], "-tempname" ) ) { |
| 750 |
strcpy( tempSource, argv[ ++i ] ); |
| 751 |
} |
| 752 |
else if ( !strcmp( argv[ i ], "-tmpout" ) ) { |
| 753 |
strcpy( outbase, "/tmp" ); |
| 754 |
} |
| 755 |
else if ( !strcmp( argv[ i ], "-nowater" ) ) { |
| 756 |
Sys_Printf( "Disabling water\n" ); |
| 757 |
nowater = qtrue; |
| 758 |
} |
| 759 |
else if ( !strcmp( argv[ i ], "-keeplights" ) ) { |
| 760 |
keepLights = qtrue; |
| 761 |
Sys_Printf( "Leaving light entities on map after compile\n" ); |
| 762 |
} |
| 763 |
else if ( !strcmp( argv[ i ], "-nodetail" ) ) { |
| 764 |
Sys_Printf( "Ignoring detail brushes\n" ) ; |
| 765 |
nodetail = qtrue; |
| 766 |
} |
| 767 |
else if ( !strcmp( argv[ i ], "-fulldetail" ) ) { |
| 768 |
Sys_Printf( "Turning detail brushes into structural brushes\n" ); |
| 769 |
fulldetail = qtrue; |
| 770 |
} |
| 771 |
else if ( !strcmp( argv[ i ], "-nofog" ) ) { |
| 772 |
Sys_Printf( "Fog volumes disabled\n" ); |
| 773 |
nofog = qtrue; |
| 774 |
} |
| 775 |
else if ( !strcmp( argv[ i ], "-nosubdivide" ) ) { |
| 776 |
Sys_Printf( "Disabling brush face subdivision\n" ); |
| 777 |
nosubdivide = qtrue; |
| 778 |
} |
| 779 |
else if ( !strcmp( argv[ i ], "-leaktest" ) ) { |
| 780 |
Sys_Printf( "Leaktest enabled\n" ); |
| 781 |
leaktest = qtrue; |
| 782 |
} |
| 783 |
else if ( !strcmp( argv[ i ], "-verboseentities" ) ) { |
| 784 |
Sys_Printf( "Verbose entities enabled\n" ); |
| 785 |
verboseEntities = qtrue; |
| 786 |
} |
| 787 |
else if ( !strcmp( argv[ i ], "-nocurves" ) ) { |
| 788 |
Sys_Printf( "Ignoring curved surfaces (patches)\n" ); |
| 789 |
noCurveBrushes = qtrue; |
| 790 |
} |
| 791 |
else if ( !strcmp( argv[ i ], "-notjunc" ) ) { |
| 792 |
Sys_Printf( "T-junction fixing disabled\n" ); |
| 793 |
notjunc = qtrue; |
| 794 |
} |
| 795 |
else if ( !strcmp( argv[ i ], "-fakemap" ) ) { |
| 796 |
Sys_Printf( "Generating fakemap.map\n" ); |
| 797 |
fakemap = qtrue; |
| 798 |
} |
| 799 |
else if ( !strcmp( argv[ i ], "-samplesize" ) ) { |
| 800 |
sampleSize = atoi( argv[ i + 1 ] ); |
| 801 |
if ( sampleSize < 1 ) { |
| 802 |
sampleSize = 1; |
| 803 |
} |
| 804 |
i++; |
| 805 |
Sys_Printf( "Lightmap sample size set to %dx%d units\n", sampleSize, sampleSize ); |
| 806 |
} |
| 807 |
else if ( !strcmp( argv[ i ], "-minsamplesize" ) ) { |
| 808 |
minSampleSize = atoi( argv[ i + 1 ] ); |
| 809 |
if ( minSampleSize < 1 ) { |
| 810 |
minSampleSize = 1; |
| 811 |
} |
| 812 |
i++; |
| 813 |
Sys_Printf( "Minimum lightmap sample size set to %dx%d units\n", minSampleSize, minSampleSize ); |
| 814 |
} |
| 815 |
else if ( !strcmp( argv[ i ], "-custinfoparms" ) ) { |
| 816 |
Sys_Printf( "Custom info parms enabled\n" ); |
| 817 |
useCustomInfoParms = qtrue; |
| 818 |
} |
| 819 |
|
| 820 |
|
| 821 |
else if ( !strcmp( argv[ i ], "-rename" ) ) { |
| 822 |
Sys_Printf( "Appending _bsp suffix to misc_model shaders (SOF2)\n" ); |
| 823 |
renameModelShaders = qtrue; |
| 824 |
} |
| 825 |
|
| 826 |
|
| 827 |
else if ( !strcmp( argv[ i ], "-ne" ) ) { |
| 828 |
normalEpsilon = atof( argv[ i + 1 ] ); |
| 829 |
i++; |
| 830 |
Sys_Printf( "Normal epsilon set to %f\n", normalEpsilon ); |
| 831 |
} |
| 832 |
else if ( !strcmp( argv[ i ], "-de" ) ) { |
| 833 |
distanceEpsilon = atof( argv[ i + 1 ] ); |
| 834 |
i++; |
| 835 |
Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon ); |
| 836 |
} |
| 837 |
else if ( !strcmp( argv[ i ], "-fastmeta" ) ) { |
| 838 |
maxLMSurfaceVerts = 64; |
| 839 |
maxSurfaceVerts = 999; |
| 840 |
maxSurfaceIndexes = 6000; |
| 841 |
Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts ); |
| 842 |
Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes ); |
| 843 |
Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts ); |
| 844 |
} |
| 845 |
else if ( !strcmp( argv[ i ], "-maxsurfacevertices" ) ) { |
| 846 |
maxSurfaceVerts = atoi( argv[ i + 1 ] ); |
| 847 |
if ( maxSurfaceVerts < 3 ) { |
| 848 |
maxSurfaceVerts = 3; |
| 849 |
} |
| 850 |
i++; |
| 851 |
Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts ); |
| 852 |
} |
| 853 |
else if ( !strcmp( argv[ i ], "-maxsurfaceindexes" ) || !strcmp( argv[ i ], "-mi" ) ) { |
| 854 |
maxSurfaceIndexes = atoi( argv[ i + 1 ] ); |
| 855 |
if ( maxSurfaceIndexes < 3 ) { |
| 856 |
maxSurfaceIndexes = 3; |
| 857 |
} |
| 858 |
i++; |
| 859 |
|
| 860 |
if ( !strcmp( argv[ i ], "-mi" ) ) { |
| 861 |
Sys_Printf( "The -mi argument is deprecated, use \"-maxsurfaceindexes\" instead\n" ); |
| 862 |
} |
| 863 |
else { |
| 864 |
Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes ); |
| 865 |
} |
| 866 |
} |
| 867 |
else if ( !strcmp( argv[ i ], "-maxlightmapvertices" ) || !strcmp( argv[ i ], "-mv" ) ) { |
| 868 |
maxLMSurfaceVerts = atoi( argv[ i + 1 ] ); |
| 869 |
if ( maxLMSurfaceVerts < 3 ) { |
| 870 |
maxLMSurfaceVerts = 3; |
| 871 |
} |
| 872 |
if ( maxLMSurfaceVerts > maxSurfaceVerts ) { |
| 873 |
maxSurfaceVerts = maxLMSurfaceVerts; |
| 874 |
} |
| 875 |
i++; |
| 876 |
|
| 877 |
if ( !strcmp( argv[ i ], "-mv" ) ) { |
| 878 |
Sys_Printf( "The -mv argument is deprecated, use \"-maxlightmapvertices\" instead\n" ); |
| 879 |
} |
| 880 |
else { |
| 881 |
Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts ); |
| 882 |
} |
| 883 |
} |
| 884 |
else if ( !strcmp( argv[ i ], "-np" ) ) { |
| 885 |
npDegrees = atof( argv[ i + 1 ] ); |
| 886 |
if ( npDegrees < 0.0f ) { |
| 887 |
npDegrees = 0.0f; |
| 888 |
} |
| 889 |
else if ( npDegrees > 0.0f ) { |
| 890 |
Sys_Printf( "Forcing nonplanar surfaces with a breaking angle of %f degrees\n", npDegrees ); |
| 891 |
} |
| 892 |
i++; |
| 893 |
} |
| 894 |
else if ( !strcmp( argv[ i ], "-snap" ) ) { |
| 895 |
bevelSnap = atoi( argv[ i + 1 ] ); |
| 896 |
if ( bevelSnap < 0 ) { |
| 897 |
bevelSnap = 0; |
| 898 |
} |
| 899 |
i++; |
| 900 |
if ( bevelSnap > 0 ) { |
| 901 |
Sys_Printf( "Snapping brush bevel planes to %d units\n", bevelSnap ); |
| 902 |
} |
| 903 |
} |
| 904 |
else if ( !strcmp( argv[ i ], "-texrange" ) ) { |
| 905 |
texRange = atoi( argv[ i + 1 ] ); |
| 906 |
if ( texRange < 0 ) { |
| 907 |
texRange = 0; |
| 908 |
} |
| 909 |
i++; |
| 910 |
Sys_Printf( "Limiting per-surface texture range to %d texels\n", texRange ); |
| 911 |
} |
| 912 |
else if ( !strcmp( argv[ i ], "-nohint" ) ) { |
| 913 |
Sys_Printf( "Hint brushes disabled\n" ); |
| 914 |
noHint = qtrue; |
| 915 |
} |
| 916 |
else if ( !strcmp( argv[ i ], "-flat" ) ) { |
| 917 |
Sys_Printf( "Flatshading enabled\n" ); |
| 918 |
flat = qtrue; |
| 919 |
} |
| 920 |
else if ( !strcmp( argv[ i ], "-celshader" ) ) { |
| 921 |
++i; |
| 922 |
if ( argv[i][0] ) { |
| 923 |
sprintf( globalCelShader, "textures/%s", argv[ i ] ); |
| 924 |
} |
| 925 |
else{ |
| 926 |
*globalCelShader = 0; |
| 927 |
} |
| 928 |
Sys_Printf( "Global cel shader set to \"%s\"\n", globalCelShader ); |
| 929 |
} |
| 930 |
else if ( !strcmp( argv[ i ], "-meta" ) ) { |
| 931 |
Sys_Printf( "Creating meta surfaces from brush faces\n" ); |
| 932 |
meta = qtrue; |
| 933 |
} |
| 934 |
else if ( !strcmp( argv[ i ], "-metaadequatescore" ) ) { |
| 935 |
metaAdequateScore = atoi( argv[ i + 1 ] ); |
| 936 |
if ( metaAdequateScore < 0 ) { |
| 937 |
metaAdequateScore = -1; |
| 938 |
} |
| 939 |
i++; |
| 940 |
if ( metaAdequateScore >= 0 ) { |
| 941 |
Sys_Printf( "Setting ADEQUATE meta score to %d (see surface_meta.c)\n", metaAdequateScore ); |
| 942 |
} |
| 943 |
} |
| 944 |
else if ( !strcmp( argv[ i ], "-metagoodscore" ) ) { |
| 945 |
metaGoodScore = atoi( argv[ i + 1 ] ); |
| 946 |
if ( metaGoodScore < 0 ) { |
| 947 |
metaGoodScore = -1; |
| 948 |
} |
| 949 |
i++; |
| 950 |
if ( metaGoodScore >= 0 ) { |
| 951 |
Sys_Printf( "Setting GOOD meta score to %d (see surface_meta.c)\n", metaGoodScore ); |
| 952 |
} |
| 953 |
} |
| 954 |
else if ( !strcmp( argv[ i ], "-metamaxbboxdistance" ) ) { |
| 955 |
metaMaxBBoxDistance = atof( argv[ i + 1 ] ); |
| 956 |
if ( metaMaxBBoxDistance < 0 ) { |
| 957 |
metaMaxBBoxDistance = -1; |
| 958 |
} |
| 959 |
i++; |
| 960 |
if ( metaMaxBBoxDistance >= 0 ) { |
| 961 |
Sys_Printf( "Setting meta maximum bounding box distance to %f\n", metaMaxBBoxDistance ); |
| 962 |
} |
| 963 |
} |
| 964 |
else if ( !strcmp( argv[ i ], "-patchmeta" ) ) { |
| 965 |
Sys_Printf( "Creating meta surfaces from patches\n" ); |
| 966 |
patchMeta = qtrue; |
| 967 |
} |
| 968 |
else if ( !strcmp( argv[ i ], "-flares" ) ) { |
| 969 |
Sys_Printf( "Flare surfaces enabled\n" ); |
| 970 |
emitFlares = qtrue; |
| 971 |
} |
| 972 |
else if ( !strcmp( argv[ i ], "-noflares" ) ) { |
| 973 |
Sys_Printf( "Flare surfaces disabled\n" ); |
| 974 |
emitFlares = qfalse; |
| 975 |
} |
| 976 |
else if ( !strcmp( argv[ i ], "-skyfix" ) ) { |
| 977 |
Sys_Printf( "GL_CLAMP sky fix/hack/workaround enabled\n" ); |
| 978 |
skyFixHack = qtrue; |
| 979 |
} |
| 980 |
else if ( !strcmp( argv[ i ], "-debugsurfaces" ) ) { |
| 981 |
Sys_Printf( "emitting debug surfaces\n" ); |
| 982 |
debugSurfaces = qtrue; |
| 983 |
} |
| 984 |
else if ( !strcmp( argv[ i ], "-debuginset" ) ) { |
| 985 |
Sys_Printf( "Debug surface triangle insetting enabled\n" ); |
| 986 |
debugInset = qtrue; |
| 987 |
} |
| 988 |
else if ( !strcmp( argv[ i ], "-debugportals" ) ) { |
| 989 |
Sys_Printf( "Debug portal surfaces enabled\n" ); |
| 990 |
debugPortals = qtrue; |
| 991 |
} |
| 992 |
else if ( !strcmp( argv[ i ], "-debugclip" ) ) { |
| 993 |
Sys_Printf( "Debug model clip enabled\n" ); |
| 994 |
debugClip = qtrue; |
| 995 |
} |
| 996 |
else if ( !strcmp( argv[ i ], "-clipdepth" ) ) { |
| 997 |
clipDepthGlobal = atof( argv[ i + 1 ] ); |
| 998 |
i++; |
| 999 |
Sys_Printf( "Model autoclip thickness set to %.3f\n", clipDepthGlobal ); |
| 1000 |
} |
| 1001 |
else if ( !strcmp( argv[ i ], "-sRGBtex" ) ) { |
| 1002 |
texturesRGB = qtrue; |
| 1003 |
Sys_Printf( "Textures are in sRGB\n" ); |
| 1004 |
} |
| 1005 |
else if ( !strcmp( argv[ i ], "-nosRGBtex" ) ) { |
| 1006 |
texturesRGB = qfalse; |
| 1007 |
Sys_Printf( "Textures are linear\n" ); |
| 1008 |
} |
| 1009 |
else if ( !strcmp( argv[ i ], "-sRGBcolor" ) ) { |
| 1010 |
colorsRGB = qtrue; |
| 1011 |
Sys_Printf( "Colors are in sRGB\n" ); |
| 1012 |
} |
| 1013 |
else if ( !strcmp( argv[ i ], "-nosRGBcolor" ) ) { |
| 1014 |
colorsRGB = qfalse; |
| 1015 |
Sys_Printf( "Colors are linear\n" ); |
| 1016 |
} |
| 1017 |
else if ( !strcmp( argv[ i ], "-nosRGB" ) ) { |
| 1018 |
texturesRGB = qfalse; |
| 1019 |
Sys_Printf( "Textures are linear\n" ); |
| 1020 |
colorsRGB = qfalse; |
| 1021 |
Sys_Printf( "Colors are linear\n" ); |
| 1022 |
} |
| 1023 |
else if ( !strcmp( argv[ i ], "-altsplit" ) ) { |
| 1024 |
Sys_Printf( "Alternate BSP splitting (by 27) enabled\n" ); |
| 1025 |
bspAlternateSplitWeights = qtrue; |
| 1026 |
} |
| 1027 |
else if ( !strcmp( argv[ i ], "-deep" ) ) { |
| 1028 |
Sys_Printf( "Deep BSP tree generation enabled\n" ); |
| 1029 |
deepBSP = qtrue; |
| 1030 |
} |
| 1031 |
else if ( !strcmp( argv[ i ], "-maxarea" ) ) { |
| 1032 |
Sys_Printf( "Max Area face surface generation enabled\n" ); |
| 1033 |
maxAreaFaceSurface = qtrue; |
| 1034 |
} |
| 1035 |
else if ( !strcmp( argv[ i ], "-bspfile" ) ) |
| 1036 |
{ |
| 1037 |
strcpy( BSPFilePath, argv[i + 1] ); |
| 1038 |
argv[ i ] = NULL; |
| 1039 |
i++; |
| 1040 |
argv[ i ] = NULL; |
| 1041 |
Sys_Printf( "Use %s as bsp file\n", BSPFilePath ); |
| 1042 |
} |
| 1043 |
else if ( !strcmp( argv[ i ], "-linfile" ) ) |
| 1044 |
{ |
| 1045 |
strcpy( lineFilePath, argv[i + 1] ); |
| 1046 |
argv[ i ] = NULL; |
| 1047 |
i++; |
| 1048 |
argv[ i ] = NULL; |
| 1049 |
Sys_Printf( "Use %s as line file\n", lineFilePath ); |
| 1050 |
} |
| 1051 |
else if ( !strcmp( argv[ i ], "-prtfile" ) ) |
| 1052 |
{ |
| 1053 |
strcpy( portalFilePath, argv[i + 1] ); |
| 1054 |
argv[ i ] = NULL; |
| 1055 |
i++; |
| 1056 |
argv[ i ] = NULL; |
| 1057 |
Sys_Printf( "Use %s as portal file\n", portalFilePath ); |
| 1058 |
} |
| 1059 |
else if ( !strcmp( argv[ i ], "-srffile" ) ) |
| 1060 |
{ |
| 1061 |
strcpy( surfaceFilePath, argv[i + 1] ); |
| 1062 |
argv[ i ] = NULL; |
| 1063 |
i++; |
| 1064 |
argv[ i ] = NULL; |
| 1065 |
Sys_Printf( "Use %s as surface file\n", surfaceFilePath ); |
| 1066 |
} |
| 1067 |
else if ( !strcmp( argv[ i ], "-noob" ) ) { |
| 1068 |
Sys_Printf( "No oBs!\n" ); |
| 1069 |
noob = qtrue; |
| 1070 |
} |
| 1071 |
else |
| 1072 |
{ |
| 1073 |
Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] ); |
| 1074 |
} |
| 1075 |
} |
| 1076 |
|
| 1077 |
|
| 1078 |
if ( i != ( argc - 1 ) ) { |
| 1079 |
Error( "usage: q3map [options] mapfile" ); |
| 1080 |
} |
| 1081 |
|
| 1082 |
|
| 1083 |
strcpy( source, ExpandArg( argv[ i ] ) ); |
| 1084 |
StripExtension( source ); |
| 1085 |
|
| 1086 |
|
| 1087 |
SetDefaultSampleSize( sampleSize ); |
| 1088 |
|
| 1089 |
if (!BSPFilePath[0]) { |
| 1090 |
sprintf( BSPFilePath, "%s.bsp", source ); |
| 1091 |
} |
| 1092 |
if (!lineFilePath[0]) { |
| 1093 |
sprintf( lineFilePath, "%s.lin", source ); |
| 1094 |
} |
| 1095 |
if (!portalFilePath[0]) { |
| 1096 |
sprintf( portalFilePath, "%s.prt", source ); |
| 1097 |
} |
| 1098 |
if (!surfaceFilePath[0]) { |
| 1099 |
sprintf( surfaceFilePath, "%s.srf", source ); |
| 1100 |
} |
| 1101 |
|
| 1102 |
|
| 1103 |
remove( portalFilePath ); |
| 1104 |
remove( lineFilePath ); |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
strcpy( name, ExpandArg( argv[ i ] ) ); |
| 1109 |
if ( strcmp( name + strlen( name ) - 4, ".reg" ) ) { |
| 1110 |
|
| 1111 |
sprintf( path, "%s.reg", source ); |
| 1112 |
remove( path ); |
| 1113 |
DefaultExtension( name, ".map" ); |
| 1114 |
} |
| 1115 |
|
| 1116 |
|
| 1117 |
if ( onlyents ) { |
| 1118 |
OnlyEnts( BSPFilePath ); |
| 1119 |
return 0; |
| 1120 |
} |
| 1121 |
|
| 1122 |
|
| 1123 |
LoadShaderInfo(); |
| 1124 |
|
| 1125 |
|
| 1126 |
if ( strlen( tempSource ) > 0 ) { |
| 1127 |
LoadMapFile( tempSource, qfalse, qfalse ); |
| 1128 |
} |
| 1129 |
else{ |
| 1130 |
LoadMapFile( name, qfalse, qfalse ); |
| 1131 |
} |
| 1132 |
|
| 1133 |
|
| 1134 |
InjectCommandLine( argv, 1, argc - 1 ); |
| 1135 |
|
| 1136 |
|
| 1137 |
ProcessDecals(); |
| 1138 |
|
| 1139 |
|
| 1140 |
SetCloneModelNumbers(); |
| 1141 |
|
| 1142 |
|
| 1143 |
ProcessModels( portalFilePath, lineFilePath ); |
| 1144 |
|
| 1145 |
|
| 1146 |
SetLightStyles(); |
| 1147 |
|
| 1148 |
|
| 1149 |
ProcessAdvertisements(); |
| 1150 |
|
| 1151 |
|
| 1152 |
EndBSPFile( qtrue, BSPFilePath, surfaceFilePath ); |
| 1153 |
|
| 1154 |
|
| 1155 |
if ( strlen( tempSource ) > 0 ) { |
| 1156 |
remove( tempSource ); |
| 1157 |
} |
| 1158 |
|
| 1159 |
|
| 1160 |
return 0; |
| 1161 |
} |