Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <string.h>
- #include "cubemap.h"
- #ifndef __CUBEMAP_H
- #define __CUBEMAP_H
- #include <zlib.h>
- typedef unsigned char uchar;
- struct ogzHeader // map file format header
- {
- char magic[4]; // "OCTA"
- int version; // any >8bit quantity is little endian
- int headersize; // sizeof(header)
- int worldsize;
- int numents;
- int numpvs;
- int lightmaps;
- int lightprecision, lighterror, lightlod;
- uchar ambient;
- uchar watercolour[3];
- uchar blendmap;
- uchar lerpangle, lerpsubdiv, lerpsubdivsize;
- uchar bumperror;
- uchar skylight[3];
- uchar lavacolour[3];
- uchar waterfallcolour[3];
- uchar reserved[10];
- char maptitle[128];
- };
- class SauerMap
- {
- public:
- SauerMap(char *);
- void PrintMapData();
- char *GetMagic();
- private:
- ogzHeader header;
- gzFile MapFile;
- };
- #endif
- SauerMap::SauerMap(char *filename)
- {
- MapFile = gzopen(filename, "r");
- if(!MapFile)
- {
- std::cout << "ERROR: Failed to load \"" << filename << "\"" << std::endl;
- return;
- }
- gzread(MapFile, &header, sizeof(ogzHeader));
- }
- void SauerMap::PrintMapData()
- {
- std::cout << "header " << header.magic << std::endl;
- std::cout << "version " << header.version << std::endl;
- std::cout << "headersize " << header.headersize << std::endl;
- std::cout << "worldsize " << header.worldsize << std::endl;
- std::cout << "numents " << header.numents << std::endl;
- std::cout << "numpvs " << header.numpvs << std::endl;
- std::cout << "lightmaps " << header.lightmaps << std::endl;
- std::cout << "blendmap " << header.blendmap << std::endl;
- std::cout << "lightprecision " << header.lightprecision << std::endl;
- std::cout << "lighterror " << header.lighterror << std::endl;
- std::cout << "lightlod " << header.lightlod << std::endl;
- std::cout << "ambient " << header.ambient << std::endl;
- std::cout << "watercolour " << header.watercolour << std::endl;
- std::cout << "lerpangle " << header.lerpangle << std::endl;
- std::cout << "lerpsubdiv " << header.lerpsubdiv << std::endl;
- std::cout << "lerpsubdivsize " << header.lerpsubdivsize << std::endl;
- std::cout << "maptitle " << header.maptitle << std::endl;
- }
- char *SauerMap::GetMagic()
- {
- return header.magic;
- };
- int main(int argc, char *argv[])
- {
- if(argc > 1){
- SauerMap ch(argv[1]);
- if(strcmp(ch.GetMagic(),"OCTA"))
- {
- ch.PrintMapData();
- std::cout<<"SUCCESS "<< argv[1] << " is a cube2 map " << std::endl;
- }else std::cout<<"ERROR: "<< argv[1] <<" is not a valid Cube 2 map" << std::endl;
- }else std::cout<<"ERROR: Usage c2mapreader.exe <mapname>"<<std::endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement