SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Loading...
Searching...
No Matches
bsppp::BSP Class Reference

#include <BSP.h>

Collaboration diagram for bsppp::BSP:

Public Member Functions

 BSP (std::string path_, bool loadPatchFiles=true)
 operator bool () const
uint32_t getVersion () const
void setVersion (uint32_t version)
uint32_t getMapRevision () const
void setMapRevision (uint32_t mapRevision)
bool isL4D2 () const
void setL4D2 (bool isL4D2)
bool isConsole () const
void setConsole (bool isConsole)
bool hasLump (BSPLump lumpIndex) const
bool isLumpCompressed (BSPLump lumpIndex) const
uint32_t getLumpVersion (BSPLump lumpIndex) const
std::optional< std::vector< std::byte > > getLumpData (BSPLump lumpIndex, bool noDecompression=false) const
template<BSPLump Lump>
auto getLumpData () const
bool setLump (BSPLump lumpIndex, uint32_t version, std::span< const std::byte > data, uint8_t compressLevel=0)
 BSP::setGameLump should be used for writing game lumps as they need special handling.
bool setLump (uint32_t version, std::span< const BSPEntityKeyValues > data, uint8_t compressLevel=0)
bool isGameLumpCompressed (BSPGameLump::Signature signature) const
uint16_t getGameLumpVersion (BSPGameLump::Signature signature) const
std::optional< std::vector< std::byte > > getGameLumpData (BSPGameLump::Signature signature) const
bool setGameLump (BSPGameLump::Signature signature, uint16_t version, std::span< const std::byte > data, uint8_t compressLevel=0)
void resetLump (BSPLump lumpIndex)
 Reset changes made to a lump before they're written to disk.
void reset ()
 Resets ALL in-memory modifications (version, all lumps including game lumps, map revision)
void createLumpPatchFile (BSPLump lumpIndex) const
bool setLumpFromPatchFile (const std::string &lumpFilePath)
bool bake (std::string_view outputPath="")

Static Public Member Functions

static BSP create (std::string path, uint32_t version=21, uint32_t mapRevision=0)

Protected Member Functions

bool readHeader ()
std::vector< BSPEntityKeyValuesparseEntities () const
std::vector< BSPPlaneparsePlanes () const
std::vector< BSPTextureDataparseTextureData () const
std::vector< BSPVertexparseVertices () const
std::vector< BSPNodeparseNodes () const
std::vector< BSPTextureInfoparseTextureInfo () const
std::vector< BSPFaceparseFaces () const
std::vector< BSPEdgeparseEdges () const
std::vector< BSPSurfEdgeparseSurfEdges () const
std::vector< BSPBrushModelparseBrushModels () const
std::vector< BSPFaceparseOriginalFaces () const
std::vector< BSPGameLumpparseGameLumps (bool decompress) const

Protected Attributes

std::string path
Header header {}
uint32_t stagedVersion {}
std::unordered_map< uint32_t, std::pair< Lump, std::vector< std::byte > > > stagedLumps
std::vector< BSPGameLumpstagedGameLumps
uint32_t stagedMapRevision {}
bool l4d2 = false
bool console = false

Detailed Description

Definition at line 125 of file BSP.h.

Constructor & Destructor Documentation

◆ BSP()

BSP::BSP ( std::string path_,
bool loadPatchFiles = true )
explicit

Definition at line 46 of file BSP.cpp.

Member Function Documentation

◆ bake()

bool BSP::bake ( std::string_view outputPath = "")

Definition at line 365 of file BSP.cpp.

◆ create()

BSP BSP::create ( std::string path,
uint32_t version = 21,
uint32_t mapRevision = 0 )
static

Definition at line 75 of file BSP.cpp.

◆ createLumpPatchFile()

void BSP::createLumpPatchFile ( BSPLump lumpIndex) const

Definition at line 305 of file BSP.cpp.

◆ getGameLumpData()

std::optional< std::vector< std::byte > > BSP::getGameLumpData ( BSPGameLump::Signature signature) const
nodiscard

Definition at line 242 of file BSP.cpp.

◆ getGameLumpVersion()

uint16_t BSP::getGameLumpVersion ( BSPGameLump::Signature signature) const
nodiscard

Definition at line 233 of file BSP.cpp.

◆ getLumpData() [1/2]

template<BSPLump Lump>
auto bsppp::BSP::getLumpData ( ) const
inlinenodiscard

Definition at line 178 of file BSP.h.

◆ getLumpData() [2/2]

std::optional< std::vector< std::byte > > BSP::getLumpData ( BSPLump lumpIndex,
bool noDecompression = false ) const
nodiscard

Definition at line 154 of file BSP.cpp.

◆ getLumpVersion()

uint32_t BSP::getLumpVersion ( BSPLump lumpIndex) const
nodiscard

Definition at line 143 of file BSP.cpp.

◆ getMapRevision()

uint32_t BSP::getMapRevision ( ) const
nodiscard

Definition at line 102 of file BSP.cpp.

◆ getVersion()

uint32_t BSP::getVersion ( ) const
nodiscard

Definition at line 94 of file BSP.cpp.

◆ hasLump()

bool BSP::hasLump ( BSPLump lumpIndex) const
nodiscard

Definition at line 126 of file BSP.cpp.

◆ isConsole()

bool BSP::isConsole ( ) const
nodiscard

Definition at line 118 of file BSP.cpp.

◆ isGameLumpCompressed()

bool BSP::isGameLumpCompressed ( BSPGameLump::Signature signature) const
nodiscard

Definition at line 224 of file BSP.cpp.

◆ isL4D2()

bool BSP::isL4D2 ( ) const
nodiscard

Definition at line 110 of file BSP.cpp.

◆ isLumpCompressed()

bool BSP::isLumpCompressed ( BSPLump lumpIndex) const
nodiscard

Definition at line 135 of file BSP.cpp.

◆ operator bool()

BSP::operator bool ( ) const
explicit

Definition at line 71 of file BSP.cpp.

◆ parseBrushModels()

std::vector< BSPBrushModel > BSP::parseBrushModels ( ) const
nodiscardprotected

Definition at line 708 of file BSP.cpp.

◆ parseEdges()

std::vector< BSPEdge > BSP::parseEdges ( ) const
nodiscardprotected

Definition at line 694 of file BSP.cpp.

◆ parseEntities()

std::vector< BSPEntityKeyValues > BSP::parseEntities ( ) const
nodiscardprotected

Definition at line 591 of file BSP.cpp.

◆ parseFaces()

std::vector< BSPFace > BSP::parseFaces ( ) const
nodiscardprotected

Definition at line 684 of file BSP.cpp.

◆ parseGameLumps()

std::vector< BSPGameLump > BSP::parseGameLumps ( bool decompress) const
nodiscardprotected

Definition at line 723 of file BSP.cpp.

◆ parseNodes()

std::vector< BSPNode > BSP::parseNodes ( ) const
nodiscardprotected

Definition at line 670 of file BSP.cpp.

◆ parseOriginalFaces()

std::vector< BSPFace > BSP::parseOriginalFaces ( ) const
nodiscardprotected

Definition at line 712 of file BSP.cpp.

◆ parsePlanes()

std::vector< BSPPlane > BSP::parsePlanes ( ) const
nodiscardprotected

Definition at line 658 of file BSP.cpp.

◆ parseSurfEdges()

std::vector< BSPSurfEdge > BSP::parseSurfEdges ( ) const
nodiscardprotected

Definition at line 704 of file BSP.cpp.

◆ parseTextureData()

std::vector< BSPTextureData > BSP::parseTextureData ( ) const
nodiscardprotected

Definition at line 662 of file BSP.cpp.

◆ parseTextureInfo()

std::vector< BSPTextureInfo > BSP::parseTextureInfo ( ) const
nodiscardprotected

Definition at line 680 of file BSP.cpp.

◆ parseVertices()

std::vector< BSPVertex > BSP::parseVertices ( ) const
nodiscardprotected

Definition at line 666 of file BSP.cpp.

◆ readHeader()

bool BSP::readHeader ( )
protected

Definition at line 539 of file BSP.cpp.

◆ reset()

void BSP::reset ( )

Resets ALL in-memory modifications (version, all lumps including game lumps, map revision)

Definition at line 295 of file BSP.cpp.

◆ resetLump()

void BSP::resetLump ( BSPLump lumpIndex)

Reset changes made to a lump before they're written to disk.

Definition at line 277 of file BSP.cpp.

◆ setConsole()

void BSP::setConsole ( bool isConsole)

Definition at line 122 of file BSP.cpp.

◆ setGameLump()

bool BSP::setGameLump ( BSPGameLump::Signature signature,
uint16_t version,
std::span< const std::byte > data,
uint8_t compressLevel = 0 )

Definition at line 254 of file BSP.cpp.

◆ setL4D2()

void BSP::setL4D2 ( bool isL4D2)

Definition at line 114 of file BSP.cpp.

◆ setLump() [1/2]

bool BSP::setLump ( BSPLump lumpIndex,
uint32_t version,
std::span< const std::byte > data,
uint8_t compressLevel = 0 )

BSP::setGameLump should be used for writing game lumps as they need special handling.

Paklump can be written here but compression is unsupported, prefer using bsppp::PakLump or your favorite zip library instead. Valid compressLevel range is 0 to 9, 0 is considered off, 9 the slowest and most compressiest

Definition at line 177 of file BSP.cpp.

◆ setLump() [2/2]

bool BSP::setLump ( uint32_t version,
std::span< const BSPEntityKeyValues > data,
uint8_t compressLevel = 0 )

Definition at line 208 of file BSP.cpp.

◆ setLumpFromPatchFile()

bool BSP::setLumpFromPatchFile ( const std::string & lumpFilePath)

Definition at line 343 of file BSP.cpp.

◆ setMapRevision()

void BSP::setMapRevision ( uint32_t mapRevision)

Definition at line 106 of file BSP.cpp.

◆ setVersion()

void BSP::setVersion ( uint32_t version)

Definition at line 98 of file BSP.cpp.

Member Data Documentation

◆ console

bool bsppp::BSP::console = false
protected

Definition at line 273 of file BSP.h.

◆ header

Header bsppp::BSP::header {}
protected

Definition at line 263 of file BSP.h.

◆ l4d2

bool bsppp::BSP::l4d2 = false
protected

Definition at line 271 of file BSP.h.

◆ path

std::string bsppp::BSP::path
protected

Definition at line 262 of file BSP.h.

◆ stagedGameLumps

std::vector<BSPGameLump> bsppp::BSP::stagedGameLumps
protected

Definition at line 267 of file BSP.h.

◆ stagedLumps

std::unordered_map<uint32_t, std::pair<Lump, std::vector<std::byte> > > bsppp::BSP::stagedLumps
protected

Definition at line 266 of file BSP.h.

◆ stagedMapRevision

uint32_t bsppp::BSP::stagedMapRevision {}
protected

Definition at line 268 of file BSP.h.

◆ stagedVersion

uint32_t bsppp::BSP::stagedVersion {}
protected

Definition at line 265 of file BSP.h.


The documentation for this class was generated from the following files: