-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfxBuff.cpp
314 lines (306 loc) · 5.96 KB
/
fxBuff.cpp
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#include "stdafx.h"
#include "unit.h"
#include "player.h"
extern void (__cdecl *noxRasterPoint)(int X,int Y);
extern void (__cdecl *noxRasterPointRel)(int X,int Y);
extern void (__cdecl *noxRasterDrawLines)();
extern int (__cdecl *noxSetRectColorMB) (int);
extern DWORD *GameFlags;
FxBuffer_t *FxFirstBuffer=0;
extern BYTE **clientPlayerInfoPtr;
void FxBuffer_t::getValues(int First,int Len)
{
//åùå íå ãîòîâî
}
bool FxBuffer_t::delBlock(int Id) //óäàëÿåì áëîê
{
int State=0;
int Cnt=0;
int Free;
int Start=0;
DWORD *CntPtr=0;
for (FxBuffer_t *Buf=FxFirstBuffer;Buf!=NULL;Buf=Buf->Next)
{
Free=0;
for (DWORD *P=Buf->Data,*E=P + (Buf->Size - Buf->FreeSize) ;P<E;)
{
switch (State)
{
case 0:
if (0==*P)
{
if (Id==(Start + P- Buf->Data))
{
*P=1;// ïðîïóñê
State=3;
return true;//TODO
}
State=1;
}else if (1==*P)
{
State=1;
}
break;
case 1: // ãðóçèì ñ÷åò÷èê
CntPtr=P;
Cnt=*P;
State=2;
break;
case 2:
if (Cnt>0)
Cnt--;
else
{
State=1;
}
break;
}//switch
Start +=Buf->Size - Buf->FreeSize;
P++;
}
if (State==2)
{
if (Cnt==0) // ñúåëè ïîñëåäíèé êóñîê
{
Buf->FreeSize+=Free;
}
else if (Cnt>0 && Buf->Next!=0)
{
Buf->FreeSize+=Free;
Buf=Buf->Next;
DWORD *P=Buf->Data;
*P=1;
P++;
*P=Cnt-2;
}
}
}
return false;
}
FxBuffer_t *FxBuffer_t::addBlock(int Size,int *Id)
{
if (Size<1)
return NULL;
FxBuffer_t *Ret=0;
int FreeSize=0;
int Idx = 0;
Size+=2;
if (FxFirstBuffer==0)
{
FreeSize = (Size + 0xF)&~0xF;
Ret = (FxBuffer_t *)new byte[ 4*FreeSize + sizeof(FxBuffer_t)];
Ret->Size = FreeSize;
Ret->SelIdx = 0;
Ret->Next = 0;
Ret->FreeSize = FreeSize;
FxFirstBuffer = Ret;
}
else
{
FxBuffer_t *Buf2=0;
for (Ret = FxFirstBuffer;Ret!=NULL && Ret->FreeSize < Size;Ret=Ret->Next)
{
Idx += Ret->Size;
Buf2=Ret;
}
if (Ret==NULL)
{
FreeSize = (Size + 0xF)&~0xF;
Ret = (FxBuffer_t *)new byte[ 4*FreeSize + sizeof(FxBuffer_t)];
Ret->Size = FreeSize;
Ret->SelIdx = 0;
Ret->Next = 0;
Ret->FreeSize = FreeSize;
Buf2->Next = Ret;
}
}
Idx += Ret->Size - Ret->FreeSize;
Ret->FreeSize -= Size;
Ret->addItem(0);
Ret->addItem(Size-2);
*Id=Idx;
return Ret;
}
// åùå íàäî îòíîñèòåëüíî êóðñîðà ñäåëàòü
void FxBuffer_t::drawBuffers()
{
int State=0;
int Cnt=0;
int OfsX=0,OfsY=0;
int X1,Y1,X2,Y2;
int Idx=0;
char Stop[sizeof(FxBuffer_t)]={0};
FxBuffer_t *StopBuf=(FxBuffer_t *)&Stop;
for (FxBuffer_t *Buf=FxFirstBuffer;Buf!=NULL;Buf=Buf->Next)
{
for (DWORD *P=Buf->Data,*E=P + (Buf->Size - Buf->FreeSize) ;P<E; Idx++)
{
switch(State)///!!! íå ìåíåå 2õ
{
case 0: // ÷èòàåì äàííûå
State=1 + *(P++);
break;
case 1:
State = 0;
P++;
break;
case 2:
Cnt=*(P++);
State = 103;
break;
case 103:
if ((--Cnt)==0)
State = 0;
P++;
break;
case 9:
noxSetRectColorMB(*(P++));
State = 0;
break;
case 10: // íà÷èíàåì ðèñîâàòü ëèíèþ
State=105;
Cnt=*(P++);
break;
case 105: // ñîâñåì ïåðâàÿ òî÷êà X
if (--Cnt==0)
State = 0;
else
State = 106;
X1 = *((int*)(P++)) - OfsX;
break;
case 106: // ñîâñåì ïåðâàÿ òî÷êà Y
if (--Cnt==0)
State = 0;
else
State = 107;
Y1 = *((int*)(P++)) - OfsY;
break;
case 107: // ñîâñåì ïåðâàÿ òî÷êà X
if (--Cnt==0)
State = 0;
else
State = 108;
X2 = *((int*)(P++)) - OfsX;
break;
case 108: // ñîâñåì ïåðâàÿ òî÷êà Y
if (--Cnt==0)
State = 0;
else
State = 107;
Y2 = *((int*)(P++)) - OfsY;
noxRasterPoint(X1,Y1);
noxRasterPoint(X2,Y2);
noxRasterDrawLines();
X1=X2;Y1=Y2;
break;
case 11:// íóëåâîå ñìåùåíèå
OfsX=0;
OfsY=0;
State = 0;
break;
case 12:// ñìåùåíèå îò âüþïîðòà
OfsX=*noxScreenX;
OfsY=*noxScreenY;
State = 0;
break;
case 13:// îñòàíîâêà
Buf=StopBuf;
P=E;
State = 0;
break;
case 14: // ñäâèã [ñêîëüêî, dX, dY , îòêóäà, êóäà], ïðîâåðèòü
State=110;
Cnt=*(P++);
break;
case 110:
State=111;
Y1=*(P++);
break;
case 111:
State=112;
Y2=*(P++);
break;
case 112:
State=113;
X1=*(P++);
break;
case 113:
State = 0;
X2=*(P++);
{
FxBuffer_t *db=FxFirstBuffer;
DWORD *sp=0,*dp=0;
for( int Base=0 ; db!=NULL ; db= db->Next,Base+=db->Size)
{
if ( X1 > Base && X1 < Base + db->Size ) // â ýòîì áóôåðå ëåæèò èñòî÷íèê
{
X1 -=Base;
sp = db->Data;
}
if ( X2 > Base && X2 < Base + db->Size ) // â ýòîì áóôåðå ëåæèò íàçíà÷åíèå
{
X2 -=Base;
dp = db->Data;
}
}
while ( Cnt-- )
{
*dp = *sp + Y1;
dp++;
sp++;
if (!Cnt--)
break;
*dp = *sp + Y2;
dp++;
sp++;
}
State=0;
}
break;
case 15: //line to cursor
X1 = *((int*)(P++));
State=114;
break;
case 114:
Y1 = *((int*)(P++));
State=115;
break;
case 115:
if ((*GameFlags&1)==0) //client
{
int *pI=(int*)(*clientPlayerInfoPtr+0x8EC);
X2=*(pI++);
Y2=*pI;
}
else
{
X2=-1;
for (bigUnitStruct *Pl=playerFirstUnit();Pl!=NULL;Pl=playerNextUnit(Pl))
{
char *Uc=(char *)Pl->unitController;
Uc=*((char **)(Uc+0x114));
if (Uc[0x810]!=*P)
continue;
int *pI=(int*)(Uc+0x8EC);
X2=*(pI++);
Y2=*pI;
break;
}
}
P++;
if (X2>0)
{
noxRasterPoint(X1 - OfsX,Y1 - OfsY);
noxRasterPoint(X2 - OfsX,Y2 - OfsY);
noxRasterDrawLines();
}
State=0;
break;
case 16:
default:
P++;
break;
}
}
}
}