Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <string>
- struct lump_t {
- int fileofs;
- int filelen;
- int version;
- char fourCC[4];
- };
- struct dheader_t {
- int ident;
- int version;
- lump_t lumps[64];
- int mapRevision;
- };
- dheader_t* LoadBSP(const std::string& path, BYTE** fileData) {
- HANDLE hFile = CreateFile(path.c_str(), GENERIC_READ, NULL, NULL, OPEN_ALWAYS, NULL, NULL);
- if (hFile == INVALID_HANDLE_VALUE) {
- return nullptr;
- }
- DWORD dwSize = GetFileSize(hFile, NULL);
- if (!dwSize) {
- CloseHandle(hFile);
- return nullptr;
- }
- printf("File Size: %i bytes\n", (int)dwSize);
- if (!(*fileData)) {
- *fileData = new BYTE[dwSize];
- }
- DWORD dwReadSize = NULL;
- if (!ReadFile(hFile, *fileData, dwSize, &dwReadSize, NULL)) {
- CloseHandle(hFile);
- delete *fileData;
- return nullptr;
- }
- return (dheader_t*)*fileData;
- }
- int main() {
- SetConsoleTitle("BSP Parser");
- BYTE* pDataBSP = nullptr;
- dheader_t* header = LoadBSP("D:\\Games\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo\\maps\\de_dust2.bsp", &pDataBSP);
- printf("ident = %i\n", header->ident);
- printf("version = %i\n", header->version);
- printf("mapRevision = %i\n", header->mapRevision);
- printf("\n");
- system("pause");
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment