2007-06-30 19:24:05 +03:00
|
|
|
#ifndef CLODHANDLER_H
|
|
|
|
#define CLODHANDLER_H
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <fstream>
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include "zlib.h"
|
2007-08-30 13:11:53 +03:00
|
|
|
#include "../nodrze.h"
|
2008-01-09 19:21:31 +02:00
|
|
|
#include "SDL.h"
|
|
|
|
|
|
|
|
|
|
|
|
class CDefHandler;
|
|
|
|
class CDefEssential;
|
2007-07-01 15:54:59 +03:00
|
|
|
|
|
|
|
enum Epcxformat {PCX8B, PCX24B};
|
2007-06-30 19:24:05 +03:00
|
|
|
|
|
|
|
namespace NLoadHandlerHelp
|
|
|
|
{
|
|
|
|
const int dmHelp=0, dmNoExtractingMask=1;
|
|
|
|
//std::string P1,P2,CurDir;
|
|
|
|
const int fCHUNK = 50000;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Entry
|
|
|
|
{
|
|
|
|
unsigned char name[12], //filename
|
|
|
|
hlam_1[4], //
|
|
|
|
hlam_2[4]; //
|
2007-07-07 14:09:25 +03:00
|
|
|
std::string nameStr;
|
2007-06-30 19:24:05 +03:00
|
|
|
int offset, //from beginning
|
|
|
|
realSize, //size without compression
|
|
|
|
size; //and with
|
2007-07-07 14:09:25 +03:00
|
|
|
bool operator<(const Entry & comp) const
|
|
|
|
{
|
2007-07-17 23:51:49 +03:00
|
|
|
return nameStr<comp.nameStr;
|
2007-07-07 14:09:25 +03:00
|
|
|
}
|
|
|
|
Entry(std::string con): nameStr(con){};
|
2007-07-17 23:51:49 +03:00
|
|
|
//Entry(unsigned char ): nameStr(con){};
|
2007-07-07 14:09:25 +03:00
|
|
|
Entry(){};
|
2007-06-30 19:24:05 +03:00
|
|
|
};
|
2007-07-01 15:54:59 +03:00
|
|
|
class CPCXConv
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
unsigned char * pcx, *bmp;
|
|
|
|
int pcxs, bmps;
|
|
|
|
void fromFile(std::string path);
|
|
|
|
void saveBMP(std::string path);
|
|
|
|
void openPCX(char * PCX, int len);
|
|
|
|
void openPCX();
|
|
|
|
void convert();
|
2007-07-08 18:19:00 +03:00
|
|
|
SDL_Surface * getSurface();
|
2007-07-01 15:54:59 +03:00
|
|
|
CPCXConv(){pcx=bmp=NULL;pcxs=bmps=0;};
|
2007-12-23 18:46:33 +02:00
|
|
|
~CPCXConv(){if (pcxs) delete[] pcx; if(bmps) delete[] bmp;}
|
2007-07-01 15:54:59 +03:00
|
|
|
};
|
2007-06-30 19:24:05 +03:00
|
|
|
class CLodHandler
|
|
|
|
{
|
2007-07-07 19:04:15 +03:00
|
|
|
private:
|
2008-01-20 17:26:34 +02:00
|
|
|
FILE* FLOD;
|
2007-06-30 19:24:05 +03:00
|
|
|
public:
|
2007-07-17 23:51:49 +03:00
|
|
|
nodrze<Entry> entries;
|
2007-06-30 19:24:05 +03:00
|
|
|
unsigned int totalFiles;
|
|
|
|
|
|
|
|
int readNormalNr (unsigned char* bufor, int bytCon, bool cyclic=false); //lod header reading helper
|
|
|
|
int decompress (unsigned char * source, int size, int realSize, std::ofstream & dest); //main decompression function
|
|
|
|
int decompress (unsigned char * source, int size, int realSize, std::string & dest); //main decompression function
|
|
|
|
int infm(FILE *source, FILE *dest, int wBits = 15); //zlib handler
|
2007-07-07 14:09:25 +03:00
|
|
|
int infs(unsigned char * in, int size, int realSize, std::ofstream & out, int wBits=15); //zlib fast handler
|
|
|
|
int infs2(unsigned char * in, int size, int realSize, unsigned char*& out, int wBits=15); //zlib fast handler
|
2007-07-09 08:57:30 +03:00
|
|
|
std::vector<CDefHandler *> extractManyFiles(std::vector<std::string> defNamesIn); //extrats given files (defs only)
|
|
|
|
CDefHandler * giveDef(std::string defName);
|
2007-10-17 01:39:11 +03:00
|
|
|
CDefEssential * giveDefEss(std::string defName);
|
2007-07-16 17:42:44 +03:00
|
|
|
std::string getTextFile(std::string name); //extracts one file
|
2007-06-30 19:24:05 +03:00
|
|
|
void extract(std::string FName);
|
2007-07-07 19:04:15 +03:00
|
|
|
void extractFile(std::string FName, std::string name); //extracts a specific file
|
2007-06-30 19:24:05 +03:00
|
|
|
void init(std::string lodFile);
|
2007-07-09 08:57:30 +03:00
|
|
|
SDL_Surface * loadBitmap(std::string fname);
|
2007-06-30 19:24:05 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //CLODHANDLER_H
|