-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path2da.h
207 lines (182 loc) · 5.43 KB
/
2da.h
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// 2da.h: interface for the C2da class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_2DA_H__D3555E4F_E3B8_492D_ABEA_638AF2B91177__INCLUDED_)
#define AFX_2DA_H__D3555E4F_E3B8_492D_ABEA_638AF2B91177__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#include "chitem.h"
class CStringMapCompiler: public CStringMapToCompiler
{
public:
~CStringMapCompiler()
{
CString key;
compiler_data value;
POSITION pos;
pos=GetStartPosition();
while(pos)
{
GetNextAssoc(pos, key, value);
if(value.parameters)
{
delete [] value.parameters;
value.parameters=NULL;
}
}
}
bool LookupIgnoreCase(CString key, compiler_data &value)
{
POSITION pos;
pos=GetStartPosition();
while(pos)
{
CString key2;
GetNextAssoc(pos, key2, value);
if(key2.CompareNoCase(key))
{
return true;
}
}
return false;
}
bool ReverseLookup(int data, int paramcount, CString &key, compiler_data &value)
{
POSITION pos;
pos=GetStartPosition();
while(pos)
{
GetNextAssoc(pos, key, value);
if(value.opcode==data)
{
if(value.parnumx==paramcount)
{
return true;
}
}
}
return false;
}
bool ReverseLookup(int data, CString &key, compiler_data &value)
{
POSITION pos;
pos=GetStartPosition();
while(pos)
{
GetNextAssoc(pos, key, value);
if(value.opcode==data)
{
return true;
}
}
return false;
}
};
class C2da
{
public:
C2da();
virtual ~C2da();
void new_2da();
void AddRow(int row, CString label, CString def);
int AddColumn(int col, CString label, CString def);
int RemoveRow(int row);
int RemoveColumn(int col);
int Read2DAFromFile(int fhandle, int ml);
int Extract2DAFromSQLFile(int fhandle, int length, CString filename, int defcols);
int Write2DAToFile(int fhandle);
int CopyColumn(int col);
int CopyRow(int row);
int PasteColumn(int col);
int PasteRow(int row);
void OrderByColumn(int column, int integers);
CString GetValue(int row, int col);
CString FindValue(CString key, int col);
inline void killcopyrow()
{
if(copyrow) delete [] copyrow;
copyrow=0;
crows=0;
}
inline void killcopycol()
{
if(copycol) delete [] copycol;
copycol=0;
ccols=0;
}
CString header;
CString defvalue;
int rows;
int cols;
CString *copyrow;
int crows;
CString *copycol;
int ccols;
CString *collabels;
CPtrList *data;
};
class Cids
{
public:
Cids();
virtual ~Cids();
void new_ids();
void AddRow(int row, CString label, CString def);
int RemoveRow(int row);
int ReadIDSFromFile(int fhandle, int ml);
int WriteIDSToFile(int fhandle);
CString header;
bool label;
int rows;
CPtrList *data;
};
#define MUSCOLUMN 3 //the number of columns
class Cmus
{
public:
Cmus();
virtual ~Cmus();
void new_mus();
void AddRow(int row, CString arg1, CString arg2, CString arg3);
int RemoveRow(int row);
int ReadMusFromFile(int fhandle, int ml);
int WriteMusToFile(int fhandle);
CString internal;
int rows;
CPtrList *data;
};
extern CStringMapCompiler action_data;
extern CStringMapCompiler trigger_data;
extern C2da the_2da;
extern Cids the_ids;
extern Cmus the_mus;
extern long creature_strrefs[SND_SLOT_COUNT]; //for copy/paste operation (persistent)
int Write2daArrayToFile(CString daname, CStringMapArray &refs, CString *columnames, int columns);
int Write2daMapToFile(CString daname, CStringMapInt &refs, CString columname);
int Write2daListToFile(CString daname, CStringList &refs, CString columname);
int ReadWeapProfs(loc_entry entry);
int Read2da(loc_entry entry, CStringList &refs);
int Read2daRow(loc_entry entry, CStringList &refs, int first);
int Read2daStringFromFile(int fhandle, CString2List &refs, int length, int column);
int Read2daString(loc_entry entry, CString2List &refs, int startcolumn);
int Read2daStrref(loc_entry entry, CIntMapInt &refs, int column);
int Read2daArray(loc_entry entry, CStringMapArray &refs, int columns); //maximum 3
int Read2daInt(loc_entry entry, CStringMapInt &refs, int removeall);
int Read2daResRef(loc_entry entry, CIntMapString &refs, int removeall, int skipcolumn=0);
int Read2daField(CString daname, int line, int column);
int Read2daColumn(loc_entry entry, CStringList &refs, int column, bool caps);
int ReadIds(loc_entry entry, CStringList &refs, int add, bool clear);
int ReadSongIds(loc_entry entry, CString2List &refs);
int ReadIds2(loc_entry entry, CString *refs, int maxindex);
int ReadIds3(loc_entry entry, CString *refs, int maxindex, CStringMapCompiler &atdata, int trigger_or_action);
int ReadIds4(loc_entry entry, CStringMapInt &refs);
int ReadIdsFromFile(int fhandle, CStringList &refs, int add, int length);
void ReadBeastIni(CStringList &beastnames, CStringList &beastkillvars);
int read_effect_descs(); // setting up opcode descriptions
int mygetc(FILE *fpoi);
int skip_string(FILE *fpoi, char chr);
void init_read(int esc);
int read_until(char c, FILE *fpoi, CString &ret, int length=65535);
int add_compiler_data(CString prototype, int cnt, CStringMapCompiler &atdata, int trigger_or_action);
#endif // !defined(AFX_2DA_H__D3555E4F_E3B8_492D_ABEA_638AF2B91177__INCLUDED_)