mirror of
https://github.com/celisej567/BCWSsrc.git
synced 2026-09-15 20:12:39 +03:00
Initial Mapbase commit (squashed from mapbase-beta)
This commit is contained in:
@@ -56,6 +56,9 @@ bool g_NodrawTriggers = false;
|
||||
bool g_DisableWaterLighting = false;
|
||||
bool g_bAllowDetailCracks = false;
|
||||
bool g_bNoVirtualMesh = false;
|
||||
#ifdef MAPBASE
|
||||
bool g_bNoDefaultCubemaps = false;
|
||||
#endif
|
||||
|
||||
float g_defaultLuxelSize = DEFAULT_LUXEL_SIZE;
|
||||
float g_luxelScale = 1.0f;
|
||||
@@ -82,6 +85,182 @@ int entity_num;
|
||||
|
||||
node_t *block_nodes[BLOCKS_SPACE+2][BLOCKS_SPACE+2];
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Manifest stuff
|
||||
//-----------------------------------------------------------------------------
|
||||
CUtlVector<const char *> g_szManifestFiles;
|
||||
bool g_bManifestVerbose = true; // Change to false when testing is over
|
||||
|
||||
#define ManifestMsg(msg, ...) g_bManifestVerbose ? Msg(msg, __VA_ARGS__) : NULL
|
||||
#define ManifestWarning(msg, ...) g_bManifestVerbose ? Warning(msg, __VA_ARGS__) : NULL
|
||||
|
||||
void SetManifestFile(char const *file)
|
||||
{
|
||||
if (g_pFileSystem->FileExists( file ))
|
||||
{
|
||||
Msg("Manifest file: %s\n", file);
|
||||
g_szManifestFiles.AddToTail(file);
|
||||
}
|
||||
}
|
||||
|
||||
void ZipDirectory(const char *dir, const char *relative, IZip *package, int *filecount)
|
||||
{
|
||||
ManifestMsg(" MANIFEST: Mounting directory \"%s\"\n", dir);
|
||||
|
||||
FileFindHandle_t handle = NULL;
|
||||
const char *file = g_pFullFileSystem->FindFirst(dir, &handle);
|
||||
|
||||
// Prevents us from packaging the folder itself
|
||||
//if (file)
|
||||
// file = g_pFullFileSystem->FindNext(handle);
|
||||
|
||||
while (file)
|
||||
{
|
||||
// Don't use hidden files/folders
|
||||
if (file[0] != '.')
|
||||
{
|
||||
char subdir[MAX_PATH];
|
||||
Q_strncpy(subdir, dir, strlen(dir) - 1); // Remove wildcard
|
||||
Q_ComposeFileName(subdir, file, subdir, sizeof(subdir));
|
||||
|
||||
char subrelative[MAX_PATH];
|
||||
Q_strncpy(subrelative, relative, sizeof(subrelative));
|
||||
Q_ComposeFileName(subrelative, file, subrelative, sizeof(subrelative));
|
||||
|
||||
if (g_pFullFileSystem->FindIsDirectory(handle))
|
||||
{
|
||||
// Append wildcard
|
||||
Q_ComposeFileName(subdir, "*", subdir, sizeof(subdir));
|
||||
|
||||
// Mount subdirectory
|
||||
ZipDirectory(subdir, subrelative, package, filecount);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mount file
|
||||
ManifestMsg(" MANIFEST: File \"%s\" packed into BSP at \"%s\"\n", subdir, subrelative);
|
||||
*filecount++;
|
||||
AddFileToPak(package, subrelative, subdir);
|
||||
}
|
||||
}
|
||||
|
||||
file = g_pFullFileSystem->FindNext(handle);
|
||||
}
|
||||
g_pFullFileSystem->FindClose(handle);
|
||||
}
|
||||
|
||||
void ParseManifestFile()
|
||||
{
|
||||
if (g_szManifestFiles.Count() == 0)
|
||||
return;
|
||||
|
||||
Msg("Starting pack manifest with %i files\n", g_szManifestFiles.Count());
|
||||
|
||||
int totalfilecount = 0;
|
||||
|
||||
for (int i = 0; i < g_szManifestFiles.Count(); i++)
|
||||
{
|
||||
FileHandle_t manifestfile = g_pFileSystem->Open( g_szManifestFiles[i], "rb" );
|
||||
if (!manifestfile)
|
||||
{
|
||||
Warning("Manifest file \"%s\" cannot be read!\n", g_szManifestFiles[i]);
|
||||
continue;
|
||||
}
|
||||
|
||||
//FileHandle_t curfile;
|
||||
bool curfile;
|
||||
char buf[1024];
|
||||
char *scan;
|
||||
int filecount = 0;
|
||||
bool fullpath = false;
|
||||
while ( CmdLib_FGets( buf, sizeof( buf ), manifestfile ) )
|
||||
{
|
||||
scan = buf;
|
||||
|
||||
// Check if it's an actual path or just relative
|
||||
fullpath = (scan[0] == '#');
|
||||
if (fullpath)
|
||||
scan += 1;
|
||||
else
|
||||
{
|
||||
char file[128];
|
||||
Q_strncpy(file, scan, sizeof(file));
|
||||
char path[_MAX_PATH];
|
||||
Q_ExtractFilePath(source, path, sizeof(path));
|
||||
sprintf(scan, "%s%s", path, file);
|
||||
}
|
||||
|
||||
bool inquotes = (scan[0] == '"');
|
||||
int namelength;
|
||||
if (inquotes)
|
||||
{
|
||||
scan += 1;
|
||||
namelength = strcspn( scan, "\"" );
|
||||
}
|
||||
else
|
||||
{
|
||||
namelength = strcspn( scan, " \t" );
|
||||
}
|
||||
|
||||
char filename[FILENAME_MAX];
|
||||
Q_strncpy(filename, scan, namelength + 1);
|
||||
|
||||
scan += (namelength + inquotes);
|
||||
scan += strspn(scan, " \t");
|
||||
|
||||
// Remove any quotes in the internal path.
|
||||
// The fact they're actually optional in the second path is irrelevant.
|
||||
if (scan[0] == '"')
|
||||
{
|
||||
scan[0] = '\0';
|
||||
if (scan[strlen(scan) - 1] == '"')
|
||||
scan[strlen(scan) - 1] = '\0';
|
||||
}
|
||||
|
||||
curfile = g_pFileSystem->FileExists(filename);
|
||||
if (curfile)
|
||||
{
|
||||
// Assume internal file is a directory if no extension
|
||||
if (Q_GetFileExtension(scan) == NULL)
|
||||
Q_ComposeFileName(scan, filename, scan, sizeof(filename));
|
||||
|
||||
ManifestMsg(" MANIFEST: File \"%s\" packed into BSP at \"%s\"\n", filename, scan);
|
||||
filecount++;
|
||||
AddFileToPak(GetPakFile(), scan, filename);
|
||||
}
|
||||
else if (g_pFullFileSystem->IsDirectory(filename))
|
||||
{
|
||||
// Append wildcard
|
||||
if (!Q_strstr(filename, "*"))
|
||||
Q_ComposeFileName(filename, "*", filename, sizeof(filename));
|
||||
|
||||
// Internal path must be a directory
|
||||
if (scan[0] == NULL || Q_GetFileExtension(scan) == NULL)
|
||||
ZipDirectory(filename, scan, GetPakFile(), &filecount);
|
||||
else
|
||||
Warning("\n MANIFEST WARNING: Directory \"%s\" tried to pack to a file!\nIf you are not trying to package a directory to the BSP, add an extension to \"%s\".\nIf you are trying to package a directory, remove the extension from \"%s\".\n\n", filename, filename, scan);
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning(" MANIFEST WARNING: File \"%s\" does not exist!\n", filename);
|
||||
}
|
||||
}
|
||||
|
||||
if (filecount > 0)
|
||||
ManifestMsg("%i file(s) packed from manifest %s\n", filecount, g_szManifestFiles[i]);
|
||||
else
|
||||
ManifestWarning("*** No files zipped from manifest %s!\n ***", g_szManifestFiles[i]);
|
||||
|
||||
totalfilecount += filecount;
|
||||
|
||||
g_pFileSystem->Close( manifestfile );
|
||||
}
|
||||
|
||||
Msg("%i total file(s) packed from manifests\n", totalfilecount);
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Assign occluder areas (must happen *after* the world model is processed)
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -668,6 +847,7 @@ void SetOccluderArea( int nOccluder, int nArea, int nEntityNum )
|
||||
{
|
||||
g_OccluderData[nOccluder].area = nArea;
|
||||
}
|
||||
#ifndef MAPBASE
|
||||
else if ( (nArea != 0) && (g_OccluderData[nOccluder].area != nArea) )
|
||||
{
|
||||
const char *pTargetName = ValueForKey( &entities[nEntityNum], "targetname" );
|
||||
@@ -677,6 +857,7 @@ void SetOccluderArea( int nOccluder, int nArea, int nEntityNum )
|
||||
}
|
||||
Warning("Occluder \"%s\" straddles multiple areas. This is invalid!\n", pTargetName );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -857,7 +1038,12 @@ void ProcessModels (void)
|
||||
}
|
||||
|
||||
// Turn the skybox into a cubemap in case we don't build env_cubemap textures.
|
||||
#ifdef MAPBASE
|
||||
if (!g_bNoDefaultCubemaps)
|
||||
Cubemap_CreateDefaultCubemaps();
|
||||
#else
|
||||
Cubemap_CreateDefaultCubemaps();
|
||||
#endif
|
||||
EndBSPFile ();
|
||||
}
|
||||
|
||||
@@ -1129,6 +1315,21 @@ int RunVBSP( int argc, char **argv )
|
||||
{
|
||||
EnableFullMinidumps( true );
|
||||
}
|
||||
#ifdef MAPBASE
|
||||
else if ( !Q_stricmp( argv[i], "-deletecubemaps" ) )
|
||||
{
|
||||
g_bNoDefaultCubemaps = true;
|
||||
}
|
||||
else if ( !Q_stricmp( argv[i], "-manifest" ) )
|
||||
{
|
||||
SetManifestFile(argv[i+1]);
|
||||
i++;
|
||||
}
|
||||
else if ( !Q_stricmp( argv[i], "-manifest_verbose" ) )
|
||||
{
|
||||
g_bManifestVerbose = true;
|
||||
}
|
||||
#endif
|
||||
else if (argv[i][0] == '-')
|
||||
{
|
||||
Warning("VBSP: Unknown option \"%s\"\n\n", argv[i]);
|
||||
@@ -1244,6 +1445,13 @@ int RunVBSP( int argc, char **argv )
|
||||
ThreadSetDefault ();
|
||||
numthreads = 1; // multiple threads aren't helping...
|
||||
|
||||
#ifdef MAPBASE
|
||||
// Any additional files to pack?
|
||||
char ManifestFile[512];
|
||||
_snprintf( ManifestFile, sizeof(ManifestFile), "%s_zipmanifest.txt", source );
|
||||
SetManifestFile(ManifestFile);
|
||||
#endif
|
||||
|
||||
// Setup the logfile.
|
||||
char logFile[512];
|
||||
_snprintf( logFile, sizeof(logFile), "%s.log", source );
|
||||
@@ -1360,6 +1568,11 @@ int RunVBSP( int argc, char **argv )
|
||||
AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false );
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
// Is this a good place for this?
|
||||
ParseManifestFile();
|
||||
#endif
|
||||
|
||||
LoadMapFile (name);
|
||||
WorldVertexTransitionFixup();
|
||||
if( ( g_nDXLevel == 0 ) || ( g_nDXLevel >= 70 ) )
|
||||
|
||||
Reference in New Issue
Block a user