-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSearchInstance.h
226 lines (200 loc) · 4.74 KB
/
SearchInstance.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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
#ifndef __ASHITA_SearchInstance_H_INCLUDED__
#define __ASHITA_SearchInstance_H_INCLUDED__
#if defined(_MSC_VER) && (_MSC_VER >= 1020)
#pragma once
#endif
#include "C:\Ashita 4\plugins\sdk\Ashita.h"
#include "InventoryCache.h"
struct ItemInfo_t
{
bool IsKeyItem;
uint16_t Id;
std::string Name;
};
struct SearchItem_t
{
uint16_t ItemId;
uint16_t KeyItemId;
uint16_t SlipId;
uint16_t SlipOffset;
SearchItem_t()
: ItemId(0)
, KeyItemId(65535)
, SlipId(0)
, SlipOffset(0)
{}
SearchItem_t(uint16_t keyItem)
: ItemId(0)
, KeyItemId(keyItem)
, SlipId(0)
, SlipOffset(0)
{}
};
struct StorageSlip_t
{
uint16_t ItemId;
uint16_t StoredItem[192];
};
struct SearchResult_t
{
CharacterIdentifier_t Character;
uint16_t Id;
IItem* Resource;
uint16_t KeyItem;
const char* KeyItemResource;
uint32_t Total;
uint32_t Count[CONTAINER_MAX];
int16_t StorageSlipContainer;
};
struct ItemStub_t
{
uint16_t KeyItem;
const char* KeyItemResource;
uint32_t Count;
IItem* pResource;
ItemStub_t(IItem* resource, uint32_t count)
: pResource(resource)
, Count(count)
, KeyItem(65535)
, KeyItemResource(nullptr)
{}
ItemStub_t(uint16_t keyItem, const char* keyResource)
: pResource(nullptr)
, Count(1)
, KeyItem(keyItem)
, KeyItemResource(keyResource)
{}
bool operator==(const ItemStub_t& other)
{
if (KeyItem == 65535)
return (pResource == other.pResource);
else
return (KeyItem == other.KeyItem);
}
};
class SearchTable
{
char** ColumnHeaders;
char** RowHeaders;
int Columns;
int Rows;
int32_t** Data;
public:
SearchTable(int rows, int columns)
: Rows(rows)
, Columns(columns)
{
ColumnHeaders = new char*[columns];
RowHeaders = new char*[rows];
Data = new int32_t*[rows];
for (int x = 0; x < Columns; x++)
{
ColumnHeaders[x] = new char[256];
}
for (int x = 0; x < Rows; x++)
{
RowHeaders[x] = new char[256];
Data[x] = new int32_t[columns];
}
}
~SearchTable()
{
for (int x = 0; x < Columns; x++)
{
delete[] ColumnHeaders[x];
}
for (int x = 0; x < Rows; x++)
{
delete[] RowHeaders[x];
delete[] Data[x];
}
delete[] ColumnHeaders;
delete[] RowHeaders;
delete[] Data;
}
const char* GetColumnHeader(int x)
{
if ((x < 0) || (x >= Columns))
return nullptr;
return ColumnHeaders[x];
}
int GetColumnCount()
{
return Columns;
}
int GetRowCount()
{
return Rows;
}
const char* GetRowHeader(int x)
{
if ((x < 0) || (x >= Rows))
return nullptr;
return RowHeaders[x];
}
int32_t GetTableData(int row, int column)
{
if ((row < 0) || (row >= Rows) || (column < 0) || (column >= Columns))
{
return 0;
}
return Data[row][column];
}
void SetColumnHeader(int x, const char* data)
{
if ((x < 0) || (x >= Columns))
return;
strcpy_s(ColumnHeaders[x], 256, data);
}
void SetRowHeader(int x, const char* data)
{
if ((x < 0) || (x >= Rows))
return;
strcpy_s(RowHeaders[x], 256, data);
}
void SetTableData(int row, int column, int32_t data)
{
if ((row < 0) || (row >= Rows) || (column < 0) || (column >= Columns))
{
return;
}
Data[row][column] = data;
}
};
enum class SearchDisplayMode
{
Unsorted,
LocationItem,
LocationCharacter,
CharacterItem
};
class SearchInstance
{
private:
std::vector<SearchResult_t> mResultVector;
SearchDisplayMode mSearchMode;
SearchTable* pSearchTable;
std::vector<CharacterIdentifier_t> mCharacters;
std::vector<ItemInfo_t> mItemResources;
std::vector<int32_t> mLocationIndices;
int mCharacterCount;
int mItemTotal;
int mItemCount;
int mContainerCount;
bool mDuplicateItemName;
bool mDuplicatePlayerName;
std::vector<std::string> mSearchTerms;
public:
SearchInstance(std::vector<SearchResult_t> results, std::vector<std::string> searchTerms, int maxResults);
~SearchInstance();
void SetSearchMode(SearchDisplayMode mode);
void BuildSearchTable();
int GetCharacterCount();
int GetItemCount();
int GetContainerCount();
int GetItemTotal();
std::vector<std::string> GetQuery();
std::vector<SearchResult_t> GetResultVector();
SearchTable* GetResultTable();
};
#endif