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)
- {
- printf("ERROR: Failed to load \"%s\"\n", filename);
- return;
- }
- gzread(MapFile, &header, sizeof(ogzHeader));
- }
- void SauerMap::PrintMapData()
- {
- printf("header %s\n",header.magic);
- printf("version %i\n", header.version);
- printf("headersize %i\n", header.headersize);
- printf("worldsize %i\n", header.worldsize);
- printf("numents %i\n", header.numents);
- printf("numpvs %i\n", header.numpvs);
- printf("lightmaps %i\n", header.lightmaps);
- printf("blendmap %i\n", header.blendmap);
- printf("lightprecision %i\n", header.lightprecision);
- printf("lighterror %i\n", header.lighterror);
- printf("lightlod %i\n", header.lightlod);
- printf("maptitle %s\n", header.maptitle);
- }
- 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();
- printf("SUCCESS %s is a cube2 map!\n", argv[1]);
- }else printf("ERROR: %s is not a valid Cube 2 map\n", argv[1]);
- }else printf("ERROR: Usage c2mapreader.exe <mapname>\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement