[dad864]: / tbg.h  Maximize  Restore  History

Download this file

178 lines (157 with data), 3.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
// tbg.h: interface for the Ctbg class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_TBG_H__5F1252F4_705E_44C1_83B3_8F64BF30969A__INCLUDED_)
#define AFX_TBG_H__5F1252F4_705E_44C1_83B3_8F64BF30969A__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef struct
{
char signature[4]; //IAP
long unused;
long tbgcount;
long othercount;
unsigned char genre; //we don't care about this too much
long totallen;
} iap_header;
typedef struct
{
char signature[4]; //PK<ver>
short headersize; //20
char unused[20];
} zip_header;
typedef struct
{
long nameoffset;
long namelength;
long launchflag;
long fileoffset;
long filelength;
} iap_file_header;
class Ctbg
{
public:
Ctbg();
virtual ~Ctbg();
int WriteIap(int fhandle);
int WriteZip(int fhandle);
int OutputTP2(CString outfilename);
int ExportFile(int filetype, CString filepath, int type);
int Readtbg(CString filepath, CStringList &filelist);
void new_iap();
//new feature: modify iap
//new feature: list of postprocessed files
int read_iap(int fhandle, int onlyopen, CStringList &filelist);
int AddTbgFile(int pos,CString &newname);
int AddOtherFile(int pos, CString &newname);
int AllocateHeaders(int tbgnum, int othernum);
tbg4_header header;
tbgn_header tbgnheader;
iap_header iapheader;
zip_header zipheader;
int revision;
tbg_tlk_reference *tlkentries;
unsigned long *strrefs;
long *ascii;
char *filedata;
char *textdata;
iap_file_header *iapfileheaders;
CString *m_tbgnames, *m_othernames;
int tlkentrycount, strrefcount, asciicount;
long textdatasize;
int actfilecount, iapfilecount;
int tbgnamecount, othernamecount;
private:
//strref collectors
int collect_itemrefs();
int collect_spellrefs();
int collect_storerefs();
int collect_effectrefs(); //only 0 or 1 effect string possible, we still export it
int collect_arearefs();
int collect_creaturerefs(int alternate);
int collect_worldmaprefs();
int collect_chuirefs();
int collect_srcrefs();
int collect_dlgrefs();
int collect_prorefs();
int AddToFile(int fhandle, CString filename, CString internalname, int ml);
int ImportFile();
int get_genre();
int get_strref(long offset, long length, CString &text);
int read_tbg(int fhandle, int maxlen);
int patch_baldur_gam(int fhandle);
inline void KillFileData()
{
if(filedata)
{
delete [] filedata;
filedata=NULL;
}
}
inline void KillTlkEntries()
{
if(tlkentries)
{
delete [] tlkentries;
tlkentries=NULL;
}
tlkentrycount=0;
}
inline void KillStrrefs()
{
if(strrefs)
{
delete [] strrefs;
strrefs=NULL;
}
strrefcount=0;
}
inline void KillAscii()
{
if(ascii)
{
delete [] ascii;
ascii=NULL;
}
ascii=0;
}
inline void KillTextData()
{
if(textdata)
{
delete [] textdata;
textdata=NULL;
}
textdatasize=0;
}
inline void KillIapFileHeaders()
{
if(iapfileheaders)
{
delete [] iapfileheaders;
iapfileheaders=NULL;
}
actfilecount=iapfilecount=0;
}
inline void KillTbgFilenames()
{
if(m_tbgnames)
{
delete [] m_tbgnames;
m_tbgnames=NULL;
}
tbgnamecount=0;
}
inline void KillOtherFilenames()
{
if(m_othernames)
{
delete [] m_othernames;
m_othernames=NULL;
}
othernamecount=0;
}
};
void ExportTBG(CWnd *pwnd, int filetype, int type);
#endif // !defined(AFX_TBG_H__5F1252F4_705E_44C1_83B3_8F64BF30969A__INCLUDED_)